Network control method and network card
Patent Information
- Application Number
- CN202211024071.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-24
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2042-08-24
AI Technical Summary
[0005] Compared to conventional techniques, the network control method and network card of this invention first remove bits with low randomness from the IP address, and then perform a hash operation based on the modified IP address. This improves the uniformity of packet distribution to the processor, thereby balancing the processor load.
Smart Images

Figure CN117675712B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a network control method and a network card, and more particularly to a network control method and a network card capable of balancing processor load. Background Technology
[0002] Modern computers typically have multiple processors to process network packets in parallel. With technological advancements, the number of network packets continues to increase. To maximize computer performance, balancing the processor load has become a crucial issue in this field. Summary of the Invention
[0003] This invention discloses a network control method for balancing the load of multiple processors, comprising: obtaining an Internet Protocol (IP) address of a packet; deleting some bits of the IP address to generate a sequence based on the IP address bit entropy distribution; performing a hash operation on the sequence to generate a hash value; taking the remainder of the hash value based on the number of processors; and allocating packets to one of the processors corresponding to the remainder.
[0004] This invention discloses a network card comprising a transceiver, a controller, and a memory device. The transceiver is used to receive packets. The memory device is used to store program code and IP address bit entropy distribution. When the program code is executed, it causes the controller to perform the following steps: obtaining the IP address of the packet; deleting some bits of the IP address according to the IP address bit entropy distribution to generate a sequence; performing a hash operation on the sequence to generate a hash value; taking the remainder of the hash value according to the number of processors; and allocating the packet to one of the processors corresponding to the remainder.
[0005] Compared to conventional techniques, the network control method and network card of this invention first remove bits with low randomness from the IP address, and then perform a hash operation based on the modified IP address. This improves the uniformity of packet distribution to the processor, thereby balancing the processor load. Attached Figure Description
[0006] The various aspects of the invention can be best understood by reading the following embodiments and accompanying drawings. It should be noted that, in accordance with standard practice in the art, the various features in the figures are not drawn to scale. In fact, the dimensions of certain features may be intentionally enlarged or reduced for clarity of description.
[0007] Figure 1 This is a schematic diagram of a network card in some embodiments of the present invention.
[0008] Figure 2 This is a schematic diagram illustrating the probability of IP address bits in some embodiments of the present invention.
[0009] Figure 3This is a schematic diagram illustrating IP address operations in some embodiments of the present invention.
[0010] Figure 4 This is a flowchart of a network control method in some embodiments of the present invention. Detailed Implementation
[0011] Figure 1 This is a schematic diagram of a network card 10 according to some embodiments of the present invention. The network card 10 is used to receive network packets 20 and distribute the packets 20 to one of a plurality of processors. For ease of understanding, these processors are designated as 1 to N. In some embodiments, N may be represented as 2. M , where M is a positive integer.
[0012] The network card 10 includes a transceiver 11, a controller 12, and a memory device 13. The transceiver 11 is used to receive packets 20. The memory device 13 is used to store program code. The controller 12 is used to execute the program code to allocate packets 20 to one of the processors 1 to N.
[0013] Packet 20 has an IP address. When executing program code, controller 12 obtains the IP address of packet 20 and performs a hash operation based on the IP address to generate a hash value. Then, controller 12 allocates packet 20 to one of processors 1 to N based on the hash value.
[0014] Packets 20 from different sources have different IP addresses. Generally, performing hash operations on different IP addresses yields different hash values. However, in some embodiments, even different IP addresses may have very low randomness in certain fields. For example, in IPv6 format, different IP addresses may share the same common address prefix, significantly reducing the randomness of that field. Therefore, even the hash value obtained after hash operations may have less than ideal randomness.
[0015] When the randomness of the hash value is not ideal, the distribution of packet 20 to processors 1 to N may not be even. This can cause some processors to be overloaded while others remain idle for too long. To avoid this situation, network card 10 selects the field with higher randomness in the IP address for hash operation based on the IP address bit entropy distribution H. The details are as follows.
[0016] refer to Figure 2 . Figure 2 This is a schematic diagram illustrating the IP address bit probability P in some embodiments of the present invention. The IP address bit probability P is interpreted in IPv6 format. However, it should be understood that the present invention is not limited to IPv6 format, and the IP address of packet 20 can be in IPv6 or IPv4 format.
[0017] In some embodiments, the IP address bit probability P is a statistical distribution based on all possible existing IP addresses, where the vertical axis represents the probability of a 1, and the horizontal axis represents the position of the IP address. For example... Figure 2 As shown, the probability of a 1 appearing in some bits is almost 1, and the probability of a 0 appearing in some bits is almost 1. The IP address bit probability P can be converted into the IP address bit entropy distribution H through equation (1).
[0018] H = -[P·log2P + (1-P)·log2(1-P)]; Equation (1).
[0019] The bit entropy distribution H of an IP address represents the normalized randomness (or scrambling rate) of the corresponding bit (field) in the IP address. In the case of the lowest randomness, for example, when the probability P of the second bit in the IP address being 1 is equal to 1 (or equal to 0), equation (1) shows that the bit entropy distribution H of the IP address corresponding to the second bit is equal to 0. Conversely, in the case of the highest randomness, for example, when the probability P of the 100th bit in the IP address being 1 is equal to 0.5, equation (1) shows that the bit entropy distribution H of the IP address corresponding to the 100th bit is equal to 1.
[0020] Please refer to Figure 3 When executing the program code, controller 12 deletes bits in the IP address whose bit entropy distribution H is less than a preset value, and concatenates the remaining bits into a sequence S. Figure 3 For example, if the IP address bit entropy distribution H of bits 1-16 and 33-48 of the IP address is less than a preset value, the controller 12 will delete bits 1-16 and 33-48 of the IP address and concatenate the remaining bits 17-32, 49-64, and 65-128 into a sequence S. In some embodiments, the preset value is approximately equal to 0.3.
[0021] Controller 12 divides sequence S into multiple segments. In some embodiments, each segment contains 16 bits. Figure 3 As shown, sequence S is divided into 6 segments S1 to S6. Before performing the hash operation, controller 12 first performs a mutual exclusive OR (XOR) operation on the first segment S1 and the second segment S2 to produce a result R1. Controller 12 then performs a hash operation on the result R1 to produce a hash value.
[0022] The controller 12 assigns packet 20 to one of the processors 1 to N based on the hash value. Specifically, the controller 12 divides the hash value by N to obtain a remainder a (for example, remainder a is 3), and then assigns packet 20 to the corresponding processor a (corresponding to processor 3).
[0023] In some embodiments, the controller 12 further performs an XOR operation on the result R1 and the third segment S3 to produce the result R2, performs an XOR operation on the result R2 and the fourth segment S4 to produce the result R3, performs an XOR operation on the result R3 and the fifth segment S5 to produce the result R4, and performs an XOR operation on the result R4 and the sixth segment S6 to produce the result R5. For the sake of simplicity, some operations are not shown. Figure 3 middle.
[0024] In some embodiments, the controller 12 selects one of the results R1 to R5 to perform a hash operation to generate a hash value, and determines which of the results R1 to R5 has the greatest randomness. Finally, the packet 20 is allocated to one of the processors 1 to N based on the hash value with the greatest randomness.
[0025] In some embodiments, before performing the XOR operation, the controller 12 determines whether each bit of the first segment S1 is independent based on the IP address specification; that is, it determines whether these bits are identical under all circumstances. When each bit of the first segment S1 is independent, the controller 12 performs the XOR operation. Conversely, when some bits of the first segment S1 are not independent, the controller 12 takes a bit from another segment in sequence S to replace them. For example, when the Xth bit and the Yth bit of the first segment S1 are not independent, the controller 12 takes one bit from the fifth segment S5 to replace the Yth bit of the first segment S1. It should be understood that the above situation is explained with the first segment S1. Before performing the XOR operation, the controller 12 can determine whether the bits in each segment are independent and decide whether to replace the non-independent bits with a bit from another segment.
[0026] In some embodiments, since the bit entropy distribution H of bits 81 to 128 in the original IP address is relatively high, when a segment of bits is not independent of each other, one of bits 81 to 128 in the original IP address is extracted to replace the bits that are not independent of each other.
[0027] refer to Figure 4 . Figure 4 This is a flowchart of a network control method 40 in some embodiments of the present invention. In some embodiments, a network card 10 is used to execute the network control method 40. For ease of understanding, the network control method 40 is described as follows: Figures 1-3 Explanation of reference numerals. Network control method 40 includes steps S41, S42, S43, S44, and S45.
[0028] In step S41, controller 12 obtains the IP address of packet 20. In step S42, controller 12 removes some bits from the IP address according to the IP address bit entropy distribution H to generate sequence S. In step S43, controller 12 performs a hash operation on the sequence to generate a hash value. In step S44, controller 12 takes the remainder of the hash value based on the number of processors N. In step S45, controller 12 assigns packet 20 to one of the processors 1 to N corresponding to the remainder.
[0029] This invention is not limited to the network control method 40 described above, but can be applied to various other methods. Figures 1-3 All operations are within the scope of network control method 40.
[0030] The foregoing description briefly outlines the features of certain embodiments of the present invention, enabling those skilled in the art to more fully understand the various forms of the invention. Those skilled in the art will readily recognize that the present invention can serve as a basis for designing or modifying other processes and structures to achieve the same objectives and / or advantages as the embodiments described herein. Those skilled in the art should understand that these equivalent embodiments remain within the spirit and scope of the present invention, and various changes, substitutions, and modifications can be made without departing from the spirit and scope of the present invention.
[0031] [Symbol Explanation]
[0032] 10: Network card
[0033] 11: Transceiver
[0034] 12: Controller
[0035] 13: Memory devices
[0036] 20: Packet
[0037] 1: Processor
[0038] 2: Processor
[0039] N: Processor
[0040] P: IP address bit probability
[0041] S: sequence
[0042] S1: Section
[0043] S2: Section
[0044] S3: Section
[0045] S4: segment
[0046] S5: Section
[0047] S6: Section
[0048] R1: Result
[0049] R2: Results
[0050] R3: Results
[0051] 40: Network Control Methods
[0052] S41: Steps
[0053] S42: Steps
[0054] S43: Steps
[0055] S44: Steps
[0056] Step S45.
Claims
1. A network control method for balancing the load of multiple processors, comprising: Obtain the Internet Protocol (IP) address of a packet; Based on the bit entropy distribution of an IP address, delete bits in the IP address whose bit entropy is less than a preset value, and concatenate the remaining bits in the IP address to generate a sequence. Perform a hash operation on the sequence to produce a hash value; Take the remainder of the hash value based on the number of processors; and The packet is assigned to one of the plurality of processors corresponding to the remainder.
2. The network control method as described in claim 1, wherein the IP address bit entropy distribution corresponds to the bit entropy of each bit of the IP address.
3. The network control method as described in claim 2, wherein the step of performing the hash operation on the sequence to generate the hash value comprises: Divide the sequence into multiple segments; Perform a mutually exclusive OR operation on a first segment and a second segment of the plurality of segments to produce a first result; and The hash operation is performed based on the first result to produce the hash value.
4. The network control method of claim 3, wherein the step of performing the hash operation on the sequence to generate the hash value further comprises: Perform the mutually exclusive OR operation between the first result and a third segment of the plurality of segments to produce a second result. The step of performing the hash operation to generate the hash value based on the first result is further performed based on the second result.
5. The network control method of claim 3, wherein the step of performing the hash operation on the sequence to generate the hash value further comprises: Before performing the mutual exclusion OR operation on the first segment and the second segment, determine whether each bit of the first segment is independent based on the IP address specification; and When the Xth bit and the Yth bit of the first segment are not independent of each other, a compensation bit is obtained from the deleted bits to replace the Yth bit in order to update the first segment.
6. The network control method as described in claim 5, wherein the compensation bit is located between bits 81 and 128 of the IP address.
7. A network card, comprising: A transceiver is used to receive a packet; One controller; A memory device for storing program code and an IP address bit entropy distribution, wherein when the program code is executed, the controller performs the following steps: Obtain the IP address of the packet; Based on the bit entropy distribution of the IP address, delete bits in the IP address whose bit entropy is less than a preset value, and concatenate the remaining bits in the IP address to generate a sequence; Perform a hash operation on the sequence to produce a hash value; Take the remainder of the hash value based on the number of processors; and The packet is assigned to one of the plurality of processors corresponding to the remainder.
8. The network card of claim 7, wherein the IP address bit entropy distribution corresponds to the bit entropy of each bit of the IP address.
9. The network card of claim 8, wherein the step of performing the hash operation on the sequence to generate the hash value comprises: Divide the sequence into multiple segments; Perform a mutually exclusive OR operation on a first segment and a second segment of the plurality of segments to produce a first result; and The hash operation is performed based on the first result to produce the hash value.
10. The network card of claim 9, wherein the step of performing the hash operation on the sequence to generate the hash value further comprises: Before performing the mutual exclusion OR operation on the first segment and the second segment, determine whether each bit of the first segment is independent based on the IP address specification; and When the Xth bit and the Yth bit of the first segment are not independent of each other, a compensation bit is obtained from the deleted bits to replace the Yth bit in order to update the first segment.
Citation Information
Patent Citations
Data rapid processing method aiming at IPv6 address
CN104917852A
Method for detection of address entropy
CN106453226A