Data packet processing method and device applied to virtual machine, equipment and storage medium
By rationally segmenting data packets between the virtual machine and the host, the problem of low communication efficiency of the virtual machine is solved, stability and compatibility are improved, and network transmission performance is optimized.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUANGZHOU SHOUYUN INTELLIGENCE NETWORK INFORMATION TECHNOLOGY CO LTD
- Filing Date
- 2025-03-31
- Publication Date
- 2026-05-01
AI Technical Summary
Communication between virtual machines and other hosts is inefficient, especially when TCP segmentation and offloading of TSO are enabled. This can lead to fragmentation and reassembly issues caused by excessively large data packets, affecting network transmission performance.
By obtaining the target packet size of the TCP link between the target virtual machine and the target host, and based on the MTU and MSS of OVS and DPDK, the data packets are reasonably segmented to ensure that the packet size adapts to the network environment and avoids fragmentation and reassembly caused by excessively large data packets.
It improves the stability and reliability of data transmission between virtual machines and the host, enhances system compatibility, optimizes data packet segmentation and transmission, and improves network transmission performance.
Smart Images

Figure CN120335933B_ABST
Abstract
Description
Data packet processing methods, apparatus, devices, and storage media applied to virtual machines Technical Field
[0001] This disclosure relates to the field of computer technology, and in particular to the fields of virtual machines, cloud computing, and other related technologies. Background Technology
[0002] With the widespread application of networks in various fields, a virtual machine (VM) is a computer system that is simulated by software and has complete hardware system functions. It runs on a physical computer (host machine) and can install operating systems and applications just like a real computer, providing users with a flexible, secure, and efficient computing environment.
[0003] However, communication failures may occur during the communication process between virtual machines and other hosts. Therefore, how to improve the communication efficiency between virtual machines and other hosts is a problem we are currently facing. Summary of the Invention
[0004] This disclosure provides a data packet processing method, apparatus, device, and storage medium for use in virtual machines to solve or alleviate one or more technical problems in the prior art.
[0005] In a first aspect, this disclosure provides a data packet processing method applied to a virtual machine, comprising:
[0006] For a data packet to be transmitted between a target virtual machine and a target host, if the data packet needs to be transmitted through at least one TCP link between the target virtual machine and the target host, and TCP Segment Offload (TSO) is enabled, the target packet size corresponding to the at least one TCP link is obtained; the target packet size is determined based on a first packet length and a second packet length allowed by the at least one TCP link; the first packet length is determined based on the virtual machine switch (OVS) between the target virtual machine and the target host; both the first packet length and the second packet length are greater than or equal to the target packet size;
[0007] The data packets to be transmitted are segmented by the OVS based on the target packet size and then transmitted.
[0008] Secondly, this disclosure provides a packet processing apparatus for use in a virtual machine, comprising:
[0009] The acquisition module is used to acquire, for example, the target packet size corresponding to at least one TCP link between a target virtual machine and a target host, provided that the data packet to be transmitted needs to be transmitted through at least one TCP link between the target virtual machine and the target host, and TCP Segment Offload (TSO) is enabled. The target packet size is determined based on a first packet length and a second packet length allowed by the at least one TCP link. The first packet length is determined based on the virtual machine switch (OVS) between the target virtual machine and the target host. Both the first packet length and the second packet length are greater than or equal to the target packet size.
[0010] The processing module is used to segment the data packet to be transmitted based on the target packet size using the OVS and then transmit the data.
[0011] Thirdly, an electronic device is provided, comprising:
[0012] At least one processor; and
[0013] The memory is communicatively connected to the at least one processor; wherein,
[0014] The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform any of the methods described in the present disclosure.
[0015] Fourthly, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are used to cause the computer to perform any of the methods according to embodiments of the present disclosure.
[0016] Fifthly, a computer program product is provided, including a computer program that, when executed by a processor, implements any of the methods according to embodiments of the present disclosure.
[0017] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0018] In the accompanying drawings, unless otherwise specified, the same reference numerals throughout the various drawings denote the same or similar parts or elements. These drawings are not necessarily drawn to scale. It should be understood that these drawings depict only some embodiments provided according to this disclosure and should not be construed as limiting the scope of this disclosure.
[0019] Figure 1 is a schematic diagram of a data packet processing method applied to a virtual machine according to a first embodiment of the present disclosure;
[0020] Figure 2 is a flowchart illustrating a data packet processing method applied to a virtual machine according to a second embodiment of the present disclosure;
[0021] Figure 3 is a schematic diagram of a TCP link according to a third embodiment of the present disclosure;
[0022] Figure 4 is another schematic flowchart of a data packet processing method applied to a virtual machine according to a fourth embodiment of the present disclosure;
[0023] Figure 5 is a schematic diagram of a data packet processing apparatus applied to a virtual machine according to a fifth embodiment of the present disclosure;
[0024] Figure 6 is a block diagram of an electronic device for implementing the packet processing method applied to a virtual machine according to an embodiment of the present disclosure. Detailed Implementation
[0025] The present disclosure will now be described in further detail with reference to the accompanying drawings. The same reference numerals in the drawings denote elements that have the same or similar functions. Although various aspects of embodiments are shown in the drawings, they are not necessarily drawn to scale unless specifically indicated otherwise.
[0026] Furthermore, to better illustrate this disclosure, numerous specific details are set forth in the following detailed description. Those skilled in the art will understand that this disclosure can be practiced without certain specific details. In some instances, methods, means, components, and circuits well known to those skilled in the art have not been described in detail in order to highlight the main points of this disclosure.
[0027] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this disclosure, "multiple" means two or more, unless otherwise explicitly specified.
[0028] This disclosure presents a data packet processing method applied to a virtual machine. For ease of understanding, some terms used in this disclosure are explained, including:
[0029] Virtual Machine (VM): A computing environment created through software simulation, allowing a single physical computer to run multiple independent operating systems and applications. VMs can provide isolated computing resources on a single hardware platform, simulating multiple independent computer systems, thereby improving hardware resource utilization and flexibility.
[0030] Host machine: The physical computer or server that runs virtualization software (i.e., the aforementioned virtual machine).
[0031] Host: The machine that communicates with the virtual machine via TCP (Transmission Control Protocol) network. It may be a virtual machine or any physical machine on the public network.
[0032] OVS (OpenvSwitch): A high-quality, multi-layer virtual switch. Widely used in virtualization platforms, it connects virtual network interface cards (NICs) to virtual machines (VMs) or containers, enabling communication between virtual networks and interaction between virtual and physical networks.
[0033] DPDK (Data Plane Development Kit) is a set of development platforms and interfaces for rapidly processing data packets.
[0034] OVS+DPDK: This is a network deployment solution for virtualized environments. The OVS program, deployed on the host machine, uses DPDK to send and receive packets from various ports. OVS creates a virtual bridge to connect different network ports. This virtual bridge is the core component of the entire virtual network, responsible for traffic forwarding and switching. Each virtual machine's virtual network interface card (such as virtio-net) connects to the OVS virtual bridge via the vhost-user port. The vhost-user port is a special port type in OVS that allows virtual machine network traffic to bypass kernel space and be processed directly by user-space OVS-DPDK.
[0035] NIC (Network Interface Card): Connected to the virtual bridge in OVS via the DPDK driver. Based on this, virtual machine traffic can be forwarded to the physical NIC through the virtual bridge and then sent to the external network.
[0036] OVS-DPDK Port: This is the other port of the virtual bridge, connected to the physical network card. This port serves as the interface between the virtual network and the physical network, responsible for forwarding virtual machine traffic to the physical network or forwarding external traffic to the virtual machine.
[0037] TCP Segmentation Offload (TSO) is a network optimization technique that allows the physical network interface card (NIC) to automatically segment large TCP packets into appropriate segments instead of the operating system (CPU). TCP is the link used for transmission between the virtual machine and the host.
[0038] MTU (Maximum Transmission Unit): In TCP communication, MTU defines the maximum amount of data a single data packet can carry. If the data packet sent by the sender exceeds the MTU of any device in the path, the data packet will be fragmented.
[0039] MSS (Maximum Segment Size): Represents the maximum length of data that can be carried in a TCP segment.
[0040] Virtio is an I / O (Input / Output) paravirtualization solution, a suite of general-purpose I / O device virtualization programs. Virtio includes front-end drivers and back-end drivers. Currently, in virtualization environments, vhost-user is the most common implementation of the Virtio network back-end. This protocol allows QEMU (Quick EMUlator) to offload network packet processing from Virtio devices to any DPDK application (such as OVS-DPDK), using this efficient user-space back-end by creating a vhost-user port on OVS-DPDK.
[0041] In this embodiment of the disclosure, the framework diagram of the data packet processing method applied to a virtual machine is shown in Figure 1, including a virtual machine 11, a host 12, a host machine 13, an OVS-DPDK 14, and a NIC 15. At least one virtual machine 11 runs on the host machine 13. For each virtual machine 11, it sends a data packet to be transmitted through a virtual network interface card (vNIC, such as virtio-net). The data packet to be transmitted enters the receive queue of the OVS-DPDK 14 through the vhost-user port. The OVS-DPDK 14 sends the data packet to be transmitted to the host 12 through the NIC 15.
[0042] The data packet processing method for virtual machines proposed in this embodiment of the disclosure, as shown in Figure 2, can be implemented as follows:
[0043] S201, for the data packet to be transmitted between the target virtual machine and the target host, if the data packet to be transmitted needs to be transmitted through at least one TCP link between the target virtual machine and the target host and TSO is enabled, obtain the target packet size corresponding to at least one TCP link; the target packet size is determined based on the first packet length and the second packet length allowed by at least one TCP link; the first packet length is determined based on OVS between the target virtual machine and the target host; the first packet length and the second packet length are both greater than or equal to the target packet size.
[0044] During implementation, the lengths of the first package and the second package are compared. If the length of the first package is less than the length of the second package, the length of the first package is determined as the target package cutting size; if the length of the first package is greater than or equal to the length of the second package, the length of the second package is determined as the target package cutting size.
[0045] In another embodiment, if the length of the first package is determined to be less than the length of the second package, the target package size may also be less than the length of the first package; if the length of the first package is determined to be greater than or equal to the length of the second package, the target package size may also be less than the length of the second package.
[0046] S202, data packets to be transmitted are segmented by OVS based on the target packet size and then transmitted.
[0047] During implementation, after determining the target segmentation size, OVS compiles the data based on the target segmentation size, and then segments the data packets to be transmitted based on the compiled OVS.
[0048] During implementation, when the target virtual machine sends a data packet to the target host, after establishing a TCP link through a three-way handshake, the target virtual machine enters the OVS-DPDK's receive queue through the vhost-user port. If the data packet size is too large, OVS-DPDK segments the data packet based on the target packet size. OVS-DPDK then sends the segmented data packet to the target host through the NIC.
[0049] In implementation, when the target host sends a data packet to the target virtual machine, the virtual machine and the target host establish a TCP link through a three-way handshake. The data packet is then transmitted via the NIC and subsequently enters the OVS-DPDK receive queue through the OVS-DPDKPort. If the data packet size is too large, OVS-DPDK segments the data packet based on the target packet size corresponding to the TCP link. OVS-DPDK then sends the segmented data packet to the target virtual machine.
[0050] In this embodiment, the target packet size required for final packet segmentation is determined by comprehensively considering the first packet length allowed by OVS and the second packet length allowed by the TCP link. The target packet size determined in this way is more reasonable. A reasonable packet size avoids fragmentation and reassembly problems caused by excessively large data packets, enhancing the stability and reliability of data transmission and improving system compatibility. This method can flexibly adapt to the TCP link between the target virtual machine and the target host. Furthermore, OVS segments data packets according to this size, effectively optimizing data packet segmentation and transmission, further improving transmission efficiency, ensuring the normal operation of the TSO function, and thereby improving the system's network data transmission performance.
[0051] In some embodiments, the length of the first packet is determined based on the MTU of the target port; the target port is used to connect the physical network interface card and the virtual bridge in the OVS.
[0052] The target port is the OVSDPDK Port. In the OVS-DPDK environment, the MTU of the DPDK port can usually be set to a preset number of bytes based on the actual situation.
[0053] In addition, the MTU setting should be adjusted according to the specific network environment and requirements to ensure network performance and compatibility.
[0054] When the destination port is used to connect the physical network interface card (NIC) and the virtual bridge in OVS, the MTU of the destination port refers to the maximum data packet size that the physical NIC can transmit in network communication, measured in bytes.
[0055] In this embodiment, the first packet length is determined based on the MTU of the target port, ensuring that the segmented data packets do not exceed the maximum data packet size that DPDK can support. This reduces data packet fragmentation and reassembly operations caused by MTU mismatch, reduces computational resource consumption and transmission latency, and guarantees TCP connections for any data packet size requirement. It can adaptively adjust the size of the segmented packets to adapt to TCP connections with any data packet size requirement.
[0056] In some embodiments, the second packet length is determined based on the maximum packet size that the bottleneck node in the at least one TCP link can transmit.
[0057] During implementation, multiple TCP links can be established between the same target virtual machine and the target device for data transmission. The transmission nodes included in each TCP link may be different, such as different routers and switches. The maximum packet size allowed to be transmitted by each node may also differ, so the MSS of each TCP link may also differ.
[0058] For each TCP link, the MSS of the target virtual machine, the MSS of the target device, and the MSS of the intermediate devices are compared through a three-way handshake of the TCP connection channel. The smallest MSS is determined as the MSS that the bottleneck node in the TCP link can transmit. The MTU that the bottleneck node in the TCP link can transmit can be determined based on equation (1), and its MTU is determined as the maximum packet size:
[0059] MTU = MSS + IP header length + TCP header length (1)
[0060] MTU is the maximum packet size that the bottleneck node in a TCP link can transmit, MSS is the maximum segment length that the bottleneck node in a TCP link can transmit, IP (Internet Protocol) header length is the length of the IP packet header, and TCP header length is the length of the TCP segment header.
[0061] For example, as shown in Figure 3, the TCP link from the target virtual machine to the target host passes through router 1 and router 2. The MSS of the target virtual machine is A, the MSS of the target device is B, the MSS (MTU1 - IP header length - TCP header length) of router 1 is C, and the MSS (MTU2 - IP header length - TCP header length) of router 2 is D, where B > A > C > D. In this case, a three-way handshake is required based on the TCP connection channel between the target virtual machine and the target device to determine the minimum MSS as D. Then, combined with the IP header length and TCP header length, the maximum packet size that the bottleneck node in the TCP link can transmit is determined.
[0062] In addition, the MSS of the target port can be obtained based on the MTU of the target port, and the MSS of the target port can be determined as the first packet length. In this case, the MSS that the bottleneck node in the TCP link can transmit can be determined as the second packet length. The first packet length and the second packet length are compared, and the smaller of the two is determined as the target packet size.
[0063] In this embodiment of the disclosure, the second packet length is determined based on the maximum packet size in the TCP link, thereby achieving end-to-end path MTU adaptive TCP link requirements and realizing high-performance network transmission based on TSO.
[0064] In some embodiments, the at least one TCP link shares the same target packet size; or, each TCP link in the at least one TCP link uses its own corresponding target packet size.
[0065] In some embodiments, multiple TCP links between the target virtual machine and the target host share the same target packet size. Specifically, this can be implemented as follows: for each TCP link, the target packet size corresponding to the TCP link is determined based on the second packet length of the TCP link and the first packet length of the target port; the smallest target packet size is selected from all TCP links between the target virtual machine and the target host as the final target packet size used by each TCP link.
[0066] Specifically, for each TCP link, the MTU corresponding to the second packet length of each TCP link between the target virtual machine and the target host can be determined; based on the comparison between the MTU corresponding to each TCP link and the MTU of the target port, the minimum value between the two is determined as the target packet size of the TCP link.
[0067] For example, the target virtual machine and the target host include TCP link 1, TCP link 2, and TCP link 3. The MTU of TCP link 1 is A, the MTU of TCP link 2 is B, and the MTU of TCP link 3 is C, where A < B < C, and all are smaller than the MTU of the target port. In this case, the target packet size is A, meaning that TCP link 1, TCP link 2, and TCP link 3 share the same target packet size.
[0068] In this embodiment of the disclosure, sharing the same target packet size across multiple TCP links helps ensure stable data packet transmission across these multiple TCP links. Network devices can schedule and forward data packets more efficiently, reducing the probability of transmission failure due to excessively large data packets.
[0069] In another embodiment, to improve the flexibility of the target packet size for TCP links and improve network resource utilization, it can also be implemented as follows: when at least one TCP link shares the same target packet size, monitor the changes in the TCP link between the target virtual machine and the target; and dynamically update the target packet size in accordance with the dynamic changes of the TCP link.
[0070] During implementation, the number of TCP links can be monitored. If the number of TCP links between two hosts changes, a reasonable target packet size can be determined based on the changed number of TCP links.
[0071] In this embodiment of the disclosure, by dynamically monitoring the changes in the TCP link between the target virtual machine and the target, and then dynamically adjusting the packet size, it can be ensured that data transmission always adapts to the current network conditions, thereby maintaining high transmission efficiency and performance.
[0072] In some embodiments, each TCP link in at least one TCP link adopts its own corresponding target packet size. Specifically, for each TCP link, based on the second packet length of the TCP link and the first packet length of the target port, the smaller of the two packet lengths is selected to determine that the target packet size corresponding to the TCP link is not greater than the smallest packet length.
[0073] In this embodiment of the disclosure, a suitable target packet size is set for each link according to the specific conditions of the link, which can optimize the performance of the link in a targeted manner and improve the transmission efficiency.
[0074] In some embodiments, in order to make the target packet size adaptable to the network environment as much as possible, when each TCP link adopts its own corresponding target packet size, for any TCP link among the at least one TCP link, the target packet size corresponding to any TCP link is determined based on the following method, as shown in Figure 4, including:
[0075] S401 establishes any TCP link through a three-way TCP handshake negotiation between the target virtual machine and the target host, and obtains the MSS of any TCP link.
[0076] The acquisition of the MSS of any TCP link has been described above, and this embodiment will not be repeated here.
[0077] S402, based on the MTU used in DPDK in MSS and OVS, determines the packet size applicable to any TCP link as the target packet size corresponding to any TCP link.
[0078] The MSS is converted to MTU based on equation (1), and then compared with the MTU used in the DPDK of OVS. If the MTU in TCP is determined to be greater than the MTU used in the DPDK of OVS, the MTU used in the DPDK of OVS is determined as the target packet size corresponding to the TCP link. If the MTU in TCP is determined not to be greater than the MTU used in the DPDK of OVS, the MTU in TCP is determined as the target packet size corresponding to the TCP link.
[0079] In another embodiment, it can also be implemented as follows: convert the MSS corresponding to the TCP link into MTU; then compare it with the MTU used in DPDK in OVS, and determine the smaller of the two as the intermediate packet size, and the target packet size can be smaller than the intermediate packet size.
[0080] Furthermore, the MTU used in the DPDK of OVS can be converted to MSS, and then compared with the MSS in TCP. If the MSS in TCP is determined to be greater than the MSS used in the DPDK of OVS, the MSS used in the DPDK of OVS is determined as the target packet size corresponding to the TCP link. If the MSS in TCP is determined not to be greater than the MSS used in the DPDK of OVS, the MSS in TCP is determined as the target packet size corresponding to the TCP link.
[0081] In another embodiment, it can also be implemented as follows: convert the MTU corresponding to the TCP link to MSS; then compare it with the MSS used in DPDK in OVS, and determine the smaller of the two as the intermediate packet size. The target packet size can be smaller than the intermediate packet size.
[0082] S403 records the relationship between any TCP link and the target packet size.
[0083] The TCP link identifier and its corresponding target packet size can be recorded in the association table as key-value pairs to express the relationship between the two.
[0084] During implementation, for each TCP link, when OVS receives a data packet to be transmitted, it obtains the length of the first packet and the length of the second packet in real time, and selects the smaller of the first packet length and the second packet length as the target packet size.
[0085] Furthermore, in another embodiment, since the aforementioned association between TCP links and target packet sizes is stored, it can be implemented as follows: when OVS receives a data packet to be transmitted, it matches it in the association table based on the TCP link identifier carried in the data packet. If the association table matches the target packet size corresponding to the TCP link identifier, OVS divides the data packet to be transmitted into multiple slices for transmission based on the target packet size.
[0086] Furthermore, the association table facilitates network management and maintenance. Additionally, when network performance issues or transmission errors occur, the relationship between link and packet size can be viewed to quickly pinpoint the problem.
[0087] In this embodiment, the network conditions of each TCP link may differ. By obtaining the MSS of each link during the three-way TCP handshake, the maximum packet length that the link can support can be accurately determined. Combined with the MTU in OVS-DPDK, it can be further ensured that the determined packet size meets both the TSO and TCP link requirements, and adapts to the transmission capabilities of the underlying network interface, thereby avoiding packet fragmentation and reassembly, and improving data transmission efficiency. Simultaneously, setting an appropriate target packet size based on the actual network conditions of each link allows for better utilization of link bandwidth.
[0088] In related technologies, without adopting the solution disclosed herein, when the target virtual machine and the target host have TSO features enabled, the TCP communication process includes: determining the MSS size through a three-way TCP handshake; the data packet to be transmitted enters the OVS-DPDK receive queue through the vhost-user port; if the data packet size is too large, OVS calculates the MSS based on the MTU of the OVS-DPDK port, determines this MSS as the target packet segmentation size, and segments the data packet to be transmitted. OVS-DPDK then sends the segmented data packet to the target host through the NIC. The methods described in related technologies may result in data packets that are too large to be transmitted over the TCP link.
[0089] As can be seen from the above transmission process, the root cause of low network transmission bandwidth is the unreasonable packet segmentation operation of OVS. Therefore, the packet processing method for virtual machines proposed in this embodiment combines the MSS of the TCP link with the Maximum Transmission Unit (MTU) used in the Data Plane Development Kit (DPDK) of OVS to obtain a reasonable target packet size, thereby improving network transmission efficiency.
[0090] Based on the same technical concept, this disclosure also proposes a packet processing device 500 for virtual machines, as shown in Figure 5, including:
[0091] The acquisition module 501 is configured to, for a data packet to be transmitted between a target virtual machine and a target host, acquire the target packet size corresponding to at least one TCP link when the data packet to be transmitted needs to be transmitted through at least one TCP link between the target virtual machine and the target host, and TCP Segment Offload (TSO) is enabled; the target packet size is determined based on a first packet length and a second packet length allowed by the at least one TCP link; the first packet length is determined based on the virtual machine switch (OVS) between the target virtual machine and the target host; both the first packet length and the second packet length are greater than or equal to the target packet size;
[0092] The processing module 502 is used to perform data transmission after the data packet to be transmitted is segmented by the OVS based on the target packet size.
[0093] In some embodiments, the length of the first packet is determined based on the maximum transmission unit (MTU) of the target port; the target port is used to connect the physical network interface card (NIC) and the virtual bridge in the OVS.
[0094] In some embodiments, the second packet length is determined based on the maximum packet size that the bottleneck node in the at least one TCP link can transmit.
[0095] In some embodiments, the at least one TCP link shares the same target packet size; or...
[0096] Each TCP link in the at least one TCP link adopts its own corresponding target packet size.
[0097] In some embodiments, a size determination module is further included, for:
[0098] Given that each TCP link uses its own target packet size, the target packet size for any TCP link among the at least one TCP link is determined based on the following method:
[0099] Any TCP link is established through a three-way TCP handshake negotiation between the target virtual machine and the target host, and the maximum message length (MSS) of any TCP link is obtained.
[0100] Based on the maximum transmission unit (MTU) used in the MSS and the data plane development kit (DPDK) in the OVS, the packet size applicable to any TCP link is determined as the target packet size corresponding to any TCP link;
[0101] Record the correlation between any TCP link and the target packet size.
[0102] In some embodiments, an update module is also included, for:
[0103] When at least one TCP link shares the same target packet size, monitor changes in the TCP link between the target virtual machine and the target.
[0104] The target packet size is dynamically updated in response to the dynamic changes in the TCP link.
[0105] The specific functions and examples of each module and submodule of the apparatus in this disclosure can be found in the relevant descriptions of the corresponding steps in the above method embodiments, and will not be repeated here.
[0106] The acquisition, storage, and application of user personal information involved in the technical solution disclosed herein comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0107] Figure 6 is a structural block diagram of an electronic device according to an embodiment of the present disclosure. As shown in Figure 6, the electronic device includes a memory 610 and a processor 620. The memory 610 stores a computer program that can run on the processor 620. The number of memories 610 and processors 620 can be one or more. The memory 610 can store one or more computer programs, which, when executed by the electronic device, cause the electronic device to perform the methods provided in the above-described method embodiments. The electronic device may further include a communication interface 630 for communicating with external devices and performing data exchange and transmission.
[0108] If the memory 610, processor 620, and communication interface 630 are implemented independently, they can be interconnected via a bus to communicate with each other. This bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. This bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used in Figure 6, but this does not indicate that there is only one bus or one type of bus.
[0109] Optionally, in a specific implementation, if the memory 610, processor 620, and communication interface 630 are integrated on a single chip, then the memory 610, processor 620, and communication interface 630 can communicate with each other through an internal interface.
[0110] It should be understood that the aforementioned processor can be a Central Processing Unit (CPU), or other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field-Programmable Gate Arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. General-purpose processors can be microprocessors or any conventional processor. It is worth noting that the processor can be a processor supporting Advanced Reduced Instruction Set Machines (ARM) architecture.
[0111] Further, optionally, the aforementioned memory may include read-only memory and random access memory, and may also include non-volatile random access memory. The memory may be volatile or non-volatile, or may include both. Non-volatile memory may include read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory may include random access memory (RAM), which serves as an external cache. Many forms of RAM are available by way of example, but not limitation. Examples include Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), Synchronous DRAM (SDRAM), Double Data Rate Synchronous DRAM (DDR SDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchlink DRAM (SLDRAM), and Direct RAMBUS RAM (DR RAM).
[0112] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this disclosure are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line, DSL) or wireless (e.g., infrared, Bluetooth, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer, or a data storage device such as a server or data center that integrates one or more available media. The available media can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., Digital Versatile Discs (DVDs)), or semiconductor media (e.g., Solid State Disks (SSDs)). It is worth noting that the computer-readable storage media mentioned in this disclosure can be non-volatile storage media; in other words, it can be non-transient storage media.
[0113] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0114] In the description of the embodiments of this disclosure, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this disclosure. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of those different embodiments or examples.
[0115] In the description of the embodiments disclosed herein, unless otherwise stated, " / " means "or". For example, A / B can mean A or B. The "and / or" in this document is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone.
[0116] In the description of embodiments of this disclosure, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of embodiments of this disclosure, unless otherwise stated, "a plurality of" means two or more.
[0117] The above description is merely an exemplary embodiment of this disclosure and is not intended to limit this disclosure. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this disclosure should be included within the protection scope of this disclosure.
Claims
1. A data packet processing method applied to a virtual machine, comprising: For data packets to be transmitted between a target virtual machine and a target host, if the data packets need to be transmitted through at least one TCP link between the target virtual machine and the target host, and TCP Segmentation Offload (TSO) is enabled, the target packet size corresponding to the at least one TCP link is obtained. The target packet size is determined based on a first packet length and a second packet length allowed by the at least one TCP link. The first packet length is determined based on the Virtual Machine Switch (OVS) between the target virtual machine and the target host. Both the first packet length and the second packet length are greater than or equal to the target packet size. The data packets to be transmitted are segmented by the OVS based on the target packet size and then transmitted. The at least one TCP link is obtained. The target packet size includes: creating multiple TCP links between the target virtual machine and the target host, and performing the following for each TCP link: comparing the MSS of the target virtual machine, the MSS of the target host, and the MSS of the intermediate devices, and determining the smallest MSS as the MSS that the bottleneck node in the TCP link can transmit; determining the MSS that the bottleneck node in the TCP link can transmit as the second packet length corresponding to the TCP link; when multiple TCP links between the target virtual machine and the target host share the same target packet size, selecting the minimum value from the first packet length of the target port and the second packet lengths corresponding to the multiple TCP links respectively, as the same target packet size shared by the multiple TCP links.
2. The method according to claim 1, wherein, The length of the first packet is determined based on the maximum transmission unit (MTU) of the target port; the target port is used to connect the physical network interface card (NIC) and the virtual bridge in the OVS.
3. The method according to claim 1 or 2, wherein, The second packet length is determined based on the maximum packet size that the bottleneck node in the at least one TCP link can transmit.
4. The method according to claim 1, wherein, The at least one TCP link shares the same target packet size; or, each TCP link in the at least one TCP link uses its own corresponding target packet size.
5. The method according to claim 4, further comprising: When each TCP link adopts its own target packet size, for any TCP link in the at least one TCP link, the target packet size corresponding to the any TCP link is determined based on the following method: the any TCP link is established through a three-way TCP handshake negotiation between the target virtual machine and the target host, and the maximum packet size (MSS) of the any TCP link is obtained; Based on the MSS and the Maximum Transmission Unit (MTU) used in the Data Plane Development Kit (DPDK) of the OVS, the packet size applicable to any TCP link is determined as the target packet size corresponding to any TCP link; the correlation between any TCP link and the target packet size is recorded.
6. The method according to claim 4, further comprising: When at least one TCP link shares the same target packet size, monitor changes in the TCP link between the target virtual machine and the target. The target packet size is dynamically updated in response to the dynamic changes in the TCP link.
7. A data packet processing apparatus for use in a virtual machine, comprising: The acquisition module is used to acquire, for example, the target packet size corresponding to at least one TCP link between the target virtual machine and the target host, provided that the data packet to be transmitted needs to be transmitted through at least one TCP link between the target virtual machine and the target host, and TCP segmentation offload (TSO) is enabled. The target packet size is determined based on a first packet length and a second packet length allowed by the at least one TCP link. The first packet length is determined based on the virtual machine switch (OVS) between the target virtual machine and the target host. Both the first packet length and the second packet length are greater than or equal to the target packet size. The processing module is used to segment the data packet to be transmitted based on the target packet size using the OVS and then transmit the data. The acquisition module is used to acquire the target packet size. The target packet size corresponding to each TCP link includes: creating multiple TCP links between the target virtual machine and the target host, and for each TCP link, performing the following: comparing the MSS of the target virtual machine, the MSS of the target host, and the MSS of the intermediate devices, and determining the smallest MSS as the MSS that the bottleneck node in the TCP link can transmit; determining the MSS that the bottleneck node in the TCP link can transmit as the second packet length corresponding to the TCP link; when multiple TCP links between the target virtual machine and the target host share the same target packet size, selecting the minimum value from the first packet length of the target port and the second packet lengths corresponding to the multiple TCP links respectively, as the same target packet size shared by the multiple TCP links.
8. The apparatus according to claim 7, wherein, The length of the first packet is determined based on the maximum transmission unit (MTU) of the target port; the target port is used to connect the physical network interface card (NIC) and the virtual bridge in the OVS.
9. The apparatus according to claim 7 or 8, wherein, The second packet length is determined based on the maximum packet size that the bottleneck node in the at least one TCP link can transmit.
10. The apparatus according to claim 7, wherein, The at least one TCP link shares the same target packet size; or, each TCP link in the at least one TCP link uses its own corresponding target packet size.
11. The apparatus of claim 10, further comprising a size determination module, configured to: when each TCP link adopts its own corresponding target packet size, for any TCP link among the at least one TCP link, determine the target packet size corresponding to the any TCP link based on the following method: establishing the any TCP link through a three-way TCP handshake negotiation between the target virtual machine and the target host, and obtaining the maximum message length (MSS) of the any TCP link; determining a data packet size suitable for the any TCP link as the target packet size corresponding to the any TCP link based on the MSS and the maximum transmission unit (MTU) used in the Data Plane Development Kit (DPDK) of the OVS; and recording the association between the any TCP link and the target packet size.
12. The apparatus of claim 10, further comprising an update module, configured to: monitor changes in the TCP link between the target virtual machine and the target when at least one TCP link shares the same target packet size; and dynamically update the target packet size in accordance with the dynamic changes in the TCP link.
13. An electronic device, comprising: At least one processor; And a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-6.
14. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-6.
15. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1-6.
Citation Information
Patent Citations
Message segment transmission method and device, equipment and medium
CN117579725A
Virtual machine message sending method, device and system and electronic equipment
CN118175114A