Method for sending and receiving container messages, storage medium, and container communication system

By creating a proxy service module on the host operating system, using sockets to capture and forward container messages, the containers share the interface address of the network device operating system, solving the compatibility and resource occupation problems between the container and the external network communication, and improving the Resource utilization efficiency.

CN113765799BActive Publication Date: 2024-12-06ZTE CORP
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202010504733.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-06-05
Publication Date
2024-12-06
Estimated Expiration
2040-06-05

AI Technical Summary

Technical Problem

In the prior art, the container communicates with the external network with low openness and incompatible with existing devices, and the container needs to occupy interface address resources separately, resulting in high deployment costs.

Method used

By creating a proxy service module on the host operating system, using sockets to capture and forward container messages, the container shares the interface address of the network device operating system, and realizes communication between the container and the external network, avoiding additional occupancy of interface resources.

Benefits of technology

It improves resource utilization efficiency, solves the problem that container communication is incompatible with existing equipment and occupies additional interface resources, and realizes efficient communication between containers and external networks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113765799B_ABST
    Figure CN113765799B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides a method, system and computer storage medium for sending and receiving container messages, the method comprising: the container message is sent from the eth0 interface, the address of the eth0 interface is the interface address of the network device operating system NOS; the proxy service module creates a socket on the host operating system, the socket is used to capture the container message sent by the container; the proxy service module forwards the container message to the NOS, and the NOS sends the container message. Through the present invention, the technical effect of the container communicating with the external device on the basis of the existing device and not occupying additional resources is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to, but are not limited to, a method for sending and receiving container messages, a storage medium, and a container communication system. Background Art

[0002] With the rapid development of the Internet and cloud computing, the construction scale of data centers is getting larger and larger, and the system complexity is getting higher and higher, which brings great challenges to the operation and maintenance of network equipment. Making network equipment more open has become a trend in future technology development. There are two major aspects to achieving network openness: on the one hand, by using management tools, improving the management level of network automation and supporting a wide range of automation features; on the other hand, supporting the programmability of network equipment.

[0003] As the scale of networks grows, especially in virtualized environments, manual configuration becomes almost impossible. Therefore, it is becoming a trend to use management tools to automate the deployment of network devices. The network has programmable capabilities, which can reduce network complexity and meet the network requirements of virtualization and cloud computing. Future network development requires the construction of a new network system that can provide open programmable interfaces.

[0004] Generally speaking, there are several technical methods to provide basic open capabilities for network devices: First, the network device operating system is directly based on the native Linux kernel protocol stack. In this way, the original network device system can be considered an open system, and there is no need to provide open capability support separately. The network device operating system is based on the user-mode NOS (network operating system) provided by the device, and provides an open architecture by loading a third-party container system through integrated deployment. However, due to the limitations of the operating system capabilities of the network device, it is not applicable to network devices that use a user-mode protocol stack operating system. In addition, this method poses great challenges to the security of the device.

[0005] The second method is that the container communicates with the outside world with the help of the network device NOS, but an external communication IP address needs to be allocated to the container separately. The container communicates with the outside world with the help of the network device NOS, and needs to monopolize the IP address of the network device or the interface of the network device from the resource point of view, and needs to notify the external system of this address as the communication address of the container. This method is presented in a dual-system mode in terms of external presentation. The original network device operating system and the container system need to be independently allocated different addresses, and the deployment cost is relatively high. Summary of the invention

[0006] In order to solve the above technical problems, the present invention provides a method and system for sending and receiving container messages, which solves the problems of low openness and incompatibility with existing devices in communication between containers and external networks, and the need for containers to occupy interface address resources separately.

[0007] According to an embodiment of the present invention, a method for sending a container message is provided, comprising: a container message is sent from an eth0 interface, the address of the eth0 interface is an interface address of a network device operating system (NOS); a proxy service module creates a socket on a host operating system, the socket is used to capture the container message sent by the container; the proxy service module forwards the container message to the NOS, and the NOS sends the container message.

[0008] According to another embodiment of the present invention, a method for receiving a container message is provided, including: a NOS receives a container message, the container message address is an interface address of the NOS, and forwards the container message to a proxy service module; the proxy service module creates a socket on a host operating system, and the socket forwards the container message to a container.

