TECHNICAL FIELD

This application relates to the communications field, and in particular, to a method and an apparatus for controlling traffic in a packet-based network.

BACKGROUND

Currently, a packet-based network is based on end-to-end packet transmission provided by the internet protocol (IP). The transmission control protocol (TCP) ensures reliability of the foregoing end-to-end packet transmission process. Therefore, TCP becomes the most widely used transmission protocol in the packet-based network currently. While ensuring transmission reliability, TCP can also implement traffic control by using a sliding window mechanism. In the sliding window mechanism, in a process of establishing a TCP connection between a transmit end and a receive end, the receive end notifies the transmit end of a receive window (rwnd) value of the receive end. The rwnd value is used to indicate a size of a buffer of the receive end. Specifically, the rwnd value may be carried in a window field of a TCP packet header and sent to the transmit end. The transmit end sets a send window (swnd) value of the transmit end based on the rwnd value. The swnd value is less than or equal to a smaller value of the rwnd value and a congestion window (cwnd) value. The cwnd value is used to indicate a maximum in-transit data amount of a TCP flow allowed in the network. The transmit end sends data to the receive end based on the swnd value. The receive end may notify the transmit end of an updated rwnd value based on a buffer capability change of the buffer of the receive end by using an acknowledgement (ACK) message used to acknowledge data receiving. After receiving the updated rwnd value sent by the receive end, the transmit end dynamically adjusts the swnd value of the transmit end, and the transmit end does not send data to the receive end when the rwnd value is adjusted to be close to 0. The method for implementing traffic control by using the sliding window mechanism is to detect a capability of network transmission between the transmit end and the receive end by using an AIMD mechanism. Due to relatively low control precision, this detection mechanism causes network congestion and a relatively long transmission delay.

SUMMARY

Embodiments of this application provide a method and an apparatus for controlling traffic in a packet-based network, to effectively reduce a possibility of network congestion and a transmission delay.

According to a first aspect, a method for controlling traffic in a packet-based network is provided, and the method includes: sending, by a transmit end, a first control packet to a receive end through a control channel, where the first control packet includes a parameter set; receiving, by the transmit end, a second control packet sent by the receive end, where the second control packet includes the parameter set; and after receiving the second control packet including the parameter set, sending, by the transmit end, a first data packet set to the receive end through a data channel, where the first data packet set includes C data packets, C is an integer greater than or equal to 1, and any data packet in the first data packet set includes the parameter set.

In the foregoing method, in a process in which the transmit end sends a data packet, for example, in a process in which the transmit end sends the first data packet set, the transmit end sends the first control packet to detect a congestion status on a transmission link of the first data packet set. After receiving the second control packet corresponding to the first control packet, the transmit end determines that no congestion occurs on the transmission link of the first data packet set and the first data packet set can be sent. The transmit end controls a sending pacing of a data packet by using a control packet. This helps reduce a possibility of link congestion, and therefore can effectively reduce a possibility of network congestion and a transmission delay.

The parameter set is a set of parameters that can be used to identify a traffic flow to which a data packet belongs. In an internet protocol (IP) network, the parameter set includes a 5-tuple, or the parameter set includes a source address and a destination address. The source address is a source media access control (MAC) address or a source IP address. The destination address is a destination MAC address or a destination IP address. In a fiber channel (FC) network, the parameter set includes a source address and a destination address corresponding to an FC. In a possible design, the parameter set includes the 5-tuple and a flow identifier, and the flow identifier is used to identify a traffic flow to which the first data packet set belongs. In another possible design, the parameter set includes the source address, the destination address, and the flow identifier.

The data channel and the control channel are carried on one or more physical links between the transmit end and the receive end. In a possible design, if the data channel and the control channel are carried on one physical link between the transmit end and the receive end, a sum of a bandwidth of the data channel and a bandwidth of the control channel is a bandwidth of the one physical link, and a ratio of the bandwidth of the data channel to the bandwidth of the control channel is a ratio of a sum of packet lengths of the C data packets to a packet length of any control packet. In the foregoing method, the bandwidth ratio is used to enable duration required for sending one control packet to be the same as duration required for sending C data packets. This helps fully use bandwidth resources on the physical link and reduce a transmission delay. In another possible design, if the data channel and the control channel are respectively carried on two physical links between the transmit end and the receive end, a ratio of a bandwidth of a physical link carrying the data channel to a bandwidth of a physical link carrying the control channel is a ratio of a sum of packet lengths of the C data packets to a packet length of any control packet. The physical link carrying the data channel and the physical link carrying the control channel pass through a same node. Therefore, a link status that is of the physical link carrying the control channel and that is detected by sending a control packet can indirectly reflect a link status of the physical link carrying the data channel.

