Patent Description:
With the rise of new applications such as artificial intelligence, enterprise storage, and the like, a demand of a data center network for a low delay characteristic is becoming increasingly urgent. It is very important to control congestion of the data center network so as to ensure the low delay characteristic of the data center network.

In a conventional congestion control method, a receive end feeds back congestion information of a network to a transmit end, and the transmit end adjusts a data sending rate based on the congestion information after learning the congestion information of the network. For example, when the network is congested, the transmit end decreases a sending rate of data packets; and when the network is not congested, the transmit end gradually increases the sending rate of the data packets.

In the foregoing solution, the transmit end gradually adjusts the sending rate of the data packets after learning the congestion state of the network. The change of the rate is relatively slow, and a certain delay may be generated in the transmission process of the data packets, and consequently, congestion control efficiency is not high.

<CIT> discloses a flow control method. The method comprises determining a bandwidth used y a flow, and selectively dropping one or more packets associated with the flow based on at least one of the used bandwidth and an access control policy. In particular, the method further comprises determining whether a used bandwidth is greater than a bandwidth limit for a flow. If yes, then one or more packets of the flow are dropped.

<CIT> discloses a transmission path determining method for switching a transmission path when a flow is congested. In particular, for determining whether the flow is congested, the method comprises determining whether a flow rate of the flow to which the to-be-transmitted packet belongs is greater than a preset threshold.

<CIT> refers to a method of using a priori information (e.g. previous network connection settings) to increase the speed at which information is initially sent using TCP.

This application provides a congestion control method and a network device, so as to better perform congestion control and reduce network packet loss.

According to a first aspect, a congestion control method is provided, where the method is applied to a data center network, the data center network includes a first network device and a second network device, and the first network device is configured to send a data flow to the second network device. The method includes: The first network device receives a first message sent by the second network device, where the first message carries an active flow quantity, and the active flow quantity is a quantity determined by the second network device based on a data flow to which data packets received from the first network device belong; the first network device determines, based on the active flow quantity and rated receiving bandwidth of the second network device, packet sending control information used to send the data flow to the second network device, where the packet sending control information indicates that actual receiving bandwidth of the second network device reaches the rated receiving bandwidth when the first network device sends the data flow to the second network device based on the packet sending control information; and the first network device sends the data flow to the second network device based on the packet sending control information.

The active flow quantity may refer to a quantity of data flows in which data packets are being transmitted within a certain statistical period. Specifically, the active flow quantity may be a quantity of data flows that is determined by the second network device based on a data flow to which data packets received from the first network device within a statistical period belong.

Optionally, the data flow sent by the first network device to the second network device based on the packet sending control information is encapsulated into remote direct memory access over converged Ethernet version <NUM> (RoCEv2) packets.

Optionally, the first message is carried in an option field in an acknowledgement (ACK) packet.

It should be understood that the data flow sent by the first network device to the second network device based on the packet sending control information may be one data flow (in this case, the data flow may be any one of all data flows sent by the first network device to the second network device), or may be a plurality of data flows (the plurality of data flows may be all data flows sent by the first network device to the second network device).

The packet sending control information is used to control the first network device to send the data flow to the second network device; and when the first network device sends the data flow to the second network device based on the packet sending control information, the actual bandwidth of the second network device can reach the rated receiving bandwidth of the second network device.

The rated receiving bandwidth of the second network device may be fixed bandwidth. When the first network device is configured, information such as the rated receiving bandwidth of the second network device may be directly configured for the first network device, so that the first network device can obtain the rated receiving bandwidth of the second network device from the configuration information.

In this application, the packet sending control information is determined based on the active flow quantity and the rated receiving bandwidth of the second network device, and the data flow sent from the first network device to the second network device is controlled based on the packet sending control information, so that congestion control can be better performed, thereby reducing network packet loss.

In the first aspect, that the first network device determines, based on the active flow quantity and rated receiving bandwidth of the second network device, packet sending control information used to send the data flow to the second network device includes: When the active flow quantity is less than a first threshold, the first network device determines, based on the following formula, the packet sending control information used to send the data flow to the second network device: <MAT> where C is the rated receiving bandwidth of the second network device, active_qp is the active flow quantity, T is a time required for a data packet sent by the first network device to the second network device to arrive at the second network device when the network is idle, and V is a data volume of the data flow sent by the first network device to the second network device within T. That the first network device sends the data flow to the second network device based on the packet sending control information includes: The first network device sends data packets with a data volume V in the data flow to the second network device within T.

The data volume may be a length of the data packets in the data flow. For example, a data flow <NUM> includes a data packet <NUM>, a data packet <NUM>, and a data packet <NUM>, where each data packet has a length of <NUM> bytes, and then the data flow <NUM> has a length of <NUM> bytes.

There are many methods for obtaining T. These methods are described below as examples.

For example, when the network is idle, a sending time and an arrival time of a data packet sent by the first network device to the second network device may be recorded, and then T may be obtained by subtracting the sending time from the arrival time.

In addition, when the network is idle, the first network device may alternatively continuously send a plurality of data packets (for example, <NUM> data packets) to the second network device, and then a time required for each data packet sent from the first network device to the second network device may be obtained based on the recorded time, and all times may be averaged to obtain an average time; and finally the average time is determined as T.

The first threshold may be set based on experience. For example, in a scenario in which there is a relatively large data volume, a relatively large value may be set as the first threshold; and in a scenario in which there is a relatively small data volume, a relatively small value may be set as the first threshold.

The first threshold may alternatively be determined based on the rated receiving bandwidth of the second network device, T, and a length of a single data packet.

Specifically, a value obtained based on C*T/1pkt may be determined as the first threshold, where 1pkt is the length of a single data packet. A specific length of 1pkt may be set based on an actual situation. In different scenarios, 1pkt may be set to different lengths. For example, in some scenarios in which a data transmission volume is relatively small (for example, a smart meter periodically reports electricity consumption information), a relatively small length may be set for 1pkt; and in scenarios in which a data transmission volume s relatively large, a relatively large length may be set for 1pkt. In addition, 1pkt may be directly set as a maximum transmission unit (MTU) allowed by the network.

With reference to the first aspect, in some implementations of the first aspect, that the first network device determines, based on the active flow quantity and rated receiving bandwidth of the second network device, packet sending control information used to send the data flow to the second network device includes: When the active flow quantity is greater than or equal to the first threshold, the first network device determines, based on the following formula, the packet sending control information used to send the data flow to the second network device: <MAT> where 1pkt is a length of a single data packet, active_qp is the active flow quantity, C is the rated receiving bandwidth of the second network device, and "interval" is a time interval between adjacent data packets when the first network device sends the data flow. That the first network device sends the data flow to the second network device based on the packet sending control information includes: The first network device sends a data packet in the data flow to the second network device based on the time interval indicated by "interval".

The length of the single data packet may be specifically a size of the data volume of the single data packet, for example, if the size of the data volume of the single data packet is <NUM> bytes, the length of the single data packet is also <NUM> bytes.

