A high-real-time and fast container communication method based on domestic hardware platform

By performing UDP packets at the transport layer and using shared memory technology to directly transfer network messages across namespaces, the problem of long communication between containers in the existing technology is solved, efficient inter-container communication is achieved, and high-real-time fast communication is achieved. needs.

CN118677966BActive Publication Date: 2024-10-18成都菁蓉联创科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411154308.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-22
Publication Date
2024-10-18
Estimated Expiration
2044-08-22

AI Technical Summary

Technical Problem

The existing communication method between containers based on socket technology is time-consuming and difficult to meet the needs of high real-time and fast communication.

Method used

Adopting a high-real-time and fast container communication method based on domestic hardware platforms, UDP packets are grouped through the transport layer, and shared memory technology is used to directly transfer network messages across namespaces on the same host, eliminating the need for processing at the IP layer and virtual bridge layer. process.

Benefits of technology

It greatly reduces the communication delay between containers, improves communication efficiency, meets the demand for high-real-time and fast communication, and reduces communication time by about 60%.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118677966B_ABST
    Figure CN118677966B_ABST
Patent Text Reader

Abstract

The present invention discloses a high-real-time and fast container communication method based on a domestic hardware platform, which relates to the technical field of inter-container communication, and includes the following steps: a network message structure is generated by a communication initiator container transport layer; a destination address is analyzed by a communication initiator container transport layer, and if the destination address and the communication initiator container are on the same host, the communication initiator container uses a shared memory technology to realize the cross-namespace transfer of network messages, and the network message structure is directly attached from the transport layer of the communication initiator container to the receiving queue of the destination socket of the communication receiving container, and the transport layer of the communication receiving container reads the packet receiving queue to complete the fast communication; otherwise, the network message structure is transferred to the IP layer for processing, and communication is performed through the IP layer. Compared with the prior art, this method greatly improves the efficiency of inter-container communication based on the domestic hardware platform, and greatly reduces the delay of inter-container communication on the hardware platform.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of inter-container communication, and in particular to a high-real-time and fast container communication method based on a domestic hardware platform. Background Art

[0002] In the field of computer security, a container is an isolated running mechanism for a program, which aims to limit the permissions of untrusted processes. Container technology is often used to execute untested or untrusted client programs. In order to prevent untrusted programs from damaging the operation of other programs, container technology provides virtualized disk, memory, and network resources for untrusted client programs, and this virtualization method is transparent to the client program. Because the resources in the container are virtualized (or indirect), the malicious behavior of untrusted programs in the container is often confined to the container, minimizing the impact of security threats.

[0003] The specific implementations of the currently popular container technology include: VMWare virtual machines and Docker containers. VMware uses virtualization technology to split the CPU, memory, hard disk and other hardware resources of a physical machine into multiple virtual machines (virtual MAChine) through software technology. A guest operating system (Guest OS) is installed on a virtual machine, and each guest operating system runs its own application software independently. The virtual machines do not interfere with each other. VMware can currently run on Windows, MAC, and Linux platforms. Docker is a lightweight virtualization technology that can provide multiple isolated operating system environments on a single host, isolate processes through a series of namespaces (network namespaces), and each container has a unique writable file system and resource quota.

[0004] In the Linux operating system, only socket technology can enable communication between different processes on a single machine and between processes on machines across a network. Container technology is a resource-isolated operating environment where networks and namespaces are independent of each other. This feature makes socket technology the only technology that supports task communication between containers.

[0005] The process of the existing inter-container communication method based on socket technology is described as follows:

[0006] 1) The socket interface of the task in the container uses system calls (such as send to, sendmsg, etc.) to write data;

[0007] 2) Data packets are packaged and processed at the kernel UDP layer (high-performance communication between containers is mainly based on signaling data. In order to ensure the efficiency and stable latency of such data transmission, the general transport layer is based on the UDP protocol, so UDP is taken as an example);

