Port switching method and device

By setting up a first and second waterline, dynamically updating the port group, and combining PFC backpressure frames and chip table timestamps, the problem of reduced communication quality under high data flow concurrency was solved, achieving uniform forwarding and efficient communication of the data flow.

CN121728026APending Publication Date: 2026-03-24HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-23
Publication Date
2026-03-24

AI Technical Summary

Technical Problem

In scenarios with high data flow concurrency, existing adaptive routing technology cannot trigger port replacement in a timely manner, resulting in reduced communication quality.

Method used

By setting up a first and second waterline and dynamically updating the port group, we ensure that data flows are forwarded preferentially through the first port group, avoiding congestion caused by data flows being concentrated on fixed ports. We adopt a combination forwarding strategy of shortest path and non-shortest path ports, and use PFC backpressure frames and slice table timestamps to switch data flows.

Benefits of technology

This enables data streams to be evenly distributed and forwarded across multiple ports, avoiding increased congestion, improving communication quality and bandwidth utilization, and ensuring the accuracy and efficiency of data transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121728026A_ABST
    Figure CN121728026A_ABST
Patent Text Reader

Abstract

The invention provides a port switching method and device, and relates to the technical field of communication. The method comprises the following steps: determining that the queue depth of a first port in a first port group is greater than or equal to a first waterline; updating a first port in the first port group to a second port in the second port group; the first waterline is smaller than the second waterline, and the second waterline is used for indicating that the data stream in the port is switched to other ports for forwarding; compared with the second port group, the data flow is preferentially forwarded through the first port group. Therefore, the first waterline is smaller than the second waterline, so that the port receiving the data stream can be quickly swapped out of the first port group, the subsequently arrived data stream can be allocated to the newly swapped port in the first port group to be forwarded, and the condition that the subsequently arrived data stream is concentrated on one or more fixed ports, so that the ports are quickly congested is avoided. Therefore, the data stream is relatively uniformly dispersed and forwarded by all ports in the first port group and the second port group, and congestion caused by data stream accumulation is prevented, so that the communication quality is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communication technology, and in particular to a port switching method and apparatus. Background Technology

[0002] Adaptive routing is a technique that makes dynamic routing decisions based on changes in network topology and traffic load. When a data flow arrives, adaptive routing selects a port from multiple preferred path ports to forward it. If the queue depth of any of the preferred path ports reaches the congestion waterline, a new port is used to replace the congested port.

[0003] However, when applying adaptive routing technology in scenarios with high data flow concurrency, if the initial arrival packets of multiple data flows at a port are few, they may not reach the congestion waterline in the adaptive routing technology to trigger the aforementioned port replacement. Multiple data flows will converge on multiple preferred path ports, and when a large number of subsequent data flows arrive, these preferred path ports will quickly become congested, leading to a decrease in communication quality. Summary of the Invention

[0004] This application provides a port switching method and apparatus to solve the problem that current adaptive routing technology cannot be applied to scenarios with high data flow concurrency, resulting in reduced communication quality.

[0005] In a first aspect, a port switching method is provided, the method comprising: determining that the queue depth of a first port in a first port group is greater than or equal to a first waterline; updating the first port in the first port group to a second port in a second port group; wherein the first waterline is less than the second waterline, and the second waterline is used to indicate switching the data flow in the port to other ports for forwarding; wherein, compared with the second port group, the data flow is preferentially forwarded through the first port group.

[0006] The execution entity of this port switching method can be a communication device, such as a router, switch, gateway, or a switching chip, network card, or other device with switching functionality. The first waterline can be called the port switching waterline, and the second waterline can be called the congestion waterline.

[0007] Based on the port switching method described above, the first waterline is smaller than the second waterline, allowing the port receiving the data stream to be quickly switched out of the first port group. This enables subsequent data streams to be distributed to newly switched-in ports within the first port group for forwarding, preventing subsequent data streams from concentrating on one or more fixed ports and causing rapid congestion on those ports. In this way, the data stream is relatively evenly distributed and forwarded across all ports in both the first and second port groups, preventing data stream accumulation from exacerbating congestion and thus improving communication quality.

[0008] In conjunction with the port switching method provided in the first aspect, as one possible implementation, the second port group includes at least one shortest path port and at least one non-shortest path port. In the process of this port switching method, before updating the first port in the first port group to the second port in the second port group, the method further includes: determining the second port from the second port group based on the port's queue depth and whether the port is a shortest path port.

[0009] Optionally, the selection order of the second ports from the second port group is arranged in the following order: the shortest path port with a queue depth less than the first waterline, the non-shortest path port with a queue depth less than the first waterline, the shortest path port with a queue depth greater than or equal to the first waterline and less than the second waterline, the non-shortest path port with a queue depth greater than or equal to the first waterline and less than the second waterline, the shortest path port with a queue depth greater than or equal to the second waterline, and the non-shortest path port with a queue depth greater than or equal to the second waterline.

[0010] Based on the above implementation, taking the first and second waterlines as a benchmark, ports with better data transmission quality are selected from the second port group and switched to the first port group according to the port queue depth and whether the port is the shortest path port. This ensures the efficiency of subsequent data streams being forwarded through the ports in the first port group.

[0011] In conjunction with the port switching method provided in the first aspect, as a possible implementation, the port switching method further includes the following steps: if the queue depth of the third port is greater than or equal to the second waterline, the first data stream in the third port is switched to the fourth port for forwarding, where the third port belongs to either the first port group or the second port group. After switching the first data stream in the third port to the fourth port for forwarding, a priority-based flow control (PFC) backpressure frame is sent.

[0012] Based on the above implementation, after the first data stream in the third port is switched to the fourth port for forwarding, a PFC backpressure frame is sent to cause the upstream to suspend data stream transmission, ensuring that data packets will not be out of order after the flow switch, thus improving the accuracy of data transmission.

[0013] In conjunction with the port switching method provided in the first aspect, as a possible implementation, the process of this port switching method includes, before switching the first data stream in the third port to the fourth port, obtaining the timestamp of at least one data stream in the flowlet table of the third port; and determining, based on the order of the timestamps, that the first data stream is not the latest data stream to arrive at the third port.

[0014] Optionally, the flowlet table of the third port is sorted according to the order of timestamps, and the data stream of the third port with a queue depth greater than or equal to the second waterline is periodically sampled. If the first data stream obtained by sampling is not the latest to arrive at the third port according to the sorting, the first data stream is switched to the fourth port. If the first data stream is the latest to arrive at the third port according to the sorting, the first data stream is not switched to the fourth port.