According to a second aspect, a congestion control method is provided, where the method is applied to a data center network, the data center network includes a first network device and a second network device, and the second network device is configured to receive a data flow sent by the first network device. The method includes: The second network device determines an active flow quantity based on a data flow to which data packets received from the first network device belong; the second network device sends a first message to the first network device, where the first message carries the active flow quantity, the active flow quantity is used by the first network device to determine packet sending control information used to send the data flow to the second network device, and the packet sending control information indicates that actual receiving bandwidth of the second network device reaches rated receiving bandwidth of the second network device when the first network device sends the data flow to the second network device based on the packet sending control information; and the second network device receives, based on the rated receiving bandwidth, the data flow sent by the first network device.

In this application, the second network device reports the active flow quantity to the first network device, so that the first network device can determine the packet sending control information based on the active flow quantity and the rated receiving bandwidth of the second network device, and controls, based on the packet sending control information, the first network device to send the data flow to the second network device, so that the second network device can receive, based on the rated receiving bandwidth, the data flow sent by the first network device, and the second network device can reach a full throughput state, thereby improving transmission efficiency of the data flow.

That the second network device determines an active flow quantity based on a data flow to which data packets received from the first network device belong includes: The second network device receives the initial packet in a first group of data packets sent by the first network device, and increases a current active flow quantity by <NUM> to obtain a first active flow quantity; the second network device receives the tail packet in the first group of data packets sent by the first network device, and determines a first congestion value based on a quantity of data packets carrying an external congestion notification ECN identifier in the first group of data packets; when the first congestion value is less than a congestion threshold, the second network device decreases the first active flow quantity by <NUM> to obtain a second active flow quantity; and when the first congestion value is greater than or equal to the congestion threshold, the second network device keeps the first active flow quantity unchanged.

Optionally, the first congestion value is used to indicate a congestion degree of the first network device when the second network device receives the data packet sent by the first network device.

It should be understood that a greater first congestion value indicates a higher congestion degree of the first network device.

The congestion threshold may be a preset threshold, and the congestion threshold may be a threshold estimated based on a network status. In a scenario in which broadband utilization is low, a relatively small congestion threshold may be set, while in a scenario in which broadband utilization is high, a relatively large congestion threshold may be set.

For example, in a scenario in which broadband utilization is low, the congestion threshold may be specifically <NUM>, <NUM>, <NUM>, or the like, while in a scenario in which broadband utilization is high, the congestion threshold may be specifically <NUM>, <NUM>, <NUM>, or the like.

It should be understood that when the initial packet in the first group of data packets is received, the current active flow quantity needs to be increased by <NUM> to obtain the first active flow quantity. The current active flow quantity herein is a quantity of active flows counted by the second network device before receiving the initial packet in the first group of data packets. When receiving the initial packet in the first group of data packets, the second network device needs to update the active flow quantity, that is, to increase the active flow quantity counted before receiving the initial packet in the first group of data packets by <NUM>.

After receiving the tail packet in the first group of data packets, the second network device needs to update the first active flow quantity again based on the quantity of the data packets carrying the ECN identifier in the first group of data packets. If the first congestion value is less than the congestion threshold, the active flow quantity counted by the second network device after receiving the tail packet in the first group of data packets is the second active flow quantity; and if the first congestion value is greater than or equal to the congestion threshold, the active flow quantity counted by the first network device after receiving the tail packet in the first group of data packets is the first active flow quantity. That is, after the tail packet in the first group of data packets is received, the counted active flow quantity is the first active flow quantity (when the first congestion value is greater than or equal to the congestion threshold) or the second active flow quantity (when the first congestion value is less than the congestion threshold).

The ECN identifier may be a congestion identifier added by another network device (which may be specifically switching equipment between the first network device and the second network device) when receiving the data packet.

Optionally, each data packet may also carry an identifier in a field, and a value of the field is used to indicate a type of the data packet (specifically, the initial packet, the tail packet, or a data packet between the initial packet and the tail packet).

Each data packet may also be considered as a packet, and an identifier of each data packet may be carried in a field of the packet. For example, when the data packet is a remote direct memory access over converged Ethernet version <NUM> (RoCEv2) packet, an identifier of the data packet may be carried in an opcode field in the RoCEv2 packet, or an identifier of the data packet may be carried in a reserved field (such as an rsvd7 field) in the RoCEv2 packet.

In this application, when the tail packet in a group of data packets is received, a congestion status may be determined based on a quantity of data packets carrying the ECN identifier in the group of data packets, and the active flow quantity may be corrected based on the congestion status, so that the active flow quantity can be more accurately counted, and a more accurate active flow quantity can be obtained.

Specifically, a conventional solution does not consider the network congestion status during counting of the active flow quantity. Actually, the conventional solution counts the active flow quantity based on an ideal situation that the network is not congested. When the network is congested, a quantity of data packets received by a receive end within a period is affected, so that the counted active flow quantity is inaccurate. In this application, data packets carrying the ECN identifier in each group of data packets are counted, so as to estimate network congestion. When the network congestion degree is relatively low, the active flow quantity can be decreased by <NUM>; and when the network congestion degree is relatively high, the active flow quantity can be kept unchanged, so that impact of network congestion on the active flow quantity can be reduced, and the counted active flow quantity is more accurate.

With reference to the second aspect, in some implementations of the second aspect, determining a first congestion value based on a quantity of data packets carrying an ECN identifier in the first group of data packets includes: determining a ratio of the quantity of data packets carrying the ECN identifier in the first group of data packets to a quantity of data packets in the first group of data packets as the first congestion value.

Optionally, the determining a ratio of the quantity of data packets carrying the ECN identifier in the first group of data packets to a quantity of data packets in the first group of data packets includes: determining a ratio of a total quantity of data packets carrying the ECN identifier in the first group of data packets to a total quantity of data packets in the first group of data packets as the first congestion value.

For example, the first group of data packets includes a total of <NUM> data packets (including the initial packet and the tail packet), where a total of five data packets carry the ECN identifier, and then it may be determined, through calculation, that the first congestion value is <NUM>.

In addition, the ratio of the total quantity of data packets carrying the ECN identifier in the first group of data packets to the total quantity of data packets in the first group of data packets may alternatively be obtained first, and then a product of the ratio and a correction coefficient is used as the first congestion value. The correction coefficient may be a coefficient set based on an operation status of the network.

In this application, the first congestion value is determined based on the data packets carrying the ECN identifier in the first group of data packets, so that a current congestion status can be reflected in real time, and the active flow quantity can be counted more accurately based on the current congestion status.

With reference to the second aspect, in some implementations of the second aspect, after the second network device receives the tail packet in the first group of data packets sent by the first network device, the method further includes: The second network device receives the initial packet in a second group of data packets sent by the first network device, and increases a third active flow quantity by <NUM> to obtain a fourth active flow quantity, where the second group of data packets and the first group of data packets belong to a same data flow, the third active flow quantity is equal to the second active flow quantity when the first congestion value is less than the congestion threshold, and the third active flow quantity is equal to the first active flow quantity when the first congestion value is greater than or equal to the congestion threshold; the second network device receives the tail packet in the second group of data packets sent by the first network device, and determines a second congestion value of the network based on a quantity of data packets carrying the ECN identifier in the second group of data packets and the first congestion value; when the second congestion value is less than the congestion threshold, the second network device decreases the fourth active flow quantity by <NUM> to obtain a fifth active flow quantity; and when the second congestion value is greater than or equal to the congestion threshold, the second network device keeps the fourth active flow quantity unchanged.