[0008] 3) Data packets are packaged and processed at the IP layer;

[0009] 4) Data packets enter the virtual interface layer for packaging and processing (the virtual interface layer is mainly VETH PAIR / MACVLAN / IPVLAN, etc.);

[0010] 5) The data message is delivered to the target container address through the virtual interface layer;

[0011] 6) The message is unpacked and processed at the IP layer of the target container;

[0012] 7) The message is unpacked and processed at the UDP layer of the target container;

[0013] 8) After the message is processed in kernel state, the target container user state packet receiving task is awakened and the message is received into the user address space of the user state socket.

[0014] The communication time required for the above process is long and time-consuming, and cannot meet the needs of inter-container communication in scenarios with high real-time and fast communication requirements. Summary of the invention

[0015] In view of the above-mentioned deficiencies in the prior art, the present invention provides a high real-time and fast container communication method based on a domestic hardware platform, which solves the problem that the existing communication method between containers is time-consuming and difficult to meet high real-time requirements.

[0016] In order to achieve the above-mentioned object of the invention, the technical solution adopted by the present invention is:

[0017] A high-real-time and fast container communication method based on a domestic hardware platform is provided, which includes the following steps:

[0018] S1. The transport layer of the communication initiator container performs UDP packet assembly to generate a network message structure;

[0019] S2. The transport layer of the communication initiator container searches and analyzes the destination address. If the destination address and the communication initiator container are on the same host, the process proceeds to step S3; otherwise, the network message structure is handed over to the IP layer for processing, and communication is performed through the IP layer.

[0020] S3. The communication initiator container uses shared memory technology to transfer network messages across namespaces, and directly connects the network message structure from the communication initiator container transport layer to the receiving queue of the destination socket of the communication receiving container.

[0021] S4. The transport layer of the communication receiving end container reads the packet receiving queue to complete the fast communication.

[0022] Furthermore, the specific method for UDP packet grouping is:

[0023] The communication initiator container calls the send to function to start the message sending process;

[0024] The communication initiator container calls the udp_send_skb function to find the route and set the IP header to generate a network message structure.

[0025] Furthermore, the specific method for quickly searching the destination address is as follows:

[0026] Traverse all IPv4 addresses of all network interface devices in each network namespace, and find the IPv4 address of the network interface device in the network namespace where the destination address is located through the destination address.

[0027] Furthermore, the specific method for determining whether the destination address and the communication initiator container are on the same host is as follows:

[0028] When the IPv4 address of the network interface device in the network namespace where the destination address is located is the same as the destination IPv4 address of the network message structure, it is determined whether the communication initiator container and the communication receiver container are both veth devices and the peer interfaces are in the same bridge. If so, it is determined that the destination address and the communication initiator container are on the same host; otherwise, it is determined that the destination address and the communication initiator container are not on the same host.

[0029] Furthermore, the shared memory technology is used to realize the cross-namespace transfer of network messages. The specific method of directly attaching the network message structure from the communication initiator container transport layer to the receiving queue of the communication receiving container destination socket is as follows:

[0030] In the udp_send process of the Linux protocol stack, by adding the udp_skb_direct_rcv function, the network message structure in the transport layer is found in the UDP protocol binding table according to the bound destination address, and the receiving queue of the transmission channel socket to be forwarded is found, and then the network message structure in the transport layer of the communication initiator container is directly attached to the receiving queue of the destination socket of the communication receiving container; wherein the udp_send process is implemented by the udp_send function, which is used to establish communication with the communication receiving container.

[0031] Furthermore, the specific method for reading the packet receiving queue by the transport layer of the communication receiving end container is:

[0032] The transport layer of the communication receiving container directly calls the udp_recvmsg packet receiving function under the kernel to read the packet receiving queue and complete fast communication.

[0033] Furthermore, after the network message structure is generated, the following operations are performed:

