Load balancing method and device, electronic equipment and computer readable storage medium
By synchronizing the number of member ports between devices and hash rules to pass through the MLAG system, the problem of uneven traffic load in the MLAG system is solved, and link utilization and network efficiency are improved.
Patent Information
- Application Number
- CN202411665988.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2025-03-11
AI Technical Summary
MLAG systems have limitations in traffic load sharing, resulting in bandwidth remaining at one end and packet loss at the other end.
By periodically synchronizing the number of member ports in the aggregation group corresponding to the device between two devices in the MLAG system, when the number of member ports is not equal, a hash rule is sent and the corresponding direct-connected ports are selected from the port pool, and the aggregation group is added or removed to achieve consistency of the number of ports, thereby load balancing.
The two devices in the MLAG system load balancing the traffic of the access device, improving link utilization and ensuring efficient network operation.
Smart Images

Figure CN119603235A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communications, and in particular to a load balancing method, device, electronic device and computer-readable storage medium. Background Art
[0002] With the rapid development of information technology, the construction of data centers and campus networks is becoming increasingly important. In this context, MLAG (Multi-chassis Link Aggregation Group) technology has been widely used in data center access, campus core and other scenarios due to its high reliability, flexibility and scalability. MLAG technology allows two network devices to logically form an aggregate to achieve cross-device link aggregation. Compared with traditional stacking technology, MLAG has the following advantages:
[0003] (1) Device independence: In the MLAG system, the two devices maintain independent control levels, which reduces the coupling between devices and improves system reliability.
[0004] (2) Flexible expansion: MLAG technology supports dynamic addition or deletion of member links without interrupting services to meet the needs of different scenarios.
[0005] (3) Rapid fault recovery: When a device fails, another device can quickly take over the traffic to ensure business continuity.
[0006] However, MLAG technology still has certain limitations in practical applications, especially in terms of traffic load sharing: when a member port on one end fails but the remaining member ports are still alive, since the two devices of the MLAG system are independent control planes, the traffic carried by the two devices cannot be evenly scheduled, which may easily lead to excess bandwidth on one end while congestion and packet loss may have occurred on the other end. Summary of the invention
[0007] The purpose of the present invention is to provide a load balancing method, device, electronic device and computer-readable storage medium to achieve load balancing of traffic from two devices to an access device in an MLAG system, improve link utilization, and ensure efficient operation of the network.
[0008] The embodiments of the present invention can be implemented as follows:
[0009] In a first aspect, the present invention provides a load balancing method, which is applied to a first device of an MLAG system, wherein the MLAG system further includes a second device that establishes a peer link with the first device; an access device dual-homedly accesses the MLAG system and the downlink links between the access device and the first device and the second device are not unique; the method includes:
[0010] Periodically sending to the second device the number of first member ports in the aggregation group corresponding to the access device maintained by itself;
[0011] receiving the number of second member ports in the aggregation group corresponding to the access device maintained by the second device, which is sent periodically by the second device;
[0012] When it is sensed that any access port corresponding to the access device fails and the number of the second member ports is not equal to the number of the first member ports, sending the first hash rule associated with the aggregation group corresponding to the access device to the second device;
[0013] Selecting, from a first port pool consisting of a plurality of direct-connection ports connected to the second device, idle direct-connection ports whose number is equal to that of the second member ports and whose bandwidth is consistent with that of the faulty access port;
[0014] After sending the port identifier of each selected direct-connected port, the bandwidth of the faulty access port and the aggregate link identifier to which it belongs to the second device, all the selected direct-connected ports are added to the end of the aggregation group corresponding to the access device maintained by itself; and the traffic from the first device to the access device is load balanced using the first hash rule and the adjusted aggregation group corresponding to the access device.
[0015] In a second aspect, the present invention provides a load balancing method, which is applied to a second device of an MLAG system, wherein the MLAG system further includes a first device that establishes a peer link with the second device; an access device dual-homedly accesses the MLAG system, and the downlink links between the access device and the first device and the second device are not unique; the method includes:
[0016] Periodically sending to the first device the number of second member ports in the aggregation group corresponding to the access device maintained by itself;
[0017] receiving the number of first member ports in the aggregation group corresponding to the access device maintained by the first device, which is sent periodically by the first device;
[0018] When the number of the second member ports is not equal to the number of the first member ports and the first hash rule, the port identifier of each directly connected port selected by the first device, the bandwidth of the faulty access port and the aggregate link identifier to which it belongs are received, updating the state of the second port pool based on the aggregate link identifier and the port identifier of each directly connected port selected by the first device;
[0019] Selecting idle direct-connected ports of the same number as the first member ports and having the same bandwidth as the failed access port from a second port pool consisting of a plurality of direct-connected ports connected to the first device, and adding all the selected direct-connected ports to the front of the aggregation group corresponding to the access device maintained by itself;
[0020] Based on the aggregate link identifier, replacing a second hash rule associated with the aggregation group corresponding to the access device with the first hash rule;
[0021] The first hash rule and the adjusted aggregation group corresponding to the access device are used to load balance the traffic from the second device to the access device.
[0022] In a third aspect, the present invention provides a load balancing method, which is applied to an MLAG system, wherein the MLAG system includes a first device and a second device with a peer link established; an access device is dual-homed to the MLAG system, and the downlink links between the access device and the first device and the second device are not unique; the method includes:
[0023] The first device periodically sends to the second device the number of first member ports in the aggregation group corresponding to the access device maintained by the first device;
[0024] The second device periodically sends to the first device the number of second member ports in the aggregation group corresponding to the access device maintained by the second device;
[0025] When the first device senses that any access port corresponding to the access device fails and the number of the second member ports is not equal to the number of the first member ports, the first device sends the first hash rule associated with the aggregation group corresponding to the access device to the second device, selects idle direct ports that are equal to the number of the second member ports and consistent with the bandwidth of the failed access port from the first port pool composed of multiple direct ports connected to the second device, sends the port identifier of each selected direct port, the bandwidth of the failed access port and the aggregation link identifier to which it belongs to the second device, and then adds all the selected direct ports to the end of the aggregation group corresponding to the access device maintained by itself;
[0026] The first device performs load balancing on traffic from the first device to the access device by using the first hash rule and the adjusted aggregation group corresponding to the access device maintained by the first device;
[0027] When the number of the second member ports is not equal to the number of the first member ports and the second device receives the first hash rule sent by the first device, the port identifier of each direct port selected by the first device, the bandwidth of the faulty access port and the aggregate link identifier to which it belongs, the second device updates the state of the second port pool based on the aggregate link identifier and the port identifier of each direct port selected by the first device, and then selects idle direct ports that are equal to the number of the first member ports and consistent with the bandwidth of the faulty access port from the second port pool composed of multiple direct ports connected to the first device, and adds all the selected direct ports to the front of the aggregation group corresponding to the access device maintained by itself, and replaces the second hash rule associated with the aggregation group corresponding to the access device with the first hash rule;
[0028] The second device uses the first hash rule and the adjusted aggregation group corresponding to the access device maintained by itself to load balance the traffic from the second device to the access device.
[0029] In a fourth aspect, the present invention provides a load balancing device, applied to a first device of an MLAG system, wherein the MLAG system further includes a second device that establishes a peer link with the first device; an access device is dual-homed to the MLAG system, and the downlink links between the access device and the first device and the second device are not unique; the device includes:
[0030] A first synchronization module, configured to periodically send to the second device the number of first member ports in the aggregation group corresponding to the access device maintained by the first device;
[0031] The first synchronization module is further used to receive the number of second member ports in the aggregation group corresponding to the access device maintained by the second device, which is sent regularly by the second device;
[0032] A first coordination module is configured to send a first hash rule associated with the aggregation group corresponding to the access device to the second device when it is sensed that any access port corresponding to the access device fails and the number of the second member ports is not equal to the number of the first member ports;
[0033] Selecting, from a first port pool consisting of a plurality of direct-connection ports connected to the second device, idle direct-connection ports whose number is equal to that of the second member ports and whose bandwidth is consistent with that of the faulty access port;
[0034] After sending the port identifier of each selected direct-connected port, the bandwidth of the faulty access port and the aggregated link identifier to which it belongs to the second device, all the selected direct-connected ports are added to the end of the aggregation group corresponding to the access device maintained by the first device;
[0035] The first forwarding module is used to load balance the traffic from the first device to the access device by using the first hash rule and the adjusted aggregation group corresponding to the access device.
[0036] In a fifth aspect, the present invention provides a load balancing device, applied to a second device of an MLAG system, wherein the MLAG system further includes a first device that establishes a peer link with the second device; an access device dual-homedly accesses the MLAG system and the downlink links between the access device and the first device and the second device are not unique; the device includes:
[0037] A second synchronization module, configured to periodically send to the first device the number of second member ports in the aggregation group corresponding to the access device maintained by the second device;
[0038] The second synchronization module is further used to receive the number of first member ports in the aggregation group corresponding to the access device maintained by the first device, which is sent regularly by the first device;
[0039] A second coordination module is configured to update the state of the second port pool based on the aggregate link identifier and the port identifier of each direct port selected by the first device when the number of the second member ports is not equal to the number of the first member ports and a first hash rule, a port identifier of each direct port selected by the first device, a bandwidth of the faulty access port and an aggregate link identifier to which the failed access port belongs are received.
[0040] Selecting idle direct-connected ports of the same number as the first member ports and having the same bandwidth as the failed access port from a second port pool consisting of a plurality of direct-connected ports connected to the first device, and adding all the selected direct-connected ports to the front of the aggregation group corresponding to the access device maintained by itself;
[0041] Based on the aggregate link identifier, replacing a second hash rule associated with the aggregation group corresponding to the access device with the first hash rule;
[0042] The second forwarding module is used to load balance the traffic from the second device to the access device by using the first hash rule and the adjusted aggregation group corresponding to the access device.
[0043] In a sixth aspect, the present invention provides an electronic device, comprising: a memory and a processor, wherein the memory stores a software program, and when the electronic device is running, the processor executes the software program to implement the load balancing method as described in the first aspect or the second aspect above.
[0044] In a seventh aspect, the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the load balancing method as described in the first aspect or the second aspect is implemented.
[0045] Compared with the prior art, the embodiments of the present invention provide a load balancing method, device, electronic device and computer-readable storage medium. The MLAG system includes a first device and a second device system with a peer link established; the access device is dual-homed to the MLAG system and the downlink links between the access device and the first device and the second device are not unique. The method is: the devices at both ends periodically synchronize the number of member ports in the aggregation group corresponding to the access device; thus, when the number of two member ports is not equal, the first device sends the first hash rule associated with the aggregation group corresponding to the access device to the second device, so that the second device replaces the second hash rule associated with the aggregation group corresponding to the access device with the received first hash rule, and the first device and the second device each select a directly connected port from their own port pool to join the aggregation group maintained by themselves so that the number of aggregation group ports at both ends is consistent. In this way, both the first device and the second device can load balance the traffic to the access device based on the first hash rule and the respectively adjusted aggregation groups corresponding to the access devices, thereby improving link utilization. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0047] Figure 1 The figure is a schematic diagram of an MLAG network.
[0048] Figure 2 One of the flow charts of a load balancing method provided in an embodiment of the present invention.
[0049] Figure 3 One of the application scenario schematic diagrams provided by an embodiment of the present invention.
[0050] Figure 4 The second flowchart of a load balancing method provided by an embodiment of the present invention.
[0051] Figure 5 The present invention provides a second application scenario diagram of an embodiment of the present invention.
[0052] Figure 6The third flowchart of a load balancing method provided by an embodiment of the present invention.
[0053] Figure 7 One of the structural schematic diagrams of a load balancing device provided by an embodiment of the present invention.
[0054] Figure 8 The second structural diagram of a load balancing device provided by an embodiment of the present invention.
[0055] Fig. 9 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0056] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0057] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0058] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0059] In addition, the terms “first”, “second”, etc., if used, are merely used to distinguish between the descriptions and should not be understood as indicating or implying relative importance.
[0060] It should be noted that, in the absence of conflict, the features in the embodiments of the present invention may be combined with each other.
[0061] Here, the key words or key terms involved in the present invention are first introduced.
[0062] 1. MLAG: Please combine Figure 1When MLAG networking is used, different ports on two devices, SwitchA and SwitchB, are combined into an aggregation group to achieve the same function as a common LAG (Link Aggregation Group). For access devices, the two MLAG devices are considered to be one device. A peer-link is configured between the two MLAG devices, so that the two MLAG devices can synchronize protocol packets to achieve active-active forwarding.
[0063] Among them, Eth-Trunk (Ethernet link aggregation) is a technology that bundles multiple physical Ethernet interfaces into one logical interface, mainly used to increase network bandwidth, enhance network reliability, and achieve load balancing. This technology bundles multiple independent physical interfaces together to form a logical interface with higher bandwidth, thereby improving the overall performance and availability of the network.
[0064] 2. FlexE: Flexible Ethernet. FlexE technology is based on high-speed Ethernet interface. By decoupling Ethernet MAC rate and PHY rate, it can flexibly control the interface rate to adapt to different network transmission structures.
[0065] 3. LACP (Link Aggregation Control Protocol) negotiation is divided into two modes:
[0066] (1) Active mode: In LACP's active mode, if a port goes down, the switch detects the link status change and notifies the peer switch. Then, according to the LACP protocol rules, the port is automatically removed from the aggregation group.
[0067] (2) Passive mode: In the passive mode of LACP, the behavior is similar to the active mode, but the passive mode port does not actively send LACP packets, but responds to the packets sent by the active mode port. If the port becomes down, it will also be removed from the aggregation group.
[0068] Next, the application scenarios of the present invention are introduced.
[0069] In the application scenario of the present invention, the MLAG system includes a first device and a second device, and a peer link is established between the two; at least one user-side access device is dual-homed to the MLAG system and the downlink link between each access device and the first device and the second device is not unique.
[0070] The first device and the second device may be a switch or a distributed switching device, etc., and the access device may be a switching device or a router or server with a switching function, etc. The first device and the second device may be a master device and a backup device, respectively, or the first device and the second device may be a backup device and a master device, respectively, which is not limited here.
[0071] The first device maintains a first port pool, and the second device maintains a second port pool; the first port pool includes multiple direct ports of the first device, and the second port pool includes multiple direct ports of the second device. Each direct port in the first port pool is connected to a direct port in the second port pool to form a direct link between the first device and the second device.
[0072] Optionally, the peer link between the first device and the second device can be a logical link formed by bundling multiple direct links. On this basis, through FlexE technology, the first device can directly apply for port resources on multiple physical direct links corresponding to the peer link, and use FlexE technology to bundle the applied multiple direct ports to form a logical FlexE channel, so that the multiple direct ports bundled by the first device constitute the first port pool; on the second device, similarly apply for the direct ports corresponding to the multiple direct ports applied by the first device for bundling, so that the multiple direct ports bundled by the two devices constitute the second port pool. In this case, the direct ports in the two port pools are both logical ports. The FlexE channel is used to undertake unicast traffic to achieve load balancing of traffic in the event of a downlink link failure. In this way, the physical link bandwidth corresponding to the peer link can be fully utilized.
[0073] Alternatively, each link between the first device and the second device may also be an additional direct physical link in addition to the multiple physical links corresponding to the peer link. In this case, the direct ports in the two port pools are all physical ports.
[0074] The load balancing method provided in an embodiment of the present invention is used to load balance the traffic from the MLAG system to the access device corresponding to the failed downlink link when a downlink link fails. Next, taking an access device dual-homing to the MLAG system as an example, the load balancing method is introduced.
[0075] Please refer to Figure 2 , Figure 2 This is one of the flow charts of a load balancing method provided in an embodiment of the present invention. The execution subject of the load balancing method is the first device in the MLAG system. The load balancing method includes the following steps S101 to S104.
[0076] S101. Periodically send to a second device the number of first member ports in an aggregation group corresponding to an access device maintained by the second device.
[0077] In this embodiment, on the first device, each port of the access device connected to the first device belongs to an aggregation group, and the number of first member ports periodically sent by the first device to the second device is the number of ports in the up state in the aggregation group.
[0078] S102: Receive the number of second member ports in the aggregation group corresponding to the access device maintained by the second device, which is periodically sent by the second device.
[0079] In this embodiment, on the second device, each port of the access device connected to the second device belongs to an aggregation group, and the number of second member ports periodically sent by the second device to the first device is the number of ports in the up state in the aggregation group.
[0080] It can be understood that, for the same access device, the aggregation link identifier of the aggregation group corresponding to the access device maintained by the first device is consistent with the aggregation link identifier of the aggregation group corresponding to the access device maintained by the second device.
[0081] S103: When it is sensed that any access port corresponding to the access device fails and the number of second member ports is not equal to the number of first member ports, send a first hash rule associated with the aggregation group corresponding to the access device to the second device.
[0082] In this embodiment, the hash rule may specify the basis for calculating the hash value, and the forwarding port may be determined based on the calculated hash value, for example, if the hash value is n, the port ranked n in the aggregation group is used as the forwarding port. The hash rule may be: the hash value is calculated based on at least one of the source MAC address, the destination MAC address, the source IP address, the destination IP address, the source port, and the destination port.
[0083] Therefore, the first hash rule associated with the aggregation group corresponding to the access device is used to perform hash routing on the traffic from the first device to the access device.
[0084] S104: Select idle direct-connection ports whose number is equal to the second member ports and whose bandwidth is consistent with that of the faulty access port from a first port pool formed by a plurality of direct-connection ports connected to the second device.
[0085] In this embodiment, the second device sets the state of each directly connected port selected from the first port pool to a busy state.
[0086] S105: After sending the port identifier of each selected direct-connected port, the bandwidth of the faulty access port and the aggregate link identifier to which it belongs to the second device, all the selected direct-connected ports are added to the end of the aggregation group corresponding to the access device maintained by itself.
[0087] In this embodiment, the first device adds all selected direct-connected ports after the last access port in the aggregation group corresponding to the access device maintained by itself, and sets each added direct-connected port not to participate in LACP negotiation.
[0088] S106: Use the first hash rule and the adjusted aggregation group corresponding to the access device to load balance the traffic from the first device to the access device.
[0089] It can be understood that in the process of traffic forwarding after adjustment, the first device can use the first hash rule and the adjusted aggregation group corresponding to the access device to load balance the traffic from the first device to the access device. That is, based on the first hash rule and the adjusted aggregation group corresponding to the access device, part of the traffic from the first device to the access device can be transmitted by the downlink link that is not faulty, and the other part can be transmitted to the second device by the FlexE channel, and then the second device can be transmitted to the access device. In this way, load balancing is achieved to avoid the phenomenon of uneven traffic distribution: the failure of a downlink link of the first device causes congestion and packet loss in other downlink links, while each downlink link of the second device still has bandwidth surplus.
[0090] In the load balancing method provided by the embodiment of the present invention, the first device and the second device periodically synchronize the number of member ports in the aggregation group corresponding to the access device; thus, when the number of two member ports is not equal, the first device will send the first hash rule associated with the aggregation group corresponding to the access device to the second device, and select a directly connected port from its own port pool to join the aggregation group maintained by itself so that the number of aggregation group ports at both ends is consistent. In this way, the first device can load balance the traffic going to the access device based on the first hash rule and the adjusted aggregation group corresponding to the access device, thereby improving link utilization.
[0091] In an optional implementation, after the port failure is restored, the first device needs to remove the directly connected port added to the aggregation group corresponding to the access device to release the port resources. Therefore, after the above step S102, the method further includes:
[0092] S107. When the number of the second member ports is equal to the number of the first member ports, check whether there is a directly connected port belonging to the first port pool in the aggregation group corresponding to the access device maintained by itself; if so, delete each directly connected port in the aggregation group corresponding to the access device maintained by itself.
[0093] In this embodiment, when the number of second member ports is equal to the number of first member ports, if there is a direct port belonging to the first port pool in the aggregation group corresponding to the access device maintained by the first device itself, it means that an access port of the first device has been changed to the down state, and now the access port has been restored to the up state. The first device needs to delete the direct port added to the aggregation group to release port resources.
[0094] In an optional implementation, since the direct connection port in the first port pool and the direct connection port in the second port pool are one-to-one connected, in order to ensure that the traffic is correctly loaded, the first device loads the traffic flowing to the access device to the direct connection link used by the second device, and the second device loads the traffic flowing to the access device to the direct connection link of the first device cannot be repeated. Therefore, the method may also include:
[0095] S100. Obtain a first port pool, and for each direct-connected port in the obtained first port pool, send a port identifier of the direct-connected port from the direct-connected port based on the LLDP (Link Layer Discovery Protocol) protocol, and when the direct-connected port receives a port identifier sent by a second device, associate the port identifier of the direct-connected port with the received port identifier to obtain a first port mapping table.
[0096] In this embodiment, each directly connected port in the first port pool has LLDP protocol enabled. The first port mapping table finally obtained by the first device includes the port identifier of each directly connected port in the first port pool and the port identifier of the directly connected port on the associated second device.
[0097] by Figure 3 For example, assuming that there are two downlink links between the access device and the first device and the second device, and there are four direct links (S1-S4) between the first device and the second device, which are bundled to form a virtual FlexE channel, then the first port pool maintained by the first device includes four direct ports a1, a2, a3, and a4, and the second port pool maintained by the second device includes four direct ports b1, b2, b3, and b4.
[0098] Combination Figure 3 For the directly connected port a1 in the first port pool, the first device will send the port identifier of port a1 from the directly connected port to the second device based on the LLDP protocol. Similarly, the first device can receive the port identifier of port b1 sent by the second device at port a1, and then the first device associates the port identifier of port a1 with the port identifier of port b1 and writes them into the first port mapping table; similarly, the first device adopts the same method for other directly connected ports in the first port pool to obtain the final first port mapping table.
[0099] This example is only an example and is not intended to be limiting.
[0100] In an optional implementation, when the ports in the first port pool are port resources belonging to a peer link, the port resources in the first port pool may be insufficient, and the first device is supported to apply for port resources from the physical port corresponding to the peer link using FlexE technology in real time to achieve flexible application of port resources. Therefore, between the above steps S103 and S104, the method may further include:
[0101] S111 . Based on the bandwidth of the faulty access port, determine whether there are idle matching direct-connected ports in the first port pool that are equal in number to the second member ports.
[0102] S112: If not, determine the number of virtual direct ports to be created based on the number of matching direct ports and the number of second member ports in the first port pool.
[0103] In this embodiment, the number of first member ports and the number of second member ports are represented by M and N respectively, and M≠N. After the first device sends the first hash rule to the second device, it first determines whether there are N idle matching direct ports in the first port pool that are consistent with the bandwidth of the faulty access port. If the number of matching direct ports in the first port pool is greater than or equal to 0 and less than N, then the port resources are insufficient, and the number to be created needs to be calculated (assuming the number to be created is K), and then K port resources are applied for immediately (that is, K virtual direct ports need to be created).
[0104] S113. Based on any physical port corresponding to the peer link, a virtual direct port consistent with the bandwidth of the faulty access port is created using the FlexE protocol based on the determined number to be created, and a creation notification is sent to the second device based on the physical port, the number to be created, and the bandwidth of the faulty access port.
[0105] In this embodiment, the K virtual direct ports created by the first device belong to logical ports with the same bandwidth as the faulty access port, and the K virtual direct ports may belong to a physical port A corresponding to the peer link. After the first device creates the K virtual direct ports, it may send a creation notification to the second device through the peer link, and the creation notification includes the port identifier of the physical port A to which the K virtual direct ports belong, the number K to be created, and the bandwidth of the faulty access port, so that the second device can create K virtual direct ports with the same bandwidth as the faulty access port based on the bandwidth resources of the physical port B connected to the physical port A.
[0106] S114: Add all created virtual direct-connected ports to the first port pool, and send port identifiers of the virtual direct-connected ports from the virtual direct-connected ports based on the LLDP protocol.
[0107] In this embodiment, the first device adds the created K virtual direct connection ports to the first port pool, and then sends the port identifiers of the K virtual direct connection ports from the K virtual direct connection ports respectively. Therefore, the second device can receive the port identifiers sent by the first device at all the K virtual direct connection ports it creates. The second device associates the port identifier of each created virtual direct connection port with the port identifier received at that port and then writes it into the second port mapping table, and sets the state of each virtual direct connection port to the idle state.
[0108] S115. When the port identifier sent by the second device is received at each virtual direct connection port, associate the port identifier of the virtual direct connection port with the received port identifier and then write it into the first port mapping table, and set the state of each virtual direct connection port to the idle state.
[0109] In this embodiment, after creating K virtual direct connection ports, the second device adds the created K virtual direct connection ports to the second port pool, and then sends the port identifiers of the K virtual direct connection ports from the K virtual direct connection ports respectively. Therefore, the first device can receive the port identifiers sent by the second device at all the K virtual direct connection ports it creates. The first device associates the port identifier of each created virtual direct connection port with the port identifier received at that port and then writes it into the first port mapping table, and sets the state of each virtual direct connection port to the idle state.
[0110] In this way, when the port resources in the first port pool are insufficient (the matching direct connection ports < N), through the above steps S111 - S114, the number of matching direct connection ports that are idle and have the same bandwidth as the faulty access port in the first port pool can be made to be N, meeting the port requirements of the first device when the number M of the first member ports ≠ the number N of the second member ports, realizing the flexible reuse of the physical ports corresponding to the peer links and improving the port resource utilization rate.
[0111] Please refer to Figure 4 , Figure 4 FIG. 2 is a second flowchart of a load balancing method provided by an embodiment of the present invention. The execution subject of this load balancing method is the second device in the MLAG system, and this load balancing method includes the following steps S201 - S203.
[0112] S201. Periodically send the number of second member ports in the aggregation group corresponding to the access device maintained by itself to the first device.
[0113] S202. Receive the number of first member ports in the aggregation group corresponding to the access device maintained by the first device periodically sent by the first device.
[0114] S203. When the number of second member ports is not equal to the number of first member ports and the first hash rule sent by the first device, the port identifier of each directly connected port selected by the first device, the bandwidth of the faulty access port and the aggregate link identifier to which it belongs are received, the status of the second port pool is updated based on the aggregate link identifier and the port identifier of each directly connected port selected by the first device.
[0115] In this embodiment, when the number of second member ports is not equal to the number of first member ports, the second device can receive the first hash rule, the port identifier of each direct port selected by the first device, the bandwidth of the faulty access port and the aggregate link identifier to which it belongs, and other information sent by the first device. After receiving the information, the second device first updates the status of the second port pool based on the second port mapping table, the received aggregate link identifier and the port identifier of each direct port selected by the first device, and then selects from the second port pool. This can avoid the direct port selected by the second device being connected to the direct port selected by the first device.
[0116] S204: From a second port pool consisting of multiple direct ports connected to the first device, select idle direct ports whose number is equal to that of the first member ports and whose bandwidth is consistent with that of the faulty access port, and add all the selected direct ports to the front of the aggregation group corresponding to the access device maintained by itself.
[0117] In this embodiment, the second device adds all the selected direct-connected ports before the first access port in the aggregation group corresponding to the access device maintained by itself, and sets each added direct-connected port not to participate in LACP negotiation.
[0118] S205: Based on the aggregate link identifier, replace the second hash rule associated with the aggregation group corresponding to the access device with the first hash rule.
[0119] In this embodiment, the aggregation group corresponding to the access device maintained by the second device originally has an associated second hash rule for performing hash routing on the traffic from the second device to the access device. The second device needs to find the second hash rule associated with the aggregation group corresponding to the access device based on the aggregated link identifier, and replace the associated second hash rule with the first hash rule, so that the first device and the second device use the same hash rule to perform hash routing on the traffic to the downlink link, avoiding traffic looping.
[0120] S206: Use the first hash rule and the adjusted aggregation group corresponding to the access device to load balance the traffic from the second device to the access device.
[0121] In this embodiment, during the process of traffic forwarding after adjustment, the second device can use the first hash rule and the adjusted aggregation group corresponding to the access device maintained by itself to load balance the traffic from the second device to the access device. That is, based on the first hash rule and the adjusted aggregation group corresponding to the access device, part of the traffic from the second device to the access device can be transmitted by its own downlink link, and the other part can be transmitted to the first device by the FlexE channel, and then the first device can transmit it to the access device. In this way, load balancing is achieved to avoid the phenomenon of uneven traffic distribution: the failure of a downlink link of the first device causes congestion and packet loss in other downlink links, while each downlink link of the second device still has bandwidth surplus.
[0122] In the load balancing method provided by the embodiment of the present invention, the first device and the second device periodically synchronize the number of member ports in the aggregation group corresponding to the access device; thus, when the number of two member ports is not equal, the second device will select a directly connected port from its own port pool to join the aggregation group maintained by itself so that the number of aggregation group ports at both ends is consistent, and the second device will receive the first hash rule sent by the first device, and the second device will replace the second hash rule associated with the aggregation group corresponding to the access device with the received first hash rule. In this way, the second device can load balance the traffic to the access device based on the first hash rule and the adjusted aggregation group corresponding to the access device, thereby improving link utilization.
[0123] In an optional implementation, after the port failure is restored, the second device needs to remove the directly connected port in the aggregation group corresponding to the access device to release the port resources. Therefore, after the above step S202, the method further includes:
[0124] S207. When the number of second member ports is equal to the number of first member ports, check whether there is a direct port belonging to the second port pool in the aggregation group corresponding to the access device maintained by itself; if so, delete each direct port in the aggregation group corresponding to the access device maintained by itself, and set the state of each target direct port belonging to the first port pool to an idle state.
[0125] In this embodiment, when the number of second member ports is equal to the number of first member ports, if there is a directly connected port belonging to the second port pool in the aggregation group corresponding to the access device maintained by the second device itself, it means that a port of the first device has been changed to the down state before, and the port has been restored to the up state at this time, or a port of the second device has been changed to the down state, the second device needs to delete the directly connected port added to the aggregation group to release the port resources.
[0126] In an optional implementation, since the direct connection port in the first port pool and the direct connection port in the second port pool are one-to-one connected, in order to ensure that the traffic is correctly loaded, the first device loads the traffic flowing to the access device to the direct connection link used by the second device, and the second device loads the traffic flowing to the access device to the direct connection link of the first device cannot be repeated. Therefore, the method may also include:
[0127] S200. Obtain a second port pool, and for each directly connected port in the obtained second port pool, send the port identifier of the directly connected port to the first device based on the LLDP protocol, and when the port identifier sent by the first device is received from the directly connected port, associate the port identifier of the directly connected port with the received port identifier to obtain a second port mapping table.
[0128] In this embodiment, each direct port in the obtained second port pool has LLDP protocol enabled. The second port mapping table finally obtained by the first device includes the port identifier of each direct port in the second port pool and the port identifier of the direct port on the associated first device.
[0129] This example is only an example and is not intended to be limiting.
[0130] Optionally, the process of updating the state of the second port pool based on the aggregate link identifier and the port identifier of each directly connected port selected by the first device in the above step S203 may include the following sub-steps:
[0131] S2031: Find the to-be-updated direct-connection port corresponding to the port identifier of each direct-connection port selected by the first device from the second port mapping table, and set the state of each to-be-updated direct-connection port to a busy state.
[0132] S2032: Obtain traffic configuration information of the aggregation group corresponding to the aggregation link identifier, and configure the traffic configuration information to each directly connected port to be updated.
[0133] The traffic configuration information is used to limit the information of the flow that each port of the aggregation group is allowed to pass. For example, the flow information included in the traffic configuration information is vlan 100, which means that each port of the aggregation group is only allowed to transparently transmit the flow belonging to vlan 100. This example is only a limitation and is not used as a limitation on the traffic configuration information.
[0134] In this embodiment, on the second device, each directly connected port to be updated is not added to any aggregation group, but in order to ensure that it can receive the traffic from the first device, the second device needs to send the traffic configuration information of the aggregation group corresponding to the received aggregate link identifier to each directly connected port to be updated.
[0135] In an optional implementation, when the ports in the first port pool belong to the port resources of the peer link, the port resources of the first port pool may be insufficient, and the first device is supported to apply for port resources from the physical port corresponding to the peer link in real time using FlexE technology to achieve flexible application of port resources. At this time, the second device also needs to apply for port resources. Therefore, between the above steps S203 and S204, the method may also include:
[0136] S221. When a creation notification sent by the first device is received, based on the creation notification, obtain a port identifier of a physical port of the first device, a quantity to be created, and a bandwidth of a faulty access port.
[0137] S222: Based on the physical port connected to the physical port of the first device and the number to be created, create a virtual direct port with the same bandwidth as the failed access port by using the FlexE protocol.
[0138] In this embodiment, the first device can determine the physical port B connected to the received physical port A of the first device. Assuming the number to be created is K, the second device can create K virtual direct ports consistent with the bandwidth of the faulty access port based on the physical port B connected to the physical port A.
[0139] S223: Add all created virtual direct-connected ports to the second port pool, and send the port identifier of each virtual direct-connected port from each virtual direct-connected port based on the LLDP protocol.
[0140] In this embodiment, the second device adds the created K virtual direct ports to the second port pool, and sends the port identifiers of the K virtual direct ports from the K virtual direct ports respectively based on the LLDP protocol.
[0141] S224: When a port identifier sent by the first device is received at each virtual direct port, the port identifier of the virtual direct port is associated with the received port identifier and written into the second port mapping table, and the state of each virtual direct port is set to an idle state.
[0142] In this embodiment, the second device can also receive the port identifier sent by the first device at K virtual direct ports. The second device will associate the port identifier of each created virtual direct port with the port identifier received at the port and write it into the second port mapping table, and set the state of each virtual direct port to an idle state.
[0143] Next, a specific example is given to illustrate the load balancing method of the present invention.
[0144] See also Figure 3, assuming that there are two downlink links between the access device and the first device and the second device, and there are four direct links (S1-S4) between the first device and the second device, which are bundled to form a virtual FlexE channel, then the first port pool maintained by the first device includes four direct ports a1, a2, a3, and a4, and the second port pool maintained by the second device includes four direct ports b1, b2, b3, and b4.
[0145] Combination Figure 3 Under normal circumstances, the aggregation group corresponding to the access device maintained by the first device includes two access ports a5 and a6 in the up state, while the aggregation group corresponding to the access device maintained by the second device includes two access ports b5 and b6 in the up state. The number of second member ports received by the first device each time is 2, and the number of first member ports received by the second device each time is also 2.
[0146] exist Figure 3 Based on Figure 5 , if the downlink link S6 fails, the port a6 of the first device will switch to the down state (that is, it is regarded as sensing that the access port has failed). At this time, the number of first member ports is 1, and the number of second member ports received by the first device is 2, which are not equal. The measures taken by the first device are:
[0147] After sending the first hash rule associated with the aggregation group corresponding to the access device to the second device, two idle direct ports that are consistent with the bandwidth of the faulty access port a6 are selected from the multiple direct ports in the first port pool (assuming that the selected direct ports include a2 and a4), and then the port identifiers of a2 and a4, the bandwidth of the faulty access port a6 and the aggregation link identifier to which it belongs are sent to the second device, and all the selected direct ports are added to the end of the aggregation group corresponding to the access device maintained by itself, and the adjusted aggregation group is {a5, a2, a4}.
[0148] When the second device receives the number of the first member ports (1) and determines that it is not equal to the number of the second member ports (2), it can receive the first hash rule, the port identifiers of a2 and a4, the bandwidth of the faulty access port a6 and the identifier of the aggregation link to which it belongs, and then takes the following measures:
[0149] First, based on the respective port identifiers of a2 and a4, find out from the second port mapping table that the ports connected to a2 and a4 are b2 and b4 respectively, set the states of b2 and b4 to busy, obtain the traffic configuration information of the aggregation group corresponding to the received aggregation link identifier, and send the traffic configuration information to b2 and b4 to ensure that b2 and b4 can receive the traffic from the first device load;
[0150] Select one idle direct port with the same bandwidth as the faulty access port a6 from the multiple direct ports in the second port pool (assuming the selected direct port is b3), and add all the selected direct ports before the first access port in the aggregation group corresponding to the access device maintained by itself, and the adjusted aggregation group is {b3, b5, b6}. Then, based on the received aggregation link identifier, find the second hash rule associated with the aggregation group corresponding to the access device and replace it with the first hash rule.
[0151] That is, on the first device and the second device, the aggregation group corresponding to the downlink link before and after the adjustment is as shown in the following table (assuming that the port will be automatically removed from the aggregation group after it goes down):
[0152] First Equipment Second device Aggregation group before adjustment a5, a6 b5, b6 Adjusted aggregation group a5, a2, a4 b3, b5, b6
[0153] Combination Figure 5 After the adjustment, assuming that the first device receives a message A, and the hash value calculated based on the first hash rule and the five-tuple of message A is 2, the first device can send the message A from the direct port a2 in the aggregation group. When the second device receives the message A, the hash value calculated based on the first hash rule and the five-tuple of message A is 2, and the second device will send the message from the access port b5 in the aggregation group to the access device.
[0154] In this way, assuming that the first device receives the traffic of unit 1, one-third of the traffic can be transmitted to the access device through the downlink link S5, and two-thirds of the traffic can reach the second device through the direct link S2 and S4, and the second device transmits it to the downlink device through the downlink link S7 or S8. Similarly, assuming that the second device receives the traffic of unit 1, two-thirds of the traffic can be transmitted to the access device through the downlink link S7 and S8, and one-third of the traffic can reach the first device through the direct link S3, and the first device transmits it to the access device through the downlink link S5 or S6. That is, the first device and the second device use the same hash algorithm, and the first device adds the direct port to the end of the aggregation group, while the second device adds the direct port to the beginning of the aggregation group, avoiding loops and making the traffic carried by each port in the aggregation balanced.
[0155] The above examples are merely illustrative and the present invention is not limited thereto.
[0156] Please refer to Figure 6 , Figure 6 The third flow chart of a load balancing method provided by an embodiment of the present invention is that the execution subject of the load balancing method is the MLAG system, and its basic principle is consistent with the above content, which will not be described in detail here. The load balancing method includes the following steps S301-304.
[0157] S301: A first device periodically sends to a second device the number of first member ports in an aggregation group corresponding to an access device maintained by the first device.
[0158] S302: The second device periodically sends to the first device the number of second member ports in the aggregation group corresponding to the access device maintained by the second device.
[0159] S303. When the first device senses that any access port corresponding to the access device has a fault and the number of second member ports is not equal to the number of first member ports, the first device sends the first hash rule associated with the aggregation group corresponding to the access device to the second device, and then selects idle direct ports that are equal to the number of second member ports and consistent with the bandwidth of the faulty access port from the first port pool composed of multiple direct ports connected to the second device, and sends the port identifier of each selected direct port, the bandwidth of the faulty access port and the aggregate link identifier to which it belongs to to the second device, and then adds all the selected direct ports to the end of the aggregation group corresponding to the access device maintained by itself.
[0160] S304: The first device uses the first hash rule and the adjusted aggregation group corresponding to the access device maintained by the first device to load balance the traffic from the first device to the access device.
[0161] S305. When the number of second member ports of the second device is not equal to the number of first member ports and the second device receives the first hash rule sent by the first device, the port identifier of each direct port selected by the first device, the bandwidth of the faulty access port and the aggregate link identifier to which it belongs, the second device updates the state of the second port pool based on the aggregate link identifier and the port identifier of each direct port selected by the first device, and then selects idle direct ports that are equal to the number of the first member ports and consistent with the bandwidth of the faulty access port from the second port pool composed of multiple direct ports connected to the first device, and adds all the selected direct ports to the front of the aggregation group corresponding to the access device maintained by itself, and replaces the second hash rule associated with the aggregation group corresponding to the access device with the first hash rule.
[0162] S306: The second device uses the first hash rule and the adjusted aggregation group corresponding to the access device maintained by itself to load balance the traffic from the second device to the access device.
[0163] In the load balancing method provided by the embodiment of the present invention, the first device and the second device periodically synchronize the number of member ports in the aggregation group corresponding to the access device; thus, when the number of two member ports is not equal, the first device will send the first hash rule associated with the aggregation group corresponding to the access device to the second device, so that the second device replaces the second hash rule associated with the aggregation group corresponding to the access device with the received first hash rule, and the first device and the second device each select a directly connected port from their own port pool to join the aggregation group maintained by themselves so that the number of aggregation group ports at both ends is consistent. In this way, based on the first hash rule and the adjusted aggregation group corresponding to the access device respectively included in the first device and the second device, the traffic from the MLAG system to the access device can be load balanced, thereby improving link utilization.
[0164] In order to execute the corresponding steps in the above method embodiment and various possible implementations, two implementations of the load balancing device are given below.
[0165] See also Figure 7 , Figure 7 One of the structural schematic diagrams of the load balancing device provided by an embodiment of the present invention is shown. The load balancing device 200 is applied to a first device of an MLAG system, and the MLAG system also includes a second device that establishes a peer link with the first device; the access device is dual-homed to the MLAG system and the downlink links between the access device and the first device and the second device are not unique. The load balancing device 200 includes: a first synchronization module 210, a first coordination module 220, and a first forwarding module 230.
[0166] The first synchronization module 210 is used to periodically send to the second device the number of first member ports in the aggregation group corresponding to the access device maintained by the first device;
[0167] The first synchronization module 210 is further configured to receive the number of second member ports in the aggregation group corresponding to the access device maintained by the second device, which is periodically sent by the second device;
[0168] The first coordination module 220 is used to send the first hash rule associated with the aggregation group corresponding to the access device to the second device when it is sensed that any access port corresponding to the access device has a fault and the number of second member ports is not equal to the number of first member ports; select idle direct ports that are equal to the number of second member ports and consistent with the bandwidth of the faulty access port from the first port pool composed of multiple direct ports connected to the second device; after sending the port identifier of each selected direct port, the bandwidth of the faulty access port and the aggregate link identifier to which it belongs to the second device, all the selected direct ports are added to the end of the aggregation group corresponding to the access device maintained by the first device;
[0169] The first forwarding module 230 is configured to load balance traffic from the first device to the access device by using the first hash rule and the adjusted aggregation group corresponding to the access device.
[0170] Optionally, the first coordination module 220 can also be used to: when the number of second member ports is equal to the number of first member ports, search whether there is a target direct port belonging to the first port pool in the aggregation group corresponding to the access device maintained by itself; if so, delete each target direct port in the aggregation group corresponding to the access device maintained by itself, and set the state of each target direct port belonging to the first port pool to an idle state.
[0171] Optionally, the first synchronization module 210 can also be used to: obtain a first port pool; for each directly connected port in the obtained first port pool, send out a port identifier of the directly connected port from the directly connected port based on the LLDP protocol, and when the directly connected port receives a port identifier sent by the second device, associate the port identifier of the directly connected port with the received port identifier to obtain a first port mapping table.
[0172] Optionally, the first coordination module 220 can also be used to: determine whether there are idle matching direct ports in the first port pool that are equal to the number of second member ports based on the bandwidth of the faulty access port; if not, determine the number of virtual direct ports to be created based on the number of matching direct ports in the first port pool and the number of second member ports; based on any physical port corresponding to the peer link, create a virtual direct port consistent with the bandwidth of the faulty access port using the FlexE protocol based on the determined number to be created, and send a creation notification to the second device based on the physical port, the number to be created and the bandwidth of the faulty access port; add all created virtual direct ports to the first port pool, and send the port identifiers of each virtual direct port from each virtual direct port based on the LLDP protocol; when the port identifier sent by the second device is received at each virtual direct port, the port identifier of the virtual direct port is associated with the received port identifier and written into the first port mapping table, and the state of each virtual direct port is set to an idle state.
[0173] See also Figure 8 , Figure 8 The second structural diagram of the load balancing device provided by an embodiment of the present invention is shown. The load balancing device 400 is applied to the second device of the MLAG system, and the MLAG system also includes a first device that establishes a peer link with the second device; the access device is dual-homed to the MLAG system and the downlink links between the access device and the first device and the second device are not unique. The load balancing device 400 includes: a second synchronization module 410, a second coordination module 420 and a second forwarding module 230.
[0174] The second synchronization module 410 is used to periodically send to the first device the number of second member ports in the aggregation group corresponding to the access device maintained by the second device;
[0175] The second synchronization module 410 is further configured to receive the number of first member ports in the aggregation group corresponding to the access device maintained by the first device, which is periodically sent by the first device;
[0176] The second coordination module 420 is used to update the state of the second port pool based on the aggregate link identifier and the port identifier of each direct port selected by the first device when the number of the second member ports is not equal to the number of the first member ports and the first hash rule sent by the first device, the port identifier of each direct port selected by the first device, the bandwidth of the faulty access port and the aggregate link identifier to which it belongs are received; select idle direct ports that are equal to the number of the first member ports and consistent with the bandwidth of the faulty access port from the second port pool composed of multiple direct ports connected to the first device, and add all the selected direct ports to the front of the aggregation group corresponding to the access device maintained by itself; replace the second hash rule associated with the aggregation group corresponding to the access device with the first hash rule based on the aggregate link identifier;
[0177] The second forwarding module 230 is used in which each directly connected port in the second port pool is connected to the first device; the first hash rule and the adjusted aggregation group corresponding to the access device are used together to achieve load balancing of traffic forwarding from the second device to the access device.
[0178] Optionally, the second coordination module 420 can also be used to: when the number of second member ports is equal to the number of first member ports, search whether there is a direct port belonging to the second port pool in the aggregation group corresponding to the access device maintained by the second device; if so, delete each direct port in the aggregation group corresponding to the access device maintained by the second device.
[0179] Optionally, the second synchronization module 410 can also be used to obtain a second port pool; for each directly connected port in the obtained second port pool, the port identifier of the directly connected port is sent to the first device based on the LLDP protocol, and when the port identifier sent by the first device is received from the directly connected port, the port identifier of the directly connected port is associated with the received port identifier to obtain a second port mapping table.
[0180] Optionally, the second coordination module 420 can be specifically used to: find out from the second port mapping table the direct port to be updated corresponding to the port identifier of each direct port selected by the first device, and set the state of each direct port to be updated to a busy state; wherein the second port mapping table includes the port identifier of each direct port in the second port pool and the port identifier of the direct port on the first device associated with it; obtain the traffic configuration information of the aggregation group corresponding to the aggregate link identifier, and configure the traffic configuration information to each direct port to be updated
[0181] Optionally, the second coordination module 420 can also be used for: when receiving a creation notification sent by the first device, based on the creation notification, obtaining the port identifier of the physical port of the first device, the number to be created, and the bandwidth of the faulty access port; based on the physical port connected to the physical port of the first device and the number to be created, using the FlexE protocol to create a virtual direct port that is consistent with the bandwidth of the faulty access port; adding all created virtual direct ports to the second port pool, and based on the LLDP protocol, sending out the port identifiers of each virtual direct port from each virtual direct port; when receiving the port identifier sent by the first device at each virtual direct port, associating the port identifier of the virtual direct port with the received port identifier and writing it into the second port mapping table, and setting the state of each virtual direct port to an idle state.
[0182] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the load balancing device 200 described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0183] See also Fig. 9 , Fig. 9 The electronic device 300 includes a processor 310 , a memory 320 , and a bus 330 , wherein the processor 310 is connected to the memory 320 via the bus 330 .
[0184] The memory 320 may be used to store software programs, for example, software programs corresponding to the load balancing device 200 or the load balancing device 400 provided in the embodiment of the present invention. The processor 310 executes various functional applications and data processing to implement the load balancing method provided in the embodiment of the present invention by running the software programs stored in the memory 320.
[0185] Among them, the memory 320 can be but is not limited to: RAM (Random Access Memory), ROM (Read Only Memory), FLASH (Flash Memory), PROM (Programmable Read-Only Memory), EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electric Erasable Programmable Read-Only Memory), etc.
[0186] The processor 310 may be an integrated circuit chip with signal processing capability. The processor 310 may be a general-purpose processor, including: CPU (Central Processing Unit), NP (Network Processor), etc.; it may also be: DSP (Digital Signal Processing), ASIC (Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0187] Understandably, Fig. 9 The structure shown is for illustration only. The electronic device 300 may also include Fig. 9 More or fewer components as shown, or with Fig. 9 Different configurations shown. Fig. 9 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0188] The embodiment of the present invention also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the load balancing method disclosed in the above embodiment is implemented. The computer-readable storage medium can be, but is not limited to, various media that can store program codes, such as a USB flash drive, a mobile hard disk, a ROM, a RAM, a PROM, an EPROM, an EEPROM, a FLASH disk, or an optical disk.
[0189] In summary, the embodiments of the present invention provide a load balancing method, apparatus, electronic device and computer-readable storage medium. The MLAG system includes a first device and a second device system with established peer links; the access device is dual-homed to the MLAG system and the downlink links between the access device and the first device and the second device are not unique. The method is: the devices at both ends periodically synchronize the number of member ports in the aggregation group corresponding to the access device; thus, when the number of two member ports is not equal, the first device sends the first hash rule associated with the aggregation group corresponding to the access device to the second device, so that the second device replaces the second hash rule associated with the aggregation group corresponding to the access device with the received first hash rule, and the first device and the second device each select a directly connected port from their own port pool to join the aggregation group maintained by themselves so that the number of aggregation group ports at both ends is consistent. In this way, both the first device and the second device can load balance the traffic to the access device based on the first hash rule and the respectively adjusted aggregation groups corresponding to the access devices, thereby improving link utilization.
[0190] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. A load balancing method, characterized in that: A first device applied to an MLAG system, the MLAG system further comprising a second device establishing a peer link with the first device; The access device is dual-homed to the MLAG system and the downlink links between the access device and the first device and the second device are not unique; the method includes: Periodically sending to the second device the number of first member ports in the aggregation group corresponding to the access device maintained by itself; receiving the number of second member ports in the aggregation group corresponding to the access device maintained by the second device, which is sent periodically by the second device; When it is sensed that any access port corresponding to the access device fails and the number of the second member ports is not equal to the number of the first member ports, sending the first hash rule associated with the aggregation group corresponding to the access device to the second device; Selecting, from a first port pool consisting of a plurality of direct-connection ports connected to the second device, idle direct-connection ports having an equal number to the second member ports and a bandwidth consistent with that of the faulty access port; After sending the port identifier of each selected direct-connected port, the bandwidth of the faulty access port and the aggregate link identifier to which it belongs to the second device, all the selected direct-connected ports are added to the end of the aggregation group corresponding to the access device maintained by itself; and the traffic from the first device to the access device is load balanced using the first hash rule and the adjusted aggregation group corresponding to the access device.
2. The method according to claim 1, characterized in that After the step of receiving the number of second member ports in the aggregation group corresponding to the access device maintained by the second device and periodically sent by the second device, the method further includes: When the number of the second member ports is equal to the number of the first member ports, searching whether there is a target direct-connected port belonging to the first port pool in the aggregation group corresponding to the access device maintained by itself; If so, each target direct-connected port in the aggregation group corresponding to the access device maintained by the access device is deleted, and the state of each target direct-connected port belonging to the first port pool is set to an idle state.
3. The method according to claim 1, characterized in that Before the step of periodically sending to the second device the number of first member ports in the aggregation group corresponding to the access device maintained by the second device, the method further includes: Obtaining the first port pool; For each directly connected port obtained in the first port pool, the port identifier of the directly connected port is sent from the directly connected port based on the LLDP protocol, and when the directly connected port receives the port identifier sent by the second device, the port identifier of the directly connected port is associated with the received port identifier to obtain a first port mapping table.
4. The method according to claim 1, characterized in that: Before the step of selecting, from a first port pool consisting of a plurality of directly connected ports connected to the second device, idle directly connected ports having an equal number to the second member ports and a bandwidth consistent with that of the failed access port, the method further includes: Based on the bandwidth of the faulty access port, determining whether there are idle matching direct-connected ports in the first port pool that are equal in number to the number of the second member ports; If not, determining the number of virtual direct ports to be created based on the number of matching direct ports in the first port pool and the number of the second member ports; Based on any physical port corresponding to the peer link, create a virtual direct port consistent with the bandwidth of the faulty access port by using the FlexE protocol based on the determined number to be created, and send a creation notification to the second device based on the physical port, the number to be created, and the bandwidth of the faulty access port; Adding all created virtual direct-connected ports to the first port pool, and sending the port identifiers of the respective virtual direct-connected ports from the respective virtual direct-connected ports based on the LLDP protocol; When the port identifier sent by the second device is received at each virtual direct port, the port identifier of the virtual direct port is associated with the received port identifier and written into the first port mapping table, and the state of each virtual direct port is set to an idle state.
5. A load balancing method, characterized in that: A second device applied to an MLAG system, the MLAG system further comprising a first device establishing a peer-to-peer link with the second device; The access device is dual-homed to the MLAG system and the downlink links between the access device and the first device and the second device are not unique; the method includes: Periodically sending to the first device the number of second member ports in the aggregation group corresponding to the access device maintained by itself; receiving the number of first member ports in the aggregation group corresponding to the access device maintained by the first device, which is sent periodically by the first device; When the number of the second member ports is not equal to the number of the first member ports and the first hash rule, the port identifier of each directly connected port selected by the first device, the bandwidth of the faulty access port and the aggregate link identifier to which it belongs are received, updating the state of the second port pool based on the aggregate link identifier and the port identifier of each directly connected port selected by the first device; Selecting idle direct-connected ports of the same number as the first member ports and having the same bandwidth as the faulty access port from a second port pool consisting of a plurality of direct-connected ports connected to the first device, and adding all the selected direct-connected ports to the front of the aggregation group corresponding to the access device maintained by itself; Based on the aggregate link identifier, replacing the second hash rule associated with the aggregation group corresponding to the access device with the first hash rule; The first hash rule and the adjusted aggregation group corresponding to the access device are used to load balance the traffic from the second device to the access device.
6. The method according to claim 5, characterized in that After the step of receiving the first number of member ports in the aggregation group corresponding to the access device maintained by the first device and periodically sent by the first device, the method further includes: When the number of the second member ports is equal to the number of the first member ports, searching whether there is a target direct-connected port belonging to the second port pool in the aggregation group corresponding to the access device maintained by itself; If so, each target direct-connected port in the aggregation group corresponding to the access device maintained by the access device is deleted, and the state of each target direct-connected port belonging to the second port pool is set to an idle state.
7. The method according to claim 5, characterized in that Before the step of periodically sending to the second device the number of first member ports in the aggregation group corresponding to the access device maintained by the second device, the method further includes: Obtain the second port pool; For each directly connected port obtained in the second port pool, the port identifier of the directly connected port is sent to the first device based on the LLDP protocol, and when the port identifier sent by the first device is received from the directly connected port, the port identifier of the directly connected port is associated with the received port identifier to obtain a second port mapping table.
8. The method according to claim 5, characterized in that The step of updating the status of the second port pool based on the aggregate link identifier and the port identifier of each directly connected port selected by the first device includes: From the second port mapping table, find the direct port to be updated corresponding to the port identifier of each direct port selected by the first device, and set the state of each direct port to be updated to a busy state; wherein the second port mapping table includes the port identifier of each direct port in the second port pool and the port identifier of the direct port on the first device associated with it; The flow configuration information of the aggregation group corresponding to the aggregation link identifier is obtained, and the flow configuration information is configured to each of the direct-connected ports to be updated.
9. The method according to claim 5, characterized in that Before receiving the port identifier of each directly connected port selected by the first device, the bandwidth of the faulty access port and the identifier of the aggregated link to which it belongs, the method further includes: When receiving the creation notification sent by the first device, obtaining, based on the creation notification, a port identifier of a physical port of the first device, a quantity to be created, and a bandwidth of the faulty access port; Based on the physical port connected to the physical port of the first device and the number to be created, create a virtual direct port with the same bandwidth as the faulty access port by using the FlexE protocol; Adding all created virtual direct-connected ports to the second port pool, and sending the port identifiers of the respective virtual direct-connected ports from the respective virtual direct-connected ports based on the LLDP protocol; When the port identifier sent by the first device is received at each virtual direct port, the port identifier of the virtual direct port is associated with the received port identifier and written into the second port mapping table, and the state of each virtual direct port is set to an idle state.
10. A load balancing method, characterized in that: Applied to an MLAG system, the MLAG system comprising a first device and a second device having a peer link established therewith; The access device is dual-homed to the MLAG system and the downlink links between the access device and the first device and the second device are not unique; the method includes: The first device periodically sends to the second device the number of first member ports in the aggregation group corresponding to the access device maintained by the first device; The second device periodically sends to the first device the number of second member ports in the aggregation group corresponding to the access device maintained by the second device; When the first device senses that any access port corresponding to the access device fails and the number of the second member ports is not equal to the number of the first member ports, the first device sends the first hash rule associated with the aggregation group corresponding to the access device to the second device, selects idle direct ports that are equal to the number of the second member ports and consistent with the bandwidth of the failed access port from the first port pool composed of multiple direct ports connected to the second device, sends the port identifier of each selected direct port, the bandwidth of the failed access port and the aggregation link identifier to which it belongs to the second device, and then adds all the selected direct ports to the end of the aggregation group corresponding to the access device maintained by itself; The first device performs load balancing on traffic from the first device to the access device by using the first hash rule and the adjusted aggregation group corresponding to the access device maintained by the first device; When the number of the second member ports is not equal to the number of the first member ports and the second device receives the first hash rule sent by the first device, the port identifier of each direct port selected by the first device, the bandwidth of the faulty access port and the aggregate link identifier to which it belongs, the second device updates the state of the second port pool based on the aggregate link identifier and the port identifier of each direct port selected by the first device, and then selects idle direct ports that are equal to the number of the first member ports and consistent with the bandwidth of the faulty access port from the second port pool composed of multiple direct ports connected to the first device, and adds all the selected direct ports to the front of the aggregation group corresponding to the access device maintained by itself, and replaces the second hash rule associated with the aggregation group corresponding to the access device with the first hash rule; The second device uses the first hash rule and the adjusted aggregation group corresponding to the access device maintained by itself to load balance the traffic from the second device to the access device.
11. A load balancing device, characterized in that: A first device applied to an MLAG system, the MLAG system further comprising a second device establishing a peer link with the first device; The access device is dual-homed to the MLAG system, and the downlink links between the access device and the first device and the second device are not unique; the apparatus comprises: A first synchronization module, configured to periodically send to the second device the number of first member ports in the aggregation group corresponding to the access device maintained by the first device; The first synchronization module is further used to receive the number of second member ports in the aggregation group corresponding to the access device maintained by the second device, which is sent regularly by the second device; The first coordination module is used to: When it is sensed that any access port corresponding to the access device fails and the number of the second member ports is not equal to the number of the first member ports, sending the first hash rule associated with the aggregation group corresponding to the access device to the second device; Selecting, from a first port pool consisting of a plurality of direct-connection ports connected to the second device, idle direct-connection ports having an equal number to the second member ports and a bandwidth consistent with that of the faulty access port; After sending the port identifier of each selected direct-connected port, the bandwidth of the faulty access port and the aggregated link identifier to which it belongs to the second device, all the selected direct-connected ports are added to the end of the aggregation group corresponding to the access device maintained by the first device; The first forwarding module is used to load balance the traffic from the first device to the access device by using the first hash rule and the adjusted aggregation group corresponding to the access device.
12. A load balancing device, characterized in that: A second device applied to an MLAG system, the MLAG system further comprising a first device establishing a peer-to-peer link with the second device; The access device is dual-homed to the MLAG system, and the downlink links between the access device and the first device and the second device are not unique; the apparatus comprises: A second synchronization module, configured to periodically send to the first device the number of second member ports in the aggregation group corresponding to the access device maintained by the second device; The second synchronization module is further used to receive the number of first member ports in the aggregation group corresponding to the access device maintained by the first device, which is sent regularly by the first device; The second coordination module is used to: When the number of the second member ports is not equal to the number of the first member ports and a first hash rule, a port identifier of each directly connected port selected by the first device, a bandwidth of the faulty access port and an aggregate link identifier to which the failed access port belongs are received, updating the state of the second port pool based on the aggregate link identifier and the port identifier of each directly connected port selected by the first device; Selecting idle direct-connected ports of the same number as the first member ports and having the same bandwidth as the faulty access port from a second port pool consisting of a plurality of direct-connected ports connected to the first device, and adding all the selected direct-connected ports to the front of the aggregation group corresponding to the access device maintained by itself; Based on the aggregate link identifier, replacing the second hash rule associated with the aggregation group corresponding to the access device with the first hash rule; The second forwarding module is used to load balance the traffic from the second device to the access device by using the first hash rule and the adjusted aggregation group corresponding to the access device.
13. An electronic device, characterized in that: include: A memory and a processor, wherein the memory stores a software program, and when the electronic device is running, the processor executes the software program to implement the load balancing method described in any one of claims 1-4 or the load balancing method described in any one of claims 5-9.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the load balancing method according to any one of claims 1 to 4 or the load balancing method according to any one of claims 5 to 9 is implemented.