A method for determining a load balancing algorithm and a network device

By calculating the equalization coefficient of the load balancing algorithm, selecting the appropriate algorithm to allocate data flow to multiple ports of the network device, solving the problem of port load imbalance, realizing the balanced allocation of port data volume, and improving the performance of network devices.

CN113518098BActive Publication Date: 2025-07-29HUAWEI TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202010272937.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-04-09
Publication Date
2025-07-29
Estimated Expiration
2040-04-09

AI Technical Summary

Technical Problem

In prior art In network equipment, there is an unbalanced problem of port load allocation of multiple data streams, resulting in excessive load on some ports and insufficient load on other ports.

Method used

By obtaining the data flow information within the set time period, calculating the balance coefficient in the load balancing algorithm set, and selecting an algorithm that meets the load balancing conditions as the new load balancing algorithm, which is used to allocate data flow to multiple ports to achieve equalization of port data volume.

Benefits of technology

It effectively ensures that the data volume of multiple ports of network equipment is more balanced, and avoids resource waste and performance degradation caused by unbalanced port load.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113518098B_ABST
    Figure CN113518098B_ABST
Patent Text Reader

Abstract

The present application discloses a method for determining a load balancing algorithm and a network device. The network device obtains the information of each data stream among multiple data streams forwarded through a link group within a set time period, and the link group corresponds to M ports. The network device calculates the equilibrium coefficient Yi corresponding to the i-th load balancing algorithm in the load balancing algorithm set according to the information of each data stream among the multiple data streams and the M ports, and the load balancing algorithm set includes N load balancing algorithms. When the equilibrium coefficient Yi meets the load balancing condition, the network device determines the i-th load balancing algorithm as the new load balancing algorithm of the network device. In the present application, the network device uses the i-th load balancing algorithm to allocate the data streams subsequently received by the network device to the M ports, which can ensure that the data volume load of the M ports of the network device is in a balanced state.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communication technologies, and more specifically, to a method for determining a load balancing algorithm and a network device. Background Art

[0002] Currently, in technical scenarios such as Ethernet link aggregation (Eth-Trunk) or equal cost multipath routing (ECMP), when a network device allocates ports to multiple received data streams, it usually determines the mapping relationship between the multiple data streams and multiple ports according to a pre-configured hash algorithm in the network device and information such as the source IP address of the data stream, and allocates the multiple data streams to multiple ports of the network device according to this mapping relationship.

[0003] For example, assume that switch A includes port a1 and port a2, and the hash algorithm crc16-lower is pre-configured in switch A. Assume that at a certain moment, switch A receives data stream L1 and data stream L2, and the data volume of both data stream L1 and data stream L2 is 10 MB / s. Assume that switch A uses the hash algorithm crc16-lower, the source IP address of data stream L1, and the source IP address of data stream L2 to determine that both data stream L1 and data stream L2 correspond to port a1. That is, both data stream L1 and data stream L2 are allocated to port a1, and the data volume transmitted by port a1 is 20 MB / s, and port a2 is idle, resulting in an unbalanced data volume load between port a1 and port a2 of switch A.

[0004] From the above example, it can be understood that using the pre-configured hash algorithm in the network device to determine the port corresponding to each data stream has strong randomness, and it is very likely to cause an unbalanced data volume load on multiple ports of the network device. Therefore, how to ensure a more balanced data volume load on multiple ports of the network device has become a technical problem that urgently needs to be solved at present. Summary of the Invention

[0005] This application provides a method for determining a load balancing algorithm and a network device to ensure a more balanced data volume load on multiple ports of the network device.

[0006] First aspect, this application provides a method for determining a load balancing algorithm. The method includes: a network device obtains information of each data stream among multiple data streams forwarded by a link group within a set time period. The link group corresponds to M ports, and M is greater than or equal to 2. The network device calculates an equilibrium coefficient Yi corresponding to the i-th load balancing algorithm in a set of load balancing algorithms according to the information of each data stream among the multiple data streams and the M ports. The set of load balancing algorithms includes N load balancing algorithms, N is greater than or equal to 2, and i ∈ [1, N]. When the equilibrium coefficient Yi meets the load balancing condition, the network device determines the i-th load balancing algorithm as the new load balancing algorithm of the network device.

[0007] In the first aspect, the network device can select the i-th load balancing algorithm in the set of load balancing algorithms as the new load balancing algorithm according to the information of each data stream among the multiple data streams and the M ports. Using the i-th load balancing algorithm to allocate the data streams subsequently received by the network device to the M ports can ensure that the data volume loads of the M ports of the network device are in a balanced state.

[0008] In a possible implementation manner of the first aspect, the equilibrium coefficient Yi meeting the load balancing condition includes: the equilibrium coefficient Yi is the first one among the equilibrium coefficients of the N load balancing algorithms that meets a set load balancing threshold; or the equilibrium coefficient Yi is the optimal one among the equilibrium coefficients of the N load balancing algorithms.

[0009] Among them, if the equilibrium coefficient Yi is the first equilibrium coefficient among the equilibrium coefficients of the N load balancing algorithms that meets the set load balancing threshold, then the network device can more quickly determine the i-th load balancing algorithm corresponding to the equilibrium coefficient Yi that meets the load balancing threshold among the N load balancing algorithms, so that the i-th load balancing algorithm can ensure that the data volume loads of the M ports of the network device are in a balanced state.

[0010] Among them, if the equilibrium coefficient Yi is the optimal equilibrium coefficient among the equilibrium coefficients of the N load balancing algorithms, then the network device can determine the i-th load balancing algorithm corresponding to the optimal equilibrium coefficient Yi among the N load balancing algorithms, so that the i-th load balancing algorithm can ensure that the data volume loads of the M ports of the network device are in a balanced state.

[0011] In a possible implementation manner of the first aspect, the information of the data stream includes the identifier of the data stream and the data volume of the data stream within the set time period.

[0012] In a possible implementation of the first aspect, the network device calculates the equilibrium coefficient Yi corresponding to the i-th load balancing algorithm in the set of load balancing algorithms according to the information of each data stream in multiple data streams and M ports, including: the network device calculates the allocation value of each data stream according to the i-th load balancing algorithm and the identifier of each data stream in multiple data streams; the network device determines the port corresponding to the data stream from M ports according to the allocation value of each data stream; the network device determines the data volume of the port according to the data stream corresponding to each port in M ports and the data volume of the data stream within a set time period; the network device calculates the equilibrium coefficient Yi according to the data volumes of M ports.

[0013] In a possible implementation of the first aspect, the equilibrium coefficient Yi is the coefficient of variation. The network device calculates the equilibrium coefficient Yi according to the data volumes of M ports, including: the network device calculates the average value Ui of the data volumes of M ports; the network device calculates the variance Fi of the data volumes of M ports; the network device calculates the standard deviation Bi of the data volumes of M ports according to the variance Fi; the network device calculates the coefficient of variation of the data volumes of M ports according to the standard deviation Bi and the average value Ui to obtain the equilibrium coefficient Yi.

[0014] Among them, the coefficient of variation is used to indicate whether the data volumes of M ports are balanced. The larger the coefficient of variation, the more unbalanced the data volumes of M ports are. The smaller the coefficient of variation, the more balanced the data volumes of M ports are. When the coefficient of variation is 0, it indicates that the data volumes of M ports are in a completely balanced state. Therefore, the corresponding load balancing algorithm can be measured by the coefficient of variation to ensure that the data volume load of M ports of the network device is in a balanced state.