When no control packet is discarded in the network, the second control packet is a control packet obtained after a source address and a destination address of the first control packet are interchanged. When a control packet is discarded in the network, the second control packet may be a control packet obtained after a source address and a destination address of a third control packet are interchanged, and the third control packet is a control packet sent by the transmit end after the transmit end sends the first control packet.

In a possible design, before the sending, by a transmit end, a first control packet to a receive end through a control channel, the method further includes: obtaining, by the transmit end, a packet header of the first control packet based on any data packet in the first data packet set, where the packet header of the first control packet includes the parameter set; and generating, by the transmit end, the first control packet based on the packet header and a preset packet length of the first control packet. In the foregoing method, the transmit end may generate, based on a data packet, a control packet corresponding to the data packet, to control a sending pacing of the data packet by using the generated control packet.

The first control packet may be buffered in a control queue of the transmit end, or the first control packet is not buffered but sent by the transmit end immediately after being generated. When the control queue exists at the transmit end, a control packet in the control queue needs to be sent through the control channel. The first data packet set may be buffered in a data queue of the transmit end, and a data packet in the data queue may be sent through the data channel.

In a possible design, after the receiving, by the transmit end, a second control packet sent by the receive end, the method further includes: sending, by the transmit end, a third control packet through the control channel according to an additive-increase/multiplicative-decrease (AIMD) algorithm, where the third control packet includes the parameter set. If the transmit end does not receive, within preset duration, a control packet fed back by the receive end, for example, if the transmit end does not receive the second control packet within the preset duration, the transmit end may delay sending the third control packet, to control a sending pacing of a data packet. In the foregoing method, in an initial link congestion phase in the packet-based network, the transmit end controls a sending pacing of a data packet by dynamically adjusting a sending pacing of a control packet. This helps reduce a probability of link congestion.

In a possible design, after the sending, by the transmit end, a third control packet through the control channel, the method further includes: receiving, by the transmit end, a fourth control packet sent by the receive end, where the fourth control packet includes the parameter set; and after receiving the fourth control packet including the parameter set, sending, by the transmit end, a second data packet set to the receive end through the data channel, where the second data packet set is after the first data packet set in a traffic flow to which the first data packet set belongs, the second data packet set includes C data packets, and any data packet in the second data packet set includes the parameter set. The C data packets included in the second data packet set are different from the C data packets included in the first data packet set.

In a possible design, the first control packet further includes a round trip time (RTT) and a sequence number, the RTT is duration from a moment at which the transmit end sends the first control packet to a moment at which the transmit end receives the second control packet, and the sequence number is used to identify the first control packet. In the foregoing method, the transmit end may determine, based on whether a sequence number included in the second control packet is consistent with the sequence number included in the first control packet, whether a packet loss occurs in the network. In addition, the transmit end may further start timing after sending the first control packet, and stop timing after receiving the second control packet. When timing duration is greater than the RTT included in the first control packet, the transmit end may determine that a link is in an initial congestion phase, and then may control a sending pacing of the third control packet according to the AIMD algorithm, for example, may delay sending the third control packet. This avoids further link congestion deterioration.

In a possible design, a ratio of a sum of packet lengths of the C data packets to a packet length of the first control packet is a ratio of a bandwidth of the data channel to a bandwidth of the control channel. The C data packets may be the C data packets in the first data packet set, or the C data packets may be the C data packets in the second data packet set. The packet length of the first control packet is a preset packet length used for generating the first control packet.

According to a second aspect, a method for controlling traffic in a packet-based network is provided, and the method includes: sending, by an intermediate node, a control packet at the head of a first control queue based on first duration, where the first duration is obtained based on a committed burst size (CBS) and a first committed information rate (CIR), and the intermediate node is configured to send a packet of a first transmit end to a first receive end in the packet-based network; and sending, by the intermediate node, a first data packet set at the head of a data queue based on the sent control packet, where the first data packet set includes C data packets, and C is an integer greater than or equal to 1.

In the foregoing method, the intermediate node controls a sending pacing of a control packet based on the first duration, so that a sending period of any data packet set in the data queue is the first duration. In the foregoing method, a sending period of any data packet set in the packet-based network is the first duration, and the first duration is a parameter related to a link status. Therefore, when no link congestion occurs, a sending pacing of a data packet is controlled in advance based on the link status. This can effectively reduce a possibility of network congestion and a transmission delay.