[0009] According to another embodiment of the present invention, a container communication system is provided, including: a container, wherein the container creates an eth0 interface, the address of the eth0 interface is the interface address of a network device operating system (NOS), and a container message is sent through the eth0 interface; a proxy service module, wherein the proxy service module creates a socket on a host operating system, the socket is used to capture container messages sent by the container, and the proxy service module forwards the container message to the NOS; and the NOS is used to send the container message.

[0010] According to another embodiment of the present invention, there is provided an implementation device for receiving or sending a container message, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the implementation method for receiving or sending a container message when executing the program.

[0011] According to another embodiment of the present invention, a computer-readable storage medium is provided, storing computer-executable instructions, wherein the computer-executable instructions are used to execute the method for implementing the container message receiving or sending.

[0012] Through this application, with the proxy module as a bridge, the container message is forwarded by the proxy module and finally sent or received by the network device, and the container shares the interface address of the network device operating system NOS, thereby achieving the technical effect that the container can communicate with the outside through existing devices. At the same time, the container does not need to occupy additional interface resources, thereby solving the problem in the prior art that container communication is incompatible with existing devices and needs to occupy additional interface resources, thereby improving resource utilization efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0014] Figure 1 Flow chart of a method for sending a container message according to an embodiment of the present invention

[0015] Figure 2 This is a flowchart of creating a container communication network according to an embodiment of the present invention.

[0016] Figure 3 This is a data flow diagram of the communication between the container and the outside world according to an embodiment of the present invention.

[0017] Figure 4 This is a data flow diagram of the internal communication between the container and the network device NOS according to an embodiment of the present invention.

[0018] Figure 5 This is a structural block diagram of a container communication system according to an embodiment of the present invention. DETAILED DESCRIPTION

[0019] The present invention will be described in detail below with reference to the accompanying drawings and in combination with embodiments. It should be noted that the embodiments and features in the embodiments of the present application can be combined with each other without conflict.

[0020] Embodiment 1

[0021] In this embodiment, a method for sending a container message is provided. Figure 1 is a flow chart of a method for sending a container message according to an embodiment of the present invention, such as Figure 1 As shown, the process includes the following steps:

[0022] Step S101, the container message is sent from the eth0 interface, and the address of the eth0 interface is the network device operating system NOS interface address;

[0023] In step S101, the container is connected to the operating system of the host through a virtual Ethernet pair veth pair (a virtual Ethernet pair is a pair of ports, all data packets entering from one end of the pair of ports will exit from the other end, and vice versa), and eth0 is the interface on the container side in the veth pair. The proxy module registers the TCP port range and / or the UDP port range of the container.

[0024] Step S102: the proxy service module creates a socket on the host operating system, where the socket is used to capture the container message sent by the container;

[0025] Before the container message is sent out from the eth0 interface, the container sends an Address Resolution Protocol Request (ARP request) to the destination address of the message; the socket captures the ARP request and completes the ARP request using the interface address of the network device operating system.

[0026] Step S013: the proxy service module forwards the container message to the NOS, and the NOS sends the container message.

[0027] In step S103, when the destination address of the container message is the IP address of the NOS, the container message is processed locally by the NOS; when the address of the container message is not the IP address of the NOS, the container message is sent to the external device by the NOS after searching for a route.

[0028] Embodiment 2

[0029] In this embodiment, a method for creating a container communication system is provided. Figure 2 is a flow chart of creating a container communication network according to an embodiment of the present invention, such as Figure 2 As shown, the process includes the following steps:

[0030] Step S201, firstly, through the basic container bridge network mode, the container is connected to the host OS through the virtual Ethernet network;

[0031] In step S201, one of the interfaces in the veth pair, eth0, is an interface in the container, and the other interface in the veth pair is connected to the bridge of the host. Generally, this creation work can be completed by the container network. When the specified container network is in bridge mode, it is the connection mode of the veth pair.

[0032] Step S202, creating a lo interface for the container, where the interface address inherits the interface address of the NOS;

[0033] In step S202, the container lo interface inherits the NOS interface address in order to reuse the NOS interface address for external communication. After the network device and the external communication interface are configured with an IP address, the address is synchronously configured to the container lo interface through the proxy service module.

[0034] Step S203, create a default route for the container, the route points to the eth0 interface in the veth pair, and the communication source address uses the lo interface address;

[0035] In step S203, the lo interface address is the interface address of the multiplexed network device. In specific implementation, after the network device and the external communication interface are configured with an IP address, the address is synchronously configured to the lo interface of the container through the proxy service module.