[0015] In a possible implementation of the first aspect, the equilibrium coefficient Yi is the range. The network device calculates the equilibrium coefficient Yi according to the data volumes of M ports, including: the network device determines the first port and the second port among M ports. The first port has the maximum bandwidth utilization rate, and the second port has the minimum bandwidth utilization rate. The bandwidth utilization rate of a port is the quotient of the data volume of the port and the bandwidth of the port; the network device calculates the difference between the bandwidth utilization rate of the first port and the bandwidth utilization rate of the second port to obtain the equilibrium coefficient Yi.

[0016] Among them, the range is used to indicate whether the bandwidth utilization rates of M ports are balanced. The larger the range, the more unbalanced the bandwidth utilization rates of M ports are. The smaller the range, the more balanced the bandwidth utilization rates of M ports are. When the range is 0, it indicates that the bandwidth utilization rates of M ports are in a completely balanced state. Therefore, the corresponding load balancing algorithm can be measured by the range to ensure that the data volume load of M ports of the network device is in a balanced state.

[0017] In a possible implementation of the first aspect, the balance coefficient Yi is the range. The network device calculates the balance coefficient Yi based on the data volumes of the M ports, including: the network device determines a first port and a second port among the M ports, where the first port has the largest data volume and the second port has the smallest data volume; the network device calculates the difference between the data volume of the first port and the data volume of the second port to obtain the balance coefficient Yi.

[0018] Among them, the range is used to indicate whether the bandwidth utilization rates of the M ports are balanced. The larger the range, the more unbalanced the bandwidth utilization rates of the M ports are. The smaller the range, the more balanced the bandwidth utilization rates of the M ports are. When the range is 0, it indicates that the bandwidth utilization rates of the M ports are in a completely balanced state. Therefore, the range can be used to measure whether the corresponding load balancing algorithm can ensure that the data volume loads of the M ports of the network device are in a balanced state.

[0019] In a possible implementation of the first aspect, the information of the data stream further includes the port that forwards the data stream within the set time period. After the network device obtains the information of each data stream in the multiple data streams forwarded through the link group within the set time period, the method further includes: the network device determines whether the data volumes of the M ports are balanced based on the port that forwards the data stream within the set time period and the data volume of the data stream within the set time period; when the data volumes of the M ports are unbalanced within the set time period, perform the step of the network device calculating the balance coefficient Yi corresponding to the i-th load balancing algorithm in the load balancing algorithm set according to the information of each data stream in the multiple data streams and the M ports.

[0020] In a second aspect, the present application provides a network device, including: an acquisition module, configured to acquire the information of each data stream in the multiple data streams forwarded through the link group within the set time period, where the link group corresponds to M ports, and M is greater than or equal to 2; a calculation module, configured to calculate the balance coefficient Yi corresponding to the i-th load balancing algorithm in the load balancing algorithm set according to the information of each data stream in the multiple data streams and the M ports, where the load balancing algorithm set includes N load balancing algorithms, N is greater than or equal to 2, and i ∈ [1, N]; a first determination module, configured to determine the i-th load balancing algorithm as the new load balancing algorithm of the network device when the balance coefficient Yi meets the load balancing condition.

[0021] In a possible implementation of the second aspect, that the balance coefficient Yi meets the load balancing condition includes: the balance coefficient Yi is the first one among the balance coefficients of the N load balancing algorithms that meets the set load balancing threshold; or the balance coefficient Yi is the optimal one among the balance coefficients of the N load balancing algorithms.

[0022] In a possible implementation of the second aspect, the information of the data stream includes the identifier of the data stream and the data volume of the data stream within the set time period.

[0023] In a possible implementation of the second aspect, a calculation module is configured to calculate an allocation value for each data stream according to the i-th load balancing algorithm and the identifier of each data stream in multiple data streams; determine the port corresponding to the data stream from M ports according to the allocation value of each data stream; determine the data volume of the port according to the data stream corresponding to each port among the M ports and the data volume of the data stream within a set time period; calculate a balance coefficient Yi according to the data volumes of the M ports.

[0024] In a possible implementation of the second aspect, a calculation module is configured to calculate an average value Ui of the data volumes of the M ports; calculate a variance Fi of the data volumes of the M ports; calculate a standard deviation Bi of the data volumes of the M ports according to the variance Fi; calculate a coefficient of variation of the data volumes of the M ports according to the standard deviation Bi and the average value Ui to obtain a balance coefficient Yi.

[0025] In a possible implementation of the second aspect, a calculation module is configured to determine a first port and a second port among the M ports, where the first port has the highest bandwidth utilization rate and the second port has the lowest bandwidth utilization rate, and the bandwidth utilization rate of a port is the quotient of the data volume of the port and the bandwidth of the port; calculate the difference between the bandwidth utilization rate of the first port and the bandwidth utilization rate of the second port to obtain a balance coefficient Yi.

[0026] In a possible implementation of the second aspect, a calculation module is configured to determine a first port and a second port among the M ports, where the first port has the largest data volume and the second port has the smallest data volume; calculate the difference between the data volume of the first port and the data volume of the second port to obtain a balance coefficient Yi.

[0027] In a possible implementation of the second aspect, the network device further includes a second determination module configured to determine whether the data volumes of the M ports are balanced within a set time period according to the ports for forwarding data streams within the set time period and the data volumes of the data streams within the set time period; and call the calculation module when the data volumes of the M ports are not balanced within the set time period.

[0028] In a third aspect, the present application provides a network device, including a controller, a forwarder, and M ports, where M is greater than or equal to 2, and the M ports correspond to M links, and the M links form a link group. The controller is configured to obtain information of each data stream in multiple data streams forwarded through the link group within a set time period from the forwarder, and calculate a balance coefficient Yi corresponding to the i-th load balancing algorithm in the load balancing algorithm set according to the information of each data stream in the multiple data streams and the M ports, and determine the i-th load balancing algorithm as the new load balancing algorithm of the network device when the balance coefficient Yi meets the load balancing condition.

[0029] Fourth aspect, the present application provides a network device, including a transponder and M ports, where M is greater than or equal to 2. The M ports correspond to M links, and the M links form a link group. The transponder is configured to obtain information of each data stream among multiple data streams forwarded through the link group within a set time period, and calculate an equilibrium coefficient Yi corresponding to the i-th load balancing algorithm in the load balancing algorithm set according to the information of each data stream among the multiple data streams and the M ports. When the equilibrium coefficient Yi meets the load balancing condition, determine the i-th load balancing algorithm as the new load balancing algorithm of the network device.

[0030] Fifth aspect, an embodiment of the present application provides a network device. The network device includes a processor, a memory, and M ports, where M is greater than or equal to 2. The M ports correspond to M links, and the M links form a link group. Among them, the processor is configured to read software code stored in the memory and execute the method in the first aspect or any possible implementation manner of the first aspect. Description of the Drawings

[0031] Figure 1 The following is a schematic diagram of the scenario of Ethernet link aggregation provided by an embodiment of the present application;

[0032] Figure 2 The following is a schematic diagram of the scenario of equivalent multi-path provided by an embodiment of the present application;