[0015] Based on the above implementation method, when switching traffic to a port whose queue depth is greater than or equal to the second waterline (i.e., in a congested state), all data streams of that port are switched to other ports. This achieves flow control for the port that needs to be switched, prevents resource waste caused by the port's entire bandwidth being idle after switching, and improves bandwidth utilization.

[0016] In conjunction with the port switching method provided in the first aspect, as a possible implementation, the port switching method further includes: receiving a second data stream; if the second data stream has been forwarded through a non-shortest path port, determining a port for forwarding the second data stream from the shortest path ports in the first port group; if the second data stream has not been forwarded through a non-shortest path port, determining a port for forwarding the second data stream from the first port group.

[0017] Based on the above implementation, data streams that have already been forwarded through non-shortest path ports cannot be forwarded through non-shortest path ports again, thus avoiding the formation of loops in the data stream transmission path.

[0018] In conjunction with the port switching method provided in the first aspect, as a possible implementation, the data streams in the first port group and the second port group mentioned above are artificial intelligence (AI) data streams.

[0019] In conjunction with the port switching method provided in the first aspect, as one possible implementation, this port switching method can be applied to mesh networks, torus networks, or dragonfly networks.

[0020] Secondly, a port switching device is provided, comprising a waterline identification module and a port switching-out module. The waterline identification module is used to determine that the queue depth of a first port in a first port group is greater than or equal to a first waterline. The port switching-out module is used to update the first port in the first port group to a second port in a second port group; the first waterline is less than the second waterline, and the second waterline is used to indicate that the data flow in the port is switched to other ports for forwarding. Specifically, compared to the second port group, the data flow is preferentially forwarded through the first port group.

[0021] In conjunction with the port switching device provided in the second aspect, as one possible implementation, the second port group includes at least one shortest path port and at least one non-shortest path port, and the port switching module is further configured to: determine the second port from the second port group based on the port queue depth and whether the port is the shortest path port.

[0022] In conjunction with the port switching device provided in the second aspect, as a possible implementation, the port switching module is specifically used to: determine the second port from the second port group according to the queue depth of the port and whether the port is the shortest path port, in the following filtering order: the shortest path port with a queue depth less than the first waterline, the non-shortest path port with a queue depth less than the first waterline, the shortest path port with a queue depth greater than or equal to the first waterline and less than the second waterline, the non-shortest path port with a queue depth greater than or equal to the first waterline and less than the second waterline, the shortest path port with a queue depth greater than or equal to the second waterline, and the non-shortest path port with a queue depth greater than or equal to the second waterline.

[0023] In conjunction with the port switching device provided in the second aspect, as a possible implementation, the device further includes: a port flow switching module, used to switch the first data stream in the third port to the fourth port for forwarding if the queue depth of the third port is greater than or equal to the second waterline; the third port belongs to the first port group or the second port group; after switching the first data stream in the third port to the fourth port for forwarding, a priority flow control (PFC) backpressure frame is sent.

[0024] In conjunction with the port switching device provided in the second aspect, as a possible implementation, the port flow switching module is also used to: obtain the timestamp of at least one data stream in the flowlet table of the third port; and determine, based on the order of the timestamps, that the first data stream is not the latest data stream to arrive at the third port among at least one data streams.

[0025] In conjunction with the port switching device provided in the second aspect, as one possible implementation, the device further includes: a stream forwarding module, used to receive the second data stream; if the second data stream has been forwarded through a non-shortest path port, determining a port for forwarding the second data stream from the shortest path ports in the first port group; if the second data stream has not been forwarded through a non-shortest path port, determining a port for forwarding the second data stream from the first port group.

[0026] In conjunction with the port switching device provided in the second aspect, as one possible implementation, the data streams in the first port group and the second port group are AI data streams.

[0027] In conjunction with the port switching device provided in the second aspect, as one possible implementation, the method can be applied to mesh networks, torus networks, or dragonfly networks.

[0028] As one possible implementation, the port switching device described above may also include other modules that perform the operational steps of the port switching method described in the first aspect.

[0029] As one possible implementation, the beneficial effects of the port switching device provided in the second aspect can be referred to the description in the port switching method provided in the first aspect, and will not be repeated here.

[0030] Thirdly, a communication device is provided, comprising a processor and a memory, the processor being configured to execute instructions stored in the memory to cause the communication device to perform the port switching method described in any possible implementation of the first aspect above.

[0031] Fourthly, a chip is provided, including a processor for retrieving and executing instructions stored in a memory, such that a communication device on which the chip is installed performs the port switching method described in any possible implementation of the first aspect above.

[0032] Fifthly, another chip is provided, comprising: an input interface, an output interface, a processor, and a memory, wherein the input interface, the output interface, the processor, and the memory are connected via an internal connection path, and the processor is used to execute code in the memory. When the code is executed, the processor is used to execute the port switching method described in any possible implementation of the first aspect above.

[0033] In a sixth aspect, a network system is provided, comprising multiple network devices and multiple servers, wherein the multiple servers are interconnected through the multiple network devices, and the multiple network devices include the communication device described in the third aspect above.

[0034] In a seventh aspect, a computer program (product) is provided, the computer program (product) comprising: computer program code, which, when executed by a computer or communication device, causes the computer or communication device to perform the port switching method described in any possible implementation of the first aspect.

[0035] Eighthly, a computer-readable storage medium is provided, the storage medium storing at least one instruction, the instruction being loaded and executed by a processor to implement the port switching method described in any possible implementation of the first aspect above. Attached Figure Description

[0036] Figure 1 A schematic diagram of the structure of a network system provided in this application;

[0037] Figure 2A flowchart illustrating a port switching method provided in this application;

[0038] Figure 3 A schematic diagram of the waterline position provided in this application;

[0039] Figure 4 A schematic diagram illustrating a screening order provided for this application;

[0040] Figure 5 A schematic diagram illustrating the initial state of a data stream arriving at a communication device, as provided in this application;

[0041] Figure 6 A schematic diagram illustrating the state of a first port group after port switching, as provided in this application;

[0042] Figure 7 A schematic diagram illustrating the state of subsequent data stream arrival at the communication device provided in this application;

[0043] Figure 8 A schematic diagram illustrating a uniform data stream distribution state provided in this application;

