A modern embedded operating system with real-time application capabilities based on Linux improvements...

1 Introduction

Today's more popular operating system, Linux, has attracted worldwide attention in an open and free spirit, but there are still many shortcomings in applying it to an embedded real-time environment. Especially when running the kernel thread, Linux closes the interrupt, and the time uncertainty of the virtual file system for time-sharing, the lack of high-precision timers, and other problems need to be solved, so real-time improvements are made on Linux to establish a real-time The operating system with application capability is the solution of the modern embedded operating system, and it has also become a subject of increasing concern.

At present, most embedded devices have the characteristics of small storage capacity, slow processing speed, and single network application. There are problems in applying such a traditional monolithic network protocol stack in such an embedded system: First, if a certain If the sub-protocol function needs to be upgraded, the entire protocol stack must be upgraded or even all core files must be recompiled. The workflow is complicated; the second is that the protocol stack is not flexible enough to configure its content according to the actual needs of the embedded system for network communication.

2 Introduction to component technology

As early as the 1960s, the ideas of "software components" and "software assembly production lines" were proposed at the International North Atlantic Treaty Organization Software Engineering Conference. Since then, component technology has been used to realize software reuse, and "building blocks" has been used to produce software. Become a long-term dream of the software industry. However, due to technical limitations, component technology only existed as an idea for a long time. Until the emergence of CORBA, J2EE, and .NET, component technology gradually came to reality after the rise of middleware.

The biggest feature of the component is that it can be continuously reused, reducing costs and shortening the development cycle. From the perspective of component technology implementation, it stipulates a commonly used abstract "standard", that is, a set of identical structural class interfaces to achieve dynamic communication. Communication protocol introduces component technology design, which can provide code reusability, shorten the program development cycle, and make the division of labor more detailed, so that the entire protocol system has better configurability, efficiency, reusability, scalability and scalability Expressiveness. Thereby, four basic problems in network communication are solved: basic component interoperability, protocol version upgrade, implementation language independence, and transparent cross-process interoperability.

Software component technology is based on object-oriented technology, which provides a higher level of abstraction than object-oriented technology. It usually encapsulates a set of classes and calls the methods provided by the component through a fixed interface. Component technology has become the development trend of embedded operating systems and embedded application software. The component technology is used to divide the monolithic network protocol into multiple independent components. Each component can be updated and replaced by a new component. A group of related components provides specific services. Therefore, the system can communicate by selecting the corresponding network protocol components for assembly.

3 Communication protocol componentization

With the increasing integration of embedded systems and networks, the introduction of TCP/IP protocol stacks in embedded real-time operating systems to support embedded devices accessing the network has become an important research direction in the embedded field. However, the traditional TCP/IP protocol implementation has poor real-time performance and cannot meet the real-time requirements of the embedded field; the traditional TCP/IP implementation is too complicated and requires a lot of system resources, and the system resources of embedded applications are often very Limited; the traditional TCP/IP protocol system is based on a monolithic architecture, that is, the protocol introduced in the embedded real-time operating system is designed and implemented in a monolithic manner, with the continuous development of network technology, and some new With the ever-increasing and changing requirements of the application, this general monolithic structure of the protocol often cannot meet the demand. Therefore, the traditional TCP/IP needs to be improved and implemented without violating the protocol standard, so that its real-time performance is improved, and the storage space occupied is as little as possible, so as to meet the requirements of embedded applications.

Linux can dynamically load and unload operating system components according to user needs. This modular mechanism provides a prerequisite for componentizing communication protocols. The user can dynamically load or remove the module from the kernel without re-editing the kernel as needed. The kernel can only implement some basic functions, and the system's scalability function is left to the module to complete. Minimize the size and communication volume of the kernel. Therefore, the implementation of protocol componentization in Linux can rely on a modular mechanism. Protocol components are implemented by Linux modules. Modules can be dynamically loaded into or removed from the kernel without recompiling the kernel.

This article aims at the application of network real-time communication of the embedded server, and uses the Linux operating system that has been improved and tailored in real time as the protocol componentized platform to componentize the TCP/IP protocol stack.

1 Communication protocol componentization principle

2 Communication protocol decomposition

In order to make the protocol components have the characteristics of dynamic link, information encapsulation, unified interface, etc., the communication protocol must be reasonably decomposed first, which is related to the granularity of the communication protocol components. From the perspective of granularity, the smaller the granularity of the components, the finer the protocol division, and the more protocol components; the larger the component granularity, the coarser the protocol division, and the fewer the protocol components.