[0033] Figure 3 The following is a flowchart of a method for determining a load balancing algorithm provided by an embodiment of the present application;

[0034] Figure 4 The following is a flowchart of another method for determining a load balancing algorithm provided by an embodiment of the present application;

[0035] Figure 5 The following is a flowchart of yet another method for determining a load balancing algorithm provided by an embodiment of the present application;

[0036] Figure 6 The following is a flowchart of yet another method for determining a load balancing algorithm provided by an embodiment of the present application;

[0037] Figure 7 The following is a schematic diagram of the structure of a network device provided by an embodiment of the present application;

[0038] Figure 8 The following is a schematic diagram of the structure of another network device provided by an embodiment of the present application;

[0039] Figure 9 The following is a schematic diagram of the structure of yet another network device provided by an embodiment of the present application;

[0040] Figure 10The following is a schematic structural diagram of another network device provided by an embodiment of the present application. Detailed implementation manners

[0041] Please refer to Figure 1 as shown in Figure 1 The following is a schematic diagram of an Ethernet link aggregation scenario provided by an embodiment of the present application. In Figure 1 the shown embodiment, port a1 of switch A is connected to port b1 of switch B through physical link x1, and port a2 of switch A is connected to port b2 of switch B through physical link x2. To implement link aggregation between switch A and switch B, physical link x1 and physical link x2 need to be aggregated together to form a logical link S1.

[0042] Please refer to Figure 2 as shown in Figure 2 The following is a schematic diagram of an equal-cost multi-path scenario provided by an embodiment of the present application. In Figure 2 the shown embodiment, port c1 of switch C is connected to switch D through physical link y1, port c2 of switch C is connected to switch E through physical link y2, switch D is connected to switch F through physical link z1, and switch E is connected to switch F through physical link z2. Among them, physical link y1 and physical link z1 form path 1, and physical link y2 and physical link z2 form path 2.

[0043] In the present application, multiple links in a logical link or multiple paths of equal-cost multi-path are collectively referred to as a link group. For example, Figure 1 x1 and x2 in Figure 2 form a link group, and Figure 1 path 1 and path 2 in Figure 2 form another link group. An embodiment of the present application provides a method for determining a load balancing algorithm to achieve load balancing among multiple ports corresponding to a link group. For example, in Figure 1 the shown embodiment, the method for determining a load balancing algorithm provided by the embodiment of the present application can be used to ensure more balanced load of the data volume of port a1 and port a2 of switch A. In Figure 2 the shown embodiment, the method for determining a load balancing algorithm provided by the embodiment of the present application can be used to ensure more balanced load of the data volume of port c1 and port c2 of switch C.

[0044] Please refer to Figure 3 as shown in Figure 3 The following is a flowchart of a method for determining a load balancing algorithm provided by an embodiment of the present application. Figure 3 The method shown includes the following steps.

[0045] S101. The network device obtains the information of each data stream among multiple data streams forwarded by the link group within a set time period.

[0046] Among them, the network device can be a device such as a switch or a router. The network device has M ports, and the M ports of the network device are connected to M links. The M links form a link group, and this link group corresponds to the M ports. M is a positive integer greater than or equal to 2.

[0047] The link group can be a link group in the Equal-Cost Multi-Path (ECMP) scenario, or a link group in the Link Aggregation Control Protocol (LACP) scenario, or a link group for load sharing in other scenarios.

[0048] The set time period refers to a past historical time period, and the time length of the set time period can be set according to the actual situation.

[0049] For example, the time period between one second before the current time and the current time can be determined as the set time period. For example, assuming the current time is 20:20:10 on April 1, 2020, then the time period from 20:20:09 on April 1, 2020 to 20:20:10 on April 1, 2020 can be determined as the set time period.

[0050] Before S101, the network device has forwarded multiple data streams through the link group within the set time period. To determine how to forward multiple data streams using M ports to achieve data volume load balancing among the M ports, the network device needs to obtain the information of each data stream among the multiple data streams forwarded by the link group in S101. Among them, the information of the data stream includes the identifier of the data stream and the data volume of the data stream within the set time period.

[0051] S102. The network device calculates the equilibrium coefficient Yi corresponding to the i-th load balancing algorithm in the load balancing algorithm set according to the information of each data stream among the multiple data streams and the M ports.

[0052] Among them, the load balancing algorithm set includes N load balancing algorithms, N is greater than or equal to 2, and i ∈ [1, N]. The equilibrium coefficient Yi is used to illustrate whether the data volume load among the M ports is balanced after distributing the multiple data streams to the M ports using the i-th load balancing algorithm.

[0053] The N load balancing algorithms in the load balancing algorithm set can be various different types of hash algorithms, ensuring that any two load balancing algorithms in the load balancing algorithm set are different. For example, the load balancing algorithm can be a hash algorithm such as a low 16-bit cyclic redundancy check (CRC) algorithm, a high 16-bit cyclic redundancy check algorithm, a low 32-bit cyclic redundancy check algorithm, or a high 32-bit cyclic redundancy check algorithm. Of course, the load balancing algorithm can also be other types of algorithms. For example, the load balancing algorithm is to take the remainder.

[0054] After the network device obtains the information of each data stream in the multiple data streams forwarded through the link group within a set time period, the network device obtains the i-th load balancing algorithm among the N pre-stored load balancing algorithms. Then, the network device executes step S102 and obtains the balance coefficient Yi corresponding to the i-th load balancing algorithm. The network device determines whether the balance coefficient Yi meets the load balancing condition. If the balance coefficient Yi meets the load balancing condition, it means that the i-th load balancing algorithm is more suitable for the network device to distribute multiple data streams to M ports, that is, the i-th load balancing algorithm can ensure that the data volume load of the M ports of the network device is more balanced; if the balance coefficient Yi does not meet the load balancing condition, it means that the i-th load balancing algorithm is not suitable for the network device to distribute multiple data streams to M ports.

[0055] S103. When the balance coefficient Yi meets the load balancing condition, the network device determines the i-th load balancing algorithm as the new load balancing algorithm of the network device.

[0056] Among them, there are two cases where the balance coefficient Yi meets the load balancing condition, and these two cases are introduced separately below.

[0057] The first case is that the balance coefficient Yi meets the load balancing condition can be: the balance coefficient Yi is the first one among the balance coefficients of the N load balancing algorithms that meets the set load balancing threshold.

[0058] In the first case, the network device pre-stores N load balancing algorithms. The network device calculates the information of each data stream in the multiple data streams and M ports using the load balancing algorithms among the N load balancing algorithms in the preset order and obtains the balance coefficient. During the calculation process of the network device, the i-th load balancing algorithm corresponding to the balance coefficient Yi that meets the load balancing threshold for the first time is determined as the new load balancing algorithm of the network device. After the network device determines the i-th load balancing algorithm as the new load balancing algorithm of the network device, the network device will stop calculating the remaining load balancing algorithms among the N load balancing algorithms.