It should be understood that the initial packet, the tail packet, and the data packet between the initial packet and the tail packet in the first group of data packets may all carry the ECN identifier. When each data packet in the first group of data packets carries the ECN identifier, it indicates that network congestion is serious. When a small quantity of data packets in the first group of data packets carry the ECN identifier, it indicates that the network congestion degree is low (or the network is relatively smooth).

After the initial packet in the second group of data packets is received, the initial packet in the second group of data packets may be processed in a manner similar to that of the initial packet in the first group of data packets; and after the tail packet in the second group of data packets is received, the second congestion value is determined based on both the quantity of data packets carrying the ECN identifier in the second group of data packets and the first congestion value, so that the second congestion value does not change too much, a slowly changing congestion value is obtained, and the counted active flow quantity does not change abruptly.

Optionally, after the second network device receives the tail packet in the second group of data packets sent by the first network device, the second congestion value may alternatively be determined based on both the quantity of data packets carrying the ECN identifier in the first group of data packets and the quantity of data packets carrying the ECN identifier in the second group of data packets.

Optionally, a ratio of a total quantity of data packets carrying the ECN identifier in both the first group of data packets and the second group of data packets to a total quantity of data packets included in both the first group of data packets and the second group of data packets is determined as the second congestion value.

With reference to the second aspect, in some implementations of the second aspect, determining a second congestion value of the network based on a quantity of data packets carrying the ECN identifier in the second group of data packets and the first congestion value includes: determining a third congestion value of the network based on the quantity of data packets carrying the ECN identifier in the second group of data packets; and determining the second congestion value based on a formula con2=x1*con3+x2*con1, where con3 is the third congestion value, con1 is the first congestion value, con2 is the second congestion value, x1 is a preset first weight, and x2 is a preset second weight.

It should be understood that in the method according to the second aspect, the active flow quantity may be counted by a network device at a receive end or switching equipment between a transmit end and the receive end; when the active flow quantity is counted by the switching equipment between the transmit end and the receive end, the switching equipment may feed back the counted active flow quantity to the receive end for forwarding it to the transmit end.

According to a third aspect, a network device is provided, where the network device includes a memory and a processor, where the memory is configured to store a program, and the processor is configured to execute the program stored in the memory, and when the program stored in the memory is executed by the processor, the processor is configured to perform the methods according to various implementations of the first aspect or various implementations of the second aspect.

Optionally, the network device further includes a transceiver; and when the program stored in the memory is executed by the processor, the processor and the transceiver are configured to perform the methods according to various implementations of the first aspect or various implementations of the second aspect.

According to a fourth aspect, a computer program product including an instruction is provided, where when the computer program product runs on a computer, the computer is enabled to perform the methods according to various implementations of the first aspect or various implementations of the second aspect.

The foregoing computer may be specifically a network device in a data center, for example, a server or a transmission device.

<FIG> is a schematic diagram of a possible application scenario of embodiments of this application.

As shown in <FIG>, a transmit end <NUM>, a transmit end <NUM>, and a transmit end <NUM> may send data flows to a receive end <NUM> and a receive end <NUM> through a switch <NUM> and a switch <NUM>. Both the receive end <NUM> and the receive end <NUM> may receive, through the switch <NUM> and the switch <NUM>, the data flows sent from the transmit end <NUM>, the transmit end <NUM>, and the transmit end <NUM> (the switch <NUM> and the switch <NUM> forward the data flows sent from the transmit end <NUM>, the transmit end <NUM>, and the transmit end <NUM> to the receive end <NUM> and the receive end <NUM>). <FIG> is merely a schematic diagram of a possible application scenario of the embodiments of this application. The embodiments of this application may also be applied to another scenario similar to the scenario shown in <FIG>.

Using the transmit end <NUM> and the receive end <NUM> as an example, a data flow sent by the transmit end <NUM> to the receive end <NUM> may lead to congestion between the transmit end <NUM> and the receive end <NUM>, and consequently, a delay of a data packet received by the receive end <NUM> becomes high, and network performance is affected. To perform congestion control, in a conventional solution, the receive end <NUM> feeds back a congestion status of the data flow to the transmit end <NUM>. When the data flow leads to congestion, the transmit end <NUM> gradually reduces a sending rate of the data flow, and when the data flow does not lead to congestion, the transmit end can gradually increase the sending rate of the data packet. In the conventional solution, the transmit end gradually adjusts the sending rate of the data packet after learning the congestion status of the network, and therefore the rate changes relatively slow. This is a passive adjustment after the congestion status of the network is known, and the congestion control effect is not very good.

Therefore, this application provides a new congestion control method, where a sending rate of a data flow is actively adjusted based on an active flow quantity and rated receiving bandwidth of a receive end, so that actual receiving bandwidth of the receive end can reach the rated receiving bandwidth, and the receive end can reach a full throughput state, thereby improving transmission efficiency of the data flow.

<FIG> is a schematic flowchart of a congestion control method according to an embodiment of this application. The method shown in <FIG> may be applied to networks such as a data center network and a metropolitan area network. A first network device and a second network device are devices in these networks. The method shown in <FIG> includes step <NUM> to step <NUM>. These steps are described in detail below.

The second network device sends a first message to the first network device, and the first network device receives the first message.

The first message carries an active flow quantity, where the active flow quantity is determined by the second network device based on a data flow to which data packets received from the first network device belong.

It should be understood that the term "active flow" may be a definition of the second network device for a data flow. For the second network device, an active flow may be a data flow in which data packets are transmitted relatively frequently, and an inactive flow may be considered as a data flow in which data packets are transmitted at a longer time interval (for example, a data flow transmits one data packet for a long time, and such a data flow may be considered as an inactive flow). Therefore, for the second network device, data flows received by the second network device may fall into two types: active flows and inactive flows.

In addition, the active flow quantity may refer to a quantity of data flows in which data packets are being transmitted within a certain statistical period. Specifically, the active flow quantity may be a quantity of data flows that is determined by the second network device based on a data flow to which data packets received from the first network device within a statistical period belong.

Optionally, before step <NUM>, the first network device sends a data flow to the second network device, and the second network device receives the data flow sent by the first network device.

When sending a data flow to the second network device, the first network device may send data packets to the second network device in groups. Each group of data packets includes the initial packet and the tail packet, and a data packet between the initial packet and the tail packet have different identifiers. The second network device may identify the initial packet and the tail packet in a group of data packets based on these identifiers, and then count the active flow quantity based on the initial packet and the tail packet of each group of data packets received, so as to obtain the active flow quantity (details about counting the active flow quantity are described in the method shown in <FIG>).