The granularity of the protocol components determines the degree of modularity, information encapsulation, and localization of the protocol components. To this end, the independence of the protocol components must be guaranteed. Once the component has good independence, the application component built on the protocol component is easier to develop and the interface will be simplified; the independent module is also easier to test and maintain, the modification workload is small, and the error propagation range is small. If the granularity is too small, although the independence of the protocol component is enhanced, the interface of the component is increased, which brings a lot of difficulties to the combination and management of the component. If the granularity is too large, the scale of components increases, the independence decreases, and the degree of association between various components will also increase, which is not conducive to the dynamic replacement and update of components.

The size of the granularity can be measured by two qualitative criteria, namely cohesion and coupling. Coupling measures how tightly different components depend on each other; cohesion measures how tightly each element within a protocol component combines with each other. When componentizing the protocol, the strategy adopted should minimize the coupling between the protocol components, enhance independence, and enhance cohesion.

At present, there is no uniform requirement for the granularity of components. Since the component is a highly cohesive software package, as long as the principle of high cohesion is met, the granularity of the component can be unlimited.

3.1.2 Communication protocol componentization method

As can be seen from the previous section, there is no uniform requirement for communication protocol decomposition, so the communication protocol can be componentized from multiple angles. For example, according to the function of the component, basic protocol components, general protocol components, special protocol components or subsystem protocol components for various fields can be implemented; static and dynamic componentization can be performed according to the way the components are used; according to the structure of the components Atomic components and combination components composed of multiple components*; hierarchical components can be implemented according to the layered structure of the protocol stack. This article is based on the TCP/IP protocol hierarchy under Linux (as shown in Figure 1) and is structured in layers. That is, the ARP, IP, ICMP, UDP, TCP protocols are separated from the Linux kernel, and the functions completed by each protocol are divided into different modules, and each module serves as a component. Each component is implemented with a pointer function. In this way, an embedded Linux-based application system can dynamically assemble protocol functions as needed when the kernel starts, forming a communication protocol stack with different configurations, showing the flexibility of system network communication.

Detailed solution of modern embedded operating system with real-time application capabilities based on Linux improvements

Considering that the TCP protocol is a connection-oriented, end-to-end reliable communication protocol, in order to ensure the correct communication between the remote client and the local embedded system server, a corresponding mechanism is adopted to ensure its reliability and real-time, that is, the establishment and connection of the connection Shutdown, timeout retransmission mechanism, packet confirmation mechanism, flow control, etc. Therefore, the TCP protocol is divided into a client module and a server module according to application functions. The former actively establishes a connection, and the latter* connects. After the connection is established, both parties send or receive data information.

Compared with the TCP protocol, ARP, IP, ICMP, UDP and other protocol functions are relatively simple, and they are not divided into modules. Each protocol is designed as a component according to the function it completes, but considering the real-time nature of the embedded system, it is removed. Necessary functions. The design of UDP protocol does not consider the data verification method, only the sending and receiving functions of the data. The design of the ICMP protocol only considers errors such as destination unreachability, source suppression, timeout, and routing change, and loopback request processing. The design of the IP protocol mainly performs routing and transfers data packets to adjacent protocol layers without considering the fragmentation and reassembly functions. The ARP protocol is mainly responsible for converting the 32-bit IP address in the LAN to the MAC address of the corresponding network card. Its functions include sending ARP requests and responding to ARP requests of the other party, and dynamically maintaining an ARP cache.

3.1.3 Assembly of communication protocol components

The assembly process of communication protocol components is shown in Figure 2. The communication protocol components are placed in the component library. When the system is running, the embedded Linux operating system dispatches the protocol assembly module, which takes the corresponding components from the component library according to the system network function requirements and dynamically configures the communication protocol stack.

Detailed solution of modern embedded operating system with real-time application capabilities based on Linux improvements

Therefore, the main function of assembly is to realize the interaction between the embedded Linux operating system and the component library, monitor the running status of the component, and record the characteristics of the component for feedback to the component library.

3.2 Realization of communication protocol componentization

This paper draws on the ideas of the literature and combines the methods proposed above to realize the componentization of communication protocols. The implementation of each protocol is similar. The TCP protocol is used as an example to illustrate the implementation process.

Assign the kernel storage space for the protocol in the protocol stack initialization file, save the linked list structure of the TCP protocol stack to the kernel, register, and initialize the content of the protocol itself into its module, complete the allocation of storage space, registration, initialization, etc. at the beginning of the module. At the end of the module, the kernel space occupied by the module is released, unregistered, and reset.

Modify the protocol implementation files tcp.c and tcp.h to create a new module file. Only the variables used by other protocols are kept in the protocol implementation file, and the other contents are placed in the newly created module file.