[0044] Figure 9 A flowchart illustrating a data stream switching step provided in this application;

[0045] Figure 10 A flowchart illustrating a data stream forwarding step provided in this application;

[0046] Figure 11 A schematic diagram of a port switching device provided in this application;

[0047] Figure 12 This is a schematic diagram of the structure of a communication device provided in this application. Detailed Implementation

[0048] This application provides a port switching method, which can be executed by a communication device. In the port switching method, the communication device determines that the queue depth of a first port in a first port group is greater than or equal to a first watermark, and updates the first port in the first port group to a second port in a second port group. The first watermark is less than the second watermark, and the second watermark indicates that the data flow in the port should be switched to another port for forwarding. Compared to the second port group, the data flow is preferentially forwarded through the first port group.

[0049] Based on the port switching method described above, the first waterline is smaller than the second waterline, allowing the port receiving the data stream to be quickly switched out of the first port group. This enables subsequent data streams to be distributed to newly switched-in ports within the first port group for forwarding, preventing subsequent data streams from concentrating on one or more fixed ports and causing rapid congestion on those ports. In this way, the data stream is relatively evenly distributed and forwarded across all ports in both the first and second port groups, preventing data stream accumulation from exacerbating congestion and thus improving communication quality.

[0050] The technical solutions involved in this application may be applied not only to current communication technologies or communication devices, but also to future communication technologies or communication devices, or to communication systems and network systems that include communication devices. The terminology used in the embodiments section of this application is only for explaining specific embodiments of this application and is not intended to limit this application. A brief introduction to some concepts that may be involved in this application is given below.

[0051] A flowlet is also called a small stream. A flowlet is a group of smaller streams that are divided into at regular time intervals. A flow is a set of data packets with the same characteristic fields.

[0052] Multipath routing, also known as multipath selection, refers to forwarding data with the same source and destination addresses through multiple forwarding paths.

[0053] Queue depth refers to the amount of data packets, messages, or requests waiting to be processed in various fields such as computer network interfaces, message passing middleware, and performance testing. For example, it can be the number of input / output (I / O) requests waiting to be served in the queue of a communication device's port, or the size of data packets waiting to be forwarded in the port's queue.

[0054] Congestion refers to a phenomenon in network communication where the number of data packets (such as data packets and messages) arriving at a certain part of the communication subnet is too large, causing that part of the network to be unable to process them, thus leading to a decline in network performance.

[0055] To make the objectives, technical solutions, and advantages of this application clearer, the application will now be described in further detail with reference to the accompanying drawings.

[0056] In the following description, the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined with "first," "second," etc., may explicitly or implicitly include one or more of that feature. In the description of this application, unless otherwise stated, "a plurality of" means two or more.

[0057] Furthermore, in this application, directional terms such as "upper" and "lower" are defined relative to the orientation of the components shown in the accompanying drawings. It should be understood that these directional terms are relative concepts, used for relative description and clarification, and can change accordingly depending on the orientation of the components in the accompanying drawings.

[0058] Current adaptive routing technology, when a data flow arrives (e.g., a switch receives a packet), determines the corresponding flowlet table based on the packet's flow identifier. If a corresponding flowlet table exists and has not expired, the switch forwards the packet to the port corresponding to that flowlet table. If a corresponding flowlet table exists but has expired, or if no corresponding flowlet table exists, a port is randomly selected from the best path, a new flowlet table is created, and packets are forwarded to the port corresponding to the newly created flowlet table. However, in scenarios with high data flow concurrency, when multiple data flows arrive at the switch with relatively few packets, these small numbers of packets may not trigger the port's congestion waterline to refresh the best path. These data flows will concentrate on the port corresponding to the best path. When a large number of subsequent packets arrive, the port corresponding to the best path will quickly become congested, while other ports not yet switched to the best path remain idle, leading to a decrease in communication quality.

[0059] To address the aforementioned issues, the application scenarios of the embodiments of this application will be described below with reference to the accompanying drawings.

[0060] Figure 1 This application provides a schematic diagram of a network system structure. This network system can belong to a data center network topology, an interconnection between multiple data centers, or a wide area network (WAN). The service scenarios of the network system can be high-performance service scenarios such as distributed machine learning training, distributed storage, high-performance computing, and containerization. The communication protocol of the network system can be remote direct memory access (RDMA) protocol, transmission control protocol (TCP), such as Infiniband and RoCEv2 (RDMA over Converged Ethernet version 2) RDMA protocols.

[0061] For example, taking a dragonfly network topology as an example, the network system 100 may include multiple groups, each group including multiple computing nodes and multiple network nodes. The computing nodes in each group establish a full-mesh relationship through multiple network nodes within the group. The computing nodes in different groups establish a full-mesh relationship through the network nodes interconnected between groups. That is, each pair of groups is connected by one or more links, and each network node within a group is directly interconnected with other network nodes within the group and can be connected to other groups and computing nodes simultaneously.

