Traffic control method, apparatus, device, and storage medium
Patent Information
- Application Number
- CN202611164488.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-03
- Publication Date
- 2026-10-13
AI Technical Summary
[0003]目前,在面对某个端口或链路发生故障的情况时,系统会重新分配ECMP组的下一跳数量,但该过程会导致原本非故障链路上的流量被错误切换至未建立连接的其他服务器,导致流量转发的准确性较低
[0043]上述流量控制方法、装置、计算机设备、计算机可读存储介质和计算机程序产品,通过在目标等价多路径组中的第一下一跳端口发生故障的情况下,获取目标等价多路径组中处于正常状态的第二下一跳端口的端口索引,并根据第二下一跳端口的端口索引,对目标等价多路径组中的第一下一跳端口的端口索引进行更新处理,得到更新后的等价多路径组,基于更新后的等价多路径组,对待转发流量进行转发处理,有利于在端口发生故障时保持原始的等价多路径组不发生改变,仅使用正常端口的索引填补故障端口的索引位置,从而有利于保证非故障端口的流量转发路径不发生变化,避免了因重新分配等价多路径组而导致的流量乱序和连接中断问题,进而提高了流量转发的准确性。
Smart Images

Figure CN122909203A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of network technology, and in particular to a flow control method, apparatus, device, and storage medium. Background Technology
[0002] With the rapid development of data centers, multi-server load balancing, with its advantages of high concurrency and easy scalability, has become an important way to meet the performance requirements of large-scale businesses. Among them, Equal Cost Multipath (ECMP) technology is often used for data forwarding in switches to achieve even distribution of traffic among multiple equal cost links.
[0003] Currently, when a port or link fails, the system will reallocate the number of next hops in the ECMP group. However, this process can cause traffic on non-faulty links to be incorrectly switched to other servers with no established connection, resulting in lower accuracy of traffic forwarding. Summary of the Invention
[0004] Therefore, it is necessary to provide a traffic control method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can improve the accuracy of traffic forwarding in response to the above-mentioned technical problems.
[0005] Firstly, this application provides a flow control method. The method includes:
[0006] If the first next-hop port in the target equivalent multipath group fails, obtain the port index of the second next-hop port in the target equivalent multipath group that is in a normal state.
[0007] Based on the port index of the second next-hop port, the port index of the first next-hop port in the target equivalent multipath group is updated to obtain the updated equivalent multipath group.
[0008] Based on the updated equivalent multipath group, the traffic to be forwarded is forwarded.
[0009] In one embodiment, updating the port index of the first next-hop port in the target equivalent multipath group based on the port index of the second next-hop port to obtain the updated equivalent multipath group includes:
[0010] Determine the target index position corresponding to the first next-hop port in the target equivalent multipath group;
[0011] Replace the port index of the first next-hop port corresponding to the target index position with the port index of the second next-hop port to obtain the updated equivalent multipath group.
[0012] In one embodiment, the number of second next-hop ports is multiple; the target index location includes multiple index sub-locations;
[0013] The step of replacing the port index of the first next-hop port corresponding to the target index position with the port index of the second next-hop port to obtain the updated equivalent multipath group includes:
[0014] For each index sub-position, the port index of the first next-hop port corresponding to the index sub-position is replaced with the port index of a second next-hop port corresponding to the index sub-position, to obtain the updated equivalent multipath group.
[0015] In one embodiment, the target equivalent multipath group includes multiple index positions;
[0016] The method further includes:
[0017] The number of index positions is determined based on the total number of next-hop ports contained in the target equivalent multipath group; each next-hop port corresponds to at least two index positions in the target equivalent multipath group.
[0018] In one embodiment, the forwarding process of the traffic to be forwarded based on the updated equivalent multipath group includes:
[0019] In the updated equivalent multipath group, determine the target forwarding port corresponding to the traffic to be forwarded;
[0020] The traffic to be forwarded is forwarded through the target forwarding port.
[0021] In one embodiment, after obtaining the updated equivalent multipath group, the method further includes:
[0022] If the first next-hop port recovers from a fault state to a normal state, obtain the port index of the first next-hop port;
[0023] Based on the port index of the first next-hop port, the port index of the second next-hop port in the updated equivalent multipath group is restored.
[0024] In one embodiment, the step of restoring the port index of the second next-hop port in the updated equivalent multipath group based on the port index of the first next-hop port includes:
[0025] In the updated equivalent multipath group, the position of the index to be restored that was replaced by the port index of the second next-hop port is determined;
[0026] Replace the port index of the second next-hop port corresponding to the index position to be restored with the port index of the first next-hop port.
[0027] Secondly, this application also provides a flow control device. The device includes:
[0028] The index acquisition module is used to acquire the port index of the second next-hop port in the target equivalent multipath group that is in a normal state when the first next-hop port in the target equivalent multipath group fails.
[0029] The index update module is used to update the port index of the first next-hop port in the target equivalent multipath group according to the port index of the second next-hop port, so as to obtain the updated equivalent multipath group.
[0030] The traffic forwarding module is used to forward traffic based on the updated equivalent multipath group.
[0031] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:
[0032] If the first next-hop port in the target equivalent multipath group fails, obtain the port index of the second next-hop port in the target equivalent multipath group that is in a normal state.
[0033] Based on the port index of the second next-hop port, the port index of the first next-hop port in the target equivalent multipath group is updated to obtain the updated equivalent multipath group.
[0034] Based on the updated equivalent multipath group, the traffic to be forwarded is forwarded.
[0035] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:
[0036] If the first next-hop port in the target equivalent multipath group fails, obtain the port index of the second next-hop port in the target equivalent multipath group that is in a normal state.
[0037] Based on the port index of the second next-hop port, the port index of the first next-hop port in the target equivalent multipath group is updated to obtain the updated equivalent multipath group.
[0038] Based on the updated equivalent multipath group, the traffic to be forwarded is forwarded.
[0039] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:
[0040] If the first next-hop port in the target equivalent multipath group fails, obtain the port index of the second next-hop port in the target equivalent multipath group that is in a normal state.
[0041] Based on the port index of the second next-hop port, the port index of the first next-hop port in the target equivalent multipath group is updated to obtain the updated equivalent multipath group.
[0042] Based on the updated equivalent multipath group, the traffic to be forwarded is forwarded.
[0043] The aforementioned flow control method, apparatus, computer equipment, computer-readable storage medium, and computer program product, by obtaining the port index of the second next-hop port in the target equivalent multipath group when the first next-hop port in the target equivalent multipath group fails, and updating the port index of the first next-hop port in the target equivalent multipath group based on the port index of the second next-hop port, obtains an updated equivalent multipath group. Based on the updated equivalent multipath group, the traffic to be forwarded is forwarded. This helps to maintain the original equivalent multipath group unchanged when a port fails, using only the index of the normal port to fill the index position of the failed port. This ensures that the traffic forwarding path of non-faulty ports remains unchanged, avoiding traffic out-of-order and connection interruption problems caused by the reallocation of equivalent multipath groups, thereby improving the accuracy of traffic forwarding. Attached Figure Description
[0044] To more clearly illustrate the technical solutions in the embodiments or related technologies of this application, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0045] Figure 1 This is a flowchart illustrating a flow control method in one embodiment;
[0046] Figure 2 This is a schematic diagram of a network architecture in one embodiment where a switch connects to multiple servers;
[0047] Figure 3 This is a schematic diagram of hash routing in a normal state in one embodiment;
[0048] Figure 4 This is a schematic diagram of hash routing in one embodiment when a port failure occurs;
[0049] Figure 5 This is a schematic diagram of a structure that maintains the original equivalent multipath group when a port failure occurs in one embodiment.
[0050] Figure 6 This is a schematic diagram of the equivalent multipath group structure after replacing the faulty port index with a single normal port index in one embodiment.
[0051] Figure 7 This is a schematic diagram of the equivalent multipath group structure after expanding the index position and replacing the faulty port index in one embodiment.
[0052] Figure 8 This is a schematic diagram of traffic forwarding under normal circumstances in one embodiment;
[0053] Figure 9 This is a schematic diagram of traffic forwarding under port failure conditions in one embodiment;
[0054] Figure 10 This is a structural block diagram of a flow control device in one embodiment;
[0055] Figure 11 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0056] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0057] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0058] In one exemplary embodiment, such as Figure 1As shown, a flow control method is provided. This embodiment illustrates the application of this method to a switch. It is understood that this method can also be applied to terminals or servers, and can also be applied to systems including terminals and servers, implemented through interaction between the terminals and servers. The terminal can be, but is not limited to, various personal computers, laptops, smartphones, tablets, etc.; the server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. In this embodiment, the method includes the following steps:
[0059] Step S101: If the first next-hop port in the target equivalent multipath group fails, obtain the port index of the second next-hop port in the target equivalent multipath group that is in a normal state.
[0060] Step S102: Based on the port index of the second next-hop port, update the port index of the first next-hop port in the target equivalent multipath group to obtain the updated equivalent multipath group.
[0061] Step S103: Based on the updated equivalent multipath group, forward the traffic to be forwarded.
[0062] The target equivalent multipath group can be a set of ports used for traffic load balancing among multiple paths with the same cost.
[0063] The first next-hop port can be a port in the target equivalent multipath group that has failed or disconnected.
[0064] The second next-hop port can be any port in the target equivalent multipath group that is in normal working order, other than the first next-hop port.
[0065] The port index can be a numbering information used to identify each next-hop port in the target equivalence multipath group.
[0066] The updated equivalent multipath group can be the equivalent multipath group obtained by replacing the port index of the first next-hop port with the port index of the second next-hop port.
[0067] The traffic to be forwarded can be a Transmission Control Protocol (TCP) data stream or other network data packets that need to be forwarded to the destination server by network devices.
[0068] Optionally, when the switch detects a failure in the first next-hop port of the target equal-cost multipath group, it keeps the target equal-cost multipath group from being reallocated and obtains the port index of at least one second next-hop port in the target equal-cost multipath group that is in a normal state; it replaces the port index of the first next-hop port in the target equal-cost multipath group with the port index of the second next-hop port to update the port index of the first next-hop port in the target equal-cost multipath group, thereby obtaining an updated equal-cost multipath group; based on the updated equal-cost multipath group, the traffic that originally needed to be forwarded through the first next-hop port is forwarded through the second next-hop port, and the traffic that originally needed to be forwarded through the second next-hop port continues to be forwarded through the second next-hop port.
[0069] In the aforementioned flow control method, when the first next-hop port in the target equal-cost multipath group fails, the port index of the second next-hop port in the target equal-cost multipath group that is in a normal state is obtained. Based on the port index of the second next-hop port, the port index of the first next-hop port in the target equal-cost multipath group is updated to obtain an updated equal-cost multipath group. Based on the updated equal-cost multipath group, the traffic to be forwarded is forwarded. This method helps to keep the original equal-cost multipath group unchanged when a port fails, and only uses the index of the normal port to fill the index position of the failed port. This helps to ensure that the traffic forwarding path of the non-failed port does not change, avoids the problems of traffic out-of-order and connection interruption caused by the reallocation of equal-cost multipath groups, and thus improves the accuracy of traffic forwarding.
[0070] In an exemplary embodiment, the port index of the first next-hop port in the target equivalent multipath group is updated according to the port index of the second next-hop port to obtain the updated equivalent multipath group. This includes: determining the target index position corresponding to the first next-hop port in the target equivalent multipath group; and replacing the port index of the first next-hop port corresponding to the target index position with the port index of the second next-hop port to obtain the updated equivalent multipath group.
[0071] The target index position can be the number position information of the first next-hop port that was originally assigned to the failed port in the target equivalent multipath group.
[0072] Optionally, the switch determines the target index position corresponding to the first next-hop port in the target equal-cost multipath group, and replaces the port index of the first next-hop port corresponding to the target index position with the port index of the second next-hop port in a normal state to fill the gap of the faulty port and obtain the updated equal-cost multipath group.
[0073] The technical solution provided in this embodiment determines the target index position corresponding to the first next-hop port in the target equivalent multipath group, and replaces the port index of the first next-hop port corresponding to the target index position with the port index of the second next-hop port. This facilitates accurate location of the faulty port in the equivalent multipath group and targeted replacement.
[0074] In an exemplary embodiment, there are multiple second next-hop ports; the target index position includes multiple index sub-positions; replacing the port index of the first next-hop port corresponding to the target index position with the port index of the second next-hop port to obtain an updated equivalent multipath group includes: for each index sub-position, replacing the port index of the first next-hop port corresponding to the index sub-position with the port index of a second next-hop port corresponding to the index sub-position to obtain an updated equivalent multipath group.
[0075] The index sub-location can be multiple specific, independent location units contained in the target index location, used to store port indexes respectively.
[0076] Optionally, when there are multiple second next-hop ports and the target index location includes multiple index sub-locations, the switch replaces the port index of the first next-hop port corresponding to each index sub-location with the port index of a second next-hop port corresponding to that index sub-location, so that multiple second next-hop ports can share the traffic of the first next-hop port and obtain an updated equivalent multipath group.
[0077] The technical solution provided in this embodiment replaces the port index of the first next-hop port corresponding to each index sub-position with the port index of a second next-hop port corresponding to the index sub-position. This helps to evenly distribute the traffic of the faulty port to multiple normally functioning ports, thereby helping to avoid the problem of unbalanced load or full bandwidth due to a single normal port bearing too much traffic.
[0078] In an exemplary embodiment, the target equivalent multipath group contains multiple index positions; the method further includes: determining the number of multiple index positions based on the total number of next-hop ports contained in the target equivalent multipath group; each next-hop port corresponds to at least two index positions in the target equivalent multipath group.
[0079] Among them, multiple index positions can be the complete set of port indexes used to store each next-hop port in the target equivalent multipath group.
[0080] The total number of next-hop ports can be the number of all ports used for forwarding traffic included in the target equivalent multipath group in its initial configuration state.
[0081] Optionally, when the total number of next-hop ports is 4, the number of index positions is determined to be 12, so as to ensure that if any port fails, the remaining ports have enough index positions to evenly fill the gap.
[0082] The technical solution provided in this embodiment is beneficial for providing sufficient location resources for index replacement when a port failure occurs, thereby facilitating the even distribution of traffic among the remaining ports when a port failure occurs.
[0083] In an exemplary embodiment, forwarding traffic to be forwarded is performed based on the updated equivalent multipath group, including: determining the target forwarding port corresponding to the traffic to be forwarded in the updated equivalent multipath group; and forwarding the traffic to be forwarded through the target forwarding port.
[0084] The target forwarding port can be a port selected from the updated equivalent multipath group by using a hash algorithm based on the characteristic information of the traffic to be forwarded, and used to actually send the traffic.
[0085] Optionally, in the updated equal-cost multipath group, the switch performs hash calculation based on the five-tuple information of the source IP address, destination IP address, source port, destination port and protocol number of the traffic to be forwarded, determines the target forwarding port corresponding to the traffic to be forwarded, and sends the traffic to be forwarded to the destination device through the target forwarding port to complete the forwarding process.
[0086] The technical solution provided in this embodiment determines the target forwarding port corresponding to the traffic to be forwarded in the updated equivalent multipath group, and forwards the traffic to be forwarded through the target forwarding port. This helps to ensure that the traffic is accurately delivered according to the updated path rules, thereby helping to ensure the connectivity of network services and the reliability of data transmission.
[0087] In an exemplary embodiment, after obtaining the updated equivalent multipath group, the method further includes: if the first next-hop port recovers from a fault state to a normal state, obtaining the port index of the first next-hop port; and restoring the port index of the second next-hop port in the updated equivalent multipath group based on the port index of the first next-hop port.
[0088] Among them, the fault status can be the working state in which the first next-hop port is unable to forward data due to reasons such as link disconnection or hardware abnormality.
[0089] The normal state can be the working state in which the first next-hop port has recovered from the failure and regained the ability to forward data.
[0090] The restoration process can be the process of revoking the port index of the second next-hop port used for replacement in the updated equivalent multipath group and re-filling the port index of the first next-hop port.
[0091] Optionally, when the first next-hop port recovers from a faulty state to a normal state, the switch obtains the port index of the first next-hop port, and restores the port index of the second next-hop port previously used for replacement in the updated equal-cost multipath group based on the port index of the first next-hop port, so that the recovered first next-hop port can participate in traffic forwarding again.
[0092] The technical solution provided in this embodiment, by obtaining the port index of the first next-hop port after it has recovered to normal status and restoring the updated equivalent multipath group, is conducive to switching traffic back to the recovered port in a timely manner, thereby improving the overall bandwidth utilization.
[0093] In an exemplary embodiment, the process of restoring the port index of the second next-hop port in the updated equivalent multipath group based on the port index of the first next-hop port includes: determining the position of the index to be restored that was replaced by the port index of the second next-hop port in the updated equivalent multipath group; and replacing the port index of the second next-hop port corresponding to the position to be restored with the port index of the first next-hop port.
[0094] The index position to be restored can be the position in the updated equivalent multipath group that originally belonged to the first next-hop port but was replaced by the port index of the second next-hop port during the fault.
[0095] Optionally, in the updated equal-cost multipath group, the switch determines the index position to be restored that was replaced by the port index of the second next-hop port during the fault, and replaces the port index of the second next-hop port corresponding to the index position to be restored with the port index of the first next-hop port to ensure that the traffic of other ports is not affected.
[0096] The technical solution provided in this embodiment determines the position of the index to be restored that has been replaced by the port index of the second next-hop port, and replaces the port index corresponding to that position with the port index of the first next-hop port, which is beneficial for accurate restoration processing.
[0097] The following example illustrates the flow control method provided in this application. This example demonstrates the application of this method to a switch.
[0098] ECMP (Equal-Cost Multi-Path) is a technique used in networks to load balance traffic across multiple paths with the same overhead. In network routing, when multiple links to the same destination network exist, and these links are considered equivalent in terms of metrics (such as bandwidth, latency, and hop count), ECMP can distribute traffic evenly across these paths to fully utilize network resources and improve bandwidth and link utilization.
[0099] Switch: The core device for network connection. Servers access the network through switches and communicate with each other through switches.
[0100] The 5-tuple of an IP (Internet Protocol) packet: The 5-tuple of an IP packet is a combination of five key elements used to identify a network flow in network communication. These five elements are the source IP address, destination IP address, source port, destination port, and protocol number.
[0101] In certain business scenarios, multiple servers are often needed to share the workload in order to meet specifications and performance requirements. These servers share the same external IP address, so remote clients or services only need to access this unified IP address. When the workload cannot be met, additional servers can be added to expand capacity, and the client is unaware of this process.
[0102] However, this type of business faces a technical problem. For example... Figure 2 As shown ( Figure 2The content includes: Servers A, B, C, and D all have the IP address 6.6.6.6; Server E has the IP address 7.7.7.7; Server E is connected to Servers A, B, C, and D via ports 1, 2, 3, and 4 of a switch. Servers A through D provide similar services and all have an external IP address of 6.6.6.6. Routes to 6.6.6.6 on the switch form ECMP equivalent-cost routes. When external access is made to 6.6.6.6, the switch performs hash routing based on the five-tuple of the packet, selecting one of the four next-hops. If Server E accesses a service with IP address 6.6.6.6, and the switch has four servers connected to this address, the switch will randomly assign one server (e.g., Server A). If the connection between Server E and Server A is a TCP (Transmission Control Protocol) session, Server E will continue to expect to access Server A when accessing this service until the connection is actively closed. Even if servers B through D can provide the same service, if traffic from server E is mistakenly forwarded to server B, the traffic will be dropped because server B did not previously establish a TCP connection with server E, resulting in service access failure.
[0103] Normally, if all four links are stable, the switch's ECMP hash algorithm is fixed, and the path selected by the hash for the first packet will also be fixed. However, if one of the four next hops fails (e.g., port 4 is down), there are only three next-hop paths left to 6.6.6.6. ECMP packets will be redistributed, and the ECMP hash routing will change. Originally, server E accessed the 6.6.6.6 service through server A. However, due to a port failure between the switch and server D, the service traffic might be switched to server B. At this point, because server E has established a TCP connection with server A but not with server B, the service connection will fail, severely impacting the service.
[0104] This embodiment relates to the fields of physical network and data center network technology. The purpose of this embodiment is to address the problem that when a switch is performing load balancing for data forwarding and carrying connection-oriented traffic such as TCP, a port failure can cause a change in the ECMP next hop, leading to all traffic in the entire ECMP group entering an unexpected destination device, ultimately resulting in TCP connection interruption and network service failure. This design proposes a method to maintain the original ECMP group: when a next hop is lost, an available next hop is used to fill the faulty location, thus ensuring that currently forwarded traffic continues its original forwarding path, while traffic that previously traveled through the faulty port travels through the newly filled port. In short, when the ECMP routing next hop changes, the ECMP group is not reassigned; instead, the original ECMP group is used, and the lost next hop in the original ECMP group is replaced with another normal next hop, thereby ensuring that traffic on non-faulty ports remains unchanged and that TCP connections are not interrupted.
[0105] Traditional ECMP process description:
[0106] like Figure 3 As shown ( Figure 3 The content includes: hash algorithms, ECMP groups, and four member routing exits (ports 1, 2, 3, and 4), demonstrating the traditional ECMP hash routing method on a switch. The ECMP group front-end is a hash calculator, and the back-end consists of multiple member routing exits. After a packet enters the ECMP group, the packet's five-tuple is hashed using an algorithm to obtain a routing value (e.g., 1). Port 1 of the four member groups is then selected, and the packet is sent out from port 1. For the same ECMP group, traffic with a fixed five-tuple will always be sent out from the same port.
[0107] like Figure 4 As shown ( Figure 4 The content includes: hash algorithm, ECMP group, and three member routing exits (port 1, port 2, and port 3). When one port fails, the route updates the ECMP group, and the newly requested ECMP group has three member ports. At this time, the hash algorithm itself remains unchanged, but because the ECMP group is reset, the number of ports involved in the calculation decreases, resulting in a completely different hash result compared to when there were four ports. Packets that originally went through port 1 might be assigned to port 2, and packets that originally went through port 4 might be forwarded to port 3, leading to out-of-order hashes.
[0108] This embodiment's solution:
[0109] To address the hash out-of-order issue, this embodiment proposes a novel solution: when the next hop of a routing ECMP group is disconnected, the original ECMP group structure is maintained, and a valid next hop is used to fill the disconnected port position. This ensures that traffic on other normal ports remains unchanged, while traffic on the disconnected port is routed to the newly filled port position. The specific solution is as follows:
[0110] like Figure 5 As shown ( Figure 5 The content includes: hash algorithm, ports 1, 2, and 3, and port 4 which is in a disconnected / faulty state. Assuming that the original ECMP group has four member ports, when port 4 is disconnected, if the original ECMP group is kept unchanged, traffic going through port 4 will be lost because the port has been closed.
[0111] like Figure 6 As shown ( Figure 6 The content includes: hash algorithm, ports 1, 2, and 3). At this point, the index of port 1 (or the index of another normal port) in the ECMP group is placed in the position of port 4. The ECMP group to which the route points remains unchanged, but the fourth position in the ECMP group is filled with the index of port 1. Thus, traffic that originally went through port 4 is redirected to port 1. However, this will cause a load imbalance problem: port 1 carries two-quarters of the traffic in the ECMP group. When traffic is high, it may saturate the bandwidth of port 1, while ports 2 and 3 still have idle bandwidth.
[0112] like Figure 7 As shown ( Figure 7 The content includes: a hash algorithm, and the indexes of 12 next-hop ports; after port 4 fails, its occupied position is filled by the indices of port 1, port 2, and port 3 respectively. The solution to the load imbalance problem is to ensure a balanced number of ports within the ECMP group. If a port in the ECMP group fails, to achieve load balancing on the remaining ports, all the remaining healthy ports need to be replaced. Obviously, simply replacing one port position is insufficient. If the initial number of ports in the ECMP group is 4, then the ECMP group needs at least 4 × 3 = 12 index positions to meet the load balancing requirements. The indices of 4 ports are repeatedly placed among the 12 next-hop port indices. When a port (such as port 4) fails, the indices of the remaining three ports (port 1, port 2, and port 3) are filled into the position occupied by the failed port, thus ensuring that the traffic from the failed port is evenly hashed to the remaining 3 ports.
[0113] When other ports fail or disconnect, the filling scheme continues to use other working ports to fill the vacated ECMP slots and handle the corresponding traffic. In extreme cases, if only one port remains, then N×(N-1) next-hop indices will all point to this single port, where N represents the number of ports (next-hop ports), for example, 4.
[0114] In this embodiment:
[0115] Keep the ECMP group fixed: The ECMP group pointed to by the route remains unchanged. When a port in the route is disconnected, the original ECMP group is still used instead of reapplying for an ECMP group.
[0116] Fault bit index filling: When a port is disconnected, the index of the faulty port in the ECMP group is filled with the index of other normal ports in the ECMP group to ensure the consistency of hashes of other ports.
[0117] Index restoration after recovery: After the faulty port is restored, the corresponding position in the ECMP group is refilled with the restored port index to ensure that traffic is smoothly switched back to the restored port without affecting the traffic of the original normal port.
[0118] Index bit count setting: The number of port index bits in the ECMP group is determined by the number of next hops in the initial ECMP group. If there are N next hops, the number of ECMP index bits is configured as N×(N-1). When N is greater than 10, a fixed 128 index bits are used (generally, in this type of load balancing scenario, the number of ECMP next hops is usually within 8).
[0119] Specific implementation scenarios:
[0120] This solution is primarily used in scenarios involving equal-cost load balancing forwarding on switches. It is commonly employed when multiple servers share the same IP address to access the switch, thereby achieving load balancing of server processing capacity. The switch connects servers with the same IP address through multiple ports, forming equal-cost routes.
[0121] On the switch, the routing software needs to handle ECMP scenarios specially when issuing underlying hardware table entries. If the equal-cost next-hop retention capability is enabled, ECMP group information and next-hop information must be recorded when issuing routing tables. When a next-hop failure occurs, the ECMP group index is updated based on the recorded information, and the update method strictly follows the above-described filling scheme.
[0122] Beneficial effects:
[0123] This technical solution leverages existing hardware capabilities and achieves data forwarding equivalence consistency with fewer ECMP next-hop index resources. This significantly enhances the stability of equivalence load balancing on the switch and provides strong support for maintaining server connectivity.
[0124] like Figure 8 and Figure 9 As shown ( Figure 8 and Figure 9 The content includes: traffic distribution under normal conditions, server E accessing servers A, B, C, and D; and traffic distribution after port 4 is disconnected. The traffic from port 1 to port 3 remains unchanged, and the traffic from port 4 is evenly distributed across ports 1, 2, and 3. When port 4 fails or is disconnected, the traffic path from port 1 to port 3 remains unchanged, while the traffic from port 4 is evenly distributed across ports 1 to 3. When port 4 recovers, the system returns to normal, and the traffic from port 1 to port 3 remains consistent, ensuring the consistency of traffic forwarding and the continuity of services.
[0125] The technical solution provided in this embodiment effectively achieves the ability to maintain consistency in equivalent load balancing, provides support for multi-server load balancing in cloud services, ensures service performance, and has significant advantages compared to switches that cannot perform load balancing consistency.
[0126] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0127] Based on the same inventive concept, this application also provides a flow control device for implementing the flow control method described above. The solution provided by this device is similar to the implementation described in the above method; therefore, the specific limitations in one or more flow control device embodiments provided below can be found in the limitations of the flow control method described above, and will not be repeated here.
[0128] In one exemplary embodiment, such as Figure 10As shown, a flow control device 1000 is provided, which may include:
[0129] The index acquisition module 1001 is used to acquire the port index of the second next-hop port in the target equivalent multipath group that is in a normal state when the first next-hop port in the target equivalent multipath group fails.
[0130] The index update module 1002 is used to update the port index of the first next-hop port in the target equivalent multipath group according to the port index of the second next-hop port, so as to obtain the updated equivalent multipath group.
[0131] The traffic forwarding module 1003 is used to forward traffic based on the updated equivalent multipath group.
[0132] In an exemplary embodiment, the index update module 1002 is further configured to determine the target index position corresponding to the first next-hop port in the target equivalent multipath group; replace the port index of the first next-hop port corresponding to the target index position with the port index of the second next-hop port to obtain the updated equivalent multipath group.
[0133] In an exemplary embodiment, there are multiple second next-hop ports; the target index position includes multiple index sub-positions; the index update module 1002 is further configured to replace the port index of the first next-hop port corresponding to the index sub-position with the port index of a second next-hop port corresponding to the index sub-position for each index sub-position, so as to obtain an updated equivalent multipath group.
[0134] In an exemplary embodiment, the target equivalent multipath group contains multiple index positions; the device 1000 further includes: a quantity determination module, configured to determine the number of multiple index positions based on the total number of next-hop ports contained in the target equivalent multipath group; each next-hop port corresponds to at least two index positions in the target equivalent multipath group.
[0135] In an exemplary embodiment, the traffic forwarding module 1003 is further configured to determine the target forwarding port corresponding to the traffic to be forwarded in the updated equivalent multipath group; and to forward the traffic to be forwarded through the target forwarding port.
[0136] In an exemplary embodiment, the device 1000 further includes: an index restoration module, configured to obtain the port index of the first next-hop port when the first next-hop port recovers from a fault state to a normal state; and restore the port index of the second next-hop port in the updated equivalent multipath group based on the port index of the first next-hop port.
[0137] In an exemplary embodiment, the index restoration module is further configured to determine, in the updated equivalent multipath group, the index position to be restored that has been replaced by the port index of the second next-hop port; and replace the port index of the second next-hop port corresponding to the index position to be restored with the port index of the first next-hop port.
[0138] Each module in the aforementioned flow control device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0139] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 11 As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a flow control method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0140] Those skilled in the art will understand that Figure 11 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0141] In one exemplary embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.
[0142] In one exemplary embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above-described method embodiments.
[0143] In one exemplary embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.
[0144] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0145] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0146] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A flow control method, characterized in that, The method includes: If the first next-hop port in the target equivalent multipath group fails, obtain the port index of the second next-hop port in the target equivalent multipath group that is in a normal state; Based on the port index of the second next-hop port, the port index of the first next-hop port in the target equivalent multipath group is updated to obtain the updated equivalent multipath group. Based on the updated equivalent multipath group, the traffic to be forwarded is forwarded.
2. The method according to claim 1, characterized in that, The step of updating the port index of the first next-hop port in the target equivalent multipath group based on the port index of the second next-hop port to obtain the updated equivalent multipath group includes: Determine the target index position corresponding to the first next-hop port in the target equivalent multipath group; Replace the port index of the first next-hop port corresponding to the target index position with the port index of the second next-hop port to obtain the updated equivalent multipath group.
3. The method according to claim 2, characterized in that, The number of second next-hop ports is multiple; the target index position includes multiple index sub-positions; The step of replacing the port index of the first next-hop port corresponding to the target index position with the port index of the second next-hop port to obtain the updated equivalent multipath group includes: For each index sub-position, the port index of the first next-hop port corresponding to the index sub-position is replaced with the port index of a second next-hop port corresponding to the index sub-position, to obtain the updated equivalent multipath group.
4. The method according to any one of claims 1 to 3, characterized in that, The target equivalent multipath group contains multiple index positions; The method further includes: The number of index positions is determined based on the total number of next-hop ports contained in the target equivalent multipath group; each next-hop port corresponds to at least two index positions in the target equivalent multipath group.
5. The method according to claim 1, characterized in that, The forwarding process based on the updated equivalent multipath group includes: In the updated equivalent multipath group, determine the target forwarding port corresponding to the traffic to be forwarded; The traffic to be forwarded is forwarded through the target forwarding port.
6. The method according to claim 1, characterized in that, After obtaining the updated equivalent multipath group, it also includes: If the first next-hop port recovers from a fault state to a normal state, obtain the port index of the first next-hop port; Based on the port index of the first next-hop port, the port index of the second next-hop port in the updated equivalent multipath group is restored.
7. The method according to claim 6, characterized in that, The step of restoring the port index of the second next-hop port in the updated equivalent multipath group based on the port index of the first next-hop port includes: In the updated equivalent multipath group, the position of the index to be restored that was replaced by the port index of the second next-hop port is determined; Replace the port index of the second next-hop port corresponding to the index position to be restored with the port index of the first next-hop port.
8. A flow control device, characterized in that, The device includes: The index acquisition module is used to acquire the port index of the second next-hop port in the target equivalent multipath group that is in a normal state when the first next-hop port in the target equivalent multipath group fails. The index update module is used to update the port index of the first next-hop port in the target equivalent multipath group according to the port index of the second next-hop port, so as to obtain the updated equivalent multipath group. The traffic forwarding module is used to forward traffic based on the updated equivalent multipath group.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.