Flow transmission method and device

By modifying the source port number of the traffic before transmission, different traffic is allocated to different CPUs, the problem of unbalanced CPU load in multi-core networks is solved and the traffic processing efficiency is improved.

CN120499112APending Publication Date: 2025-08-15QI AN XIN TECHNOLOGY GROUP INC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510828742.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-19
Publication Date
2025-08-15

AI Technical Summary

Technical Problem

Under the multi-core network forwarding technology architecture, the same traffic five-tuple information of the same transceiver and receiver leads to the same hash value, resulting in unbalanced CPU load and reducing traffic processing efficiency.

Method used

Modify the source port number in the quintile information of the traffic before transmission to make it inconsistently the same, and hash calculation based on the modified quintile information to allocate to different CPUs for processing.

Benefits of technology

It realizes the balancing of multi-CPU load, improves traffic processing efficiency, and reduces the complexity of load balancing operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120499112A_ABST
    Figure CN120499112A_ABST
Patent Text Reader

Abstract

The invention provides a traffic transmission method and device, the method is applied to a communication device group, the communication device group comprises a first device and a second device, quintuple information used when the first device communicates with the second device is the same, and the method comprises the following steps: obtaining multiple pieces of traffic sent by the first device; obtaining quintuple information from each piece of flow; modifying the source port number in the quintuple information of each piece of flow to be not completely the same to obtain new quintuple information of each piece of flow; and sending each flow containing the new quintuple information to the second equipment, so that the second equipment distributes each flow to a corresponding CPU (Central Processing Unit) of the second equipment for processing by adopting a Hash algorithm based on the new quintuple information. In the embodiment of the invention, the second equipment calculates different hash values based on the quintuple information in the traffic, so that the traffic sent out from the first equipment in a wholesale can be distributed to different CPUs of the second equipment to be processed, the load of the CPU of the second equipment is relatively balanced, and the traffic processing efficiency is further improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a traffic transmission method, a traffic transmission device, a computer device, a computer-readable storage medium, and a computer program product. Background Art

[0002] In a multi-core network forwarding technology architecture, the traffic diversion mechanism uses a hash calculation based on the traffic's five-tuple to select a core from multiple cores for traffic processing. For example, device A sends traffic to device B. After the traffic reaches device B, the diversion mechanism extracts the five-tuple information from the traffic and then performs a hash calculation on the extracted five-tuple information to obtain a hash value. Device B includes multiple central processing units (CPUs), and different hash values correspond to different CPUs. The diversion mechanism distributes the traffic to the corresponding CPU in device B based on the calculated hash value. The traffic is then processed by the CPU in device B.

[0003] However, in some scenarios, for example, device A is a client and device B is a server. In this case, the five-tuple information of all traffic sent by device A to device B is the same. That is, the source Internet Protocol (IP) address, destination IP address, source port, destination port, and transport layer protocol are all the same. In this way, after hashing the five-tuple information of each traffic sent by device A to device B, the hash value of each traffic is also the same. By allocating CPUs based on the hash values, these traffic flows will be allocated to the same CPU in device B, resulting in load imbalance among multiple CPUs in the device, thereby reducing traffic processing efficiency. Summary of the Invention

[0004] The purpose of the embodiments of the present application is to provide a traffic transmission method, a traffic transmission device, a computer device, a computer-readable storage medium, and a computer program product to reduce the false alarm rate of software code detection.

[0005] To solve the above technical problems, the embodiments of the present application provide the following technical solutions:

[0006] The first aspect of the present application provides a traffic transmission method, which is applied to a communication device group, the communication device group including a first device and a second device, and the first device uses the same five-tuple information when communicating with the second device. The method includes: obtaining multiple traffic flows sent by the first device; obtaining five-tuple information from each traffic flow; modifying the source port number in the five-tuple information of each traffic flow to be not completely the same, to obtain new five-tuple information for each traffic flow; sending each traffic flow containing the new five-tuple information to the second device, so that the second device uses a hash algorithm based on the new five-tuple information to distribute each traffic flow to the corresponding CPU of the second device for processing.

[0007] Compared with the prior art, the traffic transmission method provided in the first aspect of the present application modifies the source port number in the five-tuple of the traffic before sending the traffic from the first device to the second device, so that the source port number corresponding to each traffic is different. In this way, after the traffic is transmitted to the second device, the second device will calculate different hash values based on the five-tuple information in the traffic, and then a batch of traffic sent from the first device will be distributed to different CPUs of the second device for processing, so that the load of the CPU of the second device is more balanced, thereby improving the traffic processing efficiency. Since the simple modification of the source port number can cause a large change in the hash value subsequently calculated based on the five-tuple, while achieving multi-CPU load balancing, it can reduce the complexity of the multi-CPU load balancing operation.

[0008] In other embodiments provided in the present application, the source port number in the five-tuple information of each flow is modified to be not completely the same, including: obtaining the total number of CPUs in the second device; configuring a new port number for the source port number in the five-tuple information of each flow based on the total number, so that each flow using the new port number can be evenly distributed to the various CPUs of the second device based on the hash algorithm.

[0009] When modifying the source port number of each flow, configuring a new port number for each flow according to the total number of CPUs in the second device can ensure that each flow is evenly distributed to each CPU, making the load of the CPU of the second device more balanced and improving traffic processing efficiency.

[0010] In other embodiments provided in the present application, a new port number is configured based on the source port number in the five-tuple information for each flow, including: if the total number is greater than a preset threshold, the CPU of the second device is divided into multiple groups, the number of groups of CPUs is less than the total number of CPUs in the second device, and the CPUs in each group are configured to randomly obtain traffic; and a new port number is configured based on the source port number in the five-tuple information for each flow, based on the number of groups.