[0034] Determine whether the communication initiator container has the ptype_all protocol enabled. If so, send the network message structure to the IP layer of the communication initiator container. In the IP layer of the communication initiator container, encapsulate the MAC header according to the message format requirements of the standard network protocol to form a standard message and send it to the MAC layer of the communication initiator container, so that the TCPDUMP packet capture tool can be used to capture the message. Otherwise, no additional processing is performed.

[0035] The beneficial effects of the present invention are as follows: the method mainly optimizes the inter-container communication process of the prior art, reduces the complex and time-consuming steps in the existing inter-container communication process, designs a fast path that can directly complete the inter-container communication at the transport layer, and realizes the cross-namespace transfer of network messages through shared memory transmission and reception. It means that in fast communication operations, shared memory technology is used to reduce the copying of messages, thereby eliminating the cumbersome paths and processing procedures of the IP layer and the virtual bridge layer in the existing process, and finally realizes fast communication between different containers on the same hardware platform to meet the high real-time requirements. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 Schematic diagram of the process of this method. DETAILED DESCRIPTION

[0037] The specific implementation modes of the present invention are described below so that those skilled in the art can understand the present invention. However, it should be clear that the present invention is not limited to the scope of the specific implementation modes. For those of ordinary skill in the art, as long as various changes are within the spirit and scope of the present invention as defined and determined by the attached claims, these changes are obvious, and all inventions and creations utilizing the concept of the present invention are protected.

[0038] like Figure 1 As shown, the high real-time fast container communication method based on the domestic hardware platform includes the following steps:

[0039] S1. The transport layer of the communication initiator container performs UDP packet assembly to generate a network message structure;

[0040] S2. The transport layer of the communication initiator container searches and analyzes the destination address. If the destination address and the communication initiator container are on the same host, the process proceeds to step S3; otherwise, the network message structure is handed over to the IP layer for processing, and communication is performed through the IP layer.

[0041] S3. The communication initiator container uses shared memory technology to transfer network messages across namespaces, and directly connects the network message structure from the communication initiator container transport layer to the receiving queue of the destination socket of the communication receiving container.

[0042] S4. The transport layer of the communication receiving end container reads the packet receiving queue to complete the fast communication.

[0043] In the specific implementation process, the fast communication operation (fast forwarding rule) in this method directly communicates between containers at the transport layer. In the fast communication operation, in order to facilitate the fast search of the destination address, a hash table can be maintained in the kernel state, and this hash table is updated when the network card device status and IP of the hardware platform change.

[0044] The specific method for UDP packet grouping is:

[0045] The communication initiator container calls the send to function to start the message sending process;

[0046] The communication initiator container calls the udp_send_skb function to find the route and set the IP header to generate a network message structure.

[0047] The specific method for searching the destination address is: traverse all IPv4 addresses of all network interface devices in each network namespace, and find the IPv4 address of the network interface device in the network namespace where the destination address is located through the destination address.

[0048] Determining whether the destination address can be delivered is the key method in this method to reduce the communication latency between containers. Specifically, the specific method for determining whether the destination address and the communication initiator container are on the same host is as follows: when the IPv4 address of the network interface device in the network namespace where the destination address is located is the same as the destination IPv4 address of the network message structure, determine whether the communication initiator container and the communication receiver container are both veth devices and the peer interfaces are in the same bridge. If so, determine that the destination address and the communication initiator container are on the same host; otherwise, determine that the destination address and the communication initiator container are not on the same host.

[0049] By analyzing the destination address, it is determined whether the container that actively initiates inter-container process communication and the target container with which it wants to establish communication are running on the same host / hardware platform. If the container that actively initiates inter-container process communication and the target container are on the same hardware platform, the conditions for using the fast communication operation proposed by this method are met.