[0062] Compute nodes are used to support high-performance services with different communication requirements, such as AI training, AI inference, and storage. Figure 1 As shown, network system 100 includes multiple groups ( Figure 1 Only groups 101, 102, and 103 are shown in the image, but the model is not limited to these three groups. Each group includes one or more computing nodes. Figure 1 (Only four compute nodes are shown, but not limited to four compute nodes). For example, group 101 includes compute nodes 104-107, group 102 includes compute nodes 108-111, and group 103 includes compute nodes 112-115.

[0063] The computing node in this application can be a server, or a processor in the server (such as a neural network processing unit (NPU), central processing unit (CPU), graphics processing unit (GPU), etc.).

[0064] Network nodes are used to enable data exchange between computing nodes. For example... Figure 1 As shown, each group in network system 100 includes multiple network nodes. Figure 1 Each group shows only 4 network nodes, but is not limited to 4 network nodes. For example, group 101 includes network nodes 116-119, group 102 includes network nodes 120-123, and group 103 includes network nodes 124-127.

[0065] The connection methods of each node in network system 100 are illustrated below. For example, computing nodes 104 and 105 are communicatively connected to network node 116, computing nodes 106 and 107 are communicatively connected to network node 117, network node 116 is communicatively connected to network nodes 118 and 119, and network node 117 is communicatively connected to network nodes 118 and 119. Computing nodes 108 and 109 are communicatively connected to network node 120, computing nodes 110 and 111 are communicatively connected to network node 121, network node 120 is communicatively connected to network nodes 122 and 123, and network node 121 is communicatively connected to network nodes 122 and 123. Computing nodes 112 and 113 are communicatively connected to network node 124, respectively; computing nodes 114 and 115 are communicatively connected to network node 125, respectively; network node 124 is communicatively connected to network nodes 126 and 127, respectively; and network node 125 is communicatively connected to network nodes 126 and 127, respectively. Network node 118 is communicatively connected to network nodes 123 and 127, respectively; network node 119 is communicatively connected to network nodes 122 and 126, respectively; network node 122 is also communicatively connected to network node 126; and network node 123 is also communicatively connected to network node 127.

[0066] In addition to basic capabilities such as generating / sending / processing announcement messages, modifying message fields, and adjusting the path of each packet, the network nodes in this application also have functions such as flowlet table records, port group records, port congestion reporting mechanisms, packet sampling, port flow statistics, and congestion information recording.

[0067] The flowlet table records the mapping from the data flow described by the 5-tuple to the forwarding port, and records the latest arrival time of the data flow. The port group record can be the port corresponding to the bestpath, indicating the optimal path for forwarding the data flow. The port congestion reporting mechanism periodically refreshes and uploads information such as the port's queue depth. Packet sampling samples packets in the port and uploads them. Port flow statistics query relevant information for all data flows on the port corresponding to the port number. The congestion information record records historical port congestion information.

[0068] The network node in this application may also be referred to as a communication device, such as a router, switch, gateway, or other device with data exchange and transmission functions, or a switching chip in a network device, or a CPU in a network device.

[0069] It should be understood that Figure 1This is a simplified diagram for ease of understanding only. The network system 100 may also include other network nodes, computing nodes, and / or other nodes, and the connection relationships between the nodes may also vary. Figure 1 It was not drawn in the middle.

[0070] It should be understood that this application does not limit the specific topology of network system 100. The aforementioned dragonfly network is merely an example. Network system 100 can also be other topologies with shortest paths and non-shortest paths, such as mesh networks, torus networks, etc. Wherein, if multiple paths in network system 100 are equivalent, the shortest path refers to the path through which the data flow reaches its destination address with the fewest network nodes. If multiple paths in network system 100 are not equivalent, the shortest path refers to the path through which the data flow reaches its destination address with the lowest sum of link metrics. In this embodiment, data flow arrival and data flow forwarding can be equated to the arrival of data packets and the forwarding of data packets.

[0071] Next, the port switching method provided in the embodiments of this application will be described in detail with reference to the accompanying drawings. Here, we will refer to... Figure 1 The specific steps of the port switching method are explained by taking the communication device in the network system 100, such as any one of network nodes 116-127, as an example to illustrate the port switching method.

[0072] Figure 2 This is a flowchart illustrating a port switching method provided in this application. Please refer to it. Figure 2 The method may include the following steps S201-S202.

[0073] S201, The communication device determines that the queue depth of the first port in the first port group is greater than or equal to the first waterline.

[0074] The communication device obtains the queue depth of each port in the first port group, compares the queue depth of each port with the first waterline, and determines that the queue depth of the first port is greater than or equal to the first waterline.

[0075] As one possible implementation, the communication device receives the queue depth of each port in the first port group based on a port congestion reporting mechanism. The unit of queue depth can be a data quantifier used to indicate data size, such as kilobytes (KB), megabytes (MB), gigabytes (GB), etc. Correspondingly, the unit of the first watermark can also be the aforementioned data quantifiers such as KB, MB, GB, etc. The communication device can periodically receive the queue depth of each port in the first port group based on the port congestion reporting mechanism, or it can detect the queue depth of each port in the first port group in real time based on the port congestion reporting mechanism. The period can be any value such as 1 microsecond, 5 microseconds, 10 microseconds, 21 microseconds, 50 microseconds, etc.

[0076] Optionally, the first waterline can be called the port outgoing waterline or the bestpath outgoing waterline. The first waterline is smaller than the second waterline, which can be the congestion waterline. In other words, the port outgoing waterline is smaller than the congestion waterline. For example, the first waterline can be the size of n data packets, where n can be a positive integer such as 1, 2, 3, 7, or 12. Figure 3 As shown, the bottom of the bar indicates a queue depth of zero, and the top of the bar indicates the maximum queue depth that the port can accommodate. The position of the first waterline in the bar is lower than the position of the second waterline. If the real-time queue depth of the port overlaps with or is higher than the position of the first waterline, it means that the queue depth of the first port is greater than or equal to the first waterline.

[0077] Optionally, the first port group may include ports corresponding to the bestpath path among multiple ports managed by the communication device. Ports corresponding to the bestpath path can also be called bestpath ports. The communication device can record and manage bestpath ports by maintaining a bestpath table composed of identifiers (such as port numbers) for each bestpath port. For example, the bestpath table includes optimal path (or optimal forwarding path) information. Taking a destination Internet Protocol (IP) address as an example, if the shortest path is not congested, the bestpath table stores the shortest path information to that IP address; if the shortest path is congested, the bestpath table stores non-shortest path information to that IP address. The shortest path information can be the port number of the shortest path port corresponding to the shortest path, and the non-shortest path information can be the port number of the non-shortest path port corresponding to the non-shortest path.

[0078] As one possible implementation, the first watermark for different ports can be the same or different. For example, the first watermarks for the three ports in the first port group are 16KB, 32KB, and 64KB, respectively. When a data packet arrives at the first port group, the port with the lower first watermark is switched out first, ensuring that the first watermark can be triggered to update the ports in the first port group regardless of the data stream size.

[0079] S202, The communication device updates the first port in the first port group to the second port in the second port group.

[0080] The communication device deletes the first port from the first port group and adds the second port from the second port group to the first port group. After adding the second port from the second port group to the first port group, the communication device deletes the second port from the second port group.

[0081] As one possible implementation, the communication device removes the identifier of the first port from the bestpath table and adds the identifier of the second port to the bestpath table.

[0082] Optionally, the communication device distinguishes between the first port group and the second port group using the bestpath table. That is, the ports corresponding to the port numbers included in the bestpath table constitute the first port group, and the ports corresponding to the port numbers not included in the bestpath table constitute the second port group.

[0083] The ports corresponding to the port numbers in the first port group and the ports corresponding to the port numbers in the second port group are both ports used for forwarding data streams.

[0084] As one possible implementation, the second port can be selected by the communication device from the second port group based on the port queue depth and whether the port is the shortest path port.

[0085] Optionally, the communication device determines the second port from the second port group according to the queue depth of the port and whether the port is the shortest path port, in the order of filtering.

[0086] For example, such as Figure 4 As shown, Figure 4The shaded areas represent the possible range of queue depths. In the filtering order, the priority of the ports decreases in the direction the arrow points. The filtering order can be arranged sequentially as follows: shortest path ports with queue depth less than the first waterline, non-shortest path ports with queue depth less than the first waterline, shortest path ports with queue depth greater than or equal to the first waterline and less than the second waterline, non-shortest path ports with queue depth greater than or equal to the first waterline and less than the second waterline, shortest path ports with queue depth greater than or equal to the second waterline, and non-shortest path ports with queue depth greater than or equal to the second waterline.

[0087] The second waterline is used to indicate whether to switch the data flow in the port to another port for forwarding. Please refer to the following for specific steps. Figure 9 Steps S901-S903 shown will not be repeated here.

[0088] As one possible implementation, after the first port in the first port group is updated to the second port in the second port group, the communication device selects a port from the first port group to forward the data stream for subsequent arrivals. For specific steps, please refer to [link to relevant documentation]. Figure 10 S1001-S1008 shown will not be described again here.

[0089] The following is combined Figures 5-8 The effects of the above port switching method will be explained. Figures 5-8 The bottom of the communication device is the receiving port for receiving data streams, and the top is the forwarding port for forwarding data streams. Unfilled bars represent the shortest path ports, and filled bars represent non-shortest path ports. Figures 5-8 The port location changes are for illustration and description purposes only and do not represent an actual change in the port's location within the communication device.

[0090] like Figure 5 As shown, in the initial state, all ports in the first port group are shortest path ports, such as ports 9-12. All ports in the second port group are non-shortest path ports, such as ports 13-16. When a small number of data packets arrive at some receiving ports of the communication device, such as ports 1 and 2, the first waterline is low. These small numbers of packets cause the queue depth of some shortest path ports, such as ports 9 and 10, to be greater than or equal to the first waterline. Therefore, the communication device updates some shortest path ports, such as ports 9 and 10, to some non-shortest path ports in the second port group, such as ports 13 and 14.

[0091] like Figure 6 As shown, after some shortest path ports, such as port 9 and port 10, are swapped out of the first port group, some non-shortest path ports, such as port 13 and port 14, are swapped into the first port group. At this time, all ports in the first port group are in an idle state.

[0092] like Figure 7 As shown, when subsequent data streams arrive at the communication device, the communication device continues to route the data streams within the first port group. For example, the output port of the data stream received by port 3 is port 11, and the output port of the data stream received by port 4 is port 12.

[0093] like Figure 8 As shown, the ports in the first port group are continuously updated based on the first waterline. Newly arriving data streams can be routed in the continuously updated first port group. By rotating the ports in the first port group, the data streams are distributed as much as possible, achieving the goal of evenly distributing concurrent data streams in different paths, preventing data stream accumulation from causing congestion, and thus improving communication quality.

[0094] The above text combined Figures 2-8 The port switching method and its effects are described in general. In the port switching method of this application, in addition to updating the ports of the first port group according to the first waterline, the data flow in the port can also be switched to other ports for forwarding according to the second waterline to alleviate congestion.

[0095] Next, combine Figure 9 The document details the specific steps a communication device takes to switch the data stream in one port to another for forwarding based on the second waterline. For example... Figure 9 As shown, the data stream switching step may include the following steps S901-S903.

[0096] S901, The communication device obtains the queue depth of multiple ports.

[0097] The communication device obtains the queue depth of each port in the first port group and the second port group.

[0098] As one possible implementation, the communication device receives the queue depth of each port in the first port group and the second port group based on a port congestion reporting mechanism. The communication device can periodically receive the queue depth of each port in the first port group and the second port group based on the port congestion reporting mechanism, or it can detect the queue depth of each port in the first port group and the second port group in real time based on the port congestion reporting mechanism. For example, the period can be any value such as 1 microsecond, 5 microseconds, 10 microseconds, 21 microseconds, 50 microseconds, etc.

[0099] As one possible implementation, the communication device obtains the queue depth of each port in the first port group and the second port group, which may include the queue depth of the first port in S201 above, i.e., S901 and the above. Figure 2 S201 in the text can be implemented by the communication device in one step.

[0100] S902. When the queue depth of the third port is greater than or equal to the second waterline, the communication device switches the first data stream in the third port to the fourth port for forwarding.

[0101] If the queue depth at the third port is greater than or equal to the second waterline, the communication device determines the first data stream at the third port and switches the first data stream to the fourth port for forwarding. The second waterline is a congestion waterline, and its depth is greater than the first waterline. The third port can be any port in the first port group or any port in the second port group.

[0102] As one possible implementation, if the queue depth at the third port is greater than or equal to the second waterline, the communication device obtains the timestamps of at least one data stream in the flowlet table of the third port. Based on the order of the timestamps, it determines that the first data stream is not the latest data stream to arrive at the third port among the at least one data streams. Specifically, the communication device updates the timestamp of each data stream when its data packet arrives at the receiving port.

[0103] Optionally, the communication device sorts the timestamps of at least one data stream in the flowlet table of the third port according to their arrival times from earliest to latest to obtain a sorting result. For example, the communication device randomly samples the data streams of the third port. If the sampled data stream is not the first data stream in the sorting result, the first data stream is determined to be the sampled data stream. If the sampled data stream is the first data stream in the sorting result, the data streams of the third port are randomly sampled again. As another example, the communication device randomly samples the data streams of the third port other than the first data stream in the sorting result to obtain the first data stream.

[0104] As one possible implementation, the communication device deletes the flowlet table corresponding to the first data stream, so that when subsequent data packets of the first data stream arrive at the communication device, a port is reselected in the first port group for forwarding, thereby realizing port switching of the first data stream.

[0105] As one possible implementation, please refer to the following for details on how the communication device determines the fourth port. Figure 10 The steps of the communication device in S1008 shown to determine the port for forwarding the second data stream in the first port group will not be described again here.

[0106] S903, the communication device sends a PFC anti-pressure frame.

[0107] The communication device sends a backpressure frame through the receiving port of the first data stream, in the reverse order of receiving the first data stream, to notify the upstream device to stop sending data packets of the first data stream until the congestion is relieved. The upstream device can be the device one hop above the communication device that sent the first data stream, for example... Figure 1 The upstream device of network node 118 can be network node 116, and the upstream device of network node 116 can be computing node 104.

[0108] In this way, the communication device implements a pre-ordered flow switching mechanism based on the second waterline, avoiding prolonged port congestion. Simultaneously, during the switching of congested ports, the latest data stream is retained for the port, and the number of data streams per port is controlled to prevent resource waste caused by idle data switching, thereby improving port resource utilization.

[0109] The above text Figure 2 or Figure 3 The illustrated embodiment implements port switching based on the first waterline and the second waterline. Based on this, the port switching method provided in this application may further include a message routing step based on the first port group, thereby evenly distributing the data packets of the data stream arriving at the communication device to different ports.

[0110] Next, combine Figure 10 The specific steps for the communication device to forward data streams based on the first port group are explained in detail. For example... Figure 10 As shown, the data stream switching step may include the following steps S1001-S1008.

[0111] S1001, The communication device receives the message.

[0112] Communication devices can be Figure 1 The communication device in the network system 100, such as any one of network nodes 116-127.

[0113] S1002, The communication device determines the first identifier of the data stream to which the message belongs.

[0114] In the forwarding information base (FIB), the communication device determines the first identifier (e.g., flow_id) of the data stream to which the packet belongs based on the hash calculation result of the packet's five-tuple (e.g., source IP address, source port, destination IP address, destination port, and transport layer protocol), the flow base, and the flow number. The packet may belong to a second data stream.

[0115] S1003. The communication device determines whether there is a first flowlet table corresponding to the first identifier.

[0116] The communication device accesses the first flowlet table based on the first identifier. If the first flowlet table is accessed, then the first flowlet table corresponding to the first identifier exists. If the first flowlet table is not accessed, then the first flowlet table corresponding to the first identifier does not exist.

[0117] S1004. If a first flowlet table corresponding to the first identifier exists, the communication device determines whether the first flowlet table has expired.

[0118] The communication device determines whether the first flowlet table has expired based on the gaptime recorded in the first flowlet table. For example, if the current time is greater than the gaptime recorded in the first flowlet table, then the first flowlet table has expired.

[0119] S1005. If the first flowlet table has not expired, the communication device forwards the message according to the first flowlet table.

[0120] The communication device determines the forwarding port based on the port number corresponding to the second data stream recorded in the first flowlet table, and forwards the message through the forwarding port.

[0121] S1006. If the first flowlet table has expired, or there is no first flowlet table corresponding to the first identifier, the communication device determines whether the message has been forwarded through a non-shortest path port.

[0122] As one possible implementation, the communication device determines whether a message has been forwarded through a non-shortest path port based on the detour identifier carried in the message.

[0123] Optionally, the detour identifier can be the virtual lane (VL) identifier in the type of service (TOS) field of the IP header. For example, when the VL identifier is the first value (e.g., 0), it indicates that the packet has not been forwarded through a non-shortest path port, and when the VL identifier is the second value (e.g., 1), it indicates that the packet has been forwarded through a non-shortest path port.

[0124] S1007. If the message has been forwarded through a non-shortest path port, the communication device determines the port for forwarding the second data stream from the shortest path ports in the first port group.

[0125] The communication device determines the port for forwarding the second data stream from the shortest path ports in the first port group, and forwards the message through that port.

[0126] As one possible implementation, the communication device randomly determines the port for forwarding the second data stream from the shortest path ports in the first port group.

[0127] Optionally, the above-mentioned random determination method can be to determine the corresponding port from the shortest path ports in the first port group based on the hash calculation result of the message quintuple.

[0128] S1008. If the message is not forwarded through a non-shortest path port, the communication device determines the port in the first port group to be used for forwarding the second data stream.

[0129] The port determined by the communication device in the first port group for forwarding the second data stream can be either the shortest path port or a non-shortest path port.

[0130] As one possible implementation, the communication device randomly determines a port in the first port group to forward the second data stream and establishes a flowlet table. This flowlet table records the correspondence between the second data stream and the port number of the port used to forward the second data stream. Thus, the communication device forwards packets from the port used to forward the second data stream according to the established flowlet table.

[0131] Optionally, the above-mentioned random determination method can be to determine the corresponding port in the first port group based on the hash calculation result of the message quintuple.

[0132] Based on the above S1001-S1008, data streams that have already been forwarded through non-shortest path ports cannot be forwarded through non-shortest path ports again, thus avoiding the formation of loops in the data stream transmission path.

[0133] To complement the port switching method provided in the embodiments of this application, the embodiments of this application also provide a port switching device 1100, which is used to execute the above-described port switching method. Figure 11 As shown, the port switching device 1100 includes a waterline identification module 1110 and a port switching module 1120.

[0134] For example, the port switching device 1100 can implement Figure 2 , Figure 9 or Figure 10 The functions of communication devices.

[0135] The waterline identification module 1110 is used to determine that the queue depth of the first port in the first port group is greater than or equal to the first waterline.

[0136] The port switching module 1120 is used to update the first port in the first port group to the second port in the second port group; the first watermark is smaller than the second watermark, and the second watermark is used to indicate that the data flow in the port is switched to other ports for forwarding. Among them, the data flow is preferentially forwarded through the first port group compared to the second port group.

[0137] As one possible implementation, the second port group includes at least one shortest path port and at least one non-shortest path port. The port switching module 1120 is also used to: determine the second port from the second port group based on the port queue depth and whether the port is a shortest path port.

[0138] As one possible implementation, the port switching module 1120 is specifically used to: determine the second port from the second port group according to the queue depth of the port and whether the port is the shortest path port, in the following filtering order: the shortest path port with a queue depth less than the first waterline, the non-shortest path port with a queue depth less than the first waterline, the shortest path port with a queue depth greater than or equal to the first waterline and less than the second waterline, the non-shortest path port with a queue depth greater than or equal to the first waterline and less than the second waterline, the shortest path port with a queue depth greater than or equal to the second waterline, and the non-shortest path port with a queue depth greater than or equal to the second waterline.

[0139] As one possible implementation, the device further includes: a port flow switching module, used to switch the first data stream in the third port to the fourth port for forwarding if the queue depth of the third port is greater than or equal to the second waterline; the third port belongs to the first port group or the second port group; after switching the first data stream in the third port to the fourth port for forwarding, a priority flow control (PFC) backpressure frame is sent.

[0140] As one possible implementation, the port flow-switching module is also used to: obtain the timestamp of at least one data stream in the flowlet table of the third port; and determine, based on the order of the timestamps, that the first data stream is not the latest data stream to arrive at the third port among at least one data streams.

[0141] As one possible implementation, the device further includes: a stream forwarding module for receiving a second data stream; if the second data stream has been forwarded through a non-shortest path port, determining a port for forwarding the second data stream from the shortest path ports in the first port group; if the second data stream has not been forwarded through a non-shortest path port, determining a port for forwarding the second data stream from the first port group.

[0142] As one possible implementation, the data streams in the first port group and the second port group are AI data streams.

[0143] As one possible implementation, the method can be applied to mesh networks, torus networks, or dragonfly networks.

[0144] It should be understood that the above Figure 11The provided device, in implementing its functions, is only illustrated by the division of the above-described functional modules. In practical applications, the functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. Furthermore, the device and method embodiments provided in the above embodiments belong to the same concept, and their specific implementation processes are detailed in the method embodiments, and will not be repeated here.

[0145] Figure 12 This is a schematic diagram of the structure of a communication device provided in this application. Figure 12 As shown, the communication device 1200 includes a processor 1210, a bus 1220, a memory 1230, a communication interface 1240, and a memory unit 1250 (also referred to as a main memory unit). The processor 1210, memory 1230, memory unit 1250, and communication interface 1240 are connected via the bus 1220.

[0146] It should be understood that in this embodiment, the processor 1210 may be a CPU, but it may also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.

[0147] The processor may also be a graphics processing unit (GPU), a neural network processing unit (NPU), a microprocessor, or one or more integrated circuits used to control the execution of the program in this application.

[0148] In a possible embodiment, communication device 1200 may refer to processor 1210.

[0149] The communication interface 1240 is used to enable communication between the communication device 1200 and external devices or components. In this embodiment, the communication device 1200 is used to implement... Figure 1 When any network device, server, or controller is in use, the communication interface 1240 is used as a physical port for sending and receiving data packets.

[0150] Bus 1220 may include a pathway for transmitting information between the aforementioned components (such as processor 1210, memory unit 1250, and memory 1230). In addition to a data bus, bus 1220 may also include a power bus, a control bus, and a status signal bus, etc. However, for clarity, ... Figure 12 In this context, various buses are labeled as Bus 1220. Bus 1220 can be a Peripheral Component Interconnect Express (PCIe) bus, an Extended Industry Standard Architecture (EISA) bus, a Unified Bus (Ubus or UB), a Compute Express Link (CXL) bus, a Cache Coherent Interconnect for Accelerators (CCIX) bus, etc. Bus 1220 can be categorized into address bus, data bus, and control bus.

[0151] As an example, the communication device 1200 may include multiple processors. A processor may be a multi-core (multi-CPU) processor. Here, a processor may refer to one or more devices, circuits, and / or computing units used to process data (e.g., computer program instructions).

[0152] It is worth noting that, Figure 12 Taking the communication device 1200, which includes a processor 1210 and a memory 1230, as an example, the processor 1210 and the memory 1230 are used to indicate a type of device or equipment. In specific embodiments, the number of each type of device or equipment can be determined according to business requirements.

[0153] Memory cell 1250 may be volatile memory or non-volatile memory, or may include both. The non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory may be random access memory (RAM), which serves as an external cache. By way of example, but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous linked dynamic random access memory (SLDRAM), and direct rambus RAM (DR RAM).

[0154] The memory 1230 can correspond to the storage medium used to store computer instructions and other information in the above method embodiments, such as a disk, like a mechanical hard disk or a solid-state hard disk.

[0155] The aforementioned communication device 1200 can be a general-purpose device or a special-purpose device. For example, the communication device 1200 can be an edge device (e.g., a box carrying a chip with processing capabilities). Alternatively, the communication device 1200 can also be a chip, network device, server, or other device with computing capabilities.

[0156] It should be understood that the communication device 1200 according to this embodiment can correspond to the port switching device 1100 in this embodiment, and can correspond to the device executing according to Figure 2 , Figure 9 or Figure 10 The corresponding entities in the method, and the above and other operations and / or functions of each module in the port switching device 1100 are respectively implemented for the purpose of... Figure 2 , Figure 9 or Figure 10 For the sake of brevity, the corresponding procedures of the Chinese method will not be elaborated here.

[0157] This application also provides a communication system, including a first communication device and a second communication device. The first communication device is used to determine that the queue depth of a first port in a first port group is greater than or equal to a first waterline; update the first port in the first port group to a second port in a second port group; the first waterline is less than the second waterline, and the second waterline is used to indicate switching the data stream in the port to other ports for forwarding; wherein, compared to the second port group, the data stream is preferentially forwarded through the first port group. The second communication device is used to receive messages forwarded by the first communication device through ports in the first port group, and after updating the first port group using the same port switching method as the first communication device, select ports from the first port group to forward messages.

[0158] The first or second communication device can be used to implement the functions of the port switching device 1100. The hardware structure of the first communication device can refer to that of the communication device 1200.

[0159] This application also provides a computer program product containing instructions. The computer program product may be a software or program product containing instructions capable of running on a computing device or stored on any usable medium. When the computer program product runs on at least one computing device, it causes the at least one computing device to perform the aforementioned port switching method.

[0160] This application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium capable of being stored by a computing device, or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive). The computer-readable storage medium includes instructions that instruct the computing device to perform the aforementioned port switching method.