[0011] When there are a large number of CPUs, divide the CPUs into a smaller number of groups. This makes it easier to modify the source port numbers of each traffic. For smaller source port number changes, combined with random allocation of CPUs within a group, this can achieve CPU load balancing while simplifying the source port number modification workload and improving source port number modification efficiency.

[0012] In other embodiments provided in the present application, the source port number in the five-tuple information of each flow is modified to be not completely the same to obtain new five-tuple information for each flow, including: modifying the source port number in the five-tuple information of each flow to be not completely the same to obtain the intermediate five-tuple information corresponding to each flow; performing hash calculation on the intermediate five-tuple information corresponding to each flow to obtain the hash value corresponding to each flow; and generating new five-tuple information corresponding to each flow based on the hash value corresponding to each flow and the source port number before modification.

[0013] When modifying the source port number of each flow, a hash calculation is performed on the modified source port number to make the differences between the source port numbers larger and more random. Combined with the source port number before modification, the final source port number of each flow is not only formatted correctly, but also has a greater difference between the source port numbers. This allows different flows to be more evenly distributed to each CPU, making the CPU load more balanced.

[0014] In other embodiments provided in the present application, new five-tuple information corresponding to each flow is generated based on the hash value corresponding to each flow and the source port number before modification, including: performing modulo processing on the hash value corresponding to each flow and the source port number before modification to obtain the remainder corresponding to each flow; adding the remainder corresponding to each flow to the source port number before modification to obtain the new source port number corresponding to each flow; and generating new five-tuple information corresponding to each flow based on the new source port number corresponding to each flow.

[0015] After hashing the modified source port number, the modulo processing is performed again on the source port number before the modification, so that the value obtained by each flow is more random, and then added to the source port number before the modification, so that the source port number finally obtained by each flow is more dispersed, so that different flows can be more evenly distributed to each CPU, making the CPU load more balanced.

[0016] In other embodiments provided in the present application, a hash algorithm is used based on the new five-tuple information to distribute each flow to the corresponding central processing unit CPU of the second device for processing, including: using a hash algorithm to calculate the new five-tuple information of each flow to obtain a hash value corresponding to each flow; based on the hash value corresponding to each flow, according to the correspondence between the hash value and each CPU in the second device, the CPU corresponding to each flow is determined, and the hash value and CPU in the correspondence are in disorder; each flow is distributed to its corresponding CPU for processing.

[0017] When allocating CPUs to traffic based on the hash algorithm, the hash values are assigned to the CPUs in the second device in a random order. This allows for more random CPU allocation for each traffic flow, increasing the probability that different traffic flows are evenly distributed to each CPU, resulting in a more balanced CPU load.

[0018] In other embodiments provided in the present application, before allocating each flow to its corresponding CPU for processing, the method also includes: obtaining the current utilization of each CPU in the second device; and redistributing the portion of the flow allocated to the CPU with the highest current utilization to the CPU with the lowest current utilization.

[0019] Before traffic is actually sent to the CPU for processing, traffic distribution is adjusted based on the current utilization of each CPU. This way, less traffic is provided to CPUs with high utilization, while more traffic is provided to CPUs with low utilization, keeping the CPU load balanced throughout the entire traffic processing process.

[0020] The second aspect of the present application provides a traffic transmission device, which is applied to a communication device group, wherein the communication device group includes a first device and a second device, and the five-tuple information used by the first device and the second device when communicating is the same. The device includes: a first acquisition module, used to obtain multiple traffic sent by the first device; a second acquisition module, used to obtain five-tuple information from each traffic; a modification module, used to modify the source port number in the five-tuple information of each traffic to be not completely the same, so as to obtain new five-tuple information for each traffic; a sending module, used to send each traffic containing the new five-tuple information to the second device, so that the second device uses a hash algorithm based on the new five-tuple information to distribute each traffic to the corresponding central processing unit CPU of the second device for processing.

[0021] A third aspect of the present application provides a computer device, comprising a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method in the first aspect.

[0022] A fourth aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of the method in the first aspect when the computer program is executed by a processor.

[0023] A fifth aspect of the present application provides a computer program product, comprising a computer program, which implements the steps of the method in the first aspect when the computer program is executed by a processor.

[0024] The traffic transmission device provided in the second aspect, the computer equipment provided in the third aspect, the computer-readable storage medium provided in the fourth aspect, and the computer program product provided in the fifth aspect of this application have the same or similar beneficial effects as the traffic transmission method provided in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] The above and other objects, features and advantages of the exemplary embodiments of the present application will become readily understood by reading the detailed description below with reference to the accompanying drawings. In the accompanying drawings, several embodiments of the present application are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:

[0026] Figure 1 This is a schematic diagram of an application scenario of the traffic transmission method in an embodiment of the present application;

[0027] Figure 2 Schematic diagram of the flow transmission method in the embodiment of this application Figure 1 ;

[0028] Figure 3 Schematic diagram of the flow transmission method in the embodiment of this application Figure 2 ;

[0029] Figure 4 This is a schematic diagram of the structure of the flow transmission device in the embodiment of the present application. Figure 1 ;

[0030] Figure 5 This is a schematic diagram of the structure of the flow transmission device in the embodiment of the present application. Figure 2 ;

[0031] Figure 6 Schematic diagram of the structure of the computer device in the embodiment of the present application. DETAILED DESCRIPTION

[0032] The following describes exemplary embodiments of the present application in more detail with reference to the accompanying drawings. Although exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments described herein. Instead, these embodiments are provided to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.

[0033] It should be noted that, unless otherwise specified, the technical or scientific terms used in this application should have the common meanings understood by those skilled in the art to which this application belongs.

