A method and device for sending a message
By determining the mapping relationship between light-loaded physical ports and queues in the virtual network card, and giving priority to using light-loaded ports to send messages, the problem that the virtual network card cannot effectively achieve physical port load balancing is solved, and transmission efficiency and bandwidth utilization are improved.
Patent Information
- Application Number
- CN202210349326.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-01
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2042-04-01
AI Technical Summary
The existing technology cannot effectively achieve load balancing of physical ports when the virtual network card takes out packets from the queue, resulting in increased delay on heavily loaded ports, traffic congestion, low transmission rates on lightly loaded ports, and failure to reach the upper bandwidth limit.
By determining the light-loaded physical port that meets the preset conditions as the target port, and based on the mapping relationship between the physical port and the queue, packets are taken out of the target queue and sent. The light-loaded port is used first, and the sending of packets through the heavy-loaded port is postponed. Implement load balancing of physical ports.
It improves the transmission rate of lightly loaded physical ports, reaches the bandwidth limit, alleviates transmission delays and congestion, achieves load balancing between physical ports, and reduces the occupation of the cache area.
Smart Images

Figure CN114666276B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and more specifically, to a method and device for sending a message. Background Art
[0002] With the continuous development of computer technology, more and more users use virtual network cards in virtual machines (VMs) to send messages. When sending messages, the virtual network card takes the message from the queue used to temporarily store messages in the virtual machine memory, sends the message to the physical network card, and reaches the physical network through one of the multiple physical ports of the physical network card.
[0003] Currently, after taking out a message from the queue, the virtual network card will put the taken message in the cache area of the virtual network card, calculate the hash value through the five-tuple carried by the message, and determine which physical port of the physical network card the message is sent from based on the hash value. However, since the virtual network card blindly takes messages from the queue, the message may be sent to the overloaded physical port, which increases the delay of the overloaded physical port and causes traffic congestion; while the lightly loaded physical port may not have reached the bandwidth limit, and the load of the physical port is unbalanced.
[0004] Therefore, how to achieve load balancing of physical ports has become a technical problem that needs to be solved urgently. Summary of the invention
[0005] The present application provides a method and device for sending a message, so as to achieve load balancing of a physical port.
[0006] In a first aspect, the present application provides a method for sending a message, the method comprising: determining a target port that meets preset conditions from multiple physical ports of a physical network card; based on a mapping relationship between multiple physical ports and multiple queues, determining a target queue corresponding to the target port, one or more queues in the multiple queues correspond to a physical port in the multiple physical ports, and the multiple queues are used to cache messages to be sent; and sending the message in the target queue through the target port.
[0007] Based on the above scheme, when the virtual network card needs to send a message, it can exclude the overloaded physical port from multiple physical ports according to the load conditions and preset conditions of each port of the physical network card, determine the lightly loaded physical port as the target port, and determine the target queue corresponding to the target port according to the mapping relationship between multiple physical ports and multiple queues, and take out the message from the target queue and send it through the target port. Since the lightly loaded physical port is determined first, and there is a mapping relationship between the physical port and the queue, the virtual network card can take the message from the corresponding queue based on the determined lightly loaded physical port to send. On the one hand, the traffic of the lightly loaded physical port can be increased, and its transmission rate can be increased to reach the bandwidth limit. On the other hand, the sending of messages through the overloaded physical port can be temporarily postponed, avoiding further aggravation of transmission delay and congestion. In summary, the bandwidth of each physical port can reach the upper limit, and the transmission delay and congestion are alleviated, and load balancing between physical ports is achieved.
[0008] Optionally, the preset condition includes: the number of accumulated messages is less than a preset threshold.
[0009] Optionally, the preset condition includes: within a unit time, a rate at which packets enter the physical port is higher than a rate at which packets are sent from the physical port.
[0010] Optionally, the method further includes: acquiring a mapping relationship between multiple physical ports and multiple queues.
[0011] Optionally, the method further includes: adjusting a mapping relationship between the multiple physical ports and the multiple queues according to the number of packets in each of the multiple queues.
[0012] In a second aspect, the present application provides a device for sending a message, including a module or unit for implementing the method in the first aspect and any possible implementation of the first aspect. It should be understood that each module or unit can implement the corresponding function by executing a computer program.
[0013] In a third aspect, the present application provides a device for sending a message, the device comprising a processor, the processor being coupled to a memory and being capable of executing a computer program in the memory to implement the method in the first aspect and any possible implementation of the first aspect.
[0014] Optionally, the device for sending a message may further include a memory for storing computer-readable instructions, and the processor reads the computer-readable instructions so that the device for sending a message can implement the method in the above-mentioned first aspect and any possible implementation manner of the first aspect.
[0015] Optionally, the device for sending messages may further include a communication interface, and the communication interface is used to communicate with the device and other devices. Exemplarily, the communication interface may be a transceiver, circuit, bus, module or other type of communication interface.
[0016] In a fourth aspect, the present application provides a chip system comprising at least one processor for supporting the implementation of the functions involved in the above-mentioned first aspect and any possible implementation method of the first aspect, such as processing the determination of the target port and target queue involved in the above-mentioned method.
[0017] In one possible design, the chip system also includes a memory, which is used to store program instructions and data, and the memory is located inside or outside the processor.
[0018] The chip system may be composed of a chip, or may include a chip and other discrete devices.
[0019] In a fifth aspect, the present application provides an electronic device comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method in the above-mentioned first aspect and any possible implementation manner of the first aspect when executing the computer program.
[0020] In a sixth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the processor implements the method in the above-mentioned first aspect and any possible implementation manner of the first aspect.
[0021] It should be understood that the second to sixth aspects of the present application correspond to the technical solutions of the first aspect of the present application, and the beneficial effects achieved by each aspect and the corresponding feasible implementation methods are similar and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 It is a schematic diagram of the network architecture provided by the embodiment of the present application;
[0023] Figure 2 is a schematic flow chart of a method for sending a message provided in an embodiment of the present application;
[0024] Figure 3 is a schematic block diagram of a device for sending a message provided in an embodiment of the present application;
[0025] Figure 4 It is another schematic diagram of a block diagram of a device for sending a message provided in an embodiment of the present application. DETAILED DESCRIPTION
[0026] The technical solution in this application will be described below in conjunction with the accompanying drawings.
[0027] To facilitate understanding of the embodiments of the present application, the relevant terms involved in the present application are briefly explained below.
[0028] 1. A virtual machine is a complete computer system that simulates the functions of a complete hardware system through software and runs in a completely isolated environment. Any work that can be done in a physical computer can be done in a virtual machine. Virtual machines make every cloud computing user think that they have an independent hardware environment. One or more virtual machines can be built on a cloud server. Different operating systems and application layer software can be installed on each virtual machine based on different user needs.
[0029] 2. Virtual switch is widely used in Internet services based on infrastructure as a service. Through the virtual switch running on the virtualization platform, the virtual machine built on the server is provided with Layer 2 network access and some Layer 3 network functions. The virtual machine connects to the network through the virtual switch, and the virtual switch connects to the external network through the physical network card on the physical host as the uplink. Each virtual switch contains a certain number of ports that can be used to connect to the virtual network card or the physical network card.
[0030] 3. Hypervisor is a software layer installed on physical hardware. It can divide a physical machine into many virtual machines through virtualization. In this way, multiple operating systems can run simultaneously on one physical hardware. Hypervisor is responsible for managing and allocating system resources to virtual machines.
[0031] 4. A physical network card, commonly known as a network card, is a piece of computer hardware designed to allow computers to communicate on a computer network. A network card is a network component that works at the physical layer. It is an interface that connects a computer and a transmission medium in a local area network. It can not only achieve physical connection and electrical signal matching with the local area network transmission medium, but also involves the sending and receiving of frames, the encapsulation and unpacking of frames, media access control, data encoding and decoding, and data caching functions. A processor (central processing unit, CPU) and memory are installed on the network card. The memory includes read-only memory (ROM) and random access memory (RAM). The communication between the network card and the local area network is carried out in a serial transmission mode through a cable or twisted pair, while the communication between the network card and the computer is carried out in a parallel transmission mode through the I / O bus on the computer motherboard. Therefore, an important function of the network card is to perform serial / parallel conversion. Since the data rate on the network is different from the data rate on the computer bus, a storage chip for caching data is installed in the network card. The physical network card may include multiple physical ports, and the sending and receiving of messages are realized through the physical ports.
[0032] It should be understood that data rate generally refers to data transfer rate, which refers to the speed of transmitting information on a communication line, the number of bits transmitted per unit time (usually one second). Each physical network card may include at least one physical port, and a message may be sent to a physical network via the physical port.
[0033] 5. A virtual network card, also called a virtual network adapter, is a software that simulates a network environment and a network adapter. A virtual network card can establish a local area network between remote computers, simulate a hub function, and implement the function of a virtual private network (VPN), so that the system recognizes the software as a network card. Like a physical network card, a virtual network card may include a cache area that can be used to cache data. For example, in an embodiment of the present application, the cache area can be used to cache the mapping relationship between multiple physical ports and multiple queues, as well as messages obtained from the queue and about to be sent to the physical port. What the virtual network card exposes to the virtual machine is the virtual network card interface.
[0034] The function of the virtual network card can be implemented by software, hardware, or a combination of software and hardware. The function of the virtual network card in the embodiment of the present application can be implemented by a physical network card, which can be a board card (such as a printed circuit board (PCB)) inserted into a physical device. The board card includes a chip, and the chip can implement the method described in the following embodiment by executing a computer program or by a logic circuit or integrated circuit solidified on the chip. 6. Queue, used to temporarily store messages for communication between the host and the network card. In the embodiment of the present application, it may refer to an area in the memory of the virtual machine, used to temporarily store messages for communication between the virtual machine and the virtual network card, for example, including messages sent by the application layer software, and / or, messages received from other devices from the physical network, etc. Based on different sending directions, queues can also be divided into sending queues and receiving queues. Multiple queues can be created in the memory of each virtual machine, and different queues can be distinguished by different identifiers.
[0035] It should be understood that the queue can be regarded as a communication interface between the application layer software and the virtual network card, and the access of the message can follow the first in first out (FIFO) principle.
[0036] 7. A physical switch is a network device used for forwarding electrical (optical) signals. It can provide an exclusive electrical signal path for any two network nodes connected to the switch and can transmit messages sent by the physical network card to the physical network.
[0037] 8. The physical network is a network formed by connecting various physical devices (such as hosts, routers, switches, etc.) and media (such as optical cables, cables, twisted pairs, etc.) in the network. The physical network is the underlying network carried by the Internet and is the first layer of the seven-layer architecture of the open system interconnection reference model (OSI). It should be understood that OSI provides a functional structure framework for open interconnected information systems. From low to high, it is: physical layer, data link layer, network layer, transport layer, session layer, presentation layer and application layer.
[0038] Figure 1 This is a schematic diagram of a network architecture applicable to the embodiment of the present application. Figure 1 As shown, the network architecture may include: a virtual machine, a virtual switch and a physical switch. The virtual machine and the virtual switch are connected through a virtual network card on the virtual machine and a port on the virtual switch, and the virtual switch and the physical switch are connected through a physical network card.
[0039] One or more virtual machines are built on the server, such as Figure 1As shown, a virtual machine 1 and a virtual machine 2 may be constructed, and different application layer software may be installed on the virtual machine 1 and the virtual machine 2. Messages may be generated and sent through the application layer software.
[0040] Multiple queues can be created in the memory of each virtual machine. Taking virtual machine 2 as an example, virtual machine 2 creates four queues, namely queue 0, queue 1, queue 2 and queue 3, which are used to temporarily store the messages sent by the application layer software in the virtual machine. In addition, each virtual machine can have at least one virtual network card, such as Figure 1 As shown, virtual machine 1 has one virtual network card, and virtual machine 2 has two virtual network cards. Each virtual network card has a corresponding buffer area for temporarily storing messages taken out of the queue.
[0041] The virtual switch includes multiple ports that can be used to connect to virtual network cards or physical network cards to achieve multi-layer data forwarding. Figure 1 As shown, the message sent by the virtual network card can be sent to the physical network card via the port of the virtual switch.
[0042] A physical network card can include multiple physical ports. Figure 1 As shown, the physical network card may include three ports, namely physical port 0, physical port 1 and physical port 2. The message sent to the physical network card can be sent to the physical switch through the physical port on the physical network card, and then the message is sent to the physical network through the physical switch. It should be understood that the number of physical ports of each physical network card can be the same or different.
[0043] It should be understood that the hypervisor is responsible for managing virtual machine 1 and virtual machine 2 and allocating system resources to virtual machine 1 and virtual machine 2.
[0044] Users can send packets through the application layer software in the virtual machine. The messages sent by the application layer software will be temporarily stored in the queue in the virtual machine's memory. The messages in the queue are waiting to be processed or sent. When sending messages, the virtual network card can take the message from the queue according to the FIFO principle, send the message through the port of the virtual switch to the physical port of the physical network card, and send the message through a physical port. In this way, the message can be sent to the physical network through the physical switch.
[0045] It should be understood that this application does not specifically limit the number of constructed virtual machines, the number of virtual network cards, the number of ports of virtual switches, the number of physical network cards, the number of physical ports, and the number of queues, which can all be set by technical personnel in this field according to actual needs.
[0046] At present, after taking out a message from a queue, the virtual network card will place the taken-out message in a buffer area, and calculate the hash value through the five-tuple carried by the message to determine from which physical port of the physical network card the message is sent. However, since the virtual network card blindly takes messages from the queue, it can only determine which physical port the message is to be sent to after taking out the message and calculating the hash value. If it is determined that the message is sent to an overloaded physical port (assuming that the number of messages queued for sending at physical port 1 is already large, exceeding the carrying capacity of physical port 1), it may cause traffic congestion and increase the delay of the overloaded physical port. For lightly loaded physical ports (assuming that the number of messages queued for sending at physical port 0 and physical port 2 is small, far from reaching the carrying capacity of physical port 0 and physical port 2), the transmission rate will be low and cannot reach the bandwidth limit. Therefore, the current method of sending messages cannot effectively achieve load balancing of physical ports. In addition, placing messages in the buffer area will occupy the cache. Once the cache is full, it is impossible to continue to take messages from the queue to send, which reduces the efficiency of message sending.
[0047] In view of this, the present application provides a message sending method. When a virtual network card needs to send a message, it can exclude an overloaded physical port from multiple physical ports according to preset conditions, determine a lightly loaded physical port as a target port, and determine a target queue corresponding to the target port according to a mapping relationship between multiple physical ports and multiple queues, and take out a message from the target queue and send it via the target port. Since the lightly loaded physical port is determined first, and there is a mapping relationship between the physical port and the queue, the virtual network card can take a message from the corresponding queue to send it based on the determined lightly loaded physical port. On the one hand, the traffic of the lightly loaded physical port can be increased, and its transmission rate can be increased to reach the bandwidth upper limit. On the other hand, the sending of messages through the overloaded physical port can be temporarily suspended, avoiding further aggravation of transmission delay and congestion. Therefore, the bandwidth of each physical port can reach the upper limit, and the transmission delay and congestion are alleviated, and load balancing between physical ports is achieved. In addition, the message taken out of the queue does not need to pass through the buffer area of the virtual network card, avoiding the occupation of the buffer area.
[0048] The method for sending a message provided in an embodiment of the present application will be described in detail below with reference to the accompanying drawings.
[0049] See also Figure 2 , Figure 2 It is a schematic flow chart of the method for sending a message provided in an embodiment of the present application. It should be understood that Figure 2 The method 200 shown can be executed by a virtual network card, or by a physical device that can provide virtual network card functions (such as a server, etc.), or by a component configured in a physical device (such as a chip, a chip system, etc.), or by a module that can implement part or all of the virtual network card functions, etc.
[0050] When the method 200 is executed by a physical device, the physical device may be, for example, a server. For example, virtualization may be performed on the basis of a physical network card of the server to obtain one or more virtual network cards, which may be exposed to the user. In addition, the physical device may implement the functions performed by the virtual network card in the following embodiments by executing a computer program or the like, to provide services to the user, so as to achieve load balancing of the physical port.
[0051] For the convenience of explanation, the method provided in the embodiment of the present application is described below using a virtual network card as an example.
[0052] It should also be understood that Figure 2 The method 200 shown may be applied on a cloud server.
[0053] Method 200 may include steps 201 to 203. Figure 2 The various steps in the method 200 are shown.
[0054] Step 201 : determining a target port whose load condition meets a preset condition from a plurality of physical ports of a physical network card.
[0055] The virtual network card can collect statistics on the load conditions of each physical port of the physical network card, and use preset conditions to first determine a lightly loaded physical port as a target port. The number of the target ports can be one or more.
[0056] Two examples of preset conditions are exemplarily given below.
[0057] In one example, the preset condition includes: the number of accumulated messages is less than a preset threshold. Accordingly, the target port is a physical port where the number of accumulated messages is less than the preset threshold.
[0058] The preset threshold is a critical value used to determine whether a physical port is a heavy-loaded port or a light-loaded port. Each physical port may correspond to a preset threshold, and the preset thresholds of each physical port may be the same or different. It should be understood that those skilled in the art may set the specific value of the preset threshold according to actual needs, and this application does not limit this.
[0059] The virtual network card can count the number of messages accumulated at each physical port of the physical network card, and determine whether the physical port is overloaded or lightly loaded in combination with the preset threshold of each physical port. When the number of messages accumulated at the physical port is greater than or equal to the preset threshold, it is an overloaded port; when the number of messages accumulated at the physical port is less than the preset threshold, it is a lightly loaded port. The physical ports where the number of messages accumulated at the port is less than the preset threshold are screened out, that is, the lightly loaded ports are used as target ports.
[0060] For example, suppose the preset threshold of physical port 0 is 100 messages, the preset threshold of physical port 1 is 250 messages, and the preset threshold of physical port 2 is 250 messages. The virtual network card counts the number of messages accumulated at the three physical ports and finds that the number of messages accumulated at physical port 0 is 80, the number of messages accumulated at physical port 1 is 300, and the number of messages accumulated at physical port 2 is 200. Therefore, physical port 0 and physical port 2 can be used as target physical ports.
[0061] In another example, the preset condition includes: within a unit time, the rate at which packets enter the physical port is higher than the rate at which packets are sent from the physical port. Accordingly, the target port is a physical port at which the rate at which packets enter the physical port is higher than the rate at which packets are sent from the physical port within a unit time.
[0062] The virtual network card can determine whether the physical port is overloaded or lightly loaded by the relationship between the rate at which messages enter the physical port and the rate at which messages are sent from the physical port. When the rate at which messages enter the physical port is lower than the rate at which messages are sent from the physical port, it indicates that port delay has occurred and the port is an overloaded port; when the rate at which messages enter the physical port is higher than the rate at which messages are sent from the physical port, it indicates that there is no port delay and the port is a lightly loaded port, and these ports can be used as target ports. It should be understood that when the rate at which messages enter the physical port is equal to the rate at which messages are sent from the physical port, it indicates that the physical port is in a critical state between overload and light load and is not used as a target port.
[0063] For example, within 1 second, the rate at which packets enter physical port 0 is 1500 bits per second (BPS), and the rate at which packets are sent from physical port 0 is 1000bps; the rate at which packets enter physical port 1 is 2000bps, and the rate at which packets are sent from physical port 1 is 2200bps; the rate at which packets enter physical port 2 is 1700bps, and the rate at which packets are sent from physical port 2 is 900bps. Therefore, physical port 0 and physical port 2 can be used as target physical ports. It should be understood that bit rate refers to the number of bits transmitted per unit time.
[0064] The number of target ports determined by the virtual network card may be one or more.
[0065] It should be understood that when each physical port of the physical network card does not meet the preset conditions, there is no target port. In this case, the message may not be taken from the queue for transmission temporarily.
[0066] Step 202: Determine a target queue corresponding to a target port based on a mapping relationship between multiple physical ports and multiple queues.
[0067] One or more queues among the multiple queues correspond to a physical port among the multiple physical ports, and the multiple queues are used to buffer messages to be sent. That is, each physical port may correspond to one or more queues.
[0068] The mapping relationship between the physical port and the queue may specifically be a mapping relationship between the physical port number and the queue identifier (identity document, ID).
[0069] Two ways of expressing the mapping relationship are given as examples below.
[0070] In one example, when the queue identification IDs of the virtual machines are different, for example, the queue IDs in virtual machine 2 are: queue 0, queue 1, queue 2 and queue 3, and the queue IDs in virtual machine 1 are: queue 4, queue 5, queue 6 and queue 7. Therefore, a mapping relationship between the queue ID and the physical port number can be established.
[0071] In another example, when the queue IDs in different virtual machines are the same, for example, the queue IDs in one virtual machine are: queue 0, queue 1, queue 2, and queue 3, and the queue IDs in another virtual machine are also: queue 0, queue 1, queue 2, and queue 3. Then, different IDs can be set for different virtual machines, for example, the ID of one virtual machine is set to virtual machine 1, and the ID of another virtual machine is set to virtual machine 2. Then, the identity of the queue can be identified by the virtual machine ID and the queue ID. Therefore, a mapping relationship between the virtual machine ID, the queue ID, and the physical port number can be established.
[0072] The virtual network card can determine the target queue corresponding to the target port based on the created mapping relationship. For example, for virtual machine 2, the created mapping relationship is: physical port 0 corresponds to queue 0 and queue 3, physical port 1 corresponds to queue 1, and physical port 2 corresponds to queue 2. Assuming that the target ports determined by the virtual network card are physical port 0 and physical port 2, the target queues corresponding to physical port 0 are queue 0 and queue 3, and the target queue corresponding to physical port 2 is queue 2.
[0073] As mentioned above, the number of the target port may be one or more. Based on the above mapping relationship, the number of the target queues corresponding to the target port may also be one or more.
[0074] Optionally, the method further includes: acquiring a mapping relationship between multiple physical ports and multiple queues.
[0075] The virtual network card can obtain the mapping relationship in the following two ways:
[0076] One possible implementation manner is that the virtual network card obtains a pre-configured mapping relationship.
[0077] For example, when creating a virtual network card, the mapping relationship between multiple queues and multiple physical ports can be configured according to the queues in the virtual machine and the physical ports in the physical network card, and saved locally. When the virtual network card needs to use the mapping relationship, the above mapping relationship can be obtained locally. This method allows the virtual network card to quickly determine the target queue of the target port and improve the speed of message sending.
[0078] In a specific implementation, the virtual network card may establish a mapping relationship according to the modulus of the queue identification ID divided by the number of physical ports.
[0079] by Figure 1 Take the queues and physical ports in virtual machine 2 shown in as an example. When determining the physical port corresponding to queue 0, the queue ID 0 is divided by the number of physical ports 3, and the remainder is 0, then the physical port corresponding to queue 0 is physical port 0; when determining the physical port corresponding to queue 1, the queue ID 1 is divided by the number of physical ports 3, and the remainder is 1, then the physical port corresponding to queue 1 is physical port 1; when determining the physical port corresponding to queue 2, the queue ID 2 is divided by the number of physical ports 3, and the remainder is 2, then the physical port corresponding to queue 2 is physical port 2; when determining the physical port corresponding to queue 3, the queue ID 3 is divided by the number of physical ports 3, and the remainder is 0, then the physical port corresponding to queue 3 is physical port 0. Therefore, the mapping relationship between each queue and each physical port can be obtained.
[0080] It should be understood that the queues that can participate in establishing the mapping relationship are queues that temporarily store messages, and empty queues that do not temporarily store messages in the queues may not participate in establishing the mapping relationship. For example, when queue 3 is an empty queue, only the mapping relationship between queue 0 and queue 2 and physical port 0 and physical port 2 can be established, and the mapping relationship between queue 3 and the physical port is not established.
[0081] Another possible implementation manner is that the virtual network card temporarily creates a mapping relationship.
[0082] When sending a message, the virtual network card can also temporarily create a mapping relationship based on the queue with messages to be sent and the physical port in the physical network card. The mapping relationship created in this way is more in line with the current actual situation and can more effectively achieve load balancing of the physical port.
[0083] Since the number of messages in each queue will change in real time, the load of each physical port will also change, so the above mapping relationship can be adjusted.
[0084] Optionally, the method further includes: adjusting a mapping relationship between the multiple physical ports and the multiple queues according to the number of packets in each of the multiple queues.
[0085] One possible scenario is to add a mapping relationship. After the mapping relationship has been created, if the virtual network card finds that there is a new queue in the memory of the virtual machine, it can collect statistics on the load conditions at each physical port of the physical network card, determine the physical port with the smallest load, and establish a mapping relationship between the new queue and the physical port to adjust the mapping relationship. Alternatively, the virtual network card can still establish a mapping relationship between the new queue and the physical port by dividing the queue ID by the number of physical ports and taking the remainder.
[0086] It should be understood that the newly added queue is a newly added queue that needs to send messages, and messages are temporarily stored in the newly added queue. That is, the newly added queue can be a newly added queue. For example, on the basis of the existing queues 0 to 4, queue 5 is additionally created, and messages are temporarily stored in queue 5, then queue 5 is a newly added queue. Alternatively, the newly added queue can be an existing queue that was previously an empty queue. For example, queue 3 was previously an empty queue, and no mapping relationship with the physical port was established. However, at a certain moment, queue 3 temporarily stores messages that need to be sent, then the virtual network card can use queue 3 as a newly added queue to establish a mapping relationship with the physical port.
[0087] Another possible situation is to release the mapping relationship. After the mapping relationship has been created, if the virtual network card finds that a queue is continuously empty within a preset time, the mapping relationship between the queue and the corresponding physical port can be released.
[0088] Another possible situation is to change the mapping relationship between the queue and the physical port. After establishing the mapping relationship between the lightly loaded physical port and the queue, the virtual network card sends the messages in the queue corresponding to the lightly loaded physical port to the lightly loaded physical port one by one. If after a period of time, the number of messages accumulated at the lightly loaded physical port increases and becomes an overloaded physical port, then the lightly loaded physical port is re-determined from multiple physical ports, and a mapping relationship is established between the queue and the re-determined physical port. For example, when the lightly loaded physical port 1 corresponds to queue 1, the virtual network card sends the messages in queue 1 to physical port 1. As the number of messages accumulated at physical port 1 gradually increases, when physical port 1 becomes an overloaded physical port, the virtual network card re-determines that physical port 2 is a lightly loaded physical port, and a mapping relationship is established between queue 1 and physical port 2. Step 203, sending the message in the target queue through the target port.
[0089] After determining the target queue corresponding to the target port, the virtual network card can take out the message from the target queue, send it to the corresponding target port, and send the message to the physical network through the target port.
[0090] As mentioned above, the number of target ports may be one or more, and the number of target queues may also be one or more. The specific process of step 203 may be different for different situations.
[0091] When the number of the target port is one, the virtual network card can directly take out the message in the target queue and send it to the target port, so as to send it to the physical network through the target port.
[0092] In one example, the number of target queues corresponding to the target port is one. Assuming that the target port is physical port 2, and it is determined that physical port 2 corresponds to queue 2, the virtual network card takes out a message from queue 2 and sends it to physical port 2, and sends the message to the physical network through physical port 2.
[0093] Another example is the case where the number of target queues corresponding to the target port is multiple. Assuming that the target port is physical port 0, and it is determined that physical port 0 corresponds to queue 0 and queue 3, the virtual network card can first send the message in queue 0 to physical port 0, and after the message in queue 0 is sent, send the message in queue 3 to physical port 0; it can also first send the message in queue 3 to physical port 0, and after the message in queue 3 is sent, send the message in queue 0 to physical port 0; it can also send the messages in queue 0 and queue 3 to physical port 0 alternately.
[0094] When there are multiple target ports, the virtual network card can sort them according to the load of the target ports, first send messages to the target ports with lighter loads, and then send messages to the target ports with relatively heavy loads. Specifically, when there are multiple target ports determined by the virtual network card, the target ports can be sorted according to the number of messages accumulated at the ports, or the target ports can be sorted according to the ratio or difference between the rate at which messages enter the port and the rate at which messages are sent from the port, and the sorted target ports are obtained, and then the messages are sent according to the sorting order. It should be understood that the physical ports determined as target ports are all lightly loaded physical ports, but the degree of light loading varies.
[0095] Alternatively, the load condition of the target port may be ignored, and each time a message is retrieved, it may be randomly retrieved from a plurality of target queues and sent to the corresponding target port.
[0096] The following is an exemplary description taking the load condition of the target port as an example.
[0097] For example, assume that the target ports are physical port 0 and physical port 2, the target queues of physical port 0 are queue 0 and queue 3, and the target queue of physical port 2 is queue 2. The number of messages accumulated at physical port 0 is 80, and the number of messages accumulated at physical port 2 is 200.
[0098] When the preset thresholds of each physical port are the same, they can be directly sorted according to the size of the accumulated packets. The result is that the number of accumulated packets at physical port 0 is less than the number of accumulated packets at physical port 2, which means that the load of physical port 0 is smaller than the load of physical port 2. In this case, packets are preferentially taken out from queue 0 and queue 3 and sent to physical port 0, and then packets are taken out from queue 2 and sent to physical port 2.
[0099] When the preset thresholds of the physical ports are different, the packets can be sorted according to the accumulation degree of the packets at the physical ports. The accumulation degree of the packets can be reflected according to the ratio of the number of packets accumulated at the physical port to the preset threshold, or the absolute value of the difference. The larger the ratio, or the smaller the absolute value of the difference, the more serious the accumulation degree of the packets. For example, the preset threshold of physical port 2 is 250 packets, and the preset threshold of physical port 0 is 100 packets. The accumulation degree of the packets at physical port 2 is lower than that at physical port 0, indicating that the load of physical port 2 is smaller than that of physical port 0. In this case, the packets are preferentially taken out from queue 2 and sent to physical port 2, and then the packets are taken out from queue 0 and queue 3 and sent to physical port 0.
[0100] In another example, assume that the target ports are physical port 0 and physical port 2, the target queues of physical port 0 are queue 0 and queue 3, and the target queue of physical port 2 is queue 2. The rate at which packets enter physical port 0 is 1500bps, and the rate at which packets are sent from physical port 0 is 1000bps, so the rate difference of physical port 0 is 500bps; the rate at which packets enter physical port 2 is 1700bps, and the rate at which packets are sent from physical port 2 is 900bps, so the rate difference of physical port 2 is 800bps. The rate difference of physical port 2 is greater than the rate difference of physical port 0, indicating that the load of physical port 2 is smaller than that of physical port 0, so packets are preferentially taken from queue 2 and sent to physical port 2, and then packets are taken from queue 0 and queue 3 and sent to physical port 0.
[0101] It should be understood that the order in which messages are taken out from queue 0 and queue 3 for transmission can refer to the description of the case where there are multiple target queues corresponding to the aforementioned target port, and will not be repeated here.
[0102] From the above, it can be seen that the mapping relationship between multiple physical ports and multiple queues proposed in this application is different from the mapping relationship between the five-tuple hash value of the message and the physical port. In the current technology, the virtual network card blindly takes the message from the queue, and only after taking out the message can the five-tuple hash value be calculated to determine the corresponding physical port. Therefore, it is impossible to avoid the possibility of sending the message to the overloaded physical port.
[0103] In the present application, by establishing a mapping relationship between the physical port and the queue, after excluding the overloaded physical port from the multiple physical ports according to the preset conditions and determining the lightly loaded physical port as the target port, the target queue corresponding to the target port is determined according to the mapping relationship between the multiple physical ports and the multiple queues, and the message is taken out from the target queue and sent via the target port. Since the lightly loaded physical port is determined first, and there is a mapping relationship between the physical port and the queue, the virtual network card can take the message from the corresponding queue to send based on the determined lightly loaded physical port. On the one hand, the traffic of the lightly loaded physical port can be increased, and its transmission rate can be increased to reach the bandwidth upper limit. On the other hand, the sending of the message through the overloaded physical port can be temporarily postponed, avoiding further aggravation of transmission delay and congestion. Therefore, the bandwidth of each physical port can reach the upper limit, and the transmission delay and congestion are alleviated, and load balancing between physical ports is achieved. In addition, the message taken out from the queue can be sent directly to the corresponding physical port for sending, without introducing an additional buffer area to store the message, avoiding the occupation of storage space.
[0104] Above, combined Figure 2 The method provided by the embodiment of the present application is described in detail. Figure 3 to Figure 4 The device provided in the embodiments of the present application is described in detail.
[0105] Figure 3 is a schematic block diagram of the device provided in the embodiment of the present application. Figure 3 As shown, the device 300 may include: a processing module 310 and a transceiver module 320. Each unit in the device 300 may be used to implement Figure 2 The corresponding functions of the virtual network card in the method 200 are shown. For example, the processing module 310 can be used to execute step 201 and step 202 in the method 200, and the transceiver module 320 can be used to execute step 203 in the method 200.
[0106] Specifically, the processing module 310 can be used to determine a target port whose load conditions meet preset conditions from multiple physical ports of the physical network card; based on the mapping relationship between multiple physical ports and multiple queues, determine the target queue corresponding to the target port, one or more queues in the multiple queues correspond to a physical port in the multiple physical ports, and the multiple queues are used to cache messages to be sent; the transceiver module 320 can be used to send the messages in the target queue through the target port.
[0107] Optionally, the preset condition includes: the number of accumulated messages is less than a preset threshold.
[0108] Optionally, the preset condition includes: within a unit time, a rate at which packets enter the physical port is higher than a rate at which packets are sent from the physical port.
[0109] Optionally, the processing module 310 may also be used to obtain a mapping relationship between multiple physical ports and multiple queues.
[0110] Optionally, the processing module 310 may also be configured to adjust a mapping relationship between multiple physical ports and multiple queues according to the number of packets in each of the multiple queues.
[0111] It should be understood that the division of modules in the embodiments of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, each functional module in each embodiment of the present application may be integrated into a processor, or may exist physically separately, or two or more modules may be integrated into one module. The above-mentioned integrated modules may be implemented in the form of hardware or in the form of software functional modules.
[0112] Figure 4 400 can be used to implement the function of the virtual network card in the above method 200. The device 400 can be a chip system. In the embodiment of the present application, the chip system can be composed of a chip, or it can include a chip and other discrete devices.
[0113] like Figure 4 As shown, the device 400 may include at least one processor 410, which is used to implement the function of the virtual network card in the method 200 provided in the embodiment of the present application.
[0114] Exemplarily, when the device 400 is used to implement the function of the virtual network card in the method 200 provided in the embodiment of the present application, the processor 410 can be used to determine a target port whose load condition meets a preset condition from multiple physical ports of the physical network card; based on the mapping relationship between multiple physical ports and multiple queues, determine the target queue corresponding to the target port, one or more queues in the multiple queues correspond to a physical port in the multiple physical ports, and the multiple queues are used to cache messages to be sent; and send the message in the target queue through the target port. For details, please refer to the detailed description in the method example, which will not be repeated here.
[0115] The device 400 may also include at least one memory 420 for storing program instructions and / or data. The memory 420 is coupled to the processor 410. The coupling in the embodiment of the present application is an indirect coupling or communication connection between devices, units or modules, which may be electrical, mechanical or other forms, for information exchange between devices, units or modules. The processor 410 may operate in conjunction with the memory 420. The processor 410 may execute program instructions stored in the memory 420. At least one of the at least one memory may be included in the processor.
[0116] The device 400 may also include a communication interface 430 for communicating with other devices via a transmission medium, so that the device 400 can communicate with other devices. Exemplarily, when the device 400 is used to implement the function of the virtual network card in the method 200 provided in the embodiment of the present application, the other device may be a physical network card; the communication interface 430 may be, for example, a transceiver, an interface, a bus, a circuit, or a device capable of implementing the transceiver function. The processor 410 may use the communication interface 430 to send and receive data and / or information, and to implement Figure 2 The method executed by the virtual network card in the corresponding embodiment.
[0117] The specific connection medium between the processor 410, the memory 420 and the communication interface 430 is not limited in the embodiment of the present application. Figure 4 The processor 410, the memory 420 and the communication interface 430 are connected via a bus. Figure 4 The connection between other components is only for illustration and is not intended to be limiting. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0118] It should be understood that the processor in the embodiment of the present application can be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method embodiment can be completed by the hardware integrated logic circuit or software instructions in the processor. The above processor can be a general processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to perform, or the hardware and software modules in the decoding processor can be combined to perform. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0119] It should also be understood that the memory in the embodiments of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), and direct RAM (DR RAM). It should be noted that the memory of the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0120] The present application also provides a chip system, which includes at least one processor for implementing the above Figure 2 Functions involved in the virtual network card in the illustrated embodiment.
[0121] In one possible design, the chip system also includes a memory, which is used to store program instructions and data, and the memory is located inside or outside the processor.
[0122] The chip system may be composed of the chip, or may include the chip and other discrete devices.
[0123] As mentioned above, the above method can be implemented by executing a computer program, or by a logic circuit, an integrated circuit, etc. solidified on a chip. Therefore, the present application also provides a chip, which includes a logic circuit or an integrated circuit. The mapping relationship between the multiple physical ports and the multiple queues described in the above method embodiment, as well as each preset threshold, can be implemented by an external configuration method. This application does not limit this.
[0124] The present application also provides an electronic device, which includes: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, Figure 2 The method of the illustrated embodiment.
[0125] The present application also provides a computer-readable storage medium, which stores a computer program (also referred to as code or instruction). When the computer program is executed, the computer executes the following Figure 2 The method of the illustrated embodiment.
[0126] The terms "unit", "module" and the like used in this specification may be used to represent a computer-related entity, hardware, firmware, a combination of hardware and software, software, or software in execution.
[0127] It will be appreciated by those skilled in the art that the various illustrative logical blocks and steps described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or in combination with computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application. In the several embodiments provided in this application, it should be understood that the disclosed devices, equipment and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the unit is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point, the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0128] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0129] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0130] In the above-described embodiments, the functions of each functional unit can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions (programs). When the computer program instructions (programs) are loaded and executed on a computer, the flow or function according to the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website, computer, server or data center to another website, computer, server or data center via wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media integrated therein. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a digital video disc (DVD)), or a semiconductor medium (e.g., a solid state disk (SSD)), etc.
[0131] If this function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard drives, ROM, RAM, magnetic disks, or optical disks.
[0132] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for sending a message, characterized in that: The method comprises: Determine a target port whose load condition meets a preset condition from a plurality of physical ports of the physical network card, wherein the target port is a lightly loaded physical port, and the number of the target port is one or more; Based on the mapping relationship between the multiple physical ports and the multiple queues, determine the target queue corresponding to the target port, one or more queues in the multiple queues correspond to a physical port in the multiple physical ports, the multiple queues are used to cache messages to be sent, and the mapping relationship between the multiple physical ports and the multiple queues is temporarily created by the virtual network card when sending messages according to the queues that currently have messages to be sent and the physical ports in the physical network card; The messages in the target queue are sent through the target port.
2. The method according to claim 1, characterized in that The preset condition includes: the number of accumulated messages is less than a preset threshold.
3. The method according to claim 1, characterized in that The preset condition includes: within a unit time, the rate at which packets enter the physical port is higher than the rate at which packets are sent from the physical port.
4. The method according to any one of claims 1 to 3, characterized in that Before determining the target queue corresponding to the target port based on the mapping relationship between the multiple physical ports and the multiple queues, the method further includes: A mapping relationship between the multiple physical ports and the multiple queues is obtained.
5. The method according to claim 4, characterized in that The method further comprises: According to the number of packets in each of the multiple queues, the mapping relationship between the multiple physical ports and the multiple queues is adjusted.
6. A device for sending a message, characterized in that: The device comprises: A processing module, configured to determine a target port whose load condition meets a preset condition from a plurality of physical ports of a physical network card, wherein the target port is a lightly loaded physical port, and the number of the target ports is one or more; based on a mapping relationship between the plurality of physical ports and a plurality of queues, determine a target queue corresponding to the target port, wherein one or more queues in the plurality of queues correspond to a physical port in the plurality of physical ports, and the plurality of queues are used to cache messages to be sent, and the mapping relationship between the plurality of physical ports and the plurality of queues is temporarily created by the virtual network card when sending a message according to the queue currently having messages to be sent and the physical port in the physical network card; The transceiver module is used to send the message in the target queue through the target port.
7. The device according to claim 6, characterized in that The processing module is further configured to obtain a mapping relationship between the multiple physical ports and the multiple queues.
8. The device according to claim 7, characterized in that The processing module is further configured to adjust the mapping relationship between the multiple physical ports and the multiple queues according to the number of packets in each of the multiple queues.
9. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 5 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor is caused to implement the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Load sharing method and device thereof
CN102137018A
Port speed limiting method and device for network equipment
CN107995199A
Message processing method and network equipment
CN110677358A
Flow balancing method and device
CN111726299A
Data forwarding method, data caching method, data forwarding device, data caching device and related equipment
CN113037640A
