| In recent years,computer hardware capabilities have been continuously improved,and many fields such as the Internet of Things and artificial intelligence have also made considerable progress.Among them,embedded Internet technology research has also achieved certain innovative breakthroughs.However,the traditional TCP/IP protocol stack has a large number of protocols and takes up a lot of memory.Many embedded devices cannot meet their demanding resource requirements.Although the existing lightweight network protocol stack occupies less memory,it has a specific application environment and lacks implementation.Some protocols and neglect the design of the data buffer and other issues,which also means that the existing lightweight network protocol stack cannot be used directly.Based on this background,this paper designs a lightweight network protocol stack architecture for a domestic OS and proposes a tailoring scheme based on the traditional TCP/IP protocol stack.At the same time,the data buffer is reconstructed and applied to the UDP module.The main research work of this paper is as follows:(1)A TCP/IP protocol stack tailoring scheme suitable for a localized OS is proposed.Researched and analyzed the existing lightweight protocol stack architecture.Aiming at the main problems existing in the existing lightweight protocol stack,a lightweight network protocol stack architecture suitable for localization of a certain OS was designed and used in traditional TCP/IP.A tailoring scheme is proposed on the basis of the protocol stack.Retain the application layer protocol to be implemented and all related lower layer protocols,cut some unused functions in the protocol,and improve the performance of some protocols.The tailoring scheme not only satisfies the high reliability and strong real-time requirements of a domestic OS for embedded systems,but also reduces the storage space occupation of embedded devices to the greatest extent.(2)Reconstruction and realization of data buffer.By reconstructing the traditional data buffer to save the user data transmitted between the process and the network interface.The reconstructed data buffer dBuf draws on the ideas of the packet buffer pbuf and the memory cache mbuf,while inheriting the advantages of both,and improving their shortcomings,so that the reconstructed data buffer has a simple structure and memory Reasonable design,few types and "zero copy" advantages.(3)Design and implementation of embedded UDP.In the traditional embedded UDP design,the main actions during the uplink and downlink of the datagram are the encapsulation header and the decapsulation header,which lacks effective management of UDP packets.Therefore,when designing the UDP module,the design includes the UDP control block,the UDP function module and the UDP datagram receiving and sending process,and the reconstructed data buffer is applied to the embedded UDP.This design helps the protocol stack to better manage UDP messages and facilitate the later maintenance of the UDP module.(4)Lightweight protocol stack test.After setting up the experimental environment,the data buffer dBuf and UDP modules were tested respectively.Experimental results after the dBuf test show that the reconstructed data buffer occupies less memory and can well meet the needs of allocating and releasing buffers.Compared with unused dBuf,using dBuf can improve the throughput of the protocol stack and CPU utilization.The experimental results after the UDP module test show that the UDP module not only meets the basic functions of normal transmission and reception,but also performs better in terms of high concurrency and high throughput than ordinary UDP.Finally,the overall connectivity of the protocol stack was tested,and the UDP module was applied to the TFTP module implemented by other students in the research group.The experimental results show that it can meet the basic functions of file upload and download,and then verify that the lightweight protocol stack designed in this article is in There is no problem in terms of overall connectivity. |