It should be understood that before the first network device controls a sending rate of the data flow by using the congestion control method shown in <FIG>, the data flow may be sent to the second network device at an initial rate. The initial rate may be defined by using the following two methods:
Method <NUM>: The first network device determines the rated receiving bandwidth of the second network device as the initial rate, and sends the data flow to the second network device based on the rated receiving bandwidth within T.

T is a period from a time when a request packet is sent from the first network device (the request packet is used to request the second network device to receive a data flow sent by the first network device) to a time when the first network device receives a response packet that is specific to the request packet and that is sent by the second network device.

Method <NUM>: The initial rate is an initial sending rate per flow that is defined based on remote direct memory access over converged Ethernet version <NUM> (RoCEv2).

Specifically, in a possible implementation, the initial rate may be a maximum sending rate allowed by a line card or a sending fabric card of the first network device.

In addition, there are two methods for defining the initial packet and the tail packet in each group of data packets. The first method is to define the initial packet and the tail packet based on the RoCEv2 protocol. Specifically, the data packets may be grouped based on a message (the message is a logical group at an application layer): The first packet of the message is considered as the initial packet, the last packet of the message is considered as the tail packet, and the initial packet and the tail packet may be specifically defined in an opcode field of a base transport header (BTH) of a remote direct memory access over converged Ethernet (RoCE) packet.

In addition to defining the initial packet and the tail packet in the data packets based on the logical group at the application layer, the initial packet and the tail packet of the data packet can also be defined directly based on a segment. Specifically, data packets within a period that are fed back based on the initial rate or the active flow quantity can be grouped into a group, the first packet in the segment is referred to as the initial packet, and the last packet in the segment is referred to as the tail packet. The two fields may be defined in reserved fields (such as an rsvd7 field) in the BTH, and a flag of each field may occupy <NUM> bit.

Optionally, the first message may directly carry a specific active flow quantity, so that the first network device can directly obtain the active flow quantity based on the first message.

The first network device determines, based on the active flow quantity and the rated receiving bandwidth of the second network device, packet sending control information used to send a data flow to the second network device.

The packet sending control information indicates that when the first network device sends a data flow to the second network device based on the packet sending control information, the actual receiving bandwidth of the second network device reaches the rated receiving bandwidth. That is, the packet sending control information is used to control the first network device to send a data flow to the second network device; and when the first network device sends a data flow to the second network device based on the packet sending control information, the actual bandwidth of the second network device can reach the rated receiving bandwidth of the second network device.

The first network device sends a data flow to the second network device based on the packet sending control information, and the second network device receives the data flow based on the rated receiving bandwidth.

In this application, the packet sending control information is determined based on the active flow quantity and the rated receiving bandwidth of the second network device, and the data flow sent from the first network device to the second network device is controlled based on the packet sending control information, so that the second network device can achieve a full throughput state, thereby improving transmission efficiency of the data flow.

When the packet sending control information is determined based on the active flow quantity and the rated receiving bandwidth of the second network device, the packet sending control information may be determined based on the active flow quantity by using different methods.

For example, when the active flow quantity is relatively small, the network has strong tolerance for burst data. In this case, only a maximum data transmission volume of the data flow within a period needs to be controlled. However, when the active flow quantity is relatively large, a plurality of concurrent flows have great impact on the network. To avoid network congestion caused by a large amount of burst data, an allocation period of a network card (the network card is located at a receive end and is responsible for allocating a sending period of data packets) can be controlled, and a single packet is sent per period (that is, a transmission interval between data packets is strictly controlled, and transmission of each data packet can be considered as a period).

In the present invention, when the active flow quantity is less than a first threshold, the first network device determines, based on formula (<NUM>), the packet sending control information used to send a data flow to the second network device.

In formula (<NUM>), C is the rated receiving bandwidth of the second network device, active_qp is the active flow quantity, T is a time required for a data packet of the data flow sent by the first network device to arrive at the second network device, and V is a data volume of the data flow sent by the first network device to the second network device within T.

The packet sending control information is determined based on formula (<NUM>), and the packet sending control information is specifically used to instruct the first network device to send data packets with a data volume V in the data flow to the second network device within T. It should be understood that in this case, the packet sending control information indicates only the data volume of the data packets in the data flow sent within T, but a time interval between data packets is not limited, provided that the data volume of the data packets in the data flow within T reaches V.

After the packet sending control information is obtained based on formula (<NUM>), that the first network device sends a data flow to the second network device based on the packet sending control information includes: The first network device sends data packets with a data volume V in the data flow to the second network device within T.

T may be preset. Specifically, T may be a time for a data packet to arrive at the receive end when the data packet is sent at a specific rate when the network is idle.

Alternatively, T may be specifically a round-trip time (RTT). The RTT indicates a total delay between a time when the transmit end sends data and a time when the transmit end receives an acknowledgement from the receive end (the receive end sends the acknowledgement immediately after receiving the data). The RTT may be obtained by measuring a static delay when the network device is initialized and the network is idle.

In this application, when the active flow quantity is relatively small, the network has strong tolerance to burst data, so that only a maximum data transmission volume of the data flow within a period needs to be controlled, and control on sending of the data flow can be simplified.

Optionally, when the active flow quantity is less than or equal to the first threshold, the first network device determines, based on formula (<NUM>), the packet sending control information used to send a data flow to the second network device.

In formula (<NUM>), 1pkt is a length of a single data packet, active_qp is the active flow quantity, C is the rated receiving bandwidth of the second network device, and "interval" is a time interval between adjacent data packets when the first network device sends a data flow.

The packet sending control information is determined based on formula (<NUM>), and the packet sending control information specifically indicates that a transmission time interval between data packets when the first network device sends each data flow reaches a value indicated by "interval".

After the packet sending control information is obtained based on formula (<NUM>), that the first network device sends a data flow to the second network device based on the packet sending control information includes: The first network device sends a data packet in the data flow to the second network device based on the time interval indicated by "interval".

A derivation process of formula (<NUM>) is as follows:
Bandwidth is divided evenly among all data flows, so that a sending rate of each data flow is <MAT>. A sending rate of each data flow at the transmit end is <MAT>. Formula (<NUM>) can be obtained to enable the receive end to reach the full throughput state, and formula (<NUM>) can be obtained by transforming formula (<NUM>).

In this application, when the active flow quantity is relatively large, a plurality of concurrent flows cause a heavy burden to the network. Impact of the plurality of concurrent flows on the network can be avoided by properly setting the transmission time interval between data packets, so that network congestion can be avoided.

In determining the packet sending control information based on the active flow quantity and the rated receiving bandwidth of the second network device, in addition to determining the packet sending control information for each data flow based on formula (<NUM>) or formula (<NUM>) (in this case, the packet sending control information for each data flow is determined using the same method), the packet sending control information for the data flow may be determined based on a specific situation of the data flow (for example, a priority), in which case packet sending control information obtained for different data flows may be different. A method for determining the packet sending control information for the data flow is described in detail below.

Optionally, that the first network device determines, based on the active flow quantity and the rated receiving bandwidth of the second network device, packet sending control information used to send a data flow to the second network device includes: The first network device determines, based on the active flow quantity, the rated receiving bandwidth of the second network device, and attribute information of the data flow, the packet sending control information used to send the data flow to the second network device.

