Communication method, communication system, communication device, server and storage medium
By using flow table conversion rules in the OVS bridge, the virtual machine and host communication is directly carried out in the local area network, and the bandwidth occupation and packet loss problems in virtual machine management control is solved, and convenient virtual machine and host are realized Communication.
Patent Information
- Application Number
- CN202411299959.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-18
- Publication Date
- 2024-12-27
AI Technical Summary
In the prior art, virtual machine management control is difficult to implement in cloud computing systems, especially due to the bandwidth occupation and path packet loss caused by the characteristics of router gateways.
By using the conversion rules in the flow table in the OVS bridge, the virtual IP address is modified to the actual IP address, and the virtual machine and host communication are directly carried out in the local area network, avoiding the gateway router.
It realizes convenient communication between the virtual machine and the host, shortens the transmission path, reduces the burden on the router and the risk of data packet loss, and has not modified the virtual machine, and only adds conversion rules in the OVS bridge.
Smart Images

Figure CN119211187A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of virtual machine communication technology, and in particular to a communication method, a communication system, a device, a server and a storage medium. Background Art
[0002] In cloud computing systems, virtualization technology can be used as the basis to abstract and simulate the physical resources of a computer into several logical resources to create several virtual machines. To manage and control a single virtual machine through an IP address without affecting the existing virtual network environment, there are two solutions available in the prior art, namely, Solution A and Solution B.
[0003] Among them, Solution A is to add an additional virtual network port to the virtual machine to form an additional network, so that the host can manage and control a single virtual machine. Solution B is to manage and control the virtual machine through the router gateway of the host machine.
[0004] However, Solution A involves the modification of the virtual machine, adding a new network card to the virtual machine, which affects the integrity of the virtual machine itself, especially for virtualization scenarios, where the network complexity is high. In Solution B, due to the characteristics of the router gateway, it can control all virtual machines in the same network segment, so the traffic of the host machine to manage and control different virtual machines will all pass through a router gateway, which will occupy a large amount of bandwidth in the virtualized network. If the traffic passing through the router gateway is too large, it may cause packet loss on the path.
[0005] Therefore, how to more conveniently implement the management and control of virtual machines by the host machine is an issue that needs to be addressed urgently. Summary of the invention
[0006] Based on this, it is necessary to provide a communication method, communication system, device, server and storage medium that can more conveniently implement the host machine's management and control of a single virtual machine in response to the above technical problems.
[0007] In a first aspect, the present application provides a communication method, applied to an OVS bridge, the method comprising:
[0008] For the received data packet, a data packet whose source address is the IP address of the host machine and whose destination IP address is the virtual IP address of the target virtual machine is determined as the first data packet, wherein the virtual IP address and the IP address of the host machine are in the same network segment;
[0009] Based on the conversion rule in the flow table, the destination IP address of the first data packet is modified to the actual IP address of the target virtual machine to obtain a modified first data packet; the conversion rule represents the conversion rule between the actual IP address of the target virtual machine and the virtual IP address;
[0010] Based on the modified destination IP address of the first data packet, the modified first data packet is forwarded to the target virtual machine.
[0011] In one embodiment, forwarding the modified first data packet to the target virtual machine based on the modified destination IP address of the first data packet includes:
[0012] Based on the modified destination IP address of the first data packet, determine the port number of the target virtual machine accessing the OVS bridge from the flow table, wherein the flow table includes a flow table entry representing the correspondence between the port number of the target virtual machine accessing the OVS bridge and the actual IP address of the target virtual machine;
[0013] The modified first data packet is forwarded to the target virtual machine through the port corresponding to the port number.
[0014] In one embodiment, the method further comprises:
[0015] For the received data packet, determining the data packet whose source address is the actual IP address of the target virtual machine and whose destination address is the IP address of the host machine as the second data packet;
[0016] Modify the source address of the second data packet to the virtual IP address of the target virtual machine based on the conversion rule in the flow table to obtain a modified second data packet;
[0017] The modified second data packet is forwarded to the host machine.
[0018] In a second aspect, the present application further provides a communication method, applied to a host machine, the method comprising:
[0019] Determine the MAC address of the target virtual machine based on the virtual IP address of the target virtual machine from the Arp correspondence of the namespace, wherein the Arp correspondence includes a correspondence between the virtual IP address of the target virtual machine and the MAC address of the target virtual machine;
[0020] Generate a first data packet, wherein the destination IP address of the first data packet is the virtual IP address of the target virtual machine, the destination MAC address of the first data packet is the MAC address of the target virtual machine, the source address of the first data packet is the IP address of the host machine, and the virtual IP address of the target virtual machine and the IP address of the host machine are in the same network segment;
[0021] The first data packet is sent to the OVS bridge, so that the OVS bridge modifies the destination IP address of the first data packet to the actual IP address of the target virtual machine based on the conversion rule in the flow table, and forwards the modified first data packet to the target virtual machine based on the modified destination IP address of the first data packet, wherein the conversion rule represents the conversion rule between the actual IP address and the virtual IP address of the target virtual machine.
[0022] In a third aspect, the present application further provides a communication system, the communication system comprising an OVS bridge, a target virtual machine and a host machine, wherein:
[0023] The target virtual machine communicates with the OVS bridge through a port;
[0024] The Arp correspondence of the host machine's namespace includes the correspondence between the MAC address and the virtual IP address of the target virtual machine;
[0025] The OVS bridge is used to modify the destination IP address of the received first data packet to the actual IP address of the target virtual machine based on the conversion rule in the flow table, obtain a modified first data packet, and forward the modified first data packet to the target virtual machine based on the destination IP address of the modified first data packet, wherein the conversion rule represents the conversion rule between the actual IP address and the virtual IP address of the target virtual machine; the source address of the first data packet is the IP address of the host machine, the destination IP address is the actual IP address of the target virtual machine, and the virtual IP address is in the same network segment as the IP address of the host machine;
[0026] The OVS bridge is also used to modify the source address of the received second data packet to the virtual IP address of the target virtual machine based on the conversion rules in the flow table, obtain a modified second data packet, and forward the modified second data packet to the host machine, where the source address of the second data packet is the actual IP address of the target virtual machine, the destination IP address is the IP address of the host machine, and the destination MAC address is the MAC address of the host machine.
[0027] In one embodiment, the communication system further comprises a controller, wherein the controller is configured to:
[0028] Obtain the actual IP address of the MAC address of the target virtual machine from the hypervisor, and determine the port number corresponding to the target virtual machine in the OVS bridge;
[0029] Determine the IP address and MAC address of the host machine with which the target virtual machine needs to communicate;
[0030] Allocate a virtual IP address for the target virtual machine, where the virtual IP address is in the same network segment as the IP address of the host machine;
[0031] In the Arp relationship table of the network namespace of the host machine, write the correspondence between the MAC address and the virtual IP address of the target virtual machine;
[0032] Generate a flow table entry based on the port number of the target virtual machine accessing the OVS bridge and the actual IP address of the MAC address of the target virtual machine, and update the flow table of the OVS bridge based on the flow table entry;
[0033] A conversion rule is generated based on the virtual IP address and the actual IP address of the target virtual machine, and the flow table of the OVS bridge is updated using the conversion rule.
[0034] In one embodiment, when the controller allocates a virtual IP address to the target virtual machine, it is specifically used to:
[0035] Determine the available address resources in the network segment where the IP address of the host machine is located;
[0036] An available IP address is randomly allocated to the target virtual machine from the available address resources as a virtual IP address.
[0037] In a fourth aspect, the present application further provides a communication device, the device comprising a receiving module, a modifying module and a forwarding module, wherein:
[0038] A receiving module, configured to determine, for a received data packet, a data packet whose source address is the IP address of the host machine and whose destination IP address is the virtual IP address of the target virtual machine as a first data packet, wherein the virtual IP address and the IP address of the host machine are in the same network segment;
[0039] A modification module, configured to modify the destination IP address of the first data packet to the actual IP address of the target virtual machine based on a conversion rule in the flow table, so as to obtain a modified first data packet; the conversion rule represents a conversion rule between the actual IP address of the target virtual machine and the virtual IP address;
[0040] The sending module is used to forward the modified first data packet to the target virtual machine based on the destination IP address of the modified first data packet.
[0041] In a fifth aspect, the present application further provides a communication device, the device comprising an address determination module, a generation module and a sending module, wherein:
[0042] An address determination module, configured to determine a MAC address of a target virtual machine based on a virtual IP address of the target virtual machine from an Arp correspondence in a namespace, wherein the virtual IP address and the IP address of the host machine are in the same network segment, and the Arp correspondence includes a correspondence between the virtual address of the target virtual machine and the MAC address of the target virtual machine;
[0043] A generating module, configured to generate a first data packet, wherein the destination IP address of the first data packet is the virtual IP address of the target virtual machine, the destination MAC address of the first data packet is the MAC address of the target virtual machine, the source address of the first data packet is the IP address of the host machine, and the virtual IP address of the target virtual machine and the IP address of the host machine are in the same network segment;
[0044] A sending module is used to send the first data packet to the OVS bridge, so that the OVS bridge modifies the destination IP address of the first data packet to the actual IP address of the target virtual machine based on the conversion rule in the flow table, and forwards the modified first data packet to the target virtual machine based on the modified destination IP address of the first data packet, wherein the conversion rule represents the conversion rule between the actual IP address and the virtual IP address of the target virtual machine.
[0045] In a sixth aspect, the present application further provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0046] For the received data packet, a data packet whose source address is the IP address of the host machine and whose destination IP address is the virtual IP address of the target virtual machine is determined as the first data packet, wherein the virtual IP address and the IP address of the host machine are in the same network segment;
[0047] Based on the conversion rule in the flow table, the destination IP address of the first data packet is modified to the actual IP address of the target virtual machine to obtain a modified first data packet; the conversion rule represents the conversion rule between the actual IP address of the target virtual machine and the virtual IP address;
[0048] Based on the modified destination IP address of the first data packet, the modified first data packet is forwarded to the target virtual machine.
[0049] In one embodiment, when the processor executes the computer program, the processor may further implement the following steps:
[0050] Determine the MAC address of the target virtual machine based on the virtual IP address of the target virtual machine from the Arp correspondence of the namespace, wherein the Arp correspondence includes a correspondence between the virtual IP address of the target virtual machine and the MAC address of the target virtual machine;
[0051] Generate a first data packet, wherein the destination IP address of the first data packet is the virtual IP address of the target virtual machine, the destination MAC address of the first data packet is the MAC address of the target virtual machine, the source address of the first data packet is the IP address of the host machine, and the virtual IP address of the target virtual machine and the IP address of the host machine are in the same network segment;
[0052] The first data packet is sent to the OVS bridge, so that the OVS bridge modifies the destination IP address of the first data packet to the actual IP address of the target virtual machine based on the conversion rule in the flow table, and forwards the modified first data packet to the target virtual machine based on the destination IP address of the modified first data packet, wherein the conversion rule represents the conversion rule between the actual IP address and the virtual IP address of the target virtual machine.
[0053] In a seventh aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:
[0054] For the received data packet, a data packet whose source address is the IP address of the host machine and whose destination IP address is the virtual IP address of the target virtual machine is determined as the first data packet, wherein the virtual IP address and the IP address of the host machine are in the same network segment;
[0055] Based on the conversion rule in the flow table, the destination IP address of the first data packet is modified to the actual IP address of the target virtual machine to obtain a modified first data packet; the conversion rule represents the conversion rule between the actual IP address of the target virtual machine and the virtual IP address;
[0056] Based on the modified destination IP address of the first data packet, the modified first data packet is forwarded to the target virtual machine.
[0057] In the above communication method, communication system, device, server and storage medium, in the embodiment of the present application, since the virtual IP address of the target virtual machine and the IP address of the host machine are in the same network segment, so that the host machine and the target virtual machine can communicate in the local area network without passing through the gateway router, it is possible to shorten the link between the host machine and the target virtual machine and reduce the transmission path; and since the traffic transmitted between the target virtual machine and the host machine will not pass through the gateway router, the burden on the router is reduced, thereby reducing the risk of packet loss during data transmission. And the scheme of the embodiment of the present application does not make any modifications to the target virtual machine, but only adds the conversion rules of the actual IP address and the virtual IP address of the target virtual machine in the OVS bridge to which the target virtual machine is connected, which is used to indicate the modification of the corresponding data packet; after the OVS bridge determines that the received data packet is the first data packet sent by the host machine to the virtual IP address, the OVS bridge modifies the destination IP address of the first data packet to the actual IP address of the target virtual machine, so that the modified first data packet can be forwarded to the target virtual machine; therefore, the scheme of the embodiment of the present application can more conveniently realize the communication between the virtual machine and the host machine. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0059] Figure 1 An application environment diagram of a communication method in an embodiment;
[0060] Figure 2 A flow chart of a communication method applied to an OVS bridge in one embodiment;
[0061] Figure 3 A schematic diagram of a flow chart of steps for an OVS bridge to forward a data packet to a target virtual machine in one embodiment;
[0062] Figure 4 A schematic diagram of a process of an OVS bridge processing a data packet sent by a target virtual machine in one embodiment;
[0063] Figure 5 is a flow chart of a communication method applied to a host machine in one embodiment;
[0064] Figure 6 is a schematic diagram of the structure of a communication network in one embodiment;
[0065] Figure 7 A schematic diagram of the structure of a communication network in another embodiment;
[0066] Figure 8 A schematic diagram of a flow chart of steps for configuring a communication network by a controller in one embodiment;
[0067] Fig. 9 A schematic diagram of a network structure of a distributed host machine in one embodiment;
[0068] Fig.10 is a structural block diagram of a communication device in one embodiment;
[0069] Fig.11 is a structural block diagram of a communication device in another embodiment;
[0070] Fig.12 A schematic diagram of the structure of a computer device. DETAILED DESCRIPTION
[0071] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0072] The communication method provided in the embodiment of the present application can be applied to Figure 1 In the application environment of the SDN network (Software-Defined Networking), the host machine 101 communicates with the virtual machine 103 through the OVS bridge 102. A flow table is configured in the OVS bridge. The flow table items in the flow table represent the processing rules of the OVS bridge for data packets, and different data packets are processed and forwarded through their corresponding ports, thereby realizing isolated transmission of data packets.
[0073] The SDN network can be run on computer devices, which can be, but are not limited to, various personal computers, laptops, smart phones, tablet computers, IoT devices, portable wearable devices, and servers. IoT devices can be smart speakers, smart TVs, smart air conditioners, smart car devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server can be implemented as an independent server or a server cluster consisting of multiple servers.
[0074] In an exemplary embodiment, Figure 2 As shown, a communication method is provided, which is applied to Figure 1 The OVS bridge in the example is used as an example to illustrate, including the following steps 11 to 13, where:
[0075] Step 11: For the received data packets, determine the data packet whose source address is the IP address of the host machine and whose destination IP address is the virtual IP address of the target virtual machine as the first data packet, wherein the virtual IP address and the IP address of the host machine are in the same network segment.
[0076] For the embodiment of the present application, when the OVS bridge receives a data packet, it determines the destination IP address, source address, destination MAC address and other information of the data packet. Then it determines whether the data packet is sent from the host machine to the target virtual machine, or from the target virtual machine to the host machine. Among them, the first data packet is the data packet that the host machine wants to send to the target virtual machine. In the SDN network, if the host machine wants to send a data packet to the target virtual machine, it needs to encapsulate the data packet based on the destination IP address and the destination MAC address and the host machine's own IP address as the source address. Therefore, in the embodiment of the present application, the encapsulated first data packet has a destination IP address of the virtual IP address of the target virtual machine, a destination MAC address of the target virtual machine, and a source address of the host machine's IP address.
[0077] The first data packet can be sent directly from the host machine to the OVS bridge, or it can be forwarded through other paths to the OVS bridge connected to the target virtual machine; however, in the embodiment of the present application, since the virtual IP address of the target virtual machine and the IP address of the host machine are in the same network segment, the first data packet can be sent directly by the host machine to the OVS bridge connected to the target virtual machine, and then the first data packet is forwarded by the OVS bridge connected to the target virtual machine.
[0078] Step 12: based on the conversion rules in the flow table, modify the destination IP address of the first data packet to the actual IP address of the target virtual machine to obtain a modified first data packet; the conversion rules represent the conversion rules between the actual IP address of the target virtual machine and the virtual IP address.
[0079] The function of the OVS bridge is to search the flow table inside the OVS bridge according to the header information of the received data packet (such as the destination IP address). The flow table is dynamically generated by the SDN controller according to the network policy and is used to guide the forwarding of data packets. If there is a matching flow table entry in the flow table, the virtual switch will forward the data packet according to the instructions of the flow table entry. If there is no matching flow table entry, the OVS bridge will encapsulate the key information of the data packet (such as the header information) into an event and send it to the SDN controller. The controller sends the calculated flow table entry to the virtual switch so that subsequent data packets of the same type can be forwarded directly according to the flow table entry without being sent to the controller for processing again.
[0080] In the related art, the target virtual machine has an actual IP address. The actual IP address is determined by the network card of the target virtual machine when the target virtual machine is created, and the actual IP address is also the address of the target virtual machine connected to the OVS bridge; in the flow table of the OVS bridge connected to the target virtual machine, there is a flow table entry, which represents the correspondence between the actual IP of the target virtual machine and the port number of the network card of the target virtual machine connected to the OVS bridge. In this way, the data packet with the destination IP address being the actual IP address of the target virtual machine can be forwarded to the target virtual machine by the OVS bridge through the port of the target virtual machine connected to the OVS bridge.
[0081] In the embodiment of the present application, the target virtual machine also has a virtual IP address; the IP address of the target virtual machine is different from the actual IP address, and in the OVS bridge to which the target virtual machine is connected, the flow table is configured with a conversion rule between the actual IP address and the virtual IP address of the target virtual machine. Among them, the conversion rule is used to indicate: for a data packet whose destination IP address is the virtual IP address of the target virtual machine, the destination IP address is modified to the actual IP address of the target virtual machine; the conversion rule is also used to indicate: for a data packet whose source address is the actual IP address of the target virtual machine, the source address is modified to the virtual IP address of the target virtual machine.
[0082] When the OVS bridge receives the first data packet sent by the host machine, the OVS bridge searches the internal flow table based on the destination IP address of the first data packet (the virtual IP address of the target virtual machine) and determines the conversion rule for the first data packet. The OVS bridge modifies the destination IP address of the first data packet from the virtual IP address of the target virtual machine to the actual IP address of the target virtual machine based on the conversion rule.
[0083] Step 13: forward the modified first data packet to the target virtual machine based on the modified destination IP address of the first data packet.
[0084] For the embodiment of the present application, compared with the unmodified first data packet, only the destination IP address of the modified first data packet is modified to the actual IP address of the target virtual machine, and other information is not modified. The OVS bridge can forward the modified first data packet to the target virtual machine based on the destination IP address of the modified first data packet (the actual IP address of the target virtual machine).
[0085] In the embodiment of the present application, since the virtual IP address of the target virtual machine and the IP address of the host machine are in the same network segment, the host machine and the target virtual machine can communicate in the local area network without passing through the gateway router, which can shorten the link between the host machine and the target virtual machine and reduce the transmission path; and since the traffic transmitted between the target virtual machine and the host machine will not pass through the gateway router, the burden on the router is reduced, thereby reducing the risk of packet loss during data transmission. In addition, the scheme of the embodiment of the present application does not make any modifications to the target virtual machine, but only adds the conversion rules between the actual IP address and the virtual IP address of the target virtual machine in the OVS bridge to which the target virtual machine is connected, which is used to indicate the modification of the corresponding data packet; after the OVS bridge determines that the received data packet is the first data packet sent by the host machine to the virtual IP address, the OVS bridge modifies the destination IP address of the first data packet to the actual IP address of the target virtual machine, so that the modified first data packet can be forwarded to the target virtual machine; therefore, the scheme of the embodiment of the present application can more conveniently realize the communication between the virtual machine and the host machine.
[0086] Moreover, in an embodiment of the present application, in a communication network established based on a target virtual machine, an OVS bridge, and a host machine, the traffic between the host machine and the target virtual machine is isolated from the traffic of other communication links, and thus will not affect the entire virtual network environment.
[0087] In one embodiment, if Figure 3 As shown, step 13 may specifically include step 131 and step 132, wherein:
[0088] Step 131: Based on the modified destination IP address of the first data packet, determine the port number of the target virtual machine accessing the OVS bridge from the flow table, where the flow table includes a flow table entry representing the correspondence between the port number of the target virtual machine accessing the OVS bridge and the actual IP address of the target virtual machine;
[0089] Step 132: forward the modified first data packet to the target virtual machine through the port corresponding to the port number.
[0090] Specifically, the OVS bridge matches the modified first data packet's destination IP address and destination MAC address from the flow table to obtain the flow table entry corresponding to the modified first data packet, and the flow table entry represents the correspondence between the port of the target virtual machine accessing the OVS bridge and its actual IP address. The OVS bridge then determines the port number of the target virtual machine accessing the OVS bridge based on the matched flow table entry, and then forwards the modified first data packet to the target virtual machine through the port of the target virtual machine accessing the OVS bridge.
[0091] The above steps 11 to 13 describe the process of how the OVS bridge receives the first data packet sent by the host machine, how to modify the address, and how to send the modified first data packet to the target virtual machine. The following content describes how the OVS bridge receives the second data packet sent by the target virtual machine, and how to forward the second data packet to the host machine.
[0092] Further, refer to Figure 4 The communication method in the embodiment of the present application further includes steps 21 to 23, wherein:
[0093] Step 21: For the received data packet, a data packet whose source address is the actual IP address of the target virtual machine and whose destination address is the IP address of the host machine is determined as a second data packet.
[0094] For the embodiment of the present application, when the OVS bridge receives a data packet, it determines the destination IP address, source address, and destination MAC address of the data packet, and then determines whether the data packet is sent from the host machine to the target virtual machine, or from the target virtual machine to the host machine. Among them, the second data packet is what the target virtual machine wants to send to the host machine, so the second data packet is encapsulated by the target virtual machine, the destination IP address of the second data packet is the IP address of the host machine, the destination MAC address of the second data packet is the MAC address of the host machine, and the source address of the second data packet is the actual IP address of the target virtual machine.
[0095] Step 22: modify the source address of the second data packet to the virtual IP address of the target virtual machine based on the conversion rule in the flow table to obtain a modified second data packet;
[0096] Step 23: forward the modified second data packet to the host machine.
[0097] For the embodiment of the present application, after receiving the second data packet, the OVS bridge to which the target virtual machine is connected matches the source address of the second data packet (the actual IP address of the target virtual machine) from the internal flow table to obtain the conversion rule for the second target data packet, and the conversion rule is used to indicate: for the data packet whose source address is the actual IP address of the target virtual machine, the source address is modified to the virtual IP address of the target virtual machine. Therefore, based on the conversion rule, the OVS bridge modifies the source address of the second data packet from the actual IP address of the target virtual machine to the virtual IP address of the target virtual machine to obtain the modified second data packet. In this way, even if the actual IP address of the target virtual machine is not in the same network segment as the IP address of the host machine, since the virtual IP address of the modified second data packet is in the same network segment as the IP address of the host machine, the modified second data packet can be transmitted within the local area network. In other words, the modified second data packet also does not need to be forwarded through the gateway router, but directly forwards the modified second data packet to the host machine through the OVS bridge, which can reduce the transmission path of the data packet when the target virtual machine communicates with the host machine, thereby reducing the risk of packet loss.
[0098] Moreover, in an embodiment of the present application, in a communication network established based on a target virtual machine, an OVS bridge, and a host machine, the traffic between the host machine and the target virtual machine is isolated from the traffic of other communication links, and thus will not affect the entire virtual network environment.
[0099] In an exemplary embodiment, Figure 5 As shown, a communication method is provided, which is applied to Figure 1 The host machine in is used as an example to illustrate, including the following steps 31 to 33, wherein:
[0100] Step 31: Determine the MAC address of the target virtual machine based on the virtual IP address of the target virtual machine from the Arp correspondence of the namespace. The virtual IP address and the IP address of the host machine are in the same network segment. The Arp correspondence includes the correspondence between the virtual address of the target virtual machine and the MAC address of the target virtual machine.
[0101] In the aforementioned embodiments, it has been explained how the data packets sent by the target virtual machine to the host machine are processed by the OVS bridge and then forwarded to the host machine. In fact, when the target virtual machine first accesses (sends data to) the destination IP (IP address of the host machine), if it is found that there is no direct router locally in the target virtual machine, it will try to connect to the default gateway. Due to the characteristics of the default gateway itself, when a target virtual machine cannot find an available gateway (direct router), it sends the data packet to the default designated gateway, and this gateway processes the data packet. At this time, the destination IP address of the data packet that the target virtual machine wants to send to the host machine is the IP address of the host machine, and the destination MAC address is the MAC address of the default gateway. During the communication process, the network space where the destination IP address is located will not automatically generate the Arp correspondence of the target virtual machine. Therefore, in an embodiment of the present application, the Arp correspondence between the virtual IP address of the target virtual machine and the MAC address of the target virtual machine is pre-added in the network namespace of the host machine.
[0102] For the embodiment of the present application, the host machine determines the corresponding MAC address (the MAC address of the target virtual machine) from the Arp correspondence of its network namespace based on the destination IP address of the target virtual machine with which it wants to communicate.
[0103] Step 32: Generate a first data packet, where the destination IP address of the first data packet is the virtual IP address of the target virtual machine, the destination MAC address of the first data packet is the MAC address of the target virtual machine, the source address of the first data packet is the IP address of the host machine, and the virtual IP address of the target virtual machine and the IP address of the host machine are in the same network segment;
[0104] Step 33: Send the first data packet to the OVS bridge so that the OVS bridge modifies the destination IP address of the first data packet to the actual IP address of the target virtual machine based on the conversion rule in the flow table, and forwards the modified first data packet to the target virtual machine based on the modified destination IP address of the first data packet. The conversion rule represents the conversion rule between the actual IP address and the virtual IP address of the target virtual machine.
[0105] For the embodiment of the present application, the first data packet encapsulates the data to be sent to the target virtual machine based on the destination IP address, the destination MAC address and the source address to generate the first data packet. The destination IP address of the first data packet is the virtual IP address of the target virtual machine, the destination MAC address of the first data packet is the MAC address of the target virtual machine, and the source address of the first data packet is the IP address of the host machine.
[0106] Since the destination address is the virtual IP address of the virtual machine, and the virtual IP address and the IP address of the host machine are in the same network segment, the host machine can communicate with the virtual IP address in the local area network without routing forwarding through the gateway router. Therefore, the host machine sends the first data packet to the OVS bridge to which the target virtual machine is connected, and the OVS bridge receives the first data packet, processes it accordingly, and forwards it to the target virtual machine. Among them, the processing process of the OVS bridge on the first data packet received by the host machine can refer to the specific definition of steps 11 to 13 in the above-mentioned communication method embodiment applied to the OVS bridge.
[0107] In the embodiment of the present application, since the virtual IP address of the target virtual machine and the IP address of the host machine are in the same network segment, the host machine and the target virtual machine can communicate in the local area network without passing through the gateway router, which can shorten the link between the host machine and the target virtual machine and reduce the transmission path; and since the traffic transmitted between the target virtual machine and the host machine will not pass through the gateway router, the burden on the router is reduced, thereby reducing the risk of packet loss during data transmission. In addition, the scheme of the embodiment of the present application does not make any modifications to the target virtual machine, but only adds the conversion rules between the actual IP address and the virtual IP address of the target virtual machine in the OVS bridge to which the target virtual machine is connected, which is used to indicate the modification of the corresponding data packet; after the OVS bridge determines that the received data packet is the first data packet sent by the host machine to the virtual IP address, the OVS bridge modifies the destination IP address of the first data packet to the actual IP address of the target virtual machine, so that the modified first data packet can be forwarded to the target virtual machine; therefore, the scheme of the embodiment of the present application can more conveniently realize the communication between the virtual machine and the host machine.
[0108] Moreover, in an embodiment of the present application, in a communication network established based on a target virtual machine, an OVS bridge, and a host machine, the traffic between the host machine and the target virtual machine is isolated from the traffic of other communication links, and thus will not affect the entire virtual network environment.
[0109] In an exemplary embodiment, Figure 6 As shown, a communication system is provided, and the communication system may specifically include an OVS bridge, a target virtual machine, and a host machine, wherein:
[0110] The target virtual machine communicates with the OVS bridge through ports;
[0111] The Arp correspondence of the host namespace includes the correspondence between the MAC address and the virtual IP address of the target virtual machine;
[0112] The OVS bridge is used to modify the destination IP address of the received first data packet to the actual IP address of the target virtual machine based on the conversion rules in the flow table, obtain a modified first data packet, and forward the modified first data packet to the target virtual machine based on the destination IP address of the modified first data packet, wherein the conversion rules represent the conversion rules between the actual IP address of the target virtual machine and the virtual IP address; the source address of the first data packet is the IP address of the host machine, the destination IP address is the actual IP address of the target virtual machine, and the virtual IP address is in the same network segment as the IP address of the host machine;
[0113] The OVS bridge is also used to modify the source address of the received second data packet to the virtual IP address of the target virtual machine based on the conversion rules in the flow table, obtain a modified second data packet, and forward the modified second data packet to the host machine. The source address of the second data packet is the actual IP address of the target virtual machine, the destination IP address is the IP address of the host machine, and the destination MAC address is the MAC address of the host machine.
[0114] The host machine is used to monitor the virtual machine, including monitoring the resources of the virtual machine, monitoring the services of the virtual machine, and monitoring the container status of the virtual machine.
[0115] It should be noted that in the communication network of the embodiment of the present application, the virtual machine can also be a configured independent container; similarly, the target virtual machine corresponding to the above communication method embodiment can also be a configured independent container, and no specific limitation is made in the embodiment of the present application.
[0116] Specifically, in the above system, two processes can be implemented, namely, the process of the host machine sending data to the target virtual machine, and the process of the target virtual machine sending data to the host machine. The two processes are respectively described below.
[0117] The process of the host machine sending data to the target virtual machine is as follows:
[0118] The host determines the corresponding MAC address (MAC address of the target virtual machine) from the Arp correspondence of its network namespace based on the destination IP address of the target virtual machine (the virtual IP address of the target virtual machine) with which it wants to communicate. The host then encapsulates the data it wants to send to the target virtual machine based on the destination IP address, the destination MAC address, and the source address to generate a first data packet. Among them, the destination IP address of the first data packet is the virtual IP address of the target virtual machine, the destination MAC address of the first data packet is the MAC address of the target virtual machine, and the source address of the first data packet is the IP address of the host. Since the destination address is the virtual IP address of the virtual machine, and the virtual IP address and the IP address of the host are in the same network segment, the host can communicate with the virtual IP address in the local area network without routing forwarding through the gateway router. Therefore, the host can directly send the first data packet to the OVS bridge to which the target virtual machine is connected.
[0119] In one embodiment, if Figure 7 As shown, the host machine is connected to the traffic management end OVS bridge, and the first data packet sent by the host machine is sent to the traffic management end OVS bridge, and the traffic management end OVS bridge forwards the first data packet to the OVS bridge connected to the target virtual access.
[0120] The target virtual machine also has a virtual IP address; the IP address of the target virtual machine is different from the actual IP address. In the OVS bridge to which the target virtual machine is connected, the flow table is configured with a conversion rule between the actual IP address and the virtual IP address of the target virtual machine. The conversion rule is used to indicate: for a data packet whose destination IP address is the virtual IP address of the target virtual machine, the destination IP address is modified to the actual IP address of the target virtual machine; the conversion rule is also used to indicate: for a data packet whose source address is the actual IP address of the target virtual machine, the source address is modified to the virtual IP address of the target virtual machine.
[0121] When the OVS bridge connected to the target virtual machine receives the first data packet sent by the host machine, the OVS bridge searches the internal flow table based on the destination IP address of the first data packet and can determine the conversion rule for the first data packet; the OVS bridge modifies the destination IP address of the first data packet from the virtual IP address of the target virtual machine to the actual IP address based on the conversion rule.
[0122] Compared with the unmodified first data packet, only the destination IP address of the modified first data packet is modified to the actual IP address of the target virtual machine, and other information is not modified. Based on the destination IP address and destination MAC address of the modified first data packet, the OVS bridge matches from the flow table to obtain the flow table entry corresponding to the modified first data packet. The flow table entry represents the correspondence between the port of the target virtual machine connected to the OVS bridge and its actual IP address. Based on the matched flow table entry, the OVS bridge forwards the modified first data packet to the target virtual machine through the port of the target virtual machine connected to the OVS bridge.
[0123] In the embodiment of the present application, since the virtual IP address of the target virtual machine and the IP address of the host machine are in the same network segment, the host machine and the target virtual machine can communicate in the local area network without passing through the gateway router, which can shorten the link between the host machine and the target virtual machine and reduce the transmission path; and since the traffic transmitted between the target virtual machine and the host machine will not pass through the gateway router, the burden on the router is reduced, thereby reducing the risk of packet loss during data transmission. In addition, the scheme of the embodiment of the present application does not make any modifications to the target virtual machine, but only adds the conversion rules between the actual IP address and the virtual IP address of the target virtual machine in the OVS bridge to which the target virtual machine is connected, which is used to indicate the modification of the corresponding data packet. Therefore, the scheme of the embodiment of the present application can more conveniently realize the communication between the virtual machine and the host machine.
[0124] The process of the target virtual machine sending data to the host machine is as follows:
[0125] The second data packet is what the target virtual machine wants to send to the host machine, so the second data packet is encapsulated by the target virtual machine, the destination IP address of the second data packet is the IP address of the host machine, the destination MAC address of the second data packet is the MAC address of the host machine, and the source address of the second data packet is the actual IP address of the target virtual machine.
[0126] After receiving the second data packet, the OVS bridge to which the target virtual machine is connected matches the internal flow table based on the source address of the second data packet to obtain the conversion rule for the second target data packet, and the conversion rule is used to indicate: for the data packet whose source address is the actual IP address of the target virtual machine, the source address is modified to the virtual IP address of the target virtual machine. Therefore, based on the conversion rule, the OVS bridge modifies the source address of the second data packet from the actual IP address of the target virtual machine to the virtual IP address of the target virtual machine to obtain the modified second data packet. In this way, even if the actual IP address of the target virtual machine is not in the same network segment as the IP address of the host machine, since the virtual IP address of the modified second data packet is in the same network segment as the IP address of the host machine, the modified second data packet can be transmitted within the local area network. In other words, the modified second data packet also does not need to be forwarded through the gateway router, but directly forwards the modified second data packet to the host machine through the OVS bridge, which can reduce the transmission path of the data packet when the target virtual machine communicates with the host machine, thereby reducing the risk of packet loss.
[0127] Furthermore, in the embodiment of the present application, the process of configuring and obtaining a communication network is described:
[0128] In the communication network of the embodiment of the present application, a controller is also included, wherein the controller is an OpenFlow controller. The controller is used to execute Figure 8 Steps 01 to 06 shown, wherein:
[0129] Step 01: Get the actual IP address of the target virtual machine's MAC address from the hypervisor and determine the corresponding port number of the target virtual machine in the OVS bridge.
[0130] Step 02: Determine the IP address and MAC address of the host machine with which the target virtual machine needs to communicate.
[0131] Specifically, when creating a target virtual machine, the actual IP address of the target virtual machine depends on the IP address of the network card assigned to it, and its MAC address is also determined. The correspondence between the port number of the port of the target virtual machine connected to the OVS bridge and the actual IP address of the target virtual machine is also pre-selected and configured as a flow table entry in the flow table. The actual IP address of the MAC address of the target virtual machine can be determined through the hypervisor of the target network, and the corresponding port number of the target virtual machine in the OVS bridge and other information can be determined. Furthermore, the IP address and MAC address of the host machine are also fixed and can also be obtained from the hypervisor.
[0132] In another possible implementation, the IP address and MAC address of the host machine may also be input by the user.
[0133] Step 03. Assign a virtual IP address to the target virtual machine. The virtual IP address is in the same network segment as the host machine's IP address.
[0134] Specifically, the controller determines available address resources in the network segment where the IP address of the host machine is located, and then randomly allocates an available IP address from the available address resources to the target virtual machine as the virtual IP address.
[0135] Step 04: In the Arp relationship table of the host's network namespace, write the correspondence between the target virtual machine's MAC address and the virtual IP address;
[0136] Step 05: Generate a flow table entry based on the port number of the target virtual machine accessing the OVS bridge and the actual IP address of the MAC address of the target virtual machine, and update the flow table of the OVS bridge based on the flow table entry;
[0137] Step 06: Generate a conversion rule based on the virtual IP address and actual IP address of the target virtual machine, and update the flow table of the OVS bridge with the conversion rule.
[0138] In the related art, the target virtual machine has an actual IP address. The actual IP address is determined by the network card of the target virtual machine when the target virtual machine is created, and the actual IP address is also the address of the target virtual machine connected to the OVS bridge; in the flow table of the OVS bridge connected to the target virtual machine, there is a flow table entry, which represents the correspondence between the actual IP of the target virtual machine and the port number of the network card of the target virtual machine connected to the OVS bridge. In this way, the data packet with the destination IP address being the actual IP address of the target virtual machine can be forwarded to the target virtual machine by the OVS bridge through the port of the target virtual machine connected to the OVS bridge.
[0139] In the embodiment of the present application, the target virtual machine also has a virtual IP address; the IP address of the target virtual machine is different from the actual IP address. The controller generates a conversion rule based on the actual IP address and the virtual IP address of the target virtual machine as a flow table item. Then the controller sends the flow item to the OVS bridge connected to the target virtual machine based on the OpenFlow protocol to update the flow table in the OVS bridge.
[0140] The conversion rule generated by the controller is used to instruct the OVS bridge: for a data packet whose destination IP address is the virtual IP address of the target virtual machine, the destination IP address is modified to the actual IP address of the target virtual machine. The conversion rule is also used to instruct the OVS bridge: for a data packet whose source address is the actual IP address of the target virtual machine, the source address is modified to the virtual IP address of the target virtual machine.
[0141] When the OVS bridge receives the first data packet sent by the host machine after the flow table is updated, the OVS bridge searches the internal flow table based on the destination IP address of the first data packet and can determine the conversion rule for the first data packet; the OVS bridge modifies the destination IP address of the first data packet from the virtual IP address of the target virtual machine to the actual IP address based on the conversion rule. The OVS bridge can also modify the source address of the second data packet sent by the target virtual machine from the actual IP address of the target virtual machine to the virtual IP address of the target virtual machine based on the conversion rule.
[0142] In an embodiment of the present application, through the above steps 01 to 06, the controller can establish a communication network between any host machine and the virtual machine, so that the host machine and the virtual machine can communicate within the local area network only through the OVS bridge, and the communication-related data does not need to be forwarded through the gateway router, thereby reducing the transmission path and reducing the risk of packet loss.
[0143] In one embodiment, the host machine can be multiple distributed machines. After one of the virtual machines builds a communication network with the target virtual machine, the distributed virtual machines can be connected through VXLAN tunnels to achieve information sharing; specifically, the sharing of Arp correspondence in the network namespace can be achieved. Fig. 9 As shown in , the host in node 1 has established a communication network with the target virtual machine, enabling communication within the local area network. For other hosts (such as the host in node 2) with IP addresses in the same network segment as the host in node 1, other hosts can obtain the Arp correspondence in the namespace of the host in node 1 through the connected VXLAN tunnel, thereby enabling the host in node 2 to communicate with the target virtual machine in the local area network.
[0144] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0145] Based on the same inventive concept, the embodiment of the present application also provides a communication device for implementing the communication method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more communication device embodiments provided below can refer to the limitations on the communication method in the embodiment of the communication method applied to the OVS bridge above, and will not be repeated here.
[0146] In an exemplary embodiment, Fig.10 As shown, a communication device is provided, the device includes a receiving module 1001, a modifying module 1002 and a forwarding module 1003, wherein:
[0147] The receiving module 1001 is used to determine, for a received data packet, a data packet whose source address is the IP address of the host machine and whose destination IP address is the virtual IP address of the target virtual machine as a first data packet, wherein the virtual IP address and the IP address of the host machine are in the same network segment;
[0148] The modification module 1002 is used to modify the destination IP address of the first data packet to the actual IP address of the target virtual machine based on the conversion rule in the flow table, so as to obtain a modified first data packet; the conversion rule represents the conversion rule between the actual IP address of the target virtual machine and the virtual IP address;
[0149] The forwarding module 1003 is configured to forward the modified first data packet to the target virtual machine based on the modified destination IP address of the first data packet.
[0150] In one embodiment, the forwarding module 1003 is specifically configured to:
[0151] Based on the modified destination IP address of the first data packet, determine the port number of the target virtual machine accessing the OVS bridge from the flow table, where the flow table includes a flow table entry representing the correspondence between the port number of the target virtual machine accessing the OVS bridge and the actual IP address of the target virtual machine;
[0152] The modified first data packet is forwarded to the target virtual machine through the port corresponding to the port number.
[0153] In one embodiment:
[0154] The receiving module 1001 is further used to receive a second data packet sent by the target virtual machine, the destination IP address of the second data packet is the IP address of the host machine, the destination MAC address of the second data packet is the MAC address of the host machine, and the source address of the second data packet is the actual IP address of the target virtual machine;
[0155] The modification module 1002 is further used to modify the source address of the second data packet to the virtual IP address of the target virtual machine based on the conversion rule in the flow table to obtain a modified second data packet;
[0156] The sending module 1003 is further configured to forward the modified second data packet to the host machine.
[0157] Based on the same inventive concept, the embodiment of the present application also provides a communication device for implementing the communication method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more communication device embodiments provided below can refer to the limitations on the communication method in the embodiment of the communication method applied to the host machine above, and will not be repeated here.
[0158] In an exemplary embodiment, Fig.11 As shown, a communication device is provided, the device includes an address determination module 1101, a generation module 1102 and a sending module 1103, wherein:
[0159] An address determination module 1101 is used to determine the MAC address of the target virtual machine based on the virtual IP address of the target virtual machine from the Arp correspondence of the namespace, where the virtual IP address and the IP address of the host machine are in the same network segment, and the Arp correspondence includes a correspondence between the virtual address of the target virtual machine and the MAC address of the target virtual machine;
[0160] A generating module 1102 is used to generate a first data packet, wherein the destination IP address of the first data packet is the virtual IP address of the target virtual machine, the destination MAC address of the first data packet is the MAC address of the target virtual machine, the source address of the first data packet is the IP address of the host machine, and the virtual IP address of the target virtual machine and the IP address of the host machine are in the same network segment;
[0161] The sending module 1103 is used to send the first data packet to the OVS bridge, so that the OVS bridge modifies the destination IP address of the first data packet to the actual IP address of the target virtual machine based on the conversion rule in the flow table, and forwards the modified first data packet to the target virtual machine based on the modified destination IP address of the first data packet, wherein the conversion rule represents the conversion rule between the actual IP address and the virtual IP address of the target virtual machine.
[0162] Each module in the above communication device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0163] In an exemplary embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as shown in FIG. Fig.12 As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a communication method applied to an OVS bridge and a communication method applied to a host machine are implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.
[0164] Those skilled in the art will understand that Fig.12 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0165] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0166] For the received data packet, a data packet whose source address is the IP address of the host machine and whose destination IP address is the virtual IP address of the target virtual machine is determined as the first data packet, wherein the virtual IP address and the IP address of the host machine are in the same network segment;
[0167] Based on the conversion rule in the flow table, the destination IP address of the first data packet is modified to the actual IP address of the target virtual machine to obtain a modified first data packet; the conversion rule represents the conversion rule between the actual IP address of the target virtual machine and the virtual IP address;
[0168] Based on the modified destination IP address of the first data packet, the modified first data packet is forwarded to the target virtual machine.
[0169] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0170] Based on the modified destination IP address of the first data packet, determine the port number of the target virtual machine accessing the OVS bridge from the flow table, where the flow table includes a flow table entry representing the correspondence between the port number of the target virtual machine accessing the OVS bridge and the actual IP address of the target virtual machine;
[0171] The modified first data packet is forwarded to the target virtual machine through the port corresponding to the port number.
[0172] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0173] For the received data packet, a data packet whose source address is the actual IP address of the target virtual machine and whose destination address is the IP address of the host machine is determined as a second data packet;
[0174] Modify the source address of the second data packet to the virtual IP address of the target virtual machine based on the conversion rule in the flow table to obtain a modified second data packet;
[0175] The modified second data packet is forwarded to the host machine.
[0176] In one embodiment, the processor may further implement the following steps when executing the computer program:
[0177] Determine the MAC address of the target virtual machine based on the virtual IP address of the target virtual machine from the Arp correspondence of the namespace, wherein the Arp correspondence includes a correspondence between the virtual IP address of the target virtual machine and the MAC address of the target virtual machine;
[0178] Generate a first data packet, the destination IP address of the first data packet is the virtual IP address of the target virtual machine, the destination MAC address of the first data packet is the MAC address of the target virtual machine, the source address of the first data packet is the IP address of the host machine, and the virtual IP address of the target virtual machine and the IP address of the host machine are in the same network segment;
[0179] The first data packet is sent to the OVS bridge so that the OVS bridge modifies the destination IP address of the first data packet to the actual IP address of the target virtual machine based on the conversion rule in the flow table, and forwards the modified first data packet to the target virtual machine based on the modified destination IP address of the first data packet, wherein the conversion rule represents the conversion rule between the actual IP address and the virtual IP address of the target virtual machine.
[0180] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0181] For the received data packet, a data packet whose source address is the IP address of the host machine and whose destination IP address is the virtual IP address of the target virtual machine is determined as the first data packet, wherein the virtual IP address and the IP address of the host machine are in the same network segment;
[0182] Based on the conversion rule in the flow table, the destination IP address of the first data packet is modified to the actual IP address of the target virtual machine to obtain a modified first data packet; the conversion rule represents the conversion rule between the actual IP address of the target virtual machine and the virtual IP address;
[0183] Based on the modified destination IP address of the first data packet, the modified first data packet is forwarded to the target virtual machine.
[0184] In one embodiment, when the computer program is executed by a processor, the following steps may also be implemented:
[0185] Based on the modified destination IP address of the first data packet, determine the port number of the target virtual machine accessing the OVS bridge from the flow table, where the flow table includes a flow table entry representing the correspondence between the port number of the target virtual machine accessing the OVS bridge and the actual IP address of the target virtual machine;
[0186] The modified first data packet is forwarded to the target virtual machine through the port corresponding to the port number.
[0187] In one embodiment, when the computer program is executed by a processor, the following steps may also be implemented:
[0188] For the received data packet, a data packet whose source address is the actual IP address of the target virtual machine and whose destination address is the IP address of the host machine is determined as a second data packet;
[0189] Modify the source address of the second data packet to the virtual IP address of the target virtual machine based on the conversion rule in the flow table to obtain a modified second data packet;
[0190] The modified second data packet is forwarded to the host machine.
[0191] In one embodiment, when the computer program is executed by a processor, the following steps may also be implemented:
[0192] Determine the MAC address of the target virtual machine based on the virtual IP address of the target virtual machine from the Arp correspondence of the namespace, wherein the Arp correspondence includes a correspondence between the virtual IP address of the target virtual machine and the MAC address of the target virtual machine;
[0193] Generate a first data packet, the destination IP address of the first data packet is the virtual IP address of the target virtual machine, the destination MAC address of the first data packet is the MAC address of the target virtual machine, the source address of the first data packet is the IP address of the host machine, and the virtual IP address of the target virtual machine and the IP address of the host machine are in the same network segment;
[0194] The first data packet is sent to the OVS bridge so that the OVS bridge modifies the destination IP address of the first data packet to the actual IP address of the target virtual machine based on the conversion rule in the flow table, and forwards the modified first data packet to the target virtual machine based on the modified destination IP address of the first data packet, wherein the conversion rule represents the conversion rule between the actual IP address and the virtual IP address of the target virtual machine.
[0195] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0196] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0197] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0198] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A communication method, characterized in that: Applied to an OVS bridge, the method comprises: For the received data packet, a data packet whose source address is the IP address of the host machine and whose destination IP address is the virtual IP address of the target virtual machine is determined as the first data packet, wherein the virtual IP address and the IP address of the host machine are in the same network segment; Based on the conversion rule in the flow table, the destination IP address of the first data packet is modified to the actual IP address of the target virtual machine to obtain a modified first data packet; the conversion rule represents the conversion rule between the actual IP address of the target virtual machine and the virtual IP address; Based on the modified destination IP address of the first data packet, the modified first data packet is forwarded to the target virtual machine.
2. The method according to claim 1, characterized in that The forwarding the modified first data packet to the target virtual machine based on the modified destination IP address of the first data packet includes: Based on the modified destination IP address of the first data packet, determine the port number of the target virtual machine accessing the OVS bridge from the flow table, wherein the flow table includes a flow table entry representing the correspondence between the port number of the target virtual machine accessing the OVS bridge and the actual IP address of the target virtual machine; The modified first data packet is forwarded to the target virtual machine through the port corresponding to the port number.
3. The communication method according to claim 1, characterized in that: The method further comprises: For the received data packet, determining the data packet whose source address is the actual IP address of the target virtual machine and whose destination address is the IP address of the host machine as the second data packet; Modify the source address of the second data packet to the virtual IP address of the target virtual machine based on the conversion rule in the flow table to obtain a modified second data packet; The modified second data packet is forwarded to the host machine.
4. A communication method, characterized in that: Applied to a host machine, the method includes: Determine the MAC address of the target virtual machine based on the virtual IP address of the target virtual machine from the Arp correspondence of the namespace, wherein the Arp correspondence includes a correspondence between the virtual IP address of the target virtual machine and the MAC address of the target virtual machine; Generate a first data packet, wherein the destination IP address of the first data packet is the virtual IP address of the target virtual machine, the destination MAC address of the first data packet is the MAC address of the target virtual machine, the source address of the first data packet is the IP address of the host machine, and the virtual IP address of the target virtual machine and the IP address of the host machine are in the same network segment; The first data packet is sent to the OVS bridge, so that the OVS bridge modifies the destination IP address of the first data packet to the actual IP address of the target virtual machine based on the conversion rule in the flow table, and forwards the modified first data packet to the target virtual machine based on the modified destination IP address of the first data packet, wherein the conversion rule represents the conversion rule between the actual IP address and the virtual IP address of the target virtual machine.
5. A communication system, characterized in that: The communication system includes an OVS bridge, a target virtual machine and a host machine, wherein: The target virtual machine communicates with the OVS bridge through a port; The Arp correspondence of the host machine's namespace includes the correspondence between the MAC address and the virtual IP address of the target virtual machine; The OVS bridge is used to modify the destination IP address of the received first data packet to the actual IP address of the target virtual machine based on the conversion rule in the flow table, obtain a modified first data packet, and forward the modified first data packet to the target virtual machine based on the destination IP address of the modified first data packet, wherein the conversion rule represents the conversion rule between the actual IP address and the virtual IP address of the target virtual machine; the source address of the first data packet is the IP address of the host machine, the destination IP address is the actual IP address of the target virtual machine, and the virtual IP address is in the same network segment as the IP address of the host machine; The OVS bridge is also used to modify the source address of the received second data packet to the virtual IP address of the target virtual machine based on the conversion rules in the flow table, obtain a modified second data packet, and forward the modified second data packet to the host machine, where the source address of the second data packet is the actual IP address of the target virtual machine, the destination IP address is the IP address of the host machine, and the destination MAC address is the MAC address of the host machine.
6. The system according to claim 5, characterized in that The system also includes a controller, wherein The controller is used to: Obtain the actual IP address of the MAC address of the target virtual machine from the hypervisor, and determine the port number corresponding to the target virtual machine in the OVS bridge; Determine the IP address and MAC address of the host machine with which the target virtual machine needs to communicate; Allocate a virtual IP address for the target virtual machine, where the virtual IP address is in the same network segment as the IP address of the host machine; In the Arp relationship table of the network namespace of the host machine, write the correspondence between the MAC address and the virtual IP address of the target virtual machine; Generate a flow table entry based on the port number of the target virtual machine accessing the OVS bridge and the actual IP address of the MAC address of the target virtual machine, and update the flow table of the OVS bridge based on the flow table entry; A conversion rule is generated based on the virtual IP address and the actual IP address of the target virtual machine, and the flow table of the OVS bridge is updated using the conversion rule.
7. The system according to claim 6, characterized in that When the controller allocates a virtual IP address to the target virtual machine, it is specifically used to: Determine the available address resources in the network segment where the IP address of the host machine is located; An available IP address is randomly allocated to the target virtual machine from the available address resources as a virtual IP address.
8. A communication device, characterized in that: The device comprises a receiving module, a modifying module and a forwarding module, wherein: A receiving module, configured to determine, for a received data packet, a data packet whose source address is the IP address of the host machine and whose destination IP address is the virtual IP address of the target virtual machine as a first data packet, wherein the virtual IP address and the IP address of the host machine are in the same network segment; A modification module, configured to modify the destination IP address of the first data packet to the actual IP address of the target virtual machine based on a conversion rule in the flow table, so as to obtain a modified first data packet; the conversion rule represents a conversion rule between the actual IP address of the target virtual machine and the virtual IP address; The sending module is used to forward the modified first data packet to the target virtual machine based on the destination IP address of the modified first data packet.
9. A communication device, characterized in that: The device comprises an address determination module, a generation module and a sending module, wherein: An address determination module, configured to determine a MAC address of a target virtual machine based on a virtual IP address of the target virtual machine from an Arp correspondence in a namespace, wherein the virtual IP address and the IP address of the host machine are in the same network segment, and the Arp correspondence includes a correspondence between the virtual address of the target virtual machine and the MAC address of the target virtual machine; A generating module, configured to generate a first data packet, wherein the destination IP address of the first data packet is the virtual IP address of the target virtual machine, the destination MAC address of the first data packet is the MAC address of the target virtual machine, the source address of the first data packet is the IP address of the host machine, and the virtual IP address of the target virtual machine and the IP address of the host machine are in the same network segment; A sending module is used to send the first data packet to the OVS bridge, so that the OVS bridge modifies the destination IP address of the first data packet to the actual IP address of the target virtual machine based on the conversion rule in the flow table, and forwards the modified first data packet to the target virtual machine based on the modified destination IP address of the first data packet, wherein the conversion rule represents the conversion rule between the actual IP address and the virtual IP address of the target virtual machine.
10. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 3 or 4 are implemented.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 3 or 4 are implemented.