[0034] Currently, traffic-based multi-CPU allocation is primarily based on the hash value of the five-tuple information in the traffic. Traffic from the same sender and receiver has the same five-tuple information, resulting in the same calculated hash value. Ultimately, all traffic is assigned to the same CPU, leading to load imbalance across multiple CPUs. All traffic is processed by the same CPU, reducing traffic processing efficiency.

[0035] In view of this, an embodiment of the present application provides a traffic transmission method, a traffic transmission device, a computer device, a computer-readable storage medium, and a computer program product. Before transmitting the traffic to the next device, the source port number in the quintuple of the traffic transmitted in this batch is modified. The difference in source port number will not have a significant impact on the processing of the traffic in the CPU, but can also generate hash values with large differences based on hash calculation, so that different traffic can be allocated to different CPUs, so that the load is balanced between multiple CPUs. Multiple traffic is allocated to different CPUs for processing, which can also improve the processing efficiency of traffic.

[0036] It should be noted here that all components, data and related processing methods involved in this application are authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data comply with the relevant laws, regulations and standards of relevant countries and regions.

[0037] First, the application scenario of the traffic transmission method provided in the embodiment of the present application is described.

[0038] Figure 1 This is a schematic diagram of an application scenario of the traffic transmission method in the embodiment of the present application, see Figure 1 As shown, the scenario may include: a communication device group 11.

[0039] The communication device group 11 includes a first device 111 and a second device 112. The first device 111 and the second device 112 communicate with each other in the same manner. The five-tuple information used by the first device 111 and the second device 112 when communicating is the same. For example, the first device 111 is a device that has a client of an application installed. The second device 112 is the server of the application. In the first device 111, the IP address, port number, and transport layer protocol used for sending and receiving information of the application are the same. For the object to which the first device 111 sends and receives information, that is, the second device 112, the IP address, port number, and transport layer protocol used are also fixed. Therefore, the five-tuple information used by the first device 111 and the second device 112 when communicating is the same. In addition to being the client and server of a certain application, the first device 111 and the second device 112 can also be two devices that have established a dedicated communication channel. The specific types of the first device 111 and the second device 112 are not limited here.

[0040] Both the first device 111 and the second device 112 include multiple CPUs. When each CPU in the first device 111 generates traffic and needs to send the traffic to the second device 112, the same source port number in the five-tuple information in each traffic flow is first modified to be different, and then the multiple traffic flows are sent to the second device 112.

[0041] After receiving multiple traffic flows, the second device 112 extracts five-tuple information from each flow and performs a hash calculation on the extracted five-tuple information. Because the source port numbers corresponding to the various flows are not exactly the same, the hash values calculated for the various flows are also not exactly the same. Therefore, based on the different hash values for the various flows, it is possible to avoid assigning each flow to the same CPU for processing. Instead, each flow is assigned to a different CPU for processing, thereby balancing the load on each CPU in the second device 112.

[0042] In practical applications, the tunnel used to transmit traffic between the first device 111 and the second device 112 can be an Internet Protocol Security (IPSec) tunnel. Traffic transmitted through the IPSec tunnel can be encapsulated using Network Address Translation Traversal (NATT). The protocol can use the User Datagram Protocol (UDP). The UDP port can be 4500. Of course, a corresponding data transmission tunnel, protocol, port, etc. can also be selected according to actual needs.

[0043] Next, the traffic transmission method provided in the embodiment of the present application is described in detail.

[0044] Figure 2 Schematic diagram of the flow transmission method in the embodiment of this application Figure 1 , see Figure 2 As shown, the method may include:

[0045] S21: Acquire multiple flows sent by the first device.

[0046] Sometimes, a first device generates multiple flows within a period of time and needs to send the multiple flows to a second device for processing. After the first device generates the multiple flows and before sending the multiple flows to the second device, the multiple flows can be obtained first.

[0047] The traffic here can refer to the message sent by the first device to the second device. In addition to the actual message content, the message also needs to contain five-tuple information, namely the source IP address, destination IP address, source port number, destination port number and transport layer protocol.

[0048] It should be noted here that the entity that obtains multiple flows and processes the multiple flows, that is, the executing entity of the embodiment of the present application, can be a module in the first device, a module in the second device, that is, a diversion module, or a module outside the first device and the second device.

[0049] S22: Obtain quintuple information from each flow.

[0050] For each flow, we need to extract the quintuple information from the flow. Quintuple information is typically stored in a fixed location within the flow, for example, between characters 1 and n. Therefore, we can directly extract the information from this fixed location, and the extracted information is the quintuple information.

[0051] Alternatively, the quintuple information can be obtained by identifying information in the traffic based on its characteristics. The characteristics of the quintuple information can include a specified combination of two IP addresses, two port numbers, and protocol information. Using the characteristics of the quintuple information can avoid identifying interfering information and improve the accuracy of quintuple information acquisition.

[0052] S23: Modify the source port number in the five-tuple information of each flow to be different, and obtain new five-tuple information of each flow.

[0053] The five-tuple information includes the source IP address, destination IP address, source port number, destination port number, and transport layer protocol. Any changes to the source IP address, destination IP address, destination port number, and transport layer protocol will affect the second device's verification of traffic and the correct transmission of traffic. The source port number is generally less used in traffic verification, and the port from which traffic is actually sent is determined before it is actually sent. Therefore, the source port number can be modified to modify the five-tuple information, thereby achieving the purpose of generating a different hash value.

[0054] When modifying the source port number corresponding to each flow, the source port number corresponding to each flow can be different. That is, the source port number corresponding to one flow is retained, and the source port numbers corresponding to other flows are increased or decreased by different values based on the original value. In this way, the hash value calculated for each flow can be different, making the distribution of each flow to the CPU more even and random, and making the load of each CPU in the second device more balanced.

[0055] In addition to the above-mentioned method of modifying the source port number, since the number of traffic flows is generally greater than the number of CPUs, several flows will be assigned to the same CPU. In order to improve the efficiency of modifying the source port number, and thus improve the efficiency of traffic transmission and processing, only the source port numbers corresponding to some flows can be modified. The specific source port numbers corresponding to the flows to be modified, that is, the number of flows whose source port numbers are modified, can be determined based on the specific number of CPUs and flows, and are not limited here. For example: 10 flows and 4 CPUs, one CPU generally corresponds to 2-3 flows. Therefore, the source port numbers corresponding to 2-3 flows do not need to be modified, that is, the source port numbers corresponding to 7-8 flows can be modified.

[0056] If the source port number of the traffic changes, the traffic will have a new five-tuple. If the source port number of the traffic does not change, the original five-tuple of the traffic will be the new five-tuple.

[0057] S24: Send each flow containing the new five-tuple information to the second device, so that the second device uses a hash algorithm based on the new five-tuple information to distribute each flow to a corresponding central processing unit (CPU) of the second device for processing.

[0058] Each flow containing the new five-tuple information is sent to the second device. The traffic diversion mechanism in the second device extracts the five-tuple information from each flow and hashes the five-tuple information to obtain a hash value corresponding to each flow. In the second device, there is a corresponding relationship between hash values and CPUs. For example, hash value ab corresponds to CPU1, and hash value bc corresponds to CPU2. Therefore, this correspondence can determine the corresponding CPU for each flow in the second device, and the corresponding flow is sent to the corresponding CPU for processing.

[0059] As can be seen from the above content, the traffic transmission method provided in the embodiment of the present application, before sending the traffic from the first device to the second device, first modifies the source port number in the five-tuple of the traffic, so that the source port number corresponding to each traffic is different. In this way, after the traffic is transmitted to the second device, the second device will calculate different hash values based on the five-tuple information in the traffic, and then a batch of traffic sent from the first device will be distributed to different CPUs of the second device for processing, so that the load of the CPU of the second device is more balanced, thereby improving the traffic processing efficiency. Since the simple modification of the source port number can cause a large change in the hash value subsequently calculated based on the five-tuple, while achieving multi-CPU load balancing, it can reduce the complexity of the multi-CPU load balancing operation.

[0060] Furthermore, as a Figure 2 As a refinement and extension of the method shown, an embodiment of the present application also provides a traffic transmission method.

[0061] Figure 3 Schematic diagram of the flow transmission method in the embodiment of this application Figure 2 , see Figure 3 As shown, the method may include:

[0062] S31: Acquire multiple flows sent by the first device.

[0063] S32: Obtain quintuple information from each flow.

[0064] The specific implementation of steps S31 and S32 here is the same as that of steps S21 and S22 in the aforementioned embodiment. Please refer to the relevant description in the aforementioned embodiment and will not be repeated here.

[0065] In the process of modifying the source port number in the five-tuple information of each flow to be different and obtaining the new five-tuple information of each flow, a specific modification method can be used to modify the source port number according to actual needs.

[0066] Specifically, when the source port number modification efficiency needs to be improved, the following steps S33a and S34a may be performed. When the uniformity of each flow in CPU allocation needs to be further improved, the following steps S33b, S34b and S35b may be performed.

[0067] S33a: Obtain the total number of CPUs in the second device.

[0068] Generally speaking, the number of flows sent to the second device at a time is proportional to the number of CPUs in the second device. In other words, some flows will be assigned to the same CPU. In other words, the source port numbers corresponding to flows assigned to the same CPU can be the same. To reduce the number of source port number modifications and thus improve source port number modification efficiency, the source port numbers of each flow can be selectively modified based on the number of CPUs in the second device.

[0069] When specifically obtaining the total number of CPUs in the second device, the total number of CPUs can be obtained in advance from the configuration information of the second device to achieve efficient acquisition of the total number of CPUs. Alternatively, the total number of CPUs can be obtained from the recent historical records of the second device's traffic diversion mechanism, ensuring that the CPUs corresponding to the total number obtained are all operating normally, thereby ensuring that traffic can be processed normally. The specific method for obtaining the total number of CPUs in the second device is not limited here.

[0070] S34a: configuring a new port number based on the total number of source port numbers in the five-tuple information of each flow, so that each flow using the new port number can be evenly distributed to each CPU of the second device based on a hash algorithm.

[0071] If the total number of CPUs is small and the total number of flows is large, you can arrange multiple flows in a loop based on the total number of CPUs, ensuring that the source port numbers for each flow within the loop are different, while the source port numbers for each flow between loops can remain consistent. For example, if the second device has four CPUs, it will receive six flows, each originally corresponding to source port 4500. In this case, the source port numbers of the five flows will be adjusted to 4500, 4501, 4502, 4503, 4500, and 4501, respectively.

[0072] Alternatively, you can first divide the total number of traffic flows by the total number of CPUs, and the resulting integer part or integer part + 1 can be used as the number of traffic flows corresponding to one CPU, and the source port information of the traffic flows corresponding to the integer part or integer part + 1 does not need to be modified. For the remaining traffic flows, different source port numbers are modified in batches according to the number corresponding to the integer part or integer part + 1. For example: the second device includes 4 CPUs, and the second device will obtain 12 traffic flows this time. After calculation, one CPU needs to be allocated 3 traffic flows. Furthermore, among the 12 traffic flows, the source port numbers corresponding to 3 traffic flows do not need to be modified, the source port numbers corresponding to the other 3 traffic flows are modified to a new source port number, and the source port numbers corresponding to the last 3 traffic flows are modified to another new source port number.

