Communication method and apparatus between virtual devices, electronic device, and storage medium
By intercepting UDP messages at the transport layer and querying virtual network device relationships, UDP messages between virtual devices are directly sent, which solves the problem of low communication efficiency between virtual devices and achieves more efficient communication and business processing.
Patent Information
- Application Number
- PCT/CN2024/076237
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-02-27
- Filing Date
- 2024-02-06
- Publication Date
- 2024-09-06
AI Technical Summary
In UDP communication between virtual devices, existing technology has redundant processing, resulting in low communication efficiency and reduced business efficiency.
Intercept the UDP message at the transport layer, query the preset association relationship by obtaining the transmission information, determine the virtual network device, and directly send the UDP message through the virtual network device at the transport layer to avoid seven-layer encapsulation of the OSI model.
It improves communication efficiency and business efficiency between virtual devices and reduces redundant steps in the communication process.
Smart Images

Figure CN2024076237_06092024_PF_FP
Abstract
Description
Communication method, device, electronic device and storage medium between virtual devices
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application claims priority to Chinese patent application CN 202310216508.4, entitled “A communication method, device, electronic device and storage medium between virtual devices”, filed on February 27, 2023, the entire contents of which are incorporated herein by reference. Technical Field
[0003] The present application relates to the field of information technology, and in particular to a communication method, apparatus, electronic device, and storage medium between virtual devices. Background Art
[0004] Currently, with the general trend of cloudification of personal computers and servers, more and more businesses are running on servers in the form of microservices, and each microservice exists in the form of a virtual device (such as a container or a virtual machine). When UDP (User Datagram Protocol) is used to communicate between virtual devices on the same node, the UDP message will be encapsulated in the application layer, presentation layer, session layer, transport layer, network layer, data link layer and physical layer in the OSI (Open System Interconnection) model in sequence, and the encapsulated UDP message will be transmitted. For communication between virtual devices on the same node, there is redundancy in processing UDP messages in the above manner, resulting in low communication efficiency, thereby reducing business efficiency.
[0005] Summary of the Invention
[0006] In view of this, in order to solve the above technical problems or part of the technical problems, the present application provides a communication method, apparatus, electronic device and storage medium between virtual devices.
[0007] An embodiment of the present invention provides a communication method between virtual devices, including: in the process of sending a UDP message from a first virtual device to a second virtual device, when the UDP message reaches the transport layer in the OSI model, obtaining transmission information corresponding to the UDP message, wherein the first virtual device and the second virtual device are set on the same electronic device; based on the transmission information, performing a query operation on a preset association relationship to obtain a query result; based on the transmission information, determining a first virtual network device corresponding to the first virtual device and a second virtual network device corresponding to the second virtual device; and based on the query result, sending the UDP message to the second virtual device through the first virtual network device and the second virtual network device at the transport layer.
[0008] The present application also provides a communication device between virtual devices, including: an acquisition module, used to obtain transmission information corresponding to the UDP message when the UDP message reaches the transport layer in the OSI model during the process of sending a UDP message from a first virtual device to a second virtual device, and the first virtual device and the second virtual device are set on the same electronic device; a query module, used to perform a query operation on a preset association relationship based on the transmission information to obtain a query result; a determination module, used to determine the first virtual network device corresponding to the first virtual device and the second virtual network device corresponding to the second virtual device based on the transmission information; a sending module, used to send the UDP message to the second virtual device through the first virtual network device and the second virtual network device at the transport layer according to the query result.
[0009] The present application also provides an electronic device, comprising: a processor and a memory, wherein the processor is configured to execute a computer program stored in the memory to implement the communication method between virtual devices according to the present application.
[0010] The present application also provides a storage medium storing one or more computer programs. When the one or more computer programs are executed by one or more processors, the one or more processors implement the communication method between virtual devices according to the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] FIG1 is a schematic diagram of a communication structure between two virtual devices provided by this application;
[0012] FIG2 is a flow chart of a communication method between virtual devices provided by the present application;
[0013] FIG3 is another schematic diagram of a flow chart of a method for communication between virtual devices provided by the present application;
[0014] FIG4 is a schematic diagram of the structure of a communication device between virtual devices provided by the present application;
[0015] FIG5 is a schematic diagram of the structure of the electronic device provided in this application. DETAILED DESCRIPTION
[0016] To make the objectives, technical solutions, and advantages of this application more clear, the technical solutions in this application will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0017] To facilitate understanding of the present application, the present application will be further explained below with reference to specific embodiments in conjunction with the accompanying drawings. The embodiments do not constitute a limitation to the present application.
[0018] Referring to Figure 1, Figure 1 is a schematic diagram of the communication structure between two virtual devices provided by this application. The communication structure between the two virtual devices provided by this application includes: a first virtual device 101, a first virtual network device 102, a second virtual device 103 and a second virtual network device 104. The first virtual device 101 and the second virtual device 103 are on the same node, and the node is an electronic device, which can be a server. When the first virtual device 101 and the second virtual device 103 communicate via UDP, the first virtual device 101 encapsulates the UDP message and sends the encapsulated UDP message to the second virtual network device 104 via the first virtual network device 102, and the second virtual network device 104 sends the encapsulated UDP message to the second virtual device 102.
[0019] Referring to Figure 2, which is a flow chart of a method for communicating between virtual devices provided by the present application, the method for communicating between virtual devices provided by the present application comprises the following steps S101 to S104.
[0020] In step S101, during the process of sending a UDP message from the first virtual device to the second virtual device, when the UDP message reaches the transport layer in the OSI model, transmission information corresponding to the UDP message is obtained.
[0021] Specifically, the method is applied to the communication structure between the two virtual devices as described above, the execution subject is an electronic device, and the first virtual device and the second virtual device are both arranged in the electronic device. The first virtual device and the second virtual device communicate with each other via UDP. In order to improve the communication efficiency between the first virtual device and the second virtual device, in the process of sending a UDP message from the first virtual device to the second virtual device, when the UDP message is successively encapsulated through the application layer, presentation layer and session layer in the OSI model and reaches the transport layer, the UDP message is truncated at the transport layer, and the transmission information carried by the UDP message is judged, so that the first virtual device can send the UDP message to the second virtual device at the transport layer.
[0022] More specifically, the first virtual device and the second virtual device are both created by the electronic device. After the electronic device creates the first virtual device and the second virtual device, to enable communication between the virtual devices, a first virtual network device is created for the first virtual device and a second virtual network device is created for the second virtual device. Information about the first virtual network device corresponding to the created first virtual device and the second virtual network device corresponding to the created second virtual device is recorded. When the status or configuration information of the first virtual network device is updated, the correspondence between the first virtual device and the first virtual network device is synchronously updated. Similarly, when the status or configuration information of the second virtual network device is updated, the correspondence between the second virtual device and the second virtual network device is synchronously updated.
[0023] In step S102, a query operation is performed on the preset association relationship according to the transmission information to obtain a query result.
[0024] Specifically, the transmission information includes a first identifier of a first virtual network device corresponding to the first virtual device and a second identifier of a second virtual network device corresponding to the second virtual device. The first virtual device and the second virtual device need to communicate through their respective corresponding virtual network devices. The transmission information carried in the UDP message can be used to determine the first virtual network device corresponding to the first virtual device and the second virtual network device corresponding to the second virtual device. After encapsulating the UDP message, the first virtual device can send the UDP message to the second virtual device via the first virtual network device and the second virtual network device. More specifically, to enable the first virtual device to transmit the UDP message to the second virtual device at the transport layer, a correspondence is pre-set between the first virtual network device corresponding to the first virtual device and the second virtual network device corresponding to the second virtual device. After obtaining the transmission information, the correspondence is queried to determine whether the transmission information is stored in the correspondence, and the UDP message is transmitted based on the query result. The correspondence is a pre-configured relationship between virtual network devices that support UDP message transmission at the transport layer.
[0025] In step S103, a first virtual network device corresponding to the first virtual device and a second virtual network device corresponding to the second virtual device are determined according to the transmission information.
[0026] Specifically, the electronic device pre-stores the correspondence between the identifier and the virtual device. In order to accurately transmit the UDP message to the second virtual device, the first virtual device determines the first virtual network device corresponding to the first identifier and the second virtual network device corresponding to the second identifier through the correspondence between the identifier and the virtual device.
[0027] In step S104, according to the query result, the UDP message is sent to the second virtual device through the first virtual network device and the second virtual network device at the transport layer.
[0028] Specifically, after obtaining the query results, the first virtual network device corresponding to the first virtual device, and the second virtual network device corresponding to the second virtual device, the first virtual device can send the UDP message to the second virtual device through the first virtual network device and the second virtual network device at the transport layer based on the query results.
[0029] According to the communication method between virtual devices provided in the present application, during the UDP message transmission process between two virtual devices, the UDP message is truncated after reaching the transport layer, so that one virtual device can transmit the UDP message to another virtual device at the transport layer. There is no need to encapsulate the UDP message through the seven layers of the OSI model, thereby improving communication efficiency and business efficiency.
[0030] Referring to Figure 3, which is another flowchart of the communication method between virtual devices provided by the present application, the communication method between virtual devices provided by the present application includes the following steps S201 to S208.
[0031] In step S201, during the process of sending a UDP message from the first virtual device to the second virtual device, when the UDP message reaches the transport layer in the OSI model, transmission information corresponding to the UDP message is obtained.
[0032] Step S201 is consistent with step S101 and is not described in detail in this embodiment. For details, please refer to the above description of step S101.
[0033] In step S202, a query operation is performed on the preset association relationship according to the transmission information to obtain a query result.
[0034] Specifically, the transmission information includes a first identifier of a first virtual network device corresponding to the first virtual device and a second identifier of a second virtual network device corresponding to the second virtual device. A plurality of correspondences between two identifiers are stored in the preset association relationship. After the transmission information is acquired, when the correspondence between the transmission information is stored in the preset association relationship (i.e., the query result is the first query result), the condition for the UDP message to be transmitted at the transport layer is met; and when the correspondence between the transmission information is not stored in the preset association relationship (i.e., the query result is the second query result), the condition for the UDP message to be transmitted at the transport layer is not met.
[0035] More specifically, step S202 includes: performing a query operation on the preset association relationship based on the first identifier; obtaining a first query result when the second identifier corresponding to the first identifier is stored in the preset association relationship; obtaining a second query result when the second identifier corresponding to the first identifier is not stored in the preset association relationship.
[0036] In step S203 , a first virtual network device corresponding to the first virtual device and a second virtual network device corresponding to the second virtual device are determined according to the transmission information.
[0037] Step S203 is consistent with step S103 and is not described in detail in this embodiment. For details, please refer to the above description of step S103. It should be noted that regardless of whether the query result obtained is the first query result or the second query result, step S203 must be executed to determine the communication bridge between the first virtual device and the second virtual device (i.e., the first virtual network device and the second virtual network device) so that the UDP message is sent to the second virtual device via the first virtual network device and the second virtual network device.
[0038] In step S204, when it is determined according to the query result that the UDP message is sent to the second virtual network device at the transport layer, a shallow copy process is performed on the UDP message to obtain a first target UDP message.
[0039] Specifically, when determining, based on the query result, that the UDP message is to be sent to the second virtual network device at the transport layer, the query result obtained can be understood as being the first query result. When the query result is the first query result, the UDP message can be sent to the second virtual device at the transport layer through the first virtual network device and the second virtual network device. To further improve the communication efficiency between the first virtual device and the second virtual device, during UDP message transmission, a shallow copy of the UDP message is performed to send the obtained first target UDP message to the second virtual device.
[0040] More specifically, when it is determined according to the query result that the UDP message is not sent to the second virtual device at the transport layer (that is, the query result obtained is the second query result), the UDP message is processed in sequence through the transport layer, network layer, link layer and physical layer in the OSI model to obtain a second target UDP message, and the second target UDP message is sent to the second virtual device through the first virtual network device and the second virtual network device.
[0041] Processing the UDP message in sequence through the transport layer, network layer, link layer and physical layer in the OSI model can be understood as encapsulating the UDP message according to the seven layers of OSI. After the encapsulation is completed, the encapsulated UDP message (i.e., the second target UDP message) can be sent to the second virtual device to realize the communication between the first virtual device and the second virtual device. It should also be noted that in order to facilitate the subsequent improvement of communication between virtual devices, when the query result is the second query result, the corresponding relationship between the first identifier and the second identifier can be used to update the preset association relationship, that is, the corresponding relationship between the first identifier and the second identifier is stored in the preset association relationship, thereby realizing the update of the preset association relationship.
[0042] In step S205, after obtaining the first target UDP message, the first target UDP message is encapsulated to obtain an encapsulation frame.
[0043] In step S206, after the encapsulated frame is obtained, an empty data packet is sent to the physical layer in the OSI model through the network layer and the link layer in the OSI model in sequence.
[0044] For step S205 and step S206, specifically, when the query result is the first query result, if the first target UDP message is directly sent to the second virtual network device at the transport layer, a communication error may occur during the communication between the first virtual device and the second virtual device. In order to avoid errors during the communication process, after obtaining the first target UDP message, the first target UDP message is encapsulated. After the network layer obtains that the first target UDP message has been encapsulated at the transport layer, it can be sent to the link layer as an empty data packet, and the link layer sends the empty data packet to the physical layer. In this way, the simulated sending of the UDP message can be realized. When the first target UDP message is encapsulated, the encapsulation header is the relevant information of the second virtual network device, and the data end is the first target UDP message.
[0045] In step S207, the encapsulated frame is decapsulated to obtain a first target UDP packet.
[0046] In step S208, the first target UDP packet is sent to the second virtual device through the first virtual network device and the second virtual network device at the transport layer.
[0047] Regarding step S207 and step S208, specifically, since the encapsulated frame is formed by the relevant information of the second virtual network device and the first target UDP message, the encapsulated frame is decapsulated to obtain the relevant information of the receiving end (i.e., the second virtual network device) and the data to be transmitted at the transport layer (i.e., the first target UDP message). After determining the second virtual network device and the first target UDP message, the first target UDP message can be sent to the second virtual device through the first virtual network device and the second virtual network device.
[0048] According to the communication method between virtual devices provided in the present application, after the first virtual device sends the UDP message to the second virtual device at the transport layer (that is, after the first virtual device sends the first target UDP message to the second virtual device at the transport layer), it also includes the following steps: determining the first state corresponding to the first virtual network device and the second state corresponding to the second virtual network device; when the first state is a preset state, releasing the corresponding relationship related to the first identifier from the preset association relationship; and / or when the second state is the preset state, releasing the corresponding relationship related to the second identifier from the preset association relationship.
[0049] The preset states include a released state and a deactivated state. When the first state is the preset state, it indicates that the first virtual network device corresponding to the first identifier is no longer in use. Similarly, when the second state is the preset state, it indicates that the second virtual network device corresponding to the second identifier is no longer in use. When the first virtual network device and / or the second virtual network device are no longer in use, the corresponding relationship associated with their corresponding identifiers must be released from the preset association relationship to reduce the query process when performing subsequent queries on the preset association relationship.
[0050] According to the communication method between virtual devices provided in the present application, during the UDP message transmission process between two virtual devices, the UDP message is truncated after reaching the transport layer, so that one virtual device can transmit the UDP message to another virtual device at the transport layer. There is no need to encapsulate the UDP message through the seven layers of the OSI model, thereby improving communication efficiency and business efficiency.
[0051] Referring to Figure 4, Figure 4 is a structural diagram of the communication device between virtual devices provided by the present application. The communication device between virtual devices provided by the present application includes: an acquisition module 10, a query module 20, a determination module 30 and a sending module 40. The acquisition module 10 is used to obtain the transmission information corresponding to the UDP message when the UDP message reaches the transport layer in the OSI model during the process of sending a UDP message from the first virtual device to the second virtual device. The first virtual device and the second virtual device are set on the same electronic device; the query module 20 is used to perform a query operation on the preset association relationship according to the transmission information to obtain a query result; the determination module 30 is used to determine the first virtual network device corresponding to the first virtual device and the second virtual network device corresponding to the second virtual device according to the transmission information; the sending module 40 is used to send the UDP message to the second virtual device through the first virtual network device and the second virtual network device at the transport layer according to the query result.
[0052] Optionally, the sending module 40 is also used to: when it is determined based on the query result that the UDP message is to be sent to the second virtual network device at the transport layer, perform shallow copy processing on the UDP message to obtain a first target UDP message; and send the first target UDP message to the second virtual device through the first virtual network device and the second virtual network device at the transport layer.
[0053] Optionally, the sending module 40 is also used to: after obtaining the first target UDP message, encapsulate the first target UDP message to obtain an encapsulated frame; after obtaining the encapsulated frame, send an empty data packet to the physical layer in the OSI model through the network layer and link layer in the OSI model in sequence; decapsulate the encapsulated frame to obtain the first target UDP message; and send the first target UDP message to the second virtual device through the first virtual network device and the second virtual network device at the transport layer.
[0054] Optionally, the transmission information includes a first identifier of a first virtual network device corresponding to the first virtual device and a second identifier of a second virtual network device corresponding to the second virtual device, and the preset association relationship stores a plurality of corresponding relationships between the two identifiers.
[0055] Optionally, the query module 20 is further configured to: perform a query operation on a preset association relationship according to the first identifier; and obtain a first query result when a second identifier corresponding to the first identifier is stored in the preset association relationship.
[0056] Optionally, the sending module 40 is further configured to: when the query result is the first query result, send the UDP message to the second virtual device through the first virtual network device and the second virtual network device at the transport layer.
[0057] Optionally, the determination module 30 is further configured to: after the first virtual device sends the UDP message to the second virtual device at the transport layer, determine a first state corresponding to the first virtual network device and a second state corresponding to the second virtual network device.
[0058] The communication device between virtual devices provided in the present application also includes: a release module, which is used to: when the first state is a preset state, release the corresponding relationship related to the first identifier from the preset association relationship; and / or when the second state is the preset state, release the corresponding relationship related to the second identifier from the preset association relationship.
[0059] Optionally, the query module 20 is further configured to obtain a second query result when the second identifier corresponding to the first identifier is not stored in the preset association relationship.
[0060] Optionally, the sending module 40 is also used to: when the query result is the second query result, process the UDP message in sequence through the transport layer, network layer, link layer and physical layer in the OSI model to obtain a second target UDP message; and send the second target UDP message to the second virtual device through the first virtual network device and the second virtual network device.
[0061] The communication apparatus between virtual devices provided in the present application further includes: an updating module, configured to update the preset association relationship using the corresponding relationship between the first identifier and the second identifier when the query result is the second query result.
[0062] According to the communication device between virtual devices provided in the present application, during the UDP message transmission process between two virtual devices, the UDP message is truncated after reaching the transport layer, so that one virtual device can transmit the UDP message to another virtual device at the transport layer. There is no need to encapsulate the UDP message through the seven layers of the OSI model, thereby improving communication efficiency and business efficiency.
[0063] Figure 5 is a schematic diagram of the structure of an electronic device provided in this application. The electronic device 400 shown in Figure 5 includes: at least one processor 401, memory 402, at least one network interface 404, and other user interfaces 403. The various components in the electronic device 400 are coupled via a bus system 405. It will be understood that the bus system 405 is used to achieve connection and communication between these components. In addition to including a data bus, the bus system 405 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, in Figure 5, all various buses are labeled as bus system 405.
[0064] The user interface 403 may include a display, a keyboard, or a pointing device (eg, a mouse, a trackball, a touchpad, or a touch screen).
[0065] It is understood that the memory 402 in the present application can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. Volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct RAM bus random access memory (DRRAM). The memory 402 described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0066] In some embodiments, the memory 402 stores the following elements, executable units or data structures, or a subset thereof, or an extended set thereof: an operating system 4021 and application programs 4022 .
[0067] Operating system 4021 includes various system programs, such as a framework layer, a core library layer, and a driver layer, for implementing various basic services and processing hardware-based tasks. Application programs 4022 include various application programs, such as a media player and a browser, for implementing various application services. Programs implementing the method of the present application may be included in application programs 4022.
[0068] In the present application, by calling the program or instructions stored in the memory 402, specifically, the program or instructions stored in the application 4022, the processor 401 is used to execute the method steps provided by each method embodiment, for example, including: in the process of sending a UDP message from the first virtual device to the second virtual device, when the UDP message reaches the transport layer in the OSI model, obtaining the transmission information corresponding to the UDP message, and the first virtual device and the second virtual device are set on the same electronic device; according to the transmission information, performing a query operation on the preset association relationship to obtain a query result; according to the transmission information, determining the first virtual network device corresponding to the first virtual device and the second virtual network device corresponding to the second virtual device; according to the query result, sending the UDP message to the second virtual device through the first virtual network device and the second virtual network device at the transport layer.
[0069] The methods disclosed in this application can be applied to or implemented by processor 401. Processor 401 may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the method can be performed by hardware integrated logic circuits or software instructions in processor 401. Processor 401 can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The methods, steps, and logic block diagrams disclosed in this application can be implemented or executed. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in this application can be directly implemented and executed by a hardware decoding processor, or by a combination of hardware and software units in the decoding processor. The software units can be located in storage media well-known in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. The storage medium is located in the memory 402 , and the processor 401 reads the information in the memory 402 and completes the steps of the above method in combination with its hardware.
[0070] It is understood that the embodiments described herein may be implemented using hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit may be implemented in one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described herein, or a combination thereof.
[0071] For software implementation, the technology described herein can be implemented by a unit that performs the functions described herein. The software code can be stored in a memory and executed by a processor. The memory can be implemented in the processor or outside the processor.
[0072] The electronic device provided in this embodiment may be an electronic device as shown in FIG5 , which can execute all steps of the communication method between virtual devices as shown in FIG2 to FIG3 , thereby realizing the technical effect of the communication method between virtual devices as shown in FIG2 to FIG3 . For details, please refer to the relevant descriptions of FIG2 to FIG3 . For the sake of brevity, they are not elaborated here.
[0073] This application also provides a storage medium (computer-readable storage medium). The storage medium here stores one or more programs. The storage medium may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as read-only memory, flash memory, hard disk, or solid-state drive; the memory may also include a combination of the above types of memory.
[0074] When one or more programs in the storage medium are executed by one or more processors, the above-mentioned communication method between virtual devices can be implemented.
[0075] The processor is used to execute a program stored in a memory to implement the following steps of a communication method between virtual devices: in the process of sending a UDP message from a first virtual device to a second virtual device, when the UDP message reaches the transport layer in the OSI model, obtaining transmission information corresponding to the UDP message, and the first virtual device and the second virtual device are set on the same electronic device; based on the transmission information, performing a query operation on a preset association relationship to obtain a query result; based on the transmission information, determining a first virtual network device corresponding to the first virtual device and a second virtual network device corresponding to the second virtual device; based on the query result, sending the UDP message to the second virtual device through the first virtual network device and the second virtual network device at the transport layer.
[0076] Professionals should also be further aware that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0077] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0078] The specific implementation methods described above further illustrate the purpose, technical solutions and beneficial effects of this application. It should be understood that the above description is only the specific implementation methods of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of this application should be included in the scope of protection of this application.
Claims
1. A communication method between virtual devices, comprising: In the process of sending a User Datagram Protocol (UDP) message from the first virtual device to the second virtual device, when the UDP message reaches the transport layer in the Open Systems Interconnection (OSI) model, acquiring transmission information corresponding to the UDP message, wherein the first virtual device and the second virtual device are arranged on the same electronic device; According to the transmission information, a query operation is performed on the preset association relationship to obtain a query result; Determine, according to the transmission information, a first virtual network device corresponding to the first virtual device and a second virtual network device corresponding to the second virtual device; According to the query result, the UDP message is sent to the second virtual device through the first virtual network device and the second virtual network device at the transport layer.
2. The method according to claim 1, wherein: According to the query result, sending the UDP message to the second virtual device through the first virtual network device and the second virtual network device at the transport layer includes: When it is determined according to the query result that the UDP message is sent to the second virtual network device at the transport layer, a shallow copy process is performed on the UDP message to obtain a first target UDP message; The first target UDP packet is sent to the second virtual device through the first virtual network device and the second virtual network device at the transport layer.
3. The method according to claim 2, further comprising: After obtaining the first target UDP message, encapsulating the first target UDP message to obtain an encapsulation frame; After obtaining the encapsulated frame, sending an empty data packet to the physical layer in the OSI model through the network layer and the link layer in the OSI model in sequence; Sending the first target UDP packet to the second virtual device through the first virtual network device and the second virtual network device at the transport layer includes: Decapsulating the encapsulated frame to obtain the first target UDP message; The first target UDP packet is sent to the second virtual device through the first virtual network device and the second virtual network device at the transport layer.
4. The method according to claim 1, wherein: The transmission information includes a first identifier of a first virtual network device corresponding to the first virtual device and a second identifier of a second virtual network device corresponding to the second virtual device, and the preset association relationship stores a plurality of corresponding relationships between the two identifiers. According to the transmission information, a query operation is performed on the preset association relationship to obtain a query result, including: According to the first identifier, performing a query operation on the preset association relationship; When the second identifier corresponding to the first identifier is stored in the preset association relationship, a first query result is obtained; According to the query result, sending the UDP message to the second virtual device through the first virtual network device and the second virtual network device at the transport layer includes: When the query result is the first query result, the UDP message is sent to the second virtual device through the first virtual network device and the second virtual network device at the transport layer.
5. The method according to claim 4, further comprising: After the first virtual device sends the UDP message to the second virtual device at the transport layer, determining a first state corresponding to the first virtual network device and a second state corresponding to the second virtual network device; When the first state is a preset state, releasing the corresponding relationship associated with the first identifier from the preset association relationship; and / or, When the second state is the preset state, the corresponding relationship associated with the second identifier is released from the preset association relationship.
6. The method according to claim 4, further comprising: When the second identifier corresponding to the first identifier is not stored in the preset association relationship, a second query result is obtained; When the query result is the second query result, the UDP message is processed sequentially through the transport layer, the network layer, the link layer and the physical layer in the OSI model to obtain a second target UDP message; The second target UDP packet is sent to the second virtual device through the first virtual network device and the second virtual network device.
7. The method according to claim 6, further comprising: When the query result is the second query result, the preset association relationship is updated using the correspondence between the first identifier and the second identifier.
8. A communication device between virtual devices, comprising: An acquisition module, configured to acquire transmission information corresponding to a User Datagram Protocol (UDP) message when the UDP message reaches a transport layer in an Open Systems Interconnection (OSI) model during a process in which the first virtual device sends a User Datagram Protocol (UDP) message to the second virtual device, wherein the first virtual device and the second virtual device are arranged on the same electronic device; A query module, used to perform a query operation on the preset association relationship according to the transmission information to obtain a query result; a determination module, configured to determine, according to the transmission information, a first virtual network device corresponding to the first virtual device and a second virtual network device corresponding to the second virtual device; A sending module is used to send the UDP message to the second virtual device through the first virtual network device and the second virtual network device at the transport layer according to the query result.
9. An electronic device, comprising: processor and memory, The processor is used to execute the computer program stored in the memory to implement the communication method between virtual devices according to any one of claims 1 to 7.
10. A storage medium having one or more computer programs stored thereon, wherein when the one or more computer programs are executed by one or more processors, the one or more processors implement the communication method between virtual devices according to any one of claims 1 to 7.
Citation Information
Patent Citations
Packet transmission method, device and system
CN108293022A
Radar data high-speed communication processing module based on virtualization framework
CN109522114A
Traffic redirection method and device, electronic equipment and storage medium
CN115695013A
Automatically selecting optimal transport protocol in a cloud computing environment
US20130191826A1
