It was around 2006, due to the project requirements, I started to contact LwIP, a foreign open source tcp/ip protocol stack used in microcontroller systems, and took this opportunity to create my first book printed in lead type - "Embedded Network System Design - Based on the Atmel ARM7 Series". The response of this book is pretty good. Many people sent me msn (it's a pity that such a good instant messaging tool was abandoned by Microsoft, and many contacts lost contact, ) or email consultation related questions. In my original writing plan, the publication of this book is just the beginning, and I will write a second book next - a system introduction to the transplant, application, design and implementation of the ppp protocol stack contained in LwIP. But, things went against my wishes, this book was delayed, and this jump took twelve years...
If you think about it carefully, there are two main reasons for the delay in the first place: first, there is too little time to be disposable due to family, work, etc.; second, lack of sufficient knowledge and technical reserves related to the PPP protocol leads to insufficient confidence, fear and stagnation. But this incident has always been a regret for me. Twelve years are neither long nor short, but they are enough to turn the regrets in my heart into a small seed and grow into a towering tree of dreams.
Now, the world has arrived in the 20s when the epidemic is raging. My disposable time has increased, and my technical capabilities are far from comparable to those of the past. It's time for the tree of dreams to blossom and bear fruit. Looking back at the beginning, I had not even entered the industry for a few years and had limited technical capabilities. I could only stand on the shoulders of the great master to study how to transplant and use LwIP, and I didn’t even dare to touch the ppp stack. Now, if it only continued the work from more than ten years ago, then this thing would be meaningless. Based on an accurate understanding of my own technical strength, I decided to build a complete network protocol stack from scratch. Finally, over 6 months, the onps protocol stack (onps, open net protocol stack) completed the initial development and passed the internal test. More than ten years of regrets are paid today. In addition, after more than 20 years of experience, I finally have a dream of making core basic software in my heart. Now, these two dreams are also rewarded.
When the new orioles are first singing, there will inevitably be many unsatisfactory things. Open source can be shared, shared and studied with those who like their interests. Through these strict methods, it can be quickly iterated and matured quickly, and it is expected to be comparable to LwIP.
onps is an open source and fully self-developed domestic network protocol stack, suitable for resource-constrained microcontroller systems, provides complete implementation of ethernet/ppp/tcp/ip protocol family, and provides network tools such as sntp, dns, and ping. It supports DHCP dynamic IP address application in Ethernet environment, and also supports dynamic and static routing tables. The protocol stack also encapsulates implementing a Berkeley sockets layer. This layer is not designed and implemented completely according to the Berkeley sockets standard. Instead, based on my previous socket programming experience, I redeclare and define a set of common socket interface functions with the design goal of facilitating users' use and simplifying user coding:
The protocol stack simplifies some tedious operations required for traditional BSD socket programming, and changes some unnecessary operation details to the underlying implementation, such as select/poll model, blocking and non-blocking read and write operations. Simplification does not mean overturning. The basic definition, main parameters, and usage methods of socket interface functions have not changed. You can quickly get started and use onps stack sockets based on your previous experience and programming habits. There is no need to pay too much attention to the bottom of the protocol stack. Using socket API programming can fully meet the needs of complex communication applications, rather than using its customized set of interface functions to achieve the same goal, just like LwIp.
In order to adapt to the extremely abnormal memory usage of microcontroller systems, the onps protocol stack was considered to use zero copy on write at the beginning of its design. During the process of passing user-level data to the lower-level protocol, the protocol stack uses buf list linked list technology to link them together until they are sent out without any memory copying operations. In addition, the protocol stack uses buddy algorithm to provide secure and reliable dynamic memory management functions, in order to maximize memory utilization during the protocol stack operation and minimize memory fragmentation.
Unlike in the 2000s and early 1910s, when Ucosii and other rtos were not popular on a large scale in the application scenarios of microcontrollers, and front and backend systems were still popular, it has become mainstream for developers to choose to use rtos in most application scenarios. Therefore, the protocol stack did not support front-end and back-end modes at the beginning of its design, and its architectural design was based on the popular rtos (RT-Thread, ucosii/iii, etc.). The main task of protocol stack transplantation is naturally to write related Os adaptation layer function functions for different tos. Of course, if you have extremely specific application scenarios and need to port the onPS stack to a microcontroller that adopts front and backend mode, my suggestion is to retain the communication processing logic of the protocol layer under tcp/udp, and adjust the upper-level system architecture to adapt to the target system operation mode.
The onPS stack design implements a complete set of tcp/ip protocol models. From the data link layer to the IP layer, to the tcp/udp layer and the Berkeley socket layer above, and finally the user's own communication application layer, the onps stack achieves full stack coverage, which can meet most network programming needs. Its architecture is as follows: 
It can be seen that it is no different from the traditional network programming model. Users continue to use socket API to write common tcp and udp network applications. At the same time, you can also use several network tools provided by the protocol stack to perform network timing, DNS query and other operations.
| name | describe |
|---|---|
| bsd | The source file is implemented by the relevant interface function of the Berkeley sockets layer |
| ethernet | Related implementation source files for Ethernet protocol families such as ethernet-ii/arp and emac layer, dhcp client, etc. |
| include | The protocol stack header file |
| ip | The relevant implementation source files of the ip and its upper icmp/tcp/udp protocol family |
| mmu | Related implementation source files of protocol stack memory management module |
| net_tools | Network tools implement source files, such as dns query, network timing, ping, telnet, etc. |
| netif | Implement source files for network card and routing management related interfaces |
| port | Protocol stack migration related source files |
| ppp | PPP link layer related implementation source files, including implementation source files of protocol families such as lcp/ipcp/chap/pap, etc. |
| TcpServerForStackTesting | TCP server used for protocol stack testing, IDE is developed for vs2015, and the target system is win7 and above |
| test_code | PPP dialing principle verification file under linux |
The protocol stack supports mainstream ARM Cortex series MCUs and supports common IDEs such as Keil MDK and IAR. The core task of transplantation is to complete the writing and adaptation of the RTOS simulation layer. For detailed porting instructions, please refer to the article "Onps Network Protocol Stack Migration and Usage Instructions v1.0", click here to download. This description provides porting examples for two hardware platforms, STM32F103RCT6 and STM32F407VET6. Each sample is for RT-Thread and ucosii RTOS respectively. The sample project has undergone strict internal testing and can be used directly.
If you don't have much time, or the sample project does not match your target platform, you can directly refer to the general guidance document "Ops Stack Migration Manual" for protocol stack migration.
For general guidance documents for protocol stack development, please refer to the "Ops Stack API Interface Manual" and the "Ops Stack User Manual".
STM32F407VET6 platform : RT-Thread transplant sample ucos-ii transplant sample
Qinheng CH32V307 platform : Hongmeng LiteOS-M transplantation sample Free-ros transplantation sample RT-Thread transplantation sample
You can visit the official website of the onps stack at any time to obtain relevant information such as the development progress of the protocol stack, follow-up plans, the latest version, etc.
If you encounter any problems or suggestions during use, you can go to the onps stack communication community to make your suggestions or questions, and the release of the new version will also be notified immediately in the communication community.
You can also join the QQ group for online technical communication: 
Apache License 2.0 Open Source License Agreement
In order for the project to continue and expect your support, you can scan the QR code below to donate to this project through Alipay/WeChat:

