WO2018113622A1 - 基于虚拟机的数据包发送和接收方法及装置 - Google Patents

基于虚拟机的数据包发送和接收方法及装置 Download PDF

Info

Publication number
WO2018113622A1
WO2018113622A1 PCT/CN2017/116898 CN2017116898W WO2018113622A1 WO 2018113622 A1 WO2018113622 A1 WO 2018113622A1 CN 2017116898 W CN2017116898 W CN 2017116898W WO 2018113622 A1 WO2018113622 A1 WO 2018113622A1
Authority
WO
WIPO (PCT)
Prior art keywords
virtual machine
data packet
network card
encapsulation
sending
Prior art date
Application number
PCT/CN2017/116898
Other languages
English (en)
French (fr)
Inventor
刘华
Original Assignee
腾讯科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 腾讯科技(深圳)有限公司 filed Critical 腾讯科技(深圳)有限公司
Publication of WO2018113622A1 publication Critical patent/WO2018113622A1/zh
Priority to US16/359,036 priority Critical patent/US11048535B2/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/66Arrangements for connecting between networks having differing types of switching systems, e.g. gateways
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/09Mapping addresses
    • H04L61/25Mapping addresses of the same type
    • H04L61/2503Translation of Internet protocol [IP] addresses
    • H04L61/2592Translation of Internet protocol [IP] addresses using tunnelling or encapsulation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/50Address allocation
    • H04L61/5007Internet protocol [IP] addresses
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45579I/O management, e.g. providing access to device drivers or storage
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45595Network integration; Enabling network access in virtual machine instances
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L2101/00Indexing scheme associated with group H04L61/00
    • H04L2101/60Types of network addresses
    • H04L2101/618Details of network addresses
    • H04L2101/622Layer-2 addresses, e.g. medium access control [MAC] addresses
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/50Address allocation
    • H04L61/5038Address allocation for local use, e.g. in LAN or USB networks, or in a controller area network [CAN]