The protocol provides the function interface of other protocols, from the function name call to the function pointer call, modify the header file, add definition and declaration for the new interface implementation, and initialize the function pointer to an empty function body. In other protocols, the original function name call is changed to the corresponding function pointer call. These function pointers are the interface of the protocol component, which can be kept unchanged, and the functions provided by the interface can be modified at any time as needed.

Modifying the kernel symbol table file of the network part includes not only the interfaces provided for other protocols after the modification, but also the interfaces provided by other protocols required after the modularization.

Modify Makeflie file and add corresponding modular file list.

4 Communication protocol test

The operation of the componentized protocol is tested on the MagicARM2200 target board. Before testing, the hardware and software environment needs to be configured. The configuration process is as follows: use a serial cable and a simple emulator to connect the PC and the target board, and use two independent network cables to connect them. Connect to Ethernet; install virtual machine 5.5 and Red Hat Linux 9 on the PC, and port Linux that has been improved and tailored in real time to the target board.

4.1 Testing ARP protocol components

When the kernel does not support the ARP protocol, in order to display the MAC and IP address information in the ARP cache, run the arp -a command, the result is empty, and other network applications cannot work, the network part of the entire system is due to the failure of the underlying protocol paralysis. After the ARP protocol components are loaded with the insmod command, the network part returns to normal.

4.2 Test ICMP protocol components

When the kernel does not load the ICMP protocol component, ping the host from the outside, the ping command displays timeout, that is, ping fails. The function interface that the kernel receives and processes the incoming ICMP data packet cannot find the corresponding function implementation, and cannot return the confirmation message packet normally. After loading the ICMP protocol component with the insmod command, the function to process the data packet is correctly executed and it shows that it can be pinged. The response time is shown in Table 1.

Detailed solution of modern embedded operating system with real-time application capabilities based on Linux improvements

As can be seen from Table 1, when the ICMP protocol is loaded as a module, the response time of the ping command is longer than that of the protocol compiled into the kernel, the increase is (0.668-0.611)/0.611=0.093, and the performance degradation does not exceed 1% . Moreover, from the perspective of kernel startup speed, as a result of the componentized ICMP protocol, since the componentized kernel does not initialize the ICMP protocol part during the network part startup process, the startup speed is slightly increased.

4.3 Test UDP protocol components

In order to facilitate the observation of changes in system performance, this article uses Linux network performance testing software Netperf to test the UDP protocol components, mainly to test the batch data transmission performance, request and response performance of UDP. The test results are shown in Table 2.

Detailed solution of modern embedded operating system with real-time application capabilities based on Linux improvements

It can be seen from Table 2 that the network performance is lost after the protocol is built. The decrease in data transmission performance is (155.2-140.3)/155.2=0.096, and the decrease in request/response performance is (620.1-*. 9)/620.1=0.025, they are all below an order of magnitude.

4.4 Testing TCP protocol components

Test between the target board and the PC, with the PC as the client and the target board as the server, and write client and server test programs. When the kernel does not load the TCP protocol component, run the client program, the PC prompts that it cannot connect to the server; after loading the TCP protocol component, run the client program again, observe the PC, display the connection is successful, type characters on the target board, in The received characters can be displayed on the PC.

It can be seen from the above test results that after the TCP/IP componentization under Linux, although the system performance will be slightly lost, the loss is not large, and this small price can be exchanged for upgrades, maintenance costs are greatly reduced, and new protocol development The time is greatly shortened, which shows the feasibility and superiority of the componentized protocol, which can be considered as an effective method in practical applications.

5 Conclusion

Aiming at the application of embedded server network real-time communication, this paper introduces component technology into the TCP/IP protocol design of Linux, proposes a method to componentize the main protocols in the TCP/IP protocol stack, and tests the componentized protocol The results show that the componentized protocol can be dynamically loaded into the real-time improved and tailored Linux system, which not only reduces the size of the embedded Linux kernel, but also enhances the flexibility of the system's network communication protocol design.

VOZOL D6 Vape

VOZOL D6 Vape are so convenient, portable, and small volume, you just need to take them
out of your pocket and take a puff, feel the cloud of smoke, and the fragrance of fruit surrounding you. It's so great.
We are China leading manufacturer and supplier of Disposable Vapes puff bars, vozol d6 disposable vape,vozol d6 vape kit,
vozol d6 vape pen, and e-cigarette kit, and we specialize in disposable vapes, e-cigarette vape pens, e-cigarette kits, etc.

vozol d6 disposable vape,vozol d6 vape kit,vozol d6 vape pen,vozol d6 vape 1000 puffs,vozol d6 e-cigarette 1000 puffs

Ningbo Autrends International Trade Co.,Ltd. , https://www.vapee-cigarettes.com

Posted on