[0073] If there are a large number of CPUs but a small number of flows, you can modify the source port number for each flow sequentially, making each flow's source port number unique. This increases the probability that each flow is assigned to a CPU. For example, if the second device has eight CPUs, it will receive six flows. While the source port number for the first flow remains 4500, modify the source port number for the second flow from 4500 to 4501, the source port number for the third flow from 4500 to 4502, and so on, modify the source port number for the sixth flow from 4500 to 4505.

[0074] Sometimes, when there are a large number of CPUs, the CPUs can be divided into multiple groups to more quickly modify the source port numbers corresponding to each flow. While modifying the source port numbers corresponding to each flow based on the number of CPUs, the modification can be performed based on the number of CPU groups, thereby reducing the workload of source port number modification and improving source port number modification efficiency. That is, the number of CPU groups is less than the total number of CPUs in the second device.

[0075] The CPUs in each group are configured to receive traffic randomly. That is, the source port numbers of traffic corresponding to the same group of CPUs can be the same. After the corresponding traffic is assigned to the group through hash calculation, it can be randomly assigned to a CPU in the group.

[0076] Specifically, the above step S34a may include:

[0077] Step A1: If the total number is greater than a preset threshold, the CPUs of the second device are divided into multiple groups.

[0078] The specific value of the preset threshold can be determined according to actual needs and is not specifically limited here.

[0079] When the total number of CPUs in the second device exceeds a preset threshold, it indicates that the second device has a large number of CPUs. With a large number of CPUs, modifying the source port numbers corresponding to each flow based on the total number of CPUs will result in a wide range of source port numbers being modified for each flow, increasing the risk of modification errors. To reduce modification errors, improve the accuracy of source port number modifications, and thereby improve the balance of CPU allocation to each flow, the multiple CPUs are divided into smaller groups.

[0080] When specifically dividing the CPUs, you can divide the CPUs in the second device into several groups, with each group having a fixed number of CPUs. For example, if each group requires 2 CPUs, 12 CPUs can be divided into 6 groups. Alternatively, you can divide the CPUs based on the number of groups required, dividing the CPUs in the second device into a specified number of groups. For example, if each group requires 4 groups, each group has 3 CPUs.

[0081] Of course, CPUs can also be divided into groups based on the difference between the total number and a preset threshold. The greater the difference between the total number and the preset threshold, the higher the probability that a fixed number of groups will be chosen when dividing the CPUs into groups. This allows the total number of groups to be controlled, thereby controlling the range of source port numbers corresponding to each flow, making it easier to improve the accuracy of the modification and, in turn, improving CPU load balancing.

[0082] Step A2: Based on the number of groups, a new port number is configured for the source port number in the five-tuple information of each flow.

[0083] Modify the source port numbers for each flow based on the number of CPU groups. For example, if there are four CPU groups, modify the source port numbers for each flow to any of 4500, 4501, 4502, and 4503. Note that these four port numbers must be evenly distributed across the modified source port numbers for each flow.

[0084] Modifying the source port number corresponding to each flow based on the number of groups is the same as modifying the source port number corresponding to each flow based on the total number of CPUs. Please refer to the relevant instructions in the aforementioned step 34a and will not be repeated here.

[0085] In addition to modifying the source port number corresponding to each flow based on the total number of CPUs in the second device, the source port number corresponding to each flow can also be calculated separately to obtain a different source port number corresponding to each flow. The calculation here can refer to corresponding one source port number to one algorithm, or corresponding different source port numbers to different combination algorithms.

[0086] S33b: Modify the source port number in the five-tuple information of each flow to be different, and obtain the intermediate five-tuple information corresponding to each flow.

[0087] The source port numbers corresponding to the various flows can be modified to be completely different, or partially the same and partially different.

[0088] When making specific modifications, you can keep the source port number corresponding to one flow unchanged, and change the source port numbers corresponding to the remaining flows to different ones. For example: change the source port numbers 4500, 4500, 4500, 4500 corresponding to four flows to 4500, 4501, 4502, 4503. Alternatively, you can keep the source port numbers corresponding to some flows unchanged, and change the source port numbers corresponding to the remaining flows to one of the other port numbers. When making modifications, they are also modified evenly. For example: change the source port numbers 4500, 4500, 4500, 4500, 4500, 4500, 4500, 4500 corresponding to eight flows to 4500, 4501, 4502, 4503, 4500, 4501, 4502, 4503.

[0089] The number of source port numbers that need to be modified in the traffic can be determined based on the total number of traffic and the total number of CPUs in the second device. When the total number of traffic is less than or substantially equal to the total number of CPUs in the second device, the source port numbers corresponding to all traffic can be modified to be different. When the total number of traffic is significantly greater than the total number of CPUs in the second device, only the majority of all traffic needs to be modified, and the source port numbers corresponding to the majority of traffic are modified to the same port number in groups of multiple traffic.

[0090] Regardless of whether the source port number corresponding to each flow is modified or not, combined with the unchanged source IP address, destination IP address, destination port number and transport layer protocol, it constitutes the new five-tuple information corresponding to each flow, that is, the intermediate five-tuple information.

[0091] S34b: Perform hash calculation on the intermediate five-tuple information corresponding to each flow to obtain a hash value corresponding to each flow.

[0092] The so-called hash calculation refers to converting input data of any length (such as files, strings, numbers, etc.) into an output value of fixed length (usually a combination of letters and numbers) through a hash function. This output value is called a hash value.

