TECHNICAL FIELD

This application relates to the communications field, and more specifically, to a flow control method and an apparatus.

BACKGROUND

To support different bandwidth and latency requirements of different applications that are increasingly evolving, a data center network needs to meet both a high network throughput requirement and a low network latency requirement. However, a network throughput and network latency are two mutually constrained indicators.

As shown inFIG. 1, when network load is relatively low, there is a basic linear relationship between growth of a network throughput and network load. As the network load increases, growth of network latency is relatively slow. When the network load is greater than or equal to a network optimal point, as the network load increases, the network throughput increases very slowly, but the network latency increases rapidly. When the network load is greater than or equal to a network saturation point, the network throughput drops sharply, and the latency rises sharply accordingly.

The network saturation point is maximum load of a network. When the network load is greater than or equal to the network saturation point, severe network congestion occurs. The network congestion may cause data packet loss, and further cause packet retransmission. Consequently, the network throughput decreases and the network latency increases sharply.

An objective of network flow control is to maximize the network throughput as much as possible and maintain relatively low network latency.

Generally, network flow control may be classified into passive flow control and active flow control. In a passive flow control mode, a source node pushes data to a target node. The source node obtains a congestion feedback after network congestion occurs, and then starts to limit flow input by the source node. Latency of this type of flow control is low. However, because flow is controlled only after network congestion occurs, congestion packet loss is likely to occur. This causes a decrease in network throughput. The passive flow control mode is more suitable for an underloaded application scenario with a low network throughput.

In an active flow control mode, before sending data to the target node, the source node first needs to request, from the target node, a volume of data for sending. After obtaining an authorized data volume returned by the target node, the source node starts to send data. Therefore, packet loss during network congestion can be avoided to some extent. However, in this flow control mode, a negotiation procedure needs to be performed in advance. Therefore, network latency is increased. The active flow control mode is suitable for ensuring a network throughput under overloading.

SUMMARY

This application provides a flow control method and an apparatus, so as to improve a network throughput and reduce network latency, and further reduce a probability of packet loss caused by network congestion.

According to a first aspect, a flow control method is provided, including: sending, by a first device, a first data packet to a second device in a first sending mode; determining, by the first device, a network congestion status; and sending, by the first device, a second data packet to the second device in the second sending mode, where the second sending mode is a sending mode determined by the first device based on the network congestion status, and the second data packet is a data packet to be sent after the first data packet.

The first device determines a current network congestion status in real time, and adjusts, in real time based on the current network congestion status, a sending mode for sending a data packet to the second device, so that the first device improves a network throughput and reduces network latency, and a probability of packet loss caused by network congestion can be reduced.

With reference to the first aspect, in a possible implementation of the first aspect, the first sending mode is a push mode, the second sending mode is a request-response mode, the first data packet carries first indication information, and the first indication information is used to indicate that the first data packet is a data packet sent in the push mode.

With reference to the first aspect, in a possible implementation of the first aspect, the sending, by the first device, a second data packet to the second device in the second sending mode includes: when the network is in a congested state, sending, by the first device, request information to the second device, where the request information is used to request the second device to allocate a data volume to the first device; and sending, by the first device, the second data packet to the second device by using the data volume allocated by the second device.

After sending the first data packet to the second device in the push mode, the first device determines the network congestion status. When the network is in the congested state, the first device sends a data packet to the second device in the request-response mode, so that the first device improves a network throughput and reduces network latency, and a probability of packet loss caused by network congestion can be reduced.

With reference to the first aspect, in a possible implementation of the first aspect, after the sending, by a first device, a first data packet to a second device in a first sending mode, the method further includes: receiving, by the first device, acknowledgement information sent by the second device, where the acknowledgement information is used to indicate that the second device successfully receives the first data packet; and the determining, by the first device, a network congestion status includes: determining, by the first device, a quantity of data packets that are in sent data packets and for which no acknowledgement information is received; determining, by the first device, the network congestion status based on the quantity of data packets for which no acknowledgement information is received, where the sent data packets include the first data packet; and if the quantity of data packets for which no acknowledgement information is received is greater than or equal to a preset first threshold, determining, by the first device, that the network is in the congested state.

