Communication system for virtual machines, communication method and apparatus for virtual machines

CN116708555BActive Publication Date: 2026-08-18INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310832231.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-06
Publication Date
2026-08-18
Estimated Expiration
2043-07-06

AI Technical Summary

Technical Problem

[0004]本申请提供了一种针对虚拟机的通信系统、针对虚拟机的通信方法及装置,以至少解决相关技术中在处于不同子网的客户端对应的虚拟机之间进行通信时,存在通信效率低的技术问题

Benefits of technology

[0019] In this application, firstly, a first client connects to a first virtual machine to obtain a first communication message sent by the first virtual machine and sends the first communication message to a server. The first communication message is a communication message between the first virtual machine and a target virtual machine. The first client corresponding to the first virtual machine and the second client corresponding to the target virtual machine are on different subnets. Then, the server receives the first communication message, constructs a second communication message based on the first communication message, and sends the second communication message to the second client. The second communication message is a binary-formatted encapsulated message that the second client can receive. Finally, the second client connects to the target virtual machine to receive the second communication message and send the second communication message to the target virtual machine.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116708555B_ABST
    Figure CN116708555B_ABST
Patent Text Reader

Abstract

The application discloses a communication system and method for virtual machines and a device. It relates to the field of financial technology or other fields, wherein the system comprises: a first client connected with a first virtual machine, used for obtaining a first communication message sent by the first virtual machine and sending the first communication message to a server, wherein the first communication message is a communication message between the first virtual machine and a target virtual machine; the server is used for receiving the first communication message and constructing a second communication message according to the first communication message, and sending the second communication message to a second client; the second client is connected with the target virtual machine, used for receiving the second communication message and sending the second communication message to the target virtual machine. The application solves the technical problem of low communication efficiency when the virtual machines corresponding to the clients in different subnets communicate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of financial technology or other fields, and more specifically, to a communication system, communication method and apparatus for virtual machines. Background Technology

[0002] In cloud desktop systems based on the IDV (Intelligent Desktop Virtualization) architecture, since virtual machines are deployed on users' personal computers, they cannot communicate with each other if their host machines are not on the same subnet. Existing technologies typically address this issue by configuring special physical network settings to enable communication between virtual machines, such as configuring multicast routing protocols. However, configuring multicast routing protocols increases network load, leading to reduced network performance and lower communication efficiency when virtual machines on different subnets communicate.

[0003] There is currently no effective solution to the above problems. Summary of the Invention

[0004] This application provides a communication system, a communication method, and an apparatus for virtual machines, to at least solve the technical problem of low communication efficiency when communicating between virtual machines corresponding to clients in different subnets in related technologies.

[0005] According to one aspect of this application, a communication system for virtual machines is provided, comprising: a first client connected to a first virtual machine, configured to acquire a first communication message sent by the first virtual machine and send the first communication message to a server, wherein the first communication message is a communication message between the first virtual machine and a target virtual machine, and the first client corresponding to the first virtual machine and the second client corresponding to the target virtual machine are located in different subnets; the server is configured to receive the first communication message, construct a second communication message based on the first communication message, and send the second communication message to the second client, wherein the second communication message is an encapsulated message in binary format that the second client can receive; and the second client connected to the target virtual machine, configured to receive the second communication message and send the second communication message to the target virtual machine.

[0006] Furthermore, the first client also includes: a first process, configured to monitor whether the first virtual machine sends the first communication message, and to obtain the first communication message when the first virtual machine sends the first communication message.

[0007] Furthermore, the first process is also used to parse the first communication message after obtaining the first communication message, obtain first data, and send the first data to the server, wherein the first data includes at least the MAC address information of the first virtual machine and the MAC address information of the target virtual machine.

[0008] Furthermore, the first process is also used to obtain the IP address information of the first client and send the IP address information and the first data to the server.

[0009] Furthermore, the server is also used to construct the second communication message based on the IP address information of the first client and the first data.

[0010] Furthermore, the server also includes a database for storing the IP address information corresponding to each of the M clients and the gateway address information of the subnet where each client is located. Each client is a client that is active at a target time. The M clients include the first client and the second client. The target time is the time when the first client sends the first communication message to the server. M is a positive integer.

[0011] Furthermore, the server is also used to obtain the gateway address information of the subnet where each of the N third clients among the M clients is located from the database, to obtain N gateway address information, and divide the N gateway address information into L information sets, and send the second communication message to the third client corresponding to any gateway address information in each information set, wherein the N third clients are the clients other than the first client among the M clients, each information set contains the same gateway address information, each information set corresponds to a subnet, N and L are positive integers, and N is greater than or equal to L.

[0012] Furthermore, the server is also used to monitor whether the status of each client at the target time is the open state. If the status of a client is the closed state, the server deletes the IP address information and the gateway address information corresponding to that client from the database.

[0013] Further, the second client includes: a second process, configured to send the second communication message to a first tunnel terminal corresponding to the target virtual machine; the first tunnel terminal, configured to receive the second communication message and perform message parsing processing on the second communication message to obtain the first data, wherein the first tunnel terminal is also configured to detect whether the MAC address information of the target virtual machine contained in the second communication message is the same as the actual MAC address information of the target virtual machine, and if the MAC address information is the same as the actual MAC address information, send the first data to the target virtual machine.