In a possible design, the method further includes: receiving, by the intermediate node, a first control packet from the first transmit end, where the first control packet includes a first parameter set; receiving, by the intermediate node, a second control packet sent by a second transmit end in the packet-based network, where the second control packet includes a second parameter set, the second parameter set is different from the first parameter set, and the intermediate node is configured to send a packet of the second transmit end to a second receive end in the packet-based network; and placing, by the intermediate node, the first control packet and the second control packet in the first control queue in a sequence of receiving the first control packet and the second control packet. The intermediate node may receive the second control packet before the intermediate node sends the control packet at the head of the first control queue, or the intermediate node receives the second control packet while sending the control packet at the head of the first control queue.

In a possible design, the C data packets are data packets from the first transmit end, and the data packets from the first transmit end each include the first parameter set; or the C data packets are data packets from the second transmit end, and the data packets from the second transmit end each include the second parameter set.

In a possible design, after the sending, by an intermediate node, a control packet at the head of a first control queue based on first duration, the method further includes: when a sum of packet lengths of data packets that have been buffered in the data queue is greater than or equal to a first threshold and less than a second threshold, obtaining, by the intermediate node, second duration based on the CBS and a second CIR, where the second CIR is less than the first CIR, the first threshold is greater than a sum of packet lengths of the C data packets, and the second threshold is a maximum value of a sum of packet lengths of data packets that can be buffered in the data queue; sending, by the intermediate node, a control packet at the head of the first control queue based on the second duration; and sending, by the intermediate node, a second data packet set at the head of the data queue based on the sent control packet, where the second data packet set includes C data packets. The second duration is greater than the first duration. The data packets included in the second data packet set may be from the first transmit end or the second transmit end. In the foregoing method, after finding that a buffered data packet in the data queue cannot be sent in time, the intermediate node prolongs a sending period of a control packet in the first control queue. Therefore, a transmit end delays receiving a control packet fed back by a receive end, so that the transmit end delays sending C data packets. The intermediate node may send a buffered data packet by using a delayed time. For example, the intermediate node may accelerate sending of the buffered data packet within the delayed time. For example, the intermediate node may send the buffered data packet within the delayed time without triggering by a control packet.

In a possible design, after the sending, by an intermediate node, a control packet at the head of a first control queue based on first duration, the method further includes: when duration in which the data queue is in an idle state reaches a third threshold, obtaining, by the intermediate node, third duration based on the CBS and a third CIR, where the third CIR is greater than the first CIR, the third threshold is a larger value of a first RTT and a second RTT, the first RTT is duration from a moment at which the intermediate node sends the first control packet to a moment at which the intermediate node receives C data packets of which sending is triggered by the first control packet, and the second RTT is duration from a moment at which the intermediate node sends the second control packet to a moment at which the intermediate node receives C data packets of which sending is triggered by the second control packet; sending, by the intermediate node, a control packet at the head of the first control queue based on the third duration; and sending, by the intermediate node, a second data packet set at the head of the data queue based on the sent control packet, where the second data packet set includes C data packets. The third duration is less than the first duration. The data packets included in the second data packet set may be from the first transmit end or the second transmit end. The idle state is a state in which there is no to-be-sent data packet in the data queue. In the foregoing method, if the intermediate node finds that there is no to-be-sent data packet in the data queue within a duration range corresponding to the third threshold, the intermediate node shortens a sending period of a control packet in the first control queue. Therefore, a transmit end accelerates receiving of a control packet fed back by a receive end, so that the transmit end can quickly send C data packets. This helps fully use network bandwidth resources.

In a possible design, after the sending, by an intermediate node, a control packet at the head of a first control queue based on first duration, the method further includes: when a sum of packet lengths of data packets that have been buffered in the data queue is greater than or equal to a second threshold, sending, by the intermediate node, a second data packet set at the head of the data queue, and stopping sending a control packet at the head of the first control queue, where the second data packet set includes C data packets, and the second threshold is a maximum value of a sum of packet lengths of data packets that can be buffered in the data queue. In the foregoing method, after a quantity of buffered data packets in the data queue that are sent by the intermediate node reaches a buffer upper limit, the intermediate node stops sending a control packet in the first control queue. This prevents a data packet sent by a transmit end from being discarded because the data packet cannot be buffered in the data queue of the intermediate node.