The attribute information of the data flow includes at least one of application information of the data flow and data volume information of the data flow, the application information of the data flow is used to indicate a service type to which a data packet of the data flow belongs, and the data volume information of the data flow is used to indicate a data volume of data packets that belong to the data flow and that are sent by the first network device within a preset time.

The application information of the data flow may specifically indicate a service type (for example, audio or video) to which the data packet of the data flow belongs, a priority corresponding to the service type, and the like.

In this application, when the packet sending control information of the data flow is determined, the packet sending control information can be properly determined for the data flow based on the attribute information of the data flow.

Optionally, when the active flow quantity is less than the first threshold, the first network device determines, based on formula (<NUM>), the packet sending control information used to send a data flow to the second network device.

In formula (<NUM>), C is the rated receiving bandwidth of the second network device, active_qp is the active flow quantity, T is a time required for a data packet of the data flow sent by the first network device to arrive at the second network device, w is a weight of the data flow, w is determined based on the attribute information of the data flow, and V is a data volume of the data flow sent by the first network device to the second network device within T.

It should be understood that w may be determined based on the application information of the data flow and/or the data volume information of the data flow in the attribute information of the data flow.

Optionally, in formula (<NUM>), the value of w is positively correlated with importance of the service type indicated by the application information of the data flow.

Specifically, higher importance of the service type indicated by the application information of the data flow in formula (<NUM>) indicates a larger value of w.

Optionally, in formula (<NUM>), the value of w is positively correlated with a priority of a service indicated by the application information of the data flow. For example, a higher priority of the service indicated by the application information of the data flow indicates a larger value of w.

Optionally, in formula (<NUM>), the value of w is inversely correlated with a data volume indicated by the data volume information of the data flow. Specifically, a larger data volume indicated by the data volume information of the data flow indicates a smaller value of w.

In this application, when the data transmission volume of the data flow is determined, the data transmission volume can be properly determined for the data flow based on the attribute information of the data flow.

Optionally, when the active flow quantity is greater than or equal to the first threshold, the first network device determines, based on formula (<NUM>), the packet sending control information used to send a data flow to the second network device.

In formula (<NUM>), 1pkt is a length of a single data packet, active_qp is the active flow quantity, w is a weight of the data flow, w is determined based on the attribute information of the data flow, C is the rated receiving bandwidth of the second network device, and "interval" is a time interval between adjacent data packets when the first network device sends the data flow.

Optionally, in formula (<NUM>), the value of w is inversely correlated with importance of the service type indicated by the application information of the data flow.

Specifically, in formula (<NUM>), higher importance of the service type indicated by the application information of the data flow indicates a smaller value of w.

Optionally, in formula (<NUM>), the value of w is inversely correlated with a priority of a service indicated by the application information of the data flow.

For example, a higher priority of the service indicated by the application information of the data flow indicates a smaller value of w.

Optionally, in formula (<NUM>), the value of w is positively correlated with a data volume indicated by the data volume information of the data flow. Specifically, a larger data volume indicated by the data volume information of the data flow indicates a larger value of w.

In this application, when the data packet transmission time interval of the data flow is determined, the data packet transmission time interval can be properly determined for the data flow based on the attribute information of the data flow.

Optionally, when w is determined based on the application information of the data flow in the attribute information of the data flow, w=w1, and a value of w1 is positively correlated with importance of the service type indicated by the application information of the data flow. For example, higher importance of the service type indicated by the application information of the data flow indicates a larger value of w1. In this case, formula (<NUM>) can be transformed into formula (<NUM>). In this case, the packet sending control information used to send the data flow to the second network device may be determined directly based on formula (<NUM>).

In formula (<NUM>), w1 is determined based on the application information of the data flow in the attribute information of the data flow, and other parameters have the same meanings as those in formula (<NUM>).

Optionally, when w is determined based on the data volume information of the data flow, w=w2, and a value of w2 is inversely correlated with the data volume indicated by the data volume information of the data flow. For example, a larger data volume indicated by the data volume information of the data flow indicates a smaller value of w2. In this case, formula (<NUM>) can be transformed into formula (<NUM>). In this case, the packet sending control information used to send the data flow to the second network device may be determined directly based on formula (<NUM>).

In formula (<NUM>), w2 is determined based on the data volume information of the data flow, and other parameters have the same meanings as those in formula (<NUM>).

Optionally, when w may be determined based on the application information of the data flow and the data volume information of the data flow in the attribute information of the data flow, w=w1 x w2, a value of w1 is positively correlated with importance of the service type indicated by the application information of the data flow, and a value of w2 is inversely correlated with the data volume indicated by the data volume information of the data flow. In this case, formula (<NUM>) can be transformed into formula (<NUM>). In this case, the packet sending control information used to send the data flow to the second network device may be determined directly based on formula (<NUM>).

In formula (<NUM>), w1 is determined based on the application information of the data flow in the attribute information of the data flow, w2 is determined based on the data volume information of the data flow, and other parameters have the same meanings as those in formula (<NUM>).

The congestion control method according to the embodiments of the present invention has been described in detail above from the perspective of the transmit end (the first network device) with reference to <FIG>. The congestion control method according to the embodiments of the present invention is described in detail below from the perspective of the receive end (the second network device) with reference to <FIG>.

<FIG> is a schematic flowchart of a congestion control method according to an embodiment of this application. The method shown in <FIG> may also be applied to networks such as a data center network and a metropolitan area network, and a first network device and a second network device are devices in these networks. The method shown in <FIG> includes step <NUM> to step <NUM>. These steps are described in detail below.

The second network device determines an active flow quantity based on a data flow to which data packets received from the first network device belong.

The second network device sends a first message to the first network device, where the first message carries the active flow quantity.

The active flow quantity is used by the first network device to determine packet sending control information used to send a data flow to the second network device, where the packet sending control information indicates that when the first network device sends the data flow to the second network device based on the packet sending control information, actual receiving bandwidth of the second network device reaches rated receiving bandwidth of the second network device.

The second network device receives, based on the rated receiving bandwidth, the data flow sent by the first network device.

It should be understood that step <NUM> to step <NUM> in the method shown in <FIG> correspond to step <NUM> to step <NUM> in the method shown in <FIG>, and the relevant definitions and explanations of step <NUM> to step <NUM> also apply to step <NUM> to step <NUM>. To avoid repetition, details are not described herein again.

Optionally, in an embodiment, that the second network device determines the active flow quantity based on a data flow to which data packets received from the first network device belong includes: The second network device receives the initial packet in a first group of data packets sent by the first network device, and increases a current active flow quantity by <NUM> to obtain a first active flow quantity; the second network device receives the tail packet in the first group of data packets sent by the first network device, and determines a first congestion value based on a quantity of data packets carrying an external congestion notification ECN identifier in the first group of data packets; when the first congestion value is less than a congestion threshold, the second network device decreases the first active flow quantity by <NUM> to obtain a second active flow quantity; and when the first congestion value is greater than or equal to the congestion threshold, the second network device keeps the first active flow quantity unchanged.