[0161] This application also provides a chip, including a processor. The processor is used to retrieve and execute instructions stored in a memory, causing a communication device equipped with the chip to perform the aforementioned port switching method.

[0162] As one possible implementation, the chip also includes an input interface, an output interface, and a memory. The input interface, the output interface, the processor, and the memory are connected via internal interconnection paths. The processor is used to execute code in the memory, and when the code is executed, the processor is used to perform the aforementioned port switching method.

[0163] The method steps in this embodiment can be implemented in hardware or by a processor executing software instructions. The software instructions can consist of corresponding software modules, which can be stored in random access memory, flash memory, read-only memory, programmable read-only memory, erasable programmable read-only memory, electrically erasable programmable read-only memory, registers, hard disks, portable hard disks, CD-ROMs, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor, enabling the processor to read information from and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and storage medium can reside in an ASIC. Alternatively, the ASIC can reside in an electronic device (such as a network device). Of course, the processor and storage medium can also exist as discrete components in an electronic device.

[0164] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instructions are loaded and executed on a computer, the processes or functions described in the embodiments of this application are performed entirely or partially. The computer can be a general-purpose computer, a special-purpose computer, a computer network, a network device, a user equipment, or other programmable device. The computer program or instructions can be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another. For example, the computer program or instructions can be transferred from one website, computer, server, or data center to another website, computer, server, or data center via wired or wireless means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium, such as a floppy disk, hard disk, or magnetic tape; it can also be an optical medium, such as a digital video disc (DVD); or it can be a semiconductor medium, such as a solid-state drive (SSD). The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A port switching method, characterized in that, include: Determine that the queue depth of the first port in the first port group is greater than or equal to the first waterline; Update the first port in the first port group to the second port in the second port group; the first waterline is smaller than the second waterline, and the second waterline is used to indicate that the data flow in the port is switched to other ports for forwarding. In this case, the data flow is preferentially forwarded through the first port group compared to the second port group.