Definitions

  • the present invention relates to the field of computer technologies, and in particular, to a method and device for transmitting and receiving data packets based on a virtual machine, a network device, and a storage medium.
  • VMs virtual machines
  • physical hosts can act as hosts for two or more virtual machines.
  • a virtual machine is a complete computer system that runs through a software and has full hardware system functionality running in a fully isolated environment. These virtual machine systems work exactly like real computers, such as installing an operating system, installing applications, accessing network resources, and more.
  • IP Internet Protocol
  • the virtual machine is a virtual module on the physical host, that is, it does not have a physical network card or network card device, it needs to go through the corresponding network card device on the host to send data or receive data.
  • the back end driver is installed on the host side
  • the front end driver is installed on the virtual machine side
  • the back end driver of the host directly interacts with the hardware of the network card on the host to complete the optional sending and receiving of the data packet, and the front end driver of the virtual machine is driven.
  • the back-end driver on the host side it interacts with the back-end driver on the host side to indirectly interact with the network card.
  • the above technology implements setting up multiple virtual machines on one physical host, but sometimes it is found that the physical host's network card obviously has a lot of idle bandwidth, but the virtual machine's data transmission and reception speed is very slow, and the physical host's CPU resources are very expensive. The load is large.
  • the physical host means that the above-mentioned virtual machine-based data packet transmission cannot fully utilize the processing capability of the network card and excessively consumes the CPU (Centre Processor Unite, CPU) resources, that is, the effective utilization of system resources is insufficient.
  • CPU Central Processor Unite
  • the embodiments of the present invention are directed to providing a method and device for transmitting and receiving a data packet based on a virtual machine, a network device, and a storage medium, which can at least partially solve the problem of low effective utilization of the processing capability of the network and/or large CPU resource consumption.
  • the first embodiment of the present invention provides a method for sending a data packet based on a virtual machine, including:
  • the second embodiment of the present invention provides a method for receiving a data packet based on a virtual machine, including:
  • the embodiment of the present invention further provides a virtual machine-based data packet sending apparatus, including:
  • a through connection establishment module configured to establish a direct connection between the virtual machine and the network card
  • a packet detection module configured to detect a data packet sent by a driver layer of the virtual machine
  • the encapsulation parameter obtaining module is configured to send a encapsulation parameter acquisition request to the virtual machine monitor corresponding to the virtual machine, and receive the encapsulation information and the encapsulation parameter returned by the virtual machine monitor;
  • the encapsulating module is configured to encapsulate the data packet according to the encapsulation information and the encapsulation parameter, and send the encapsulated data packet to a hardware sending queue of the network card by using the through connection.
  • an embodiment of the present invention provides a virtual machine-based data packet receiving apparatus, including:
  • a through connection establishment module configured to establish a direct connection between the virtual machine and the network card
  • a data packet obtaining module configured to acquire a data packet in a hardware receiving queue of the network card
  • a decapsulation parameter obtaining module configured to send a decapsulation parameter acquisition request to the virtual machine monitor corresponding to the virtual machine, and obtain decapsulation information and decapsulation parameters returned by the virtual machine monitor;
  • the decapsulation module is configured to decapsulate the obtained data packet according to the decapsulation information and the decapsulation parameter, and send the decapsulated data packet to a driver layer of the virtual machine.
  • an embodiment of the present invention provides a computer storage medium, where the computer storage medium stores computer executable code, and after the computer executable code is executed, the virtual reality provided by the one or more technical solutions can be implemented.
  • the virtual machine on the physical host establishes a direct connection with the network card, and the virtual machine directly connects through the network card.
  • the data is sent and received without the need to transit through the network card driver on the host.
  • the virtual machine monitor on the host needs to request the data packet encapsulation parameter corresponding to the data to be sent, and then the data to be encapsulated according to the encapsulation parameter given by the virtual machine monitor on the host. After being encapsulated, it is sent to the network card for transmission.
  • the virtual machine's pass-through network card When the virtual machine's pass-through network card receives the encapsulated data, it also needs to request the de-encapsulation parameters from the virtual machine monitor on the host before the solution can be given according to the virtual machine monitor.
  • the encapsulation parameter decapsulates the received data before it can be sent to the driver layer of the virtual machine. That is to say, after the virtual machine side establishes a direct connection with the network card, the data packet can be encapsulated and decapsulated by itself, but the strategy for encapsulating and decapsulating the data packet is still completed by the host side, that is, The control plane and data plane of the data packet are separated, and the data transmission and reception are transparent to the virtual machine.
  • the network card driver on the host side is not required to perform multiple data transmissions and the encapsulation and decapsulation of the data packets, thereby reducing the system.
  • Resources in particular, occupy resources such as CPU resources or memory resources, thereby reducing resource consumption such as CPU and memory, and reducing the load rate of the CPU.
  • resources such as CPU and memory no longer become the bottleneck of the physical host network card, so that the bandwidth usage of the physical host network card can be higher, thereby improving the effective use rate of the physical host network card.
  • the CPU resource and the memory resource are too high, and the data interaction delay between the virtual machine and the peripheral device is large, and the sending and receiving speed is slow, which improves the data exchange rate between the virtual machine and the peripheral device. , improve the data transmission speed.
  • FIG. 1 is a schematic diagram of a logical structure of a computer device including multiple virtual machines in an embodiment
  • FIG. 2 is a schematic flowchart of a method for sending a data packet based on a virtual machine in an embodiment
  • FIG. 3 is a schematic flowchart of a method for receiving a data packet based on a virtual machine in an embodiment
  • FIG. 4 is a logical structure diagram based on a virtual machine and a host in an embodiment
  • FIG. 5 is a schematic structural diagram of a virtual machine-based data packet sending apparatus according to an embodiment
  • FIG. 6 is a schematic structural diagram of a virtual machine-based data packet receiving apparatus in an embodiment
  • FIG. 7 is a schematic structural diagram of a computer device that runs the foregoing virtual machine-based data packet transmitting method and a virtual machine-based data packet receiving method in one embodiment.
  • a virtual machine-based data packet sending method and a virtual machine-based data packet receiving method are proposed, and the implementation of the method may depend on a computer program, and the computer program may run.
  • the computer program can be an application or virtual machine management program based on virtual machine data transmission and management.
  • the computer system may be a server or terminal such as a smartphone, tablet, personal computer or the like that runs the above computer program.
  • FIG. 1 is a schematic diagram showing the logical structure of a computer system on which an embodiment of the present invention is based.
  • N virtual machines such as VM-1, . . . , VM-N, and the like are included on a physical host, and for each virtual machine VM-i, a corresponding computer system is installed in the corresponding computer system.
  • NIC driver, DVM-i The value of i is less than N, and N and i are both positive integers.
  • For a virtual machine when sending data or data sent by other virtual machines or devices, it needs to receive and send data through the network card driver installed on the virtual machine.
  • a virtual machine monitor is also included on the physical host.
  • the VMM is a system software used to create and manage virtual machines on the physical host, and Dynamic management of virtual resources. That is, the virtual machine monitor VMM is a virtual machine management program installed on the physical host, and can be configured to present a virtual hardware platform for the virtual machine to implement scheduling and isolation of the virtual machine; wherein each virtual virtual platform runs on the virtual machine
  • the machine provides various hardware resources, such as providing virtual CPU, memory, virtual disk, virtual network card, and so on.
  • the foregoing virtual machine-based data packet sending method is based on an Overlay network technology, for example, a VXLAN (Virtual Extensible LAN) technology, that is, data needs to be performed before being sent.
  • the network intermediate device After being encapsulated and formatted into a preset VXLAN packet format, the network intermediate device forwards the packet according to the address of the corresponding packet header in the packet after receiving the VXLAN packet.
  • the virtual machine first needs to encapsulate the data before sending the data, and the data that is not encapsulated cannot be directly sent; correspondingly, the received data is also the data that has been encapsulated, and The virtual machine needs to decapsulate the data after receiving the data.
  • the virtual machine before the virtual machine sends data, it needs to encapsulate the data packet that needs to be sent. After receiving the data packet, the data packet is encapsulated. Therefore, the received data needs to be decapsulated to perform the next processing.
  • the foregoing virtual machine-based data packet sending method includes the following steps S102 to S108:
  • Step S102 Establish a through connection between the virtual machine and the network card.
  • the front-end NIC driver installed on the virtual machine can only indirectly access the physical NIC on the host through the back-end NIC driver installed on the host, that is, the host and multiple virtual machines integrated on the host are shared.
  • the same physical network card, and the virtual machine controller and the host's network card driver to manage the network card; that is, the network card driver installed on the virtual machine can not directly access the physical network card on the host.
  • the direct connection may be: the front end network card driver (may be referred to as a front end driver) of the virtual machine may directly perform data interaction with the physical network card without first sending data to the back end network card driver on the host side. (referred to as the back-end driver), after the data processing by the back-end NIC driver, it is forwarded to the physical network card, which obviously reduces the modules that need to pass during the data transmission process. At the same time, the data encapsulation and de-encapsulation can be directly from the front-end.
  • the front end network card driver may be referred to as a front end driver
  • the back-end driver after the data processing by the back-end NIC driver, it is forwarded to the physical network card, which obviously reduces the modules that need to pass during the data transmission process.
  • the data encapsulation and de-encapsulation can be directly from the front-end.
  • the NIC driver is executed, and the back-end network card is not required to perform repeated data encapsulation and destination address mapping, thereby reducing unnecessary encapsulation and forwarding actions on the host side of the physical host, thereby reducing the encapsulation and decapsulation of the back-end NIC driver.
  • the CPU resources consumed by the transfer operation reduce the load rate of the CPU, thereby reducing the transmission delay caused by the shortage of CPU resources, and the limitation of receiving the CPU by the effective resource utilization rate of the physical network card is reduced.
  • a direct connection between the network card and the network card on the host is established, so that the driver layer of the virtual machine can directly access and use the network card without using the network card driver on the host. Transit or forwarding.
  • the driver layer of the virtual machine can directly send the data or data packet to the network card that establishes the through connection, without the need to transit or forward through the driver on the host side.
  • the data transceiver module of a virtual machine can include two types:
  • the first mode is: direct mode, the virtual machine directly establishes a direct connection with the network card, and the front end network card driver of the virtual machine can directly access the network card, send data packets to the network card, and receive data packets from the network card. At this time, the data packet is no longer sent or received.
  • a back-end NIC driver is required for data encapsulation, decapsulation, and transit.
  • the second mode is: indirect mode, the virtual machine is connected to the network card through the back-end network card driver on the host side, and the data transmission and reception of the virtual machine needs to be involved in data encapsulation, decapsulation, and transit by the back-end network card driver.
  • one or more ports on a network card or a network card need to be allocated to a virtual machine that has a direct connection. Therefore, if the data currently sent and received by the virtual machine needs to be encapsulated, it needs to be carried in the encapsulation layer.
  • the address of the network card or the network card and the corresponding port After receiving the address of the network card or the network card and the corresponding port, the network card can directly send the address. If the data received by the network card is based on the port number of the received data and the virtual machine to which it is bound, it knows which virtual machine needs to be sent directly to the virtual machine, so that the virtual machine data packet does not need to be driven by the back end network card. The processing of the data is completed and sent.
  • the method further includes:
  • Determining a data transceiving mode of one or more of the virtual machines according to a data transmission and reception status of the virtual machine in the physical host or the computer node.
  • the data transmission and reception mode of one or more virtual machines may be determined in the following manner.
  • the amount of data sent and received by the first virtual machine in a unit time is greater than a first threshold
  • the amount of data sent and received by the second virtual machine in a unit time is lower than a second threshold
  • the first threshold is greater than the second threshold, and the number of the first virtual machines is less than the number of network cards;
  • Determining the data transmission and reception mode of the first virtual machine as the first mode, and establishing a direct connection of each of the first virtual machine and a network card including:
  • the amount of data sent and received by the first virtual machine in a unit time is greater than a first threshold
  • the amount of data sent and received by the second virtual machine in a unit time is lower than a second threshold
  • the first threshold is greater than the second threshold, and the number of the first virtual machines is not less than the number of network cards;
  • the data transmission and reception mode is the second mode, and the second virtual machine shares a second port that does not currently establish a through connection with the first virtual machine for data transmission and reception.
  • the first port may include: one or more groups of ports, the group of ports including: a data sending port and a data receiving port, wherein the data sending port may be configured to send a data packet to the external device by the virtual machine, A data receiving port that can be configured to receive packets from an external device.
  • the second port is different from the first port, and may also include: one or more groups of ports.
  • the physical host or the computer node correspondingly records the identifier of the first virtual machine and the network card, or the identifier of the port of the first virtual machine and the network card according to the established through connection.
  • the third type is the third type.
  • the data type of the data that the first virtual machine interacts with the other device is the first type, determining that the data sending and receiving mode of the first virtual machine is the first mode;
  • the data type of the data that the second virtual machine interacts with the other device is the second type, determining that the data sending and receiving mode of the second virtual machine is the second mode.
  • the first type is different from the second type, and the transmission delay of the first type of data is higher than the transmission delay of the second type of data.
  • the quality of service (QoS) of the first type of data is higher than the QoS of the second type of data.
  • the through connection may be based on a network card granularity or may be based on port granularity.
  • the straight-through connection of the network card granularity usually one virtual machine is bound to one network card, and a straight-through connection is established with the bound network card.
  • the data packet encapsulation based on the network card granularity needs to carry the MAC address and/or the IP address of the network card, and the data packet between the data packet of the network card and the virtual machine can be sent and received according to the MAC address and/or the IP address of the network card.
  • one virtual machine establishes a direct connection with a specific port of one or more network cards, and one network card can be used for a straight-through connection with multiple virtual machines.
  • Packet encapsulation based on port granularity requires that the address of the network card also needs to carry the port number of the corresponding port.
  • a host of a physical host or computer node can set the data transceiving mode of the virtual machine.
  • the network card that establishes a direct connection with the virtual machine may be an independent physical network card, that is, if multiple virtual machines are integrated on the host, if each virtual machine needs to be established and connected with the network card.
  • the direct connection requires that each virtual machine corresponds to a separate network card device. For example, multiple physical network cards are included on the physical host, and each virtual machine corresponds to a physical network card, and the virtual machine is established. A straight-through connection between the physical NICs.
  • the network card that establishes a direct connection with the virtual machine may also be a physical address range on the physical network card, and map the physical address range on the network card to the driver layer of the virtual machine, and the driver layer sends data. When the data is sent to the corresponding physical address range on the network card.
  • the driving layer of the virtual machine is a component of the foregoing front-end network card driver.
  • the establishing a direct connection between the virtual machine and the network card further includes: assigning, to the virtual machine, a target physical address range corresponding to the virtual machine within a physical address range corresponding to the network card, and The target physical address range is mapped to the driver layer of the virtual machine.
  • the network card is an SR-IOV (Single Root I/O Virtualization) network card, and the target physical address range allocated to the virtual machine and a VF (Virtual Functions, virtual) corresponding to the SR-IOV network card. Function) NIC.
  • the physical network card included in the host may also be an SR-IOV (Single Root I/O Virtualization) network card, that is, a PF (Physical Functions) of the physical network card is extended.
  • SR-IOV Single Root I/O Virtualization
  • PF Physical Functions
  • VFs extended by a single physical network card are deployed as optional network cards, and each VF corresponds to a VF interface, and each VF interface has a separate virtual PCIe channel (ie, a PCI-Express channel). That is, each virtual machine corresponding to the VF communicates independently with the external I/O device.
  • These virtual PCIe channels share the PCIe channel of the physical network card.
  • Each virtual machine can occupy one or more VF interfaces, so that the virtual machine can directly access its own VF interface, that is, access its own virtual network card without the coordinated intervention of the VMM.
  • the virtual machine establishes a direct connection with the network card, which is equivalent to establishing a direct connection with the VF interface under the physical network card, and the VF interface is used by the current virtual machine and can be used as the virtual machine.
  • Step S104 Detect a data packet sent by a driver layer of the virtual machine.
  • the corresponding data packet is sent to the driver layer of the virtual machine, and is optionally processed by the driver layer of the virtual machine, for example, The packet is sent to the NIC driver of the virtual machine for processing.
  • the transmitted data packet is acquired, and the header information of the data packet is obtained.
  • the header information may include an address of the source virtual machine, a port of the source virtual machine, a destination address/port, and the like.
  • the packet header information of the data packet may further include a protocol that meets the requirements, such as a TCP (Transmission Control Protocol), and is not limited in the present invention.
  • TCP Transmission Control Protocol
  • Step S106 Send an encapsulation parameter acquisition request to the virtual machine monitor corresponding to the virtual machine, and receive the encapsulation information and the encapsulation parameter returned by the virtual machine monitor.
  • the encapsulation of the data packet sent by the virtual machine is performed by the virtual machine, but the virtual machine optionally operates in the process of encapsulating the data packet and the corresponding parameter is virtualized by the host.
  • Machine Monitor determines.
  • the virtual machine monitor when the virtual machine needs to send a data packet, requesting, by the virtual machine monitor managing the virtual machine, a parameter request corresponding to the encapsulated data packet, that is, sending a package parameter acquisition request to the virtual machine monitoring machine. .
  • the virtual machine monitor After receiving the encapsulation parameter acquisition request sent by the virtual machine, the virtual machine monitor obtains the corresponding encapsulation policy and the data related to the encapsulation policy according to the encapsulation parameter acquisition request virtual machine identifier and the specific data packet to be sent. Return to the virtual machine for the virtual machine to encapsulate the packet.
  • the related data of the encapsulation policy determined by the virtual machine monitor includes the encapsulation information and the encapsulation parameter.
  • the encapsulation information includes an encapsulation format for encapsulating and encapsulating the data packet in the format;
  • the encapsulation parameters include a source IP address, a source media access control (MAC) address, and a destination IP address.
  • the necessary information when sending data, such as the address and destination MAC address also includes the protocol used by the encapsulation layer.
  • IP layer For packet encapsulation based on TCP/IP network protocol stack, it is mainly divided into layered encapsulation of application, transport layer, network layer and link layer. After the above layered encapsulation, data is encapsulated into frames and sent to the network card. For transmission, the encapsulation format may be any one of the above layers.
  • the network layer (IP layer) format is GRE data packet format (Generic Routing Encapsulation) or VXLAN data packet format (virtual Extensible LAN). , virtual scalable LAN).
  • Step S108 Encapsulate the data packet according to the encapsulation information and the encapsulation parameter, and add the encapsulated data packet to the hardware sending queue of the network card by using the through connection.
  • the virtual package can encapsulate the data packet according to the encapsulation information and the encapsulation parameter.
  • the corresponding encapsulation parameter is added to the packet header information of the data packet to complete the encapsulation of the data packet.
  • the data packet is processed according to the GRE data packet format. Encapsulate and encapsulate the corresponding encapsulation parameters into the corresponding layered package in the packet.
  • the encapsulated data packet is sent to the network card through the direct connection between the virtual machine and the network card, and is optionally sent by the network card; for example, the encapsulated data packet passes through the virtual network.
  • the straight-through connection between the machine and the network card is added to the hardware sending queue of the network card, and the data or data packet in the hardware sending queue is sent by the network card one by one.
  • the virtual machine if a direct connection between the virtual machine and the network card is established, the virtual machine is allocated a target physical address range corresponding to the virtual machine by using a physical address corresponding to the network card. And mapping the target physical address range to the driver layer of the virtual machine, when adding data to the hardware sending queue of the network card, sending data to the hardware corresponding to the target physical address range on the network card Send queue.
  • the sending, by the through-connection, the encapsulated data packet to the hardware sending queue of the network card for sending further comprises: sending the encapsulated data packet to a target physics on the network card The hardware send queue corresponding to the address range is sent.
  • the virtual machine-based data packet sending method is applied to a network device, where the network device includes: at least one network card and at least one processor connected to the network card.
  • the network device includes one or more network cards, and one or more processors.
  • the network card and the processor are connected by a bus, for example, through an integrated circuit bus.
  • the processor may be: a central processing unit, a microprocessor, a digital signal processor, an application processor, a programmable array, or an application specific integrated circuit.
  • the processor can execute computer executable code such as an operating system, a software application, or a computer program, and can set up one or more virtual machines.
  • the network device is further provided with a memory such as a memory, and can be connected to the processor through a bus.
  • the network card can be used by the virtual machine to perform data transmission using the first mode and/or the second mode.
  • FIG. 3 illustrates the above virtual machine-based data packet receiving method.
  • the method includes the following steps S202-S208:
  • Step S202 Establish a direct connection between the virtual machine and the network card. For related operations, refer to step S102.
  • Step S204 Acquire a data packet in a hardware receiving queue of the network card.
  • the data when another virtual machine or other device or server sends data to the current virtual machine, the data is sent to the network card that establishes a direct connection with the virtual machine, and then the network card sends the data to the current network card.
  • the driver layer of the virtual machine when there is a data packet sent to an IP address or a MAC address corresponding to the current virtual machine, the data packet is sent to a hardware receiving queue of the network card, and the network card performs receiving processing according to the data packet in the hardware receiving queue. .
  • the data packet when a data packet exists in a hardware receiving queue of the network card, the data packet is acquired.
  • the data packet acquired by the hardware receiving queue of the network card is an encapsulated data packet, that is, the virtual machine needs to perform decapsulation operation on the received data packet that is encapsulated. .
  • the virtual machine if a direct connection between the virtual machine and the network card is established, the virtual machine is allocated a target physical address range corresponding to the virtual machine by using a physical address corresponding to the network card. And mapping the target physical address range to the driver layer of the virtual machine, when acquiring the data packet in the hardware receiving queue of the network card, is the target physical address range on the network card allocated for the virtual machine. Corresponding hardware received in the queue.
  • the acquiring the data packet in the hardware receiving queue of the network card further includes: acquiring a data packet in a hardware receiving queue corresponding to the target physical address range on the network card.
  • Step S206 Send a decapsulation parameter acquisition request to the virtual machine monitor corresponding to the virtual machine, and obtain decapsulation information and decapsulation parameters returned by the virtual machine monitor.
  • the specific operation of decapsulating the data packet received by the virtual machine is performed by the virtual machine, but the virtual machine optionally operates in the process of decapsulating the data packet and the corresponding parameter is performed by the host. Determined by the virtual machine monitor (VMM).
  • VMM virtual machine monitor
  • the network card receiving queue of the virtual machine when the network card receiving queue of the virtual machine receives the data packet, requesting, by the virtual machine monitor managing the virtual machine, a parameter request corresponding to the decapsulated data packet, that is, to the virtual machine monitoring machine.
  • the virtual machine monitor After receiving the decapsulation parameter acquisition request sent by the virtual machine, the virtual machine monitor obtains the corresponding decapsulation policy according to the virtual machine identifier included in the decapsulation parameter acquisition request and the specifically received data packet, and decapsulates the decapsulation policy. Policy-related data is returned to the virtual machine for the virtual machine to encapsulate the packet solution.
  • the related data of the decapsulation policy determined by the virtual machine monitor includes understanding the encapsulation information and decapsulating parameters.
  • the decapsulation information includes an encapsulation format for decapsulating the data packet in a format;
  • the decapsulation parameter includes a source IP address, a source MAC address, a destination IP address, a destination MAC address, etc., received.
  • the necessary information to encapsulate the data for decapsulation including the protocol used by the encapsulation layer.
  • Step S208 Decapsulate the acquired data packet according to the decapsulation information and the decapsulation parameter, and send the decapsulated data packet to a driver layer of the virtual machine.
  • the data packet may be decapsulated according to the decapsulation information and the decapsulation parameter.
  • the data packet can be sent by the network card to the driver layer of the virtual machine, that is, the network card driver, and then sent by the driver layer to the corresponding application layer for optional processing.
  • the virtual machine-based data packet sending method is applied to a network device, where the network device includes: at least one network card and at least one processor connected to the network card.
  • the network device includes one or more network cards, and one or more processors.
  • the network card and the processor are connected by a bus, for example, through an integrated circuit bus.
  • the processor may be: a central processing unit, a microprocessor, a digital signal processor, an application processor, a programmable array, or an application specific integrated circuit.
  • the processor can execute computer executable code such as an operating system, a software application, or a computer program, and can set up one or more virtual machines.
  • the network device is further provided with a memory such as a memory, and can be connected to the processor through a bus.
  • the network card can be used by the virtual machine to receive data using the first mode and/or the second mode.
  • FIG. 4 shows a system architecture diagram of virtual machine-based data packet transmission and reception.
  • a virtual machine is included on the host, and the virtual machine monitor (VMM) that manages the virtual machine is included, and the physical network card is included on the host; the network card driver corresponding to the network card is installed on the virtual machine, and Through the network card driver to directly communicate with the network card on the host.
  • the front end management module is included on the virtual machine, and specifically includes three sub-modules: a policy management, a communication front end, and a packetization/decoding data package.
  • the front-end management module is placed under the network card driver of the virtual machine, that is, when the network card driver sends the data transmission queue to the network card and receives the data packet from the hardware receiving queue, the data packet is taken out and sent.
  • the front-end management module is encapsulated or decapsulated and then sent to the driver layer of the network card or network card.
  • the back-end management module is configured to process and respond to the request sent by the virtual machine, for example, parsing the encapsulation parameter acquisition request or the decapsulation parameter acquisition request sent by the virtual machine side and giving a corresponding response. .
  • control plane and the data plane in the process of transmitting and receiving the data packet based on the virtual machine are separated, and the encapsulation and decapsulation of the data packet is completed on the virtual machine side, and the encapsulation strategy and the decapsulation strategy are optionally encapsulated. It is still done by the host side.
  • a virtual machine-based data packet sending apparatus and a A virtual machine based data packet receiving device in order to solve the technical problem that the effective utilization of the system resources of the virtual machine-based data packet is insufficient in the prior art, in the embodiment, a virtual machine-based data packet sending apparatus and a A virtual machine based data packet receiving device.
  • the virtual machine-based data packet sending apparatus includes a through connection establishing module 102, a data packet detecting module 104, a package parameter obtaining module 106, and a packaging module 108, where:
  • the through connection establishing module 102 is configured to establish a direct connection between the virtual machine and the network card;
  • the packet detection module 104 is configured to detect a data packet sent by a driver layer of the virtual machine
  • the encapsulation parameter obtaining module 106 is configured to send a encapsulation parameter acquisition request to the virtual machine monitor corresponding to the virtual machine, and receive the encapsulation information and the encapsulation parameter returned by the virtual machine monitor;
  • the encapsulating module 108 is configured to encapsulate the data packet according to the encapsulation information and the encapsulation parameter, and send the encapsulated data packet to a hardware sending queue of the network card by using the through connection.
  • the encapsulation information includes an encapsulation format, where the encapsulation format includes an encapsulation protocol of a data packet encapsulation layer.
  • the encapsulation parameter includes an IP address and/or a MAC address of a data packet encapsulation layer.
  • the pass-through connection establishing module 102 is further configured to allocate, to the virtual machine, a target physical address range corresponding to the virtual machine in a physical address range corresponding to the network card, and Mapping the target physical address range to a driver layer of the virtual machine.
  • the encapsulating module 108 is further configured to send the encapsulated data packet to a hardware sending queue corresponding to a target physical address range on the network card for sending.
  • FIG. 6 shows a specific structural composition of the above-mentioned virtual machine-based data packet receiving apparatus.
  • the apparatus includes a through connection establishing module 202, a data packet obtaining module 204, and a decapsulation parameter obtaining module 206.
  • Decapsulation module 208 wherein:
  • the through connection establishing module 202 is configured to establish a direct connection between the virtual machine and the network card;
  • the data packet obtaining module 204 is configured to acquire a data packet in a hardware receiving queue of the network card
  • the decapsulation parameter obtaining module 206 is configured to send a decapsulation parameter acquisition request to the virtual machine monitor corresponding to the virtual machine, and obtain decapsulation information and decapsulation parameters returned by the virtual machine monitor;
  • the decapsulation module 208 is configured to decapsulate the obtained data packet according to the decapsulation information and the decapsulation parameter, and send the decapsulated data packet to a driving layer of the virtual machine.
  • the decapsulation information includes an encapsulation format, where the encapsulation format includes an encapsulation protocol of a data packet encapsulation layer.
  • the decapsulation parameter includes an IP address and/or a MAC address of a data packet encapsulation layer.
  • the pass-through connection establishing module 202 is further configured to: allocate, by the virtual machine, a target physical address range corresponding to the virtual machine in a physical address range corresponding to the network card, and Mapping the target physical address range to a driver layer of the virtual machine.
  • the decapsulation module 208 is further configured to acquire a data packet in a hardware receiving queue corresponding to a target physical address range on the network card.
  • the virtual machine on the physical host establishes a direct connection with the network card, and the virtual machine directly transmits and receives data through a direct connection with the network card.
  • the virtual machine monitor on the host needs to request the data packet encapsulation parameter corresponding to the data to be sent, and then according to the virtuality on the host.
  • the package parameters given by the machine monitor encapsulate the data that needs to be encapsulated and then send it to the network card for transmission.
  • the virtual machine's pass-through network card receives the encapsulated data, it also needs to request the virtual machine monitor on the host.
  • the received data can be decapsulated according to the decapsulation parameters given by the virtual machine monitor before the data can be sent to the driver layer of the virtual machine. That is to say, after the virtual machine side establishes a direct connection with the network card, the data packet can be encapsulated and decapsulated by itself, but the strategy for encapsulating and decapsulating the data packet is still completed by the host side, that is, The control plane and the data plane of the data packet are separated, and the data transmission and reception are transparent to the virtual machine; for the physical host, during the process of sending or receiving the data packet by the virtual machine, The NIC driver on the host side is required to perform multiple data transmissions and encapsulation and decapsulation of data packets, thereby reducing the occupation of system resources, especially CPU resources.
  • FIG. 7 illustrates a terminal of a von Neumann system-based computer system that runs the above-described virtual machine-based packet transmission and reception method.
  • the computer system can be a terminal device such as a smartphone, a tablet, a palmtop, a laptop, or a personal computer.
  • an external input interface 1001, a processor 1002, a memory 1003, and an output interface 1004 connected by a system bus may be included.
  • the external input interface 1001 can optionally include at least a network interface 10012.
  • the memory 1003 may include an external memory 10032 (such as a hard disk, an optical disk, or a floppy disk, etc.) and an internal memory 10034.
  • the internal memory 10034 includes a virtual machine monitor VMM and N virtual machines VM-1, VM-2, ..., VM. -N, and each virtual machine corresponds to its corresponding network card driver DVM-1, DVM-2, ..., DVM-N.
  • the output interface 1004 can include at least a device such as a display 10042.
  • the operation of the method is based on a computer program whose program file is stored in the external memory 10032 of the aforementioned von Neumann system-based computer system, loaded into the internal memory 10034 at runtime, and then After being compiled into a machine code, it is passed to the processor 1002 for execution, so that a logic direct connection establishment module 102, a data packet detection module 104, a package parameter acquisition module 106, and a package module are formed in the von Neumann system-based computer system. 108 and the through connection establishment module 202, the data packet acquisition module 204, the decapsulation parameter acquisition module 206, and the decapsulation module 208.
  • the input parameters are all received through the external input interface 1001, and transferred to the buffer in the memory 1003, and then input to the processor 1002 for processing, and the processed result data is processed. It may be cached in the memory 1003 for subsequent processing or passed to the output interface 1004 for output.
  • the embodiment of the present invention provides a computer storage medium, where the computer storage medium stores computer executable code, and the virtual machine-based data packet sending method provided by one or more technical solutions after the computer executable code is executed , or a virtual machine based packet receiving method provided by one or more technical solutions.
  • the computer storage medium may be a variety of computer storage media such as a random storage medium, a read-only storage medium, a flash memory, a mobile hard disk, an optical disk, or a magnetic tape, and may be a non-transitory storage medium.
  • the computer executable code on the computer storage medium can be: a computer program or an application, and the method shown in FIG. 2 and/or FIG. 3 can be implemented after being executed.
  • the virtual machine can directly establish a direct connection with the network card, and the virtual machine can use the direct connection to perform data interaction with the external device, so that the data does not need the operations of transit, encapsulation, and decapsulation driven by the back end network card on the host side. Therefore, the host side consumes CPU resources or memory resources to perform data transfer processing, thereby reducing CPU consumption, reducing delay caused by processing of data transmission and reception due to back-end network card driver processing, and reducing network card limitation by CPU or memory.
  • the resource-utilized resource utilization rate is low, and the data transmission and reception speed and the effective use rate of the network card are improved, and the product has a positive industrial effect; and the technical solution provided by the embodiment of the present invention is simply implemented by a program change of the virtual machine, and thus has an industrial It has strong achievability and a wide range of industrial extensions.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