Determining of the active flow quantity by the second network device based on a data flow to which data packets received from the first network device belong is described in detail below with reference to <FIG> and <FIG>.

<FIG> is a flowchart of a method for counting an active flow quantity according to an embodiment of this application. A second network device in <FIG> corresponds to the receive end <NUM> or the receive end <NUM> in <FIG>, and is configured to receive a data flow; and a first network device in <FIG> corresponds to the transmit end (the transmit end <NUM>, the transmit end <NUM>, or the transmit end <NUM>) in <FIG>, and is configured to send a data flow. A process shown in <FIG> may include at least step <NUM> to step <NUM>; and further, the process shown in <FIG> may include step <NUM> to step <NUM>. These steps are described in detail below.

The second network device receives the initial packet in a first group of data packets.

In this application, each group of data packets includes a certain quantity of data packets, and each group of data packets includes the initial packet and the tail packet. After receiving a data packet, the second network device may identify whether the data packet is the initial packet or the tail packet by identifying whether the data packet carries an identifier of the initial packet and an identifier of the tail packet.

The identifier of the initial packet and the identifier of the tail packet can be defined using two methods. The two methods are described below.

When this application is applied to an RoCEv2 scenario, data packets may be grouped based on a message as defined by the RoCEv2 protocol. Specifically, the data packets may be grouped based on a message (the message is a logical group at an application layer). The first packet of the message is considered as the initial packet, the last packet of the message is considered as the tail packet, and the initial packet and the tail packet may be specifically defined in an opcode field of a base transport header (BTH) of an RoCEv2 packet.

Data packets may be grouped based on a segment. Specifically, corresponding data packets within a period that are fed back based on an initial rate or the active flow quantity may be grouped into a group, the first packet in the segment is referred to as the initial packet, and the last packet in the segment is referred to as the tail packet. The two fields may be defined in reserved fields (such as an rsvd7 field) in the BTH, and a flag of each field may occupy <NUM> bit.

The second network device increases a current active flow quantity by <NUM> to obtain a first active flow quantity.

The current active flow quantity in step <NUM> is a quantity of active flows counted by the second network device before receiving the initial packet in the first group of data packets. When receiving the initial packet in the first group of data packets, the second network device needs to update the active flow quantity, that is, to increase the active flow quantity counted before receiving the initial packet in the first group of data packets by <NUM>.

The second network device receives the tail packet in the first group of data packets.

It should be understood that the initial packet in the first group of data packets may be the first packet in the first group of data packets received by the second network device, and the tail packet in the first group of data packets may be the last packet in the first group of data packets received by the second network device. A quantity of data packets included in each group of data packets may be preset.

In addition, each data packet may carry an identifier in a certain field, and a value of the identifier is used to indicate a type of the data packet (specifically, the initial packet, the tail packet, or a data packet between the initial packet and the tail packet).

Optionally, each data packet further includes a data packet identifier, where the data packet identifier is used to indicate a type of the data packet. Specifically, a value of the identifier may be used to indicate that the data packet is the initial packet, the tail packet, or a data packet between the initial packet and the tail packet in a group of data packets.

Specifically, the data packet identifier may be carried in a packet header or a payload of a packet, or the data packet identifier may be carried in a field outside the packet, and the field carrying the data packet identifier is transmitted together with the packet, so that the first network device can identify the type of the data packet based on the field.

For example, in a scenario based on remote direct memory access over converged Ethernet version <NUM> (RoCEv2), the data packet identifier may be carried in an opcode field in an RoCEv2 packet, or the data packet identifier may be carried in a reserved field (such as an rsvd7 field) in the RoCEv2 packet.

It should be understood that the data packets in the first group of data packets belong to a same data flow.

The second network device determines a first congestion value based on a quantity of data packets carrying an external congestion notification ECN identifier in the first group of data packets, and updates the active flow quantity based on a relationship between the first congestion value and a congestion threshold.

Optionally, in step <NUM>, the first active flow quantity needs to be updated again based on the quantity of data packets carrying the ECN identifier in the first group of data packets. If the first congestion value is less than the congestion threshold, the active flow quantity counted by the second network device after receiving the tail packet in the first group of data packets is a second active flow quantity; and if the first congestion value is greater than or equal to the congestion threshold, the active flow quantity counted by the second network device after receiving the tail packet in the first group of data packets is the first active flow quantity. That is, after the tail packet in the first group of data packets is received, the counted active flow quantity is the first active flow quantity (when the first congestion value is greater than or equal to the congestion threshold) or the second active flow quantity (when the first congestion value is less than the congestion threshold).

Optionally, in an embodiment, determining a first congestion value based on a quantity of data packets carrying an ECN identifier in the first group of data packets includes: determining a ratio of the quantity of data packets carrying the ECN identifier in the first group of data packets to a quantity of data packets in the first group of data packets as the first congestion value.

Specifically, a ratio of a total quantity of data packets carrying the ECN identifier in the first group of data packets to the quantity of data packets in the first group of data packets may be determined as the first congestion value.

For example, the first group of data packets includes a total of <NUM> data packets (including the initial packet and the tail packet), where a total of five data packets carry the ECN identifier, and it may be determined, through calculation, that the first congestion value is <NUM>.

For example, the first group of data packets includes a total of <NUM> data packets (including the initial packet and the tail packet), where eight data packets carry the ECN identifier. Then, it can be determined, through calculation, that the ratio of the total quantity of data packets carrying the ECN identifier to the total quantity of data packets is <NUM>. Assuming that the correction coefficient is <NUM>, the product of the ratio and the correction coefficient, that is, <NUM>, is the first congestion value.

Optionally, before step <NUM>, the process shown in <FIG> further includes: determining that a data flow including the first group of data packets is a first data flow, where the first data flow is a data flow in which a quantity of data packets received by the second network device within a preset time is greater than a preset quantity.

The first data flow may be considered as a large data flow. In this application, the active flow quantity is counted only for the first data flow (for a large data flow, the active flow quantity can be properly counted using the solution in this application), so that the solution for counting the active flow quantity in this application is more targeted.

Specifically, because a small data flow includes a small quantity of data packets, network congestion has little impact on the small data flow; because a large data flow includes a large quantity of data packets, network congestion has great impact on the large data flow. Therefore, for a small data flow, the active flow quantity does not need to be counted (that is, a small data flow is not considered as an active flow even if data packets can be received); and for a large data flow, the active flow quantity can be counted using the solution of this application.

Step <NUM> to step <NUM> only show the case of counting the active flow quantity based on a group of data packets. Actually, the method for counting the active flow quantity according to the embodiment of this application can also be used to count the active flow quantity based on a plurality of groups of data packets.

Optionally, in the process shown in <FIG>, after receiving the first group of data packets and updating the active flow quantity through step <NUM> to step <NUM>, the second network device may further receive a second group of data packets and update the active flow quantity again based on the received second group of data packets.

The second network device receives the initial packet in the second group of data packets.

It should be understood that the second group of data packets and the first group of data packets belong to a same data flow, and the second group of data packets may be a group of data packets received by the second network device after receiving the first group of data packets; and specifically, the second group of data packets and the first group of data packets may be two consecutive groups of data packets in the data flow (that is, the second group of data packets is the next group of data packets received by the second network device immediately after receiving the first group of data packets).

