Smartos Ethernet protocol stack tinyip

Source: Internet
Author: User

How can I do this without Ethernet for Iot!
Based on enc28j60, our team independently implemented the Ethernet protocol stack tinyip. Currently, ARP, ICMP, TCP, UDP, and DHCP are supported, and only one DNS is complete.
Tinyip has a built-in data buffer. After receiving the data, enc28j60 puts it into the buffer zone, tinyip then splits and restructured the data based on the Ethernet/arp/IP/ICMP/TCP/UDP/DHCP header structure to execute the business logic.
Tinyip is completely independently completed by our team. If we do not copy any of our existing Ethernet protocols (such as UIP/LWIP), we are afraid to refer to any of them. The Protocol structures are open as international standards, we only need to implement it according to the protocol.
Despise those who say they are plagiarized if they cannot!

#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");}

Chip gd32f103vk/gd32f103ve/stm32f103ve
The tinyip class generates random MAC addresses and initial IP addresses 192.168.0.x Based on the System ID. The last byte of the IP address is the first byte of the System ID.
After DHCP is enabled, the IP address is automatically obtained.
ARP must be implemented. Otherwise, the Mac corresponding to your IP address cannot be found and communication fails.
Supports attaching Ping, TCP, and UDP events.

All Ethernet functions are enabled. The firmware Rom in RTM is about 9 KB.

End.

Turn stone brother

Smartos Ethernet protocol stack tinyip

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.