[0093] Here, for each flow, the input is its intermediate five-tuple information, and the output is the hash value of the corresponding flow.

[0094] Because hash functions can produce significantly different outputs with slightly different inputs, even a slight change in the source port number of a flow can produce a completely different hash value. Subsequent allocation of CPUs to traffic based on the hash value allows for more even distribution of different flows to different CPUs, improving CPU load balancing.

[0095] S35b: Generate new five-tuple information corresponding to each flow based on the hash value corresponding to each flow and the source port number before modification.

[0096] That is, for each flow, the calculated hash value is added to the source port number in the original five-tuple information. This way, the original source port number can be retained in the five-tuple information of the flow, which is convenient for the second device to use for verification, etc., and the second device's traffic diversion mechanism can calculate different hash values based on the five-tuple calculation, which helps to even out the CPU load.

[0097] Alternatively, when the hash value is a pure number, for each flow, the hash value can be added to its original source port number to obtain a new source port number, thereby combining its original source IP address, destination IP address, destination port number and transport layer protocol to generate a new five-tuple information corresponding to each flow.

[0098] To ensure that the source port numbers in the new five-tuple information for each flow are more authentic while maintaining significant differences, thereby avoiding traffic processing issues caused by inconsistent five-tuple information formats and ensuring smooth transmission and processing of traffic, the hash value can also be processed into a format close to the source port number format. Specific processing methods include but are not limited to modulo and digital extraction.

[0099] Specifically, the above step S35b may include:

[0100] Step B1: Perform a modulo process on the hash value corresponding to each flow and the source port number before modification to obtain the remainder corresponding to each flow.

[0101] Modulo means calculating the remainder after dividing two numbers.

[0102] If the hash value contains characters other than numbers, such as letters or special symbols, remove them from the hash value before performing a modulo calculation with the source port number. If the hash value contains only numbers, perform a modulo calculation with the source port number.

[0103] In the modulo calculation between the hash value and the source port number, the object with the larger value can be used as the dividend and the object with the smaller value as the divisor. This will allow you to obtain a remainder that meets the requirements more quickly.

[0104] Step B2: Add the remainder corresponding to each flow to the source port number before modification to obtain a new source port number corresponding to each flow.

[0105] Generally speaking, the remainder is smaller than the source port number, that is, between 0 and the source port number, for example, between 0000 and 4500. The remainder is added to the original source port number to obtain the new source port number corresponding to each flow.

[0106] Step B3: Based on the new source port number corresponding to each flow, generate new five-tuple information corresponding to each flow.

[0107] Each flow has a corresponding new source port number, and when combined with its original source IP address, destination IP address, destination port number, and transport layer protocol, a new five-tuple of information corresponding to each flow is obtained.

[0108] S36: Send each flow containing the new quintuple information to the second device.

[0109] When sending traffic from the first device to the second device, each flow can be sent one by one, avoiding congestion in the same tunnel during traffic transmission and ensuring the smooth transmission of each flow. If the total data volume of the flow does not exceed the tunnel carrying capacity, it can also be sent together to improve traffic transmission efficiency and further enhance traffic processing efficiency.

[0110] S37: A hash algorithm is used to calculate the new five-tuple information of each flow to obtain a hash value corresponding to each flow.

[0111] For the multiple flows received by the second device within a period of time, its diversion mechanism obtains the source IP address, destination IP address, source port number, destination port number and transport layer protocol from the five-tuple information of each flow, and then uses a hash function to calculate the source IP address, destination IP address, source port number, destination port number and transport layer protocol to obtain the hash value corresponding to each flow.

[0112] S38: Based on the hash value corresponding to each flow, and according to the correspondence between the hash value and each CPU in the second device, determine the CPU corresponding to each flow, where the hash value and the CPU in the correspondence are in random order.

[0113] The second device stores a correspondence between hash values and CPUs. Unlike conventional correspondence between hash values and CPUs, the correspondence between hash values and CPUs is not in a specific order. For example, the correspondence between hash values and CPUs is not in the order of hash value 0-10-CPU1, hash value 11-20-CPU2, hash value 21-30-CPU3, and hash value 31-40-CPU4. Instead, the correspondence is in a random order. For example, the correspondence between hash values and CPUs is in the order of hash value 11-20-CPU1, hash value 31-40-CPU2, hash value 0-10-CPU3, and hash value 21-30-CPU4.

[0114] The out-of-order correspondence here can be the normal CPU sorting mentioned above, and the hash value sorting can be disordered and then corresponded in sequence, or it can be the normal hash value sorting, and the CPU sorting can be disordered and then corresponded in sequence, so as to further provide more uniform CPU distribution for traffic.

[0115] The out-of-order correspondence here can also mean that the correspondence between hash values and CPUs changes dynamically after a period of time to avoid traffic always being distributed to the corresponding CPU according to a certain pattern, making the distribution of traffic in the CPU more random and even as a whole, further balancing the CPU load.

[0116] S39: Allocate each flow to its corresponding CPU for processing.

[0117] After determining the corresponding CPU for each flow based on the corresponding relationship, each flow can be sent to the corresponding CPU so that the corresponding CPU processes the corresponding flow.

[0118] In some cases, some CPUs may process the allocated traffic more slowly due to performance issues or other needs. To improve overall traffic processing efficiency, the relationship between allocated traffic and CPUs can be adjusted in a timely manner based on the operating conditions of the CPUs in the second device.

[0119] Specifically, before the above step S39, the method may further include:

[0120] S3901: Obtain the current utilization of each CPU in the second device.

[0121] The current utilization rate of each CPU in the second device is obtained in real time. After the CPU corresponding to each flow is determined based on the corresponding relationship, the utilization rate of each CPU is obtained from the second device.