The second network device increases the current active flow quantity by <NUM> to obtain a fourth active flow quantity.

The second network device receives the tail packet in the second group of data packets.

A specific process of step <NUM> to step <NUM> is similar to the specific process of step <NUM> to step <NUM>.

The second network device determines a second congestion value based on a quantity of data packets carrying the external congestion notification ECN identifier in the second group of data packets, and updates the active flow quantity based on a relationship between the second congestion value and the congestion threshold.

After the initial packet in the second group of data packets is received, the initial packet in the second group of data packets may be processed in a manner similar to that of the initial packet in the first group of data packets; and after the tail packet in the second group of data packets is received, the second congestion value is determined based on both the quantity of data packets carrying the ECN identifier in the second group of data packets and the first congestion value, so that the second congestion value does not change too much, and a slowly changing congestion value is obtained.

For example, the first group of data packets and the second group of data packets each include <NUM> data packets, where four data packets in the first group of data packets carry the ECN identifier and six data packets in the second group of data packets carry the ECN identifier. Then, the total quantity of data packets carrying the ECN identifier in the first group of data packets and the second group of data packets is <NUM>, and the total quantity of data packets in the first group of data packets and the second group of data packets is <NUM>; then, the second congestion value is <NUM>/<NUM> = <NUM>.

It should be understood that the second congestion value may be alternatively obtained as follows: obtaining a congestion value based on the quantity of data packets carrying the ECN identifier in the first group of data packets, obtaining another congestion value based on the quantity of data packets carrying the ECN identifier in the second group of data packets, and then performing weighted summation on the two congestion values.

Optionally, in an embodiment, determining the second congestion value of the network based on the quantity of data packets carrying the ECN identifier in the second group of data packets and the first congestion value includes: determining a third congestion value of the network based on the quantity of data packets carrying the ECN identifier in the second group of data packets; and determining the second congestion value based on formula (<NUM>).

In formula (<NUM>), con3 is the third congestion value, con1 is the first congestion value, con2 is the second congestion value, x1 is a preset first weight, and x2 is a preset second weight.

It should be understood that, in this application, each time the second network device receives the initial packet in a group of data packets (for example, the first group of data packets or the second group of data packets), the current active flow quantity needs to be increased by <NUM>; each time the second network device receives the tail packet in a group of data packets, the active flow quantity needs to be adjusted based on the quantity of data packets carrying the ECN identifier in the group of data packets (the active flow quantity is decreased by <NUM> or kept unchanged), so that the active flow quantity is updated in real time.

For a better understanding of the technical solutions in this application, the method for counting the active data flow quantity according to the embodiments of this application is described below from the perspective of the second network device.

<FIG> is a flowchart of a method for counting an active flow quantity according to an embodiment of this application. A process shown in <FIG> may include at least step <NUM> to step <NUM>; and further, the process shown in <FIG> may include step <NUM> to step <NUM>. These steps are described in detail below.

Step <NUM> indicates that counting of the active flow quantity is started. Step <NUM> may occur after one group of data packets is received and the active flow quantity is updated and before another group of data packets are received.

The second network device receives the initial packet in a first group of data packets sent by the first network device, and executes counter++.

A counter is the current active flow quantity counted by the second network device. Specifically, the counter is a quantity of currently active data flows counted by the second network device when the second network device receives the initial packet in the first group of data packets sent by the first network device.

A counter obtained after counter++ is executed in step <NUM> is the active flow quantity after the initial packet in the first group of data packets is received and the current active flow quantity is updated. The counter obtained after counter++ is executed corresponds to the first active flow quantity obtained in step <NUM>.

The second network device receives the tail packet in the first group of data packets, and determines a first congestion value based on a quantity of data packets carrying an external congestion notification ECN identifier in the first group of data packets.

Determine whether the first congestion value is greater than a congestion threshold.

When the first congestion value is less than or equal to the congestion threshold, it indicates that a congestion degree of a network is relatively low. In this case, the current active flow quantity needs to be decreased by <NUM>, that is, step <NUM> is performed. When the first congestion value is greater than or equal to the congestion threshold, it indicates that network congestion is serious. In this case, the current active flow quantity needs to be kept unchanged, that is, step <NUM> is performed.

In step <NUM>, a counter obtained by executing counter-- corresponds to the foregoing second active flow quantity.

In step <NUM>, the counter corresponds to the foregoing first active flow quantity.

The second network device receives the initial packet in a second group of data packets sent by the first network device, and executes counter++.

A counter obtained after counter++ is executed in step <NUM> corresponds to the foregoing fourth active flow quantity.

The second network device receives the tail packet in the second group of data packets, and determines a second congestion value based on the quantity of data packets carrying the ECN identifier in the first group of data packets and a quantity of data packets carrying the ECN identifier in the second group of data packets.

Determine whether the second congestion value is greater than the congestion threshold.

When the second congestion value is less than or equal to the congestion threshold, it indicates that the congestion degree of the network is relatively low. In this case, the current active flow quantity needs to be decreased by <NUM>, that is, step <NUM> is performed. When the second congestion value is greater than or equal to the congestion threshold, it indicates that the network congestion is serious. In this case, the current active flow quantity needs to be kept unchanged, that is, step <NUM> is performed.

In step <NUM>, a counter obtained by executing counter-- corresponds to the foregoing fifth active flow quantity.

In step <NUM>, the counter corresponds to the foregoing fourth active flow quantity.

It should be understood that, in step <NUM> to step <NUM> of the process shown in <FIG>, the counter indicates the current active flow quantity, and an addition operation or a subtraction operation needs to be performed on the counter through different operation steps, or the counter is kept unchanged, so as to count the current active flow quantity in real time.

The congestion control methods according to the embodiments of this application have been described in detail above with reference to <FIG>. Network devices according to the embodiments of this application are described in detail below with reference to <FIG>. It should be understood that the network devices shown in <FIG> can perform the congestion control methods according to the embodiments of this application (a network device <NUM> shown in <FIG> corresponds to the foregoing first network device, and the network device <NUM> can perform the steps performed by the foregoing first network device; and a network device <NUM> shown in <FIG> corresponds to the foregoing second network device, and the network device <NUM> can perform the steps performed by the foregoing second network device). For brevity, repeated descriptions are appropriately omitted when the network devices shown in <FIG> are described.

<FIG> is a schematic block diagram of a network device according to an embodiment of this application. The network device <NUM> in <FIG> includes:.

The processing module <NUM> is configured to: when the active flow quantity is less than a first threshold, determine, based on the following formula, the packet sending control information used to send a data flow to the second network device: <MAT> where C is the rated receiving bandwidth of the second network device, active_qp is the active flow quantity, T is a time required for a data packet of the data flow sent by the first network device to arrive at the second network device, and V is a data volume of the data flow sent by the first network device to the second network device within T.

The sending module <NUM> is configured to send data packets with a data volume V in the data flow to the second network device within T.