[0050] The cross-namespace transfer of network messages through shared memory transmission and reception means that in fast communication operations, shared memory technology is used to reduce the copying of messages. That is, if the fast forwarding rules are met, the receiving function is directly called to wake up the thread waiting to receive packets in another container to receive the message. This design further optimizes the communication efficiency between containers and reduces the communication delay between containers. Specifically, the specific method of using shared memory technology to transfer network messages across namespaces and directly attaching the network message structure from the transport layer of the communication initiator container to the receiving queue of the destination socket of the communication receiving container is as follows:

[0051] In the udp_send process of the Linux protocol stack, by adding the udp_skb_direct_rcv function, the network message structure in the transport layer is found in the UDP protocol binding table according to the bound destination address, and the receiving queue of the transmission channel socket to be forwarded is found, and then the network message structure in the transport layer of the communication initiator container is directly attached to the receiving queue of the destination socket of the communication receiving container; wherein the udp_send process is implemented by the udp_send function, which is used to establish communication with the communication receiving container.

[0052] The specific method of reading the packet receiving queue by the transport layer of the communication receiving end container is: the transport layer of the communication receiving end container directly calls the udp_recvmsg packet receiving function under the kernel to read the packet receiving queue, thereby completing fast communication.

[0053] In this embodiment, when the two communicating containers are on the same host / hardware platform, the network message structure of the communication is not transmitted through the IP layer and the MAC layer. However, in actual work, relevant personnel may need to capture and debug the transmitted network message structure, and the traditional TCPDUMP packet capture tool cannot capture packets at the transport layer. Therefore, in order to provide the relevant personnel with the packet capture function, this method also performs the following operations after generating the network message structure:

[0054] Determine whether the communication initiator container has the ptype_all protocol enabled. If so, send the network message structure to the IP layer of the communication initiator container. In the IP layer of the communication initiator container, encapsulate the MAC header according to the message format requirements of the standard network protocol to form a standard message and send it to the MAC layer of the communication initiator container, so that the TCPDUMP packet capture tool can be used to capture the message. Otherwise, no additional processing is performed.

[0055] In one embodiment of the present invention, taking the Feiteng domestic hardware platform as an example, the process of using the fast communication operation on the platform is as follows:

[0056] Step 1: The user program in the container as the communication initiator sends UDP network data, that is, the user program uses the send to function call to send data;

[0057] Step 2: The data enters the transport layer of the communication initiator container for processing, completing the rapid communication between containers from the transport layer processing of the communication initiator container to the transport layer receiving of the communication receiving container;

[0058] Step 3: The receiving container is awakened and continues to execute the udp_recvmsg function to read the packet receiving queue and complete the packet receiving.

[0059] Comparing the above process with the process of the prior art, the following differences can be seen:

[0060] (1) Differences in data message processing at the transport layer;

[0061] Existing method: Perform standard UDP packet encapsulation and transmit the encapsulated message further downward to the IP layer;

[0062] The fast communication operation of this method: completing the network message structure generation, destination address fast search and analysis at the transport layer, and realizing the fast communication process of network message cross-namespace transfer through shared memory technology;

[0063] (2) Differences in data message processing at the IP layer;

[0064] Existing methods: Packets are encapsulated and processed in a standard manner at the IP layer, and then forwarded to the virtual bridge layer;

[0065] The fast communication operation of this method: no IP layer processing flow;

[0066] (3) Differences in data message processing at the virtual bridge layer:

[0067] Existing method: Packeting and processing are performed at the virtual bridge layer, and then the packets are sent to the target container address for unpacking and processing;

[0068] The fast communication operation of this method: no virtual bridge layer processing flow;

[0069] (4) Differences in packet capture implementation mechanisms during maintenance and testing:

[0070] Existing methods: The tcpdump tool captures the MAC layer messages in the communication process;

[0071] The fast communication operation of this method: the ptype_all protocol is used as a switch to enable the packet capture function. When the system enables ptype_all, the MAC header of the message will be encapsulated while fast forwarding, and the message will be sent to the MAC layer through the standard interface, so that the standard tcpdump tool can capture this message, and it is only used for TCPDUMP tool capture. This operation can save system computing resources when packet capture is not needed.