[0014] According to another aspect of this application, a communication method for virtual machines is also provided, comprising: receiving a first communication message sent by a first client through a server, wherein the first communication message is a communication message between a first virtual machine and a target virtual machine, the first client corresponding to the first virtual machine and the second client corresponding to the target virtual machine are in different subnets, and the first communication message is sent by the first virtual machine to the first client; constructing a second communication message based on the first communication message through the server, and sending the second communication message to the second client, wherein the second client is used to send the second communication message to the target virtual machine, and the second communication message is a binary format encapsulated message that the second client can receive.

[0015] Further, the process of constructing a second communication message based on the first communication message by the server and sending the second communication message to the second client includes: obtaining gateway address information of the subnet of each of the N third clients among the M clients from the database by the server, resulting in N gateway address information, wherein the database is used to store the IP address information corresponding to each client among the M clients and the gateway address information of the subnet of each client, each client being a client that is in an open state at a target time, the M clients including the first client and the second client, the target time being the time when the first client sends the first communication message to the server, the N third clients being the clients other than the first client among the M clients, and M and N being positive integers; dividing the N gateway address information into L information sets by the server, wherein each information set contains the same gateway address information, each information set corresponding to a subnet, L being a positive integer, and L being less than or equal to N; and sending the second communication message to the third client corresponding to any gateway address information in each information set by the server.

[0016] According to another aspect of this application, a communication device for virtual machines is also provided, comprising: a first sending module, configured to receive a first communication message sent by a first client through a server, wherein the first communication message is a communication message between a first virtual machine and a target virtual machine, the first client corresponding to the first virtual machine and the second client corresponding to the target virtual machine are in different subnets, and the first communication message is sent by the first virtual machine to the first client; and a second sending module, configured to construct a second communication message based on the first communication message through the server, and send the second communication message to the second client, wherein the second client is configured to send the second communication message to the target virtual machine, and the second communication message is an encapsulated message in binary format that can be received by the second client.

[0017] According to another aspect of this application, a computer-readable storage medium is also provided, in which a computer program is stored, wherein the computer program is configured to execute the above-described communication method for a virtual machine at runtime.

[0018] According to another aspect of this application, an electronic device is also provided, the electronic device including one or more processors; a memory for storing one or more programs, which, when executed by one or more processors, cause one or more processors to implement the program for running the program, wherein the program is configured to execute the above-described communication method for virtual machines during runtime.

[0019] In this application, firstly, a first client connects to a first virtual machine to obtain a first communication message sent by the first virtual machine and sends the first communication message to a server. The first communication message is a communication message between the first virtual machine and a target virtual machine. The first client corresponding to the first virtual machine and the second client corresponding to the target virtual machine are on different subnets. Then, the server receives the first communication message, constructs a second communication message based on the first communication message, and sends the second communication message to the second client. The second communication message is a binary-formatted encapsulated message that the second client can receive. Finally, the second client connects to the target virtual machine to receive the second communication message and send the second communication message to the target virtual machine.

[0020] In the above process, by adding a server, the first client and the second client are located in different subnets. When the first virtual machine corresponding to the first client communicates with the target virtual machine corresponding to the second client, the server receives and forwards the first communication message to realize communication between the first virtual machine and the target virtual machine. No special configuration of the physical network is required, and communication between the first virtual machine and the target virtual machine can be realized without affecting the performance of the physical network. This avoids the problem of low communication efficiency caused by poor physical network performance, thereby achieving the technical effect of improving communication efficiency. In turn, it solves the technical problem of low communication efficiency when virtual machines corresponding to clients in different subnets communicate in related technologies. Attached Figure Description

[0021] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0022] Figure 1 This is a schematic diagram of an optional communication system for a virtual machine according to an embodiment of this application;

[0023] Figure 2 This is a flowchart of an optional communication method for a virtual machine according to an embodiment of this application;

[0024] Figure 3 This is a flowchart of another optional communication method for a virtual machine according to an embodiment of this application;

[0025] Figure 4 This is a flowchart of an optional server-side monitoring of client status according to an embodiment of this application;

[0026] Figure 5 This is a schematic diagram of an optional communication device for a virtual machine according to an embodiment of this application;

[0027] Figure 6 This is a schematic diagram of an optional electronic device according to an embodiment of this application. Detailed Implementation

[0028] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0029] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0030] It should be noted that the communication system, communication method and apparatus for virtual machines of this application can be used in the field of financial technology, as well as in other fields other than financial technology. The application fields of the communication system, communication method and apparatus for virtual machines of this application are not limited.

[0031] 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, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation portals are provided for users to choose to authorize or refuse.

[0032] Example 1

[0033] Figure 1 This is a schematic diagram of an optional communication system for a virtual machine according to an embodiment of this application, such as... Figure 1 As shown, the system includes: a first client 102, a server 103, and a second client 104.

[0034] The first client 102 is connected to the first virtual machine 101 and is used to obtain the first communication message sent by the first virtual machine 101 and send the first communication message to the server 103. The first communication message is a communication message between the first virtual machine 101 and the target virtual machine 105, and the first virtual machine 101 and the target virtual machine 105 are in different subnets.