[0036] Step S204, creating a Socket based on the host system and binding an interface to capture messages sent by the container;

[0037] In step S204, the proxy module creates a Socket based on the host operating system. The Socket is bound to the host side of the vethpair and connected to the network port of the host to capture messages sent from the container. Messages sent from the outside to the container are also distributed to the container through the socket.

[0038] Among them, Socket is the proxy service module to realize the proxy between the container and the network device NOS. It creates a socket through the host operating system and connects to the host's network port to capture packets by binding the socket to the veth pair, so as to capture the messages sent by the container.

[0039] Step S205, creating a communication channel between the proxy module and the NOS;

[0040] In step S205, based on the interface provided by the NOS, a communication channel between the proxy module and the NOS is created, and the captured message sent by the container is sent to the NOS through the channel, and finally the NOS communicates with the outside world. Similarly, the message sent from the outside to the container is also received through this communication channel.

[0041] Step S206, completing the registration of the TCP / UDP port range of the container system.

[0042] In step S206, the registration of the TCP / UDP port range of the container is completed to provide a basis for the container and the network device to share IP address resources.

[0043] Embodiment 3

[0044] In this embodiment, a method for creating a container communication system is provided. Figure 3 is a data flow diagram of the communication between the container and the outside world according to an embodiment of the present invention, such as Figure 3 As shown, the data flow includes the following steps:

[0045] Step 301: When the container system communicates with the outside, according to the routing of the container system, the message is sent from the eth0 interface, using the IP_NOS address of the NOS interface as the source address, and according to the link type of the routing, first triggering an ARP request to the destination address of the communication;

[0046] Step 302: The proxy service module creates a socket based on the host OS, binds it to the docker0 interface, captures the ARP request sent from the container, and uses the NOS interface address to implement the ARP proxy. After the ARP proxy learning process of the container system is completed, all subsequent IP packets sent from the container system are captured by the socket.

[0047] Step 303: The proxy service module transfers the captured outbound message of the container to the NOS for processing through the communication channel between the proxy service module and the NOS;

[0048] Step 304, the NOS receives the message forwarded by the proxy service module, performs NOS processing normally, and sends the message from the NOS network interface to the external device by searching for a route;

[0049] Step 305, the NOS receives a message sent from the external device to the container through the interface of the network device;

[0050] Step 306: The network device NOS system processes the received message, the destination address of the message is the device interface address IP_NOS, and distributes it according to the TCP / UDP port interval registered by the proxy service module for the container system, and distributes the message sent to the container to the proxy service module;

[0051] Step 307, the proxy service module distributes the message to the bridge (Docker0) on the Bridge connecting the container and the host through the Socket of the host operating system;

[0052] Here, Docker0 connects to other physical or virtual network cards at the kernel layer, placing all containers and the local host on the same physical network.

[0053] Step 308: Use the Layer 2 forwarding (MAC forwarding) of the Bridge to distribute the message to the container system.

[0054] Embodiment 4

[0055] In this embodiment, a method for creating a container communication system is provided. Figure 4 : is a data flow diagram of internal communication between the container and the network device NOS according to an embodiment of the present invention, such as Figure 4 As shown, the data flow includes the following steps:

[0056] Step 401: When the container system communicates with the NOS internally, according to the routing of the container message, the message is sent from the eth0 interface, using the NOS interface IP_NOS address as the source address, and the destination address is the device interface address IP_NOS2. According to the link type of the route, an ARP request is first triggered to the destination address of the communication;

[0057] Step 402: The proxy service module completes the ARP learning process of the container system. All subsequent IP packets sent from the container system are captured and sent out by the Socket.

[0058] Step 403: The proxy service module transfers the captured outbound message of the container to the NOS for processing through the communication channel with the NOS;

[0059] Step 404: NOS receives the message forwarded by the proxy service module, performs normal NOS processing, searches for the local termination of the route, and forwards it to NOS for service processing. At the same time, for the message sent by NOS with the destination address being IP_NOS, the route is processed locally;

[0060] Step 405: The NOS determines whether the message is to be sent to the container based on the port range registered by the proxy service module for the container system. If yes, the NOS distributes the message to the proxy service module.

[0061] Step 406: The proxy service module distributes the message to the bridge (Docker0) connecting the host and the container through the Socket of the host operating system;

[0062] Step 407: Use the Layer 2 forwarding (MAC forwarding) of the Bridge to distribute the message to the container system for reception.