The first device determines the network congestion status based on the quantity of data packets for which no acknowledgement information is received, and the first device sends the data packet to the second device in the request-response mode when the network is in the congested state, so that the first device improves a network throughput and reduces network latency, and a probability of packet loss caused by network congestion can be reduced.

With reference to the first aspect, in a possible implementation of the first aspect, the acknowledgement information carries a sending time point at which the first device sends the first data packet, and the method further includes: determining, by the first device, a receiving time point of the acknowledgement information; and determining, by the first device, the first threshold based on a difference between the receiving time point of the acknowledgement information and the sending time point of the first data packet.

With reference to the first aspect, in a possible implementation of the first aspect, the acknowledgement information carries a count value N, N≥1, and the count value N is used to indicate that first N data packets sent by the first device are all successfully received by the second device.

The acknowledgement information carries the count value N, so that the first device determines, based on the count value N carried in the acknowledgement information, that the received acknowledgement information is about acknowledgement performed by the second device for one data packet or more data packets. In this case, the first device can further determine the quantity of data packets for which no acknowledgement information is received.

Optionally, the second device may indicate, by using one piece of acknowledgement information that carries a count value, that a plurality of data packets sent by the first device are all successfully received.

The second device performs acknowledgement once for a plurality of data packets sent by the first device, so that occupation of network bandwidth by the acknowledgement information can be reduced. In addition, a count value is carried in the acknowledgement information, so that a case in which a piece of acknowledgement information sent by the second device is lost in a transmission process can be tolerated.

With reference to the first aspect, in a possible implementation of the first aspect, the first sending mode is a request-response mode, and the second sending mode is a push mode.

With reference to the first aspect, in a possible implementation of the first aspect, the sending, by the first device, a second data packet to the second device in the second sending mode includes: when the network is not in a congested state, sending, by the first device, the second data packet to the second device in the second sending mode.

The first device determines the network congestion status, and the first device sends the data packet to the second device in the push mode when the network is not in the congested state, so that the first device improves a network throughput and reduces network latency, and a probability of packet loss caused by network congestion can be reduced.

According to a second aspect, a flow control method is provided, including: receiving, by a second device, a first data packet sent by a first device in a first sending mode; and receiving, by the second device, a second data packet sent by the first device in a second sending mode, where the second sending mode is a sending mode determined by the first device based on the network congestion status, and the second data packet is a data packet to be sent after the first data packet.

The first device determines a current network congestion status in real time, and adjusts, in real time based on the current network congestion status, a sending mode for sending a data packet to the second device, so that the first device improves a network throughput and reduces network latency, and a probability of packet loss caused by network congestion can be reduced.

With reference to the second aspect, in a possible implementation of the second aspect, the first sending mode is a push mode, the second sending mode is a request-response mode, the first data packet carries first indication information, and the first indication information is used to indicate that the first data packet is a data packet sent in the push mode.

With reference to the second aspect, in a possible implementation of the second aspect, the method further includes: receiving, by the second device, request information sent by the first device, where the request information is used to request the second device to allocate a data volume to the first device, and the data volume is used by the first device to send the second data packet to the second device; and allocating, by the second device, the data volume to the first device based on the request information.

After sending the first data packet to the second device in the push mode, the first device determines the network congestion status. When a network is in a congested state, the first device sends a data packet to the second device in the request-response mode, so that the first device improves a network throughput and reduces network latency, and a probability of packet loss caused by network congestion can be reduced.

With reference to the second aspect, in a possible implementation of the second aspect, after the receiving, by a second device, a first data packet sent by a first device in a first sending mode, the method further includes: sending, by the second device, acknowledgement information to the first device, where the acknowledgement information is used to indicate that the second device successfully receives the first data packet.

The second device sends the acknowledgement information to the first device, so that the first device can determine the network congestion status based on a quantity of data packets for which no acknowledgement information is received, and the first device sends a data packet to the second device in the request-response mode when the network is in the congested state, so that the first device improves a network throughput and reduces network latency, and a probability of packet loss caused by network congestion can be reduced.

With reference to the second aspect, in a possible implementation of the second aspect, the acknowledgement information carries a sending time point at which the first device sends the first data packet.

With reference to the second aspect, in a possible implementation of the second aspect, the acknowledgement information carries a count value N, N≥1, and the count value N is used to indicate that first N data packets sent by the first device are all successfully received by the second device.