[0035] Optionally, the first client and the first virtual machine are connected through the target tunnel terminal VTEP-1 (VTEP stands for Virtual Tunnel Endpoint). The system creates a VXLAN interface by obtaining the VNI (Virtual Network Interface) number, multicast IP address information, and port number corresponding to the first virtual machine of the virtual network where the first virtual machine is located, and binds the VXLAN interface to the target tunnel terminal to realize the packet data transmission between the first client and the first virtual machine.

[0036] Optionally, the first communication message is an ARP (Address Resolution Protocol) request message, which is used to request the mapping relationship between the MAC address information of the target virtual machine and the IP address information and VNI number of the first tunnel terminal corresponding to the target virtual machine. The first communication message includes at least the MAC address information of the first virtual machine and the MAC address information of the target virtual machine.

[0037] Server 103 is used to receive the first communication message, construct a second communication message based on the first communication message, and send the second communication message to the second client 104. The second communication message is a binary format encapsulated message that the second client 104 can receive.

[0038] Optionally, the server can create an IP layer header using the IP address information of the first client and the IP address information of the multicast group, create a UDP (User Datagram Protocol) layer header using the port number and VXLAN port number corresponding to the first virtual machine, create a UDP payload using the MAC address information of the first virtual machine and the MAC address information of the target virtual machine in the first communication packet, calculate the checksum, and concatenate the IP layer header, UDP layer header and UDP payload in big-endian order to obtain a second communication packet in byte array format (i.e., binary format).

[0039] The second client 104 is connected to the target virtual machine 105 and is used to receive the second communication message and send the second communication message to the target virtual machine 105.

[0040] Optionally, when the second client receives the second communication message, it can send the second communication message to the first tunnel terminal VTEP-2 corresponding to the target virtual machine through a Unix raw socket. VTEP-2 detects the second communication message and sends the second communication message to the target virtual machine if the MAC address information of the target virtual machine contained in the second communication message is the same as the actual MAC address information of the target virtual machine.

[0041] Optionally, the control plane of VTEP-2 can learn the mapping relationship between the IP address, VNI number, and MAC address of VTEP-1 through the second communication message. Optionally, after the target virtual machine receives the second communication message, the target virtual machine sends an encapsulated ARP response communication message to the first virtual machine through VTEP-2. The control plane of VTEP-1 can learn the mapping relationship between the IP address, VNI number, and MAC address of VTEP-2 through the ARP response. Subsequent communication between the first virtual machine and the target virtual machine can be conducted only through VTEP-1 and VTEP-2.

[0042] Through the above scheme, it can be understood that in the communication system for virtual machines provided in this application embodiment, firstly, a first client connects to a first virtual machine to obtain a first communication message sent by the first virtual machine and sends the first communication message to the server. The first communication message is a communication message between the first virtual machine and the target virtual machine. The first client corresponding to the first virtual machine and the second client corresponding to the target virtual machine are in different subnets. Then, the server receives the first communication message, constructs a second communication message based on the first communication message, and sends the second communication message to the second client. The second communication message is a binary format encapsulated message that the second client can receive. Finally, the second client connects to the target virtual machine to receive the second communication message and sends the second communication message to the target virtual machine.

[0043] It should be noted that, in the above process, by adding a server, the first client and the second client can be located in different subnets. When the first virtual machine corresponding to the first client communicates with the target virtual machine corresponding to the second client, the server receives and forwards the first communication message to realize communication between the first virtual machine and the target virtual machine. No special configuration of the physical network is required, and communication between the first virtual machine and the target virtual machine can be realized without affecting the performance of the physical network. This avoids the problem of low communication efficiency caused by poor physical network performance, thereby achieving the technical effect of improving communication efficiency. In turn, it solves the technical problem of low communication efficiency when virtual machines corresponding to clients in different subnets communicate in related technologies.

[0044] Optionally, in the communication system for virtual machines provided in this application embodiment, the first client further includes: a first process, used to monitor whether the first virtual machine sends a first communication message, and to obtain the first communication message when the first virtual machine sends a first communication message.

[0045] To improve communication efficiency and avoid the problem of not being able to send the first communication message to the server in a timely manner, this application runs a first process on the first client, monitors whether the first virtual machine sends the first communication message, and obtains the first communication message when the first virtual machine sends the first communication message.

[0046] Optionally, the first process can call the relevant interfaces of the C libcap library or the golang gopacket library to implement monitoring.

[0047] Optionally, in the communication system for virtual machines provided in this application embodiment, the first process is further configured to, after obtaining the first communication message, parse the first communication message to obtain first data, and send the first data to the server, wherein the first data includes at least the MAC address information of the first virtual machine and the MAC address information of the target virtual machine.

[0048] Optionally, in the communication system for virtual machines provided in this application embodiment, the first process is further used to obtain the IP address information of the first client and send the IP address information and the first data to the server.

[0049] To avoid resource waste due to excessive redundant data, this application uses a first process to parse the first communication message to obtain first data. This first data includes the MAC address information of the first virtual machine and the target virtual machine, as well as the port number of the first virtual machine.

