WO2020135856A1 - 一种网络通信方法及系统 - Google Patents
一种网络通信方法及系统 Download PDFInfo
- Publication number
- WO2020135856A1 WO2020135856A1 PCT/CN2019/129787 CN2019129787W WO2020135856A1 WO 2020135856 A1 WO2020135856 A1 WO 2020135856A1 CN 2019129787 W CN2019129787 W CN 2019129787W WO 2020135856 A1 WO2020135856 A1 WO 2020135856A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- data
- port
- application
- docker container
- address
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L49/00—Packet switching elements
- H04L49/70—Virtual switches
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L45/00—Routing or path finding of packets in data switching networks
- H04L45/38—Flow based routing
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L45/00—Routing or path finding of packets in data switching networks
- H04L45/64—Routing or path finding of packets in data switching networks using an overlay routing layer
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L45/00—Routing or path finding of packets in data switching networks
- H04L45/74—Address processing for routing
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L65/00—Network arrangements, protocols or services for supporting real-time applications in data packet communication
- H04L65/60—Network streaming of media packets
- H04L65/65—Network streaming protocols, e.g. real-time transport protocol [RTP] or real-time control protocol [RTCP]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L65/00—Network arrangements, protocols or services for supporting real-time applications in data packet communication
- H04L65/60—Network streaming of media packets
- H04L65/75—Media network packet handling
- H04L65/762—Media network packet handling at the source
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
- G06F2009/45595—Network integration; Enabling network access in virtual machine instances
Definitions
- This application relates to, but is not limited to, the field of communication technology, such as a network communication method and system.
- Microservice architecture has become one of the mainstream models for software system development and deployment.
- Docker containers are usually used to deploy services in order to achieve rapid deployment of services and dynamic scaling of instances.
- Docker is an open source application container engine that allows developers to package applications into containers.
- Kubernetes usually implements container cluster management and scheduling, and at the same time combines network plug-ins such as Flannel to achieve network interconnection and interworking between Docker containers.
- Flannel network plug-ins
- the service functions of the applications are relatively simple, and the overall capacity requirements are not high.
- the system is increasing.
- UDP User Datagram Protocol
- the Docker container itself also provides docker-proxy to implement packet forwarding of container applications, but its implementation mechanism is to provide a docker-proxy process to forward data packets for each container port that is port mapped.
- its implementation mechanism is to provide a docker-proxy process to forward data packets for each container port that is port mapped.
- the embodiments of the present application provide a network communication method and system, which can reduce the port management complexity of the Docker container and improve the data transmission efficiency.
- an embodiment of the present application provides a network communication method, including: determining a data forwarding rule in a Docker container, a pair of first ports of the Docker container is mapped to a port of the host where it is located; according to the data forwarding rule, Forwarding the data packet received through the first port to the application deployed in the Docker container, or forwarding the data packet sent by the application deployed in the Docker container to the external device through the first port.
- an embodiment of the present application provides a network communication system, including: a data distribution unit and a network application unit; the data distribution unit and the network application unit are deployed in a Docker container; a pair of A port is mapped to the port of the host where it is located; the network application unit includes at least one application; the data distribution unit is set to determine the data forwarding rules in the Docker container; according to the data forwarding rules, it will pass the The data packet received by the first port is forwarded to an application in the network application unit, or the data packet sent by the application in the network application unit is forwarded to an external device through the first port.
- an embodiment of the present application provides a network device, including: a processor and a memory; the memory is configured to store a network communication program, and when the network communication program is executed by the processor, the above network communication method is implemented.
- an embodiment of the present application provides a computer-readable medium that stores a network communication program.
- the network communication program is executed by a processor, the above network communication method is implemented.
- FIG. 1 is a schematic diagram of a network communication system provided by an embodiment of this application.
- FIG. 2 is a schematic diagram of an implementation process of a network communication system provided by an embodiment of this application.
- FIG. 3 is a flowchart of a network communication method provided by an embodiment of the present application.
- FIG. 5 is an exemplary flowchart of another network communication method provided by an embodiment of the present application.
- FIG. 6 is an example flowchart of another network communication method provided by an embodiment of the present application.
- FIG. 7 is an example flowchart of another network communication method provided by an embodiment of the present application.
- FIG. 8 is a schematic diagram of a network device provided by an embodiment of this application.
- FIG. 1 is a schematic diagram of a network communication system provided by an embodiment of this application.
- 2 is a schematic diagram of an implementation process of a network communication system provided by an embodiment of the present application.
- the network communication system provided by this embodiment includes a data distribution unit 112 and a network application unit 114.
- the data distribution unit 112 and the network application unit 114 are deployed in the Docker container 11.
- the Docker container 11 may be deployed on a network device (which may be called a host), and multiple Docker containers may be deployed on each network device at the same time.
- At least one application can be deployed on the Docker container 11, for example, different network applications can be instantiated according to different business scenarios.
- the network application unit 114 may include at least one application, such as application 1, application 2, and application n in FIG. 2, where application 1 is bound to port a, application 2 is bound to port b, and application n is bound Port n.
- a pair of first ports of the Docker container 11 (port B is used in FIG. 2) is mapped to the port of the host.
- a pair of first ports can include a Realtime Transport Protocol (Realtime Transport Protocol, RTP) port and a Real Time Transport Control Protocol (Realtime Transport Control (Protocol, RTCP) port, a pair of first ports of the Docker container 11 are set to transmit data .
- the Docker container 11 may use a port mapping method to expose a pair of first ports on the host where the Docker container 11 is started, and the exposed pair of first ports are set to receive data packets from the external device 10, or, to the external device 10 Send the data packet.
- the Docker container 11 when the Docker container 11 starts, it will initialize the correspondence between the Docker container address and the network protocol (Internet Protocol, IP) address of the host, and the mapping relationship between the first port and the port on the host. Based on this, the Docker container 11 can realize data interaction with the external device 10.
- IP Internet Protocol
- the data distribution unit 112 is configured to determine the data forwarding rules in the Docker container 11 and forward the data packets received through the first port (eg, port B in FIG. 2) to the network according to the data forwarding rules
- the application in the application unit 114 or the data packet sent by the application in the network application unit 114 is forwarded to the external device 10 through the first port.
- the external device 10 may include other objects than the Docker container 11, such as other network devices or other Docker containers.
- this application is not limited to this.
- the Docker container 11 only needs to expose a pair of first ports to the outside.
- the exposed pair of first ports is set for data transmission. No matter how much data exists between the external device 10 and the network application unit 114, it will pass through the first The port is transmitted, and the exposed port will not be dynamically increased.
- the only thing that changes dynamically is the data forwarding rules in the Docker container 11; among them, when adding one way of data, the data distribution unit 112 can add a data forwarding rule; when deleting one way of data, The data distribution unit 112 may delete a corresponding data forwarding rule.
- the data forwarding rule may be used to record the information of the data source and the data destination of each way of data, where the data source or data destination may be an application within the network application unit 114.
- the information of the data source may include the source address and the source port; the information of the data destination may include: the destination address and the destination port; wherein, the source port or the destination port may be an application in the network application unit 114 The bound port.
- This application is not limited to this.
- the information of the data source may include: the address of the Docker container where the application is located, the port to which the application is bound, and the identification of the application ( Identity, Document, ID).
- the destination address of the channel of data can be the IP address of the host where the Docker container is located, and the destination port of the channel of data can be inside the Docker container The port to which the deployed application is bound.
- the source address of the channel data can be the IP address of the host where the Docker container is located, and the destination port of the channel data can be the Docker container The port to which the deployed application is bound.
- the data distribution unit 112 may be configured to forward the data packet received through the first port to the application deployed in the Docker container 11 according to the data forwarding rule by: The source address carried in the data packet received by the first port and the destination port corresponding to the source port in common; forward the data packet to the application in the network application unit 114 bound to the destination port.
- the data distribution unit 112 receives the data packet carrying the source address and the source port through port B; the destination address and the corresponding address of the source address and the source port are recorded in the data forwarding rule In the case of the destination port, the data packet is forwarded in the Docker container 11 according to the found destination port. For example, if the destination port corresponding to the source address and the source port is recorded as port a in the data forwarding rule, the data distribution unit 112 forwards the received data packet to the application 1 bound to port a; this is not recorded in the data forwarding rule In the case of source address and source port, the received packet is directly discarded.
- the data distribution unit 112 may forward the data packet sent by the application deployed in the Docker container 11 to the external device 10 through the first port according to the data forwarding rule by: querying the data forwarding rule to determine The IP address and port of the external device corresponding to the port bound to the application to which the data packet is sent in the Docker container; the data packet is forwarded to the external device through the first port.
- the data distribution unit 112 after receiving the data packet sent by the application 1 in the network application unit 114, the data distribution unit 112 queries the data forwarding rule whether there is a destination address and a destination port corresponding to port a , In the case where the IP address and port of the external device 10 corresponding to port a can be queried, the data distribution unit 112 forwards the data packet to the external device 10 through the port B, and if no corresponding record of the port a is queried, directly Discard received packets.
- the network communication system provided in this embodiment may further include: a signaling processing unit 110 configured to acquire communication link information of each channel of data and send the communication The link information is given to the data distribution unit 112; the data distribution unit 112 may be configured to determine the data forwarding rules in the Docker container 11 according to the communication link information of each channel of data.
- a second port of the Docker container 11 (for example, port A in FIG. 2) is mapped to the port of the host where the second port is set to transmit signaling.
- the signaling processing unit 110 may be configured to obtain the communication link information of each channel of data in any of the following ways:
- Method 1 Perform signaling interaction with an external device (for example, the external device 10) through the second port to determine the source address and source port of any data to be received through the first port (for example, the IP address and port of the external device 10) ); Obtain the address and port of the Docker container to which the application is bound from the application that is to receive the data of the way; determine the data of the way according to the source address, source port of the way of data, and the address and port of the Docker container bound to the application Communication link information;
- Method 2 Receive the request message sent by the external device through the second port, and parse out the destination address and destination port of any data to be sent through the first port from the request message (for example, the IP address and port of the external device 10) 1.
- the application to send the data of the way obtain the address and port of the Docker container bound to the application from the application to send the data of the way; according to the destination address and destination port of the data of the way, the address and port of the Docker container bound to the application To determine the communication link information of the data.
- the signaling processing unit 110 is responsible for interacting with an external device (for example, the external device 10) through standard signaling to complete data negotiation.
- These standard signaling may generally include a session initiation protocol (Session Initiation Protocol) , SIP), Real Time Streaming Protocol (Real Time Streaming Protocol, RTSP), Media Gateway Control Protocol (Media Gateway Control Protocol, MGCP) and other protocols.
- the signaling transmission channel can support multiple modes such as Transmission Control Protocol (TCP), User Datagram Protocol (User Datagram Protocol, UDP) and so on. Since the signaling processing unit 110 needs to communicate with an external device (for example, the external device 10), a port for transmitting signaling (that is, the second port described above, such as port A in FIG. 2) is mapped through the port Way to the host. For the entire Docker container, there is usually only one port for signaling transmission, so it will not affect the host's packet forwarding based on iptables rules.
- TCP Transmission Control Protocol
- UDP User Datagram
- the data distribution unit 112 is responsible for communicating with the external device 10 through a standard data transmission protocol, receiving and forwarding data packets based on data forwarding rules.
- the data distribution unit 112 may expose a pair of ports for data packet transmission (that is, the above-mentioned first port, such as port B in FIG. 2) on the host through a port mapping manner. For the entire Docker container, only a pair of ports need to be exposed for data transmission, so it will not affect the host's forwarding of data packets based on iptables rules.
- the data forwarding rules can be created or updated according to the communication link information sent by the signaling processing unit 110.
- the data distribution unit 112 can query the source address and source port carried in the data packet by querying Data forwarding rules to determine which port to forward to the Docker container, or which external device.
- the network application unit 114 is responsible for interacting with the data distribution unit 112 and can be instantiated into different network applications (eg, application 1, application 2, application n) according to different business scenarios, network application unit 114 can receive the data packet forwarded by the data distribution unit 112, and can also send the data packet to the data distribution unit 112.
- the network application unit 114 can be started when the Docker container 11 is started, or it can be started by other units (for example, a signaling processing unit 110) Create.
- the network application unit 114 and the data distribution unit 112 generally need to bind a pair of ports (a pair of ports includes an RTP port and an RTCP port) for each channel of data (for example, video or audio data), for example, application 1 in FIG.
- the signaling processing unit 110 may initiate a data session establishment request from port A, which may be a protocol such as SIP, RTSP, MGCP, or other protocols.
- port A which may be a protocol such as SIP, RTSP, MGCP, or other protocols.
- record the source address and source port of the peer data (For example, the IP address and port number of the external device 10).
- the receiving address of the local data can use the IP address of the host where the Docker container is located and the port B exposed by the Docker container on the host.
- the signaling processing unit 110 notifies the network application unit 114 that the network application unit 114 creates a new application 1, and the application 1 binds to port a, and the application 1 informs the signaling processing unit 110 of the Docker container address and port a it binds For processing data.
- the signaling processing unit 110 notifies the data distribution unit 112 of the data address pair to be forwarded (including the source address and source port of the peer data, and the Docker container address and port a bound to the data destination application 1).
- the data distribution unit 112 creates a data distribution mapping table based on the received information, in which the following correspondences are recorded: the source address, the source port, the IP address of the host where the Docker container is located, and the port bound by the application 1 as a data forwarding rule. It should be noted that, since the Docker container initializes the correspondence between the Docker container address and the host IP address where it is started, the host IP address where the Docker container is located can be determined based on the correspondence between the Docker container address and the above initialization.
- the data distribution unit 112 starts to receive the data packet, and queries the data forwarding rules in the data distribution mapping table according to the source address and source port carried in the data packet, and forwards the received data packet to the Docker container according to the query result
- the application 1 bound to the port a can perform corresponding services, such as video analysis tasks.
- the network communication system provided in this embodiment combines iptables-based forwarding and application distribution.
- the Docker container only needs to expose a pair of ports to realize multi-channel data transmission.
- the network communication system provided in this embodiment can reduce the management complexity of Docker container ports and improve the transmission efficiency of data packets, thereby facilitating operation and maintenance management. It also improves reliability.
- FIG. 3 is a flowchart of a network communication method provided by an embodiment of the present application.
- the network communication method provided in this embodiment may be applied to a Docker container deployed on a host, and a pair of first ports of the Docker container are mapped to ports of the host.
- a pair of first ports of the Docker container are mapped to ports of the host.
- the network communication method provided in this embodiment includes step 201 and step 202.
- step 201 the data forwarding rules in the Docker container are determined.
- step 202 forward the data packet received through the first port to the application deployed in the Docker container, or forward the data packet sent by the application deployed in the Docker container to the external device through the first port.
- a pair of first ports of the Docker container is mapped to the port of the host where it is located; according to the data forwarding rules in the Docker container, the data packets received through the first port are forwarded to the application deployed in the Docker container, Or, forward the data packet sent by the application deployed in the Docker container to the external device through the first port.
- the Docker container only needs to expose a pair of first ports on the host for transmitting data packets, which not only reduces the port management complexity, but also improves the data transmission efficiency.
- the data forwarding rule may be used to record information of the data source and data destination of each data, where the data source or data destination is an application deployed in the Docker container.
- the information of the data source may include: a source address and a source port; the information of the data destination may include: a destination address and a destination port, where the source port or the destination port is bound to an application deployed in the Docker container Fixed port.
- this application is not limited to this.
- the information of the data source may include: the address of the Docker container where the application is located, the port to which the application is bound, and the identification (ID) of the application .
- forwarding the data packet received through the first port to the application deployed in the Docker container according to the data forwarding rule may include: determining the first port from the data forwarding rule by querying the data forwarding rule The source address and source port carried by the received data packet correspond to the destination port; the data packet is forwarded to the application bound to the destination port in the Docker container.
- the data forwarding rule records the source address and source port (for example, the IP address and port of the external device 10) as the destination port is port a, you can receive
- the data packet is forwarded to application 1 that is bound to port a; when the source address and source port are not recorded in the data forwarding rule, the received data packet is directly discarded.
- forwarding the data packet sent by the application deployed in the Docker container to the external device through the first port may include: determining the Docker container by querying the data forwarding rule The IP address and port of the external device corresponding to the port to which the application that sends the data packet is bound; forwards the data packet to the external device through the first port.
- the source port of one channel of data recorded in the data forwarding rule may be the port bound to the application deployed in the Docker container, and the destination address and destination port of the channel of data may be the IP address and port of the external device .
- the data forwarding rule after receiving the data packet sent by an application deployed in the Docker container, query the data forwarding rule whether there is a destination address and a destination port corresponding to the port bound by the application, if the corresponding destination address can be queried And the destination port, such as the IP address and port of the external device, forwards the data packet to the external device through the first port, and if no corresponding record is queried, the received data packet is directly discarded.
- the network communication method may further include: acquiring communication link information of each data; at this time, step 201 may include: determining Docker according to the communication link information of each data Data forwarding rules in the container.
- a second port of the Docker container is mapped to the port of the host where it is located; wherein, obtaining the communication link information of each channel of data may include one of the following:
- Method 1 Use the second port to perform signaling interaction with an external device to determine the source address and source port of any data to be received through the first port; obtain the Docker container address bound to the application from the application to receive the data And port; based on the source address, source port, and Docker container address and port of the application, determine the communication link information of the data;
- Method 2 Receive a request message sent by an external device through the second port, and parse out the destination address and destination port of any channel of data to be sent through the first port, and the application of the channel of data to be sent from the request message;
- the application of the road data obtains the address and port of the Docker container bound to the application; according to the destination address, the destination port of the road data, and the address and port of the Docker container bound to the application, the communication link information of the road data is determined.
- the Docker container exposes the first port and the second port through port mapping during initialization, the first port is set to transmit data, and the second port is set to transmit signaling.
- the first port is set to transmit data
- the second port is set to transmit signaling.
- there is usually only one port for signaling transmission so it will not affect the host's packet forwarding based on iptables rules.
- only one pair of ports (the first port) needs to be exposed to the outside for data transmission, so it will not affect the host's forwarding of packets based on iptables rules.
- the Docker container only needs to expose a pair of first ports for data transmission. No matter how many data exists between the application deployed in the Docker container and the external device, they will be transmitted through the first port and will not be dynamic. Adding exposed ports, the only thing that changes dynamically is the data forwarding rules in the Docker container; among them, when adding a new way of data, you can add a record in the data forwarding rule; when deleting a way of data, you can delete a record in the data forwarding rule.
- the network communication method provided in this embodiment combines iptables-based forwarding and application distribution.
- the Docker container only needs to expose a pair of ports to realize multi-channel data transmission.
- the network communication method provided in this embodiment can reduce the management complexity of Docker container ports and improve the transmission efficiency of data packets, thereby facilitating operation and maintenance management. It also improves reliability.
- FIG. 4 is an exemplary flowchart of another network communication method provided by an embodiment of the present application. This example can be applied to the following scenarios:
- the network communication system pulls a data stream from the GB28181 server (that is, the streaming media server) through the Session Initiation Protocol (SIP), which is used for video analysis tasks; in this example, the network application
- SIP Session Initiation Protocol
- the unit may include a data analysis unit.
- the network communication method in this example may include steps S101 to S114.
- step S101 the signaling processing unit receives the video analysis task request; for example, the video analysis task request may be triggered by a click operation on a webpage corresponding to the network communication system.
- the video analysis task request may be triggered by a click operation on a webpage corresponding to the network communication system.
- this application is not limited to this.
- step S102 after receiving the video analysis task request, the signaling processing unit creates a data analysis unit.
- step S103 the data analysis unit sends the Docker container address and UDP port information (for example, port number) bound to the signaling processing unit, and the signaling processing unit records the Docker container address and UDP port bound by the data analysis unit Information (for example, port number).
- the data analysis unit Information for example, port number
- step S104 the signaling processing unit parses the video analysis task request and assembles a standard SIP on-demand request message; where the SIP on-demand request message includes a Session Description Protocol (SDP) message, and the SDP message includes the destination address and Destination port number.
- SDP Session Description Protocol
- the destination address is the IP address of the host where the Docker container is located
- the destination port number is the port number of the first port that the Docker container maps to the host (for example, the port number of port B in FIG. 2).
- step S105 the signaling processing unit sends a SIP on-demand request message to the streaming server.
- step S106 the streaming server sends a 200OK message to the signaling processing unit after it is ready, which also contains an SDP message, and the SDP message includes the source address and source port number of the requested video data; in this example, the source address
- the source port number is the IP address and port number of the camera.
- step S107 the signaling processing unit assembles the Docker container address and port number bound to the data analysis unit and the IP address and port number of the corresponding camera into a communication link message, and sends it to the data distribution unit.
- the data distribution unit receives the communication link message and updates the data distribution mapping table according to the communication link message, that is, a new data forwarding rule is added to the data distribution mapping table, for example, the host of the data analysis unit can be recorded
- the IP address of the host where the data analysis unit is located may be determined according to the correspondence between the Docker container address bound to the data analysis unit and the Docker container address established when the Docker container is initialized and the IP address of the host where it is located.
- step S109 after updating the data distribution mapping table, the data distribution unit sends an acknowledgement (Acknowledge Character, ACK) message to the signaling processing unit.
- Acknowledge Character ACK
- step S110 the signaling processing unit sends an ACK message to the streaming server.
- step S111 after receiving the ACK message, the streaming media server sends the data of the corresponding camera to the data distribution unit; wherein, the streaming media server can follow the destination address and destination port number (that is, where the Docker container is located) carried in the SIP on-demand request message The IP address of the host and the port number of the first port of the Docker container mapped to the host), send the camera data.
- step S112 after receiving the data packet through the first port, the data distribution unit searches the data distribution mapping table and finds the destination port number corresponding to the source address and source port number carried by the data packet in the data distribution mapping table.
- step S113 the received data packet is forwarded to the data analysis unit corresponding to the destination port number; when the destination corresponding to the source address and source port number carried by the data packet cannot be found in the data distribution mapping table In the case of the port number, the data packet is directly discarded.
- step S114 after receiving the data packet, the data analysis unit performs a video data analysis task.
- FIG. 5 is an exemplary flowchart of still another network communication method provided by an embodiment of the present application. This example can be applied to the following scenarios:
- the network communication system acts as a data flow server, supports the GB28181 protocol, and sends data streams to external devices in response to requests from external devices; in this example, the network application unit may include data flow devices.
- the network communication method in this example may include steps S201 to S216.
- step S201 the signaling processing unit receives the data stream device query request message sent by the external device.
- step S202 the signaling processing unit sends a device status query request message to all managed data flow devices.
- step S203 the data flow device in the working state (that is, the normal data flow device) returns a device status query response message to the signaling processing unit; where the device status response message returned by any normal data flow device may include : The ID (ID) of the data flow device, the address and port number of the Docker container to which the data flow device is bound.
- step S204 the signaling processing unit updates the data flow device status list according to the received device status query response message, and assembles the data flow device list in the working state into the data flow device query response message; wherein, it is in the working state
- the data flow device status list of can record the IDs of all data flow devices in working state.
- step S205 the signaling processing unit sends the data stream device query response message to the external device.
- step S206 the signaling processing unit receives the SIP on-demand request message sent by the external device.
- step S207 the signaling processing unit parses out the IP address and port number of the external device from the SIP on-demand request message, and the ID of the data stream device that needs to be ordered; query the ID of the data stream device that needs to be ordered in the data stream device status list ,
- the signaling processing unit assembles the IP address and port number of the external device and the Docker container address and port number bound to the data flow device corresponding to the ID into communication Link message, and execute step S208; otherwise (ie, the data flow device corresponding to the ID is in a non-working state (ie, there is an abnormality)), the signaling processing unit feeds back an abnormality notification to the external device.
- step S208 the signaling processing unit sends the communication link message to the data distribution unit.
- step S209 the data distribution unit parses the communication link message and updates the data distribution mapping table according to the communication link message; that is, a new data forwarding rule is added to the data distribution mapping table, for example, the IP address and the external device can be recorded
- a new data forwarding rule is added to the data distribution mapping table, for example, the IP address and the external device can be recorded
- the IP address of the host where the data flow device is located may be determined according to the correspondence between the Docker container address bound to the data flow device, and the Docker container address established when the Docker container is initialized and the IP address of the host where it is located.
- step S210 after updating the data distribution mapping table, the data distribution unit returns an ACK message to the signaling processing unit.
- step S211 after receiving the ACK message, the signaling processing unit sends a 200 OK message to the external device, which may contain the SDP message, and the SDP message may include the ID of the data streaming device that needs to be ordered.
- step S212 the external device sends an ACK message to the signaling processing unit.
- step S213 after receiving the ACK message, the signaling processing unit sends an on-demand request message to the data stream device corresponding to the ID that needs to be on-demand.
- step S214 after receiving the on-demand request message, the data stream device corresponding to the on-demand ID sends the data to the data distribution unit.
- step S215 after receiving the data packet, the data distribution unit searches the data distribution mapping table, and when the destination address and the destination port number corresponding to the source address and the source port number carried in the data packet can be found, the step is executed S216: Forward the data packet to the corresponding external device; if the destination address and the destination port number corresponding to the source address and the source port number carried in the data packet cannot be found, the data packet is directly discarded.
- FIG. 6 is an exemplary flowchart of still another network communication method provided by an embodiment of the present application. This example can be applied to the following scenarios:
- the network communication system obtains the data stream through the GAT1400 protocol for video analysis tasks; in this example, the network application unit may include a data analysis unit.
- the network communication method in this example may include steps S301 to S314.
- step S301 the signaling processing unit receives the video analysis task request; for example, the video analysis task request may be triggered by a click operation on a webpage corresponding to the network communication system.
- the video analysis task request may be triggered by a click operation on a webpage corresponding to the network communication system.
- this application is not limited to this.
- step S302 after receiving the video analysis task request, the signaling processing unit creates a data analysis unit.
- step S303 the data analysis unit sends the Docker container address and UDP port information (for example, port number) bound to the signaling processing unit, and the signaling processing unit records the Docker container address and UDP port bound by the data analysis unit Information (for example, port number).
- the data analysis unit Information for example, port number
- step S304 the signaling processing unit parses the video analysis task request and assembles the subscription message; wherein, the subscription message may include the destination address and the destination port number.
- the destination address is the IP address of the host where the Docker container is located.
- the port number is the port number of the first port mapped from the Docker container to the host (for example, the port number of port B in FIG. 2).
- step S305 the signaling processing unit sends a subscription message to the subscriber, for example, HTTP POST/VIID/Subscribes.
- step S306 the subscribed video gallery returns a response message of whether the subscription is successful to the signaling processing unit, where the response message carries the source address and source port number of the subscribed video data, and the subscribed video data in this example
- the source address and source port number are the IP address and port number of the subscribed view gallery.
- step S307 when the subscription is successful, the signaling processing unit assembles the Docker container address and port number bound to the data analysis unit and the IP address and port number of the corresponding view library into a communication link message, and sends To the data distribution unit.
- step S308 the data distribution unit receives the communication link message, and updates the data distribution mapping table according to the communication link message; that is, a new data forwarding rule is added to the data distribution mapping table, for example, the host of the data analysis unit can be recorded
- the IP address of the host where the data analysis unit is located may be determined according to the correspondence between the Docker container address bound to the data analysis unit and the Docker container address established when the Docker container is initialized and the IP address of the host where it is located.
- step S309 after updating the data distribution mapping table, the data distribution unit sends an ACK message to the signaling processing unit.
- step S310 the signaling processing unit sends an ACK message to the view gallery.
- step S311 after receiving the ACK message, the view library sends the subscribed data to the data distribution unit; where, the view library can follow the destination address and destination port number carried in the subscription message (that is, the IP address of the host where the Docker container is located and The Docker container is mapped to the port number of the first port of the host), and the data packet is sent.
- the view library can follow the destination address and destination port number carried in the subscription message (that is, the IP address of the host where the Docker container is located and The Docker container is mapped to the port number of the first port of the host), and the data packet is sent.
- step S312 after receiving the data packet, the data distribution unit searches the data distribution mapping table, and when the destination port number corresponding to the source address and the source port number carried in the data packet can be found in the data distribution mapping table, Step S313 is executed, that is, the data packet is forwarded to the data analysis unit corresponding to the destination port number; if the destination port number corresponding to the source address and the source port number carried by the data packet cannot be found in the data distribution mapping table, then Packets are discarded directly.
- step S314 after receiving the data packet, the data analysis unit performs a video data analysis task.
- the network communication system serves as a data flow server, supports the GAT1400 protocol, and sends data streams to external devices in response to requests from external devices; in this example, the network application unit may include a data flow device.
- the network communication method in this example may include steps S401 to S416.
- step S401 the signaling processing unit receives a data stream device query request message sent by an external device.
- step S402 the signaling processing unit sends a device status query request message to all managed data flow devices.
- step S403 the data flow device in the working state (that is, the normal data flow device) returns a device status query response message to the signaling processing unit; wherein, the device status response message returned by any normal data flow device may include : The ID (ID) of the data flow device, the address and port number of the Docker container to which the data flow device is bound.
- step S404 the signaling processing unit updates the data flow device status list according to the received device status query response message, and assembles the data flow device list in the working state into a data flow device query response message; wherein, it is in the working state
- the data flow device status list of can record the IDs of all data flow devices in working state.
- step S405 the signaling processing unit sends the data stream device query response message to the external device.
- step S406 the signaling processing unit receives a subscription message of an external device, for example, an HTTP POST/VIID/Subscribes message.
- step S407 the signaling processing unit parses out the IP address and port number of the external device and the ID of the data stream device to be played from the subscription message; the signaling processing unit queries the data stream requiring on-demand in the data stream device status list Device ID.
- the signaling processing unit assembles the IP address and port number of the external device and the Docker container address and port number bound to the data flow device corresponding to the ID.
- step S408 is executed; otherwise (ie, the data flow device corresponding to the ID is in a non-working state (ie, there is an abnormality)), the signaling processing unit feeds back an abnormality notification to the external device.
- step S408 the signaling processing unit sends the communication link message to the data distribution unit.
- step S409 the data distribution unit parses the communication link message and updates the data distribution mapping table according to the communication link message; that is, a new data forwarding rule is added to the data distribution mapping table, for example, the IP address and the external device can be recorded
- a new data forwarding rule is added to the data distribution mapping table, for example, the IP address and the external device can be recorded
- the IP address of the host where the data flow device is located can be determined according to the correspondence between the Docker container address bound to the data flow device, and the Docker container address established when the Docker container is initialized and the IP address of the host where it is located.
- step S410 after updating the data distribution mapping table, the data distribution unit returns an ACK message to the signaling processing unit.
- step S411 after receiving the ACK message, the signaling processing unit sends a subscription response message to the external device, which may contain the ID of the data streaming device that needs to be ordered.
- step S412 the external device sends an ACK message to the signaling processing unit.
- step S413 after receiving the ACK message, the signaling processing unit sends an on-demand request message to the data stream device corresponding to the ID that needs to be on-demand.
- step S414 after receiving the on-demand request message, the data stream device corresponding to the on-demand ID sends the data to the data distribution unit.
- step S415 after receiving the data packet, the data distribution unit searches the data distribution mapping table, and if the destination address and the destination port number corresponding to the source address and the source port number carried in the data packet can be found, the step is executed S416: Forward the data packet to the corresponding external device; if the destination address and the destination port number corresponding to the source address and the source port number carried in the data packet cannot be found, the data packet is directly discarded.
- the network communication method and system provided in this embodiment are combined with iptables forwarding and application forwarding for Docker container application deployment scenarios.
- the Docker container only needs to expose a pair of first ports on the host, and the pair of first ports are set For data transmission, data can be forwarded to multiple ports in the Docker container, which not only reduces the management complexity of the Docker container port, but also improves the data transmission efficiency, facilitates operation and maintenance management, and also improves the reliability of the Docker container.
- FIG. 8 is a schematic diagram of a network device provided by an embodiment of this application.
- a network device 800 for example, a host device deploying a Docker container
- the memory 801 is configured to store a network communication program, and the network communication program is
- the processor 802 executes, it implements the network communication method provided in the above embodiment, such as the steps shown in FIG. 3.
- the network device 800 may It includes more or fewer components than shown in the figure, or some components are combined, or have a different component arrangement.
- the processor 802 may include, but is not limited to, a processing device such as a microprocessor (Microcontroller Unit, MCU) or programmable logic device (Field Programmable Gate Array, FPGA).
- the memory 801 is configured to store software programs and modules of application software, such as program instructions or modules corresponding to the network communication method in this embodiment, and the processor 802 executes various functions by running the software programs and modules stored in the memory 801 Applications and data processing, such as implementing the network communication method provided in this embodiment.
- the memory 801 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one magnetic storage device, flash memory, or other non-volatile solid-state memory.
- the memory 801 may include memories remotely provided with respect to the processor 802, and these remote memories may be connected to the network device 800 through a network.
- Examples of the aforementioned network include, but are not limited to, the Internet, intranet, local area network, mobile communication network, and combinations thereof.
- embodiments of the present application also provide a computer-readable medium that stores a network communication program.
- the network communication program is executed by a processor, the network communication method provided by the foregoing embodiment is implemented, for example, as shown in FIG. 3 Steps shown.
- the term computer storage medium includes both volatile and nonvolatile implemented in any method or technology for storing information such as computer readable instructions, data structures, program modules, or other data Sex, removable and non-removable media.
- Computer storage media include but are not limited to Random Access Memory (RAM), Read-Only Memory (ROM), Erasable Programmable Read-Only Memory (Electrically Programmable Read Only Memory (EEPROM), Flash memory or other memory technology, compact disc (Read-Only Memory, CD-ROM), digital versatile disc (Digital Video Disc, DVD) or other optical disc storage, magnetic box, magnetic tape, magnetic disk storage or other magnetic storage devices Or any other medium that can be used to store desired information and can be accessed by a computer.
- the communication medium generally contains computer readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and may include any information delivery medium .
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Multimedia (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
本申请公开了一种网络通信方法及系统;上述网络通信方法包括:确定Docker容器内的数据转发规则;根据数据转发规则,将通过第一端口接收的数据包转发给Docker容器内部署的应用,或者,将Docker容器内部署的应用发送的数据包通过第一端口转发给外部设备;其中,Docker容器的一对第一端口映射到所在主机的端口上。
Description
本申请要求在2018年12月28日提交中国专利局、申请号为201811617423.2的中国专利申请的优先权,该申请的全部内容通过引用结合在本申请中。
本申请涉及但不限于通信技术领域,例如一种网络通信方法及系统。
微服务架构已经成为软件系统开发和部署的主流模式之一。在微服务应用场景下,通常采用Docker容器部署服务,以便实现服务的快速部署和实例的动态伸缩。Docker是一个开源的应用容器引擎,允许开发者打包应用到容器中。在一般场景下,通常由Kubernetes来实现容器集群的管理和调度,同时结合Flannel等网络插件来实现Docker容器之间的网络互联互通。然而,在很多面向中小企业的应用场景中,应用的服务功能相对比较单一,整体容量要求不高,这时如果再通过Kubernetes和Flannel来做Docker容器的集群管理和网络互联互通,在加大系统整体工作负载的同时,也会使得整个系统变得比较复杂,增大整个系统运维管理的难度和成本。因此,在这种应用场景下,通常只使用Docker基础服务来部署应用微服务,并利用Docker基础服务所提供的容器管理接口来实施容器的管理。Docker容器网络通常使用桥接(bridge)模式来构建。当Docker容器需要对外暴露服务的端口时,在Docker容器启动时采用端口映射的方式将Docker容器内的端口映射到主机端口上暴露出去。这种端口映射的实现机理是通过在网际互连协议信息包过滤系统(iptables)中增加规则链来实现的。
然而,在Docker容器内需要多端口暴露的情况下,特别是一些数据传输的场景下,比如视频会议、视频分析、媒体服务器等应用,数据基于用户数据报协议(User Datagram Protocol,UDP)传输,通常一路数据就需要暴露至少一对端口;如果继续使用端口映射方式,一来端口管理变得复杂,二来实际验证测试发现:基于iptables的端口映射和数据包转发,效率极其低下,时延加大,严重影响容器内应用的业务功能。
另外,Docker容器自身也提供了docker-proxy来实现容器应用的数据包转发,但是它的实现机制是为每个做端口映射的容器端口都提供一个docker-proxy进程来进行数据包的转发,在存在大量的端口映射的情况下,就需要开启大量的docker-proxy进程,同样存在效率低、运维管理难度大的情况。
发明内容
本申请实施例提供一种网络通信方法及系统,可以降低Docker容器的端口管理复杂度,并提高数据传输效率。
一方面,本申请实施例提供一种网络通信方法,包括:确定Docker容器内的数据转发规则,所述Docker容器的一对第一端口映射到所在主机的端口上;根据所述数据转发规则,将通过所述第一端口接收的数据包转发给所述Docker容器内部署的应用,或者,将所述Docker容器内部署的应用发送的数据包通过所述第一端口转发给外部设备。
另一方面,本申请实施例提供一种网络通信系统,包括:数据分发单元以及网络应用单元;所述数据分发单元和所述网络应用单元部署在Docker容器内;所述Docker容器的一对第一端口映射到所在主机的端口上;所述网络应用单元包括至少一个应用;所述数据分发单元,设置为确定所述Docker容器内的数据转发规则;根据所述数据转发规则,将通过所述第一端口接收的数据包转发给所述网络应用单元内的应用,或者,将所述网络应用单元内的应用发送的数据包通过所述第一端口转发给外部设备。
另一方面,本申请实施例提供一种网络设备,包括:处理器和存储器;所述存储器设置为存储网络通信程序,所述网络通信程序被所述处理器执行时,实现上述网络通信方法。
另一方面,本申请实施例提供一种计算机可读介质,存储有网络通信程序,所述网络通信程序被处理器执行时,实现上述网络通信方法。
图1为本申请一实施例提供的网络通信系统的示意图;
图2为本申请一实施例提供的网络通信系统的实施流程示意图;
图3为本申请一实施例提供的网络通信方法的流程图;
图4为本申请一实施例提供的另一种网络通信方法的示例流程图;
图5为本申请一实施例提供的再一种网络通信方法的示例流程图;
图6为本申请一实施例提供的再一种网络通信方法的示例流程图;
图7为本申请一实施例提供的再一种网络通信方法的示例流程图;
图8为本申请一实施例提供的网络设备的示意图。
在附图的流程图示出的步骤可以在诸如一组计算机可执行指令的计算机系统中执行。并且,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。
需要说明的是,本申请中的术语“第一”、“第二”等是用于区别不同对象,而 不是用于描述特定顺序。
图1为本申请实施例提供的网络通信系统的示意图。图2为本申请实施例提供的网络通信系统的实施流程示意图。如图1和图2所示,本实施例提供的网络通信系统,包括:数据分发单元112以及网络应用单元114,数据分发单元112以及网络应用单元114部署在Docker容器11内。其中,Docker容器11可以部署在一台网络设备(可以称为主机)上,每台网络设备上可以同时部署多个Docker容器。Docker容器11上可以部署至少一个应用,比如,可以根据不同的业务场景实例化得到不同的网络应用。如图2所示,网络应用单元114内可以包括至少一个应用,比如图2中的应用1、应用2及应用n,其中,应用1绑定端口a,应用2绑定端口b,应用n绑定端口n。
在本实施例中,Docker容器11的一对第一端口(在图2中采用端口B示意)映射到所在主机的端口上。其中,一对第一端口可以包括一个实时传输协议(Realtime Transport Protocol,RTP)端口和一个实时传输控制协议(Realtime Transport Control Protocol,RTCP)端口,Docker容器11的一对第一端口设置为传输数据。示例性地,Docker容器11可以在启动时采用端口映射方式在所在主机上暴露一对第一端口,暴露的这一对第一端口设置为接收来自外部设备10的数据包,或者,向外部设备10发送数据包。需要说明的是,Docker容器11在启动时会初始化Docker容器地址与所在主机的网络协议(Internet Protocol,IP)地址的对应关系,以及第一端口与所在主机上端口的映射关系。基于此,Docker容器11可以实现与外部设备10的数据交互。
在本实施例中,数据分发单元112设置为确定Docker容器11内的数据转发规则,以及根据数据转发规则,将通过第一端口(比如,图2中的端口B)接收的数据包转发给网络应用单元114内的应用,或者,将网络应用单元114内的应用发送的数据包通过第一端口转发给外部设备10。
本实施例中,外部设备10可以包括除Docker容器11外的其他对象,比如,其他网络设备或者其他Docker容器。然而,本申请对此并不限定。
本实施例中,Docker容器11仅需对外暴露一对第一端口,暴露的一对第一端口设置为数据传输,无论外部设备10和网络应用单元114之间存在几路数据,都会通过第一端口进行传输,不会再动态增加暴露的端口,动态变化的只是Docker容器11内的数据转发规则;其中,新增一路数据时,数据分发单元112可以增加一条数据转发规则;删除一路数据时,数据分发单元112可以删除一条对应的数据转发规则。
在一示例性实施方式中,数据转发规则可以用于记录每路数据的数据源的信息和数据目的地的信息,其中,数据源或数据目的地可以为网络应用单元114内的应用。
在一示例性实施方式中,数据源的信息可以包括源地址以及源端口;数据目的地的信息可以包括:目的地址以及目的端口;其中,源端口或目的端口可以为网络应用单元114内的应用绑定的端口。本申请对此并不限定。例如,在其他实现方式中,在数据源为网络应用单元内的应用的情况下,数据源的信息可以包括:该应用所在的Docker容器地址、该应用所绑定的端口以及该应用的标识(Identity Document,ID)。
比如,在一路数据的源地址和源端口为外部设备的IP地址和端口的情况下,该路数据的目的地址可以为Docker容器所在主机的IP地址,该路数据的目的端口可以为Docker容器内部署的应用绑定的端口。比如,在一路数据的目的地址和目的端口为外部设备的IP地址和端口的情况下,该路数据的源地址可以为Docker容器所在主机的IP地址,该路数据的目的端口可以为Docker容器内部署的应用绑定的端口。
在一示例性实施方式中,数据分发单元112可以设置为通过以下方式根据数据转发规则,将通过第一端口接收的数据包转发给Docker容器11内部署的应用:通过查询数据转发规则,确定从第一端口接收到的数据包携带的源地址和源端口所共同对应的目的端口;将数据包转发给网络应用单元114内绑定该目的端口的应用。
在本示例性实施方式中,如图2所示,数据分发单元112通过端口B接收到携带源地址和源端口的数据包;在数据转发规则中记录该源地址和源端口对应的目的地址和目的端口的情况下,根据查询到的目的端口在Docker容器11内进行数据包转发。比如,数据转发规则中记录有源地址和源端口对应的目的端口为端口a,则数据分发单元112将接收到的数据包转发到绑定端口a的应用1;在数据转发规则中没有记录该源地址和源端口的情况下,直接丢弃接收到的数据包。
在一示例性实施方式中,数据分发单元112可以通过以下方式根据数据转发规则,将Docker容器11内部署的应用发送的数据包通过第一端口转发给外部设备10:通过查询数据转发规则,确定Docker容器内发送数据包的应用所绑定的端口对应的外部设备的IP地址和端口;通过第一端口将数据包转发至该外部设备。
在本示例性实施方式中,如图2所示,数据分发单元112接收到网络应用单元114内的应用1发送的数据包后,从数据转发规则查询是否有端口a对应的目的地址和目的端口,在可以查询到端口a对应外部设备10的IP地址和端口的情况下,数据分发单元112将数据包通过端口B转发给外部设备10,在没有查询到端口a的对应记录的情况下,直接丢弃接收到的数据包。
在一示例性实施方式中,如图1和图2所示,本实施例提供的网络通信系 统还可以包括:信令处理单元110,设置为获取每路数据的通信链路信息,并发送通信链路信息给数据分发单元112;数据分发单元112可以设置为根据每路数据的通信链路信息,确定Docker容器11内的数据转发规则。
在本示例性实施方式中,Docker容器11的一个第二端口(比如,图2中的端口A)映射到所在主机的端口上,该第二端口设置为传输信令。其中,信令处理单元110可以设置为通过以下任一种方式获取每路数据的通信链路信息:
方式一、通过第二端口与外部设备(比如,外部设备10)进行信令交互,确定待通过第一端口接收的任一路数据的源地址和源端口(比如,外部设备10的IP地址和端口);从待接收该路数据的应用获取该应用绑定的Docker容器地址和端口;根据该路数据的源地址、源端口、该应用所绑定的Docker容器地址和端口,确定该路数据的通信链路信息;
方式二、通过第二端口接收外部设备发送的请求消息,从该请求消息中解析出待通过第一端口发送的任一路数据的目的地址和目的端口(比如,外部设备10的IP地址和端口)、待发送该路数据的应用;从待发送该路数据的应用获取该应用绑定的Docker容器地址和端口;根据该路数据的目的地址、目的端口、该应用绑定的Docker容器地址和端口,确定该路数据的通信链路信息。
在本示例性实施方式中,信令处理单元110负责与外部设备(比如,外部设备10)通过标准信令进行交互,完成数据的协商,这些标准信令通常可以包括会话初始协议(Session Initiation Protocol,SIP)、实时流协议(Real Time Streaming Protocol,RTSP)、媒体网关控制协议(Media Gateway Control Protocol,MGCP)等协议。信令传输通道可以支持传输控制协议(Transmission Control Protocol,TCP)、用户数据报协议(User Datagram Protocol,UDP)等多种模式。由于信令处理单元110需要和外部设备(比如,外部设备10)进行通信,因此,将一个用于传输信令的端口(即上述的第二端口,比如图2中的端口A)通过端口映射方式暴露到主机上。由于对整个Docker容器来说,用于信令传输的端口通常只有一个,因此不会对主机基于iptables规则的数据包转发带来影响。
在本示例性实施方式中,数据分发单元112负责与外部设备10通过标准的数据传输协议进行通信,接收并基于数据转发规则来转发数据包。数据分发单元112可以通过端口映射方式在主机上暴露用于数据包传输的一对端口(即上述的第一端口,比如图2中的端口B)。由于对整个Docker容器来说,只需要对外暴露一对端口用于数据传输,因此,不会对主机基于iptables规则的数据包转发带来影响。其中,数据转发规则可以根据信令处理单元110发送的通信链路信息来创建或更新,在数据分发单元112接收到数据包的情况下,可以根据数据包携带的源地址和源端口,通过查询数据转发规则来确定转发给Docker容器内的哪个端口,或者哪个外部设备。
在本示例性实施方式中,网络应用单元114负责与数据分发单元112交互,并可根据不同的业务场景实例化为不同的网络应用(比如,应用1、应用2、应用n),网络应用单元114可以接收数据分发单元112转发过来的数据包,也可以向数据分发单元112发送数据包,网络应用单元114可以随着Docker容器11启动而启动,亦可以由其他单元(比如,信令处理单元110)创建。网络应用单元114和数据分发单元112通常需要为每一路数据(比如,视频或音频数据)绑定一对端口(一对端口包括一个RTP端口和一个RTCP端口),比如,图2中应用1绑定端口a,应用2绑定端口b,应用n绑定端口n,在需要收发多路数据的情况下,需要绑定多对端口。网络应用单元114和数据分发单元112之间可以通过Docker容器内的套接字socket进行通信。
下面基于图2通过一个示例对本实施例提供的网络通信系统的实施流程进行举例说明。在本示例中,信令处理单元110可以从端口A发起数据会话建立请求,可以是SIP、RTSP、MGCP等协议或者其它协议,在完成信令协商之后,记录对端数据的源地址和源端口(比如,外部设备10的IP地址和端口号)。在协商的信令中,本端数据的接收地址可以采用Docker容器所在主机IP地址及Docker容器在主机上暴露的端口B。然后,信令处理单元110通知网络应用单元114,网络应用单元114创建新的应用1,且应用1绑定端口a,应用1将自己绑定的Docker容器地址和端口a告诉信令处理单元110,用于处理数据。信令处理单元110将需要转发的数据地址对(其中,包括对端数据的源地址和源端口、以及数据目的地应用1所绑定的Docker容器地址和端口a)通知数据分发单元112。数据分发单元112根据接收到的信息创建数据分发映射表,其中,记录以下对应关系:源地址、源端口、Docker容器所在主机IP地址以及应用1绑定的端口,作为一条数据转发规则。需要说明的是,由于Docker容器在启动时初始化了Docker容器地址和所在主机IP地址的对应关系,因此,基于Docker容器地址和上述初始化的对应关系可以确定Docker容器所在主机IP地址。然后,数据分发单元112开始接收数据包,并根据数据包携带的源地址和源端口,查询数据分发映射表中的数据转发规则,根据查询到的结果,将接收到的数据包转发到Docker容器内的端口a;绑定端口a的应用1接收到数据分发单元112转发过来的数据包后,可以执行相应的业务,比如视频分析任务。
本实施例提供的网络通信系统中将基于iptables转发和应用分发相结合,Docker容器仅需对外暴露一对端口即可实现多路数据传输。针对小规模的政企应用场景,使用Docker容器来部署微服务时,通过本实施例提供的网络通信系统可以降低Docker容器端口的管理复杂度,提高数据包的传输效率,从而便于运维管理,也提升了可靠性。
图3为本申请一实施例提供的网络通信方法的流程图。本实施例提供的网 络通信方法可以应用于部署在主机上的Docker容器,且Docker容器的一对第一端口映射到所在主机的端口上。关于Docker容器以及第一端口的相关说明可以参照上述网络通信系统中的相关描述,故于此不再赘述。
如图3所示,本实施例提供的网络通信方法,包括步骤201和步骤202。
在步骤201中,确定Docker容器内的数据转发规则。
在步骤202中,根据数据转发规则,将通过第一端口接收的数据包转发给Docker容器内部署的应用,或者,将Docker容器内部署的应用发送的数据包通过第一端口转发给外部设备。
在本申请实施例中,Docker容器的一对第一端口映射到所在主机的端口上;根据Docker容器内的数据转发规则,将通过第一端口接收的数据包转发给Docker容器内部署的应用,或者,将Docker容器内部署的应用发送的数据包通过第一端口转发给外部设备。在本实施例中,Docker容器只需在主机上暴露一对第一端口用于传输数据包,不仅降低了端口管理复杂度,而且提高了数据传输效率。
在一示例性实施方式中,数据转发规则可以用于记录每路数据的数据源和数据目的地的信息,其中,数据源或数据目的地为Docker容器内部署的应用。
在一示例性实施方式中,数据源的信息可以包括:源地址以及源端口;数据目的地的信息可以包括:目的地址以及目的端口,其中,源端口或目的端口为Docker容器内部署的应用绑定的端口。然而,本申请对此并不限定。例如,在其他实现方式中,当数据源为网络应用单元内的应用,则数据源的信息可以包括:该应用所在的Docker容器地址、该应用所绑定的端口以及该应用的标识(ID)。
在一示例性实施方式中,在步骤202中,根据数据转发规则,将通过第一端口接收的数据包转发给Docker容器内部署的应用,可以包括:通过查询数据转发规则,确定从第一端口接收到的数据包携带的源地址和源端口所共同对应的目的端口;将数据包转发给Docker容器内绑定该目的端口的应用。
示例性地,通过第一端口接收到携带源地址和源端口的数据包后,当数据转发规则中记录该源地址和源端口对应的目的地址和目的端口,则根据查询到的目的端口在Docker容器内进行数据包转发;比如,在图2中,数据转发规则中记录有源地址和源端口(例如,外部设备10的IP地址和端口)对应的目的端口为端口a,则可以将接收到的数据包转发到绑定端口a的应用1;当数据转发规则中没有记录该源地址和源端口,则直接丢弃接收到的数据包。
在一示例性实施方式中,在步骤202中,根据数据转发规则,将Docker容器内部署的应用发送的数据包通过第一端口转发给外部设备,可以包括:通过查询数据转发规则,确定Docker容器内发送数据包的应用所绑定的端口对应的 外部设备的IP地址和端口;通过第一端口将数据包转发至该外部设备。在本示例性实施例中,数据转发规则中记录的一路数据的源端口可以为Docker容器内部署的应用绑定的端口,该路数据的目的地址和目的端口可以为外部设备的IP地址和端口。
示例性地,在接收到Docker容器内部署的一个应用发送的数据包后,从数据转发规则查询是否有该应用所绑定的端口对应的目的地址和目的端口,若可以查询到对应的目的地址和目的端口,比如为外部设备的IP地址和端口,则将数据包通过第一端口转发给该外部设备,若没有查询到对应记录,则直接丢弃接收到的数据包。
在一示例性实施方式中,在步骤201之前,网络通信方法还可以包括:获取每路数据的通信链路信息;此时,步骤201可以包括:根据每路数据的通信链路信息,确定Docker容器内的数据转发规则。
在一示例性实施方式中,Docker容器的一个第二端口映射到所在主机的端口上;其中,获取每路数据的通信链路信息,可以包括以下之一:
方式一、通过第二端口与外部设备进行信令交互,确定待通过第一端口接收的任一路数据的源地址和源端口;从待接收该路数据的应用获取该应用绑定的Docker容器地址和端口;根据该路数据的源地址、源端口、该应用所绑定的Docker容器地址和端口,确定该路数据的通信链路信息;
方式二、通过第二端口接收外部设备发送的请求消息,从该请求消息中解析出待通过第一端口发送的任一路数据的目的地址和目的端口、待发送该路数据的应用;待发送该路数据的应用获取该应用绑定的Docker容器地址和端口;根据该路数据的目的地址、目的端口、该应用绑定的Docker容器地址和端口,确定该路数据的通信链路信息。
其中,关于第二端口的说明可以参照上述网络通信系统中的相关描述,故于此不再赘述。
本示例性实施例中,Docker容器在初始化时通过端口映射方式对外暴露第一端口和第二端口,第一端口设置为传输数据,第二端口设置为传输信令。由于对整个Docker容器来说,用于信令传输的端口通常只有一个,因此不会对主机基于iptables规则的数据包转发带来影响。由于对整个Docker容器来说,只需要对外暴露一对端口(第一端口)用于数据传输,因此,不会对主机基于iptables规则的数据包转发带来影响。
本实施例中,Docker容器仅需对外暴露一对第一端口用于数据传输,无论Docker容器内部署的应用与外部设备之间存在几路数据,都会通过第一端口进行传输,不会再动态增加暴露的端口,动态变化的只是Docker容器内的数据转发规则;其中,新增一路数据时,可以在数据转发规则中增加一条记录;删除 一路数据时,可以在数据转发规则中删除一条记录。
本实施例提供的网络通信方法将基于iptables转发和应用分发相结合,Docker容器仅需对外暴露一对端口即可实现多路数据传输。针对小规模的政企应用场景,使用Docker容器来部署微服务时,通过本实施例提供的网络通信方法可以降低Docker容器端口的管理复杂度,提高数据包的传输效率,从而便于运维管理,也提升了可靠性。
下面结合图1和图2通过多个示例性实施例对本申请实施例提供的网络通信方法及系统进行说明。
图4为本申请一实施例提供的另一种网络通信方法的示例流程图。本示例可以适用于以下场景:网络通信系统通过会话初始协议(Session Initiation Protocol,SIP)向GB28181服务器(即流媒体服务器)拉取数据流,该数据流用于视频分析任务;本示例中,网络应用单元可以包括数据分析单元。
如图4所示,本示例中网络通信方法可以包括步骤S101至步骤S114。
在步骤S101中,信令处理单元接收到视频分析任务请求;示例性地,视频分析任务请求可以通过网络通信系统所对应的网页上的点击操作触发。然而,本申请对此并不限定。
在步骤S102中,信令处理单元接收到视频分析任务请求后,创建数据分析单元。
在步骤S103中,数据分析单元将自己绑定的Docker容器地址以及UDP端口信息(比如,端口号)发送给信令处理单元,信令处理单元记录数据分析单元绑定的Docker容器地址以及UDP端口信息(比如,端口号)。
在步骤S104中,信令处理单元解析视频分析任务请求,组装出标准的SIP点播请求消息;其中,SIP点播请求消息包含会话描述协议(Session Description Protocol,SDP)消息,SDP消息中包括目的地址和目的端口号,本示例中,目的地址为Docker容器所在主机的IP地址,目的端口号为Docker容器映射到主机的第一端口的端口号(比如,图2中端口B的端口号)。
在步骤S105中,信令处理单元向流媒体服务器发送SIP点播请求消息。
在步骤S106中,流媒体服务器在准备就绪后,向信令处理单元发送200OK消息,其中同样包含SDP消息,SDP消息中包括所请求视频数据的源地址和源端口号;本示例中,源地址和源端口号为摄像头的IP地址和端口号。
在步骤S107中,信令处理单元将数据分析单元所绑定的Docker容器地址和端口号与对应摄像头的IP地址和端口号拼装成通信链路消息,并下发给数据分发单元。
在步骤S108中,数据分发单元接收通信链路消息,并根据通信链路消息更新数据分发映射表,即在数据分发映射表中新增一条数据转发规则,比如,可 以记录数据分析单元所在主机的IP地址和在Docker容器内绑定的端口号与对应摄像头的IP地址和端口号的对应关系。其中,数据分析单元所在主机的IP地址可以根据数据分析单元所绑定的Docker容器地址、以及Docker容器初始化时建立的Docker容器地址与所在主机的IP地址之间的对应关系确定。
在步骤S109中,数据分发单元在更新数据分发映射表后,向信令处理单元发送确认(Acknowledge character,ACK)消息。
在步骤S110中,信令处理单元向流媒体服务器发送ACK消息。
在步骤S111中,流媒体服务器接收到ACK消息后,将对应摄像头的数据发送到数据分发单元;其中,流媒体服务器可以按照SIP点播请求消息中携带的目的地址和目的端口号(即Docker容器所在主机的IP地址和Docker容器映射到主机的第一端口的端口号),发送摄像头的数据。
在步骤S112中,数据分发单元通过第一端口接收到数据包后,查找数据分发映射表,在能在数据分发映射表查到数据包携带的源地址和源端口号共同所对应的目的端口号的情况下,执行步骤S113,即将接收到的数据包转发到该目的端口号对应的数据分析单元;在不能在数据分发映射表查到数据包携带的源地址和源端口号所共同对应的目的端口号的情况下,将数据包直接丢弃掉。
在步骤S114中,数据分析单元接收到数据包后,执行视频数据分析任务。
图5为本申请一实施例提供的再一种网络通信方法的示例流程图。本示例可以适用于以下场景:网络通信系统作为数据流服务器,支持GB28181协议,响应外部设备的请求,向外部设备发送数据流;本示例中,网络应用单元可以包括数据流设备。
如图5所示,本示例中网络通信方法可以包括步骤S201至步骤S216。
在步骤S201中,信令处理单元接收外部设备发送的数据流设备查询请求消息。
在步骤S202中,信令处理单元向管理的所有数据流设备发送设备状态查询请求消息。
在步骤S203中,处于工作状态的数据流设备(即正常的数据流设备)向信令处理单元返回设备状态查询响应消息;其中,任一个正常的数据流设备返回的设备状态响应消息中可以包括:该数据流设备的标识(ID)、该数据流设备所绑定的Docker容器地址以及端口号。
在步骤S204中,信令处理单元根据接收到的设备状态查询响应消息,更新数据流设备状态列表,并将处于工作状态的数据流设备列表拼装成数据流设备查询响应消息;其中,处于工作状态的数据流设备状态列表中可以记录处于工作状态的全部数据流设备的ID。
在步骤S205中,信令处理单元将数据流设备查询响应消息发送给外部设备。
在步骤S206中,信令处理单元接收外部设备发送的SIP点播请求消息。
在步骤S207中,信令处理单元从SIP点播请求消息中解析出外部设备的IP地址和端口号,以及需要点播的数据流设备ID;在数据流设备状态列表中查询需要点播的数据流设备ID,在该ID对应的数据流设备处于工作状态的情况下,信令处理单元将外部设备的IP地址和端口号以及该ID对应的数据流设备所绑定的Docker容器地址和端口号拼装成通信链路消息,并执行步骤S208;否则(即该ID对应的数据流设备处于非工作状态(即存在异常)),信令处理单元向外部设备反馈异常通知。
在步骤S208中,信令处理单元将通信链路消息发送给数据分发单元。
在步骤S209中,数据分发单元解析通信链路消息,并根据通信链路消息更新数据分发映射表;即在数据分发映射表中新增一条数据转发规则,比如,可以记录外部设备的IP地址和端口号以及需要点播的数据流设备ID所绑定的主机IP地址和在Docker容器内绑定的端口号的对应关系。其中,数据流设备所在主机的IP地址可以根据数据流设备所绑定的Docker容器地址、以及Docker容器初始化时建立的Docker容器地址与所在主机的IP地址之间的对应关系确定。
在步骤S210中,数据分发单元在更新数据分发映射表后,向信令处理单元返回ACK消息。
在步骤S211中,信令处理单元接收到ACK消息后,向外部设备发送200OK消息,其中可以包含SDP消息,SDP消息中可以包括需要点播的数据流设备的ID。
在步骤S212中,外部设备向信令处理单元发送ACK消息。
在步骤S213中,信令处理单元接收到ACK消息后,向需要点播的ID所对应的数据流设备发送点播请求消息。
在步骤S214中,需要点播的ID所对应的数据流设备接收到点播请求消息后,向数据分发单元发送数据。
在步骤S215中,数据分发单元接收到数据包后,查找数据分发映射表,在能查到数据包携带的源地址和源端口号所共同对应的目的地址和目的端口号的情况下,执行步骤S216,即将数据包转发到对应的外部设备;在查不到数据包携带的源地址和源端口号所共同对应的目的地址和目的端口号的情况下,将数据包直接丢弃掉。
图6为本申请一实施例提供的再一种网络通信方法的示例流程图。本示例可以适用于以下场景:网络通信系统通过GAT1400协议获取数据流用于视频分析任务;本示例中,网络应用单元可以包括数据分析单元。
如图6所示,本示例中网络通信方法可以包括步骤S301至步骤S314。
在步骤S301中,信令处理单元接收到视频分析任务请求;示例性地,视频 分析任务请求可以通过网络通信系统所对应的网页上的点击操作触发。然而,本申请对此并不限定。
在步骤S302中,信令处理单元接收到视频分析任务请求后,创建数据分析单元。
在步骤S303中,数据分析单元将自己绑定的Docker容器地址以及UDP端口信息(比如,端口号)发送给信令处理单元,信令处理单元记录数据分析单元绑定的Docker容器地址以及UDP端口信息(比如,端口号)。
在步骤S304中,信令处理单元解析视频分析任务请求,组装出订阅消息;其中,订阅消息中可以包括目的地址和目的端口号,本示例中,目的地址为Docker容器所在主机的IP地址,目的端口号为Docker容器映射到主机的第一端口的端口号(比如,图2中端口B的端口号)。
在步骤S305中,信令处理单元向被订阅者发送订阅消息,比如,HTTP POST/VIID/Subscribes。
在步骤S306中,被订阅的视图库将订阅成功与否的响应消息返回给信令处理单元,其中,响应消息中携带所订阅视频数据的源地址和源端口号,本示例中所订阅视频数据的源地址和源端口号为订阅的视图库的IP地址和端口号。
在步骤S307中,在订阅成功的情况下,信令处理单元将数据分析单元所绑定的Docker容器地址和端口号以及对应视图库的IP地址和端口号拼装成通信链路消息,并下发给数据分发单元。
在步骤S308中,数据分发单元接收通信链路消息,并根据通信链路消息更新数据分发映射表;即在数据分发映射表中新增一条数据转发规则,比如,可以记录数据分析单元所在主机的IP地址以及在Docker容器内绑定的端口号与订阅视图库的IP地址和端口号的对应关系。其中,数据分析单元所在主机的IP地址可以根据数据分析单元所绑定的Docker容器地址、以及Docker容器初始化时建立的Docker容器地址与所在主机的IP地址之间的对应关系确定。
在步骤S309中、数据分发单元在更新数据分发映射表后,向信令处理单元发送ACK消息。
在步骤S310中,信令处理单元向视图库发送ACK消息。
在步骤S311中,视图库接收到ACK消息后,将订阅的数据发送到数据分发单元;其中,视图库可以按照订阅消息中携带的目的地址和目的端口号(即Docker容器所在主机的IP地址和Docker容器映射到主机的第一端口的端口号),发送数据包。
在步骤S312中,数据分发单元接收到数据包后,查找数据分发映射表,在能在数据分发映射表查到数据包携带的源地址和源端口号所共同对应的目的端口号的情况下,执行步骤S313,即将数据包转发到该目的端口号对应的数据分 析单元;在不能在数据分发映射表查到数据包携带的源地址和源端口号所共同对应的目的端口号的情况下,将数据包直接丢弃掉。
在步骤S314中,数据分析单元接收到数据包后,执行视频数据分析任务。
图7为本申请一实施例提供的再一种网络通信方法的示例流程图。本示例可以适用于以下场景:网络通信系统作为数据流服务器,支持GAT1400协议,响应外部设备的请求,向外部设备发送数据流;本示例中,网络应用单元可以包括数据流设备。
如图7所示,本示例中网络通信方法可以包括步骤S401至步骤S416。
在步骤S401中,信令处理单元接收外部设备发送的数据流设备查询请求消息。
在步骤S402中,信令处理单元向管理的所有数据流设备发送设备状态查询请求消息。
在步骤S403中,处于工作状态的数据流设备(即正常的数据流设备)向信令处理单元返回设备状态查询响应消息;其中,任一个正常的数据流设备返回的设备状态响应消息中可以包括:该数据流设备的标识(ID)、该数据流设备所绑定的Docker容器地址以及端口号。
在步骤S404中,信令处理单元根据接收到的设备状态查询响应消息,更新数据流设备状态列表,并将处于工作状态的数据流设备列表拼装成数据流设备查询响应消息;其中,处于工作状态的数据流设备状态列表中可以记录处于工作状态的全部数据流设备的ID。
在步骤S405中,信令处理单元将数据流设备查询响应消息发送给外部设备。
在步骤S406中,信令处理单元接收到外部设备的订阅消息,比如,HTTP POST/VIID/Subscribes消息。
在步骤S407中,信令处理单元从订阅消息中解析出外部设备的IP地址和端口号,以及需要播放的数据流设备ID;信令处理单元在数据流设备状态列表中查询需要点播的数据流设备ID,在该ID对应的数据流设备处于工作状态的情况下,信令处理单元将外部设备的IP地址和端口号以及该ID对应的数据流设备所绑定的Docker容器地址和端口号拼装成通信链路消息,并执行步骤S408;否则(即该ID对应的数据流设备处于非工作状态(即存在异常)),信令处理单元向外部设备反馈异常通知。
在步骤S408中,信令处理单元将通信链路消息发送给数据分发单元。
在步骤S409中,数据分发单元解析通信链路消息,并根据通信链路消息更新数据分发映射表;即在数据分发映射表中新增一条数据转发规则,比如,可以记录外部设备的IP地址和端口号以及需要点播的数据流设备ID所绑定的主机IP地址和在Docker容器内绑定的端口号的对应关系。其中,数据流设备所在 主机的IP地址可以根据数据流设备所绑定的Docker容器地址、以及Docker容器初始化时建立的Docker容器地址与所在主机的IP地址之间的对应关系确定。
在步骤S410中,数据分发单元在更新数据分发映射表后,向信令处理单元返回ACK消息。
在步骤S411中,信令处理单元接收到ACK消息后,向外部设备发送订阅响应消息,其中可以包含需要点播的数据流设备的ID。
在步骤S412中,外部设备向信令处理单元发送ACK消息。
在步骤S413中,信令处理单元接收到ACK消息后,向需要点播的ID所对应的数据流设备发送点播请求消息。
在步骤S414中,需要点播的ID所对应的数据流设备接收到点播请求消息后,向数据分发单元发送数据。
在步骤S415中,数据分发单元接收到数据包后,查找数据分发映射表,在能查到数据包携带的源地址和源端口号所共同对应的目的地址和目的端口号的情况下,执行步骤S416,即将数据包转发到对应的外部设备;在不能查到数据包携带的源地址和源端口号所共同对应的目的地址和目的端口号的情况下,将数据包直接丢弃掉。
综上可知,本实施例提供的网络通信方法及系统针对Docker容器应用部署的场景,将iptables转发和应用转发结合,Docker容器只需在主机上暴露一对第一端口,该对第一端口设置为数据传输,即可实现Docker容器内多个端口的数据转发,不仅降低了Docker容器端口的管理复杂度,而且提高了数据传输效率,方便了运维管理,也提高了Docker容器的可靠性。
图8为本申请实施例提供的网络设备的示意图。如图8所示,本申请实施例提供一种网络设备800(比如,部署Docker容器的主机设备),包括:存储器801和处理器802,存储器801设置为存储网络通信程序,该网络通信程序被处理器802执行时,实现上述实施例提供的网络通信方法,比如图3所示的步骤。本领域技术人员可以理解,图8中示出的结构,仅仅是与本申请方案相关的部分结构的示意图,并不构成对本申请方案所应用于其上的网络设备800的限定,网络设备800可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。
其中,处理器802可以包括但不限于微处理器(Microcontroller Unit,MCU)或可编程逻辑器件(Field Programmable Gate Array,FPGA)等的处理装置。存储器801设置为存储应用软件的软件程序以及模块,如本实施例中的网络通信方法对应的程序指令或模块,处理器802通过运行存储在存储器801内的软件程序以及模块,从而执行各种功能应用以及数据处理,比如实现本实施例提供的网络通信方法。存储器801可包括高速随机存储器,还可包括非易失性存储 器,如至少一个磁性存储装置、闪存、或者其他非易失性固态存储器。在一些示例中,存储器801可包括相对于处理器802远程设置的存储器,这些远程存储器可以通过网络连接至网络设备800。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。
此外,本申请实施例还提供一种计算机可读介质,该计算机存储介质存储有网络通信程序,该网络通信程序被处理器执行时,实现上述实施例提供的网络通信方法,比如,图3所示的步骤。
本领域普通技术人员可以理解,上文中所公开方法中的全部或某些步骤、系统、装置中的功能模块/单元可以被实施为软件、固件、硬件及其适当的组合。在硬件实施方式中,在以上描述中提及的功能模块/单元之间的划分不一定对应于物理组件的划分;例如,一个物理组件可以具有多个功能,或者一个功能或步骤可以由若干物理组件合作执行。某些组件或所有组件可以被实施为由处理器,如数字信号处理器或微处理器执行的软件,或者被实施为硬件,或者被实施为集成电路,如专用集成电路。这样的软件可以分布在计算机可读介质上,计算机可读介质可以包括计算机存储介质(或非暂时性介质)和通信介质(或暂时性介质)。如本领域普通技术人员公知的,术语计算机存储介质包括在用于存储信息(诸如计算机可读指令、数据结构、程序模块或其他数据)的任何方法或技术中实施的易失性和非易失性、可移除和不可移除介质。计算机存储介质包括但不限于随机存取存储器(Random Access Memory,RAM)、只读存储器(Read-Only Memory,ROM)、带电可擦可编程只读存储器(Electrically Erasable Programmable read only memory,EEPROM)、闪存或其他存储器技术、只读光盘(Compact Disc Read-Only Memory,CD-ROM)、数字多功能盘(Digital Video Disc,DVD)或其他光盘存储、磁盒、磁带、磁盘存储或其他磁存储装置、或者可以用于存储期望的信息并且可以被计算机访问的任何其他的介质。此外,本领域普通技术人员公知的是,通信介质通常包含计算机可读指令、数据结构、程序模块或者诸如载波或其他传输机制之类的调制数据信号中的其他数据,并且可包括任何信息递送介质。
Claims (14)
- 一种网络通信方法,包括:确定Docker容器内的数据转发规则;其中,所述Docker容器的一对第一端口映射到所在主机的端口上;根据所述数据转发规则,将通过所述第一端口接收的数据包转发给所述Docker容器内部署的应用,或者,将所述Docker容器内部署的应用发送的数据包通过所述第一端口转发给外部设备。
- 根据权利要求1所述的方法,其中,所述一对第一端口设置为传输至少一路数据,所述数据转发规则用于记录每路数据的数据源的信息和数据目的地的信息,所述数据源或所述数据目的地为所述Docker容器内部署的应用。
- 根据权利要求2所述的方法,其中,所述数据源的信息包括:源地址以及源端口;所述数据目的地的信息包括:目的地址以及目的端口,所述源端口或所述目的端口为所述Docker容器内部署的应用绑定的端口。
- 根据权利要求3所述的方法,其中,所述根据所述数据转发规则,将通过所述第一端口接收的数据包转发给所述Docker容器内部署的应用,包括:通过查询所述数据转发规则,确定从所述第一端口接收到的数据包携带的源地址和源端口所共同对应的目的端口;将所述数据包转发给所述Docker容器内绑定所述目的端口的应用。
- 根据权利要求3所述的方法,其中,所述根据所述数据转发规则,将所述Docker容器内部署的应用发送的数据包通过所述第一端口转发给外部设备,包括:通过查询所述数据转发规则,确定所述Docker容器内发送所述数据包的应用所绑定的端口对应的外部设备的网络协议IP地址和端口;通过所述第一端口将所述数据包转发至所述外部设备。
- 根据权利要求1所述的方法,其中,所述一对第一端口设置为传输至少一路数据,所述方法还包括:获取每路数据的通信链路信息;其中,所述确定Docker容器内的数据转发规则,包括:根据每路数据的通信链路信息,确定所述Docker容器内的数据转发规则。
- 根据权利要求6所述的方法,其中,所述Docker容器的一个第二端口映射到所述主机的端口上;所述获取每路数据的通信链路信息,包括:通过所述第二端口与所述外部设备进行信令交互,确定待通过所述第一端口接收的一路数据的源地址和源端口;从待接收所述一路数据的应用中获取所述应用绑定的Docker容器地址和端口;根据所述一路数据的源地址、源端口、所述应用所绑定的Docker容器地址和端口,确定所述一路数据的通信链路信息;或者,通过所述第二端口接收所述外部设备发送的请求消息,从所述请求消息中解析出待通过所述第一端口发送的一路数据的目的地址和目的端口、待发送所述一路数据的应用;从所述待发送所述一路数据的应用获取所述应用绑定的Docker容器地址和端口;根据所述一路数据的目的地址、目的端口、所述应用绑定的Docker容器地址和端口,确定所述一路数据的通信链路信息。
- 一种网络通信系统,包括:数据分发单元以及网络应用单元;所述数据分发单元和所述网络应用单元部署在Docker容器内;所述Docker容器的一对第一端口映射到所在主机的端口上;所述网络应用单元包括至少一个应用;所述数据分发单元,设置为确定所述Docker容器内的数据转发规则;根据所述数据转发规则,将通过所述第一端口接收的数据包转发给所述网络应用单元内的应用,或者,将所述网络应用单元内的应用发送的数据包通过所述第一端口转发给外部设备。
- 根据权利要求8所述的系统,其中,所述一对第一端口设置为传输至少一路数据,所述数据转发规则用于记录每路数据的数据源信息和数据目的地的信息,所述数据源或所述数据目的地为所述网络应用单元内的应用。
- 根据权利要求9所述的系统,其中,所述数据源的信息包括:源地址以及源端口;所述数据目的地的信息包括:目的地址以及目的端口,所述源端口或所述目的端口为所述网络应用单元内的应用绑定的端口。
- 根据权利要求8所述的系统,其中,所述一对第一端口设置为传输至少一路数据,所述系统还包括:信令处理单元,设置为获取每路数据的通信链路信息,并发送所述通信链路信息给所述数据分发单元;所述数据分发单元设置为根据每路数据的通信链路信息,确定所述Docker容器内的数据转发规则。
- 根据权利要求11所述的系统,其中,所述Docker容器的一个第二端口映射到所在主机的端口上;所述信令处理单元,设置为通过以下方式获取每路数据的通信链路信息:通过所述第二端口与所述外部设备进行信令交互,确定待通过所述第一端口接收的一路数据的源地址和源端口;从待接收所述一路数据的应用获取所述应用绑定的Docker容器地址和端口;根据所述一路数据的源地址、源端口、所述应用所绑定的Docker容器地址和端口,确定所述一路数据的通信链路信息;或者,通过所述第二端口接收所述外部设备发送的请求消息,从所述请求消息中解析出待通过所述第一端口发送的一路数据的目的地址和目的端口、待发送所述一路数据的应用;从所述待发送该路数据的应用获取所述应用绑定的Docker 容器地址和端口;根据所述一路数据的目的地址、目的端口、所述应用绑定的Docker容器地址和端口,确定所述一路数据的通信链路信息。
- 一种网络设备,包括:处理器和存储器;所述存储器设置为存储网络通信程序,所述网络通信程序被所述处理器执行时,实现如权利要求1至7中任一项所述的网络通信方法。
- 一种计算机可读介质,存储有网络通信程序,所述网络通信程序被处理器执行时,实现如权利要求1至7中任一项所述的网络通信方法。
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| EP19901849.0A EP3905610B1 (en) | 2018-12-28 | 2019-12-30 | Method and system for network communicaton |
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201811617423.2 | 2018-12-28 | ||
| CN201811617423.2A CN109842559B (zh) | 2018-12-28 | 2018-12-28 | 一种网络通信方法及系统 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2020135856A1 true WO2020135856A1 (zh) | 2020-07-02 |
Family
ID=66883430
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2019/129787 Ceased WO2020135856A1 (zh) | 2018-12-28 | 2019-12-30 | 一种网络通信方法及系统 |
Country Status (3)
| Country | Link |
|---|---|
| EP (1) | EP3905610B1 (zh) |
| CN (1) | CN109842559B (zh) |
| WO (1) | WO2020135856A1 (zh) |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114363092A (zh) * | 2022-03-17 | 2022-04-15 | 万商云集(成都)科技股份有限公司 | 一种用于云容器引擎微服务部署的网关及方法 |
| CN115567285A (zh) * | 2022-09-22 | 2023-01-03 | 深圳前海微众银行股份有限公司 | 容器化服务漏洞检测方法、装置和服务器 |
Families Citing this family (8)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN109842559B (zh) * | 2018-12-28 | 2021-04-09 | 中兴通讯股份有限公司 | 一种网络通信方法及系统 |
| CN110943914B (zh) * | 2019-11-28 | 2022-01-21 | 中国南方电网有限责任公司 | 配电房智能网关及控制方法 |
| US11513830B2 (en) * | 2020-04-02 | 2022-11-29 | Vmware, Inc. | Introspection into workloads running within virtual machines |
| CN113765799B (zh) * | 2020-06-05 | 2024-12-06 | 中兴通讯股份有限公司 | 容器报文发送和接收的方法及存储介质、容器通信系统 |
| CN114286051B (zh) * | 2021-12-17 | 2025-06-06 | 武汉众智数字技术有限公司 | 一种基于gb35114协议的gb28181监控系统的升级改造方法及系统 |
| CN115617450A (zh) * | 2022-08-30 | 2023-01-17 | 武汉光庭信息技术股份有限公司 | 基于Ivshmem的通讯方法、系统、设备及存储介质 |
| CN116074309B (zh) * | 2023-03-06 | 2023-06-16 | 深圳前海环融联易信息科技服务有限公司 | 跨平台容器内操作系统的访问方法及相关设备 |
| CN119484467A (zh) * | 2023-07-28 | 2025-02-18 | 杭州阿里云飞天信息技术有限公司 | 容器与外部网络通信的方法、装置和电子设备及存储介质 |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| GB191328181A (en) | 1913-12-06 | 1914-05-21 | Thomas Matthew Munro | Improvements in Distributors for Sand Pump Dredgers and the like. |
| EP3101966A1 (en) * | 2015-06-05 | 2016-12-07 | Alcatel Lucent | A network, a cloud-based server, and a method of registering for a service |
| CN107608763A (zh) * | 2017-09-26 | 2018-01-19 | 中国科学院声学研究所 | 一种通过Web浏览器进入Docker容器操作的方法 |
| CN108600282A (zh) * | 2017-11-30 | 2018-09-28 | 深圳市牛鼎丰科技有限公司 | 微服务发布方法、装置、存储介质和计算机设备 |
| CN108932153A (zh) * | 2018-07-06 | 2018-12-04 | 杭州涂鸦信息技术有限公司 | 一种多Docker实例动态分配宿主机端口的方法和装置 |
| CN109842559A (zh) * | 2018-12-28 | 2019-06-04 | 中兴通讯股份有限公司 | 一种网络通信方法及系统 |
Family Cites Families (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102932568B (zh) * | 2012-11-23 | 2014-03-12 | 上海市共进通信技术有限公司 | 嵌入式VoIP电话系统及实现VoIP电话语音质量管理的方法 |
| US10892942B2 (en) * | 2016-01-22 | 2021-01-12 | Equinix, Inc. | Container-based cloud exchange disaster recovery |
| CN106130990B (zh) * | 2016-06-29 | 2019-06-18 | 中国联合网络通信集团有限公司 | 容器访问的控制方法及装置 |
| CN106656980A (zh) * | 2016-10-21 | 2017-05-10 | 郑州云海信息技术有限公司 | 一种自动化配置Docker容器访问控制的方法 |
| US10530747B2 (en) * | 2017-01-13 | 2020-01-07 | Citrix Systems, Inc. | Systems and methods to run user space network stack inside docker container while bypassing container Linux network stack |
| US10356048B2 (en) * | 2017-03-17 | 2019-07-16 | Verizon Patent And Licensing Inc. | Container deployment for a network |
| CN107465765B (zh) * | 2017-09-21 | 2020-07-14 | 深圳市视维科技股份有限公司 | 一种基于容器云的智能应用网关实现方法 |
-
2018
- 2018-12-28 CN CN201811617423.2A patent/CN109842559B/zh active Active
-
2019
- 2019-12-30 WO PCT/CN2019/129787 patent/WO2020135856A1/zh not_active Ceased
- 2019-12-30 EP EP19901849.0A patent/EP3905610B1/en active Active
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| GB191328181A (en) | 1913-12-06 | 1914-05-21 | Thomas Matthew Munro | Improvements in Distributors for Sand Pump Dredgers and the like. |
| EP3101966A1 (en) * | 2015-06-05 | 2016-12-07 | Alcatel Lucent | A network, a cloud-based server, and a method of registering for a service |
| CN107608763A (zh) * | 2017-09-26 | 2018-01-19 | 中国科学院声学研究所 | 一种通过Web浏览器进入Docker容器操作的方法 |
| CN108600282A (zh) * | 2017-11-30 | 2018-09-28 | 深圳市牛鼎丰科技有限公司 | 微服务发布方法、装置、存储介质和计算机设备 |
| CN108932153A (zh) * | 2018-07-06 | 2018-12-04 | 杭州涂鸦信息技术有限公司 | 一种多Docker实例动态分配宿主机端口的方法和装置 |
| CN109842559A (zh) * | 2018-12-28 | 2019-06-04 | 中兴通讯股份有限公司 | 一种网络通信方法及系统 |
Non-Patent Citations (1)
| Title |
|---|
| See also references of EP3905610A4 |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114363092A (zh) * | 2022-03-17 | 2022-04-15 | 万商云集(成都)科技股份有限公司 | 一种用于云容器引擎微服务部署的网关及方法 |
| CN114363092B (zh) * | 2022-03-17 | 2022-05-17 | 万商云集(成都)科技股份有限公司 | 一种用于云容器引擎微服务部署的网关及方法 |
| CN115567285A (zh) * | 2022-09-22 | 2023-01-03 | 深圳前海微众银行股份有限公司 | 容器化服务漏洞检测方法、装置和服务器 |
Also Published As
| Publication number | Publication date |
|---|---|
| EP3905610A4 (en) | 2022-03-02 |
| EP3905610A1 (en) | 2021-11-03 |
| CN109842559A (zh) | 2019-06-04 |
| EP3905610B1 (en) | 2024-04-03 |
| CN109842559B (zh) | 2021-04-09 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2020135856A1 (zh) | 一种网络通信方法及系统 | |
| US10693791B2 (en) | Software-defined network-based method and system for implementing content distribution network | |
| US10263951B2 (en) | Network address family translation method and system | |
| US8055771B2 (en) | Network traversal method for establishing connection between two endpoints and network communication system | |
| US20200228433A1 (en) | Computer-readable recording medium including monitoring program, programmable device, and monitoring method | |
| US8725883B2 (en) | Method for the establishing of peer-to-peer multimedia sessions in a communication system | |
| CN113630439B (zh) | 实时通信rtc连接方法、服务器及存储介质 | |
| TWI245192B (en) | Method, system and storage medium for passing through network address translation device | |
| US20100257276A1 (en) | Virtual network interface for relayed nat traversal | |
| WO2009121305A1 (zh) | 网络地址转换地址映射表维护方法、媒体网关及其控制器 | |
| CN114501593B (zh) | 网络切片接入方法、装置、系统和存储介质 | |
| CN115001846A (zh) | 一种跨网数据传输的方法、隔离设备、装置及介质 | |
| US10791164B2 (en) | Intelligent route management for diverse ecosystems | |
| CN108737505A (zh) | 一种资源下载的方法、系统和终端设备 | |
| CN118301214A (zh) | 目标服务数据的传输方法、系统、存储介质及电子装置 | |
| CN110661896B (zh) | 一种确定数据流的映射地址的方法及服务器 | |
| US20150095469A1 (en) | Identifier-based communication method using application program interface | |
| CN109413224A (zh) | 报文转发方法和装置 | |
| CN105979405A (zh) | 访问视频设备的方法及装置 | |
| CN116633852A (zh) | 数据传输方法、系统及电子设备 | |
| US10027586B2 (en) | Network address family translation method and system | |
| CN100579132C (zh) | 在具有不同地址范围的网络中的网络单元之间进行数据交换的方法 | |
| CN117354019A (zh) | 一种虚拟私有云vpc之间互通的实现系统及其方法 | |
| Piron | Master thesis: Implementation and Evaluation of LISP Publish/Subscribe Functionality in NS3 | |
| CN118764461B (zh) | 网络地址转换类型的确定方法、装置及电子设备 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 19901849 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| ENP | Entry into the national phase |
Ref document number: 2019901849 Country of ref document: EP Effective date: 20210728 |