The acknowledgement information carries the count value N, so that the first device determines, based on the count value N carried in the acknowledgement information, that the received acknowledgement information is about acknowledgement performed by the second device for one data packet or more data packets. In this case, the first device can further determine the quantity of data packets for which no acknowledgement information is received.

Optionally, the second device may indicate, by using one piece of acknowledgement information that carries a count value, that a plurality of data packets sent by the first device are all successfully received.

The second device performs acknowledgement once for a plurality of data packets sent by the first device, so that occupation of network bandwidth by the acknowledgement information can be reduced. In addition, a count value is carried in the acknowledgement information, so that a case in which a piece of acknowledgement information sent by the second device is lost in a transmission process can be tolerated.

With reference to the second aspect, in a possible implementation of the second aspect, the first sending mode is a request-response mode, and the second sending mode is a push mode.

According to the flow control method in this embodiment of this application, the first device evaluates the congestion status of the network, and sends a data packet in the push mode when the network is underloaded, so as to reduce network latency; and sends a data packet in the request-response mode when network overload causes serious congestion, so as to alleviate a congestion degree of the network and improve a network throughput. The data packet sending mode is dynamically switched, so that all devices in the network transmit data packets in the push mode when the network is underloaded, some devices in the network transmit data packets in the request-response mode when the network is slightly congested, and all the devices in the network transmit data packets in the request-response mode when the network overload causes serious congestion, thereby implementing a relatively high network throughput and reducing network latency.

According to a third aspect, a flow control method is provided. The method is applied to a transmission scenario that includes at least two sending modes. The at least two sending modes are a push mode and a request-response mode. The method includes: determining, by a first device, a network congestion status; determining, by the first device based on the network congestion status, a sending mode of a target data packet to be sent to a second device, where the sending mode of the target data packet is the push mode or the request-response mode; and

sending, by the first device, the target data packet to the second device in the sending mode of the target data packet.

The first device determines a current network congestion status in real time, and determines, in real time based on the current network congestion status, a sending mode for sending a data packet to the second device, so that the first device improves a network throughput and reduces network latency, and a probability of packet loss caused by network congestion can be reduced.

With reference to the third aspect, in a possible implementation of the third aspect, the determining, by the first device based on the network congestion status, a sending mode of a target data packet to be sent to a second device includes: when the network is not in a congested state, sending, by the first device, the target data packet to the second device in the push mode; or when the network is in a congested state, sending, by the first device, the target data packet to the second device in the request-response mode.

The first device determines the network congestion status. The first device sends the data packet to the second device in the push mode when the network is not in the congested state, or the first device sends the data packet to the second device in the request-response mode when the network is in the congested state. The first device determines, based on the network congestion status, a sending mode for sending the data packet to the second device, so that the first device improves a network throughput and reduces network latency, and a probability of packet loss caused by network congestion can be reduced.

With reference to the third aspect, in a possible implementation of the third aspect, the method further includes: receiving, by the first device, acknowledgement information sent by the second device, where the acknowledgement information is used to indicate that the second device successfully receives the target data packet; and the determining, by the first device, a network congestion status includes: determining, by the first device, a quantity of data packets that are in sent data packets and for which no acknowledgement information is received; determining, by the first device, the network congestion status based on the quantity of data packets for which no acknowledgement information is received, where the sent data packets include the target data packet; and if the quantity of data packets for which no acknowledgement information is received is greater than or equal to a preset first threshold, determining, by the first device, that the network is in the congested state.

The first device determines the network congestion status based on the quantity of data packets for which no acknowledgement information is received, and the first device sends the data packet to the second device in the request-response mode when the network is in the congested state, so that the first device improves a network throughput and reduces network latency, and a probability of packet loss caused by network congestion can be reduced.

With reference to the third aspect, in a possible implementation of the third aspect, the acknowledgement information carries a sending time point at which the first device sends the target data packet. The method further includes: determining, by the first device, a receiving time point of the acknowledgement information; and determining, by the first device, the first threshold based on a difference between the receiving time point of the acknowledgement information and the sending time point of the first data packet.

With reference to the third aspect, in a possible implementation of the third aspect, the acknowledgement information carries a count value N, N≥1, and the count value N is used to indicate that first N data packets sent by the first device are all successfully received by the second device.

