Traffic Balancing Method and Apparatus
20210352018 · 2021-11-11
Inventors
Cpc classification
Y02D30/50
GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
H04L47/36
ELECTRICITY
International classification
Abstract
A traffic balancing method includes an Ethernet device sending a query packet carrying load information of each physical port of a logical port of the Ethernet device to a controller. The controller receives the query packet and determines a weight factor of each physical port of the logical port based on the load information. The weight factor of each physical port is positively correlated with an amount of traffic that is of the logical port and that can be shared by each of the physical ports. The controller sends a response packet carrying the weight factor to the Ethernet device. The Ethernet device adjusts, based on the weight factor, traffic sent to each of the physical ports.
Claims
1. A traffic balancing method implemented by an Ethernet device, comprising: sending, to a controller, a first query packet carrying first load information of each physical port in a plurality of physical ports of a logical port of the Ethernet device; receiving, from the controller, a response packet carrying a weight factor of each of the physical ports, wherein the weight factor is positively correlated with an amount of first traffic that is of the logical port and that can be shared by each of the physical ports; and adjusting, based on the weight factor, second traffic sent to each of the physical ports when sending a packet through the logical port.
2. The traffic balancing method of claim 1, further comprising: determining whether third traffic of a first physical port in the physical ports exceeds a first preset threshold; and further sending, to the controller, the first query packet when the third traffic exceeds the first preset threshold.
3. The traffic balancing method of claim 2, wherein the first load information indicates a percentage of a consumed bandwidth of each of the physical ports in a total bandwidth of each of the physical ports, and wherein the traffic balancing method further comprises: determining whether the percentage varies; and further adjusting the second traffic when percentage variation indicated by the first load information does not exceed a second preset threshold.
4. The traffic balancing method of claim 1, wherein the first load information indicates a percentage of a consumed bandwidth of each of the physical ports in a total bandwidth of each of the physical ports, and wherein the traffic balancing method further comprises: determining whether the percentage varies; and further adjusting the second traffic when percentage variation indicated by the first load information does not exceed a second preset threshold.
5. The traffic balancing method of claim 4, further comprising: identifying that the percentage variation exceeds the second preset threshold; collecting, in response to the percentage variation exceeding the second preset threshold, second load information of each of the physical ports; and sending, to the controller, a second query packet carrying the second load information.
6. The traffic balancing method of claim 4, further comprising further adjusting, based on a preset hash factor, the second traffic.
7. The traffic balancing method of claim 6, wherein the preset hash factor comprises a source media access control (MAC) address, a destination MAC address, a source Internet Protocol (IP) address, a destination IP address, a source port number, or a destination port number.
8. The traffic balancing method of claim 6, wherein before adjusting the second traffic, the traffic balancing method further comprises determining, based on the preset hash factor, a second physical port in the physical ports to forward the packet.
9. A traffic balancing method implemented by a controller, comprising: receiving, from an Ethernet device, a query packet carrying load information of each physical port in a plurality of physical ports of a logical port of the Ethernet device; determining, based on the load information, a weight factor of each of the physical ports, wherein the weight factor is positively correlated with an amount of first traffic that is of the logical port and that can be shared by each of the physical ports; and sending, to the Ethernet device, a response packet carrying the weight factor.
10. The traffic balancing method of claim 9, wherein the load information indicates a percentage of a consumed bandwidth of each of the physical ports in a total bandwidth of each of the physical ports, and wherein the traffic balancing method further comprises: determining, based on the percentage, a least common multiple of percentages of the physical ports; and further determining the weight factor by dividing the least common multiple by the percentage.
11. An Ethernet device comprising: a memory configured to store instructions; and a processor coupled to the memory, wherein the instructions cause the processor to be configured to: send, to a controller, a first query packet carrying first load information of each physical port in a plurality of physical ports of a logical port of the Ethernet device; receive, from the controller, a response packet carrying a weight factor of each of the physical ports, wherein the weight factor is positively correlated with an amount of first traffic that is of the logical port and that can be shared by each of the physical ports; and adjusting, based on the weight factor, second traffic sent to each of the physical ports when sending a packet through the logical port.
12. The Ethernet device of claim 11, wherein the instructions further cause the processor to be configured to: determine whether third traffic of a first physical port in the physical ports exceeds a first preset threshold; and further send, to the controller, the first query packet when the third traffic exceeds the first preset threshold.
13. The Ethernet device of claim 12, wherein the first load information indicates a percentage of a consumed bandwidth of each of the physical ports in a total bandwidth of each of the physical ports, and wherein the instructions further cause the processor to be configured to: determine whether the percentage varies; and further adjust the second traffic when percentage variation indicated by the first load information does not exceed a second preset threshold.
14. The Ethernet device of claim 11, wherein the first load information indicates a percentage of a consumed bandwidth of each of the physical ports in a total bandwidth of each of the physical ports, and wherein the instructions further cause the processor to be configured to: determine whether the percentage indicated by the first load information varies; and further adjust the second traffic when percentage variation indicated by the first load information does not exceed a second preset threshold.
15. The Ethernet device of claim 14, wherein the instructions further cause the processor to be configured to: identify that the percentage variation exceeds the second preset threshold; collect, in response to the percentage variation exceeding the second preset threshold, second load information of each of the physical ports; and send, to the controller, a second query packet carrying the second load information.
16. The Ethernet device of claim 14, wherein the instructions further cause the processor to be configured to further adjust, based on a preset hash factor, the second traffic.
17. The Ethernet device of claim 16, wherein the preset hash factor comprises a source media access control (MAC) address, a destination MAC address, a source Internet Protocol (IP) address, a destination IP address, a source port number, or a destination port number.
18. The Ethernet device of claim 16, wherein before adjusting the second traffic, the instructions further cause the processor to be configured to determine, based on the preset hash factor, a second physical port in the physical ports to forward the packet.
19. A traffic balancing apparatus comprising: a memory configured to store instructions; and a processor coupled to the memory, wherein the instructions cause the processor to be configured to: receive, from an Ethernet device, a query packet carrying load information of each physical port in a plurality of physical ports of a logical port of the Ethernet device; determine, based on the load information, a weight factor of each of the physical ports, wherein the weight factor is positively correlated with an amount of first traffic that is of the logical port and that can be shared by each of the physical ports; and send, to the Ethernet device, a response packet carrying the weight factor.
20. The traffic balancing apparatus of claim 19, wherein the load information indicates a percentage of a consumed bandwidth of each of the physical ports in a total bandwidth of each of the physical ports, and wherein the instructions further cause the processor to be configured to: determine, based on the percentage, a least common multiple of percentages of the physical ports; and further determine the weight factor by dividing the least common multiple by the percentage.
Description
BRIEF DESCRIPTION OF DRAWINGS
[0025]
[0026]
[0027]
[0028]
[0029]
[0030]
[0031]
[0032]
DESCRIPTION OF EMBODIMENTS
[0033] An Eth-Trunk connection mechanism applicable to an Eth-Trunk connection system is derived based on the Eth-Trunk mechanism. For example,
[0034] In a scenario, the switch 1 allocates, based on the hash algorithm, a packet that arrives at the logical port 1 to the physical port 1, the physical port 2, the physical port 3, or the physical port 4. A percentage of consumed bandwidth of each physical port in total bandwidth of the physical port is 60%. For one physical port, the percentage of the consumed bandwidth of the physical port in the total bandwidth of the physical port is also referred to as traffic bandwidth.
[0035] Because the switch 2, the switch 3, and the switch 1 use the same hash algorithm, hash calculation results of the switch 2, the switch 3, and the switch 1 are relatively similar. Consequently, the traffic is unevenly allocated to the logical port 2 and the logical port 3. For example, traffic bandwidth of the physical port 1, the physical port 2, and the physical port 3 of the logical port 2 is respectively 20%, 40%, and 95%. If the traffic arriving at the switch 2 is heavy, packet loss easily occurs on a physical port 3 of the logical port 2 due to a data amount exceeds bandwidth.
[0036] To prevent uneven traffic allocation, the hash factor or the hash algorithm used in the hash calculation may be manually modified. For example, the packet features used for the hash calculation are modified. For another example, an offset is performed on the hash calculation result. However, even if a new hash factor is used, the calculated physical port is fixed. In a multi-level Eth-Trunk port scenario, uneven load balancing among member ports of an Eth-Trunk port except a first-level Eth-Trunk port cannot be avoided. In addition, during hash factor modification, an appropriate hash factor can be obtained only after a plurality of attempts. This modification process may cause a service exception.
[0037] In view of this, embodiments of this application provide a traffic balancing method and apparatus, to evenly balance traffic among the member ports of the Eth-Trunk port by automatically adjusting the traffic of the member ports of the Eth-Trunk port.
[0038] In the embodiments of this application, the words such as “example” or “for example” are used to represent giving an example, an illustration, or a description. Any embodiment or design scheme described as “example” or “for example” in the embodiments of this application should not be explained as being more preferred or having more advantages than another embodiment or design scheme. Exactly, use of the word such as “example” or “for example” is intended to present a related concept in a specific manner.
[0039]
[0040] In
[0041] The following describes in detail the traffic balancing method in this embodiment of this application based on the architecture shown in
[0042] Step 101: An Ethernet device sends a query packet to a controller, where the query packet carries load information of each physical port in a plurality of physical ports of a logical port of the Ethernet device.
[0043] Correspondingly, the controller receives the query packet.
[0044] For example, an agent module is pre-deployed on the Ethernet device, and is configured to collect the load information of each physical port of the logical port of the Ethernet device and report the load information to the controller. The controller receives the query packet. In a process of collecting the load information, the agent module collects traffic statistics on each physical port of the logical port, and determines a percentage of consumed bandwidth of each physical port of the logical port in total bandwidth of the physical port. For example, still refer to
[0045] Step 102: The controller determines a weight factor of each physical port based on the load information of each physical port. The weight factor of each physical port is positively correlated with an amount of traffic that is of the logical port and that can be shared by the physical port.
[0046] For example, for one logical port, the controller determines the weight factor of each physical port based on the load information of each physical port of the logical port. The weight factor of each physical port is positively correlated with the amount of the traffic that is of the logical port and that can be shared by the physical port. To be specific, for the one logical port, among the physical ports of the logical port, a physical port with a larger weight factor can share larger traffic. In other words, the physical port with the larger weight factor has a smaller percentage of currently consumed bandwidth in the total bandwidth of the physical port.
[0047] The example in step 101 is still used. Assuming that the load information is the percentage of the consumed bandwidth of each physical port in the total bandwidth, the controller determines, based on the three percentages, that the weight factors of the physical port 1, the physical port 2, and the physical port 3 are respectively 3.8, 1.9, and 0.8. To be specific, traffic that can be shared by physical port 1 is the largest, traffic that can be shared by physical port 2 is the second largest, and traffic that can be shared by the physical port 3 is the smallest.
[0048] Step 103: The controller sends a response packet to the Ethernet device, where the response packet carries the weight factor of each physical port.
[0049] Correspondingly, the Ethernet device receives the response packet carrying the weight factor of each physical port.
[0050] Step 104: When sending a packet through the logical port, the Ethernet device adjusts, based on the weight factor of each physical port, the traffic sent to each physical port.
[0051] For example, after data arrives at the logical port, the Ethernet device adjusts, based on the weight factor of each physical port of the logical port, the traffic sent to each physical port. The foregoing examples in steps 101 and 102 are still used. Assuming that an amount of a new data flow is 6 M. After the data flow arrives at a switch 2, it is determined, using a hash algorithm, that the new data flow is forwarded through the physical port 3. However, the Ethernet device determines that the weight factor of the physical port 3 is 0.8, which is relatively small. If the data flow is sent through the physical port 3, packet loss occurs on the physical port 3 because the amount exceeds bandwidth. Therefore, the Ethernet device selects a physical port with the largest weight factor, namely, the physical port 1, to forward the new data flow.
[0052] In the traffic balancing method provided in this embodiment of the present disclosure, the Ethernet device sends the query packet carrying the load information of each physical port of the logical port of the Ethernet device to the controller. The controller receives the query packet, and determines the weight factor of each physical port of the logical port based on the load information of each physical port. The weight factor of each physical port is positively correlated with the amount of the traffic that is of the logical port and that can be shared by the physical port. Then, the controller sends the response packet carrying the weight factor of each physical port to the Ethernet device, so that the Ethernet device adjusts, based on the weight factor of each physical port, the traffic sent to each physical port. In this process, a user does not need to manually adjust a hash factor used in hash calculation. Instead, the Ethernet device automatically adjusts the traffic of each physical port. This does not affect currently transmitted service data and does not cause a service exception.
[0053] The following uses an example in which the logical port is the logical port 2, and the logical port 2 includes the physical port 1, the physical port 2, and the physical port 3 to describe in detail how the Ethernet device adjusts the traffic sent to each physical port when the packet is sent through the logical port in the foregoing embodiment.
[0054] For example, a hash factor is preset on each Ethernet device, and the hash factor may be one or more of information such as a source MAC address, a destination MAC address, a source IP address, a destination IP address, a source port number, and a destination port number of the packet. That the hash factor is the source MAC address, and the last three bits of the source MAC address are mapped to different physical ports using the hash algorithm is used as an example. For example, 000, 001, and 010 are mapped to the physical port 1, 011 and 100 are mapped to the physical port 2, and 101 and 111 are mapped to the physical port 3. When sending the packet through the logical port, the Ethernet device adjusts, based on the preset hash factor and the weight factor of each physical port, the traffic sent to each physical port.
[0055] In a feasible design, in addition to the preset hash factor, a minimum weight factor is further configured for the Ethernet device. When the packet needs to be sent through the logical port 2, the Ethernet device determines a physical port based on the preset hash factor, and then the Ethernet device determines whether a weight factor of the physical port is greater than the minimum weight factor. If the weight factor of the physical port is greater than the minimum weight factor, the Ethernet device forwards the packet through the physical port. If the weight factor of the physical port is less than or equal to the minimum weight factor, the Ethernet device forwards the packet through another physical port. For example, the weight factors of the physical port 1, the physical port 2, and the physical port 3 are respectively 3.8, 1.9, and 0.8, and the minimum weight factor is 1. If the physical port determined by the Ethernet device based on the hash algorithm is the physical port 3, because the weight factor of the physical port 3 is less than the minimum weight factor, the Ethernet device selects one physical port from the physical port 1 and the physical port 2 to send the packet. For example, the one physical port is randomly selected from the physical port 1 and the physical port 2 to send the packet. For another example, the physical port with a larger weight factor, namely, the physical port 1, is selected from the physical port 1 and the physical port 2 to send the packet.
[0056] In another feasible design, in addition to the preset hash factor, a weight factor difference threshold is further configured for the Ethernet device. When the packet needs to be sent through the logical port 2, the Ethernet device determines the physical port based on the preset hash factor, and then the Ethernet device determines whether a difference between the weight factor of the physical port and the maximum weight factor is greater than or equal to the weight factor difference threshold. If the difference is greater than or equal to the weight factor difference threshold, the Ethernet device sends the packet through another physical port. If the difference is less than the weight factor difference threshold, the Ethernet device sends the packet through the physical port calculated through the hash algorithm. For example, the weight factors of the physical port 1, the physical port 2, and the physical port 3 are respectively 3.8, 1.9, and 0.8, and the weight factor difference threshold is 2. If the physical port determined by the Ethernet device based on the hash algorithm is the physical port 3, because a difference between the weight factor of the physical port 3 and the maximum weight factor, namely, the weight factor of the physical port 1, is equal to 3, and the difference is greater than the weight factor difference threshold 2, the Ethernet device selects the one physical port from the physical port 1 and the physical port 2 to send the packet. For example, the one physical port is randomly selected from the physical port 1 and the physical port 2 to send the packet. For another example, the physical port with maximum larger weight factor, namely, the physical port 1, is selected from the physical port 1 and the physical port 2 to send the packet.
[0057] In this embodiment, the Ethernet device determines, based on the preset hash factor, the physical port used to forward the packet, and then determines, based on the weight factor, whether the packet can be forwarded through the physical port determined based on the hash factor. The traffic sent to each physical port can be adjusted without modifying the hash factor. The adjustment process is simple and does not affect services.
[0058] In the foregoing embodiment, for a determined service, a source MAC address, a destination MAC address, and the like of a packet of the service are fixed. Therefore, the traffic sent to each physical port can be adjusted based on the hash factor and the weight factor. However, the service is not fixed. If the service changes, for example, before the Ethernet device sends the query packet to the controller, 100 users are initiating the service, and after the Ethernet device receives the response packet sent by the controller, 1000 users are initiating the service. In this case, the traffic of each physical port of the logical port varies. It is clearly that the weight factor carried in the response packet cannot meet a traffic balancing requirement. To avoid this phenomenon, optionally, in this embodiment of this application, when sending the packet through the logical port, that the Ethernet device adjusts, based on the weight factor of each physical port, the traffic sent to each physical port includes, when sending the packet through the logical port, the Ethernet device determines whether the traffic of each physical port of the logical port varies. If the traffic of each physical port does not vary, the Ethernet device adjusts, based on the weight factor of each physical port, the traffic sent to each physical port.
[0059] For example, assuming that the Ethernet device has the logical port 2, and the logical port 2 includes the physical port 1, the physical port 2, and the physical port 3. Before the Ethernet device sends the packet to the controller, the 100 users are initiating the service, and currently consumed bandwidth of the physical port 1 is 40 M, accounting for 20% of the total bandwidth of physical port 1. Currently consumed bandwidth of the physical port 2 is 40 M, accounting for 40% of the total bandwidth of physical port 2. Currently consumed bandwidth of the physical port 3 is 47.5 M, accounting for 95% of the total bandwidth of the physical port 3. The controller determines, based on the query packet, that the weight factors of the physical port 1, the physical port 2, and the physical port 3 are respectively 3.8, 1.9, and 0.8, encapsulates the weight factors, a logical port identifier of the Ethernet device, and the like into the response packet, and sends the response packet to the Ethernet device. After receiving the response packet, the Ethernet device determines that the weight factors of the physical port 1, the physical port 2, and the physical port 3 are respectively 3.8, 1.9, and 0.8, and determines that percentage variation indicated by the load information of each physical port does not exceed a preset threshold. In other words, variation of the percentage of the consumed bandwidth of each physical port in the total bandwidth of the physical port does not exceed the preset threshold. For example, after the Ethernet device receives the response packet, the percentages of the consumed bandwidth of the physical port 1, the physical port 2, and the physical port 3 in the total bandwidth is still 20%, 40% and 95%, or although the percentage of the consumed bandwidth of each physical port in the total bandwidth varies, the variation is not significant, for example, from the original 20%, 40%, and 95% to 25%, 40%, and 95%, the Ethernet device adjusts, based on the weight factor of each physical port, the traffic sent to each physical port.
[0060] In this embodiment, the load information of each physical port is used to indicate the percentage of the consumed bandwidth of the physical port in the total bandwidth of the physical port. Before adjusting, based on the weight factor, the traffic sent to each physical port, the Ethernet device determines whether the percentage variation indicated by the load information of each physical port in the physical ports exceeds the preset threshold. Only in a case in which the percentage variation indicated by the load information of all the physical ports does not exceed the preset threshold, the Ethernet device adjusts, based on the weight factor, the traffic sent to each physical port. This avoids that the weight factor is not applicable when the percentage of the consumed bandwidth in the total bandwidth of the physical port greatly varies. In addition, the Ethernet device may only determine percentage variation indicated by load information of some physical ports. For example, in the query packet sent by the Ethernet device, the percentages of the consumed bandwidth of the physical port 1, the physical port 2, and the physical port 3 in the total bandwidth is respectively 20%, 40%, and 95%. After the Ethernet device receives the response packet, it is discovered that the weight factor of the physical port 1 is greater than that of the physical port 3, and the weight factor of the physical port 3 is the smallest. Therefore, the traffic of the physical port 3 should be increased. In this case, the Ethernet device mainly detects whether the percentage of the consumed bandwidth of the physical port 1 in the total bandwidth of the physical port 1 greatly varies. If the percentage varies from 20% to 30%, variation is 10%, which is 30% less than the preset threshold. Then, the Ethernet device adjusts, based on the weight factor carried in the response packet, the traffic sent to each physical port.
[0061] Optionally, in the foregoing embodiment, if the percentage variation indicated by the load information of one or more physical ports exceeds the preset threshold, the Ethernet device determines whether the weight factor of each physical port is applicable to each physical port whose traffic varies. If the weight factor of each physical port is applicable to each physical port whose traffic varies, the Ethernet device adjusts, based on the weight factor of each physical port, the traffic sent to each physical port.
[0062] For example, if a percentage of consumed bandwidth of any of the one or more physical ports in total bandwidth greatly varies, for example, varies from the original 20%, 40%, and 95% to 80%, 40%, and 95%, the Ethernet device re-collects load information of each physical port, and sends the load information to the controller, so that the controller recalculates the weight factor.
[0063] The following describes in detail the query packet and the response packet in this embodiment of this application.
[0064] In this embodiment of this application, the query packet and the response packet may be UDP packets. For example,
[0065] As shown in
[0066] In this embodiment of this application, the UDP packet used as a query packet has a fixed UDP port number. In other words, the source port number in the outer UDP header is fixed, which is for example, 6000. In this way, after a controller receives the UDP packet and parses the UDP packet, if the UDP port number of the UDP packet is 6000, the controller determines that the UDP packet is the query packet, and a weight factor needs to be calculated based on load information carried in the UDP packet. If the UDP port number of the UDP packet is not 6000, the weight factor does not need to be calculated. Similarly, after an Ethernet device receives the UDP packet and parses the packet, if the UDP port number of the UDP packet is 6000, the Ethernet device determines that the UDP packet is a response packet, and traffic sent to each physical port needs to be adjusted based on the weight factor carried in the UDP packet. If the UDP port number of the UDP packet is not 6000, the traffic of each physical port does not need to be adjusted.
[0067] In this embodiment of this application, when the UDP packet is the query packet, the payload of the UDP packet is used to store device information of the Ethernet device, load information of each physical port of a logical port, and the like. When the UDP packet is the response packet, the payload of the UDP packet is used to store the device information of the Ethernet device, a weight factor of each physical port of the logical port, and the like. The following describes the payload of the UDP packet in detail. For example, refer to Table 1.
[0068] Table 1 is a detailed content table of the payload of the UDP packet in this embodiment of this application.
TABLE-US-00001 TABLE 1 Message main field Query packet Response packet IP IP 1 IP 1 Logical port identifier 10 10 Quantity of physical ports 3 3 Physical port 1 20% 3.8 Physical port 2 40% 1.9 Physical port 3 95% 0.8
[0069] The following describes Table 1 in detail.
[0070] (a) IP field.
[0071] In this embodiment of this application, the IP field indicates an IP address of the Ethernet device, namely, a network location of the Ethernet device, and is used to exchange a message between the Ethernet device and the controller. When an agent module is deployed on the Ethernet device, the IP address may also be referred to as an IP address of an agent. Assuming that the IP address of the Ethernet device is 10.1.1.1 and the IP address of the controller is 20.1.1.1, when the Ethernet device sends the query packet to the controller, the IP DA in the outer IP header of the query packet is the IP address 20.1.1.1 of the controller. The IP SA in the outer IP header is the IP address 10.1.1.1 of the Ethernet device. The IP field in the payload of the query packet, namely, the IP 1 in Table 1, is the IP address 10.1.1.1 of the Ethernet device. After receiving the query packet, the controller parses the payload in the query packet, stores related information of the Ethernet device in a local database, and extracts the information as an input during calculation.
[0072] (b) Logical port identifier, namely, an Eth-Trunk ID field.
[0073] In this embodiment of this application, the Eth-Trunk ID field includes a logical port number, interface index (ifindex) data of the logical port, and the like. In payload data of the query packet sent by the Ethernet device to the controller, the Eth-trunk ID field may uniquely identify one logical port on the Ethernet device. After calculating the weight factor, the controller sends the response packet carrying the Eth-trunk ID to the Ethernet device, so that the Ethernet device determines a corresponding logical port based on the Eth-trunk ID.
[0074] (c) Field of the quantity of physical ports, namely, a Member_Num field.
[0075] In this embodiment of this application, the Member_Num field the quantity of physical ports included in the logical port. After receiving the query packet, the controller determines the quantity of physical ports based on the Member_Num field, traverses all physical ports based on the quantity, and calculates the weight factor of each physical port based on the load information of each physical port.
[0076] (d) Physical port field, namely, Member_N, where N indicates a physical port number.
[0077] In this embodiment of this application, if the UDP packet is the query packet, a value of the field indicates the load information of the physical port, and the load information is important data for the controller to calculate the weight factor. If the UDP packet is the response packet, the value of the field indicates the weight factor of the physical port, and is used to indicate the Ethernet device to adjust the traffic of each physical port based on the weight factor of each physical port.
[0078] The following describes in detail how the controller determines the weight factor of each physical port based on the load information of each physical port in the query packet after receiving the query packet.
[0079] In a feasible design, load information of one physical port is used to indicate a percentage of consumed bandwidth of the physical port in total bandwidth of the physical port, and that the controller determines the weight factor of each physical port based on the load information of each physical port includes that the controller determines a least common multiple of percentages of the plurality of physical ports based on the percentage of each physical port. The controller determines the weight factor of each physical port based on the least common multiple. The weight factor of one physical port=the least common multiple/the percentage of the physical port.
[0080] For example, the weight factor is denoted as weight, the percentage is recorded as OutUti, the least common multiple is denoted as X, and the logical port include physical ports 1 to N. In this case, (weight_1×OutUti_1): (weight_2×OutUti_2): (weight_3×OutUti_3): (weight_4×OutUti_4): . . . : (weight_N×OutUti_N)=1:1:1: . . . Therefore, weight_1, weight_2, weight_3, and weight_N can be determined by calculating the least common multiple X of OutUti_1, OutUti_2, OutUti_3, . . . , and OutUti_N, where weight_N=X/OutUti_N. For example, in the foregoing Table 1, if the logical port identifier is 2, the field of the quantity of physical ports is 3, and physical port fields are respectively 20%, 40%, and 95%, it indicates that the logical port 2 includes the physical port 1, the physical port 2, and the physical port 3. Consumed bandwidth of the three physical ports is 20%, 40%, and 95% in total bandwidth thereof. The controller finds, based on 20%, 40%, and 95%, that the least common multiple X=0.76, and then weight factors of the physical port 1, the physical port 2, and the physical port 3 are respectively 3.8, 1.9, and 0.8. After calculating the weight factor, the controller sends the response packet to the Ethernet device. Based on Table 1, the value of the physical port field in the response packet is the weight factor.
[0081] The following describes in detail an occasion in which the Ethernet device reports the load information of each physical port in this embodiment of this application. The occasion may also be considered as an occasion in which the controller determines the weight factor of each physical port of the logical port.
[0082] In a feasible implementation, that the Ethernet device sends the query packet to the controller includes that the Ethernet device determines whether traffic of at least one physical port in the plurality of physical ports exceeds a preset threshold. If the traffic of the at least one physical port exceeds the preset threshold, the Ethernet device sends the query packet to the controller.
[0083] For example, the agent module is deployed on the Ethernet device. If a load of a specific logical port exceeds a limit, the Ethernet device notifies a user that uneven traffic allocation may occur. After detecting the event, the agent module actively collects the load information of each physical port of the logical port and reports the load information to the controller. For example, the Ethernet device pre-stores a bandwidth warning value, which is for example, 90%. In this case, if the percentage of the consumed bandwidth of the physical port in the total bandwidth of the physical port exceeds 90%, an alarm is reported to the user. The agent module senses the event, collects the load information of each physical port of the logical port, and reports the load information to the controller. For another example, a bandwidth warning value difference, which is for example, 10%, is pre-stored on the Ethernet device, and the agent module collects the load information of each logical port. If there are two physical ports, a difference between percentages of consumed bandwidth of the two physical ports is greater than 10%. In this case, the agent module sends the load information of each physical port to the controller. For example, the agent module finds that the percentages of the consumed bandwidth of the physical port 1, the physical port 2, and the physical port 3 of the logical port in the total bandwidth thereof are respectively 20%, 40%, and 60%. A difference between the percentages of the consumed bandwidth of the physical port 1 and the physical port 2 is greater than 10%, a difference between the percentages of the consumed bandwidth of the physical port 2 and the physical port 3 is greater than 10%, and a difference between the percentages of the consumed bandwidth of the physical ports 1 and the physical port 3 is greater than 10%. The agent module sends the load information of each physical port of the logical port to the controller.
[0084] In this embodiment, the Ethernet device actively reports the load information of each physical port of the logical port to the controller, so that the controller determines the weight factor based on the load information, and adjusts the traffic of each physical port without modifying a hash factor.
[0085] In another feasible design, that the Ethernet device sends the query packet to the controller includes that the Ethernet device sends the query packet to the controller for a plurality of times.
[0086] For example, the Ethernet device may periodically or aperiodically collect the load information of each physical port of the logical port, and report the load information to the controller in batches.
[0087] In this example, the Ethernet device periodically or aperiodically reports the load information of each physical port of the logical port to the controller, so that the controller determines the weight factor based on the load information, and adjusts the traffic of each physical port without modifying the hash factor.
[0088] The following describes in detail the controller in the embodiments of this application. For example,
[0089] Refer to
[0090]
[0091] In a feasible design, the processing unit 13 is further configured to determine whether traffic of at least one physical port in the plurality of physical ports exceeds a preset threshold.
[0092] The sending unit 11 is configured to if the processing unit 13 determines that the traffic of the at least one physical port exceeds the preset threshold, send the query packet to the controller.
[0093] In a feasible design, the load information of each physical port is used to indicate a percentage of consumed bandwidth of the physical port in total bandwidth of the physical port. The processing unit 13 is configured to determine whether the percentage indicated by the load information of each physical port of the logical port varies. If the percentage variation indicated by the load information of each physical port does not exceed a preset threshold, the processing unit 13 adjusts, based on the weight factor of each physical port, the traffic sent to each physical port.
[0094] In a feasible design, the processing unit 13 is further configured to If percentage variation indicated by the load information of each physical port exceeds the preset threshold, the Ethernet device re-collects load information of each physical port.
[0095] The sending unit 11 is further configured to send a query packet carrying the re-collected load information to the controller.
[0096] In a feasible design, the processing unit 13 is configured to adjust, based on a preset hash factor and the weight factor of each physical port, the traffic sent to each physical port.
[0097] The traffic balancing apparatus provided in this embodiment of this application may perform an action of the Ethernet device in the foregoing embodiment. An implementation principle and a technical effect of the traffic balancing apparatus are similar to those of the Ethernet device in the foregoing embodiment. Details are not described herein again.
[0098]
[0099] In a feasible design, the load information of each physical port is used to indicate a percentage of consumed bandwidth of the physical port in total bandwidth of the physical port, and the processing unit 22 is configured to determine a least common multiple of percentages of the plurality of physical ports based on the percentage of each physical port. The processing unit 22 determines the weight factor of each physical port based on the least common multiple. The weight factor of one physical port=the least common multiple/the percentage of the physical port.
[0100] The traffic balancing apparatus provided in this embodiment of this application may perform an action of the controller in the foregoing embodiment. An implementation principle and a technical effect of the traffic balancing apparatus are similar to those of the controller in the foregoing embodiment. Details are not described herein again.
[0101] It should be noted that, the receiving unit may be a receiver in actual implementation, and the sending unit may be a transmitter in actual implementation. The processing unit may be implemented in a form of software invoked by a processing element. This may also be implemented in a form of hardware. For example, the processing unit may be a separately disposed processing element, or may be integrated into a chip of the foregoing apparatus for implementation. In addition, the processing unit may alternatively be stored in a memory of the foregoing apparatus in a form of program code, and is invoked by a processing element of the foregoing apparatus to perform a function of the processing unit. In addition, all or some of the units may be integrated together, or may be implemented independently. The processing element described herein may be an integrated circuit with a signal processing capability. In an implementation process, steps of the foregoing method or the foregoing units may be implemented using an integrated logical circuit of hardware in the processor element, or using an instruction in a form of software.
[0102] For example, the foregoing units may be configured as one or more integrated circuits configured to implement the foregoing method, for example, one or more application-specific integrated circuits (ASICs), or one or more microprocessors (digital signal processor (DSP)), or one or more field-programmable gate arrays (FPGAs). For another example, when one of the units is implemented in a form of scheduling program code by a processing element, the processing element may be a general-purpose processor, for example, a central processing unit (CPU) or another processor that can invoke the program code. For still another example, the units may be integrated and implemented in a form of a system-on-a-chip (SOC).
[0103] In addition, an embodiment of this application further provides a traffic balancing system. The system includes one or more traffic balancing apparatuses (or a first traffic balancing apparatus) shown in
[0104]
[0105] In this embodiment of this application, the memory 32 is configured to store computer-executable program code, and the program code includes an instruction. When the processor 31 executes the instruction, the processor 31 of the traffic balancing apparatus is enabled to perform a processing action of the Ethernet device in the foregoing method embodiments, the receiver 33 is enabled to perform a receiving action of the Ethernet device in the foregoing method embodiments, and the transmitter 34 is enabled to perform a sending action of the Ethernet device in the foregoing method embodiments. Implementation principles and technical effects of the processor 31, the receiver 33, and the transmitter 34 are similar to those of the processing action, the receiving action, and the sending action. Details are not described herein again.
[0106] In another embodiment of this application, the memory 32 is configured to store computer-executable program code, and the program code includes an instruction. When the processor 31 executes the instruction, the processor 31 of the traffic balancing apparatus is enabled to perform a processing action of the controller in the foregoing method embodiments, the receiver 33 is enabled to perform a receiving action of the controller in the foregoing method embodiments, and the transmitter 34 is enabled to perform a sending action of the controller in the foregoing method embodiments. Implementation principles and technical effects of the processor 31, the receiver 33, and the transmitter 34 are similar to those of the processing action, the receiving action, and the sending action. Details are not described herein again.
[0107] An embodiment of this application further provides a storage medium. The storage medium stores a computer-executable instruction, and when the computer-executable instruction is executed by a processor, the processor is configured to implement the foregoing traffic balancing method.
[0108] An embodiment of the present disclosure further provides a computer program product. When the computer program product runs on an Ethernet device, the Ethernet device is enabled to perform the foregoing traffic balancing method.
[0109] An embodiment of the present disclosure further provides a computer program product. When the computer program product runs on a controller, the controller is enabled to perform the foregoing traffic balancing method.
[0110] All or some of the foregoing embodiments may be implemented using software, hardware, firmware, or any combination thereof. When the software is used to implement the embodiments, all or some of the embodiments may be implemented in a form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the procedures or functions according to the embodiments of this application are all or partially generated. The computer may be a general-purpose computer, a dedicated computer, a computer network, or another programmable apparatus. The computer instructions may be stored in a computer-readable storage medium or may be transmitted from a computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website, computer, server, or data center to another website, computer, server, or data center in a wired (for example, a coaxial cable, an optical fiber, or a digital subscriber line (DSL)) or wireless (for example, infrared, radio, or microwave) manner. The computer-readable storage medium may be any usable medium accessible by a computer, or a data storage device, such as a server or a data center, integrating one or more usable media. The usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, or a magnetic tape), an optical medium (for example, a digital versatile disc (DVD)), a semiconductor medium (for example, a solid-state drive (SSD)), or the like.
[0111] “A plurality of” in this application refers to two or more than two. The term “and/or” in this specification is only an association relationship for describing associated objects and represents that there may be three relationships. For example, A and/or B may represent the following three cases: only A exists, both A and B exist, and only B exists. In addition, the description manner “at least one of . . . ” in this specification indicates one of listed items or any combination thereof. For example, “at least one of A, B, and C” may indicate the following six cases: Only A exists, only B exists, only C exists, and both A and B exist, both B and C exist, both A and C exist, and A, B, and C all exist. In addition, the character “/” in this specification usually indicates an “or” relationship between the associated objects. In a formula, the character “I” indicates a “division” relationship between associated objects.
[0112] It may be understood that numerical symbols involved in the embodiments of this application are differentiated merely for ease of description, but are not used to limit the scope of the embodiments of this application.
[0113] It should be understood that sequence numbers of the foregoing processes do not mean execution sequences in the embodiments of this application. The execution sequences of the processes should be determined according to functions and internal logic of the processes, and should not be construed as any limitation on the implementation processes of the embodiments of this application.