日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

SmartOS之以太网精简协议栈TinyIP

發布時間:2025/7/14 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SmartOS之以太网精简协议栈TinyIP 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

做物聯網,沒有以太網怎么能行!
基于Enc28j60,我們團隊獨立實現了以太網精簡協議棧TinyIP,目前支持ARP/ICMP/TCP/UDP/DHCP,還缺一個DNS就完整了。
TinyIP內置一個數據緩沖區,Enc28j60收到數據以后,放入緩沖區,然后TinyIP內部開始根據Ethernet/ARP/IP/ICMP/TCP/UDP/DHCP頭部結構體對數據進行拆分和重組,執行業務邏輯。
TinyIP百分百是我們團隊獨立完成,沒有抄襲那怕參考任何一款已有以太網協議(例如uip/lwip),各種協議結構作為國際標準是公開的,我們只需要按照協議去實現即可。
鄙視那些自己做不到就說別人抄襲的人!

#include "Sys.h" #include "Enc28j60.h" #include "SerialPort.h" #include "TinyIP/TinyIP.h" #include "conf.h" Spi* spi; Enc28j60* enc; TinyIP* tip; void OnPing(TinyIP* tip, ICMP_HEADER* icmp, byte* buf, uint len) { ????debug_printf("Ping From "); ????TinyIP::ShowIP(tip->RemoteIP); ????debug_printf(" with Payload=%d\r\n", len); } void OnUdpReceived(TinyIP* tip, UDP_HEADER* udp, byte* buf, uint len) { ????debug_printf("Udp From "); ????TinyIP::ShowIP(tip->RemoteIP); ????debug_printf(":%d with Payload=%d??", tip->RemotePort, len); ????TinyIP::ShowData(buf, len); ????debug_printf(" \r\n"); } void OnTcpAccepted(TinyIP* tip, TCP_HEADER* tcp, byte* buf, uint len) { ????debug_printf("TcpAccepted From "); ????TinyIP::ShowIP(tip->RemoteIP); ????debug_printf(":%d with Payload=%d\r\n", tip->RemotePort, len); } void OnTcpDisconnected(TinyIP* tip, TCP_HEADER* tcp, byte* buf, uint len) { ????debug_printf("TcpDisconnected From "); ????TinyIP::ShowIP(tip->RemoteIP); ????debug_printf(":%d with Payload=%d\r\n", tip->RemotePort, len); } void OnTcpReceived(TinyIP* tip, TCP_HEADER* tcp, byte* buf, uint len) { ????debug_printf("TcpReceived From "); ????TinyIP::ShowIP(tip->RemoteIP); ????debug_printf(":%d with Payload=%d??", tip->RemotePort, len); ????TinyIP::ShowData(buf, len); ????debug_printf(" \r\n"); } void TestEthernet() { ????debug_printf("\r\n\r\n"); ????debug_printf("TestEthernet Start......\r\n"); ????spi = new Spi(SPI_3); ????enc = new Enc28j60(spi); ????tip = new TinyIP(enc); ????tip->UseDHCP = true; ????tip->Init(); ???? ????tip->OnPing = OnPing; ????tip->OnUdpReceived = OnUdpReceived; ????tip->OnTcpAccepted = OnTcpAccepted; ????tip->OnTcpDisconnected = OnTcpDisconnected; ????tip->OnTcpReceived = OnTcpReceived; ????debug_printf("\r\n TestEthernet Finish!\r\n"); }

芯片GD32F103VK/GD32F103VE/STM32F103VE
TinyIP類內部根據系統ID生成隨機的MAC地址和初始IP地址192.168.0.x,IP最后一字節就是系統ID第一字節。
開啟DHCP后,將會自動獲取IP地址。
必須實現ARP協議,否則別人找不到你這個IP所對應的MAC,進而無法通信。
支持Ping/TCP/UDP多種必要事件掛載。

以太網所有功能全開,RTM下固件ROM大概9k。

End.

                轉石頭大哥

轉載于:https://www.cnblogs.com/Ph-one/p/3960961.html

總結

以上是生活随笔為你收集整理的SmartOS之以太网精简协议栈TinyIP的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。