[0059] For example, assume that 10 load balancing algorithms A1 - A10 are pre - stored in the network device. The network device will select the first load balancing algorithm A1 from the 10 load balancing algorithms in the preset order. Assume that the network device uses the load balancing algorithm A1 to calculate the information of each data stream among multiple data streams and M ports and obtains the balance coefficient Y1. The network device determines whether the balance coefficient Y1 meets the set load balancing threshold. If the balance coefficient Y1 meets the set load balancing threshold, then the network device will determine the load balancing algorithm A1 corresponding to the balance coefficient Y1 as the new load balancing algorithm of the network device; if the balance coefficient Y1 does not meet the set load balancing threshold, then the network device will select other load balancing algorithms from the 10 load balancing algorithms in the preset order for calculation until the balance coefficient Yi corresponding to the selected i - th load balancing algorithm meets the set load balancing threshold, then the network device will determine the i - th load balancing algorithm as the new load balancing algorithm of the network device.

[0060] In the second case, the condition that the balance coefficient Yi meets the load balancing condition can also be: the balance coefficient Yi is the optimal among the balance coefficients of N load balancing algorithms.

[0061] In the second case, N load balancing algorithms are pre - stored in the network device. The network device will use the N load balancing algorithms to calculate the information of each data stream among multiple data streams and M ports and obtain N balance coefficients. After the network device calculates the N balance coefficients, the network device will determine the i - th load balancing algorithm corresponding to the optimal balance coefficient Yi among the N balance coefficients as the new load balancing algorithm of the network device.

[0062] Among them, the i - th load balancing algorithm corresponding to the optimal balance coefficient Yi among the N balance coefficients can ensure that the data volume load of the M ports of the network device is in the most balanced state.

[0063] For example, assume that 10 load balancing algorithms A1 - A10 are pre - stored in the network device. The network device will use the 10 load balancing algorithms to calculate the information of each data stream among multiple data streams and M ports and obtain 10 balance coefficients Y1 - Y10. After the network device calculates the 10 balance coefficients Y1 - Y10, the network device will determine the i - th load balancing algorithm corresponding to the optimal balance coefficient Yi among the 10 balance coefficients Y1 - Y10 as the new load balancing algorithm of the network device.

[0064] In Figure 3In the illustrated embodiment, the network device may select the i-th load balancing algorithm as the new load balancing algorithm from the set of load balancing algorithms according to the information of each data stream among multiple data streams and M ports. Using the i-th load balancing algorithm to allocate the data streams subsequently received by the network device to the M ports can ensure that the data volume loads of the M ports of the network device are in a balanced state.

[0065] Optionally, in Figure 3 the illustrated embodiment, after S101 and before S102, the network device may further perform the following steps: The network device determines the data volume of each of the M ports within a set time period according to the ports forwarding the data streams within the set time period and the data volume of the data streams within the set time period; determines whether the data volumes of the M ports within the set time period are balanced according to the data volume of each of the M ports within the set time period; and when the data volumes of the M ports within the set time period are not balanced, executes S102.

[0066] Among them, the information of the data stream further includes the port forwarding the data stream within the set time period, that is, the information of a data stream contains the port forwarding the data stream within the set time period.

[0067] For example, please refer to Figure 1 as shown. Assume that within the set time period, port a1 of switch A forwards data stream L1 and data stream L3, and port a2 of switch A forwards data stream L2. Then, the information of data stream L1 includes port a1 that forwards data stream L1 within the set time period, the information of data stream L3 includes port a1 that forwards data stream L3 within the set time period, and the information of data stream L2 includes port a2 that forwards data stream L2 within the set time period. Assume that the data volume of data stream L1 within the set time period is 20 MB / s, the data volume of data stream L2 within the set time period is 40 MB / s, and the data volume of data stream L3 within the set time period is 50 MB / s. Then, switch A can determine that the data volume of port a1 is 70 MB / s and the data volume of port a2 is 40 MB / . Then, switch A determines whether the data volume of port a1 is balanced with the data volume of port a2 within the set time period. Assume that switch A determines that the data volume of port a1 is not balanced with the data volume of port a2 within the set time period. Then, switch A will execute step S102 to find a load balancing algorithm that can ensure that the loads of the data volumes of port a1 and port a2 are in a balanced state.

[0068] Please refer to Figure 4 as shown, Figure 4 which is a flowchart of another method for determining a load balancing algorithm provided by the embodiment of the present application. Figure 4 The illustrated embodiment is Figure 3 a refinement scheme of step S102 in Figure 4The method shown includes the following steps.

[0069] S201. The network device calculates the allocation value of each data stream according to the i-th load balancing algorithm and the identifier of each data stream in multiple data streams.

[0070] Among them, the identifier of the data stream may include one or more of the source IP address, destination IP address, source port number, destination port number, and protocol type information of the data stream. The identifier of the data stream may also include other information outside the above information, such as sequence number, checksum, etc.

[0071] S202. The network device determines the port corresponding to the data stream from M ports according to the allocation value of each data stream.

[0072] Among them, the network device will preset the mapping relationship between the allocation value and the port in advance. After the network device calculates the allocation value of each data stream, the network device can use the mapping relationship between the allocation value and the port to determine the port corresponding to the allocation value of each data stream, so as to determine the port corresponding to the data stream. It should be noted that the port corresponding to the data stream here refers to the port that the data stream theoretically passes through if the data stream is forwarded according to the i-th load balancing algorithm, rather than the port that actually forwards the data stream.

[0073] Exemplarily, please refer to Figure 1 As shown in Table 1 and Table 2, assume that switch A forwards data stream L1, data stream L2, and data stream L3 through the link group within a set time period. Switch A calculates the allocation values of the 3 data streams according to the i-th load balancing algorithm and the identifiers of the 3 data streams as shown in Table 1. The mapping relationship between the allocation value and the port preset by switch A is shown in Table 2.

[0074] Data flow Allocated value L1 0 L2 1 L3 0

[0075] Table 1

[0076] Allocated value Port 0 a1 1 a2

[0077] Table 2

[0078] Refer to Figure 1 As shown in Table 1 and Table 2, after switch A calculates the allocation values of the 3 data streams, it can use the mapping relationship between the allocation value and the port in Table 2 to determine the ports corresponding to the 3 data streams. Specifically, both data stream L1 and data stream L3 correspond to port a1, and data stream L2 corresponds to port a2.

[0079] S203. The network device determines the data volume of the port according to the data stream corresponding to each port among the M ports and the data volume of the data stream within a set time period.

[0080] Among them, the data volume of the data stream can be the number of packets of the data stream or the number of bytes of the data stream, etc., and the data volume of the port can be the number of packets of the port or the number of bytes of the port, etc.

[0081] For example, please refer to Figure 1 As shown in Tables 1 to 4, assume that switch A has determined that port a1 corresponds to data streams L1 and L3, and port a2 corresponds to data stream L2, as shown in Table 3. Assume that the data volume of data stream L1 is 20 MB / s, the data volume of data stream L2 is 40 MB / s, and the data volume of data stream L3 is 50 MB / s. Then it can be known that the data volume of port a1 is 70 MB / s, and the data volume of port a2 is 40 MB / s.

[0082] Port Data flow a1 L1, L3 a2 L2

[0083] Table 3

[0084] Port Data volume a1 70MB / s a2 40MB / s

[0085] Table 4

[0086] S204. The network device calculates the balance coefficient Yi according to the data volumes of M ports.

[0087] Among them, there are multiple calculation methods for the network device to calculate the balance coefficient Yi according to the data volumes of M ports. The following will introduce these calculation methods separately.