[0050] Furthermore, the first process sends the IP address information of the first client and the first data to the server.

[0051] Optionally, in the communication system for virtual machines provided in this application embodiment, the server is further configured to construct a second communication message based on the IP address information of the first client and the first data.

[0052] To enable the server to send the first communication message to the second client, this application constructs a second communication message in binary format that the second client can receive, based on the IP address information of the first client and the first data. For example, the server can create an IP layer header using the IP address information of the first client, the multicast group IP address information, etc., create a UDP layer header using the port number corresponding to the first virtual machine, the VXLAN port number, etc., create a UDP payload using the MAC address information of the first virtual machine and the MAC address information of the target virtual machine in the first communication message, calculate the checksum, and concatenate the IP layer header, UDP layer header, and UDP payload in big-endian order to obtain a second communication message in byte array format (i.e., binary format).

[0053] Optionally, in the communication system for virtual machines provided in this application embodiment, the server further includes: a database for storing the IP address information corresponding to each of the M clients and the gateway address information of the subnet where each client is located, wherein each client is a client that is in an open state at a target time, the M clients include a first client and a second client, the target time is the time when the first client sends the first communication message to the server, and M is a positive integer.

[0054] Optionally, in the communication system for virtual machines provided in this application embodiment, the server is further configured to obtain the gateway address information of the subnet where each of the N third clients among the M clients is located from the database, obtain N gateway address information, divide the N gateway address information into L information sets, and send the second communication message to the third client corresponding to any gateway address information in each information set. Here, the N third clients are the clients other than the first client among the M clients, each information set contains the same gateway address information, each information set corresponds to a subnet, N and L are positive integers, and N is greater than or equal to L.

[0055] To avoid sending the second communication message to a client in a closed state, leading to communication failure, in this application, the server can obtain the IP address information of M clients that are in an open state at the target time, as well as the gateway address information of the subnet where each client is located, and store the above information in a database. After constructing the second communication message based on the first communication message, the server obtains the gateway address information of the subnet where each of the N third clients (excluding the first client) is located from the database, obtaining N gateway address information. Then, the server divides the N gateway address information into L information sets containing the same gateway address information, and sends the second communication message to the third client corresponding to any gateway address information in each information set. Clients with the same gateway address information are in the same subnet, that is, each information set corresponds to one subnet. For example, if the gateway address information of the subnet where each third client is located is A, B, B, C, C, C, E, F, F, F, G, G, then the L information sets are {A}, {B, B}, {C, C, C}, {E}, {F, F, F}, {G, G}. It is only necessary to send the second communication message to any third client corresponding to any gateway address information in each information set.

[0056] Optionally, after a third client corresponding to any gateway address in each information set receives the second communication message, the second communication message can be propagated among other third clients in the same subnet as that third client. Therefore, each other third client in the same subnet can receive the second communication message. Optionally, after receiving the second communication message, each other third client sends the second communication message to its VTEP. The VTEP checks whether the MAC address information of the target virtual machine contained in the second communication message is the same as the actual MAC address information of the virtual machine corresponding to the VTEP. If the MAC address information of the target virtual machine is the same as the actual MAC address information, the second communication message is sent to the target virtual machine; if the MAC address information of the target virtual machine is different from the actual MAC address information, the second communication message is discarded.

[0057] Optionally, in the communication system for virtual machines provided in this application embodiment, the server is further configured to monitor whether the status of each client is in an open state at a target time, and if the status of a client is in a closed state, delete the IP address information and gateway address information corresponding to that client from the database.

[0058] To further avoid sending the second communication message to a client in a closed state, which could lead to communication failure, the server monitors whether each client is in an open state at the target time and deletes the IP address information and gateway address information of the client in a closed state from the database.

[0059] Optionally, if the client is in an enabled state, obtain the IP address information and the gateway address information corresponding to the client and store them in the database.

[0060] Optionally, the server can periodically poll whether the client is in a closed state due to a fault. If the client is in a closed state due to a fault, the server will delete the IP address information and the gateway address information corresponding to the client from the database.

[0061] Optionally, in the communication system for virtual machines provided in this application embodiment, the second client includes: a second process, used to send a second communication message to a first tunnel terminal corresponding to the target virtual machine; and a first tunnel terminal, used to receive the second communication message and perform message parsing processing on the second communication message to obtain first data. The first tunnel terminal is also used to detect whether the MAC address information of the target virtual machine contained in the second communication message is the same as the MAC address information of the target virtual machine, and if the MAC address information is the same as the actual MAC address information, send the first data to the target virtual machine.

[0062] To enhance message security, this application uses a second process of a second client to send a second communication message to a first tunnel terminal (VTEP-2) corresponding to the target virtual machine. VTEP-2 checks whether the MAC address information of the target virtual machine contained in the second communication message matches the actual MAC address of the target virtual machine. If the MAC address matches, the second communication message is parsed to obtain first data, which is then sent to the target virtual machine. If the MAC address does not match, the second communication message is discarded.

