A load balancing method and related apparatus
By using ordered numbering and path selection for network device ports, the problem of unbalanced load in existing technologies is solved, improving the load balancing and overall performance of network devices, especially in fat-tree networks for AI tasks.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HUAWEI TECH CO LTD
- Filing Date
- 2022-06-07
- Publication Date
- 2026-07-17
Smart Images

Figure CN117014378B_ABST
Abstract
Description
[0001] This application claims priority to Chinese Patent Application No. 202210474334.7, filed on April 29, 2022, entitled "A method, switch and system for load sharing", the entire contents of which are incorporated herein by reference. Technical Field
[0002] This application relates to the field of Internet technology, and in particular to a load balancing method and related apparatus. Background Technology
[0003] In communication networks, most data transmission requires high latency and reliability. Therefore, network devices used for data transmission are typically configured with multiple transmission links, and load balancing methods are used to distribute the load across these links as evenly as possible to prevent any single link from becoming overloaded and impacting service performance.
[0004] Currently, the mainstream load balancing method is the five-tuple-based load balancing method. Specifically, when a network device receives a packet, it performs a hash operation on the packet's five-tuple information and selects the transmission link based on the result, ensuring that packets with different five-tuple information are transmitted through different links. The five-tuple information includes the packet's source Internet Protocol (IP) address, destination IP address, source port number, destination port number, and transport protocol number.
[0005] However, load balancing based on quintuple information and hash algorithms has a coarse granularity, which can easily lead to multiple data streams from different sources being forwarded to the same path, resulting in network load imbalance. Summary of the Invention
[0006] This application provides a load balancing method that sequentially numbers the ports of connected network devices and selects a forwarding path based on the port number of the receiving packet when forwarding packets, thereby enabling packets from different paths to be forwarded to different paths and improving the load balancing of the network.
[0007] This application provides a load balancing method, comprising: a first network device receiving a first packet; then, the first network device selecting a target forwarding path from the equivalent forwarding paths based on the number of a first port receiving the first packet and the number of equivalent forwarding paths corresponding to the first packet; finally, the first network device forwarding the first packet through the target forwarding path. The first network device includes M ports for receiving packets, where M is greater than or equal to 2, and the M ports include the first port. Each of the M ports has a corresponding number, and the numbers of the M ports are set in an orderly manner according to the network devices connected to the M ports. That is, for the M ports connected to network devices, the M port numbers are set in an orderly manner. For ports in the first network device not connected to any network devices, no corresponding number is set. The equivalent forwarding path is determined based on the destination address of the first packet.
[0008] In this application, by systematically assigning corresponding numbers to the ports of the first network device connected to other network devices, and selecting the forwarding path of the packet based on the number of the port receiving the packet, the path selection can be performed according to the source of the packet, ensuring that packets from different sources are systematically distributed to different forwarding paths, thereby improving load balancing.
[0009] Optionally, before forwarding the first packet through the target forwarding path, the first network device determines the M ports from all its ports, wherein the network devices connected to the M ports belong to the same network layer. Here, "network devices belonging to the same network layer" means that the network devices are at the same network layer in the network architecture. For example, all switches in the access layer belong to the same network layer (i.e., the access layer).
[0010] In this application, since the forwarding paths corresponding to packets received from multiple ports on the first network device are only likely to be the same if the connected network devices belong to the same network layer, the first network device identifies multiple ports belonging to the same network layer and numbers them together to orderly allocate packets from different sources but with the same equivalent forwarding path to the corresponding forwarding path.
[0011] Optionally, the first network device is an access switch, and the multiple numbers corresponding to the M ports are consecutive.
[0012] Optionally, the network devices connected to the M ports are all terminal devices, and the first network device numbers the M ports in an orderly manner to obtain the port numbers.
[0013] In this application, when the first network device is an access switch, the packets received by the first network device from ports connected to other switches do not have multiple equivalent forwarding paths. Therefore, the ports on the first network device connected to other switches do not need to be numbered. The first network device's orderly numbering of the ports connected to terminal devices ensures load balancing.
[0014] Optionally, the network devices connected to the M ports are all switches, and the numbers corresponding to the N ports connected to the same network device among the M ports are consecutive, where N is greater than or equal to 2.
[0015] Optionally, the first network device is an aggregation switch or a core switch. The first network device determines the M ports from all its ports and divides the M ports into multiple port groups. Each port group includes one or more ports connected to the same switch. Then, the first network device sequentially numbers the ports in each port group to obtain the port numbers.
[0016] In other words, ports on the first network device that are connected to the same network device are numbered in a unified and orderly manner, while ports on the first network device that are connected to different network devices may have the same number.
[0017] Optionally, the first network device determines the M ports from all its ports, specifically including: the first network device receiving multiple Link Layer Discovery Protocol (LLDP) messages from different ports, each LLDP message indicating the network layer of the network device sending the LLDP message; and the first network device determining the M ports from all its ports based on the multiple LLDP messages. LLDP is a protocol that enables devices in a network to discover each other and announce their status and exchange information.
[0018] In this application, by sending LLDP messages between interconnected network devices and indicating its own network layer in the LLDP message, the network device receiving the LLDP message can determine the network layer of other network devices connected to its port, so that the network device can implement its own port numbering.
[0019] Optionally, the LLDP message may also be used to indicate the identifier of the network device that sent the LLDP message.
[0020] Optionally, the first network device selects a target forwarding path from the equivalent forwarding paths based on the number of the first port receiving the first packet and the number of equivalent forwarding paths corresponding to the first packet, including: the first network device calculating the value modulo the number of the first port with respect to the number of equivalent forwarding paths; and the first network device selecting the target forwarding path from the equivalent forwarding paths based on the value.
[0021] Optionally, the first network device is deployed in a fat-tree network.
[0022] In this application, by implementing a load balancing method in a fat-tree network without bandwidth convergence, the overall network throughput can be guaranteed to be 100%, that is, all links in the network are in a fully loaded state, which greatly improves the overall network performance.
[0023] Optionally, multiple servers in the fat-tree network are used to perform artificial intelligence (AI) training tasks or AI inference tasks.
[0024] Optionally, when performing the AI training task or AI inference task, one of the multiple servers sends traffic to each other only with the other server, that is, one server communicates with only one server. This communication method is called split traffic communication.
[0025] In this application, by implementing a load balancing method in a fat-tree network that performs AI training or inference tasks that satisfy the characteristics of traffic distribution, the load of each link in the network can be completely balanced, the overall network throughput reaches the theoretical maximum bandwidth, and the network bandwidth no longer becomes a performance bottleneck in the AI training or inference process, which greatly improves the performance of the network in performing AI tasks.
[0026] A second aspect of this application provides a network device, comprising: a receiving unit for receiving a first message; a processing unit for selecting a target forwarding path from the equivalent forwarding paths based on the number of a first port receiving the first message and the number of equivalent forwarding paths corresponding to the first message; and a sending unit for forwarding the first message through the target forwarding path; wherein the network device includes M ports for receiving messages, M being greater than or equal to 2, the M ports including the first port, each of the M ports having a corresponding number, and the numbering of the M ports being ordered according to the network devices connected to the M ports, and the equivalent forwarding path being determined based on the destination address of the first message.
[0027] Optionally, the processing unit is further configured to determine the M ports from all ports of the first network device; the network devices connected to the M ports belong to the same network layer.
[0028] Optionally, the network device is an access switch, and the multiple numbers corresponding to the M ports are consecutive.
[0029] Optionally, the network devices connected to the M ports are all terminal devices; the processing unit is also used to number the M ports in an orderly manner to obtain the port numbers.
[0030] Optionally, the network devices connected to the M ports are all switches, and the numbers corresponding to the N ports connected to the same network device among the M ports are consecutive, where N is greater than or equal to 2.
[0031] Optionally, the first network device is an aggregation switch or a core switch; the processing unit is further configured to: determine the M ports from all ports of the first network device, and divide the M ports into multiple port groups, each of the multiple port groups including one or more ports connected to the same switch; and number the ports in each of the multiple port groups in an orderly manner to obtain the numbers of the multiple ports.
[0032] Optionally, the processing unit is further configured to: receive multiple LLDP messages from different ports, each LLDP message indicating the network layer of the network device sending the LLDP message; and determine the M ports from all ports of the first network device based on the multiple LLDP messages.
[0033] Optionally, the LLDP message may also be used to indicate the identifier of the network device that sent the LLDP message.
[0034] Optionally, the processing unit is further configured to: calculate the value of the first port number modulo the number of the equivalent forwarding paths; and select the target forwarding path from the equivalent forwarding paths according to the value.
[0035] Optionally, the first network device is deployed in a fat-tree network.
[0036] Optionally, multiple servers in the fat-tree network are used to perform AI training tasks or AI inference tasks.
[0037] Optionally, when performing the AI training task or AI inference task, one of the multiple servers may only send traffic to the other server.
[0038] A third aspect of this application provides a network device comprising: a processor configured to cause the network device to implement the methods described in the first aspect or any possible implementation thereof. The network device may further include a memory coupled to the processor, wherein when the processor executes instructions stored in the memory, the network device may implement the methods described in the first aspect or any possible implementation thereof. The network device may also include a communication interface for communicating with other devices; exemplaryly, the communication interface may be a transceiver, circuit, bus, module, or other type of communication interface.
[0039] In this application, the instructions in the memory can be pre-stored or downloaded from the Internet and stored when using the network device. This application does not specifically limit the source of the instructions in the memory. Coupling in this application refers to indirect coupling or connection between devices, units, or modules, which can be electrical, mechanical, or other forms, used for information exchange between devices, units, or modules.
[0040] A fourth aspect of this application provides a computer storage medium that may be non-volatile; the computer storage medium stores computer-readable instructions that, when executed by a processor, implement the methods described in the first aspect or any possible implementation thereof.
[0041] The fifth aspect of this application provides a computer program product containing instructions that, when run on a computer, cause the computer to perform the methods described in the first aspect or any possible implementation thereof.
[0042] The sixth aspect of this application provides a network system that includes a plurality of network devices as described in the second or third aspect above.
[0043] The solutions provided in the second to sixth aspects above are used to implement or cooperate with the methods provided in the first aspect above, and therefore can achieve the same or corresponding beneficial effects as the first aspect, which will not be elaborated here. Attached Figure Description
[0044] Figure 1 A schematic diagram of an equivalent multipath provided for an embodiment of this application;
[0045] Figure 2 A schematic diagram illustrating network load imbalance provided in an embodiment of this application;
[0046] Figure 3A A schematic diagram of a network architecture provided in an embodiment of this application;
[0047] Figure 3BA schematic diagram of another network architecture provided for an embodiment of this application;
[0048] Figure 4 A flowchart illustrating a load balancing method provided in an embodiment of this application;
[0049] Figure 5 This is a schematic diagram illustrating the application of a load balancing method provided in an embodiment of this application;
[0050] Figure 6 This is a schematic diagram illustrating how ports in a network device are numbered, as provided in an embodiment of this application.
[0051] Figure 7 This is a schematic diagram illustrating another method of numbering ports in a network device, provided as an embodiment of this application.
[0052] Figure 8 A schematic diagram illustrating another port numbering method provided in this application embodiment;
[0053] Figure 9 A schematic diagram illustrating another port numbering method provided in this application embodiment;
[0054] Figure 10A A bandwidth diagram of a traditional tree network topology provided for an embodiment of this application;
[0055] Figure 10B A bandwidth diagram of a fat-tree network topology provided in this application embodiment;
[0056] Figure 11 A schematic diagram of a Ring Allreduce algorithm provided for an embodiment of this application;
[0057] Figure 12 A schematic diagram illustrating an NPU performing a scatter-reduce step, provided as an embodiment of this application;
[0058] Figure 13 A schematic diagram illustrating the execution of the allgather step by an NPU, provided as an embodiment of this application;
[0059] Figure 14 A schematic diagram illustrating load balancing in a network architecture for executing AI tasks, provided in an embodiment of this application;
[0060] Figure 15 This is a schematic diagram of the structure of a network device 1500 provided in an embodiment of this application;
[0061] Figure 16 This is a schematic diagram of the structure of a network device 1600 provided in an embodiment of this application;
[0062] Figure 17 This is a schematic diagram of the structure of a network device 1700 provided in an embodiment of this application. Detailed Implementation
[0063] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application are described below with reference to the accompanying drawings. Obviously, the described embodiments are merely some, and not all, of the embodiments of this application. Those skilled in the art will understand that, with the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.
[0064] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such descriptions can be used interchangeably where appropriate to allow embodiments to be implemented in a sequence other than that illustrated or described in this application. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or device that includes a series of steps or modules is not necessarily limited to those explicitly listed, but may include other steps or modules not explicitly listed or inherent to such processes, methods, products, or devices.
[0065] The naming or numbering of steps in this application does not imply that the steps in the method flow must be executed in the time / logical order indicated by the naming or numbering. The execution order of the named or numbered process steps can be changed according to the technical purpose to be achieved, as long as the same or similar technical effect can be achieved. The division of units in this application is a logical division. In actual applications, there may be other division methods. For example, multiple units may be combined into or integrated into another system, or some features may be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed may be through some interfaces, and the indirect coupling or communication connection between units may be electrical or other similar forms, which are not limited in this application. Furthermore, the units or sub-units described as separate components may or may not be physically separated, may or may not be physical units, or may be distributed in multiple circuit units. Some or all of the units can be selected to achieve the purpose of the solution in this application according to actual needs.
[0066] In a communication network, if multiple paths exist from one address to a destination address, and each path has the same cost, then multiple equal-cost paths are formed. Network devices at the intersection of these multiple paths typically select paths based on specific strategies, thus sending packets to different paths to achieve load balancing. This routing method is called equal-cost multi-path (ECMP) technology.
[0067] For example, please refer to Figure 1 , Figure 1 This is a schematic diagram illustrating an equivalent multipath implementation as provided in an embodiment of this application. For example... Figure 1 As shown, the network includes multiple switches (sw) and servers. There are two paths from server 1 to server 2: path 1 and path 2. Path 1 is: server1-sw1-sw2-sw4-server2. Path 2 is: server1-sw1-sw3-sw4-server2. Furthermore, the intersection of these two paths is sw1. Therefore, when a packet destined for server 2 arrives at sw1, sw1 will select a forwarding path based on a specific policy.
[0068] Currently, network devices located at multi-path intersections typically use a load balancing method based on 5-tuple information for path selection. However, the granularity of load balancing based on 5-tuple information is relatively coarse, which can easily lead to multiple data flows from different sources being forwarded to the same path, resulting in network load imbalance.
[0069] For example, please refer to Figure 2 , Figure 2 This is a schematic diagram illustrating network load imbalance as provided in an embodiment of this application.
[0070] like Figure 2As shown, the IP addresses of server1, server2, server3, and server4 are 0.0.0.1, 0.0.0.2, 0.0.0.3, and 0.0.0.4, respectively. Server1 sends packets P1 and P3 to server3, and server2 sends packets P2 and P4 to server4. The intersection of multiple equivalent paths is sw1. For ease of explanation, assume that sw1 uses a hash function to calculate the source and destination IP addresses in the 5-tuple information to select the packet forwarding path. Specifically, the calculation method for sw1 to select the packet forwarding path is as follows: For a packet from server1 to server3, sw1 uses a hash function to calculate the IP addresses of server1 and server3, resulting in a value of 4. Since the number of paths is 2, sw1 takes the modulo of the result with the number of paths, resulting in a value of 0, meaning it selects the 0th path to forward the packet from server1 to server3. The path numbering starts from 0.
[0071] For packets traveling from server2 to server4, sw1 performs a hash function on the IP addresses of server2 and server4, resulting in a value of 6. Since the number of paths is 2, sw1 modulo the hash result with the number of paths, resulting in a value of 0. Therefore, it selects path 0 to forward packets from server2 to server4. In other words, based on the load balancing method described above, all packets are forwarded to path 1, while no packets are forwarded on path 2, leading to unbalanced network load and impaired service performance.
[0072] In view of this, embodiments of this application provide a load balancing method that, by numbering the ports of a network device in an orderly manner according to the other network devices connected to the ports in the network device, and selecting the forwarding path according to the port number of the receiving packet when forwarding packets, packets from different paths can be forwarded to different paths, thereby improving the load balancing of the network.
[0073] For ease of understanding, the following will introduce the scenarios in which the load balancing method provided in the embodiments of this application is applied.
[0074] For example, please refer to Figure 3A , Figure 3A This is a schematic diagram of a network architecture provided in an embodiment of this application. The two-tier network architecture includes an access layer and a core layer (also known as a backbone layer). The network devices in the access layer are each connected to one or more terminal devices. For example, in... Figure 3AIn this configuration, SW1 connects terminal device 1 and terminal device 2, and SW2 connects terminal device 3 and terminal device 4. Furthermore, the network devices in the access layer are also connected to each network device in the core layer. For example, SW1 in the access layer is connected to SW3 and SW4 in the core layer, and SW2 in the access layer is connected to SW3 and SW4 in the core layer. Moreover, the connection between a network device in the access layer and a network device in the core layer can involve multiple links (…). Figure 3A (Not shown in the text).
[0075] The load balancing method provided in this application embodiment can be applied to... Figure 3A In the two-level network architecture shown, any one of the network devices (e.g., sw1-sw4) in the access layer and core layer can be used to achieve load balancing during packet forwarding.
[0076] For example, please refer to Figure 3B , Figure 3B This is a schematic diagram of another network architecture provided in an embodiment of this application. The three-tier network architecture includes an access layer, an aggregation layer, and a core layer. The network devices in the access layer are each connected to one or more terminal devices. Furthermore, the network devices in the access layer are also connected to network devices in the aggregation layer. For example, in... Figure 3B In this architecture, access layer SW1 and SW2 are both connected to aggregation layer SW5, and access layer SW3 and SW4 are both connected to aggregation layer SW6. The network devices in the aggregation layer are then connected to the various network devices in the core layer. For example, in... Figure 3B In the middle, sw5 of the aggregation layer is connected to sw7 and sw8 of the core layer, and sw6 of the aggregation layer is connected to sw7 and sw8 of the core layer.
[0077] The load balancing method provided in this application embodiment can also be applied to... Figure 3B In the three-tier network architecture shown, any one of the network devices (e.g., sw1-sw4) in the access layer, aggregation layer, and core layer can be used to achieve load balancing during packet forwarding.
[0078] Optional, in Figure 3A and Figure 3B In the network architecture shown, the network devices in the access layer, aggregation layer, and core layer can be physical devices, such as switches that implement packet forwarding functions. In addition, these network devices can also be virtualized devices. Virtualized devices can be virtual machines (VMs) running programs for sending packets, virtual routers, or virtual switches. Virtualized devices are deployed on hardware devices (e.g., physical servers). For example, the first network device can be implemented based on a general-purpose physical server combined with network function virtualization (NFV) technology.
[0079] The terminal devices accessed at the access layer are servers or virtual machines used to implement server functions. When different terminal devices need to communicate, the network devices in the network architecture handle the forwarding of packets.
[0080] It should be noted that the above is based on Figure 3A The two-level network architecture shown is Figure 3B Taking the three-tier network architecture shown as an example, this application illustrates the application scenario of the method provided in this embodiment. In practical applications, in addition to the two-tier and three-tier network architectures described above, the method provided in this embodiment can also be applied to other network architectures used for packet forwarding, and this embodiment does not specifically limit its application in this regard.
[0081] Please see Figure 4 , Figure 4 This is a flowchart illustrating a load balancing method provided in an embodiment of this application. Figure 4 As shown, the load balancing method includes the following steps 401-403.
[0082] Step 401: The first network device receives the first message.
[0083] For example, the first network device may be a network device at any of the access layer, aggregation layer, and core layer in the above-mentioned two-level or three-level network architecture. Furthermore, the first network device may be a physical switch or a virtual switch. The following will use a physical switch (hereinafter referred to as a switch) as an example to describe the method of this application embodiment.
[0084] In this embodiment, the first network device receives a first packet to be forwarded from its neighboring device. For example, if the first network device is an access switch in a two-level network architecture, the first network device receives the first packet from a terminal device. As another example, if the first network device is a core layer switch in a two-level network structure, the first network device receives the first packet from an access switch connected to it.
[0085] Step 402: The first network device selects a target forwarding path from the equivalent forwarding paths based on the number of the first port that received the first message and the number of equivalent forwarding paths corresponding to the first message.
[0086] In this embodiment, after receiving the first packet, the first network device first determines the forwarding path of the first packet based on its destination address. The forwarding path determined by the first network device based on the destination address of the first packet includes multiple equivalent forwarding paths. Therefore, the first network device needs to select one of these multiple equivalent forwarding paths to forward the first packet.
[0087] In this application, the first port of the first network device that receives the first message has a corresponding number. The first network device selects one path (i.e., the target forwarding path) from the multiple equivalent forwarding paths corresponding to the first message based on the number of the first port and the number of such paths. For example, assuming there are three equivalent forwarding paths corresponding to the first message, and the number of the first port in the first network device is 1, the first network device selects the first forwarding path from the three equivalent forwarding paths to forward the first message; or, for another example, assuming there are three corresponding equivalent forwarding paths for the first message, and the number of the first port in the first network device is 5, the first network device selects the second forwarding path from the three equivalent forwarding paths to forward the first message.
[0088] In this embodiment, the first network device includes M ports for receiving packets, where M is greater than or equal to 2. The M ports include the first port, and each of the M ports has a corresponding number. The numbering of the M ports is ordered according to the network devices connected to them. That is, for the M ports connected to network devices, the port numbers are set in an orderly manner. For ports in the first network device not connected to any network device, no corresponding number is set. By orderly assigning corresponding numbers to the ports of the first network device connected to network devices, and selecting the packet forwarding path based on the number of the port receiving the packet, the appropriate path can be effectively selected according to the packet's source, ensuring that packets from different sources are orderly distributed to different forwarding paths, thus improving load balancing.
[0089] Optionally, the first network device selects a target forwarding path from multiple equivalent forwarding paths in the following specific way: the first network device calculates the value of the first port number modulo the number of equivalent forwarding paths; then, the first network device selects the target forwarding path from the equivalent forwarding paths based on the modulo value. Here, modulo means finding the remainder when dividing two numbers. Therefore, the value of the first port number modulo the number of equivalent forwarding paths is actually the remainder after dividing the first port number by the number of equivalent forwarding paths. For example, assuming the number of equivalent forwarding paths is 3, and these 3 equivalent forwarding paths are forwarding path 0, forwarding path 1, and forwarding path 2; then, when the first port number is 0, the value of 0 modulo 3 is 0, so the first network device selects forwarding path 0 from the 3 equivalent forwarding paths; when the first port number is 1, the value of 1 modulo 3 is 1, so the first network device selects forwarding path 1 from the 3 equivalent forwarding paths; when the first port number is 2, the value of 2 modulo 3 is 2, so the first network device selects forwarding path 2 from the 3 equivalent forwarding paths.
[0090] Step 403: The first network device forwards the first packet through the target forwarding path.
[0091] After the first network device determines the target forwarding path among multiple equivalent forwarding paths, the first network device forwards the first packet through the target forwarding path.
[0092] This embodiment uses the first packet as an example to illustrate how the first network device selects a forwarding path. In practical applications, if the first network device receives other packets from the first port, and the equivalent forwarding path corresponding to the other packets is the same as that of the first packet, then the first network device will forward the first packet based on the same target forwarding path.
[0093] For example, please refer to Figure 5 , Figure 5 This is a schematic diagram illustrating the application of a load balancing method provided in an embodiment of this application.
[0094] like Figure 5 As shown, access layer sw1 is connected to terminal devices 1-4, and access layer sw2 is connected to terminal devices 5-8. Furthermore, both sw1 and sw2 are connected to sw3 and sw4. sw1 numbers the four ports connecting terminal devices 1-4 as 0, 1, 2, and 3.
[0095] When sw1 receives a packet from terminal device 1 to terminal device 5 from port 0, sw1 determines that there are four equivalent forwarding paths corresponding to the packet: two forwarding paths between sw1 and sw3, and two forwarding paths between sw1 and sw4. Then, sw1 calculates the modulo value of the port 0 number (0) divided by the number of equivalent forwarding paths (4), and obtains a value of 0. Therefore, sw1 selects forwarding path 0 for the packet from terminal device 1 to terminal device 5.
[0096] Similarly, when sw1 receives a packet from terminal device 2 to terminal device 6 from port 1, sw1 determines that there are also four equivalent forwarding paths corresponding to the packet. Furthermore, sw1 selects forwarding path 1 for the packet from terminal device 2 to terminal device 6 using the same method. Correspondingly, sw1 selects forwarding path 2 for the packet from terminal device 3 to terminal device 7, and sw1 selects forwarding path 3 for the packet from terminal device 4 to terminal device 8.
[0097] As can be seen from the above introduction, for sw1, packets from different ports are forwarded to different forwarding paths, thus achieving load balancing on sw1.
[0098] In this embodiment, the ports of the network devices are numbered in an orderly manner according to the network devices connected to the ports in the network devices, and the forwarding path is selected according to the port number of the receiving packet when forwarding packets, so that packets from different paths can be forwarded to different paths, thereby improving the load balancing of the network.
[0099] Optionally, in some embodiments, since the first network device numbers the ports to facilitate the selection of the appropriate forwarding path from multiple equivalent forwarding paths corresponding to the packets received on these ports, if the ports in the first network device are not used to receive packets, or if the packets received by the ports of the first network device do not have multiple equivalent forwarding paths, these ports on the first network device do not actually need to be numbered, so as to avoid affecting the normal numbering of other ports.
[0100] For example, in the above Figure 4 In the load balancing method shown, before forwarding the first packet through the target forwarding path, the first network device determines M ports from all its ports. Specifically, each of the M ports is connected to a network device, and the network devices connected to the M ports belong to the same network layer. Here, "network devices belonging to the same network layer" means that the network devices are at the same network layer in the network architecture. For example, all switches in the access layer belong to the same network layer (i.e., the access layer), all switches in the aggregation layer belong to the same network layer (i.e., the aggregation layer), and all switches in the core layer also belong to the same network layer (i.e., the core layer). Another example is that all terminal devices connected to the switches in the access layer also belong to the same network layer (i.e., the user layer).
[0101] If the network devices connected to two ports on the first network device are at different network layers, then the forwarding paths for packets received from these two ports will inevitably be different. The forwarding paths for packets received from two ports on the first network device can only be the same if the connected network devices belong to the same network layer. Therefore, before numbering the ports connected to network devices, the first network device needs to identify multiple ports belonging to the same network layer and number them together.
[0102] For example, please refer to Figure 6 , Figure 6 This is a schematic diagram illustrating how ports in a network device are numbered, as provided in an embodiment of this application.
[0103] like Figure 6As shown, there are five ports on sw1 in the access layer used to connect to user-level terminal devices: port A, port B, port C, port D, and port E. Since there are multiple equivalent forwarding paths for packets received from these ports during forwarding, it is necessary to number these ports. Furthermore, since only ports A, B, C, and E are actually connected to terminal devices on sw1, while port D is not connected, sw1 only assigns sequential numbers to ports A, B, C, and E. After sw1 completes the numbering, port A is numbered 0, port B is numbered 1, port C is numbered 2, and port E is numbered 3.
[0104] Furthermore, the access layer switch SW1 has four ports used to connect to the core layer switch: port a, port b, port c, and port d. However, for SW1, packets received from these ports have only one forwarding path during forwarding (determined by the destination IP address of the packet), and there are no multiple equivalent forwarding paths. For example, for a packet destined for terminal device 1, SW1 can only forward it through port A; and for a packet destined for terminal device 2, SW1 can only forward it through port B. Therefore, the ports on SW1 used to connect to the core layer switch do not need to be numbered; that is, ports a, b, c, and d do not need to be numbered.
[0105] Furthermore, in some cases, different ports on the first network device may connect to network devices at different network layers, and the packets received from the ports connected to network devices at different network layers may all require load balancing. Therefore, in such cases, the first network device can determine the ports connected to network devices at each network layer, and in the numbering process, number all ports of the connected network devices belonging to the same network layer together, that is, number the ports of the connected network devices that do not belong to the same network layer independently.
[0106] For example, please refer to Figure 7 , Figure 7 This is a schematic diagram illustrating another method of numbering ports in a network device, as provided in an embodiment of this application.
[0107] like Figure 7As shown, the aggregation layer SW5 includes four ports connecting to the access layer switches (i.e., ports A-D) and four ports connecting to the core layer switches (i.e., ports a-d). Packets received by SW5 from ports A-D have multiple equivalent forwarding paths during forwarding. For example, a packet received from port A destined for terminal device 5 has four equivalent forwarding paths, all originating from ports a-d. Furthermore, packets received by SW5 from ports a-d also have multiple equivalent forwarding paths during forwarding. For example, a packet received from port a destined for terminal device 1 has two equivalent forwarding paths, originating from ports A and B.
[0108] In this scenario, SW5 needs to number the ports of network devices connecting different network layers. For example, in... Figure 7 In SW5, ports A through D are numbered 0 through 3 respectively; ports a through d are numbered 0 through 3 respectively.
[0109] To facilitate understanding, the following will detail how to set the numbering of the M ports in the first network device in practical applications.
[0110] In implementation method 1, the first network device is an access switch, and the multiple numbers corresponding to the M ports connecting the terminal devices in the first network device are consecutive.
[0111] When the first network device is an access switch, the packets received on the first network device from ports connected to other switches do not have multiple equivalent forwarding paths. Therefore, the ports on the first network device connected to other switches do not need to be numbered. The ports on the first network device that need to be numbered are the ports connected to terminal devices; that is, the network devices connected to the M numbered ports on the first network device are all terminal devices.
[0112] After the first network device determines the M ports connected to the terminal device, the first network device numbers the M ports in an orderly manner, resulting in M port numbers, where M is greater than or equal to 2. The first network device can number the M ports in an orderly manner starting from any number; this embodiment of the application does not limit this. For example, assuming the first network device has 4 ports that need to be numbered, the first network device can start numbering the 4 ports from 0, resulting in port numbers 0, 1, 2, and 3; or the first network device can start numbering the 4 ports from 1, resulting in port numbers 1, 2, 3, and 4.
[0113] In implementation method 2, the first network device is an aggregation layer switch or a core layer switch, and the port numbers corresponding to multiple network devices connected to the same network layer in the first network device are consecutive.
[0114] For example, if the first network device is a core layer switch in a two-level network architecture, all ports on the first network device are connected to access switches at the same network layer. Therefore, after determining the M ports connected to the access switches, the first network device numbers the M ports in an orderly manner to obtain the port numbers on the first network device, where M is greater than or equal to 2.
[0115] Similarly, when the first network device is a core layer switch in a three-tier network architecture, all ports on the first network device are connected to aggregation layer switches at the same network layer. After determining the M ports connected to the aggregation layer switches, the first network device numbers the M ports in an orderly manner to obtain the port numbers.
[0116] For example, when the first network device is an aggregation layer switch in a three-tier network architecture, the network devices connected to different ports on the first network device include network devices at different tiers. That is, some ports on the first network device connect to the core layer switch, and other ports connect to the access switches. In this case, the first network device determines M ports connected to the core layer switch and L ports connected to the access switches, and numbers the M ports and L ports sequentially. For example, assuming the first network device determines that there are 4 ports connected to the core layer switch and 2 ports connected to the access switches, then the first network device will number the 4 ports connected to the core layer switch as 0, 1, 2, and 3, and the 2 ports connected to the access switches as 0 and 1, respectively.
[0117] Implementation method 3: The first network device is an aggregation layer switch or a core layer switch. All network devices connected to the M ports on the first network device are switches, and the N ports connected to the same network device among the M ports are consecutively numbered. Where M is greater than or equal to N, and N is greater than or equal to 2.
[0118] For example, if the first network device is a core layer switch in a two-tier or three-tier network architecture, all ports on the first network device are connected to switches at the same network layer. Therefore, after identifying M ports connected to switches from all its ports, the first network device divides these M ports into multiple port groups. Each port group includes one or more ports connected to the same switch. Then, the first network device sequentially numbers the ports in each port group to obtain port numbers.
[0119] For example, please refer to Figure 8 , Figure 8 This is a schematic diagram illustrating another port numbering method provided in an embodiment of this application. For example... Figure 8 As shown, assume the first network device is a core layer switch (sw3) in a two-level network architecture. The first network device has a total of 4 ports connected to access switches, of which 2 ports are connected to sw1 and the other 2 ports are connected to sw2. The first network device numbers the 2 ports connected to sw1 as 0-1, and also numbers the other 2 ports connected to sw2 as 0-1.
[0120] For example, if the first network device is an aggregation layer switch in a three-tier network architecture, the network devices connected to different ports on the first network device include network devices at different tiers. Similarly, after determining M ports connected to the switch from all ports of the first network device, the first network device divides the M ports into multiple port groups. Each port group includes one or more ports connected to the same switch. Then, the first network device sequentially numbers the ports in each port group to obtain the port numbers.
[0121] For example, please refer to Figure 9 , Figure 9 This is a schematic diagram illustrating another port numbering method provided in an embodiment of this application. For example... Figure 9 As shown, assuming the first network device is an aggregation layer switch (sw5) in a three-tier network architecture, the first network device has a total of 4 ports connected to access switches and 4 ports connected to core layer switches. Specifically, 2 ports are connected to access layer switch sw1, 2 ports to access layer switch sw2, 2 ports to core layer switch sw7, and 2 ports to core layer switch sw8. The first network device numbers the 2 ports connected to sw1 (0-1), the 2 ports connected to sw2 (0-1), the 2 ports connected to sw7 (0-1), and the 2 ports connected to sw8 (0-1).
[0122] In other words, ports on the first network device that are connected to the same network device are numbered in a unified and orderly manner, while ports on the first network device that are connected to different network devices may have the same number.
[0123] The above describes how to set the port numbers of the M ports in the first network device. In practical applications, the port numbers of the M ports in the first network device can be set manually. For example, the administrator can enter commands via command line on the first network device to indicate the port numbers; or, the administrator can enter commands via command line on the controller, and the controller can then issue commands to the first network device to indicate the port numbers.
[0124] Furthermore, the numbering of the M ports in the first network device can also be automatically set by the first network device based on the information of the network devices connected to the M ports.
[0125] For example, the first network device may receive multiple Link Layer Discovery Protocol (LLDP) messages from different ports, each LLDP message indicating the network layer of the network device sending the LLDP message. Therefore, the first network device can determine the network layer of the network device connected to each port that received the LLDP messages based on the multiple LLDP messages, and then determine M ports of the network device connected to the same network layer from all ports of the first network device.
[0126] LLDP enables a device connected to a network to send information such as its primary capabilities, management address, device identifier, and interface identifier to other devices connected to the same local area network. Simply put, LLDP is a protocol that allows devices in a network to discover each other, announce their status, and exchange information.
[0127] In this embodiment, interconnected network devices send LLDP messages to each other, and the network layer they are in is indicated in the LLDP message. This allows the network device that receives the LLDP message to determine the network layer of other network devices connected to its port.
[0128] For example, suppose the network layer identifier of the terminal device is 0, the network layer identifier of the access switch is 1, the network layer identifier of the aggregation layer switch is 2, and the network layer identifier of the core layer switch is 3. Then, when the terminal device sends an LLDP message to the access switch, the port subtype field of the LLDP message will have a value of 0, indicating that the terminal device is in the user layer. Similarly, the port subtype field of the LLDP message sent by the access switch to the aggregation layer switch will have a value of 1, indicating that the access switch is in the access layer.
[0129] In this embodiment, by having network devices send LLDP messages to each other to indicate the network layer in which the network devices are located, each network device can determine the network layer in which other network devices connected to each port are located, so that the network devices can number the ports.
[0130] Optionally, in some cases, the first network device also needs to determine whether the network devices connected to each port are the same network device in order to number the ports. For example, if the first network device is an aggregation layer switch or a core layer switch, the first network device also needs to determine whether the network devices connected to each port are the same switch.
[0131] Therefore, in some embodiments, the LLDP message can also be an identifier indicating the network device sending the LLDP message. For example, each network device in the network architecture is assigned a unique identifier, and each network device indicates its own identifier in the LLDP message when sending it to other network devices. In this way, if the identifier of the network device indicated in the LLDP received by the first network device from multiple different ports is the same, the first network device can determine that the multiple different ports are connected to the same network device.
[0132] The identifier of a network device as indicated in LLDP can be, for example, a unique identifier assigned to the network device in the current network architecture, or a unique identifier assigned to the network device during manufacturing. This application does not specifically limit the form of the network device's identifier.
[0133] Optionally, to improve network performance, in some embodiments, the first network device described above may be deployed in a fat-tree network.
[0134] Understandably, in traditional tree network topologies, bandwidth converges layer by layer, meaning the network bandwidth at the root is much smaller than the sum of the bandwidths at all the leaves. However, a fat-tree network is more like a real tree network; the branches become thicker towards the root, meaning the network bandwidth does not converge from the leaves to the root. Therefore, even if all links in a fat-tree network are at full load, link congestion will not occur.
[0135] For example, please refer to Figure 10A and Figure 10B , Figure 10A A bandwidth diagram of a traditional tree network topology provided for an embodiment of this application; Figure 10B This is a bandwidth diagram of a fat-tree network topology provided in an embodiment of this application. Figure 10A As shown, in a traditional tree network topology, all links have the same bandwidth of 1Gbps. However, there are 8 links between the access switches and terminal devices in the access layer, meaning the total bandwidth of these 8 links is 8Gbps; while there are only 4 links between the aggregation layer switches and access switches, meaning the total bandwidth of these 4 links is 4Gbps. Therefore, in a traditional tree network topology, as the network layers change, the bandwidth of the links gradually converges, causing some links in the network topology to not be able to operate at full capacity.
[0136] like Figure 10B As shown, in a fat-tree network topology, the bandwidth of each link is not uniform. Specifically, there are 8 links between the access switches and terminal devices in the access layer, each with a bandwidth of 1Gbps, for a total bandwidth of 8Gbps. There are only 4 links between the aggregation layer switches and access switches, but each link has a bandwidth of 2Gbps, also for a total bandwidth of 8Gbps. Similarly, there are 4 links between the core layer switches and aggregation layer switches, each with a bandwidth of 2Gbps, again for a total bandwidth of 8Gbps. In other words, in a fat-tree network topology, the bandwidth of the links does not converge as the network layer changes; therefore, all links in the network topology can operate at full capacity simultaneously.
[0137] In this embodiment, by implementing a load balancing method in a fat-tree network without bandwidth convergence, the overall network throughput can be guaranteed to be 100%, meaning that all links in the network are at full load, which greatly improves the overall network performance.
[0138] Optionally, the fat-tree network deployed by the first network device includes multiple servers, which are used to perform AI training or AI inference tasks. Generally, AI training or inference tasks are divided into multiple parts, with each server responsible for completing one part; that is, multiple servers work together to complete the AI training or inference task. In this case, the servers often need to communicate with each other to exchange the results they have obtained.
[0139] For example, when parallelizing the training of a neural network across multiple servers, each server's computing unit, such as a graphics processing unit (GPU) or neural network processing unit (NPU), has a complete copy of the entire neural network model. Taking the NPU as the computing unit, in each training iteration of the neural network, each NPU on the server is allocated only a subset of the samples in the mini-batch. Furthermore, in each training iteration, each NPU performs forward propagation of the neural network based on its data, followed by backpropagation of the error to calculate the gradient of the loss function relative to the network parameters. Finally, the NPUs on different servers communicate with each other to average the gradients calculated by the different NPUs, thereby applying the average gradient to update the parameters in the neural network.
[0140] To fully utilize the bandwidth between NPUs and improve communication efficiency, the Ring Allreduce algorithm is currently commonly used to achieve communication between NPUs.
[0141] Please see Figure 11 , Figure 11 This is a schematic diagram of a Ring Allreduce algorithm provided in an embodiment of this application. Figure 11 As shown, the NPUs that need to perform communication are arranged in a logical ring. In the logical ring, each NPU has a left neighbor and a right neighbor, and each NPU only sends data to its right neighbor and receives data from its left neighbor.
[0142] The algorithm consists of two steps: first, scatter-reduce, and then allgather. In the scatter-reduce step, the NPUs exchange data so that each NPU obtains a block of the final result. In the allgather step, the NPUs exchange these blocks so that all NPUs obtain the complete final result.
[0143] For example, please refer to Figure 12, Figure 12 This is a schematic diagram illustrating an NPU performing a scatter-reduce step, as provided in an embodiment of this application. Figure 12 As shown, taking a network with 8 servers as an example, assuming that each server includes one NPU, the process of performing the scatter-reduce step among the 8 NPUs (NPU0-NPU7) includes stages one to three.
[0144] In Phase 1, NPU0 and NPU4 communicate with each other to exchange data; NPU1 and NPU5 communicate with each other; NPU2 and NPU6 communicate with each other; and NPU3 and NPU7 communicate with each other.
[0145] In Phase 2, NPU0 communicates with NPU2; NPU1 communicates with NPU3; NPU4 communicates with NPU6; and NPU5 communicates with NPU7.
[0146] In Phase 3, NPU0 communicates with NPU1; NPU2 communicates with NPU3; NPU4 communicates with NPU5; and NPU6 communicates with NPU7.
[0147] Please see Figure 13 , Figure 13 This is a schematic diagram illustrating an NPU performing the allgather step, as provided in an embodiment of this application. Figure 13 As shown, after the scatter-reduce step is completed, the process of performing the allgather step between NPU0 and NPU7 includes stages four to six.
[0148] In phase four, NPU0 communicates with NPU1; NPU2 communicates with NPU3; NPU4 communicates with NPU5; and NPU6 communicates with NPU7.
[0149] In phase five, NPU0 communicates with NPU2; NPU1 communicates with NPU3; NPU4 communicates with NPU6; and NPU5 communicates with NPU7.
[0150] In phase six, NPU0 and NPU4 communicate with each other to exchange data; NPU1 and NPU5 communicate with each other; NPU2 and NPU6 communicate with each other; and NPU3 and NPU7 communicate with each other.
[0151] From the above Figure 12 and Figure 13It can be seen that during the execution of the Ring Allreduce algorithm, the NPU in the server communicates only with the NPU in the other server at each stage.
[0152] In general, AI training or AI inference tasks typically involve multiple stages. During one stage of an AI training or AI inference task, one of the multiple servers sends traffic to another server.
[0153] For example, please refer to Figure 14 , Figure 14 This diagram illustrates a network architecture for executing AI tasks to achieve load balancing, as provided in an embodiment of this application. Figure 14 As shown, the network architecture includes access layer sw1-sw4 and core layer sw5 and sw6; and access layer sw1-sw4 are all connected to core layer sw5 and sw6. Specifically, sw1 connects server 0 and server 1, sw2 connects server 2 and server 3, sw3 connects server 4 and server 5, and sw4 connects server 6 and server 7.
[0154] During a certain stage of the AI task, server 0 communicates with server 4, server 1 communicates with server 5, server 2 communicates with server 6, and server 3 communicates with server 7.
[0155] Based on the load balancing method provided in the embodiments of this application, the communication link between server 0 and server 4 includes link 1.1 between sw1 and sw5 and link 3.1 between sw5 and sw3.
[0156] The communication links between server 1 and server 5 include link 1.2 between sw1 and sw6 and link 3.2 between sw6 and sw3.
[0157] The communication links between server 2 and server 6 include link 2.1 between sw2 and sw5 and link 4.1 between sw5 and sw4.
[0158] The communication links between server 3 and server 7 include link 2.2 between sw2 and sw6 and link 4.2 between sw6 and sw4.
[0159] From the above analysis, it can be seen that, Figure 14The network architecture shown has the same load on each link, and no two data flows share a single path when traversing the network. In other words, by implementing load balancing in a fat-tree network performing AI training or inference tasks that satisfy the characteristics of traffic distribution, the load on each link in the network can be completely balanced, the overall network throughput reaches its theoretical maximum bandwidth, and network bandwidth no longer becomes a performance bottleneck in the AI training or inference process, greatly improving the network's performance in performing AI tasks.
[0160] It's important to note that the traffic characteristics of AI training or inference tasks are actually split traffic. Split traffic refers to dividing all n servers connected to the network into two equal parts, H1 and H2, where H1 has n / 2 servers and H2 has n / 2 servers. Then, one server is randomly selected from H1 and H2, and these two servers send traffic to each other. Subsequently, another server is randomly selected from the remaining servers in H1 and H2 and has it send traffic to each other, and this process is repeated until all servers are sending traffic to each other.
[0161] Therefore, the load balancing method provided in this embodiment can be applied not only to network architectures that perform AI training or AI inference tasks, but also to other network architectures that meet the characteristics of traffic distribution, and can also ensure that the load of each link in the network architecture is completely balanced.
[0162] To implement the above embodiments, this application also provides a network device. See also... Figure 15 , Figure 15 This is a schematic diagram of the structure of a network device 1500 provided in an embodiment of this application.
[0163] like Figure 15 As shown, the network device 1500 includes: a receiving unit 1501 for receiving a first packet; a processing unit 1502 for selecting a target forwarding path from the equivalent forwarding paths according to the number of the first port receiving the first packet and the number of equivalent forwarding paths corresponding to the first packet; and a sending unit 1503 for forwarding the first packet through the target forwarding path. The network device includes M ports for receiving packets, where M is greater than or equal to 2, the M ports include the first port, each of the M ports has a corresponding number, and the numbers of the M ports are set in an orderly manner according to the network devices connected to the M ports. The equivalent forwarding path is determined according to the destination address of the first packet.
[0164] Optionally, the processing unit 1502 is further configured to determine the M ports from all ports of the first network device; the network devices connected to the M ports belong to the same network layer.
[0165] Optionally, the network device is an access switch, and the multiple numbers corresponding to the M ports are consecutive.
[0166] Optionally, the network devices connected to the M ports are all terminal devices; the processing unit 1502 is further configured to number the M ports in an orderly manner to obtain the port numbers.
[0167] Optionally, the network devices connected to the M ports are all switches, and the numbers corresponding to the N ports connected to the same network device among the M ports are consecutive, where N is greater than or equal to 2.
[0168] Optionally, the first network device is an aggregation switch or a core switch; the processing unit 1502 is further configured to: determine the M ports from all ports of the first network device, and divide the M ports into multiple port groups, each of the multiple port groups including one or more ports connected to the same switch; and number the ports in each of the multiple port groups in an orderly manner to obtain the numbers of the multiple ports.
[0169] Optionally, the processing unit 1502 is further configured to: receive multiple LLDP messages from different ports, each of the multiple LLDP messages indicating the network layer of the network device that sent the LLDP message; and determine the M ports from all ports of the first network device based on the multiple LLDP messages.
[0170] Optionally, the LLDP message may also be used to indicate the identifier of the network device that sent the LLDP message.
[0171] Optionally, the processing unit 1502 is further configured to: calculate the value of the first port number modulo the number of the equivalent forwarding paths; and select the target forwarding path from the equivalent forwarding paths according to the value.
[0172] Optionally, the network device is deployed in a fat-tree network.
[0173] Optionally, multiple servers in the fat-tree network are used to perform AI training tasks or AI inference tasks.
[0174] Optionally, when performing the AI training task or AI inference task, one of the multiple servers may only send traffic to the other server.
[0175] Please refer to Figure 16 , Figure 16 This is a schematic diagram of the structure of a network device 1600 provided in an embodiment of this application. Figure 16 Although the network device 1600 shown has certain specific features, those skilled in the art will realize from the embodiments of this application that, for the sake of brevity, Figure 16 Various other features are not shown to avoid obscuring more relevant aspects of the implementation methods disclosed in this application. Therefore, as an example, in some implementations, network device 1600 includes one or more processors (e.g., CPU) 1601, a network interface 1602, a programming interface 1603, a memory 1604, and one or more communication buses 1605 for interconnecting various components. In other implementations, network device 1600 may omit or add some functional components or units based on the above examples.
[0176] In some implementations, network interface 1602 is used to connect to one or more other network devices / servers in a network system. In some implementations, communication bus 1605 includes circuitry for interconnecting and controlling communication between system components. Memory 1604 may include non-volatile memory, such as read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Memory 1604 may also include volatile memory, which may be random access memory (RAM) used as an external cache.
[0177] In some implementations, the non-transitory computer-readable storage medium of memory 1604 stores programs, modules, and data structures, or subsets thereof, including, for example, an acquisition unit (not shown), a transmission unit (not shown), and a processing unit 16041.
[0178] In one possible embodiment, the network device 1600 may have the above-described features. Figure 4 Any function in the first network device in the corresponding method embodiment.
[0179] It should be understood that network device 1600 corresponds to the first network device in the above method embodiments. Each module in network device 1600 and the other operations and / or functions described above are respectively implemented by the first network device in the above method embodiments to achieve various steps and methods. For specific details, please refer to the above... Figure 4 For the sake of brevity, the corresponding method implementations will not be described in detail here.
[0180] It should be understood that the data transmission and reception operations in this application can be performed by the network interface 1602 on the network device 1600, or the processor can call the program code in the memory and cooperate with the network interface 1602 to realize the function of the transceiver unit when needed.
[0181] In various implementations, the network device 1600 is used to execute the load balancing method provided in the embodiments of this application, such as executing the above-described method. Figure 4 The load balancing method corresponding to the illustrated embodiment.
[0182] This application Figure 16 The specific structure of the network device can be as follows: Figure 17 As shown.
[0183] Figure 17 This is a schematic diagram of the structure of a network device 1700 provided in an embodiment of this application. The network device 1700 includes a main control board 1717 and an interface board 1730.
[0184] The main control board 1717, also known as the main processing unit (MPU) or route processor, is used to control and manage the various components in the network device 1700, including route calculation, device management, device maintenance, and protocol processing functions. The main control board 1717 includes a central processing unit 1711 and a memory 1712.
[0185] Interface board 1730 is also known as a line processing unit (LPU), linecard, or service board. Interface board 1730 provides various service interfaces and implements packet forwarding. Service interfaces include, but are not limited to, Ethernet interfaces, POS (Packet over SONET / SDH) interfaces, etc. Interface board 1730 includes: a central processing unit 1731, a network processor 1732, a physical interface card (PIC) 1733, and a forwarding table entry memory 1734.
[0186] The central processing unit 1731 on the interface board 1730 is used to control and manage the interface board 1730 and communicate with the central processing unit 1711 on the main control board 1717.
[0187] The network processor 1732 is used to implement packet forwarding. The network processor 1732 can be in the form of a forwarding chip.
[0188] Physical interface card 1733 is used to implement physical layer interfacing functions. Raw traffic enters interface board 1730 through this card, and processed packets are sent out from the physical interface card 1733. Physical interface card 1733 includes at least one physical interface, also called a physical port, which can be a Flexible Ethernet (FlexE) physical interface. In some embodiments, the central processing unit 1731 of interface board 1730 can also perform the functions of network processor 1732, such as implementing software forwarding based on a general-purpose CPU, thus eliminating the need for network processor 1732 in interface board 1730.
[0189] Optionally, network device 1700 includes multiple interface boards. For example, network device 1700 also includes interface board 1740, which includes: central processing unit 1741, network processor 1742, physical interface card 1743, and forwarding table entry memory 1744.
[0190] Optionally, network device 1700 also includes a switching fabric board 1720. The switching fabric board 1720 can also be referred to as a switch fabric unit (SFU). In cases where the network device has multiple interface boards 1730, the switching fabric board 1720 is used for data exchange between the interface boards. For example, interface boards 1730 and 1740 can communicate via the switching fabric board 1720.
[0191] The main control board 1717 and the interface board are coupled. For example, the main control board 1717, interface boards 1730 and 1740, and the switching network board 1720 are interconnected via a system bus and / or a system backplane. In one possible implementation, an inter-process communication (IPC) channel is established between the main control board 1717 and the interface board 1730, and the main control board 1717 and the interface board 1730 communicate with each other through the IPC channel.
[0192] Logically, network device 1700 includes a control plane and a forwarding plane. The control plane includes a main control board 1717 and a central processing unit 1731, while the forwarding plane includes various components that perform forwarding, such as a forwarding table entry memory 1734, a physical interface card 1733, and a network processor 1732. The control plane performs functions such as publishing routes, generating forwarding tables, processing signaling and protocol messages, and configuring and maintaining the device's status. The control plane distributes the generated forwarding tables to the forwarding plane. In the forwarding plane, the network processor 1732 looks up and forwards messages received by the physical interface card 1733 based on the forwarding tables distributed by the control plane. The forwarding tables distributed by the control plane can be stored in the forwarding table entry memory 1734. In some embodiments, the control plane and the forwarding plane can be completely separated and not on the same device.
[0193] It should be understood that the receiving unit 1501 and the transmitting unit 1503 in network device 1500 can be equivalent to the physical interface card 1733 or the physical interface card 1743 in network device 1700; the processing unit 1502 in network device 1500 can be equivalent to the central processing unit 1711 or the central processing unit 1731 in network device 1700, or it can be equivalent to the program code or instructions stored in memory 1712.
[0194] It should be understood that the operation on interface board 1740 in this embodiment is consistent with the operation on interface board 1730, and will not be described again for the sake of simplicity. It should be understood that the network device 1700 in this embodiment can correspond to the first network device in the above-described method embodiments. The main control board 1717, interface board 1730 and / or interface board 1740 in the network device 1700 can implement the functions and / or various steps implemented by the first network device in the above-described method embodiments, and will not be described again for the sake of simplicity.
[0195] It's worth noting that a network device may have one or more main control boards, including a primary and a backup main control board. It may also have one or more interface boards; the stronger the network device's data processing capabilities, the more interface boards it provides. Each interface board may also have one or more physical interface cards. A switching board may or may not exist; multiple switching boards can share load and provide redundancy. In a centralized forwarding architecture, the network device may not need a switching board, with the interface boards handling the entire system's business data processing. In a distributed forwarding architecture, the network device can have at least one switching board, enabling data exchange between multiple interface boards and providing high-capacity data exchange and processing capabilities. Optionally, the network device can also consist of only one board, without a switching board, integrating the functions of the interface boards and the main control board onto this single board. In this case, the central processing unit (CPU) on the interface board and the CPU on the main control board can be combined into a single CPU, executing the combined functions of both. The specific architecture adopted depends on the specific network deployment scenario and is not a single, definitive choice.
[0196] It should be understood that the network devices of the various product forms described above each have any of the functions of the first network device in the above method embodiments, which will not be elaborated here.
[0197] Furthermore, embodiments of this application also provide a computer program product that, when run on a network device, causes the network device to perform the aforementioned... Figure 4 The method executed by the first network device in the corresponding method embodiment.
[0198] This application also provides a chip system, including a processor and an interface circuit. The interface circuit is used to receive instructions and transmit them to the processor. The processor is used to implement the methods in any of the above method embodiments.
[0199] Optionally, the chip system also includes a memory, and the chip system can have one or more processors. The processor can be implemented in hardware or software. When implemented in hardware, the processor can be a logic circuit, integrated circuit, etc. When implemented in software, the processor can be a general-purpose processor that implements the methods in any of the above method embodiments by reading software code stored in the memory.
[0200] Optionally, the chip system may contain one or more memories. These memories may be integrated with the processor or separated from it; this application does not limit this. For example, the memory may be a non-transient processor, such as a read-only memory (ROM), which may be integrated with the processor on the same chip or disposed on different chips. This application does not specifically limit the type of memory or the arrangement of the memory and processor.
[0201] The embodiments of this application have been described in detail above. The steps in the method of the embodiments of this application can be scheduled, merged or deleted in sequence according to actual needs; the modules in the device of the embodiments of this application can be divided, merged or deleted according to actual needs.
[0202] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0203] It should be understood that the phrase "an embodiment" or "one embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of this application. Therefore, "in one embodiment" or "in one embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. It should be understood that in the various embodiments of this application, the sequence number of the above-described processes does not imply a sequential order of execution; the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0204] In this article, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.
[0205] It should be understood that in the embodiments of this application, "B corresponding to A" means that B is associated with A, and B can be determined based on A. However, it should also be understood that determining B based on A does not mean that B is determined solely based on A; B can also be determined based on A and / or other information.
[0206] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, or indirect coupling or communication connection between apparatuses or units, and may be electrical, mechanical, or other forms.
[0207] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0208] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
Claims
1. A load balancing method, characterized in that, include: The first network device receives the first message; The first network device selects a target forwarding path from the equivalent forwarding paths based on the number of the first port that received the first packet and the number of equivalent forwarding paths corresponding to the first packet. The first network device forwards the first packet through the target forwarding path; The first network device includes M ports for receiving packets, where M is greater than or equal to 2. The M ports include the first port. Each of the M ports has a corresponding number, and the numbers of the M ports are set in an ordered manner. The M ports include a first port group and a second port group. The numbers of multiple ports in the first port group are consecutive, the numbers of multiple ports in the second port group are consecutive, and the numbers of multiple ports in the first port group and the numbers of multiple ports in the second port group are repeated. The equivalent forwarding path is determined based on the destination address of the first packet. The first network device selects a target forwarding path from the equivalent forwarding paths based on the number of the first port receiving the first packet and the number of equivalent forwarding paths corresponding to the first packet, including: The first network device calculates the value modulo the number of the first port with respect to the number of equivalent forwarding paths; The first network device selects the target forwarding path from the equivalent forwarding paths based on the value.
2. The method according to claim 1, characterized in that, The method further includes: The first network device determines the M ports from all ports of the first network device.
3. The method according to claim 2, characterized in that, The method further includes: The first network device numbers the M ports in an orderly manner to obtain the port numbers.
4. The method according to any one of claims 1-3, characterized in that, The network devices connected to the M ports belong to the same network layer.
5. The method according to claim 4, characterized in that, The first network device is an access layer device, and the M ports are all ports used to connect to terminal devices.
6. The method according to claim 5, characterized in that, The M ports are used to connect to different terminal devices.
7. The method according to claim 4, characterized in that, When the first network device is a core layer device in a two-level network architecture, all M ports are ports used to connect to access layer devices.
8. The method according to claim 7, characterized in that, Multiple ports in the first port group are connected to the same network device, and multiple ports in the second port group are connected to the same network device.
9. The method according to any one of claims 2-8, characterized in that, The first network device determines the M ports from all ports of the first network device, including: The first network device receives multiple Link Layer Discovery Protocol (LLDP) messages from different ports, and each LLDP message is used to indicate the network layer of the network device that sent the LLDP message. The first network device determines the M ports from all its ports based on the plurality of LLDP messages.
10. The method according to claim 9, characterized in that, The LLDP message is also used to indicate the identifier of the network device that sent the LLDP message.
11. The method according to any one of claims 1-10, characterized in that, The first network device is deployed in a fat-tree network.
12. The method according to claim 11, characterized in that, The fat-tree network contains multiple servers used to perform artificial intelligence (AI) training or inference tasks.
13. The method according to claim 12, characterized in that, When performing the AI training task or AI inference task, one of the multiple servers sends traffic to each other only with the other server.
14. A network device, characterized in that, include: The receiving unit is used to receive the first message; The processing unit is configured to select a target forwarding path from the equivalent forwarding paths based on the number of the first port receiving the first message and the number of equivalent forwarding paths corresponding to the first message; Specifically, the processing unit is used to calculate the value of the first port number modulo the number of the equivalent forwarding paths, and to select the target forwarding path from the equivalent forwarding paths according to the value; The sending unit is configured to forward the first message through the target forwarding path; The network device includes M ports for receiving packets, where M is greater than or equal to 2. The M ports include the first port. Each of the M ports has a corresponding number, and the numbers of the M ports are set in an ordered manner. The M ports include a first port group and a second port group. The numbers of multiple ports in the first port group are consecutive, the numbers of multiple ports in the second port group are consecutive, and the numbers of multiple ports in the first port group and the numbers of multiple ports in the second port group are repeated. The equivalent forwarding path is determined based on the destination address of the first packet.
15. The network device according to claim 14, characterized in that, The processing unit is also configured to determine the M ports from all ports of the network device.
16. The network device according to claim 15, characterized in that, The processing unit is also used to number the M ports in an orderly manner to obtain the numbers of the M ports.
17. The network device according to any one of claims 14-16, characterized in that, The network devices connected to the M ports belong to the same network layer.
18. The network device according to claim 17, characterized in that, The network device is an access layer device, and the M ports are all ports used to connect to terminal devices.
19. The network device according to claim 18, characterized in that, The M ports are used to connect to different terminal devices.
20. The network device according to claim 17, characterized in that, In the case where the network device is a core layer device in a two-level network architecture, all M ports are ports used to connect to access layer devices.
21. The network device according to claim 20, characterized in that, Multiple ports in the first port group are connected to the same network device, and multiple ports in the second port group are connected to the same network device.
22. The network device according to any one of claims 15-21, characterized in that, The processing unit is also used for: Multiple LLDP messages are received from different ports, and each LLDP message is used to indicate the network layer of the network device that sent the LLDP message. The M ports are determined from all ports of the first network device based on the multiple LLDP messages.
23. The network device according to claim 22, characterized in that, The LLDP message is also used to indicate the identifier of the network device that sent the LLDP message.
24. The network device according to any one of claims 14-23, characterized in that, The network devices are deployed in a fat-tree network.
25. The network device according to claim 24, characterized in that, The fat-tree network contains multiple servers used to perform AI training or AI inference tasks.
26. The network device according to claim 25, characterized in that, When performing the AI training task or AI inference task, one of the multiple servers sends traffic to each other only with the other server.
27. A network system, characterized in that, It includes a plurality of network devices as described in any one of claims 14-26.
28. A computer storage medium storing computer-readable instructions that, when executed by a processor, implement the method as described in any one of claims 1-13.
29. A computer program product comprising instructions that, when executed on a computer, implement the method as described in any one of claims 1-13.