Traffic Distribution Method for Multiple Network Interfaces in Cloud Gateway Server and Related Devices
By setting up a packet queue in each packet cache area in the cloud gateway server and matching it with the number of processor cores, combining hashing algorithm and DMA engine, the problem of the packet queue occupying too much memory is solved, and network traffic processing efficiency and performance are improved.
Patent Information
- Application Number
- CN202310123824.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-13
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2043-02-13
AI Technical Summary
Due to the increase in the number of network ports in existing cloud gateway servers, the total number of packetized queues has increased significantly, occupying too much memory resources, and the CPU core thread needs to access memory across multiple queues, affecting network forwarding performance.
Set up a packet queue in each packet cache area to match the total number of processor cores, use a hash algorithm to determine the target queue, and use the DMA engine to cache network traffic, reduce memory usage and improve data access efficiency of CPU core threads.
It effectively reduces the memory usage of the packetized queue, improves the memory resource utilization rate, and improves the network traffic processing efficiency and forwarding performance of cloud gateway servers.
Smart Images

Figure CN116132369B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of cloud gateways, and particularly relates to a method for distributing traffic of multiple network interfaces in a cloud gateway server and related devices. Background Art
[0002] A cloud gateway is a device for efficiently forwarding network traffic, generally using a multi-core server. In a cloud gateway server, the network traffic received by the network card is distributed to the receive packet queues for caching, so that multiple CPU cores in the cloud gateway server can process this network traffic in parallel. During the traffic distribution process, it is required that the bidirectional traffic of the same network connection be distributed to the same receive packet queue, so as to effectively ensure the normal and efficient forwarding of network traffic in the cloud gateway.
[0003] Currently, generally, a receive packet buffer is set for each network interface in the network card, and multiple receive packet queues are set in the receive packet buffer of each network interface, and there is a proportional relationship with the number of CPU core threads. For example, if there are 2 network interfaces and 16 CPU core threads, then 2 receive packet buffers are set, 16 queues are set in each receive packet buffer, and each thread is responsible for processing the corresponding receive packet queue. For example, the thread of CPU core 1 processes queue Q1 in the receive packet buffer of network interface eth1 and queue Q1 in the receive packet buffer of network interface eth2. By using the load balancing of the RSS (Receive Side Scaling) rule of the network card, the bidirectional traffic of the same network connection can be distributed to the receive packet queue with the same number (such as queue numbered Q1).
[0004] When setting the receive packet queues according to the number of network interfaces and the number of CPU core threads, as the number of network interfaces increases, the total number of receive packet queues in the cloud gateway will increase significantly. For example, if there are 8 network interfaces and 32 CPU core threads, then the total number of receive packet queues in the cloud gateway is 8 * 32 = 256, resulting in excessive memory resources occupied by the receive packet queues.
[0005] It can be seen that the current traffic distribution method has the technical problem of excessive memory resource occupation. Summary of the Invention
[0006] This application provides a method for distributing traffic of multiple network interfaces in a cloud gateway server and related devices, aiming to reduce the memory occupation of the receive packet queues.
[0007] On the one hand, this application provides a method for distributing traffic of multiple network interfaces in a cloud gateway server. The cloud gateway server includes a processor, multiple receive packet buffers, and a network card. The processor includes multiple processor cores. One receive packet queue is set in each of the receive packet buffers. The total number of the multiple receive packet buffers matches the total number of the multiple processor cores. The network card includes multiple network interfaces. The method includes:
[0008] Obtain the target network traffic received by any one of the network interfaces;
[0009] Among multiple receiving packet queues, determine the target queue to which the target network traffic should be allocated;
[0010] Cache the target network traffic into the target queue for the processor core associated with the target queue to process the target network traffic.
[0011] In some embodiments, the total number of the receiving packet buffers is equal to the total number of multiple processor cores, and multiple receiving packet queues are associated with multiple processor cores one by one.
[0012] In some embodiments, the determining, among multiple receiving packet queues, the target queue to which the target network traffic should be allocated includes:
[0013] Use a hash algorithm to determine the hash value corresponding to the target network traffic;
[0014] In a preset redirection table, determine the target redirection value of the hash value, where the redirection table includes redirection values of multiple preset hash values;
[0015] Among multiple receiving packet queues, determine the receiving packet queue numbered with the target redirection value as the target queue to which the target network traffic should be allocated.
[0016] In some embodiments, the using a hash algorithm to determine the hash value corresponding to the target network traffic includes:
[0017] If the target network traffic is network traffic without tunnel encapsulation, obtain the QinQ tag and IP header in the target network traffic;
[0018] Perform hash processing on the QinQ tag and IP header to obtain the hash value corresponding to the target network traffic.
[0019] In some embodiments, the using a hash algorithm to determine the hash value corresponding to the target network traffic includes:
[0020] If the target network traffic is network traffic with tunnel encapsulation, obtain the QinQ tag and the inner IP header in the target network traffic;
[0021] Perform hash processing on the QinQ tag and the inner IP header to obtain the hash value corresponding to the target network traffic.
[0022] In some embodiments, the hash processing is symmetric hash processing.
[0023] In some embodiments, caching the target network traffic into the target queue includes:
[0024] Using a direct memory access engine to cache the target network traffic into the target queue.
[0025] On the other hand, the present application provides a cloud gateway server, which includes a processor, a plurality of packet receiving buffers, and a network card. The processor includes a plurality of processor cores. Each of the packet receiving buffers is provided with a packet receiving queue. The total number of the plurality of packet receiving buffers matches the total number of the plurality of processor cores. The network card includes a plurality of network interfaces. The cloud gateway server further includes:
[0026] An obtaining module, configured to obtain the target network traffic received by any one of the network interfaces;
[0027] A determining module, configured to determine the target queue to which the target network traffic should be allocated among the plurality of packet receiving queues;
[0028] A distributing module, configured to cache the target network traffic into the target queue for the processor core associated with the target queue to process the target network traffic.
[0029] On the other hand, the present application further provides a computer device, which includes:
[0030] One or more processors;
[0031] A memory; and
[0032] One or more applications, where the one or more applications are stored in the memory and configured to be executed by the processor to implement the traffic distribution method for multiple network interfaces in the cloud gateway server.
[0033] On the other hand, the present application further provides a computer-readable storage medium, on which a computer program is stored. The computer program is loaded by a processor to execute the steps in the traffic distribution method for multiple network interfaces in the cloud gateway server.
[0034] The traffic distribution method and related devices for multiple network interfaces in the cloud gateway server provided by the embodiments of the present application. The cloud gateway server includes a processor, multiple packet receiving buffer areas, and network cards. The processor includes multiple processor cores. Each packet receiving buffer area is provided with a packet receiving queue. The total number of multiple packet receiving buffer areas matches the total number of multiple processor cores. The network card includes multiple network interfaces. The method includes: obtaining the target network traffic received by any network interface; determining the target queue to which the target network traffic should be allocated among the multiple packet receiving queues; caching the target network traffic into the target queue for the processor core associated with the target queue to process the target network traffic. By setting a packet receiving queue in each packet receiving buffer area and making the total number of multiple packet receiving buffer areas match the total number of multiple processor cores in the embodiments of the present application, when obtaining the target network traffic received by any network interface, the target queue can be directly determined among the multiple packet receiving queues, avoiding a large increase in the total number of packet receiving queues caused by setting a packet receiving buffer area for each network interface and reducing the memory occupancy of the packet receiving queues. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present application. For those skilled in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0036] Figure 1 It is a schematic diagram of the scenario of the general method for traffic distribution of multiple network interfaces in the cloud gateway server;
[0037] Figure 2 It is a schematic diagram of a scenario of the traffic distribution system for multiple network interfaces in the cloud gateway server provided by the embodiments of the present application;
[0038] Figure 3 It is a schematic diagram of a scenario of the traffic distribution method for multiple network interfaces in the cloud gateway server provided by the embodiments of the present application;
[0039] Figure 4 It is a schematic diagram of the flowchart of an embodiment of the traffic distribution method for multiple network interfaces in the cloud gateway server provided by the embodiments of the present application;
[0040] Figure 5 It is a schematic diagram of a structure of the request traffic and response traffic in the embodiments of the present application;
[0041] Figure 6 It is another schematic diagram of the structure of the request traffic and response traffic in the embodiments of the present application;
[0042] Figure 7It is a schematic structural diagram of an embodiment of the cloud gateway server provided in the embodiments of the present application;
[0043] Figure 8 It is a schematic structural diagram of an embodiment of the computer device provided in the embodiments of the present application. Detailed implementation manners
[0044] Next, the technical solutions in the embodiments of the present application will be clearly and completely described with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative efforts fall within the protection scope of the present application.
[0045] In the description of the present application, "a plurality of" means two or more, unless otherwise specifically defined. In the present application, the term "exemplary" is used to mean "serving as an example, illustration, or description". Any embodiment described as "exemplary" in the present application is not necessarily to be construed as more preferred or more advantageous than other embodiments. In order for any person skilled in the art to implement and use the present application, the following description is given. In the following description, details are set forth for the purpose of explanation. It should be understood that those skilled in the art can realize that the present application can be implemented without using these specific details. In other instances, well-known technologies and processes are not elaborated in detail to avoid obscuring the description of the present application with unnecessary details. Therefore, the present application is not intended to be limited to the embodiments shown, but is to be accorded the widest scope consistent with the principles and features disclosed in the present application.
[0046] First, with reference to Figure 1 , a general method for traffic distribution of multiple network interfaces in the cloud gateway server is described as follows:
[0047] In Figure 1 , the cloud gateway server includes a processor and network cards. The processor is generally a multi-core processor, such as a multi-core CPU (central processing unit). The multi-core processor includes multiple processor cores. For example, the multiple processor cores can be Figure 1 the 16 processor cores of CPU1, CPU2, CPU3,..., CPU16 in
[0048] The network cards of the cloud gateway server include multiple network interfaces. For example, the multiple network interfaces can be Figure 1Among the two network interfaces, namely eth1 (network interface 1) and eth2 (network interface 2), "eth" refers to Ethernet. Each network interface includes two ports: RX-FIFO (receive-first in, first out) and TX-FIFO (transmit-first in, first out). Each network interface can be used to receive request traffic or the response traffic of request traffic.
[0049] Generally, a packet receiving buffer is set for each network interface in the network card. Multiple packet receiving queues are set in the packet receiving buffer of each network interface, and they are in a proportional relationship with the number of CPU core threads. Taking the example of setting one thread in each CPU core, there are 16 CPU core threads in total for 16 CPU cores. Then, 16 packet receiving queues can be set in the packet receiving buffer of each network interface. For example, Figure 1 In the packet receiving buffer of the eth1 network interface in [], there are 16 packet receiving queues numbered Q1, Q2, Q3,..., Q16 in sequence. Similarly, in the packet receiving buffer of the eth2 network interface, there are also 16 packet receiving queues numbered Q1, Q2, Q3,..., Q16 in sequence. By using the load balancing of the RSS (Receive Side Scaling) rule of the network card, the DMA (Direct Memory Access) engine can distribute the two-way traffic of the same network connection (including request traffic and the response traffic of request traffic) to the packet receiving queue with the same number (such as the packet receiving queue numbered Q1). RSS is a network card driver technology that can efficiently distribute the received network traffic among multiple CPU cores in a multi-core processor system. From Figure 1 it can be seen that CPU1 is responsible for processing the network traffic in the packet receiving queue numbered Q1, CPU2 is responsible for processing the network traffic in the packet receiving queue numbered Q2, CPU3 is responsible for processing the network traffic in the packet receiving queue numbered Q3, and so on. CPU16 is responsible for processing the network traffic in the packet receiving queue numbered Q16, so as to ensure that the CPU core threads can process the network traffic concurrently without interfering with each other, effectively ensuring the normal and efficient forwarding of network traffic in the cloud gateway.
[0050] When setting up receive queues according to the number of network interfaces and the number of CPU core threads, as the number of network interfaces increases, the total number of receive queues in the cloud gateway will increase significantly. For example, if there are 8 network interfaces and 32 CPU core threads, then the total number of receive queues in the cloud gateway is 8 * 32 = 256. Assuming that each receive queue occupies 1 GB (Gigabyte) of memory resources, then 256 receive queues will occupy 256 GB of memory resources. However, the inventor found through testing that actually only 16 GB of memory resources are needed for 8 network interfaces. Therefore, the utilization rate of the memory resources occupied by the receive queues is less than 5%. It can be seen that the receive queues occupy too much memory resources.
[0051] Moreover, the inventor also found that since one CPU core thread needs to process receive queues in multiple network interfaces. For example, Figure 1 CPU1 in
[0052] needs to process the receive queue numbered Q1 in the eth1 network interface and the receive queue numbered Q1 in the eth2 network interface. The CPU core thread needs to perform memory space addressing access across multiple queues. For a CPU with a smaller cache (high-speed buffer memory), its access efficiency is greatly reduced, thus affecting the network forwarding performance of the cloud gateway server.
[0053] As Figure 2 shown, Figure 2 is a schematic diagram of the scenario of the traffic distribution system for multiple network interfaces in the cloud gateway server provided by an embodiment of the present application. The traffic distribution system for multiple network interfaces in the cloud gateway server may include a cloud gateway server 100, a client 200, and a target server 300. The client 200 sends request traffic to the cloud gateway server 100 to request data from the target server 300. After the target server 300 obtains the response traffic of the request traffic, it feeds back the response traffic to the cloud gateway server 100, so that the cloud gateway server 100 transmits the response traffic to the client 200.
[0054] In an embodiment of the present application, the cloud gateway server 100 may be an independent server, or a server network or server cluster composed of servers. For example, the cloud gateway server 100 described in the embodiments of the present application includes, but is not limited to, a computer, a network host, a single network server, a set of multiple network servers, or a cloud server constructed by multiple servers. Among them, the cloud server is constructed by a large number of computers or network servers based on cloud computing (Cloud Computing).
[0055] Those skilled in the art can understand that, Figure 2The application environment shown is merely one application scenario of the solution of this application, and does not limit the application scenario of the solution of this application. Other application environments may also include more or fewer computer devices than those shown in Figure 2 For example, Figure 2 only 3 computer devices are shown in . It can be understood that the traffic distribution system with multiple network interfaces in this cloud gateway server may also include one or more other computer devices, which are not specifically limited here.
[0056] As is known to those of ordinary skill in the art, with the evolution of the traffic distribution system with multiple network interfaces in the cloud gateway server and the emergence of new business scenarios, the technical solution provided in the embodiments of this application is also applicable to similar technical problems.
[0057] Please refer to Figure 3 , Figure 3 which is a schematic diagram of a scenario of the traffic distribution method with multiple network interfaces in the cloud gateway server provided in the embodiments of this application. In Figure 3 , the cloud gateway server includes a processor, multiple packet receiving buffer areas, and network cards. The processor includes multiple processor cores (such as Figure 3 the 16 processor cores of CPU1, CPU2, CPU3,..., CPU16 in ), each packet receiving buffer area is provided with a packet receiving queue (such as Figure 3 in , only the packet receiving queue numbered Q1 is set in the first packet receiving buffer area, only the packet receiving queue numbered Q2 is set in the second packet receiving buffer area, only the packet receiving queue numbered Q3 is set in the third packet receiving buffer area, and so on). The total number of multiple packet receiving buffer areas matches the total number of multiple processor cores (such as Figure 3 16 processor cores in are matched with 16 packet receiving buffer areas), and the network card includes multiple network interfaces (such as Figure 3 the 2 network interfaces of eth1 and eth2 in ). It can be seen that compared with Figure 1 , Figure 3 the number of packet receiving queues in the cloud gateway server in is smaller. For example, Figure 3 there are only 16 packet receiving queues in , and the memory resources occupied are 16GB, which is greatly reduced compared with the 32GB memory resources occupied by the packet receiving queues in Figure 1 . It should be noted that in the cloud gateway server provided in the embodiments of this application, the total number of packet receiving queues is only related to the total number of processor cores in the processor and has nothing to do with the number of network interfaces in the network card. That is, no matter how many network interfaces there are, it does not affect the total number of packet receiving queues and the size of the memory resources occupied by the packet receiving queues. Therefore, the occupation of memory resources by the packet receiving queues can be greatly reduced, and the utilization rate of memory resources is improved.
[0058] In some embodiments of the present application, the total number of packet receiving buffer areas is equal to the total number of multiple processor cores, and multiple packet receiving queues are associated with multiple processor cores one by one. For example Figure 3 the cloud gateway server in Figure 3 includes 16 packet receiving buffer areas and 16 processor cores. One packet receiving queue is set in each packet receiving buffer area, so that multiple packet receiving queues can be associated with multiple processor cores one by one. For example
[0059] Next, a method for distributing traffic of multiple network interfaces in the cloud gateway server provided by the embodiments of the present application is introduced.
[0060] In the embodiments of the method for distributing traffic of multiple network interfaces in the cloud gateway server of the embodiments of the present application Figure 3 the cloud gateway server in
[0061] Please refer to Figure 4 , Figure 4 which is a schematic flowchart of an embodiment of the method for distributing traffic of multiple network interfaces in the cloud gateway server provided by the embodiments of the present application. The method for distributing traffic of multiple network interfaces in the cloud gateway server includes:
[0062] 401. Obtain the target network traffic received by any one of the network interfaces;
[0063] Taking Figure 3 as an example, any one of the network interfaces can be Figure 3 any one of the two network interfaces eth1 and eth2 in
[0064] 402. Determine the target queue to which the target network traffic should be allocated among the multiple packet receiving queues;
[0065] Taking Figure 3 as an example, the multiple packet receiving queues can be Figure 3 the 16 packet receiving queues numbered Q1, Q2, Q3,..., Q16 shown in
[0066] In some embodiments of the present application, to ensure that the bidirectional data (request traffic and response traffic) of the same network connection can enter the same queue, so as to ensure that the CPU core threads can be concurrent and not interfere with each other during processing, the RSS technology is adopted to determine the target queue. Specifically, among multiple packet receiving queues, determining the target queue to which the target network traffic should be allocated may include: using a hash algorithm to determine the hash value corresponding to the target network traffic; in a preset redirection table (RETA), determining the target redirection value of the hash value, where the redirection table includes the redirection values of multiple preset hash values, and the redirection values of the multiple preset hash values are all the numbers of the packet receiving queues. Subsequently, dynamic load balancing can be achieved by modifying the redirection table; among multiple packet receiving queues, the packet receiving queue numbered with the target redirection value is determined as the target queue to which the target network traffic should be allocated.
[0067] Further, using a hash algorithm to determine the hash value corresponding to the target network traffic may include: if the target network traffic is network traffic without tunnel encapsulation, obtaining the QinQ tag and the IP header in the target network traffic, where the QinQ tag refers to 802.1Q in 802.1Q, also called VLAN (Virtual Local Area Network) nesting. Specifically, two 802.1Q headers are stacked in the Ethernet frame, effectively expanding the number of VLANs. The IP header refers to the IP header information, for example Figure 5 shows the structure of the network traffic without tunnel encapsulation. If the network traffic without tunnel encapsulation is request traffic, the request traffic includes an eth header, a QinQ tag, an IP header, and a payload. If the network traffic without tunnel encapsulation is response traffic, the response traffic includes an eth header, a QinQ tag, a PPPoE (Point-to-Point Protocol Over Ethernet) header, an IP header, and a payload. By parsing the target network traffic without tunnel encapsulation, the QinQ tag and the IP header in the target network traffic can be obtained; performing hash processing on the QinQ tag and the IP header to obtain the hash value corresponding to the target network traffic.
[0068] Further, using a hash algorithm to determine the hash value corresponding to the target network traffic may include: when the target network traffic is network traffic with tunnel encapsulation, obtaining the QinQ tag and the inner IP header in the target network traffic. Since there is tunnel encapsulation, a tunnel header is also encapsulated outside the original packet, so the structure of the network traffic with tunnel encapsulation is different from that of the network traffic without tunnel encapsulation, for example Figure 6The structure of tunnel-encapsulated network traffic is shown. If the tunnel-encapsulated network traffic is request traffic, the request traffic includes a tunnel header (outer eth header, VLAN tag, outer IP header), an inner eth header, a QinQ tag, an inner IP header, and a payload. If the tunnel-encapsulated network traffic is response traffic, the response traffic includes a tunnel header (outer eth header, VLAN tag, outer IP header), an inner eth header, a QinQ tag, a PPPoE (Point-to-Point Protocol Over Ethernet) header, an inner IP header, and a payload. By parsing the target network traffic with tunnel encapsulation, the QinQ tag and the inner IP header in the target network traffic can be obtained. It can be seen that when there is no tunnel encapsulation and when there is tunnel encapsulation, the field areas where the QinQ tag and the IP header are located in the target network traffic are different. Therefore, by setting different parsing rules, the QinQ tag and the IP header in the target network traffic can be accurately found; the QinQ tag and the inner IP header are hashed to obtain the hash value corresponding to the target network traffic.
[0069] In some other embodiments of the present application, the hashing process is a symmetric hashing process. The symmetric hashing process is generally implemented based on toeplitz hashing. Toeplitz hashing has two inputs: a default hash key and the QinQ tag and IP header extracted from the target network traffic. When using the default hash key, the hash values calculated by toeplitz hashing for the bidirectional data of the same network connection are different, which will cause the bidirectional data of the same network connection to be distributed to different packet receiving queues. Therefore, by using another hash key of the symmetric hashing to replace the default hash key, the hash values of the bidirectional data of the same network connection can be made the same and distributed to the same packet receiving queue.
[0070] 403. Cache the target network traffic to the target queue for the processor core associated with the target queue to process the target network traffic.
[0071] In the embodiments of the present application, a DMA (Direct Memory Access) engine is set in the network card, which can directly send data from an attached device (such as a network port) to the packet receiving queue in the mainboard memory of the cloud gateway server. Therefore, after determining the target queue, using the DMA engine, the target network traffic can be cached to the target queue for the processor core thread associated with the target queue to process the target network traffic, thereby completing the normal and efficient forwarding of the target network traffic.
[0072] In the traffic distribution method for multiple network interfaces in the cloud gateway server provided by the embodiments of the present application, by setting a packet receiving queue in each packet receiving buffer, and the total number of multiple packet receiving buffers matches the total number of multiple processor cores. In this way, when obtaining the target network traffic received by any network interface, the target queue can be directly determined among multiple packet receiving queues, avoiding a large increase in the total number of packet receiving queues caused by setting a packet receiving buffer for each network interface. In the case of a cloud gateway server with multiple CPU cores and multiple network interfaces, while ensuring multi-core concurrent processing, the memory resource occupancy is reduced.
[0073] To better implement the traffic distribution method for multiple network interfaces in the cloud gateway server in the embodiments of the present application, based on the traffic distribution method for multiple network interfaces in the cloud gateway server, the embodiments of the present application also provide a cloud gateway server, as Figure 7 shown, the cloud gateway server 700 includes:
[0074] An obtaining module 701, configured to obtain the target network traffic received by any network interface;
[0075] A determining module 702, configured to determine, among multiple packet receiving queues, the target queue to which the target network traffic should be allocated;
[0076] A distributing module 703, configured to cache the target network traffic into the target queue for the processor core associated with the target queue to process the target network traffic.
[0077] For the cloud gateway server 700 provided by the embodiments of the present application, by setting a packet receiving queue in each packet receiving buffer, and the total number of multiple packet receiving buffers matches the total number of multiple processor cores. In this way, when obtaining the target network traffic received by any network interface, the target queue can be directly determined among multiple packet receiving queues, avoiding a large increase in the total number of packet receiving queues caused by setting a packet receiving buffer for each network interface, and reducing the memory occupancy of the packet receiving queue.
[0078] In some embodiments of the present application, the determining module 702 is specifically configured to:
[0079] Adopt a hash algorithm to determine the hash value corresponding to the target network traffic;
[0080] In a preset redirection table, determine the target redirection value of the hash value, where the redirection table includes the redirection values of multiple preset hash values;
[0081] Among multiple said packet receiving queues, determine the packet receiving queue numbered with the target redirection value as the target queue to which the target network traffic should be allocated.
[0082] In some embodiments of the present application, the determining module 702 is specifically configured to:
[0083] If the target network traffic is network traffic without tunnel encapsulation, obtain the QinQ tag and IP header in the target network traffic;
[0084] Perform hash processing on the QinQ tag and IP header to obtain the hash value corresponding to the target network traffic.
[0085] In some embodiments of the present application, the determining module 702 is specifically configured to:
[0086] If the target network traffic is network traffic with tunnel encapsulation, obtain the QinQ tag and the inner IP header in the target network traffic;
[0087] Perform hash processing on the QinQ tag and the inner IP header to obtain the hash value corresponding to the target network traffic.
[0088] In some embodiments of the present application, the distributing module 703 is specifically configured to:
[0089] Use the direct memory access engine to cache the target network traffic into the target queue.
[0090] In addition to the above-introduced traffic distribution method and cloud gateway server for multiple network interfaces in the cloud gateway server, the embodiments of the present application further provide a computer device, which integrates any cloud gateway server provided by the embodiments of the present application. The computer device includes:
[0091] One or more processors;
[0092] A memory; and
[0093] One or more applications, where one or more applications are stored in the memory and are configured to be executed by the processor to perform any step in any embodiment of the above-mentioned traffic distribution method for multiple network interfaces in the cloud gateway server.
[0094] The embodiments of the present application further provide a computer device, which integrates any cloud gateway server provided by the embodiments of the present application. As Figure 8 shown, it shows a schematic structural diagram of the computer device involved in the embodiments of the present application. Specifically:
[0095] The computer device may include components such as a processor 801 with one or more processing cores, a storage unit 802 with one or more computer-readable storage media, a power supply 803, and an input unit 804. Those skilled in the art can understand that, Figure 8The computer device structure shown does not constitute a limitation on the computer device, and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Among them:
[0096] The processor 801 is the control center of the computer device, connecting various parts of the entire computer device through various interfaces and lines. By running or executing software programs and / or modules stored in the storage unit 802, and by calling the data stored in the storage unit 802, it executes various functions of the computer device and processes data, thereby monitoring the computer device as a whole. Optionally, the processor 801 may include one or more processing cores; preferably, the processor 801 may integrate an application processor and a modem processor. Among them, the application processor mainly processes the operating system, user interface, application programs, etc., and the modem processor mainly processes wireless communication. It can be understood that the above-mentioned modem processor may not be integrated into the processor 801 either.
[0097] The storage unit 802 can be used to store software programs and modules. The processor 801 executes various functional applications and data processing by running the software programs and modules stored in the storage unit 802. The storage unit 802 may mainly include a program storage area and a data storage area. Among them, the program storage area can store the operating system, application programs required for at least one function (such as the sound playback function, image playback function, etc.); the data storage area can store data created according to the use of the computer device. In addition, the storage unit 802 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid-state storage devices. Correspondingly, the storage unit 802 may also include a memory controller to provide the processor 801 with access to the storage unit 802.
[0098] The computer device also includes a power supply 803 that powers each component. Preferably, the power supply 803 can be logically connected to the processor 801 through a power management system, so as to realize functions such as management of charging, discharging, and power consumption management through the power management system. The power supply 803 may also include any components such as one or more DC or AC power supplies, a recharge system, a power failure detection circuit, a power converter or inverter, and a power status indicator.
[0099] The computer device may also include an input unit 804, which can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function controls.
[0100] Although not shown, the computer device may further include a display unit and the like, which will not be elaborated herein. Specifically, in the embodiments of the present application, the processor 801 in the computer device will load the executable files corresponding to the processes of one or more application programs into the storage unit 802 according to the following instructions, and the processor 801 will run the application programs stored in the storage unit 802 to implement various functions as follows:
[0101] Obtain the target network traffic received by any network interface; in multiple packet receiving queues, determine the target queue to which the target network traffic should be allocated; cache the target network traffic into the target queue for the processor core associated with the target queue to process the target network traffic.
[0102] For this reason, the embodiments of the present application provide a computer-readable storage medium, which may include: read-only memory (ROM, Read Only Memory), random access memory (RAM, Random Access Memory), a magnetic disk or an optical disc, etc. Multiple instructions are stored in the computer-readable storage medium, and the instructions can be loaded by the processor to execute the steps in any of the traffic distribution methods for multiple network interfaces in the cloud gateway server provided by the embodiments of the present application. For example, the instructions can execute the following steps:
[0103] Obtain the target network traffic received by any network interface; in multiple packet receiving queues, determine the target queue to which the target network traffic should be allocated; cache the target network traffic into the target queue for the processor core associated with the target queue to process the target network traffic.
[0104] In the above embodiments, the descriptions of the respective embodiments have their own emphases. For the parts not elaborated in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0105] The above has introduced in detail a traffic distribution method for multiple network interfaces in a cloud gateway server and related devices provided by the embodiments of the present application. Specific examples are used in this article to elaborate on the principle and implementation manner of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application; at the same time, for those skilled in the art, based on the idea of the present application, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present application.
Claims
1. A traffic distribution method for multiple network interfaces in a cloud gateway server, characterized in that The cloud gateway server includes a processor, multiple packet receiving buffers, and a network card. The processor includes multiple processor cores. Each of the packet receiving buffers is provided with a packet receiving queue. The total number of the multiple packet receiving buffers matches the total number of the multiple processor cores. The network card includes multiple network interfaces. The method includes: Obtain target network traffic received by any one of the network interfaces, where the target network traffic is request traffic or response traffic of the request traffic; Among the multiple packet receiving queues, determine a target queue to which the target network traffic should be allocated. Among them, the target queues to which the target network traffic received by the multiple network interfaces should be allocated are all determined from the same multiple packet receiving queues; Use a direct memory access engine to cache the target network traffic into the target queue for the processor core associated with the target queue to process the target network traffic. Among them, the target network traffic received by the multiple network interfaces is cached into the corresponding target queues using the same direct memory access engine. The direct memory access engine uses load balancing of the receive-side scaling rules of the network card to distribute the request traffic and the response traffic of the request traffic of the same network connection to the same packet receiving queue; The determining, among the multiple packet receiving queues, a target queue to which the target network traffic should be allocated includes: using a hash algorithm to determine a hash value corresponding to the target network traffic; in a preset redirection table, determining a target redirection value of the hash value, where the redirection table includes redirection values of multiple preset hash values; among the multiple packet receiving queues, determining the packet receiving queue numbered with the target redirection value as the target queue to which the target network traffic should be allocated; The using a hash algorithm to determine a hash value corresponding to the target network traffic includes: if the target network traffic is network traffic without tunnel encapsulation, obtaining the QinQ tag and IP header in the target network traffic; performing symmetric hash processing on the QinQ tag and the IP header to obtain the hash value corresponding to the target network traffic; The using a hash algorithm to determine a hash value corresponding to the target network traffic further includes: if the target network traffic is network traffic with tunnel encapsulation, obtaining the QinQ tag and the inner IP header in the target network traffic; performing symmetric hash processing on the QinQ tag and the inner IP header to obtain the hash value corresponding to the target network traffic.
2. The traffic distribution method for multiple network interfaces in the cloud gateway server according to claim 1, characterized in that, The total number of the packet receiving buffers is equal to the total number of the multiple processor cores, and the multiple packet receiving queues are associated with the multiple processor cores one by one.
3. A cloud gateway server, characterized in that, The cloud gateway server includes a processor, multiple packet receiving buffers, and a network card. The processor includes multiple processor cores. Each of the packet receiving buffers is provided with a packet receiving queue. The total number of the multiple packet receiving buffers matches the total number of the multiple processor cores. The network card includes multiple network interfaces. The cloud gateway server further includes: An acquisition module, configured to acquire target network traffic received by any one of the network interfaces, where the target network traffic is request traffic or response traffic of the request traffic; A determination module, configured to determine a target queue to which the target network traffic should be allocated from multiple receive queues, where the target queues to which the target network traffic received by multiple network interfaces should be allocated are all determined from the same multiple receive queues; A distribution module, configured to use a direct memory access engine to cache the target network traffic into the target queue for the processor core associated with the target queue to process the target network traffic, where the target network traffic received by multiple network interfaces is cached into the corresponding target queues using the same direct memory access engine, and the direct memory access engine distributes the request traffic and the response traffic of the request traffic of the same network connection into the same receive queue by using load balancing of the receive-side scaling rule of the network card; The determining, from multiple receive queues, a target queue to which the target network traffic should be allocated includes: using a hash algorithm to determine a hash value corresponding to the target network traffic; determining a target redirection value of the hash value in a preset redirection table, where the redirection table includes redirection values of multiple preset hash values; and determining, from multiple receive queues, the receive queue numbered with the target redirection value as the target queue to which the target network traffic should be allocated; The using a hash algorithm to determine a hash value corresponding to the target network traffic includes: if the target network traffic is network traffic without tunnel encapsulation, acquiring a QinQ tag and an IP header in the target network traffic; and performing symmetric hash processing on the QinQ tag and the IP header to obtain the hash value corresponding to the target network traffic; The using a hash algorithm to determine a hash value corresponding to the target network traffic further includes: if the target network traffic is network traffic with tunnel encapsulation, acquiring a QinQ tag and an inner IP header in the target network traffic; and performing symmetric hash processing on the QinQ tag and the inner IP header to obtain the hash value corresponding to the target network traffic.
4. A computer device, characterized in that, The computer device includes: One or more processors; A memory; and One or more application programs, where the one or more application programs are stored in the memory and are configured to be executed by the processor to implement the traffic distribution method for multiple network interfaces in the cloud gateway server according to any one of claims 1 to 2.
5. A computer-readable storage medium, characterized in that, A computer program is stored thereon, and the computer program is loaded by the processor to execute the steps in the traffic distribution method for multiple network interfaces in the cloud gateway server according to any one of claims 1 to 2.
Citation Information
Patent Citations
Network flow processing method, apparatus and device, and storage medium
CN109688069A
Lockless stateful network address translation
CN111866204A
Message processing method and device, electronic equipment and readable storage medium
CN114430394A
CPU load balanced network card flow secondary assignment method, system, device and medium
CN114490039A