[0063] Therefore, the system provided in this application, by adding a server, enables communication between the first virtual machine (MPM) and the target virtual machine (MMC) of the second client, even when the first client and the second client are on different subnets and the first virtual machine corresponding to the first client communicates with the target virtual machine, by receiving and forwarding the first communication message. This achieves communication between the MPM and the target virtual machine without requiring special configuration of the physical network and without affecting the performance of the physical network. This avoids the problem of low communication efficiency due to poor physical network performance, thus improving communication efficiency and solving the technical problem of low communication efficiency when communicating between virtual machines of clients on different subnets in related technologies. To avoid communication failures, this application obtains the IP address information of the M clients that are active at the target time, as well as the gateway address information of the subnet where each client is located, and stores this information in a database. It also monitors whether each client is active at the target time and deletes the IP address information and gateway address information of clients that are in a closed state from the database.

[0064] Example 2

[0065] According to an embodiment of this application, an optional communication method for virtual machines is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.

[0066] Figure 2 This is a flowchart of an optional communication method for a virtual machine according to an embodiment of this application, such as... Figure 2 As shown, the method includes the following steps:

[0067] Step S201: The server receives a first communication message sent by the first client. The first communication message is a communication message between the first virtual machine and the target virtual machine. The first client corresponding to the first virtual machine and the second client corresponding to the target virtual machine are in different subnets. The first communication message is sent from the first virtual machine to the first client.

[0068] In step S201, the first communication message is an ARP (Address Resolution Protocol) request message, which is used to request the mapping relationship between the MAC address information of the target virtual machine and the IP address information and VNI number of the first tunnel terminal corresponding to the target virtual machine. The first communication message includes at least the MAC address information of the first virtual machine and the MAC address information of the target virtual machine.

[0069] Optionally, such as Figure 3 As shown, after obtaining the first communication message, the first client is used to detect whether the first communication message is a compliant message. When the first communication message is a compliant message, the first client parses the first communication message into first data. The first data includes the MAC address information of the first virtual machine and the MAC address information of the target virtual machine, as well as the port number of the first virtual machine.

[0070] Furthermore, the first process is used to send the IP address information of the first client and the first data to the server.

[0071] Optionally, the first client and the first virtual machine are connected through a target tunnel terminal VTEP-1 (VTEP stands for Virtual Tunnel Endpoint). The system creates a VXLAN interface by obtaining the VNI number of the virtual network where the first virtual machine is located, the multicast IP address information, and the port number corresponding to the first virtual machine, and binds the VXLAN interface to the target tunnel terminal to realize the packet data transmission between the first client and the first virtual machine.

[0072] Optionally, a first process runs on the first client. This first client is also used to monitor whether the first virtual machine sends a first communication message, and to obtain the first communication message if the first virtual machine sends one. Optionally, the first process can call the relevant interfaces of the C libcap library or the Golang gopacket library to implement monitoring.

[0073] Step S202: The server constructs a second communication message based on the first communication message and sends the second communication message to the second client. The second client is used to send the second communication message to the target virtual machine. The second communication message is a binary format encapsulated message that the second client can receive.

[0074] In step S202, the server can create an IP layer header using the IP address information of the first client and the IP address information of the multicast group, create a UDP layer header using the port number and VXLAN port number corresponding to the first virtual machine, create a UDP payload using the MAC address information of the first virtual machine and the MAC address information of the target virtual machine in the first communication packet, calculate the checksum, and concatenate the IP layer header, UDP layer header and UDP payload in big-endian order to obtain a second communication packet in byte array format (i.e., binary format).

[0075] Optionally, the second client is also configured to send the second communication message to the first tunnel terminal VTEP-2 corresponding to the target virtual machine via a Unix raw socket when it receives the second communication message. VTEP-2 detects the second communication message and sends the second communication message to the target virtual machine if the MAC address information of the target virtual machine contained in the second communication message is the same as the actual MAC address information of the target virtual machine.

[0076] Optionally, the control plane of VTEP-2 can learn the mapping relationship between the IP address, VNI number, and MAC address of VTEP-1 through the second communication message. Optionally, after the target virtual machine receives the second communication message, the target virtual machine sends an encapsulated ARP response communication message to the first virtual machine through VTEP-2. The control plane of VTEP-1 can learn the mapping relationship between the IP address, VNI number, and MAC address of VTEP-2 through the ARP response. Subsequent communication between the first virtual machine and the target virtual machine can be conducted only through VTEP-1 and VTEP-2.

[0077] Based on the scheme defined in steps S201 to S202 above, it can be understood that in this embodiment of the application, the server first receives a first communication message sent by the first client, wherein the first communication message is a communication message between the first virtual machine and the target virtual machine, the first client corresponding to the first virtual machine and the second client corresponding to the target virtual machine are in different subnets, and the first communication message is sent by the first virtual machine to the first client; the server constructs a second communication message based on the first communication message and sends the second communication message to the second client, wherein the second client is used to send the second communication message to the target virtual machine, and the second communication message is a binary format encapsulated message that the second client can receive.