[0122] CPU utilization is a core metric for measuring processor workload, representing the percentage of time the CPU spends executing active tasks within a specific time period. This CPU utilization can include one or more of the following: user-mode utilization (the percentage of time the CPU spends executing user program code), kernel-mode utilization (the percentage of time the CPU spends executing operating system kernel code), I / O wait time (the percentage of time the CPU is idle and waiting for I / O operations to complete), the number of soft / hard interrupts, and idle time (the percentage of time the CPU is completely idle).

[0123] S3902: Redistribute the portion of traffic allocated to the CPU with the highest current utilization to the CPU with the lowest current utilization.

[0124] High utilization indicates a heavy CPU load, but traffic is evenly distributed across the CPUs. To reduce the burden on high-utilization CPUs and process traffic allocated to them more quickly, the traffic allocated to the CPU with the highest utilization can be transferred to the CPU with the lowest utilization. This reduces traffic queuing time and improves traffic processing efficiency.

[0125] For example, assume the second device includes four CPUs: CPU1, CPU2, CPU3, and CPU4. The current utilization rates of CPU1, CPU2, CPU3, and CPU4 are 50%, 60%, 80%, and 10%, respectively. Based on the corresponding relationship, 80 flows are evenly distributed to the four CPUs: flow 1-20 - CPU1, flow 21-40 - CPU2, flow 41-60 - CPU3, and flow 61-80 - CPU4. Because CPU3's current utilization is higher, some of the flows allocated to CPU3 are directly transferred to CPU4, which has the lowest current utilization. That is, flows 41-50 are transferred to CPU4. At this point, CPU1 receives flows 1-20, CPU2 receives flows 21-40, CPU3 receives flows 51-60, and CPU4 receives flows 41-50 and 61-80.

[0126] The number of traffic flows to be transferred from the currently highest-utilized CPU to the currently lowest-utilized CPU can be determined based on the utilization difference between the two CPUs. The greater the difference in utilization between the two CPUs, the more traffic flows to be transferred from the currently highest-utilized CPU to the currently lowest-utilized CPU. Conversely, the smaller the difference, the fewer traffic flows to be transferred. This automatically balances the CPU load on the second device.

[0127] After the allocation adjustment of each flow and CPU is completed, the flow can be sent to the corresponding CPU according to the final allocation so that the CPU can process the flow.

[0128] At this point, the traffic transmission method provided in the embodiments of the present application has been fully described.

[0129] Based on the same inventive concept, an embodiment of the present application also provides a flow transmission device.

[0130] The traffic transmission device is applied to a communication device group, which includes a first device and a second device. The first device and the second device use the same quintuple information when communicating.

[0131] Figure 4 This is a schematic diagram of the structure of the flow transmission device in the embodiment of the present application. Figure 1 , see Figure 4As shown, the device may include:

[0132] A first acquisition module 41 is configured to acquire multiple flows sent by a first device;

[0133] A second acquisition module 42 is configured to acquire quintuple information from each flow;

[0134] A modification module 43 is used to modify the source port number in the five-tuple information of each flow to be different, thereby obtaining new five-tuple information of each flow;

[0135] The sending module 44 is used to send each flow containing the new five-tuple information to the second device, so that the second device uses a hash algorithm based on the new five-tuple information to distribute each flow to the corresponding central processing unit CPU of the second device for processing.

[0136] Further, as Figure 4 As a refinement and expansion of the device shown, an embodiment of the present application also provides a flow transmission device.

[0137] Figure 5 This is a schematic diagram of the structure of the flow transmission device in the embodiment of the present application. Figure 2 , see Figure 5 As shown, the device may include:

[0138] The first acquisition module 51 is configured to acquire multiple flows sent by a first device.

[0139] The second acquisition module 52 is configured to acquire quintuple information from each flow.

[0140] The modification module 53 includes a first modification unit 531 and a second modification unit 532 .

[0141] The first modification unit 531 is used to obtain the total number of CPUs in the second device; configure a new port number for the source port number in the five-tuple information of each flow based on the total number, so that each flow using the new port number can be evenly distributed to the various CPUs of the second device based on the hash algorithm.

[0142] The first modification unit 531 is specifically used to divide the CPUs of the second device into multiple groups if the total number is greater than a preset threshold, and the number of groups of CPUs is less than the total number of CPUs in the second device, and the CPUs in each group are configured to randomly obtain traffic; based on the number of groups, a new port number is configured for the source port number in the five-tuple information of each traffic.

[0143] The second modification unit 532 is used to modify the source port number in the five-tuple information of each flow to be not completely the same, so as to obtain the intermediate five-tuple information corresponding to each flow; perform hash calculation on the intermediate five-tuple information corresponding to each flow to obtain the hash value corresponding to each flow; and generate new five-tuple information corresponding to each flow based on the hash value corresponding to each flow and the source port number before modification.

[0144] The second modification unit 532 is specifically used to perform modulo processing on the hash value corresponding to each flow and the source port number before modification to obtain the remainder corresponding to each flow; add the remainder corresponding to each flow and the source port number before modification to obtain the new source port number corresponding to each flow; and generate new five-tuple information corresponding to each flow based on the new source port number corresponding to each flow.

[0145] The sending module 54 is configured to send each flow containing the new quintuple information to the second device.

[0146] The diversion module 55 is used to calculate the new five-tuple information of each flow using a hash algorithm to obtain the hash value corresponding to each flow; based on the hash value corresponding to each flow, according to the correspondence between the hash value and each CPU in the second device, the CPU corresponding to each flow is determined, and the hash value and CPU in the correspondence are in disorder; each flow is assigned to its corresponding CPU for processing.

