LwIP protocol stack based on embedded OS

Infineon / Mitsubishi / Fuji / Semikron / Eupec / IXYS

LwIP protocol stack based on embedded OS

Posted Date: 2024-02-04

Basic implementation ideas of PROFINET IO device protocol stack

The difficulty of the PROFINET IO protocol is that its protocol state machine is not a hierarchical upper-lower relationship, but a complex relationship. Because each state machine may have interface calls, the coupling degree is very high, and it is difficult to completely implement the protocol stack in one go. Very big.

General process of PROFINET IO device communication

For a PROFINET IO device, it is actually a protocol converter that packages the data of the connected input modules, such as AI, DI, etc., into a byte stream of the PROFINET IO protocol using the PROFINET protocol. Convert the byte stream in the PROFINET IO protocol into data of the output module, into DO, AO, etc. Therefore, we can consider decomposing the protocol stack and its protocol machine from the perspective of communication between IO devices and IO controllers.

PROFINET IO device protocol stack implementation simplified ideas

The communication protocol of PROFINET IO equipment is mainly used to complete communication with the IO controller. The communication process mainly includes: addressing process, configuration process, data interaction process and alarm process. If each link of the above communication process corresponds to a protocol machine, then you can consider using a step-by-step implementation idea and using a basic code framework to implement the above process, which can meet the basic requirements of most PROFINET IO devices. application.

Protocol stack design based on LwIP

Designing a communication protocol stack program requires functions such as memory management, task management, inter-process communication, semaphores, clocks, and timing processing. It is difficult and error-prone to start from scratch. Therefore, it is more appropriate to upgrade in an already mature code system. The LwIP framework system meets the requirements very well. As the saying goes, you can see far by standing on the shoulders of giants.

LwIP has already implemented the distribution of data link layer packets in arp.c, so you only need to add the frame processing of PROFIENT real-time message type and LLDP message type in this file to ensure that real-time data is processed first, so there is no need In addition, a layer mapping protocol machine (LMPM) is designed.


An LwIP protocol stack based on embedded OS adopts a layered architecture. As a lightweight TCPIP protocol stack, it not only includes IP, UDP, ARP and other protocols, but also implements memory management, packet management, clock, timing and other functions. , it is simply said to be the first choice for home travel and the development of new protocol stacks.

Review Editor: Huang Fei

#LwIP #protocol #stack #based #embedded