本发明实施例第一方面公开了一种基于虚拟机的数据包发送方法及装置,其中,所述包括:建立虚拟机与网卡之间的直通连接;检测所述虚拟机的驱动层发出的数据包;向与所述虚拟机对应的虚拟机监控器发送封装参数获取请求,接收所述虚拟机监控器返回的封装信息和封装参数;根据所述封装信息和所述封装参数将所述数据包封装,将所述封装后的数据包通过所述直通连接添加到所述网卡的硬件发送队列进行发送。此外,本发明实施例第二方面还公开了一种基于虚拟机的数据包接收方法及装置。本发明实施例第方面还提供一种计算机存储介质。

Description

基于虚拟机的数据包发送和接收方法及装置
相关申请的交叉引用
本申请基于申请号为201611190729.5、申请日为2016年12月21日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本申请作为参考。
技术领域
本发明涉及计算机技术领域,尤其涉及一种基于虚拟机的数据包发送和接收方法及装置、网络设备及存储介质。
背景技术
随着虚拟化技术的产生和发展,用户可以在一台物理服务器上(物理主机可以作为两个或更多虚拟机的主机)模拟出一个或者多个虚拟机(Virtual Machine,简称VM),所谓虚拟机,即为通过软件模拟的具有完整硬件***功能的、运行在一个完全隔离环境中的完整计算机***。这些虚拟机***完全就像真正的计算机那样进行工作,例如可以安装操作***、安装应用程序、访问网络资源等等。用户创建虚拟机后为使其能够如物理主机一样收发数据,需建立虚拟网络并为其分配网络协议(Internet Protocol,IP)地址,以便根据该IP地址来发送数据或者接收数据。
因为虚拟机是在物理主机上一个虚拟的模块,也就是说,其不存在实体的网卡或者网卡设备,其发送数据或者接收数据都需要经过相应的主机上的网卡设备。可选地例如,在主机侧安装后端驱动,在虚拟机侧安装前端驱动,主机的后端驱动直接与主机上的网卡的硬件交互,完成可选地收发数据包,而虚拟机的前端驱动不与网卡的硬件直接进行交互,而是与主机侧的后端驱动进行交互,从而间接完成与网卡的交互。也就是说,所有发送到虚拟机的数据包或者由虚拟机发送的数据包都会通过主机侧的后端 驱动,然后在主机侧对虚拟机的网络通信进行数据包的封装/解封装等网络IP虚拟化的操作。
上述技术实现了在一个物理主机上设置多台虚拟机,但是有时候发现,物理主机的网卡明明还有很多闲置带宽,可是虚拟机的数据收发速度却很慢,物理主机的CPU资源消耗很大,负载量大。
物理主机也就是说,上述基于虚拟机的数据包的发送存在无法充分利用网卡的处理能力以及过度消耗中央处理器(Centre Processor Unite,CPU)资源的问题,即对***资源的有效利用率不足。
发明内容
本发明实施例期望提供一种基于虚拟机的数据包发送和接收方法及装置、网络设备及存储介质,能够至少部分解决上述网络的处理能力有效利用率低和/或CPU资源消耗大的问题。
第一发面本发明实施例提出了一种基于虚拟机的数据包发送方法,包括:
建立虚拟机与网卡之间的直通连接;
检测所述虚拟机的驱动层发出的数据包;
向与所述虚拟机对应的虚拟机监控器发送封装参数获取请求,接收所述虚拟机监控器返回的封装信息和封装参数;
根据所述封装信息和所述封装参数将所述数据包封装,将所述封装后的数据包通过所述直通连接添加到所述网卡的硬件发送队列进行发送。
第二发面,本发明实施例提出了一种基于虚拟机的数据包接收方法,包括:
建立虚拟机与网卡之间的直通连接;
获取所述网卡的硬件接收队列中的数据包;
向与所述虚拟机对应的虚拟机监控器发送解封装参数获取请求,获取所述虚拟机监控器返回的解封装信息和解封装参数;
根据所述解封装信息和所述解封装参数对所述获取到的数据包进行解封装,将所述解封装后的数据包发送到所述虚拟机的驱动层。
第三方面,本发明实施例还提出了一种基于虚拟机的数据包发送装置,包括:
直通连接建立模块,配置为建立虚拟机与网卡之间的直通连接;
数据包检测模块,配置为检测所述虚拟机的驱动层发出的数据包;
封装参数获取模块,配置为向与所述虚拟机对应的虚拟机监控器发送封装参数获取请求,接收所述虚拟机监控器返回的封装信息和封装参数;
封装模块,配置为根据所述封装信息和所述封装参数将所述数据包封装,将所述封装后的数据包通过所述直通连接添加到所述网卡的硬件发送队列进行发送。
第四方面,本发明实施例提出了一种基于虚拟机的数据包接收装置,包括:
直通连接建立模块,配置为建立虚拟机与网卡之间的直通连接;
数据包获取模块,配置为获取所述网卡的硬件接收队列中的数据包;
解封装参数获取模块,配置为向与所述虚拟机对应的虚拟机监控器发送解封装参数获取请求,获取所述虚拟机监控器返回的解封装信息和解封装参数;
解封装模块,配置为根据所述解封装信息和所述解封装参数对所述获取到的数据包进行解封装,将所述解封装后的数据包发送到所述虚拟机的驱动层。
第五方面,本发明实施例提供一种计算机存储介质,所述计算机存储介质存储有计算机可执行代码,所述计算机可执行代码被执行后,能够实现前述一个或多个技术方案提供的基于虚拟机的数据包发送方法,或执行前述一个或多个技术方案提供的基于虚拟机的数据包接收方法。
在本发明实施例中,采用了上述基于虚拟机的数据发送和接收方法及装置之后,物理主机上的虚拟机建立与网卡之间的直通连接,虚拟机通过与该网卡之间的直通连接直接进行数据的发送和接收,而不需要经过主机上的网卡驱动的中转。在虚拟机发送数据的过程中,需要向主机上的虚拟机监控器请求需要发送的数据对应的数据包封装参数,然后根据主机上的虚拟机监控器给出的封装参数对需要进行封装的数据进行封装之后再发送 到网卡进行发送;在虚拟机的直通网卡接收的已经被封装的数据时,也需要向主机上的虚拟机监控器请求解封装参数之后才能根据虚拟机监控器给出的解封装参数对接收到的数据进行解封装,然后才能将该数据发送至虚拟机的驱动层。也就是说,在虚拟机侧通过建立与网卡之间的直通连接之后,可以自行完成对数据包的封装以及解封装,但是其对于数据包的封装和解封装的策略还是由主机侧完成的,即将数据包的收发的控制面和数据面进行了分离,其数据的发送和接收对于虚拟机来讲是透明的。
故第一方面,对于物理主机来讲,在虚拟机进行数据包的发送或接收的过程中,不需要主机侧的网卡驱动进行多次的数据传输以及数据包的封装和解封装,减少了对于***资源尤其是对CPU资源或内存资源等资源的占用,从而降低了CPU及内存等资源消耗,降低了CPU的负载率。
第二方面,CPU及内存等资源不再会成为物理主机网卡的使用的瓶颈,从而使得物理主机上网卡的带宽的使用率可以更高,从而提高物理主机上网卡的有效使用率。
第三方面,同时也减少了CPU资源及内存资源占用过高,导致的虚拟机与外设之间的数据交互延时大,收发速度慢的问题,提升了虚拟机与外设的数据交互速率,提高了数据的传输速度。
附图说明
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
其图1为一个实施例中包含多个虚拟机的计算机设备的逻辑结构示意图;
图2为一个实施例中一种基于虚拟机的数据包发送方法的流程示意图;
图3为一个实施例中一种基于虚拟机的数据包接收方法的流程示意图;
图4为一个实施例中一种基于虚拟机和主机的逻辑结构图;
图5为一个实施例中一种基于虚拟机的数据包发送装置的结构示意图;
图6为一个实施例中一种基于虚拟机的数据包接收装置的结构示意图;
图7为一个实施例中运行前述基于虚拟机的数据包发送方法和基于虚拟机的数据包接收方法的计算机设备的结构示意图。
具体实施方式
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
研究发现,在上述虚拟机对于数据包的发送和接收的过程中,所有的数据包的发送或接收都需要经过主机侧的后端驱动与虚拟机端的前端驱动之间的数据传输、主机侧的后端驱动对数据包的封装或者解封装等多个步骤,一个数据包的发送或接收的完成需要经过多个模块之间的数据的传输和数据的处理。这样的话,主机侧的后端驱动,需要消耗CPU的处理资源。尤其是,在计算机的物理网卡处理能力较大、网络吞吐量较大时,基于虚拟机的数据包接收和发送的计算量会大幅的增加,导致CPU的消耗急剧加大,CPU负载率高。CPU称为虚拟机与外部设备的数据收发的瓶颈,导致数据收发时延大,网卡的带宽资源无法得到有效利用等问题。
有鉴于此,在本实施例中,特提出了一种基于虚拟机的数据包发送方法和一种基于虚拟机的数据包接收方法,该方法的实现可依赖于计算机程序,该计算机程序可运行于基于冯诺依曼体系的计算机***之上,该计算机程序可以是基于虚拟机的数据收发管理的应用程序或者虚拟机管理程序。该计算机***可以是运行上述计算机程序的例如智能手机、平板电脑、个人电脑等服务器或终端。
参考图1,图1给出了本发明实施例所基于的计算机***的逻辑结构示意图。如图1所示,在物理主机上包含了VM-1、…、VM-N等N个虚拟机, 并且,对于每一个虚拟机VM-i来讲,其对应的计算机***中安装了相应的网卡驱动,即DVM-i。i的取值小于N,N和i均为正整数。对于一个虚拟机来讲,其在发送数据或者其他虚拟机或者设备发送的数据时,都需要通过该虚拟机上安装的网卡驱动进行数据的接收和发送。
如图1所示,在物理主机上还包含了虚拟机监控器(Virtual Machine Monitor,简称VMM),可选地,VMM是一个***软件,用来创建和管理在物理主机上的虚拟机,并对虚拟资源进行动态管理。即,虚拟机监控器VMM是安装在物理主机上的虚拟机管理程序,可配置为为虚拟机呈现虚拟硬件平台,实现虚拟机的调度和隔离;其中,虚拟硬件平台对其上运行的各个虚拟机提供各种硬件资源,如提供虚拟CPU、内存、虚拟磁盘、虚拟网卡等等。
可选地,在本实施例中,上述基于虚拟机的数据包发送方法是基于Overlay(叠加)网络技术,例如,VXLAN(virtual Extensible LAN,虚拟可扩展局域网)技术,即数据在发送之前需要进行封装,封装成预设的VXLAN报文的格式之后再进行发送,网络中间设备在接收到VXLAN报文之后,根据报文中相应的包头中国的地址进行转发。在本实施例中,可表现为,虚拟机在发送数据之前首先需要对数据进行封装,没有进行封装的数据是不能直接进行发送的;相应的,接收的数据也是已经被封装之后的数据,并且,虚拟机在接收到数据之后需要对数据进行解封装。
在下述具体描述中,虚拟机发送数据之前需要对需要发送的数据包进行封装,接收到是数据包是封装后的,因此需要对接收到的数据进行解封装才能进行下一步的处理。
可选地,如图2所示,上述基于虚拟机的数据包发送方法包括如下步骤S102至S108:
步骤S102:建立虚拟机与网卡之间的直通连接。
在相关技术中,虚拟机上安装的前端网卡驱动只能通过主机上安装的后端网卡驱动来间接的访问主机上的物理网卡,也就是说,主机以及主机上集成的多个虚拟机是共用同一个物理网卡的,并且用虚拟机控制器和主机的网卡驱动来对网卡进行管理;也就是说,虚拟机上安装的网卡驱动不 能直接访问主机上的物理网卡。
在本实施例中所述直通连接可为:所述虚拟机的前端网卡驱动(可简称为前端驱动)可以直接与物理网卡进行数据交互,而不用先将数据发送给主机侧的后端网卡驱动(简称为后端驱动),再由后端网卡驱动进行数据处理之后,转发给物理网卡,显然减少了数据传输过程中所需经过的模块,于此同时,数据的封装和解封装可以直接由前端网卡驱动执行,无需后端网卡确定进行重复的进行数据封装和目的地址的映射,从而减少了物理主机的主机侧不必要的封装和转发动作,从而减少了后端网卡驱动执行封装、解封装及中转操作所消耗的CPU资源,从而降低了CPU的负载率,从而减少了CPU资源紧张导致的传输时延,物理网卡的资源有效使用率收到CPU的局限性减小了。
在本实施例中,对于某一个虚拟机来讲,建立其与主机上的网卡之间的直通连接,使得虚拟机的驱动层可以直接访问和使用该网卡,而不需要通过主机上的网卡驱动的中转或转发。在虚拟机与网卡之间的直通连接建立之后,虚拟机的驱动层可以直接将数据或数据包发送给建立了直通连接的网卡,而不需要通过主机侧的驱动的中转或者转发。
例如,虚拟机的数据收发模块可包括两种:
第一种模式为:直接模式,虚拟机与网卡直接建立直通连接,虚拟机的前端网卡驱动可以直接访问网卡,向网卡发送数据包以及从网卡接收数据包,此时,数据包的收发不再需要后端网卡驱动进行数据的封装、解封装及中转。
第二种模式为:间接模式,虚拟机通过主机侧的后端网卡驱动与网卡连接,虚拟机的数据收发是需要由后端网卡驱动参与数据封装、解封装及中转的。
在第一种模式下,一个网卡整体或者网卡上的一个或多个端口需要分配给建立有直通连接的虚拟机,这样若虚拟机当前收发的数据需要封装,则需要在封装层内携带有该网卡或该网卡及对应端口的地址,网卡接收到已经携带有该网卡或该网卡及对应端口的地址,就可以直接向外发送。若网卡接收到的数据之后,根据收到数据的端口号和自身绑定的虚拟机,就 知道需要将数据直发送给哪一个虚拟机,从而使得虚拟机的数据包不需要经过后端网卡驱动的处理,就完成数据的收发。
在一些实施例中,所述方法还包括:
根据物理主机或计算机节点内虚拟机的数据收发状况,确定一个或多个所述虚拟机的数据收发模式。
若一个所述物理主机或计算节点包括多个网卡,该物理主机或计算机点上设置有多个虚拟机,可以采用以下方式确定一个或多个虚拟机的数据收发模式。
第一种:
第一虚拟机在单位时间内的数据收发量大于第一阈值;
第二虚拟机在单位时间内的数据收发量低于第二阈值;
所述第一阈值大于第二阈值,所述第一虚拟机的个数小于网卡的个数;
确定所述第一虚拟机的数据收发模式为所述第一模式,并建立每一个所述第一虚拟机和一个网卡的直通连接;和/或,确定所述第二虚拟机的数据收发模式为所述第二模式,第二虚拟机共用当前未与第一虚拟机建立直通连接的网卡进行数据收发。
所述确定所述第一虚拟机的数据收发模式为所述第一模式,并建立每一个所述第一虚拟机和一个网卡的直通连接,包括:
根据单个第一虚拟机在单位时间内的数据收发量及网卡的带宽,选择具有与对应的第一虚拟机的单位时间内的数据收发量相适配带宽的网卡,与所述对应的第一虚拟机建立直通连接。
第二种:
第一虚拟机在单位时间内的数据收发量大于第一阈值;
第二虚拟机在单位时间内的数据收发量低于第二阈值;
所述第一阈值大于第二阈值,所述第一虚拟机的个数不小于网卡的个数;
确定所述第一虚拟机的数据收发模式为所述第一模式,并建立每一个所述第一虚拟机和网卡的第一端口的直通连接;和/或,确定所述第二虚拟机的数据收发模式为所述第二模式,第二虚拟机共用当前未与第一虚拟机 建立直通连接的第二端口进行数据收发。
所述第一端口可包括:一组或多组端口,一组端口包括:一个数据发送端口及一个数据接收端口,所述数据发送端口,可配置为虚拟机向外部设备发送数据包,所述数据接收端口,可配置为虚拟机从外部设备接收数据包。所述第二端口不同于所述第一端口,同样可包括:一组或多组端口。
在一些实施例中,所述物理主机或计算机节点,会根据建立的直通连接,对应记录下第一虚拟机及网卡的标识,或,第一虚拟机及网卡的端口的标识。
第三种:
确定当前虚拟机收发的数据类型;
若第一虚拟机与其他设备交互的数据的数据类型为第一类型,则确定第一虚拟机的数据收发模式为第一模式;
和/或,
第二虚拟机与其他设备交互的数据的数据类型为第二类型,则确定第二虚拟机的数据收发模式为第二模式。
所述第一类型不同于第二类型,所述第一类型的数据的传输时延要求高于所述第二类型的数据的传输时延。或者,所述第一类型的数据的服务质量(Quality of Service,QoS)高于所述第二类型的数据的QoS。
在本实施例中,所述直通连接可是基于网卡粒度的,也可以是基于端口粒度的。在本实施例中,基于网卡粒度的直通连接,则通常一个虚拟机与一个网卡绑定,并与绑定的网卡建立直通连接。
基于网卡粒度的数据包封装,需要携带该网卡的MAC地址和/或IP地址即可,网卡的数据包与虚拟机之间的数据包收发,可以基于网卡的MAC地址和/或IP地址。
若是基于端口粒度的,则一个虚拟机与一个或多个网卡的特定端口建立直通连接,一个网卡可以用于与多个虚拟机建立的直通连接。
基于端口粒度的数据包封装,是需要网卡的地址还需要携带对应端口的端口号的。
在一些实施例中物理主机或计算机节点的主机可设置所述虚拟机的数 据收发模式。
在本实施例中,与虚拟机建立直通连接的网卡可以是独立的物理网卡,也就是说,在主机上集成了多个虚拟机的情况下,若每一个虚拟机均需要建立与网卡之间的直通连接,则需要每一个虚拟机都对应了一个独立的网卡设备,例如,在物理主机上包含了多个物理网卡,且每一个虚拟机均对应了一个物理网卡,并建立该虚拟机与该物理网卡之间的直通连接。
在另一个实施例中,与虚拟机建立直通连接的网卡还可以是物理网卡上一段物理地址范围,并且,将网卡上的这一段物理地址范围映射给虚拟机的驱动层,驱动层在发送数据时,将数据发送至网卡上相应的物理地址范围。在本发明实施例中,所述虚拟机的驱动层即为前述的前端网卡驱动的组成部分。
可选地,所述建立虚拟机与网卡之间的直通连接还包括:在所述网卡对应的物理地址范围内为所述虚拟机分配与所述虚拟机对应的目标物理地址范围,并将所述目标物理地址范围映射给所述虚拟机的驱动层。
在一个可选地实施例中,上述网卡为SR-IOV(Single Root I/O Virtualization)网卡,为虚拟机分配的目标物理地址范围及对应该SR-IOV网卡上的一个VF(Virtual Functions,虚拟功能)网卡。可选地,在主机上包含的物理网卡还可以是SR-IOV(Single Root I/O Virtualization,单根I/O虚拟化)网卡,即将物理网卡的一个PF(Physical Functions,物理功能)扩展出若干个VF,并且,每一个VF以一个独立网卡的形式呈现,有独立的PCI(Peripheral Component Interconnect,外设部件互连标准)配置区域和资源范围,并可以与其它VF共享同一个物理资源(共用同一个物理网口)。也就是说,将单一的物理网卡扩展出来的多个VF当成可选地网卡来进行部署,每一个VF对应了一个VF接口,每个VF接口都有单独的虚拟PCIe通道(即PCI-Express通道,也就是说,每一个VF对应的虚拟机与外部I/O设备之间独立的进行通信),这些虚拟的PCIe通道共用物理网卡的PCIe通道。每个虚拟机可占用一个或多个VF接口,这样虚拟机就可以直接访问自己的VF接口,即访问自己的虚拟网卡,而不需要VMM的协调干预。在此种情况下,虚拟机建立了与网卡的直通连接,即相当于建立与物 理网卡下的VF接口的直通连接,并且,该VF接口被当前的虚拟机所使用,可作为该虚拟机的专用接口,用于该虚拟机的数据快速收发。
步骤S104:检测所述虚拟机的驱动层发出的数据包。
在虚拟机上的应用程序或者***需要向网络或者其他虚拟机或设备发送数据时,会将相应的数据包发送给虚拟机的驱动层,由虚拟机的驱动层进行可选地处理,例如,将数据包发送给虚拟机的网卡驱动进行处理。在本步骤中,在检测到虚拟机的驱动层发出的数据包时,获取该发送的数据包,并获取与该数据包的包头信息。可选地,包头信息可以包括源虚拟机的地址、源虚拟机的端口、目的地地址/端口等。可选地,在数据包的包头信息中还可以包括TCP(Transmission Control Protocol,传输控制协议)等满足要求的协议,在本发明中不做限制。
步骤S106:向与所述虚拟机对应的虚拟机监控器发送封装参数获取请求,接收所述虚拟机监控器返回的封装信息和封装参数。
在本实施例中,虚拟机发送出的数据包的封装的是由虚拟机完成的,但是,虚拟机在对数据包进行封装的过程中可选地操作以及相应的参数是由主机上的虚拟机监控器(VMM)决定的。
可选地,在本实施例中,在虚拟机需要发送数据包时,向管理该虚拟机的虚拟机监控器请求与封装数据包对应的参数请求,即向虚拟机监控机发送封装参数获取请求。虚拟机监控器在接收到虚拟机发送的封装参数获取请求之后,根据封装参数获取请求中包含的虚拟机标识以及具体需要发送的数据包,确定相应的封装策略,并将与封装策略相关的数据返回给虚拟机,以供虚拟机对数据包进行封装。
可选地,在本实施例中,上述由虚拟机监控器确定的封装策略的相关数据包括了封装信息和封装参数。可选地,封装信息包括了是否进行封装、以及采用何种格式对数据包进行封装的封装格式;封装参数包括了源IP地址、源媒体访问控制(Media Access Control,MAC)地址、目的地IP地址、目的地MAC地址等发送数据时的必要信息,还包括了封装层采用的协议。
对于基于TCP/IP网络协议栈的数据包封装,主要是分为应用程序、传输层、网络层以及链路层的分层封装,在经过上述分层封装之后,数据被 封装成帧发送到网卡中进行传输,封装格式可以是上述任意一个层的格式,例如,网络层(IP层)的格式为GRE数据报文格式(Generic Routing Encapsulation,通用路由封装)或VXLAN数据报文格式(virtual Extensible LAN,虚拟可扩展局域网)。
步骤S108:根据所述封装信息和所述封装参数将所述数据包封装,将所述封装后的数据包通过所述直通连接添加到所述网卡的硬件发送队列进行发送。
在虚拟机接收到返回的封装信息以及封装参数之后,即可根据该封装信息和封装参数对数据包进行封装。
可选地,在封装信息中标识了不需要对当前需要发送的数据包进行封装时,只需要将相应的封装参数添加到该数据包的包头信息中即可完成对该数据包的封装。在另一个实施例中,若在封装信息中指示需要对数据包进行封装,并且使用GRE数据报文格式对当前需要发送的数据包进行封装时,即根据GRE数据报文格式的对数据包进行封装,并且将相应的封装参数封装到该数据包中对应的分层封装中。
在虚拟机将待发送的数据包进行封装之后,即将该封装后的数据包通过虚拟机与网卡之间的直通连接发送给网卡由网卡进行可选地发送;例如,封装后的数据包通过虚拟机与网卡之间的直通连接添加到网卡的硬件发送队列中,由网卡对硬件发送队列中的数据或数据包逐一进行发送。
在一个可选实施例中,若在建立虚拟机与网卡之间的直通连接时是通过在所述网卡对应的物理地址范围内为所述虚拟机分配与所述虚拟机对应的目标物理地址范围并将所述目标物理地址范围映射给所述虚拟机的驱动层来建立的,则在将数据添加到网卡的硬件发送队列时,是将数据发送至网卡上与该目标物理地址范围对应的硬件发送队列的。可选地,所述将所述封装后的数据包通过所述直通连接添加到所述网卡的硬件发送队列进行发送还包括:将所述封装后的数据包发送至所述网卡上的目标物理地址范围对应的硬件发送队列进行发送。
所述基于虚拟机的数据包发送方法,应用于网络设备中,所述网络设备包括:至少一个网卡及与所述网卡连接的至少一个处理器。
该网络设备包括一个或多个网卡,以及,一个或多个处理器。
网卡及处理器之间通过总线连接,例如,通过集成电路总线连接。
所述处理器,可为:中央处理器、微处理器、数字信号处理器、应用处理器、可编程阵列或专用集成电路等。
所述处理器可运行操作***、软件应用或计算机程序等计算机可执行代码,能够设置一个或多个虚拟机。所述网络设备内还设置有内存等存储器,可以通过总线与所述处理器连接。所述网卡可用于虚拟机利用第一模式和/或第二模式进行数据发送。
参考图3所示,图3展示了上述基于虚拟机的数据包接收方法,可选地该方法包括如下步骤S202-S208:
步骤S202:建立虚拟机与网卡之间的直通连接,相关操作,可参见步骤S102。
步骤S204:获取所述网卡的硬件接收队列中的数据包。
在本实施例中,在有其他虚拟机或者其他设备、服务器向当前虚拟机发送数据时,是将数据发送给与该虚拟机建立了直通连接的网卡,然后转而由该网卡将数据发送给虚拟机的驱动层。可选地,在存在发送给当前虚拟机对应的IP地址或者MAC地址的数据包时,将该数据包发送给网卡的硬件接收队列,由网卡根据硬件接收队列中的数据包一一进行接收处理。
在本实施例中,在网卡的硬件接收队列中存在数据包时,获取该数据包。需要说明的是,在本实施例中,由网卡的硬件接收队列中获取的数据包是封装了的数据包,也就是说,虚拟机需要对接收到是被封装了的数据包进行解封装操作。
在一个可选实施例中,若在建立虚拟机与网卡之间的直通连接时是通过在所述网卡对应的物理地址范围内为所述虚拟机分配与所述虚拟机对应的目标物理地址范围并将所述目标物理地址范围映射给所述虚拟机的驱动层来建立的,则在获取网卡的硬件接收队列中的数据包时,是从上述为虚拟机分配的网卡上的目标物理地址范围对应的硬件接收队列中获取的。可选地,所述获取所述网卡的硬件接收队列中的数据包还包括:获取所述网卡上的目标物理地址范围对应的硬件接收队列中的数据包。
步骤S206:向与所述虚拟机对应的虚拟机监控器发送解封装参数获取请求,获取所述虚拟机监控器返回的解封装信息和解封装参数。
在本实施例中,虚拟机接收的数据包的解封装的具体操作是由虚拟机完成的,但是,虚拟机在对数据包进行解封装的过程中可选地操作以及相应的参数是由主机上的虚拟机监控器(VMM)决定的。
可选地,在本实施例中,在虚拟机的网卡接收队列接收到数据包时,向管理该虚拟机的虚拟机监控器请求与解封装数据包对应的参数请求,即向虚拟机监控机发送解封装参数获取请求。虚拟机监控器在接收到虚拟机发送的解封装参数获取请求之后,根据解封装参数获取请求中包含的虚拟机标识以及具体接收到的数据包,确定相应的解封装策略,并将与解封装策略相关的数据返回给虚拟机,以供虚拟机对数据包解进行封装。
可选地,在本实施例中,上述由虚拟机监控器确定的解封装策略的相关数据包括了解封装信息和解封装参数。可选地,解封装信息包括了采用何种格式对数据包进行解封装的封装格式;解封装参数包括了源IP地址、源MAC地址、目的地IP地址、目的地MAC地址等对接收到的封装数据进行解封装的必要信息,还包括了封装层采用的协议。
步骤S208:根据所述解封装信息和所述解封装参数对所述获取到的数据包进行解封装,将所述解封装后的数据包发送到所述虚拟机的驱动层。
在虚拟机接收到返回的解封装信息以及解封装参数之后,即可根据该解封装信息和解封装参数对数据包进行解封装。针对已经解封装的数据包,即可由网卡将该数据包发送给虚拟机的驱动层,即网卡驱动,然后由驱动层发送给相应的应用层进行可选地处理。
所述基于虚拟机的数据包发送方法,应用于网络设备中,所述网络设备包括:至少一个网卡及与所述网卡连接的至少一个处理器。
该网络设备包括一个或多个网卡,以及,一个或多个处理器。
网卡及处理器之间通过总线连接,例如,通过集成电路总线连接。
所述处理器,可为:中央处理器、微处理器、数字信号处理器、应用处理器、可编程阵列或专用集成电路等。
所述处理器可运行操作***、软件应用或计算机程序等计算机可执行 代码,能够设置一个或多个虚拟机。所述网络设备内还设置有内存等存储器,可以通过总线与所述处理器连接。所述网卡可用于虚拟机利用第一模式和/或第二模式进行数据接收。
参考图4,图4给出了一种基于虚拟机的数据包发送和接收的***架构图。可选地,在主机上包括了一个虚拟机,还包括管理该虚拟机的虚拟机监控器(VMM),在主机上包含了物理网卡;在虚拟机上安装了与网卡对应的网卡驱动,并且,通过该网卡驱动与主机上的网卡直接进行通讯。可选地,在虚拟机上包含了前端管理模块,并具体包括了策略管理、通信前端、封/解数据包3个子模块。需要说明的是,该前端管理模块是放在虚拟机的网卡驱动下面的,即网卡驱动中即将发送到网卡的硬件发送队列和从硬件接收队列中接收数据包时,将数据包取出来,送往前端管理模块进行封装或解封装,然后再发送到网卡或者网卡的驱动层。而在主机侧,包括了后端管理模块,配置为处理虚拟机发送过来的请求并给予响应,例如,对虚拟机侧发送的封装参数获取请求或者解封装参数获取请求进行解析并给予对应的应答。
也就是说,将基于虚拟机的数据包的发送和接收过程中的控制面与数据面进行分离,在虚拟机侧至完成对数据包的封装和解封装,而可选地封装策略以及解封装策略依旧由主机侧完成。
此外,为解决现有技术中基于虚拟机的数据包的发送存在的***资源的有效利用率不足的技术问题,在本实施例中,还提出了一种基于虚拟机的数据包发送装置和一种基于虚拟机的数据包接收装置。
可选地,如图5所示,上述基于虚拟机的数据包发送装置包括直通连接建立模块102、数据包检测模块104、封装参数获取模块106、封装模块108,其中:
直通连接建立模块102,配置为建立虚拟机与网卡之间的直通连接;
数据包检测模块104,配置为检测所述虚拟机的驱动层发出的数据包;
封装参数获取模块106,配置为向与所述虚拟机对应的虚拟机监控器发送封装参数获取请求,接收所述虚拟机监控器返回的封装信息和封装参数;
封装模块108,配置为根据所述封装信息和所述封装参数将所述数据包封装,将所述封装后的数据包通过所述直通连接添加到所述网卡的硬件发送队列进行发送。
可选的,在一个实施例中,所述封装信息包括封装格式,所述封装格式包括数据包封装层的封装协议。
可选的,在一个实施例中,所述封装参数包括数据包封装层的IP地址和/或MAC地址。
可选的,在一个实施例中,所述直通连接建立模块102,还配置为在所述网卡对应的物理地址范围内为所述虚拟机分配与所述虚拟机对应的目标物理地址范围,并将所述目标物理地址范围映射给所述虚拟机的驱动层。
可选的,在一个实施例中,所述封装模块108,还配置为将所述封装后的数据包发送至所述网卡上的目标物理地址范围对应的硬件发送队列进行发送。
参考图6,图6展示了上述基于虚拟机的数据包接收装置的具体结构组成,如图6所示,该装置包括直通连接建立模块202、数据包获取模块204、解封装参数获取模块206、解封装模块208,其中:
直通连接建立模块202,配置为建立虚拟机与网卡之间的直通连接;
数据包获取模块204,配置为获取所述网卡的硬件接收队列中的数据包;
解封装参数获取模块206,配置为向与所述虚拟机对应的虚拟机监控器发送解封装参数获取请求,获取所述虚拟机监控器返回的解封装信息和解封装参数;
解封装模块208,配置为根据所述解封装信息和所述解封装参数对所述获取到的数据包进行解封装,将所述解封装后的数据包发送到所述虚拟机的驱动层。
可选的,在一个实施例中,所述解封装信息包括封装格式,所述封装格式包括数据包封装层的封装协议。
可选的,在一个实施例中,所述解封装参数包括数据包封装层的IP地 址和/或MAC地址。
可选的,在一个实施例中,所述直通连接建立模块202还用于:在所述网卡对应的物理地址范围内为所述虚拟机分配与所述虚拟机对应的目标物理地址范围,并将所述目标物理地址范围映射给所述虚拟机的驱动层。
可选的,在一个实施例中,所述解封装模块208还用于获取所述网卡上的目标物理地址范围对应的硬件接收队列中的数据包。
采用了上述基于虚拟机的数据发送和接收方法及装置之后,物理主机上的虚拟机建立与网卡之间的直通连接,虚拟机通过与该网卡之间的直通连接直接进行数据的发送和接收,而不需要经过主机上的网卡驱动的中转;并且,在虚拟机发送数据的过程中,需要向主机上的虚拟机监控器请求需要发送的数据对应的数据包封装参数,然后根据主机上的虚拟机监控器给出的封装参数对需要进行封装的数据进行封装之后再发送到网卡进行发送;在虚拟机的直通网卡接收的已经被封装的数据时,也需要向主机上的虚拟机监控器请求解封装参数之后才能根据虚拟机监控器给出的解封装参数对接收到的数据进行解封装,然后才能将该数据发送至虚拟机的驱动层。也就是说,在虚拟机侧通过建立与网卡之间的直通连接之后,可以自行完成对数据包的封装以及解封装,但是其对于数据包的封装和解封装的策略还是由主机侧完成的,即将数据包的收发的控制面和数据面进行了分离,其数据的发送和接收对于虚拟机来讲是透明的;对于物理主机来讲,在虚拟机进行数据包的发送或接收的过程中,不需要主机侧的网卡驱动进行多次的数据传输以及数据包的封装和解封装,减少了对于***资源尤其是对CPU资源的占用。
在一个实施例中,如图7所示,图7展示了一种运行上述基于虚拟机的数据包发送和接收方法的基于冯诺依曼体系的计算机***的终端。该计算机***可以是智能手机、平板电脑、掌上电脑、笔记本电脑或个人电脑等终端设备。可选地,可包括通过***总线连接的外部输入接口1001、处理器1002、存储器1003和输出接口1004。其中,外部输入接口1001可选的可至少包括网络接口10012。存储器1003可包括外存储器10032(例如硬盘、光盘或软盘等)和内存储器10034,在内存储器10034上包含有虚拟 机监控器VMM以及N各虚拟机VM-1、VM-2、……、VM-N,并且每一个虚拟机都对应有与之对应的网卡驱动DVM-1、DVM-2、……、DVM-N。输出接口1004可至少包括显示屏10042等设备。
在本实施例中,本方法的运行基于计算机程序,该计算机程序的程序文件存储于前述基于冯诺依曼体系的计算机***的外存储器10032中,在运行时被加载到内存储器10034中,然后被编译为机器码之后传递至处理器1002中执行,从而使得基于冯诺依曼体系的计算机***中形成逻辑上的直通连接建立模块102、数据包检测模块104、封装参数获取模块106、封装模块108和直通连接建立模块202、数据包获取模块204、解封装参数获取模块206、解封装模块208。且在上述基于虚拟机的数据包发送和接收方法执行过程中,输入的参数均通过外部输入接口1001接收,并传递至存储器1003中缓存,然后输入到处理器1002中进行处理,处理的结果数据或缓存于存储器1003中进行后续地处理,或被传递至输出接口1004进行输出。
本发明实施例提供一种计算机存储介质,所述计算机存储介质存储有计算机可执行代码,所述计算机可执行代码被执行后,能够一个或多个技术方案提供的基于虚拟机的数据包发送方法,或一个或多个技术方案提供的基于虚拟机的数据包接收方法。
所述计算机存储介质可为随机存储介质、只读存储介质、闪存、移动硬盘、光盘或磁带等各种计算机存储介质,可选为非瞬间存储介质。
所述计算机存储介质上的计算机可执行代码,可为:计算机程序或应用程序,被执行后可实现图2和/或图3所示的方法。
以上所揭露的仅为本发明较佳实施例而已,当然不能以此来限定本发明之权利范围,因此依本发明权利要求所作的等同变化,仍属本发明所涵盖的范围。
工业实用性
本发明实施例中虚拟机可以直接与网卡之间建立直通连接,虚拟机可以利用该直通连接与外部设备进行数据交互,这样数据不用主机侧的后端网卡驱动的中转、封装和解封装等操作,从而减少了主机侧占用CPU资源或内存资源等进行数据中转处理,从而降低了CPU的消耗,降低了数据收发因后端网卡驱动的处理导致的时延,减小了网卡受限于CPU或内存资源导致的资源有效使用率低的现象,提升数据收发速度及网卡有效使用率,具有积极的工业效果;且通过虚拟机的程序更改等简便的实现本发明实施例提供的技术方案,故具有工业上可实现性强,及工业上可推广范围大的特点。