2. The method according to claim 1, characterized in that, The second port group includes at least one shortest path port and at least one non-shortest path port. Before updating the first port in the first port group to the second port in the second port group, the method further includes: The second port is determined from the second port group based on the port's queue depth and whether the port is the shortest path port.

3. The method according to claim 2, characterized in that, The step of determining the second port from the second port group based on the port's queue depth and whether the port is the shortest path port includes: Based on the queue depth of the port and whether the port is the shortest path port, the second port is determined from the second port group according to the filtering order; the filtering order is arranged in the following order: shortest path port with queue depth less than the first waterline, non-shortest path port with queue depth less than the first waterline, shortest path port with queue depth greater than or equal to the first waterline and less than the second waterline, non-shortest path port with queue depth greater than or equal to the first waterline and less than the second waterline, shortest path port with queue depth greater than or equal to the second waterline, and non-shortest path port with queue depth greater than or equal to the second waterline.

4. The method according to any one of claims 1-3, characterized in that, The method further includes: If the queue depth of the third port is greater than or equal to the second waterline, the first data stream in the third port is switched to the fourth port for forwarding; the third port belongs to the first port group or the second port group; After switching the first data stream in the third port to the fourth port for forwarding, a Priority Stream Control (PFC) backpressure frame is sent.

5. The method according to claim 4, characterized in that, Before switching the first data stream in the third port to the fourth port, the method further includes: Obtain the timestamp of at least one data stream in the flowlet table of the third port; Based on the order of the timestamps, the first data stream is determined to be the data stream that is not the latest to arrive at the third port among the at least one data streams.