In a possible design, before the sending, by an intermediate node, a control packet at the head of a first control queue based on first duration, the method further includes: receiving, by the intermediate node, a first control packet from the first transmit end, and placing the first control packet in the first control queue, where the first control packet includes a first parameter set; and receiving, by the intermediate node, a second control packet from a second transmit end, and placing the second control packet in a second control queue, where a priority of the second control queue is lower than a priority of the first control queue, the second control packet includes a second parameter set, the second parameter set is different from the first parameter set, and the intermediate node is configured to send a packet of the second transmit end to a second receive end in the packet-based network. The sending, by an intermediate node, a control packet at the head of a first control queue based on first duration includes: sending, by the intermediate node based on the priority of the first control queue and the priority of the second control queue, a control packet in the first control queue or a control packet in the second control queue according to a priority scheduling policy after the first duration expires, where the priority scheduling policy is priority queuing (PQ) or weighted fair queuing (WFQ). In the foregoing method, priorities are set for different control queues, so that a data packet of a traffic flow having a low delay requirement can be preferentially sent, and the traffic flow having a low delay requirement cannot be sent.

In a possible design, the first control packet includes the first parameter set, the first RTT, and C sequence numbers, the first RTT is the duration from the moment at which the intermediate node sends the first control packet to the moment at which the intermediate node receives the C data packets of which sending is triggered by the first control packet, and before the sending, by an intermediate node, a control packet at the head of a first control queue based on first duration, the method further includes: when the data queue includes a free and unreserved storage space and a registration table of the intermediate node includes C unoccupied entries, determining, by the intermediate node, to reserve a first storage space, where the first storage space is used to buffer the C data packets of which sending is triggered by the first control packet; generating, by the intermediate node, C identifiers based on the first parameter set and the C sequence numbers, where an ithidentifier in the C identifiers is an identifier generated based on the first parameter set and an ithsequence number in the C sequence numbers, and i is an integer that ranges from 1 to C; and writing, by the intermediate node, the first RTT and the C identifiers into the C unoccupied entries, where an ithentry in the C entries includes the first RTT and the ithidentifier. In the foregoing method, the intermediate node reserves a specific storage space before sending a control packet. Therefore, C data packets of which sending is triggered by the sent control packet can be prevented from being discarded because the C data packets cannot be buffered when the C data packets reach the intermediate node. This helps reduce a possibility of discarding a data packet.

When the intermediate node has a function of dynamically adjusting a sending period of a control packet and has the foregoing function of reserving a storage space, the sum of the packet lengths of the data packets that have been buffered in the data queue of the intermediate node may be a sum of packet lengths of data packets placed in the data queue, or may be a sum of packet lengths of data packets corresponding to the first storage space. The duration in which the data queue of the intermediate node is in an idle state is duration in which no reserved storage space exists and no data packet is buffered in the data queue of the intermediate node.

In a possible design, after the writing, by the intermediate node, the first RTT and the C identifiers into the C unoccupied entries, the method further includes: setting, by the intermediate node, an ithtimer for the ithentry in the C entries, where duration of the ithtimer is the first RTT; and if the intermediate node does not receive an ithdata packet before the ithtimer expires, releasing, by the intermediate node, the ithentry in the C entries and a storage space that is reserved for the ithdata packet in the first storage space, where the ithdata packet is any one of the C data packets of which sending is triggered by the first control packet, and the ithdata packet includes the first parameter set and the ithsequence number. In the foregoing method, the intermediate node monitors, by using the first RTT and the ithtimer, a time point at which the ithdata packet arrives; and if the intermediate node does not receive the ithdata packet within a preset time, the intermediate node may release the storage space that is reserved for the ithdata packet and the corresponding entry. This can help properly and fully use buffer resources.

In a possible design, the first data packet set includes the C data packets of which sending is triggered by the first control packet, a jthdata packet in the first data packet set includes the first parameter set and a jthsequence number, j is an integer that ranges from 1 to C, and before the sending, by the intermediate node, a first data packet set at the head of a data queue based on the sent control packet, the method further includes: generating, by the intermediate node, a jthidentifier based on the first parameter set and the jthsequence number that are included in the jthdata packet; after determining that the registration table includes the jthidentifier, placing, by the intermediate node, the jthdata packet in the data queue of the intermediate node; and releasing, by the intermediate node, an entry including the jthidentifier in the registration table. In the foregoing method, after receiving the jthdata packet, the intermediate node may release the corresponding entry in the registration table. This helps fully use entry resources.