[0063] Embodiment 5

[0064] In this embodiment, a method for creating a container communication system is provided. Figure 5 is a structural block diagram of a container communication system according to an embodiment of the present invention. Figure 5 As shown, this system includes the following modules:

[0065] Network device host operating system module: provides the device host operating system, carries and supports the operating system of the network device, and serves as the host system for the container;

[0066] Network device operating system module: the main operating system that provides services for network devices, works in the user-mode protocol stack, and provides software routing operating systems for network devices through the network device operating system;

[0067] Container system module: A container system integrated into network devices to provide open capability support for network devices;

[0068] Proxy service module: realizes intercommunication between the host operating system, network device operating system, and container modules, establishes a socket on the host, uses the socket to capture the message sent by the container, and forwards it to the network device operating system, which sends it out; or receives the message sent by the network device to the container and forwards it to the container.

[0069] According to another embodiment of the present invention, there is provided an implementation device for receiving or sending a container message, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the implementation method for receiving or sending a container message when executing the program.

[0070] According to another embodiment of the present invention, a computer-readable storage medium is provided, storing computer-executable instructions, wherein the computer-executable instructions are used to execute the method for implementing the container message receiving or sending.

[0071] In this embodiment, the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store program codes.

[0072] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In hardware implementations, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all components may be implemented as software executed by a processor, such as a digital signal processor or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, it is well known to those of ordinary skill in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.

Claims

1. A method for sending a container message, comprising: The container message is sent from the eth0 interface, and the address of the eth0 interface is the interface address of the network device operating system NOS; The proxy service module creates a socket on the host operating system, where the socket is used to capture the container message sent by the container; The container is connected to the host operating system through a virtual Ethernet network veth pair, the socket is bound to the host side of the veth pair, and the eth0 interface is one of the interfaces in the veth pair; The proxy service module forwards the captured container message to the NOS, and the NOS sends out the container message.

2. The method according to claim 1, before the container message is sent from the eth0 interface, further comprising: The container is connected to the host operating system via a virtual Ethernet network pair veth pair.

3. The method of claim 1, comprising: The proxy service module registers the Transmission Control Protocol TCP port interval and / or the User Datagram Protocol UDP port interval of the container.

4. The method according to claim 1, before the container message is sent from the eth0 interface, comprises: The container sends an Address Resolution Protocol (ARP) request to the destination address; The Socket captures the ARP reply request and uses the NOS interface address to complete the ARP reply.

5. The method according to claim 1, wherein the NOS sends the container message, comprising: When the destination address of the container message is the IP address of the NOS, the container message is processed locally by the NOS; Or, when the container message address is not the IP address of the NOS, the container message is sent to the external device by the NOS after searching for a route.

6. A method for receiving a container message, comprising: The NOS receives the container message and forwards the container message to the proxy service module, wherein the container message address is the interface address of the NOS; The proxy service module creates a socket on the host operating system, and the socket forwards the container message to the eth0 interface of the container, where the address of the eth0 interface is the interface address of the network device operating system NOS; The container is connected to the host operating system through a virtual Ethernet pair veth pair, the socket is bound to the host side of the veth pair, and the eth0 interface is one of the interfaces in the veth pair.

7. The method of claim 6, comprising: The proxy service module registers the Transmission Control Protocol TCP port interval and / or the User Datagram Protocol UDP port interval of the container.

8. The method of claim 7, comprising: The NOS sends the container message to the proxy service module according to the TCP port interval and / or UDP port interval pair.

9. A container communication system, comprising: A container creates an eth0 interface, the address of which is the network device operating system NOS interface address, and sends a container message through the eth0 interface; A proxy service module, wherein the proxy service module creates a socket on the host operating system, wherein the socket is used to capture container messages sent by the container, and the proxy service module forwards the container messages to the NOS; The NOS is used to send the container message; The container is connected to the host operating system through a virtual Ethernet pair veth pair, the socket is bound to the host side of the veth pair, and the eth0 interface is one of the interfaces in the veth pair.

10. A computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to execute the method for receiving or sending a container message according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Method and device for communication between multiple containers

    CN106487811A

  • Network isolation sharing method and device for multiple systems

    CN106789931A

  • Cross-host mutual access system based on docker containers and control method thereof

    CN107332775A

  • Message processing system and network equipment

    CN109309634A

  • Message processing system and network equipment

    CN109361606A