[0078] It should be noted that, in the above process, by adding a server, the first client and the second client can be located in different subnets. When the first virtual machine corresponding to the first client communicates with the target virtual machine corresponding to the second client, the server receives and forwards the first communication message to realize communication between the first virtual machine and the target virtual machine. No special configuration of the physical network is required, and communication between the first virtual machine and the target virtual machine can be realized without affecting the performance of the physical network. This avoids the problem of low communication efficiency caused by poor physical network performance, thereby achieving the technical effect of improving communication efficiency. In turn, it solves the technical problem of low communication efficiency when virtual machines corresponding to clients in different subnets communicate in related technologies.

[0079] Optionally, in the communication method for virtual machines provided in this application embodiment, the server constructs a second communication message based on the first communication message and sends the second communication message to the second client, including: obtaining gateway address information of the subnet where each of the N third clients among the M clients is located from the database, thus obtaining N gateway address information, wherein the database is used to store the IP address information corresponding to each client among the M clients and the gateway address information of the subnet where each client is located, each client is a client that is in the open state at the target time, the M clients include the first client and the second client, the target time is the time when the first client sends the first communication message to the server, the N third clients are the clients other than the first client among the M clients, and M and N are positive integers; the server divides the N gateway address information into L information sets, wherein each information set contains the same gateway address information, each information set corresponds to a subnet, L is a positive integer, and L is less than or equal to N; the server sends the second communication message to the third client corresponding to any gateway address information in each information set.

[0080] To avoid sending the second communication message to a client in a closed state, which could cause communication failure, such as... Figure 3As shown in this application, the server can obtain the IP address information of M clients that are active at the target time, as well as the gateway address information of the subnet where each client is located, and store the above information in the database. After constructing the second communication message based on the first communication message, the server obtains the gateway address information of the subnet where each of the N third clients (excluding the first client) is located from the database, thus obtaining N gateway address information. The server then divides the N gateway address information into L information sets containing the same gateway address information, and sends the second communication message to the third client corresponding to any gateway address information in each information set. Clients with the same gateway address information are in the same subnet, meaning each information set corresponds to one subnet. For example, if the gateway address information of the subnet where each third client is located is A, B, B, C, C, C, E, F, F, F, G, G, then the L information sets are {A}, {B, B}, {C, C, C}, {E}, {F, F, F}, {G, G}. It is only necessary to send the second communication message to any third client corresponding to any gateway address information in each information set.

[0081] Optionally, after a third client corresponding to any gateway address in each information set receives the second communication message, the second communication message can be propagated among other third clients in the same subnet as that third client. Therefore, each other third client in the same subnet can receive the second communication message. Optionally, after receiving the second communication message, each other third client is also used to send the second communication message to its VTEP. The VTEP checks whether the MAC address information of the target virtual machine contained in the second communication message is the same as the actual MAC address information of the virtual machine corresponding to the VTEP. If the MAC address information of the target virtual machine is the same as the actual MAC address information, the second communication message is sent to the target virtual machine; if the MAC address information of the target virtual machine is different from the actual MAC address information, the second communication message is discarded.

[0082] Optionally, in the communication method for virtual machines provided in this application embodiment, the second client further includes a second process, wherein the second process is used to send a second communication message to a first tunnel terminal corresponding to the target virtual machine. The first tunnel terminal is used to receive the second communication message and perform message parsing processing on the second communication message to obtain first data. The first tunnel terminal is also used to detect whether the MAC address information of the target virtual machine contained in the second communication message is the same as the MAC address information of the target virtual machine, and if the MAC address information is the same as the actual MAC address information, send the first data to the target virtual machine.

[0083] To improve the security of message data, such as Figure 3 As shown, this application sends a second communication message to a first tunnel terminal (VTEP-2) corresponding to the target virtual machine through a second process of a second client. VTEP-2 checks whether the MAC address information of the target virtual machine contained in the second communication message is the same as the actual MAC address information of the target virtual machine. If the MAC address information is the same as the actual MAC address information, the second communication message is parsed to obtain first data, and the first data is sent to the target virtual machine. If the MAC address information is different from the actual MAC address information, the second communication message is discarded.

[0084] Optionally, in the communication system for virtual machines provided in the embodiments of this application, such as Figure 4 As shown, the server also monitors whether each client is in an "on" state at the target time. If a client is in a "off" state, its corresponding IP address and gateway address are deleted from the database. If a client is in an "on" state, its corresponding IP address and gateway address are retrieved and stored in the database.

[0085] Optionally, such as Figure 4 As shown, the server can periodically poll whether the client is in a closed state due to a fault. If the client is in a closed state due to a fault, the server will delete the IP address information and the gateway address information corresponding to the client from the database.

[0086] Therefore, the method provided in this application, by adding a server, enables communication between the first virtual machine (MPM) and the target virtual machine (MMC) of the second client, even when the first client and the second client are on different subnets and the first virtual machine corresponding to the first client communicates with the target virtual machine, by receiving and forwarding the first communication message through the server. This achieves communication between the MPM and the target virtual machine without requiring special configuration of the physical network and without affecting the performance of the physical network. This avoids the problem of low communication efficiency due to poor physical network performance, thus improving communication efficiency and solving the technical problem of low communication efficiency when communicating between virtual machines of clients on different subnets in related technologies. To avoid communication failures, this application obtains the IP address information of the M clients that are active at the target time, as well as the gateway address information of the subnet where each client is located, through the server, and stores this information in a database. It also monitors whether each client is active at the target time and deletes the IP address information and gateway address information of clients that are in a closed state from the database.