[0147] The traffic distribution module 55 is further configured to obtain the current utilization of each CPU in the second device and redistribute the portion of traffic allocated to the CPU with the highest current utilization to the CPU with the lowest current utilization.

[0148] It should be noted that the description of the above device embodiment is similar to the description of the above method embodiment and has similar beneficial effects as the method embodiment. For technical details not disclosed in the device embodiment of this application, please refer to the description of the method embodiment of this application for understanding.

[0149] Based on the same inventive concept, an embodiment of the present application also provides a computer device.

[0150] Figure 6 This is a schematic diagram of the structure of the computer device in the embodiment of the present application, see Figure 6 As shown, the computer device may include: a memory 61, a processor 62 and a computer program stored in the memory 61, and the processor 62 executes the computer program to implement the method in the above embodiment.

[0151] It should be noted that the description of the above computer device embodiment is similar to the description of the above method embodiment and has similar beneficial effects as the method embodiment. For technical details not disclosed in the computer device embodiment of this application, please refer to the description of the method embodiment of this application for understanding.

[0152] Based on the same inventive concept, an embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon, which implements the method of the aforementioned embodiment when executed by a processor.

[0153] It should be noted that the description of the above computer-readable storage medium embodiment is similar to the description of the above method embodiment and has similar beneficial effects as the method embodiment. For technical details not disclosed in the computer-readable storage medium embodiment of this application, please refer to the description of the method embodiment of this application for understanding.

[0154] Based on the same inventive concept, an embodiment of the present application further provides a computer program product, which includes a computer program that implements the method in the aforementioned embodiment when executed by a processor.

[0155] It should be noted that the description of the above computer program product embodiment is similar to the description of the above method embodiment and has similar beneficial effects as the method embodiment. For technical details not disclosed in the computer program product embodiment of this application, please refer to the description of the method embodiment of this application for understanding.

[0156] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.

Claims

1. A traffic transmission method, characterized in that: The method is applied to a communication device group, the communication device group including a first device and a second device, the first device and the second device using the same quintuple information when communicating, the method including: Obtaining multiple flows sent by the first device; Get five-tuple information from each flow; Modify the source port number in the five-tuple information of each flow to be different, and obtain new five-tuple information of each flow; Each flow containing the new five-tuple information is sent to the second device, so that the second device uses a hash algorithm based on the new five-tuple information to distribute each flow to the corresponding central processing unit CPU of the second device for processing.

2. The method according to claim 1, characterized in that Modifying the source port number in the five-tuple information of each flow to be different includes: Obtaining the total number of CPUs in the second device; A new port number is configured for the source port number in the five-tuple information of each flow based on the total number, so that each flow using the new port number can be evenly distributed to each CPU of the second device based on a hash algorithm.

3. The method according to claim 2, characterized in that The configuring a new port number for the source port number in the five-tuple information of each flow based on the total number includes: If the total number is greater than a preset threshold, dividing the CPUs of the second device into multiple groups, where the number of groups of CPUs is less than the total number of CPUs in the second device, and configuring the CPUs in each group to randomly obtain traffic; A new port number is configured for the source port number in the five-tuple information of each flow based on the group quantity.

4. The method according to claim 1, wherein The source port number in the five-tuple information of each flow is modified to be different to obtain new five-tuple information of each flow, including: Modify the source port number in the five-tuple information of each flow to be different, and obtain the intermediate five-tuple information corresponding to each flow; Perform hash calculation on the intermediate five-tuple information corresponding to each flow to obtain the hash value corresponding to each flow; Based on the hash value corresponding to each flow and the source port number before modification, new five-tuple information corresponding to each flow is generated.

5. The method according to claim 4, characterized in that The method generates new five-tuple information corresponding to each flow based on the hash value corresponding to each flow and the source port number before modification, including: Perform a modulo operation on the hash value corresponding to each flow and the source port number before modification to obtain the remainder corresponding to each flow; Add the remainder corresponding to each flow to the source port number before modification to obtain the new source port number corresponding to each flow; Based on the new source port number corresponding to each flow, new five-tuple information corresponding to each flow is generated.

6. The method according to any one of claims 1 to 5, characterized in that The method of distributing each flow to a corresponding central processing unit (CPU) of the second device for processing by using a hash algorithm based on the new quintuple information includes: The new five-tuple information of each flow is calculated using a hash algorithm to obtain the hash value corresponding to each flow; Determining the CPU corresponding to each flow based on the hash value corresponding to each flow and according to the corresponding relationship between the hash value and each CPU in the second device, where the hash value and the CPU in the corresponding relationship are in a disordered order; Allocate each flow to its corresponding CPU for processing.

7. The method according to claim 6, characterized in that Before allocating each flow to its corresponding CPU for processing, the method further includes: Obtaining a current utilization rate of each CPU in the second device; The traffic allocated to the CPU with the highest utilization is transferred to the CPU with the lowest utilization.

8. A flow transmission device, characterized in that: The apparatus is applied to a communication device group, the communication device group including a first device and a second device, the first device and the second device using the same quintuple information when communicating, and the apparatus includes: A first acquisition module, configured to acquire multiple flows sent by the first device; The second acquisition module is used to obtain five-tuple information from each flow; A modification module is used to modify the source port number in the five-tuple information of each flow to be different, so as to obtain new five-tuple information of each flow; The sending module is used to send each flow containing the new five-tuple information to the second device, so that the second device uses a hash algorithm based on the new five-tuple information to distribute each flow to the corresponding central processing unit CPU of the second device for processing.

9. A computer device comprising a memory, a processor, and a computer program stored in the memory, wherein: The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 7.

10. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.