Optionally, in an embodiment, the processing module <NUM> is configured to: when the active flow quantity is greater than or equal to the first threshold, determine, based on the following formula, the packet sending control information used to send a data flow to the second network device: <MAT> where 1pkt is a length of a single data packet, active_qp is the active flow quantity, C is the rated receiving bandwidth of the second network device, and "interval" is a time interval between adjacent data packets when the first network device sends the data flow.

The sending module <NUM> is configured to send the data packet in the data flow to the second network device based on the time interval indicated by "interval".

Optionally, the processing module <NUM> is configured to determine, based on the active flow quantity, the rated receiving bandwidth of the second network device, and attribute information of the data flow, the packet sending control information used to send the data flow to the second network device, where the attribute information of the data flow includes at least one of application information of the data flow and data volume information of the data flow, the application information of the data flow is used to indicate a service type to which the data packet of the data flow belongs, and the data volume information of the data flow is used to indicate a data volume of data packets that belong to the data flow and that are sent by the first network device within a preset time.

Optionally, the processing module <NUM> is configured to: when the active flow quantity is less than a first threshold, determine, based on the following formula, the packet sending control information used to send a data flow to the second network device: <MAT> where C is the rated receiving bandwidth of the second network device, active_qp is the active flow quantity, T is a time required for a data packet of the data flow sent by the first network device to arrive at the second network device, w is a weight of the data flow, w is determined based on the attribute information of the data flow, and V is a data volume of the data flow sent by the first network device to the second network device within T.

Optionally, the processing module <NUM> is configured to: when the active flow quantity is greater than or equal to the first threshold, determine, based on the following formula, the packet sending control information used to send a data flow to the second network device: <MAT> where 1pkt is a length of a single data packet, active_qp is the active flow quantity, w is a weight of the data flow, w is determined based on the attribute information of the data flow, C is the rated receiving bandwidth of the second network device, and "interval" is a time interval between adjacent data packets when the first network device sends the data flow.

Optionally, in an embodiment, the receiving module <NUM> is configured to receive the initial packet in a first group of data packets sent by the first network device; the processing module <NUM> is configured to increase a current active flow quantity by <NUM> to obtain a first active flow quantity; the receiving module <NUM> is configured to receive the tail packet in the first group of data packets sent by the first network device; the processing module <NUM> is configured to: determine a first congestion value based on a quantity of data packets carrying an external congestion notification ECN identifier in the first group of data packets; when the first congestion value is less than a congestion threshold, the second network device decreases the first active flow quantity by <NUM> to obtain a second active flow quantity; and when the first congestion value is greater than or equal to the congestion threshold, the second network device keeps the first active flow quantity unchanged.

Optionally, in an embodiment, the processing module <NUM> is configured to determine a ratio of the quantity of data packets carrying the ECN identifier in the first group of data packets to a quantity of data packets in the first group of data packets as the first congestion value.

Optionally, in an embodiment, after the receiving module <NUM> receives the tail packet in the first group of data packets sent by the first network device, the receiving module <NUM> is further configured to receive the initial packet in a second group of data packets sent by the first network device. The processing module <NUM> is configured to: increase a third active flow quantity by <NUM> to obtain a fourth active flow quantity, where the second group of data packets and the first group of data packets belong to a same data flow; when the first congestion value is less than a congestion threshold, the third active flow quantity is equal to the second active flow quantity; and when the first congestion value is greater than or equal to the congestion threshold, the third active flow quantity is equal to the first active flow quantity.

The receiving module <NUM> is configured to receive the tail packet in the second group of data packets sent by the first network device. The processing module <NUM> is further configured to: determine a second congestion value of the network based on a quantity of data packets carrying the ECN identifier in the second group of data packets and the first congestion value; when the second congestion value is less than the congestion threshold, the second network device decreases the fourth active flow quantity by <NUM> to obtain a fifth active flow quantity; and when the second congestion value is greater than or equal to the congestion threshold, the second network device keeps the fourth active flow quantity unchanged.

Optionally, in an embodiment, the processing module <NUM> is configured to: determine a third congestion value of the network based on the quantity of data packets carrying the ECN identifier in the second group of data packets; and determine the second congestion value based on the formula con2=x1*con3+x2*con1, where con3 is the third congestion value, con1 is the first congestion value, con2 is the second congestion value, x1 is a preset first weight, and x2 is a preset second weight.

<FIG> is a schematic block diagram of a network device according to an embodiment of this application.

A network device <NUM> in <FIG> includes a memory <NUM>, a transceiver <NUM>, and a processor <NUM>. The processor <NUM> may be a central processing unit (CPU), a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or another programmable logical device, a transistor logical device, a hardware component, or any combination thereof. The memory <NUM> is configured to store a program, and the processor <NUM> may execute the program stored in the memory <NUM>. When the program stored in the memory <NUM> is executed by the processor <NUM>, the processor <NUM> is configured to perform the congestion control method according to the embodiments of this application. Specifically, the transceiver <NUM> and the processor <NUM> may be configured to perform the foregoing steps performed by the first network device or the second network device.

When the functions are implemented in the form of a software functional unit and sold or used as an independent product, the functions may be stored in a computer-readable storage medium. Based on such an understanding, the technical solutions of this application essentially, or the part contributing to the prior art, or some of the technical solutions may be implemented in a form of a software product. The software product is stored in a storage medium, and includes several instructions for instructing a computer device (which may be a personal computer, a server, or a network device) to perform all or some of the steps of the methods described in the embodiments of this application. The foregoing storage medium includes: any medium that can store program code, such as a USB flash drive, a removable hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disc.

Claim 1:
A congestion control method, wherein the method is applied to a data center network, the data center network comprises a first network device and a second network device, the first network device is configured to send a data flow to the second network device, and the method comprises:
receiving (<NUM>), by the first network device, a first message sent by the second network device, wherein the first message carries an active flow quantity, and the active flow quantity is a quantity determined by the second network device based on a data flow to which data packets received from the first network device belong;
determining (<NUM>), by the first network device based on the active flow quantity and rated receiving bandwidth of the second network device, packet sending control information used to send the data flow to the second network device, wherein the packet sending control information indicates that: when the first network device sends the data flow to the second network device based on the packet sending control information, actual receiving bandwidth of the second network device reaches the rated receiving bandwidth; and
sending (<NUM>), by the first network device based on the packet sending control information, the data flow to the second network device,
wherein the determining (<NUM>), by the first network device based on the active flow quantity and rated receiving bandwidth of the second network device, packet sending control information used to send the data flow to the second network device comprises:
when the active flow quantity is less than a first threshold, determining, by the first network device based on the following formula, the packet sending control information used to send the data flow to the second network device: <MAT>
wherein C is the rated receiving bandwidth of the second network device, active_qp is the active flow quantity, T is a time required for a data packet sent by the first network device to the second network device to arrive at the second network device when the network is idle, and V is a data volume of the data flow sent by the first network device to the second network device within T; and
the sending, by the first network device based on the packet sending control information, the data flow to the second network device comprises:
sending (<NUM>), by the first network device, data packets with a data volume V in the data flow to the second network device within T.