[0087] Example 3

[0088] According to an embodiment of this application, an embodiment of a communication device for a virtual machine is provided, wherein, Figure 5 This is a schematic diagram of an optional communication device for a virtual machine according to an embodiment of this application, such as... Figure 5 As shown, the device includes:

[0089] The first sending module 501 is used to receive a first communication message sent by a first client through a server. The first communication message is a communication message between a first virtual machine and a target virtual machine. The first client corresponding to the first virtual machine and the second client corresponding to the target virtual machine are in different subnets. The first communication message is sent from the first virtual machine to the first client.

[0090] The second sending module 502 is used to construct a second communication message based on the first communication message through the server and send the second communication message to the second client. The second client is used to send the second communication message to the target virtual machine. The second communication message is a binary format encapsulated message that the second client can receive.

[0091] It should be noted that the first sending module 501 and the second sending module 502 mentioned above correspond to steps S201 to S202 in the above embodiment 1. The two modules and the corresponding steps implement the same examples and application scenarios, but are not limited to the content disclosed in the above embodiment 2.

[0092] Optionally, the second sending module includes: an acquisition unit, configured to acquire gateway address information of the subnet of each of the N third clients among the M clients from the database via the server, thereby obtaining N gateway address information, wherein the database is used to store the IP address information corresponding to each client among the M clients and the gateway address information of the subnet of each client, each client being a client that is in an open state at a target time, the M clients including a first client and a second client, the target time being the time when the first client sends the first communication message to the server, and the N third clients being the clients other than the first client among the M clients, where M and N are positive integers; a partitioning unit, configured to partition the N gateway address information into L information sets via the server, wherein each information set contains the same gateway address information, each information set corresponds to a subnet, L is a positive integer, and L is less than or equal to N; and a sending unit, configured to send the second communication message to the third client corresponding to any gateway address information in each information set via the server.

[0093] Example 4

[0094] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, in which a computer program is stored, wherein the computer program is configured to execute the above-described communication method for a virtual machine at runtime.

[0095] Example 5

[0096] According to another aspect of the embodiments of this application, an electronic device is also provided, wherein, Figure 6 This is a schematic diagram of an optional electronic device according to an embodiment of this application, such as... Figure 6 As shown, the electronic device includes one or more processors; and a memory for storing one or more programs, which, when executed by one or more processors, cause the one or more processors to run the programs, wherein the programs are configured to execute the aforementioned communication method for virtual machines at runtime.

[0097] like Figure 6 As shown, this application embodiment provides an electronic device, which includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it performs the following steps:

[0098] The server receives a first communication message sent by a first client. The first communication message is a communication message between a first virtual machine and a target virtual machine. The first client corresponding to the first virtual machine and the second client corresponding to the target virtual machine are on different subnets. The first communication message is sent from the first virtual machine to the first client. The server constructs a second communication message based on the first communication message and sends the second communication message to the second client. The second client is used to send the second communication message to the target virtual machine. The second communication message is a binary format encapsulated message that the second client can receive.

[0099] Optionally, the processor, when executing the program, further implements the following steps: The server retrieves the gateway address information of the subnet where each of the N third clients among the M clients resides from the database, resulting in N gateway address information. The database stores the IP address information corresponding to each of the M clients and the gateway address information of the subnet where each client resides. Each client is a client that is active at the target time. The M clients include a first client and a second client. The target time is the time when the first client sends the first communication message to the server. The N third clients are the clients other than the first client among the M clients, where M and N are positive integers. The server divides the N gateway address information into L information sets, where each information set contains the same gateway address information. Each information set corresponds to a subnet, where L is a positive integer and L is less than or equal to N. The server sends a second communication message to the third client corresponding to any gateway address information in each information set.

[0100] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0101] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0102] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some interfaces; indirect couplings or communication connections between units or modules may be electrical or other forms.

[0103] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0104] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0105] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.

[0106] The above are merely preferred embodiments of this application. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A communication system for virtual machines, characterized in that, include: A first client is connected to a first virtual machine and is used to obtain a first communication message sent by the first virtual machine and send the first communication message to the server. The first communication message is a communication message between the first virtual machine and the target virtual machine. The first client corresponding to the first virtual machine and the second client corresponding to the target virtual machine are in different subnets. The server is configured to receive the first communication message, construct a second communication message based on the first communication message, and send the second communication message to the second client, wherein the second communication message is a binary format encapsulated message that the second client can receive; The second client is connected to the target virtual machine and is used to receive the second communication message and send the second communication message to the target virtual machine; The server further includes a database for storing IP address information corresponding to each of the M clients and gateway address information of the subnet where each client is located. The server is also used to obtain gateway address information of the subnet where each of the N third clients among the M clients is located from the database, to obtain N gateway address information, and divide the N gateway address information into L information sets. The server then sends the second communication message to the third client corresponding to any gateway address information in each information set. The N third clients are clients other than the first client among the M clients. Each information set contains the same gateway address information, and each information set corresponds to a subnet. N and L are positive integers, and N is greater than or equal to L. The second client further includes: a second process, used to send the second communication message to a first tunnel terminal corresponding to the target virtual machine; the first tunnel terminal, used to learn the mapping relationship between the IP address, VNI number, and MAC address of the target tunnel terminal connecting the first client and the first virtual machine.