Claims (19)

  1. 一种基于虚拟机的数据包发送方法,包括:
    建立虚拟机与网卡之间的直通连接;
    检测所述虚拟机的驱动层发出的数据包;
    向与所述虚拟机对应的虚拟机监控器发送封装参数获取请求,接收所述虚拟机监控器返回的封装信息和封装参数;
    根据所述封装信息和所述封装参数将所述数据包封装,将所述封装后的数据包通过所述直通连接添加到所述网卡的硬件发送队列进行发送。
  2. 根据权利要求1所述的基于虚拟机的数据包发送方法,其中,所述封装信息包括封装格式,所述封装格式包括数据包封装层的封装协议。
  3. 根据权利要求1所述的基于虚拟机的数据包发送方法,其中,所述封装参数包括数据包封装层的网络协议IP地址和/或媒体访问控制MAC地址。
  4. 根据权利要求1至3任一所述的基于虚拟机的数据包发送方法,其中,所述建立虚拟机与网卡之间的直通连接还包括:
    在所述网卡对应的物理地址范围内为所述虚拟机分配与所述虚拟机对应的目标物理地址范围,并将所述目标物理地址范围映射给所述虚拟机的驱动层。
  5. 根据权利要求4所述的基于虚拟机的数据包发送方法,其中,所述将所述封装后的数据包通过所述直通连接添加到所述网卡的硬件发送队列进行发送还包括:
    将所述封装后的数据包发送至所述网卡上的目标物理地址范围对应的硬件发送队列进行发送。
  6. 根据权利要求1至3任一项所述的基于虚拟机的数据包发送方法,其中,所述基于虚拟机的数据包发送方法,应用于网络设备中,所述网络设备包括:至少一个网卡及与所述网卡连接的至少一个处理器。
  7. 一种基于虚拟机的数据包发送装置,包括:
    直通连接建立模块,配置为建立虚拟机与网卡之间的直通连接;
    数据包检测模块,配置为检测所述虚拟机的驱动层发出的数据包;
    封装参数获取模块,配置为向与所述虚拟机对应的虚拟机监控器发送封装参数获取请求,接收所述虚拟机监控器返回的封装信息和封装参数;
    封装模块,配置为根据所述封装信息和所述封装参数将所述数据包封装,将所述封装后的数据包通过所述直通连接添加到所述网卡的硬件发送队列进行发送。
  8. 根据权利要求7所述的基于虚拟机的数据包发送装置,其中,所述封装信息包括封装格式,所述封装格式包括数据包封装层的封装协议;所述封装参数包括数据包封装层的IP地址和/或MAC地址。
  9. 根据权利要求7或8所述的基于虚拟机的数据包发送装置,其中,所述直通连接建立模块,还配置为在所述网卡对应的物理地址范围内为所述虚拟机分配与所述虚拟机对应的目标物理地址范围,并将所述目标物理地址范围映射给所述虚拟机的驱动层;
    所述封装模块,还配置为将所述封装后的数据包发送至所述网卡上的目标物理地址范围对应的硬件发送队列进行发送。
  10. 一种基于虚拟机的数据包接收方法,其中,包括:
    建立虚拟机与网卡之间的直通连接;
    获取所述网卡的硬件接收队列中的数据包;
    向与所述虚拟机对应的虚拟机监控器发送解封装参数获取请求,获取所述虚拟机监控器返回的解封装信息和解封装参数;
    根据所述解封装信息和所述解封装参数对所述获取到的数据包进行解封装,将所述解封装后的数据包发送到所述虚拟机的驱动层。
  11. 根据权利要求10所述的基于虚拟机的数据包接收方法,其中,所述解封装信息包括封装格式,所述封装格式包括数据包封装层的封装协议。
  12. 根据权利要求10所述的基于虚拟机的数据包接收方法,其中,所述解封装参数包括数据包封装层的IP地址和/或MAC地址。
  13. 根据权利要求10至12任一所述的基于虚拟机的数据包接收方法,其中,所述建立虚拟机与网卡之间的直通连接还包括:
    在所述网卡对应的物理地址范围内为所述虚拟机分配与所述虚拟机对 应的目标物理地址范围,并将所述目标物理地址范围映射给所述虚拟机的驱动层。
  14. 根据权利要求13所述的基于虚拟机的数据包接收方法,其中,所述获取所述网卡的硬件接收队列中的数据包还包括:
    获取所述网卡上的目标物理地址范围对应的硬件接收队列中的数据包。
  15. 根据权利要求10至12任一所述的基于虚拟机的数据包接收方法,其中,所述基于虚拟机的数据包接收方法应用于网络设备中,所述网络设备包括:至少一个网卡及与所述网卡连接的至少一个处理器。
  16. 一种基于虚拟机的数据包接收装置,其中,包括:
    直通连接建立模块,配置为建立虚拟机与网卡之间的直通连接;
    数据包获取模块,配置为获取所述网卡的硬件接收队列中的数据包;
    解封装参数获取模块,配置为向与所述虚拟机对应的虚拟机监控器发送解封装参数获取请求,获取所述虚拟机监控器返回的解封装信息和解封装参数;
    解封装模块,配置为装,将所述解封装后的数据包发送到所述虚拟机的驱动层。
  17. 根据权利要求16所述的基于虚拟机的数据包接收装置,其中,所述解封装信息包括封装格式,所述封装格式包括数据包封装层的封装协议;所述解封装参数包括数据包封装层的IP地址和/或MAC地址。
  18. 根据权利要求16或17所述的基于虚拟机的数据包接收装置,其中,所述直通连接建立模块还用于在所述网卡对应的物理地址范围内为所述虚拟机分配与所述虚拟机对应的目标物理地址范围,并将所述目标物理地址范围映射给所述虚拟机的驱动层;所述解封装模块还用于获取所述网卡上的目标物理地址范围对应的硬件接收队列中的数据包。
  19. 一种计算机存储介质,所述计算机存储介质存储有计算机可执行代码,所述计算机可执行代码被执行后,能够实现权利要求1至6或10至15任一项提供的方法。