In a possible design, the first data packet set includes the C data packets of which sending is triggered by the first control packet, a jthdata packet in the first data packet set includes the first parameter set and a jthsequence number, j is an integer that ranges from 1 to C, and before the sending, by the intermediate node, a first data packet set at the head of a data queue based on the sent control packet, the method further includes: generating, by the intermediate node, a jthidentifier based on the first parameter set and the jthsequence number that are included in the jthdata packet; after determining that the registration table does not include the jthidentifier, determining, by the intermediate node, whether the data queue includes a free and unreserved storage space that can accommodate the jthdata packet; and after determining that the data queue includes the free and unreserved storage space that can accommodate the jthdata packet, placing, by the intermediate node, the jthdata packet in the data queue of the intermediate node. In the foregoing method, after a time point at which the intermediate node receives the jthdata packet exceeds timing duration of a timer, the intermediate node releases an entry corresponding to the jthdata packet, and the intermediate node may determine, based on a buffer status in the data queue, whether to place the jthdata packet in the data queue, to prevent the jthdata packet from being discarded because the entry is released.

In a possible design, the method further includes: after determining that the data queue does not include the free and unreserved storage space that can accommodate the jthdata packet, discarding, by the intermediate node, the jthdata packet.

For the intermediate node, a control packet in any control queue of the intermediate node may be sent through a control channel connected to the intermediate node, and a data packet in any data queue of the intermediate node may be sent through a data channel connected to the intermediate node. The data channel and the control channel may be carried on one or more physical links. A ratio of a bandwidth of the data channel to a bandwidth of the control channel is a ratio of a sum of packet lengths of C data packets to a packet length of any control packet.

According to a third aspect, a source device in a packet-based network is provided, and the source device includes a module that can implement a function corresponding to the first aspect or any possible design of the first aspect. The source device may be the transmit end mentioned in the first aspect or any possible design of the first aspect.

According to a fourth aspect, an intermediate device in a packet-based network is provided, and the intermediate device includes a module that can implement a function corresponding to the second aspect or any possible design of the second aspect. The intermediate device may be the intermediate node mentioned in the second aspect or any possible design of the second aspect.

According to a fifth aspect, a destination device in a packet-based network is provided, and the destination device includes a receiving module, a generation module, and a sending module. The receiving module is configured to receive a first control packet from a source device. The first control packet includes a parameter set. The generation module is configured to generate a second control packet based on the first control packet. A source address of the second control packet is a destination address of the first control packet, and a destination address of the second control packet is a source address of the first control packet. The sending module is configured to send the second control packet to the source device. The source address of the second control packet is an address of the destination device, and the destination address of the second control packet is an address of the source device. The destination device may be the receive end mentioned in the first aspect, any possible design of the first aspect, the second aspect, or any possible design of the second aspect.

According to a sixth aspect, a computer readable storage medium is provided. The computer readable storage medium includes an instruction, and when the instruction is run on a computer, the computer is enabled to perform the method for controlling traffic in a packet-based network according to the first aspect or any possible design of the first aspect.

According to a seventh aspect, a computer readable storage medium is provided. The computer readable storage medium includes an instruction, and when the instruction is run on a computer, the computer is enabled to perform the method for controlling traffic in a packet-based network according to the second aspect or any possible design of the second aspect.

According to an eighth aspect, a computer program product including an instruction is provided. When the computer program product is run on a computer, the computer is enabled to perform the method for controlling traffic in a packet-based network according to the first aspect or any possible design of the first aspect.

According to a ninth aspect, a computer program product including an instruction is provided. When the computer program product is run on a computer, the computer is enabled to perform the method for controlling traffic in a packet-based network according to the second aspect or any possible design of the second aspect.

According to a tenth aspect, a source device in a packet-based network is provided, and the source device includes a processor, a memory, a bus, and a communications interface. The memory is configured to store a computer-executable instruction, the processor and the memory are connected by using the bus, and when the source device runs, the processor executes the computer-executable instruction stored in the memory, so that the source device performs the method for controlling traffic in a packet-based network according to the first aspect or any possible design of the first aspect. The source device may be the transmit end mentioned in the first aspect or any possible design of the first aspect.

According to an eleventh aspect, an intermediate device in a packet-based network is provided, and the intermediate device includes a processor, a memory, a bus, and a communications interface. The memory is configured to store a computer-executable instruction, the processor and the memory are connected by using the bus, and when the intermediate device runs, the processor executes the computer-executable instruction stored in the memory, so that the intermediate device performs the method for controlling traffic in a packet-based network according to the second aspect or any possible design of the second aspect. The intermediate device may be the intermediate node mentioned in the second aspect or any possible design of the second aspect.

According to a twelfth aspect, a system for controlling traffic in a packet-based network is provided, and the system includes the source device provided in the third aspect or the tenth aspect, and the intermediate device provided in the fourth aspect or the eleventh aspect. In a possible design, the system further includes the destination device provided in the fifth aspect.