2. The system according to claim 1, characterized in that, The first client also includes: The first process is used to monitor whether the first virtual machine sends the first communication message, and to obtain the first communication message if the first virtual machine sends the first communication message.

3. The system according to claim 2, characterized in that, The first process is further configured to, after acquiring the first communication message, parse the first communication message to obtain first data, and send the first data to the server, wherein the first data includes at least the MAC address information of the first virtual machine and the MAC address information of the target virtual machine.

4. The system according to claim 3, characterized in that, The first process is also used to obtain the IP address information of the first client and send the IP address information and the first data to the server.

5. The system according to claim 4, characterized in that, The server is also used to construct the second communication message based on the IP address information of the first client and the first data.

6. The system according to claim 1, characterized in that, Each client is a client that is active at the target time. The M clients include the first client and the second client. The target time is the time when the first client sends the first communication message to the server. M is a positive integer.

7. The system according to claim 6, characterized in that, The server is also used to monitor whether the status of each client at the target time is the open state. If the status of a client is the closed state, the server deletes the IP address information and the gateway address information corresponding to the client from the database.

8. The system according to claim 3, characterized in that, The first tunnel terminal is configured to receive the second communication message and perform message parsing processing on the second communication message to obtain the first data. The first tunnel terminal is also configured to detect whether the MAC address information of the target virtual machine contained in the second communication message is the same as the actual MAC address information of the target virtual machine, and if the MAC address information is the same as the actual MAC address information, send the first data to the target virtual machine.

9. A communication method for virtual machines, characterized in that, include: The server receives a first communication message sent by a first client. The first communication message is a communication message between a first virtual machine and a target virtual machine. The first client corresponding to the first virtual machine and the second client corresponding to the target virtual machine are in different subnets. The first communication message is sent from the first virtual machine to the first client. The server constructs a second communication message based on the first communication message and sends the second communication message to the second client. The second client is used to send the second communication message to the target virtual machine. The second communication message is a binary format encapsulated message that the second client can receive. The process of constructing a second communication message based on the first communication message by the server and sending the second communication message to the second client includes: obtaining gateway address information of the subnet of each of the N third clients among the M clients from the database, resulting in N gateway address information, wherein the database is used to store the IP address information corresponding to each client among the M clients and the gateway address information of the subnet of each client, each client being a client that is in an open state at a target time, the M clients including the first client and the second client, the target time being the time when the first client sends the first communication message to the server, and the N third clients being clients other than the first client among the M clients, where M and N are positive integers; dividing the N gateway address information into L information sets by the server, wherein each information set contains the same gateway address information, each information set corresponding to a subnet, L being a positive integer, and L being less than or equal to N; and sending the second communication message to the third client corresponding to any gateway address information in each information set by the server. The second client further includes: a first tunnel terminal, used to learn the mapping relationship between the IP address, VNI number, and MAC address of the target tunnel terminal connecting the first client and the first virtual machine.

10. A communication device for virtual machines, characterized in that, include: The first sending module is used to receive a first communication message sent by a first client through a server. The first communication message is a communication message between a first virtual machine and a target virtual machine. The first client corresponding to the first virtual machine and the second client corresponding to the target virtual machine are in different subnets. The first communication message is sent from the first virtual machine to the first client. The second sending module is used to construct a second communication message based on the first communication message through the server and send the second communication message to the second client. The second client is used to send the second communication message to the target virtual machine. The second communication message is a binary format encapsulated message that the second client can receive. The second sending module further includes: an acquisition unit, used to acquire gateway address information of the subnet of each of the N third clients among the M clients from the database via the server, to obtain N gateway address information, wherein the database is used to store the IP address information corresponding to each client among the M clients and the gateway address information of the subnet of each client, each client is a client that is in the open state at the target time, the M clients include a first client and a second client, the target time is the time when the first client sends the first communication message to the server, and the N third clients are the clients other than the first client among the M clients, where M and N are positive integers; and a partitioning unit, used to partition the N gateway address information into L information sets via the server, wherein each information set contains the same gateway address information, each information set corresponds to a subnet, L is a positive integer, and L is less than or equal to N; The second client further includes: a second process, used to send the second communication message to a first tunnel terminal corresponding to the target virtual machine; the first tunnel terminal, used to learn the mapping relationship between the IP address, VNI number, and MAC address of the target tunnel terminal connecting the first client and the first virtual machine.

11. A computer-readable storage medium, characterized in that, A computer-readable storage medium stores a computer program, wherein the computer program is configured to execute the communication method for a virtual machine as described in claim 9 at runtime.

12. An electronic device, characterized in that, It includes one or more processors and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the communication method for a virtual machine as described in claim 9.

Citation Information

Patent Citations

  • Method and system for implementing sub-network intercommunication

    CN106850379A