PCT/CN2017/116898 2016-12-21 2017-12-18 基于虚拟机的数据包发送和接收方法及装置 WO2018113622A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US16/359,036 US11048535B2 (en) 2016-12-21 2019-03-20 Method and apparatus for transmitting data packet based on virtual machine

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201611190729.5A CN108228309B (zh) 2016-12-21 2016-12-21 基于虚拟机的数据包发送和接收方法及装置
CN201611190729.5 2016-12-21

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US16/359,036 Continuation US11048535B2 (en) 2016-12-21 2019-03-20 Method and apparatus for transmitting data packet based on virtual machine

Publications (1)

Publication Number Publication Date
WO2018113622A1 true WO2018113622A1 (zh) 2018-06-28

Family

ID=62624531

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/116898 WO2018113622A1 (zh) 2016-12-21 2017-12-18 基于虚拟机的数据包发送和接收方法及装置

Country Status (3)

Country Link
US (1) US11048535B2 (zh)
CN (1) CN108228309B (zh)
WO (1) WO2018113622A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112929419A (zh) * 2021-01-22 2021-06-08 苏州浪潮智能科技有限公司 一种数据包传输方法、装置、电子设备及可读存储介质

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111147369B (zh) * 2018-11-05 2022-02-08 中国电信股份有限公司 路由***、路由方法和服务器
CN112118594A (zh) * 2020-08-07 2020-12-22 深圳市圣麾科技有限公司 数据上传方法、下载方法、电子设备及存储介质
CN114765631A (zh) * 2021-01-14 2022-07-19 华为技术有限公司 数据传输***、数据传输方法以及网络设备
CN113259994B (zh) * 2021-04-20 2023-08-01 深圳震有科技股份有限公司 5g虚拟网元控制网卡收发数据包方法、设备及存储介质
CN115002087A (zh) * 2022-05-31 2022-09-02 济南浪潮数据技术有限公司 一种音视频数据传输方法、***、装置及存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101557420A (zh) * 2009-03-31 2009-10-14 北京航空航天大学 虚拟机监控器高效网络通信的实现方法
CN102291428A (zh) * 2010-06-21 2011-12-21 英特尔公司 用于在多个虚拟机之间共享网络接口的方法
CN102609298A (zh) * 2012-01-11 2012-07-25 中国科学技术大学苏州研究院 基于硬件队列扩展的网卡虚拟化***及其方法
CN103200085A (zh) * 2013-04-16 2013-07-10 中航网信(北京)科技有限公司 一种实现vxlan报文线速收发的方法及***
US20160170782A1 (en) * 2012-06-28 2016-06-16 Amazon Technologies, Inc. Network policy implementation with multiple interfaces

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020124095A1 (en) * 2001-03-02 2002-09-05 Sultan Israel Daniel Apparatus and method for sending point-to-point protocol over ethernet
US20050195809A1 (en) * 2004-03-05 2005-09-08 Zanaty Farouk M. SS7 full duplex transverser
CN101459618B (zh) * 2009-01-06 2011-01-19 北京航空航天大学 虚拟机网络的数据包转发方法和装置
US8856407B2 (en) * 2011-11-23 2014-10-07 Red Hat, Inc. USB redirection for write streams
KR20130074401A (ko) * 2011-12-26 2013-07-04 삼성전자주식회사 계층적 스케줄러를 갖는 멀티코어 기반의 컴퓨팅 장치 및 계층적 스케줄 방법
CN103200128B (zh) * 2013-04-01 2016-12-28 华为技术有限公司 一种网络包处理的方法、装置和***
CN103473136B (zh) * 2013-09-02 2017-06-13 华为技术有限公司 一种虚拟机的资源配置方法和通信设备
KR20150135966A (ko) * 2014-05-26 2015-12-04 한국전자통신연구원 가상 데스크탑 서비스 시스템 및 그것의 가상 데스크탑 서비스 제공 방법
CN104883302B (zh) * 2015-03-18 2018-11-09 华为技术有限公司 一种数据包转发的方法、装置及***

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101557420A (zh) * 2009-03-31 2009-10-14 北京航空航天大学 虚拟机监控器高效网络通信的实现方法
CN102291428A (zh) * 2010-06-21 2011-12-21 英特尔公司 用于在多个虚拟机之间共享网络接口的方法
CN102609298A (zh) * 2012-01-11 2012-07-25 中国科学技术大学苏州研究院 基于硬件队列扩展的网卡虚拟化***及其方法
US20160170782A1 (en) * 2012-06-28 2016-06-16 Amazon Technologies, Inc. Network policy implementation with multiple interfaces
CN103200085A (zh) * 2013-04-16 2013-07-10 中航网信(北京)科技有限公司 一种实现vxlan报文线速收发的方法及***

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112929419A (zh) * 2021-01-22 2021-06-08 苏州浪潮智能科技有限公司 一种数据包传输方法、装置、电子设备及可读存储介质