6. The method according to any one of claims 1-5, characterized in that, The method further includes: Receive the second data stream; If the second data stream has already been forwarded through a non-shortest path port, determine the port used to forward the second data stream from the shortest path ports in the first port group; If the second data stream is not forwarded through a port other than the shortest path, determine the port from the first port group to forward the second data stream.

7. The method according to any one of claims 1-6, characterized in that, The data streams in the first port group and the second port group are artificial intelligence (AI) data streams.

8. The method according to any one of claims 1-7, characterized in that, The method is applicable to mesh networks, torus networks, or dragonfly networks.

9. A port switching device, characterized in that, include: The waterline identification module is used to determine whether the queue depth of the first port in the first port group is greater than or equal to the first waterline. The port switching module is used to update the first port in the first port group to the second port in the second port group; the first waterline is smaller than the second waterline, and the second waterline is used to indicate that the data flow in the port is switched to other ports for forwarding. In this case, the data flow is preferentially forwarded through the first port group compared to the second port group.

10. The apparatus according to claim 9, characterized in that, The second port group includes at least one shortest path port and at least one non-shortest path port, and the port switching module is further configured to: The second port is determined from the second port group based on the port's queue depth and whether the port is the shortest path port.

11. The apparatus according to claim 10, characterized in that, The port switching module is specifically used for: Based on the queue depth of the port and whether the port is the shortest path port, the second port is determined from the second port group according to the filtering order; the filtering order is arranged in the following order: shortest path port with queue depth less than the first waterline, non-shortest path port with queue depth less than the first waterline, shortest path port with queue depth greater than or equal to the first waterline and less than the second waterline, non-shortest path port with queue depth greater than or equal to the first waterline and less than the second waterline, shortest path port with queue depth greater than or equal to the second waterline, and non-shortest path port with queue depth greater than or equal to the second waterline.

