High-performance network communication system under sky vein system and implementation method thereof
By integrating the third-party protocol stack and open source protocol stack in the Tianmai system, the problem that the Tianmai operating system kernel protocol stack cannot be customized is solved, and a high-performance network communication system is realized, supporting hardware offloading and flexible protocol stack switching is met, meeting the needs of high-performance communication.
Patent Information
- Application Number
- CN202510502208.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-21
- Publication Date
- 2025-07-25
AI Technical Summary
The kernel protocol stack of Tianmai operating system cannot be customized, and it is difficult to integrate network hardware offloading functions, resulting in limited data communication performance and scalability.
The main partition integrated third-party protocol stack is designed under the system framework of Tianmai system, providing Socket-like interfaces, combining open source protocol stack and hardware offloading functions, improving communication performance by reducing memory copy, and supporting the coexistence and flexible switching of third-party protocol stack and system protocol stack.
It significantly improves data communication performance, achieves 5 times performance improvement, meets new needs for high-performance network communication, and supports customization and expansion of different applications.
Smart Images

Figure CN120378473A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of Ethernet network transmission, and more particularly to a high-performance network communication system and its implementation method under the Tianmai system. Background Art
[0002] The Tianmai operating system (ACoreOS) is a domestic airborne operating system with a scalable architecture, multi-core support, real-time processes, 64-bit support, and other features of multi-core operating systems. It has characteristics such as strong real-time, high security, high reliability, high determinism, scalability, and upgradability. Network communication under the Tianmai multi-core operating system is completed based on the main partition kernel TCP / IP protocol stack. The partition calls the standard socket interface, and the main partition completes the encapsulation and decapsulation of the UDP / TCP layer, IP layer, and data link layer of the data. The driver module completes the sending and receiving of data through the End layer access mechanism. However, in actual use, we found that the current Tianmai 3 kernel protocol stack has the following problems: poor scalability. Since the Tianmai kernel protocol stack is a closed commercial system and cannot be customized, it is difficult to utilize the offloading functions provided by network hardware, such as UFO, virtualization, and switch offloading, and it is difficult to integrate new network functions, such as port aggregation, which greatly limits its data communication performance and scalability. Summary of the Invention
[0003] In view of the technical problems existing in the prior art, the purpose of the present invention is to provide a high-performance network communication system and its implementation method under the Tianmai system. Under the system framework of the Tianmai system, a main partition is designed to integrate a third-party protocol stack to bypass the default protocol stack, and a network communication solution with a class Socket interface is provided within the partition. It is implemented using a self-controlled and open-source protocol stack. By reducing memory copying and integrating hardware offloading functions, the data communication performance is greatly improved. The support for network services is extended through customized interfaces to meet the requirements of new network communication characteristics.
[0004] According to the first aspect of the object of the present invention, a high-performance network communication system under the Tianmai system is proposed, including:
[0005] A class Socket API module for providing a class Socket interface for use by partition user applications. The class Socket API module converts application requests into system call parameters and uses the services provided by the system call module to complete the network communication process;
[0006] A class Socket system call module, which is the Socket encapsulation layer of network services. Based on the system call requests of partition / container applications, it creates and manages network communication connections and uses a third-party protocol stack to complete the encapsulation, decapsulation, and protocol interaction of TCP / IP packets;
[0007] The third-party protocol stack, which contains the implementations of multiple network protocols, processes the TCP / IP network communication process and encapsulates and decapsulates protocol packets for the class Socket system call module, and uses the packet sending and receiving functions of the network device through the driver to complete the communication function with other network devices;
[0008] The driver module, as the management module of the network device, is used for the management and configuration of the network device, provides data sending and receiving for the protocol stack through the hook interfaces defined by the third-party protocol stack and the kernel protocol stack, and relies on the DMA function of the network device to complete the transfer of data packets, thereby completing the communication function between the internal application and the external device;
[0009] The network device, as a standard Ethernet communication hardware, is used to implement the data link layer and physical layer functions of Ethernet communication. In the data sending direction, it encapsulates the data packets of the host at the Ethernet link layer and converts them into electrical signals and optical signals to send to the remote device. In the receiving direction, it converts the optical signals from the remote device into electrical signals and decapsulates them into data packets to send to the host; and
[0010] The kernel protocol stack and Socket interface inside the Tianmai system, as the standard network communication module of the Tianmai system, provide network communication functions for the partition user applications;
[0011] Among them, the class Socket API module runs in the partition / container together with the partition user application in the form of a software library, and provides network communication API interfaces for the partition user application; the third-party protocol stack, the class Socket system call module, and the driver module are compiled and run together as part of the Tianmai system; the network device is connected to the host through the PCIE interface.
[0012] As an optional implementation, after the Tianmai system is powered on and runs, it triggers the initialization of the driver module to identify the network device, completes the configuration of the network device and the docking with the kernel protocol stack inside the Tianmai system, so that the network device can be used by the kernel protocol stack to implement the network communication function.
[0013] As an optional implementation, after the configuration of the network device is completed, it triggers the initialization of the third-party protocol stack communication system, and the network device driver registers the protocol stack switching interface to the third-party protocol stack communication system, so that the network device can be used by the third-party protocol stack to implement the network communication function.
[0014] As an optional implementation, when the partition user application in the partition / container runs, the application program decides to use the third-party protocol stack to complete network communication, calls the class Socket API to create a third-party protocol stack Socket_trd handle, and completes the protocol stack resource application, creates the first Socket management structure, and returns the application handle information;
[0015] The partition user application configures the network device and IP information of the third-party protocol stack using the setsockopt_trd interface.
[0016] As an optional implementation, when the partition user application in the partition / container decides not to use the network communication function of the third-party protocol stack, it switches the network device back to the communication mode of the kernel protocol stack inside the Tianmai system through the setsockopt_trd interface, or automatically switches the network device back to the communication mode of the kernel protocol stack inside the Tianmai system when all Socket_trd handles are closed.
[0017] According to the second aspect of the object of the present invention, there is also provided a method for implementing a high-performance network communication system under the Tianmai system. The method includes initializing the network device, and after switching the network device to the third-party protocol stack, sending and receiving data packets, specifically as follows:
[0018] Initializing the network device includes the following processes:
[0019] Step 1-1: After the system starts, the Tianmai system calls the initialization interface of the network device based on the configured network device information.
[0020] Step 1-2: The initialization function of the network device driver finds the corresponding network device and performs initialization configuration on the network device.
[0021] Step 1-3: The network device driver registers the kernel protocol stack device and mounts the hook functions of the network device, including enabling, controlling, and data sending, so that the network device can be used by the kernel protocol stack.
[0022] Step 1-4: When the network device driver supports the third-party protocol stack communication system, it triggers the call to the initialization interface of the third-party protocol stack system, and mounts the protocol stack switching interface of the network device into the third-party protocol stack communication system.
[0023] Step 1-5: The network device is successfully initialized, enabling the network device to be used by the kernel protocol stack inside the system and able to switch to the third-party protocol stack when needed.
[0024] Then, after the network device is registered with both the kernel protocol stack and the third-party protocol stack, switching the network device to the third-party protocol stack includes the following processes:
[0025] Step 2-1: The application calls the Socket_trd API to create a three-party protocol stack Socket handle. The Socket_trd API converts the parameters into system call parameters and calls the system call interface.
[0026] Step 2-2: The system call module obtains the Socket structure according to the Socket type and applies for Socket buffer resources based on the Socket type;
[0027] Step 2-3: Return the Socket structure ID as the Socket handle to the application;
[0028] Step 2-4: The application calls the setsockopt_trd interface to set the network device to be switched to the third-party protocol stack and complete the network configuration, including IP address, subnet mask, gateway, and MAC address information;
[0029] Step 2-5: The Socket API layer converts and encapsulates the parameters into system call parameters and calls the system call interface;
[0030] Step 2-6: The system call layer finds the corresponding network device to be switched, calls the network device driver interface, switches the protocol stack used by the network device, and completes the configuration update of the device and the protocol stack;
[0031] Step 2-7: The device driver program applies for the driver resources used by the third-party protocol stack, registers the corresponding hook function, and reconfigures the network device;
[0032] Step 2-8: The application switches to using the communication function of the network device through the third-party protocol stack system.
[0033] As an optional implementation, after switching the network device to the third-party protocol stack, the process of the application using the network device and sending data packets through the third-party protocol stack includes:
[0034] The partition user application applies for the Socket_trd handle;
[0035] The partition user application calls the bind_trd API to bind the local protocol port. If it is TCP, it calls the connect_trd API to create a TCP connection with the peer;
[0036] The Socket API layer encapsulates the interface parameters into call parameters and calls the corresponding system call interface;
[0037] The system call layer saves the port information into the control structure of the protocol stack based on the system call parameters, and finds the local IP / MAC and device information used by this channel. If it is a TCP connect_trd call, it triggers the connection establishment process;
[0038] The partition user application calls the send_trd / sento_trd API to send data packets;
[0039] The Socket API layer encapsulates the interface parameters into call parameters and invokes the corresponding system call interface;
[0040] The system call layer converts the data packet into the internal storage format of the third-party protocol stack, and after setting the identifier of the packet, invokes the sending function of the third-party protocol stack to send the data packet;
[0041] The third-party protocol stack encapsulates the protocol header of the data packet based on the port / address information in the control structure, and invokes the sending interface of the network device driver. The driver stores the packet and sends it to the external device through the network device.
[0042] As an optional implementation, after switching the network device to the third-party protocol stack, the process by which the application program utilizes the network device and receives data packets through the third-party protocol stack includes:
[0043] The partition user application invokes the receive data APIs, recv_trd / recvfrm_trd;
[0044] The Socket API interface layer's receive function encapsulates the system call parameters and invokes the system call;
[0045] The system call layer obtains the control entity information based on the socket handle and checks whether there is a packet in the receive queue that needs to be processed: If there is a packet that needs to be processed, the packet is returned to the application for processing; If there is no packet that needs to be processed, it waits for a packet to arrive based on the setting, or directly returns no data;
[0046] When the driver program detects the arrival of a packet, it converts the packet into the storage structure of the third-party protocol stack and invokes the receive interface of the protocol stack to send the packet to the third-party protocol stack;
[0047] The third-party protocol stack parses the packet header and performs corresponding protocol processing, including the ARP / ICMP process; If it is a UDP or TCP packet, it detects the port information of the existing receive entity. If there is a corresponding receive entity, the packet is saved in the receive queue of the receive entity. If there is no corresponding receive entity, the packet is returned to the driver program.
[0048] As an optional implementation, the process of switching the network device back to the communication mode of the kernel protocol stack inside the Tianmai system includes:
[0049] The partition user application invokes the setsockopt_trd interface to switch the network device back to the kernel protocol stack inside the Tianmai system, or the application program of the last Socket_trd ends running;
[0050] When the system call layer obtains an instruction or checks that the count of Socket entities is 0, it calls the device driver interface to switch the network device to use the kernel protocol stack;
[0051] The driver releases the driver resources used by the third-party protocol stack, applies for the driver resources used by the kernel protocol stack, and re-registers the corresponding hook functions;
[0052] The kernel protocol stack can use this network device to send and receive data packets.
[0053] From the implementation method of the high-performance network communication system under the Tianmai system of the embodiments of the present invention above, compared with the test comparison of the internal network protocol stack of the traditional Tianmai 3 operating system, its significant advantages are as follows:
[0054] 1. Based on the current test results, the communication rate of the network protocol stack of the Tianmai 3 system is about 1 Gbps, while the communication requirement is above 5 Gbps or even higher. Therefore, the communication performance of the system protocol stack restricts the application of high-speed Ethernet on the Tianmai 3 system. In the design of the present invention, by integrating a third-party protocol stack, the upper limit restriction problem of the communication rate of the system protocol stack can be solved. Based on the current test results, the one-way UDP communication performance with the same hardware configuration is above 5 Gbps, and the performance improvement can reach 5 times;
[0055] 2. The implementation method of the high-performance network communication system under the Tianmai system proposed by the present invention, the integrated third-party protocol stack has full control, can use technologies such as zero-copy to improve communication performance, and cooperate with the network device to achieve hardware offloading of network communication, which is convenient for expansion and meets the new requirements of high-performance network communication; at the same time, for different application requirements of customers, application interfaces and processes can be customized to meet the customized needs of customers, which is more convenient for customization and expansion;
[0056] 3. Through the system design of the present invention, the coexistence and flexible switching of the third-party protocol stack and the system protocol stack. By specifying the network device to use the third-party protocol stack through the management interface, when there are multiple network devices, the network devices that support the third-party protocol stack can be selected to use the third-party protocol stack, while other devices still use the system protocol stack; when there is no application using the third-party protocol stack, the management interface can automatically switch back to the system protocol stack.
[0057] It should be understood that all combinations of the foregoing concepts and additional concepts described in more detail below can be regarded as part of the inventive subject matter of the present disclosure as long as such concepts do not conflict with each other. In addition, all combinations of the claimed subject matter are regarded as part of the inventive subject matter of the present disclosure.
[0058] The foregoing and other aspects, embodiments, and features of the teachings of the present invention can be more fully understood from the following description in conjunction with the accompanying drawings. Other additional aspects of the present invention, such as the features and / or beneficial effects of exemplary embodiments, will be apparent from the following description or will be learned from the practice of specific embodiments in accordance with the teachings of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] The drawings are not intended to be drawn to scale. In the drawings, each identical or nearly identical component shown in various figures may be represented by the same reference numeral. For clarity, not every component is labeled in each figure. Now, embodiments of various aspects of the present invention will be described by way of example and with reference to the drawings.
[0060] Figure 1 is a schematic diagram of a high-performance network communication system under the Tianmai system according to an embodiment of the present invention.
[0061] Figure 2 is a flowchart of network device initialization of a high-performance network communication system under the Tianmai system according to an embodiment of the present invention.
[0062] Figure 3 is a flowchart of switching the system protocol stack to a third-party protocol stack of a high-performance network communication system under the Tianmai system according to an embodiment of the present invention.
[0063] Figure 4 is a flowchart of an application sending data packets of a high-performance network communication system under the Tianmai system according to an embodiment of the present invention.
[0064] Figure 5 is a flowchart of the data packet receiving process of a high-performance network communication system under the Tianmai system according to an embodiment of the present invention.
[0065] Figure 6 is a flowchart of a network device switching back to the system protocol stack of a high-performance network communication system under the Tianmai system according to an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0066] In order to better understand the technical content of the present invention, specific embodiments are hereby given and described in conjunction with the accompanying drawings as follows.
[0067] In the present disclosure, aspects of the present invention are described with reference to the accompanying drawings, in which numerous illustrative embodiments are shown. The embodiments of the present disclosure are not necessarily intended to cover all aspects of the present invention. It should be understood that the various concepts and embodiments introduced above, as well as those described in more detail below, can be implemented in any of a number of ways, because the concepts and embodiments disclosed in the present invention are not limited to any embodiment. Additionally, some aspects of the present invention can be used alone or in any suitable combination with any other aspects disclosed in the present invention.
[0068] {Example 1}
[0069] Combined Figures 1-6 As shown, the high-performance network communication system under the Tianmai system according to the embodiments of the present invention includes:
[0070] The class Socket API module is used to provide an interface of the class Socket for partition user applications. The class Socket API module converts the application request into system call parameters and uses the services provided by the system call module to complete the network communication process;
[0071] The class Socket system call module, as the Socket encapsulation layer of the network service, creates and manages network communication connections based on the partition / container application system call request, and uses a third-party protocol stack to complete the encapsulation and decapsulation of TCP / IP packets and protocol interaction;
[0072] The third-party protocol stack contains the implementations of multiple network protocols, processes the TCP / IP network communication process and encapsulates and decapsulates protocol packets for the class Socket system call module, and uses the packet sending and receiving functions of network devices through the driver to complete the communication function with other network devices;
[0073] The driver module, as the management module of network devices, is used for the management and configuration of network devices, provides data sending and receiving for the protocol stack through the hook interfaces defined by the third-party protocol stack and the kernel protocol stack, and relies on the DMA function of network devices to complete the transfer of data packets, thereby completing the communication function between internal applications and external devices;
[0074] The network device, as a standard Ethernet communication hardware, is used to implement the data link layer and physical layer functions of Ethernet communication. In the data sending direction, it encapsulates the data packets of the host at the Ethernet link layer and converts them into electrical signals and optical signals to send to the remote device. In the receiving direction, it converts the optical signals from the remote device into electrical signals and decapsulates them into data packets to send to the host; and
[0075] The kernel protocol stack and Socket interface inside the Tianmai system are the standard network communication modules of the Tianmai system, providing network communication functions for partition user applications.
[0076] It should be understood that the foregoing class Socket API module is used to provide an interface of the class Socket for partition applications for the transplantation of the original Socket code, and can also provide customized interfaces to meet different requirements.
[0077] The foregoing third-party protocol stack can integrate common network protocols, including but not limited to TCP / UDP / IPV4 / IPV6 / ICMP / IGMP / ARP, etc., and can be implemented by porting existing open-source projects. Thus, it completes the processing of the TCP / IP network communication process and the encapsulation and decapsulation of protocol packets for the class Socket layer, and uses the packet sending and receiving functions of the network device through the driver to complete the communication function with other network devices.
[0078] Among them, the class Socket API module runs in the partition / container together with the partition user application in the form of a software library, providing an API interface for network communication for the partition user application; the third-party protocol stack, the class Socket system call module, and the driver module are compiled and run together as part of the Tianmai system; the network device is connected to the host through the PCIE interface.
[0079] In an optional embodiment, after the Tianmai system is powered on and running, it triggers the initialization of the driver module to identify the network device, completes the configuration of the network device and the docking with the kernel protocol stack inside the Tianmai system, so that the network device can be used by the kernel protocol stack to achieve the network communication function.
[0080] In an optional embodiment, after the configuration of the network device is completed, it triggers the initialization of the third-party protocol stack communication system, and the network device driver registers the protocol stack switching interface to the third-party protocol stack communication system, so that the network device can be used by the third-party protocol stack to achieve the network communication function.
[0081] In an optional embodiment, when the partition user application in the partition / container runs, the application program decides to use the third-party protocol stack to complete network communication, calls the class Socket API to create a third-party protocol stack Socket_trd handle, and completes the protocol stack resource application, creates the first Socket management structure, and returns the application handle information;
[0082] The partition user application configures the network device and IP information of the third-party protocol stack using the setsockopt_trd interface.
[0083] In an optional embodiment, the partition user application in the partition / container uses the Socket_trd handle, binds the sending and receiving ports, and sends or receives data packets to achieve the purpose of network communication.
[0084] In an optional embodiment, when the partition user application of a partition / container decides not to use the network communication function of the third-party protocol stack, the network device is switched back to the communication mode of the kernel protocol stack inside the Tianmai system through the setsockopt_trd interface, or when all Socket_trd handles are closed, the network device is automatically switched back to the communication mode of the kernel protocol stack inside the Tianmai system.
[0085] Thus, through the above processing, a high-performance TCP / IP network communication system under the Tianmai 3 operating system is built for subsequent use.
[0086] {Embodiment 2}
[0087] Based on Figure 1 , combined with Figures 2-6 shown, the implementation method and process of the high-performance network communication system under the aforementioned Tianmai 3 operating system are described in more detail.
[0088] In this embodiment, the implementation method of the high-performance network communication system under the Tianmai 3 operating system includes initializing the network device, and after switching the network device to the third-party protocol stack, completing the process of sending and receiving data packets.
[0089] Combined with Figure 2 shown, the initialization of the network device includes the following processes:
[0090] Step 1-1: After the system starts, the Tianmai system calls the initialization interface of the network device based on the configured network device information;
[0091] Step 1-2: The initialization function of the network device driver finds the corresponding network device and performs initialization configuration on the network device;
[0092] Step 1-3: The network device driver registers the kernel protocol stack device and mounts the hook functions of the network device, including enabling, controlling, and data sending, so that the network device can be used by the kernel protocol stack;
[0093] Step 1-4: When the network device driver supports the third-party protocol stack communication system, it triggers the call to the initialization interface of the third-party protocol stack system, and mounts the network device switching protocol stack interface to the third-party protocol stack communication system;
[0094] Step 1-5: The network device is successfully initialized, enabling the network device to be used by the kernel protocol stack inside the system and able to switch to the third-party protocol stack for use when needed.
[0095] Combined with Figure 3 shown, after the network device is registered in both the kernel protocol stack and the third-party protocol stack, switching the network device to the third-party protocol stack includes the following processes:
[0096] Step 2-1: The application calls the Socket_trd API to create a three-party protocol stack Socket handle. The Socket_trd API converts the parameters into system call parameters and calls the system call interface.
[0097] Step 2-2: The system call module obtains the Socket structure based on the Socket type and applies for Socket buffer resources based on the Socket type.
[0098] Step 2-3: Return the Socket structure ID as the Socket handle to the application.
[0099] Step 2-4: The application calls the setsockopt_trd interface to set the network device to be switched to the three-party protocol stack and complete the network configuration, including IP address, subnet mask, gateway, and MAC address information.
[0100] Step 2-5: The Socket API layer converts and encapsulates the parameters into system call parameters and calls the system call interface.
[0101] Step 2-6: The system call layer finds the corresponding network device to be switched, calls the network device driver interface, switches the protocol stack used by the network device, and completes the configuration update of the device and the protocol stack.
[0102] Step 2-7: The device driver program applies for the driver resources used by the third-party protocol stack, registers the corresponding hook function, and reconfigures the network device.
[0103] Step 2-8: The application switches to using the communication function of the network device through the third-party protocol stack system.
[0104] Combined with the attached Figure 4 As shown, after switching the network device to the third-party protocol stack, the process of the application using the network device and sending data packets through the third-party protocol stack includes:
[0105] The partition user application applies for a Socket_trd handle.
[0106] The partition user application calls the bind_trd API to bind the local protocol port. If it is TCP, it calls the connect_trd API to create a TCP connection with the peer.
[0107] The Socket API layer encapsulates the interface parameters into call parameters and calls the corresponding system call interface.
[0108] Based on the system call parameters, the system call layer saves the port information into the control structure of the protocol stack, and finds the local IP / MAC and device information used by this channel. If it is a TCP connect_trd call, the connection establishment process is triggered;
[0109] The partition user application calls the send_trd / sento_trd API to send data packets;
[0110] The Socket API layer encapsulates the interface parameters into call parameters and calls the corresponding system call interface;
[0111] The system call layer converts the data packet into the internal storage format of the third-party protocol stack, and after setting the packet identifier, calls the send function of the third-party protocol stack to send the data packet;
[0112] The third-party protocol stack encapsulates the protocol header of the data packet based on the port / address information in the control structure, and calls the send interface of the network device driver. The driver stores the packet and sends it to the external device through the network device.
[0113] Combined with the appendix Figure 5 As shown, after switching the network device to the third-party protocol stack, the process by which the application program uses the network device and receives data packets through the third-party protocol stack includes:
[0114] The partition user application calls the receive data API, recv_trd / recvfrm_trd;
[0115] The Socket API interface layer's receive function encapsulates the system call parameters and calls the system call;
[0116] The system call layer obtains the control entity information based on the socket handle and checks whether there are packets to be processed in the receive queue: If there are packets to be processed, the packets are returned to the application for processing; If there are no packets to be processed, it waits for packets to arrive based on the settings, or directly returns no data;
[0117] When the driver detects the arrival of a packet, it converts the packet into the storage structure of the third-party protocol stack and calls the receive interface of the protocol stack to send the packet to the third-party protocol stack;
[0118] The third-party protocol stack parses the packet header and performs corresponding protocol processing, including ARP / ICMP processes; If it is a UDP or TCP packet, it detects the port information of the existing receiving entity. If there is a corresponding receiving entity, the packet is saved in the receive queue of the receiving entity. If there is no corresponding receiving entity, the packet is returned to the driver.
[0119] Combined with the appendix Figure 6As shown, the process of the network device switching back to the communication mode through the kernel protocol stack inside the TIANMA system includes:
[0120] The partition user application calls the setsockopt_trd interface to switch the network device back to the kernel protocol stack inside the TIANMA system, or the application of the last Socket_trd ends running;
[0121] The system call layer obtains the instruction or checks that the Socket entity count is 0, and calls the device driver interface to switch the network device to use the kernel protocol stack;
[0122] The driver releases the driver resources used by the third-party protocol stack, applies for the driver resources used by the kernel protocol stack, and re-registers the corresponding hook function;
[0123] The kernel protocol stack can use this network device to send and receive data packets.
[0124] Although the present invention has been disclosed above with a preferred embodiment, it is not intended to limit the present invention. Those with ordinary knowledge in the technical field to which the present invention pertains can make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, the protection scope of the present invention shall be subject to what is defined by the claims.
Claims
1. A high-performance network communication system under the Tianmai system, characterized in that, Including: A class Socket API module, which is used to provide an interface of the class Socket for partition user applications. The class Socket API module converts application requests into system call parameters and uses the services provided by the system call module to complete the network communication process; A class Socket system call module, which is the Socket encapsulation layer of network services. Based on the partition / container application system call request, it creates and manages network communication connections, and uses a third-party protocol stack to complete the encapsulation and decapsulation of TCP / IP packets and protocol interactions; A third-party protocol stack, which contains the implementations of multiple network protocols, processes the TCP / IP network communication process and encapsulates and decapsulates protocol packets for the class Socket system call module, and uses the packet sending and receiving functions of network devices through the driver to complete the communication function with other network devices; A driver module, which is the management module of network devices, is used for the management and configuration of network devices, provides data sending and receiving for the protocol stack through the hook interfaces defined by the third-party protocol stack and the kernel protocol stack, and relies on the DMA function of network devices to complete the transfer of data packets, thereby completing the communication function between internal applications and external devices; A network device, which is a standard Ethernet communication hardware, is used to implement the data link layer and physical layer functions of Ethernet communication. In the data sending direction, it encapsulates the data packets of the host at the Ethernet link layer and converts them into electrical signals and optical signals to be sent to the remote device. In the receiving direction, it converts the optical signals from the remote device into electrical signals and decapsulates them into data packets to be sent to the host; And The kernel protocol stack and Socket interface inside the Tianmai system, which are the standard network communication modules of the Tianmai system and provide network communication functions for partition user applications; Among them, the class Socket API module runs in the partition / container together with the partition user application in the form of a software library, and provides an API interface for network communication for the partition user application; the third-party protocol stack, the class Socket system call module and the driver module are compiled and run together as part of the Tianmai system; the network device is connected to the host through the PCIE interface.
2. The high-performance network communication system under the Tianmai system according to claim 1, wherein After the Tianmai system is powered on and running, it triggers the initialization of the driver module to identify the network device, completes the configuration of the network device and the docking with the kernel protocol stack inside the Tianmai system, so that the network device can be used by the kernel protocol stack to achieve the network communication function.
3. The high-performance network communication system under the Tianmai system according to claim 2, characterized in that After the configuration of the network device is completed, it triggers the initialization of the third-party protocol stack communication system. The network device driver registers the protocol stack switching interface to the third-party protocol stack communication system, so that the network device can be used by the third-party protocol stack to achieve the network communication function.
4. The high-performance network communication system under the Tianmai system according to claim 2, characterized in that, When the partition user application in the partition / container runs, the application program decides to use the third-party protocol stack to complete network communication, calls the class Socket API to create a third-party protocol stack Socket_trd handle, completes the protocol stack resource application, creates the first Socket management structure, and returns the application handle information; The partition user application configures the network device and IP information of the third-party protocol stack using the setsockopt_trd interface.
5. The high-performance network communication system under the Tianmai system according to claim 4, characterized in that, The partition user application of the partition / container uses the Socket_trd handle, binds the sending and receiving ports, and sends or receives data packets to achieve network communication.
6. The high-performance network communication system under the Tianmai system according to claim 4, characterized in that When the partition user application of the partition / container decides not to use the network communication function of the third-party protocol stack, it switches the network device back to the communication mode of the kernel protocol stack inside the Tianmai system through the setsockopt_trd interface, or automatically switches the network device back to the communication mode of the kernel protocol stack inside the Tianmai system when all Socket_trd handles are closed.
7. The implementation method of the high-performance network communication system under the Tianmai system according to any one of claims 1-6, characterized in that, The method includes network device initialization, and after switching the network device to the third-party protocol stack, the sending and receiving of data packets are completed, specifically as follows: Network device initialization includes the following processes: Step 1-1: After the system starts, the Tianmai system calls the initialization interface of the network device based on the configured network device information. Step 1-2: The initialization function of the network device driver finds the corresponding network device and performs initialization configuration on the network device. Step 1-3: The network device driver registers the kernel protocol stack device and mounts the hook functions of the network device, including enabling, controlling, and data sending, so that the network device can be used by the kernel protocol stack. Step 1-4: When the network device driver supports the third-party protocol stack communication system, it triggers the call to the initialization interface of the third-party protocol stack system, and mounts the protocol stack switching interface of the network device into the third-party protocol stack communication system. Step 1-5: The network device is initialized successfully, enabling the network device to be used by the kernel protocol stack inside the system and able to switch to the third-party protocol stack when needed. Then, after the network device is registered with both the kernel protocol stack and the third-party protocol stack, the network device is switched to the third-party protocol stack, including the following processes: Step 2-1: The application calls the Socket_trd API to create a three-party protocol stack Socket handle. The Socket_trd API converts the parameters into system call parameters and calls the system call interface. Step 2-2: The system call module obtains the Socket structure based on the Socket type and applies for Socket buffer resources based on the Socket type. Step 2-3: Returns the Socket structure ID as the Socket handle to the application. Step 2-4: The application calls the setsockopt_trd interface to set the network device to be switched to the three-party protocol stack and complete the network configuration, including IP address, subnet mask, gateway, and MAC address information. Step 2-5: The Socket API layer converts and encapsulates the parameters into system call parameters and calls the system call interface. Step 2-6: The system call layer finds the corresponding network device to be switched, calls the network device driver interface, switches the protocol stack used by the network device, and completes the configuration update of the device and the protocol stack. Step 2-7: The device driver applies for the driver resources used by the third-party protocol stack, registers the corresponding hook function, and reconfigures the network device; Step 2-8: The application switches to using the communication function of the network device through the third-party protocol stack system.
8. The implementation method of the high-performance network communication system under the Tianmai system according to claim 7, characterized in that, After switching the network device to the third-party protocol stack, the process of the application using the network device to send data packets through the third-party protocol stack includes: The partition user application applies for a Socket_trd handle; The partition user application calls the bind_trd API to bind the local protocol port. If it is TCP, it calls the connect_trd API to create a TCP connection with the peer; The Socket API layer encapsulates the interface parameters into call parameters and calls the corresponding system call interface; Based on the system call parameters, the system call layer saves the port information into the control structure of the protocol stack, and finds the local IP / MAC and device information used by this channel. If it is a TCP connect_trd call, it triggers the connection establishment process; The partition user application calls the send_trd / sento_trd API to send data packets; The Socket API layer encapsulates the interface parameters into call parameters and calls the corresponding system call interface; The system call layer converts the data packet into the internal storage format of the third-party protocol stack, and after setting the identifier of the packet, calls the send function of the third-party protocol stack to send the data packet; The third-party protocol stack encapsulates the protocol header of the data packet based on the port / address information in the control structure, and calls the send interface of the network device driver. The driver stores the packet and sends it to the external device through the network device.
9. The implementation method of the high-performance network communication system under the Tianmai system according to claim 7, characterized in that, After switching the network device to the third-party protocol stack, the process of the application using the network device to receive data packets through the third-party protocol stack includes: The partition user application calls the receive data API, recv_trd / recvfrm_trd; The Socket API interface layer receives the function to encapsulate the system call parameters and calls the system call; The system call layer obtains the control entity information based on the socket handle and checks whether there are packets to be processed in the receive queue: If there are packets to be processed, it returns the packet to the application for processing; If there are no packets to be processed, it waits for the packet to arrive based on the setting, or directly returns no data; When the driver detects the arrival of the packet, it converts the packet into the storage structure of the third-party protocol stack and calls the receive interface of the protocol stack to send the packet to the third-party protocol stack; The third-party protocol stack parses the packet header and performs corresponding protocol processing, including the ARP / ICMP process; If it is a UDP or TCP packet, it detects the port information of the existing receiving entity. If there is a corresponding receiving entity, it saves the packet in the receive queue of the receiving entity. If there is no corresponding receiving entity, it returns the packet to the driver.
10. The implementation method of the high-performance network communication system under the Tianmai system according to claim 7, 8 or 9, characterized in that, The process of switching the network device back to the communication mode through the kernel protocol stack inside the Tianmai system includes: The partitioned user application calls the setsockopt_trd interface to switch the network device back to the kernel protocol stack inside the Tianmai system, or the application of the last Socket_trd ends running; The system call layer obtains an instruction or checks that the Socket entity count is 0, calls the device driver interface, and switches the network device to use the kernel protocol stack; The driver releases the driver resources used by the third-party protocol stack, applies for the driver resources used by the kernel protocol stack, and re-registers the corresponding hook function; The kernel protocol stack can use this network device to send and receive data packets.
Citation Information
Cited By
Network interface design method and system supporting multiple network modes
CN121418278A