[0072] In this embodiment, a comparative test of UDP transmission delay between ordinary container communication in bridge mode and MACVLAN network card virtual mode and the high real-time fast container communication method proposed by this method is also carried out. The test results are shown in Table 1 below.

[0073] Table 1: Comparative test results

[0074]

[0075] From the above differences and Table 1, it can be seen that the processing steps of the IP layer and the virtual bridge layer are omitted in the fast communication operation of this method. Compared with the existing technology, this method can save more than 60% of the communication time, greatly improve the efficiency of inter-container communication based on domestic hardware platforms, greatly reduce the delay of inter-container communication on the hardware platform, and expand the application scope of inter-container communication technology based on hardware devices in various fields.

Claims

1. A high real-time and fast container communication method based on a domestic hardware platform, characterized in that: The following steps are involved: S1. The transport layer of the communication initiator container performs UDP packet assembly to generate a network message structure; S2. The transport layer of the communication initiator container searches and analyzes the destination address. If the destination address and the communication initiator container are on the same host, the process proceeds to step S3; otherwise, the network message structure is handed over to the IP layer for processing, and communication is performed through the IP layer. S3. The communication initiator container uses shared memory technology to transfer network messages across namespaces, and directly connects the network message structure from the communication initiator container transport layer to the receiving queue of the destination socket of the communication receiving container. S4, the transport layer of the communication receiving end container reads the packet receiving queue to complete the fast communication; The specific method for UDP packet grouping is: The communication initiator container calls the send to function to start the message sending process; The communication initiator container calls the udp_send_skb function to find the route and set the IP header to generate a network message structure. The specific method for searching the destination address is as follows: Traverse all IPv4 addresses of all network interface devices in each network namespace, and find the IPv4 address of the network interface device in the network namespace where the destination address is located through the destination address; The specific method to determine whether the destination address and the communication initiator container are on the same host is: When the IPv4 address of the network interface device in the network namespace where the destination address is located is the same as the destination IPv4 address of the network message structure, determine whether the communication initiator container and the communication receiver container are both veth devices and the peer interfaces are in the same bridge. If so, it is determined that the destination address and the communication initiator container are on the same host; otherwise, it is determined that the destination address and the communication initiator container are not on the same host; The specific method of using shared memory technology to realize the cross-namespace transfer of network messages and directly attaching the network message structure from the transport layer of the communication initiator container to the receiving queue of the destination socket of the communication receiver container is as follows: In the udp_send process of the Linux protocol stack, by adding the udp_skb_direct_rcv function, the network message structure in the transport layer is found in the UDP protocol binding table according to the bound destination address, and the network message structure in the transport layer of the communication initiator container is directly attached to the receiving queue of the destination socket of the communication receiving container. The udp_send process is implemented by the udp_send function, which is used to establish communication with the communication receiving end container; The specific method of reading the packet receiving queue by the transport layer of the communication receiving end container is: The transport layer of the communication receiving container directly calls the udp_recvmsg packet receiving function under the kernel to read the packet receiving queue and complete fast communication.

2. According to claim 1, a high real-time fast container communication method based on a domestic hardware platform is characterized in that: After generating the network message structure, the following operations are performed: Determine whether the communication initiator container has the ptype_all protocol enabled. If so, send the network message structure to the IP layer of the communication initiator container. In the IP layer of the communication initiator container, encapsulate the MAC header according to the message format requirements of the standard network protocol to form a standard message and send it to the MAC layer of the communication initiator container, so that the message can be captured by the TCPDUMP packet capture tool. Otherwise, no additional processing is performed.

Citation Information

Patent Citations

  • Container network interface monitoring

    US20210234785A1

  • Communication method, apparatus, and system

    WO2022160714A1