[0088] The first calculation method includes the following steps: The network device calculates the average value Ui of the data volumes of M ports, calculates the variance Fi of the data volumes of M ports, calculates the standard deviation Bi of the data volumes of M ports according to the variance Fi, and calculates the coefficient of variation of the data volumes of M ports according to the standard deviation Bi and the average value Ui to obtain the balance coefficient Yi.

[0089] Among them, in probability theory and statistics, the coefficient of variation is also called the "coefficient of dispersion" (coefficient of variation), which is a normalized measure of the degree of dispersion of a probability distribution, and is defined as the ratio of the standard deviation to the average value.

[0090] In the first calculation method provided by the embodiments of the present application, the coefficient of variation is used to indicate whether the data volumes of M ports are balanced. The larger the coefficient of variation, the more unbalanced the data volumes of M ports are. The smaller the coefficient of variation, the more balanced the data volumes of M ports are. When the coefficient of variation is 0, it means that the data volumes of M ports are in a completely balanced state.

[0091] For example, please refer to Figure 1 As shown in Tables 1 to 4, assume that the data volume of port a1 of switch A is 70 MB / s, and the data volume of port a2 is 40 MB / s.

[0092] First, switch A calculates the average value U1 of the data volume of port a1 and the data volume of port a2

[0093] =(Data volume of port a1 + Data volume of port a2)÷Number of ports=(70MB / s + 40MB / s)÷2 = 55MB / s.

[0094] Then, switch A calculates the variance F1 of the data volume of port a1 and the data volume of port a2