Also Published As

Publication number Publication date
CN108228309B (zh) 2021-11-23
CN108228309A (zh) 2018-06-29
US20190220296A1 (en) 2019-07-18
US11048535B2 (en) 2021-06-29

Similar Documents

Publication Publication Date Title
WO2018113622A1 (zh) 基于虚拟机的数据包发送和接收方法及装置
US11005755B2 (en) Packet processing method in cloud computing system, host, and system
US10567275B2 (en) Network interface card switching for virtual networks
US11086650B2 (en) Technologies for application-specific network acceleration with unified coherency domain
US7996569B2 (en) Method and system for zero copy in a virtualized network environment
US11531752B2 (en) Technologies for control plane separation in a network interface controller
CN113326228B (zh) 基于远程直接数据存储的报文转发方法、装置及设备
WO2018023498A1 (zh) 网络接口卡、计算设备以及数据包处理方法
US20130044629A1 (en) Virtual network overlays and methods of forming thereof
US11593140B2 (en) Smart network interface card for smart I/O
CN111756791A (zh) 用于加速的功能即服务的网络设备负载平衡器的技术
US7751401B2 (en) Method and apparatus to provide virtual toe interface with fail-over
US11487567B2 (en) Techniques for network packet classification, transmission and receipt
US11669468B2 (en) Interconnect module for smart I/O
US20120093035A1 (en) Unified fabric port
US9515963B2 (en) Universal network interface controller
WO2016184283A1 (zh) 一种虚拟机数据流管理方法和***
US8478877B2 (en) Architecture-aware allocation of network buffers
US11575620B2 (en) Queue-to-port allocation
WO2018057165A1 (en) Technologies for dynamically transitioning network traffic host buffer queues
CN112291259A (zh) 一种协议转换方法、网关、设备及可读存储介质
US20140282551A1 (en) Network virtualization via i/o interface

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17883342

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17883342

Country of ref document: EP

Kind code of ref document: A1