The acknowledgement information carries the count value N, so that the first device determines, based on the count value N carried in the acknowledgement information, that the received acknowledgement information is about acknowledgement performed by the second device for one data packet or more data packets. In this case, the first device can further determine the quantity of data packets for which no acknowledgement information is received.

Optionally, the second device may indicate, by using one piece of acknowledgement information that carries a count value, that a plurality of data packets sent by the first device are all successfully received.

The second device performs acknowledgement once for a plurality of data packets sent by the first device, so that occupation of network bandwidth by the acknowledgement information can be reduced. In addition, a count value is carried in the acknowledgement information, so that a case in which a piece of acknowledgement information sent by the second device is lost in a transmission process can be tolerated.

According to a fourth aspect, a flow control method is provided. The method is applied to a transmission scenario that includes at least two sending modes. The at least two sending modes are a push mode and a request-response mode. The method includes: receiving, by a second device, the target data packet sent by the first device to the second device in a sending mode of the target data packet, where the sending mode of the target data packet is the push mode or the request-response mode.

The first device determines a current network congestion status in real time, and determines, in real time based on the current network congestion status, a sending mode for sending a data packet to the second device, so that the first device improves a network throughput and reduces network latency, and a probability of packet loss caused by network congestion can be reduced.

With reference to the fourth aspect, in a possible implementation of the fourth aspect, the method further includes: sending, by the second device, acknowledgement information to the first device, where the acknowledgement information is used to indicate that the second device successfully receives the target data packet.

The second device sends the acknowledgement information to the first device, so that the first device can determine the network congestion status based on a quantity of data packets for which no acknowledgement information is received, and the first device sends a data packet to the second device in the request-response mode when a network is in a congested state, so that the first device improves a network throughput and reduces network latency, and a probability of packet loss caused by network congestion can be reduced.

With reference to the fourth aspect, in a possible implementation of the fourth aspect, the acknowledgement information carries a sending time point at which the first device sends the target data packet.

With reference to the fourth aspect, in a possible implementation of the fourth aspect, the acknowledgement information carries a count value N, N≥1, and the count value N is used to indicate that first N data packets sent by the first device are all successfully received by the second device.

The acknowledgement information carries the count value N, so that the first device determines, based on the count value N carried in the acknowledgement information, that the received acknowledgement information is about acknowledgement performed by the second device for one data packet or more data packets. In this case, the first device can further determine the quantity of data packets for which no acknowledgement information is received.

Optionally, the second device may indicate, by using one piece of acknowledgement information that carries a count value, that a plurality of data packets sent by the first device are all successfully received.

The second device performs acknowledgement once for a plurality of data packets sent by the first device, so that occupation of network bandwidth by the acknowledgement information can be reduced. In addition, a count value is carried in the acknowledgement information, so that a case in which a piece of acknowledgement information sent by the second device is lost in a transmission process can be tolerated.

According to a fifth aspect, a first device is provided, and the first device is configured to perform the flow control method in any one of the first aspect or the possible implementations of the first aspect. Specifically, the first device may include a module configured to perform the flow control method in any one of the first aspect or possible implementations of the first aspect.

According to a sixth aspect, a first device is provided. The first device includes a memory and a processor. The memory is configured to store an instruction, and the processor is configured to execute the instruction stored in the memory. The execution of the instruction stored in the memory enables the processor to perform the method in any one of the first aspect or the possible implementations of the first aspect.

According to a seventh aspect, a computer readable storage medium is provided, and a computer program is stored in the computer readable storage medium. The program is executed by a processor to perform the method in any one of the first aspect or the possible implementations of the first aspect.

According to an eighth aspect, a second device is provided, and the second device is configured to perform the flow control method in any one of the second aspect or the possible implementations of the second aspect. Specifically, the second device may include a module configured to perform the flow control method in any one of the second aspect or possible implementations of the second aspect.

According to a ninth aspect, a second device is provided. The second device includes a memory and a processor. The memory is configured to store an instruction, and the processor is configured to execute the instruction stored in the memory. The execution of the instruction stored in the memory enables the processor to perform the method in any one of the second aspect or the possible implementations of the second aspect.

According to a tenth aspect, a computer readable storage medium is provided, and a computer program is stored in the computer readable storage medium. The program is executed by a processor to perform the method in any one of the second aspect or the possible implementations of the second aspect.