12. The apparatus according to claim 10 or 11, characterized in that, The device further includes: The port flow switching module is used to switch the first data stream in the third port to the fourth port for forwarding if the queue depth of the third port is greater than or equal to the second waterline; the third port belongs to the first port group or the second port group; after switching the first data stream in the third port to the fourth port for forwarding, a Priority Flow Control (PFC) backpressure frame is sent.

13. The apparatus according to claim 12, characterized in that, The port switching module is also used for: Obtain the timestamp of at least one data stream from the flowlet table of the third port; Based on the order of the timestamps, the first data stream is determined to be the data stream that is not the latest to arrive at the third port among the at least one data streams.

14. The apparatus according to any one of claims 9-13, characterized in that, The device further includes: The stream forwarding module is used to receive the second data stream; if the second data stream has been forwarded through a non-shortest path port, the port for forwarding the second data stream is determined from the shortest path ports in the first port group; if the second data stream has not been forwarded through a non-shortest path port, the port for forwarding the second data stream is determined from the first port group.

15. The apparatus according to any one of claims 9-14, characterized in that, The data streams in the first port group and the second port group are AI data streams.

16. The apparatus according to any one of claims 9-15, characterized in that, The method is applicable to mesh networks, torus networks, or dragonfly networks.

17. A chip, characterized in that, The chip includes a processor for retrieving and executing instructions stored in a memory, causing the chip to perform the method as described in any one of claims 1-8.

18. A communication device, characterized in that, The communication device includes a processor and a memory; The processor is configured to execute instructions stored in the memory to cause the communication device to perform the method as described in any one of claims 1-8.

19. A computer program product containing instructions, characterized in that, When the instruction is executed by the communication device, the communication device performs the method as described in any one of claims 1-8.

20. A computer-readable storage medium, characterized in that, It includes computer program instructions, which, when executed by a communication device, perform the method as described in any one of claims 1-8.