[0095] =[(Data volume of port a1 - Average value U1 2 +(Data volume of port a2 - Average value U1 2 )÷Number of ports=[(70MB / s - 55MB / s 2 +(40MB / s - 55MB / s 2 )÷2=(225 + 225)÷2 = 225MB / s.

[0096] Secondly, switch A calculates the standard deviation B1 of the data volume of port a1 and the data volume of port a2

[0097] =SQRT((1÷Number of ports)×Variance F1)=SQRT((1÷2)×225)≈10.6MB / s.

[0098] Finally, switch A calculates the coefficient of variation of the data volume of port a1 and the data volume of port a2

[0099] =Standard deviation B1÷Average value U1 = 10.6÷55≈0.19.

[0100] The second calculation method includes the following steps: The network device determines a first port and a second port among the M ports, where the first port has the highest bandwidth utilization rate and the second port has the lowest bandwidth utilization rate; the network device calculates the difference (also known as the range) between the bandwidth utilization rate of the first port and the bandwidth utilization rate of the second port to obtain the balance coefficient Yi. The bandwidth utilization rate of a port is the quotient of the data volume of the port and the bandwidth of the port.

[0101] Among them, the range is also called the range error or the full range (range), which is used to represent the gap between the maximum value and the minimum value among multiple data, that is, the value obtained after subtracting the minimum value from the maximum value.

[0102] In the second calculation method provided in the embodiments of the present application, the range is used to represent whether the bandwidth utilization rates of the M ports are balanced. The larger the range, the more unbalanced the bandwidth utilization rates of the M ports are. The smaller the range, the more balanced the bandwidth utilization rates of the M ports are. When the range is 0, it means that the bandwidth utilization rates of the M ports are in a completely balanced state.

[0103] For example, in combination with Figure 1 as shown in Tables 1 to 4, it is assumed that switch A has determined that the data volume of port a1 is 70 MB / s, the data volume of port a2 is 40 MB / s, the bandwidth of port a1 is 100 MB / s, and the bandwidth of port a2 is 50 MB / s.

[0104] First, switch A calculates the bandwidth utilization rate H1 of port a1 = data volume of port a1 ÷ bandwidth of port a1 = 70 MB / s ÷ 100 MB / s = 0.7.

[0105] Second, switch A calculates the bandwidth utilization rate H2 of port a2 = data volume of port a2 ÷ bandwidth of port a2 = 40 MB / s ÷ 50 MB / s = 0.8.

[0106] Finally, switch A calculates the range J1 between the bandwidth utilization rate H2 of port a2 and the bandwidth utilization rate H1 of port a1 = bandwidth utilization rate H2 of port a2 - bandwidth utilization rate H1 of port a1 = 0.8 - 0.7 = 0.1.

[0107] The third calculation method includes the following steps: The network device determines the first port and the second port among the M ports. The first port has the largest data volume, and the second port has the smallest data volume. The network device calculates the difference (range) between the data volume of the first port and the data volume of the second port to obtain the balance coefficient Yi. Wherein, the first port is the port with the largest data volume among the M ports, and the second port is the port with the smallest data volume among the M ports.

[0108] In the third calculation method provided in the embodiments of the present application, the range is used to indicate whether the data volumes of the M ports are balanced. The larger the range, the more unbalanced the data volumes of the M ports are. The smaller the range, the more balanced the data volumes of the M ports are. When the range is 0, it indicates that the data volumes of the M ports are in a completely balanced state.

[0109] For example, in combination with Figure 1 as shown in Tables 1 to 4, it is assumed that switch A has determined that the data volume of port a1 is 70 MB / s and the data volume of port a2 is 40 MB / s.

[0110] First, switch A determines that among the 2 ports, port a1 has the largest data volume and port a2 has the smallest data volume.

[0111] Then, switch A calculates the range J1 between the data volume of port a1 and the data volume of port a2 = data volume of port a1 - data volume of port a2 = 70 MB / s - 40 MB / s = 30 MB / s.

[0112] To fully demonstrate the execution process of the embodiments of the present application, the following will be described in detail through two application examples.

[0113] Please refer to Figure 1 and Figure 5 as shown in Figure 5 Figure 9 shows a flowchart of another method for determining a load balancing algorithm provided by an embodiment of the present application. In Figure 1 and Figure 5 In the shown embodiment, it is assumed that three load balancing algorithms, namely load balancing algorithm A1, load balancing algorithm A2, and load balancing algorithm A3, are pre-stored in switch A. It is assumed that switch A forwards data stream L1 and data stream L3 through port a1 and forwards data stream L2 through port a2 within a set time period. The data volume of data stream L1 is 20 MB / s, the data volume of data stream L2 is 40 MB / s, the data volume of data stream L3 is 50 MB / s, the bandwidth of port a1 is 100 MB / s, and the bandwidth of port a2 is 50 MB / s. Figure 5 The method shown includes the following steps.

[0114] S301. Switch A obtains the identifiers of data stream L1, data stream L2, and data stream L3 forwarded through the link group within the set time period.

[0115] Exemplarily, the identifier of data stream L1 is the source IP address of data stream L1, the identifier of data stream L2 is the source IP address of data stream L2, and the identifier of data stream L3 is the source IP address of data stream L3.

[0116] S302. Switch A calculates the allocation values of data stream L1, data stream L2, and data stream L3 according to load balancing algorithm A1, the identifier of data stream L1, the identifier of data stream L2, and the identifier of data stream L3.

[0117] Exemplarily, the allocation value of data stream L1 is 0, the allocation value of data stream L2 is 1, and the allocation value of data stream L3 is 0. Load balancing algorithm A1, load balancing algorithm A2, and load balancing algorithm A3 are pre-stored in switch A, and switch A selects a load balancing algorithm each time. In step S302 of this example, switch A first selects load balancing algorithm A1 for calculation.

[0118] S303. Switch A determines the ports corresponding to data stream L1, data stream L2, and data stream L3 from port a1 and port a2 according to the allocation values of data stream L1, data stream L2, and data stream L3.

[0119] Exemplarily, both data stream L1 and data stream L3 correspond to port a1, and data stream L2 corresponds to port a2.

[0120] S304. Switch A determines the data volume of port a1 and port a2 based on the port a1 corresponding to data stream L1, port a2 corresponding to data stream L2, port a1 corresponding to data stream L3, and the data volume of the data stream within the set time period.

[0121] Exemplarily, the data volume of port a1 is 70 MB / s, and the data volume of port a2 is 40 MB / s.

[0122] S305. Switch A calculates the difference between the bandwidth utilization rate H2 of port a2 and the bandwidth utilization rate H1 of port a1 to obtain the balance coefficient Y1 corresponding to load balancing algorithm A1.

[0123] Exemplarily, switch A calculates the bandwidth utilization rate H1 of port a1 = the data volume of port a1 ÷ the bandwidth of port a1 = 70 MB / s ÷ 100 MB / s = 0.7.

[0124] Switch A calculates the bandwidth utilization rate H2 of port a2 = the data volume of port a2 ÷ the bandwidth of port a2 = 40 MB / s ÷ 50 MB / s = 0.8.

[0125] The balance coefficient Y1 corresponding to load balancing algorithm A1 = the range J1 of the bandwidth utilization rate H2 of port a2 calculated by switch A and the bandwidth utilization rate H1 of port a1 = the bandwidth utilization rate H2 of port a2 - the bandwidth utilization rate H1 of port a1 = 0.8 - 0.7 = 0.1.

[0126] S306. Switch A determines whether the balance coefficient Y1 is the first balance coefficient among the balance coefficients of the three load balancing algorithms that meets the set load balancing threshold.

[0127] Exemplarily, the set load balancing threshold is the bandwidth utilization rate between 0 and 0.3.

[0128] S307. If the balance coefficient Y1 is the first balance coefficient among the balance coefficients of the three load balancing algorithms that meets the set load balancing threshold, switch A determines that load balancing algorithm A1 is the new load balancing algorithm of switch A.

[0129] Among them, since the balance coefficient Y1 corresponding to load balancing algorithm A1 is the first balance coefficient among the balance coefficients of the three load balancing algorithms that meets the set load balancing threshold, that is, the balance coefficient Y1 ∈ (0, 0.3), so switch A determines that load balancing algorithm A1 is the new load balancing algorithm of switch A.

[0130] Please refer to Figure 1 and Figure 6 shown in Figure 6 shown in the flowchart of another method for determining a load balancing algorithm provided by the embodiment of the present application. In Figure 1 andFigure 6 In the illustrated embodiment, it is assumed that three load balancing algorithms, namely load balancing algorithm A1, load balancing algorithm A2, and load balancing algorithm A3, are pre-stored in switch A. It is assumed that switch A forwards data stream L1 and data stream L3 through port a1 and forwards data stream L2 through port a2 within a set time period. The data volume of data stream L1 is 20 MB / s, the data volume of data stream L2 is 40 MB / s, the data volume of data stream L3 is 50 MB / s, the bandwidth of port a1 is 100 MB / s, and the bandwidth of port a2 is 50 MB / s. Figure 6 The method shown includes the following steps.

[0131] S401. Switch A obtains the identifiers of data stream L1, data stream L2, and data stream L3 forwarded through the link group within a set time period.

[0132] Exemplarily, the identifier of data stream L1 is the source IP address of data stream L1, the identifier of data stream L2 is the source IP address of data stream L2, and the identifier of data stream L3 is the source IP address of data stream L3.

[0133] S402. Switch A calculates the balance coefficient Y1 corresponding to load balancing algorithm A1, the balance coefficient Y2 corresponding to load balancing algorithm A2, and the balance coefficient Y3 corresponding to load balancing algorithm A3 according to the identifiers of data stream L1, data stream L2, data stream L3, port a1, and port a2.

[0134] Exemplarily, it is assumed that the allocation result obtained according to load balancing algorithm A1 is that data stream L1 and data stream L3 both correspond to port a1, and data stream L2 corresponds to port a2. Thus, it can be known that the data volume of port a1 is 70 MB / s, and the data volume of port a2 is 40 MB / s.

[0135] Among them, switch A calculates the bandwidth utilization rate H1 of port a1 = the data volume of port a1 ÷ the bandwidth of port a1 = 70 MB / s ÷ 100 MB / s = 0.7.

[0136] Switch A calculates the bandwidth utilization rate H2 of port a2 = the data volume of port a2 ÷ the bandwidth of port a2 = 40 MB / s ÷ 50 MB / s = 0.8.

[0137] The balance coefficient Y1 corresponding to load balancing algorithm A1 = the range J1 of the bandwidth utilization rate H2 of port a2 calculated by switch A and the bandwidth utilization rate H1 of port a1 = the bandwidth utilization rate H2 of port a2 - the bandwidth utilization rate H1 of port a1 = 0.8 - 0.7 = 0.1.

[0138] Exemplarily, assume that the allocation result obtained according to the load balancing algorithm A2 is as follows: both data stream L2 and data stream L3 correspond to port a1, and data stream L1 corresponds to port a2. Thus, it can be known that the data volume of port a1 is 90 MB / s, and the data volume of port a2 is 20 MB / s.

[0139] Among them, switch A calculates the bandwidth utilization rate H3 of port a1 = the data volume of port a1 ÷ the bandwidth of port a1 = 90 MB / s ÷ 100 MB / s = 0.9.

[0140] Switch A calculates the bandwidth utilization rate H4 of port a2 = the data volume of port a2 ÷ the bandwidth of port a2 = 20 MB / s ÷ 50 MB / s = 0.4.

[0141] The balance coefficient Y2 corresponding to the load balancing algorithm A2 = the range J2 of the bandwidth utilization rate H3 of port a1 calculated by switch A and the bandwidth utilization rate H4 of port a2 = the bandwidth utilization rate H3 of port a1 - the bandwidth utilization rate H4 of port a2 = 0.9 - 0.4 = 0.5.

[0142] Exemplarily, assume that the allocation result obtained according to the load balancing algorithm A3 is as follows: both data stream L1 and data stream L2 correspond to port a1, and data stream L3 corresponds to port a2. Thus, it can be known that the data volume of port a1 is 60 MB / s, and the data volume of port a2 is 50 MB / s.

[0143] Among them, switch A calculates the bandwidth utilization rate H5 of port a1 = the data volume of port a1 ÷ the bandwidth of port a1 = 60 MB / s ÷ 100 MB / s = 0.6.

[0144] Switch A calculates the bandwidth utilization rate H6 of port a2 = the data volume of port a2 ÷ the bandwidth of port a2 = 50 MB / s ÷ 50 MB / s = 1.

[0145] The balance coefficient Y3 corresponding to the load balancing algorithm A3 = the range J2 of the bandwidth utilization rate H6 of port a2 calculated by switch A and the bandwidth utilization rate H5 of port a1 = the bandwidth utilization rate H6 of port a2 - the bandwidth utilization rate H5 of port a1 = 1 - 0.6 = 0.4.

[0146] S403. Switch A determines that the load balancing algorithm corresponding to the optimal balance coefficient among the balance coefficient Y1, the balance coefficient Y2, and the balance coefficient Y3 is the new load balancing algorithm of switch A.

[0147] For example, when the balance coefficient is the range of the bandwidth utilization rate of port a1 and the bandwidth utilization rate of port a2, the smaller the balance coefficient, the more balanced the load of the bandwidth utilization rate of port a1 and the bandwidth utilization rate of port a2. Through the calculation in step S402, it can be known that the balance coefficient Y1 corresponding to the load balancing algorithm A1 is 0.1, the balance coefficient Y2 corresponding to the load balancing algorithm A2 is 0.5, and the balance coefficient Y3 corresponding to the load balancing algorithm A3 is 0.4. Then the balance coefficient Y1 corresponding to the load balancing algorithm A1 is the optimal balance coefficient. Therefore, switch A will determine that the load balancing algorithm A1 is the new load balancing algorithm of switch A.

[0148] Please refer to Figure 7 as shown in Figure 7 FIG. shows a schematic structural diagram of a network device provided by an embodiment of the present application. The network device includes the following modules:

[0149] An obtaining module 11, configured to obtain information of each data stream among multiple data streams forwarded through a link group within a set time period. Among them, the link group corresponds to M ports, and M is greater than or equal to 2. For the specific detailed implementation manner, please refer to the detailed description corresponding to step S101 in the method embodiment shown above. Figure 3 shown.

[0150] A calculating module 12, configured to calculate a balance coefficient Yi corresponding to the i-th load balancing algorithm in the load balancing algorithm set according to the information of each data stream among multiple data streams and M ports. Among them, the load balancing algorithm set includes N load balancing algorithms, N is greater than or equal to 2, and i ∈ [1, N]. For the specific detailed implementation manner, please refer to the detailed description corresponding to step S102 in the method embodiment shown above. Figure 3 shown.

[0151] A first determining module 13, configured to determine the i-th load balancing algorithm as the new load balancing algorithm of the network device when the balance coefficient Yi meets the load balancing condition. For the specific detailed implementation manner, please refer to the detailed description corresponding to step S103 in the method embodiment shown above. Figure 3 shown.

[0152] In a feasible embodiment, that the balance coefficient Yi meets the load balancing condition includes: the balance coefficient Yi is the first one among the balance coefficients of N load balancing algorithms that meets the set load balancing threshold; or the balance coefficient Yi is the optimal one among the balance coefficients of N load balancing algorithms.

[0153] In a feasible embodiment, the information of the data stream includes the identifier of the data stream and the data volume of the data stream within the set time period.

[0154] In an implementable embodiment, the calculation module 12 is configured to calculate the allocation value of each data stream according to the i-th load balancing algorithm and the identifier of each data stream in multiple data streams; determine the port corresponding to the data stream from M ports according to the allocation value of each data stream; determine the data volume of the port according to the data stream corresponding to each port among the M ports and the data volume of the data stream within a set time period; calculate the balance coefficient Yi according to the data volumes of the M ports. For the specific detailed implementation method, please refer to the above Figure 4 detailed description corresponding to steps S201 to S204 in the method embodiment shown.

[0155] In an implementable embodiment, the calculation module 12 is configured to calculate the average value Ui of the data volumes of the M ports; calculate the variance Fi of the data volumes of the M ports; calculate the standard deviation Bi of the data volumes of the M ports according to the variance Fi; calculate the coefficient of variation of the M ports according to the standard deviation Bi and the average value Ui to obtain the balance coefficient Yi. For the specific detailed implementation method, please refer to the above Figure 4 detailed description corresponding to step S204 in the method embodiment shown.

[0156] In an implementable embodiment, the calculation module 12 is configured to determine a first port and a second port among the M ports, where the first port has the maximum bandwidth utilization rate and the second port has the minimum bandwidth utilization rate, and the bandwidth utilization rate of the port is the quotient of the data volume of the port and the bandwidth of the port; calculate the difference between the bandwidth utilization rate of the first port and the bandwidth utilization rate of the second port to obtain the balance coefficient Yi. For the specific detailed implementation method, please refer to the above Figure 4 detailed description corresponding to step S204 in the method embodiment shown.

[0157] In an implementable embodiment, the calculation module 12 is configured to determine a first port and a second port among the M ports, where the first port has the maximum data volume and the second port has the minimum data volume; calculate the difference between the data volume of the first port and the data volume of the second port to obtain the balance coefficient Yi. For the specific detailed implementation method, please refer to the above Figure 4 detailed description corresponding to step S204 in the method embodiment shown.

[0158] In an implementable embodiment, the network device further includes a second determination module 14. The second determination module 14 is configured to determine the data volumes of the M ports within a set time period according to the ports forwarding data streams within the set time period and the data volumes of the data streams within the set time period; determine whether the data volumes of the M ports within the set time period are balanced; and call the calculation module 12 when the data volumes of the M ports within the set time period are not balanced.

[0159] Please refer to Figure 8 shown as Figure 8The following is a schematic structural diagram of another network device provided by an embodiment of the present application. The network device includes a controller 21, a forwarder 22, and M ports (port a1,..., port aM). The M ports correspond to M links, and the M links form a link group, where M is greater than or equal to 2.

[0160] Among them, the controller 21 is used to obtain information of each data stream among multiple data streams forwarded through the link group within a set time period from the forwarder 22, and calculate the equilibrium coefficient Yi corresponding to the i-th load balancing algorithm in the load balancing algorithm set according to the information of each data stream among the multiple data streams and the M ports. When the equilibrium coefficient Yi meets the load balancing condition, it is determined that the i-th load balancing algorithm is the new load balancing algorithm of the network device.

[0161] In Figure 8 In the illustrated embodiment, the controller 21 may be a central processing unit (CPU), the forwarder 22 may be an application specific integrated circuit (ASIC), and the controller 21 and the forwarder 22 may be connected through a bus of the peripheral component interconnect express (PCIE) type.

[0162] Please refer to Figure 9 as shown Figure 9 The following is a schematic structural diagram of yet another network device provided by an embodiment of the present application. The network device includes a forwarder 31 and M ports (port a1,..., port aM). The M ports correspond to M links, and the M links form a link group, where M is greater than or equal to 2.

[0163] Among them, the forwarder 31 is used to obtain information of each data stream among multiple data streams forwarded through the link group within a set time period, and calculate the equilibrium coefficient Yi corresponding to the i-th load balancing algorithm in the load balancing algorithm set according to the information of each data stream among the multiple data streams and the M ports. When the equilibrium coefficient Yi meets the load balancing condition, it is determined that the i-th load balancing algorithm is the new load balancing algorithm of the network device.

[0164] In Figure 9 In the illustrated embodiment, the forwarder 31 may be an application-specific integrated circuit (ASIC).

[0165] Please refer to Figure 10 as shown Figure 10 The following is a schematic structural diagram of yet another network device provided by an embodiment of the present application.Figure 10 The network device shown includes a processor 41, a memory 42, and M ports (port a1, …, port aM), where the M ports correspond to M links, and the M links form a link group, and M is greater than or equal to 2.

[0166] Among them, the processor 41 is used to obtain the information of each data stream among multiple data streams forwarded through the link group within a set time period, and calculate the equilibrium coefficient Yi corresponding to the i-th load balancing algorithm in the set of load balancing algorithms according to the information of each data stream among the multiple data streams and the M ports. When the equilibrium coefficient Yi meets the load balancing condition, determine the i-th load balancing algorithm as the new load balancing algorithm of the network device.

[0167] Through the above embodiments of the present invention, the network device can select the i-th load balancing algorithm as the new load balancing algorithm from the set of load balancing algorithms according to the information of each data stream among the multiple data streams and the M ports. Using the i-th load balancing algorithm to allocate the data streams subsequently received by the network device to the M ports can ensure that the data volume loads of the M ports of the network device are in a balanced state.

[0168] All of the above optional technical solutions can be combined arbitrarily to form optional embodiments of the present application, which will not be elaborated one by one here.

[0169] The network device provided in the above embodiments is only illustrated by the above division of each functional module. In practical applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the network device is divided into different functional modules to complete all or part of the functions described above.

[0170] The above are only optional embodiments of the present application, and are not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the principle of the present application shall be included in the protection scope of the present application.

Claims

1. A method for determining a load balancing algorithm, characterized in that Including: The network device obtains information of each data stream among multiple data streams forwarded by a link group within a set time period. The link group corresponds to M ports, M≥2, and the information of the data stream further includes the port that forwards the data stream within the set time period; The network device determines whether the data amounts of the M ports within the set time period are balanced according to the port that forwards the data stream within the set time period and the data amount of the data stream within the set time period; When the data amounts of the M ports within the set time period are unbalanced, the network device calculates the balance coefficient Yi corresponding to the i-th load balancing algorithm in the load balancing algorithm set according to the information of each data stream among the multiple data streams and the M ports. The load balancing algorithm set includes N load balancing algorithms, N≥2, and i∈[1, N]; When the balance coefficient Yi meets the load balancing condition, the network device determines the i-th load balancing algorithm as the new load balancing algorithm of the network device.

2. The method according to claim 1, wherein The balance coefficient Yi meeting the load balancing condition includes: The balance coefficient Yi is the first one among the balance coefficients of the N load balancing algorithms that meets the set load balancing threshold; Or The balance coefficient Yi is the optimal one among the balance coefficients of the N load balancing algorithms.

3. The method according to claim 1 or 2, characterized in that, The information of the data stream includes the identifier of the data stream and the data amount of the data stream within the set time period.

4. The method according to claim 3, characterized in that, The network device calculates the balance coefficient Yi corresponding to the i-th load balancing algorithm in the load balancing algorithm set according to the information of each data stream among the multiple data streams and the M ports, including: The network device calculates the allocation value of each data stream according to the i-th load balancing algorithm and the identifier of each data stream among the multiple data streams; The network device determines the port corresponding to the data stream from the M ports according to the allocation value of each data stream; The network device determines the data amount of the port according to the data stream corresponding to each port among the M ports and the data amount of the data stream within the set time period; The network device calculates the balance coefficient Yi according to the data amounts of the M ports.

5. The method according to claim 4, wherein The balance coefficient Yi is the coefficient of variation. The network device calculates the balance coefficient Yi according to the data amounts of the M ports, including: The network device calculates the average value Ui of the data amounts of the M ports; The network device calculates the variance Fi of the data amounts of the M ports; The network device calculates the standard deviation Bi of the data amounts of the M ports according to the variance Fi; The network device calculates the coefficient of variation of the data amounts of the M ports according to the standard deviation Bi and the average value Ui to obtain the balance coefficient Yi.

6. The method according to claim 4, characterized in that, The balance coefficient Yi is the range. The network device calculates the balance coefficient Yi according to the data amounts of the M ports, including: The network device determines a first port and a second port among the M ports. The first port has the highest bandwidth utilization rate, and the second port has the lowest bandwidth utilization rate. The bandwidth utilization rate of a port is the quotient of the data volume of the port and the bandwidth of the port. The network device calculates the difference between the bandwidth utilization rate of the first port and the bandwidth utilization rate of the second port to obtain the balance coefficient Yi.

7. The method according to claim 4, wherein The balance coefficient Yi is the range. The network device calculates the balance coefficient Yi according to the data volumes of the M ports, including: The network device determines a first port and a second port among the M ports. The first port has the largest data volume, and the second port has the smallest data volume. The network device calculates the difference between the data volume of the first port and the data volume of the second port to obtain the balance coefficient Yi.

8. A network device, characterized in that, including: An acquisition module, configured to acquire information of each data stream in multiple data streams forwarded through a link group within a set time period. The link group corresponds to M ports, and M is greater than or equal to 2. A second determination module, configured to determine whether the data volumes of the M ports are balanced within the set time period according to the port that forwards the data stream within the set time period and the data volume of the data stream within the set time period; when the data volumes of the M ports are not balanced within the set time period, call the calculation module. A calculation module, configured to calculate the balance coefficient Yi corresponding to the i-th load balancing algorithm in the load balancing algorithm set according to the information of each data stream in the multiple data streams and the M ports. The load balancing algorithm set includes N load balancing algorithms, N is greater than or equal to 2, and i ∈ [1, N]. A first determination module, configured to determine the i-th load balancing algorithm as the new load balancing algorithm of the network device when the balance coefficient Yi meets the load balancing condition.

9. The network device according to claim 8, wherein The balance coefficient Yi meets the load balancing condition includes: The balance coefficient Yi is the first one among the balance coefficients of the N load balancing algorithms that meets the set load balancing threshold. or The balance coefficient Yi is the optimal one among the balance coefficients of the N load balancing algorithms.

10. The network device according to claim 8 or 9, characterized in that, The information of the data stream includes the identifier of the data stream and the data volume of the data stream within the set time period.

11. The network device according to claim 10, wherein: The calculation module is configured to calculate the allocation value of each data stream according to the i-th load balancing algorithm and the identifier of each data stream in the multiple data streams; determine the port corresponding to the data stream from the M ports according to the allocation value of each data stream; determine the data volume of the port according to the data stream corresponding to each port in the M ports and the data volume of the data stream within the set time period; calculate the balance coefficient Yi according to the data volumes of the M ports.

12. The network device according to claim 11, wherein: The calculation module is configured to calculate the average value Ui of the data volumes of the M ports; calculate the variance Fi of the data volumes of the M ports; calculate the standard deviation Bi of the data volumes of the M ports according to the variance Fi; calculate the coefficient of variation of the data volumes of the M ports according to the standard deviation Bi and the average value Ui to obtain the balance coefficient Yi.

13. The network device according to claim 11, wherein: The calculation module is configured to determine a first port and a second port among the M ports, the first port having the maximum bandwidth utilization rate, and the second port having the minimum bandwidth utilization rate, and the bandwidth utilization rate of a port being the quotient of the data volume of the port and the bandwidth of the port; calculate the difference between the bandwidth utilization rate of the first port and the bandwidth utilization rate of the second port to obtain the balance coefficient Yi.

14. The network device according to claim 11, wherein: The calculation module is configured to determine a first port and a second port among the M ports, the first port having the maximum data volume, and the second port having the minimum data volume; calculate the difference between the data volume of the first port and the data volume of the second port to obtain the balance coefficient Yi.

Citation Information

Patent Citations

  • Flow load balancing method and device

    CN110661719A