Patent Description:
Transmission control protocol (TCP) is a connection-oriented and reliable transport layer communications protocol. In a scenario in which TCP is used to transmit a service packet, when a network device receives packets from a high-speed interface and sends packets from a low-speed interface, or when traffic of a plurality of user access devices converges on a same network device, the network device may lose service packets. Consequently, the requirement (for example, a throughput) of the service carried by the TCP cannot be met, user experience is seriously affected, and in particular, when the network device transmits a video service, the video service is interrupted, or the like.

In the prior art, to resolve such a problem, a buffer (buffer) of a network device is usually added to avoid a packet loss. However, this manner increases a queuing time for service traffic in a buffer, and consequently, a transmission delay of the service traffic increases, and a service transmission requirement cannot be ensured. In addition, when there is burst traffic on a network device, the packet loss still occurs to some extent.

<CIT> discloses that destination endpoints can use in-band signaling to adjust TCP parameters, to adjust entries in history and profile tables, to initialize a transition to an in-band communication mode, or to communicate short flows and/or alerts to a mobile device. A destination endpoint achieves in-band singling by embedding sequence number patterns in acknowledgement (ACK) messages, or by transmitting ACK messages (duplicates or otherwise) in accordance with an ACK sequence pattern. The sequence number or ACK sequence pattern can be pre-associated with any in-band communication message, such as a request to adjust TCP parameters, the reporting of a network or triggering condition, a request to adjust entries in a history or profile table, an indication to transition from a normal communication mode to an in-band communication mode, etc..

<CIT> discloses a communications apparatus, enabling an efficient data transfer without an environmental restriction, which notifies a transmission-side apparatus connected via a network of data amount in a window size, and receives data as large as the window size, the data which is transmitted from the transmission-side apparatus. The communications apparatus includes: a receiving buffer memory having a region for storing a data packet transmitted from the transmission-side apparatus; a communications protocol processing unit notifying the transmission-side apparatus of the window size larger than a capacity of the receiving buffer memory, receiving the data packet transmitted from the transmission-side apparatus according to the notified window size, and storing the received data packet in the receiving buffer memory; and a central controlling unit retrieving the data packet stored in the receiving buffer memory and processing the retrieved data packet.

<CIT> discloses a packet handling method comprising: receiving a TCP ACK packet currently sent by a client; searching in a storage device for a TCP packet requested for retransmission by the TCP ACK packet when it is determined that the Acknowledge Number field value in the TCP header of the TCP ACK packet currently sent by the client is equal to the Acknowledge Number field value in the TCP header of a TCP ACK packet previously sent by the client over the same TCP connection; discarding the TCP ACK packet and transmitting the TCP packet to the client when the TCP packet requested for retransmission is found in the storage device.

This application provides methods for sending a service packet, a network device, and a controller, to obtain a TCP window based on a priority of a service, according to the attached claims, so that a size of a service packet sent by a transmit end can be flexibly controlled, and a loss of service packets is reduced while a service packet transmission requirement is met.

According to a first aspect, an embodiment of the present invention provides a method for sending a service packet. The method includes: receiving, by a first network device, a TCP packet sent by a second network device, where the TCP packet includes a service identifier; determining, by the first network device based on the service identifier, a priority of a service corresponding to the service identifier; obtaining, by the first network device, a TCP window based on the priority of the service; and sending, by the first network device, a first TCP ACK packet to the second network device, where the first TCP ACK packet includes the TCP window, and the TCP window is used by the second network device to calculate a size of a service packet to be sent to the first network device.

In the foregoing method, the first network device obtains the priority of the service based on the service identifier in the TCP packet, and then obtains the TCP window based on the priority of the service. Because the TCP window obtained by the first network device is determined based on a service priority, different transmission requirements of services of different priorities can be met, and a size of a packet sent by a transmit end can be flexibly controlled. For example, for a low-priority service, the TCP window may be a smaller one; and for a high-priority service, the TCP window may be a larger one. In this way, requirements of different services can be met, network resources can be fully utilized, and a loss of service packets can be reduced.

In a possible design, the first network device sends the TCP packet to a third network device, the first network device receives a second TCP ACK packet sent by the third network device; and the first network device updates a TCP window in the second TCP ACK packet with the TCP window, and generates the first TCP ACK packet. In this design, as an intermediate device on a TCP service packet transmission path, the first network device actively intercepts a TCP packet, calculates a TCP window based on the priority of the service, and replaces the TCP window with a TCP window in the TCP ACK packet sent by a service packet receive end, so that the size of the service packet sent by the transmit end can be flexibly controlled.

According to the first aspect, when determining that the priority of the service is a first priority, the first network device obtains service requirement information of the service, and calculates the TCP window based on the service requirement information. A service corresponding to the first priority is a high-priority service. If the priority of the service is the first priority, it indicates that the service is a high-priority service.

In a possible design, when the first network device determines that the priority of the service is the first priority, the first network device sends the service identifier to a controller, and receives the TCP window that is calculated by the controller based on the service requirement information of the service.

In a possible design, the service requirement information includes a throughput, and the throughput is used to identify traffic of a corresponding service that needs to be transmitted by the first network device within a unit time. The first network device calculates a TCP window based on the throughput and an occupied buffer size in a buffer of the first network device.

In the foregoing manner, the first network device calculates the TCP window based on the service requirement information. In this way, a transmission requirement of a service can be accurately ensured. Different TCP windows are obtained through calculation for different services, so that a size of a service packet sent by a transmit end can be flexibly controlled. When a bandwidth resource is given, bandwidth occupation of different services can be flexibly adjusted, thereby reducing a packet loss. In addition, when the first network device is an intermediate device on a TCP service packet transmission path, the TCP window is calculated based on an occupation status of the buffer of the first network device, thereby more accurately ensuring service transmission for the forwarded service.

In a possible design, the TCP window is calculated by using the following formula: <MAT> where.

In the foregoing manner, the first network device can obtain a TCP window range through calculation by using the foregoing formula. All TCP windows in the range can meet a throughput requirement of the service, and the TCP window can be flexibly adjusted. For example, when a buffer occupation rate of the first network device exceeds a specific threshold, for example, <NUM>%, a TCP window may be selected to be a smaller value in the range obtained through calculation by using the foregoing formula; or if the buffer occupation rate of the first network device is less than a specific threshold, for example, <NUM>%, a TCP window may be selected to be a larger value in the range obtained through calculation by using the foregoing formula. In this way, the buffer of the first network device is avoided from being excessively occupied while the TCP window can be flexibly adjusted to meet a user service requirement, so that a loss of service packets is reduced.

In a possible design, the first network device calculates the TCP window by using the following formula: <MAT> where.

In the foregoing manner, when calculating the TCP window, the first network device also uses the transmission delay of the outbound interface used by the first network device to send the service packet, or the processing delay of processing the service packet in the occupied buffer by the first network device. In this way, a range of the TCP window is calculated more accurately. In particular, when the transmission delay of the outbound interface used by the first network device to send the service packet is relatively high, or the processing delay of processing the service packet in the occupied buffer by the first network device is relatively high, a range of the TCP window obtained through calculation is more accurate, so that a user service requirement can be met more accurately.

In a possible implementation, the TCP window that is calculated by using the foregoing formula further meets the following formula: window < B-currentB. when the first network device calculates the TCP window, a remaining buffer size of the first network device is B - currentB. Therefore, the first network device may store only packets of the remaining buffer size at most. This formula is used as a supplement to calculate the TCP window, and a loss of service packets may be reduced to some extent.

In a possible implementation, the first network device sends the service identifier to a controller that stores a correspondence between the service identifier and the service requirement information. The controller obtains the service requirement information based on the service identifier and the correspondence, and sends the service requirement information to the first network device. The first network device receives the service requirement information sent by the controller.

In a possible implementation, the first network device directly stores a correspondence between the service identifier and the service requirement information; and the first network device obtains the service requirement information from the correspondence by using the service identifier.

In a possible implementation, when determining that the priority of the service is the first priority, and the occupied buffer size in the buffer of the first network device is greater than or equal to a first threshold, the first network device obtains the service requirement information of the service and calculates the TCP window based on the service requirement information.

In the foregoing manner, the first network device calculates the TCP window based on the service requirement information only when determining that the occupied buffer size in the buffer of the first network device is greater than or equal to the first threshold. Therefore, this avoids excessive occupation of a network resource caused by frequent calculation of the TCP window.

In a possible implementation, that the first network device obtains the TCP window based on the priority of the service includes:
when the first network device determines that the priority of the service is a second-priority service, and the occupied buffer size in the buffer of the first network device is greater than or equal to a second threshold, a value of the TCP window is <NUM>, or the TCP window is set to a smaller value, where the smaller value only needs to ensure that the service will not be interrupted, the first priority is greater than the second priority, and a service corresponding to the second priority is a low-priority service.

In the foregoing manner, when the first network device determines that the service is the low-priority service, and the occupied buffer size of the first network device reaches the second threshold, the TCP window is <NUM> or a smaller value. In this way, properly restraining sending of the low-priority service packets can reduce the loss of packets, so that more resources can be reserved for a transmission of the high-priority service.

In a possible implementation, when the first network device determines that the priority of the service is the first priority, and the occupied buffer size in the buffer of the first network device is greater than or equal to the second threshold, the first network device sends the service identifier to the controller, and the first network device receives the TCP window that is calculated by the controller based on the service requirement information of the service. The controller performs centralized control on devices in the network, and the controller stores the requirement information of the service, and therefore, the controller can more flexibly calculate the TCP window for the managed network devices.

In a possible implementation, the method further includes: receiving, by the first network device, a flow table sent by the controller, where the flow table is used to provide guidance for the first network device to send the first TCP ACK packet to the second network device; adding, by the first network device, the TCP window to the flow table; when the first network device sends the first TCP ACK packet to the second network device, obtaining, by the first network device, the TCP window from the flow table, and adding the TCP window to the first TCP ACK packet. The TCP window is added to the flow table, so that when the first TCP ACK packet is sent, the TCP window can be directly obtained from the flow table, and the forwarding efficiency of the first TCP ACK packet is higher.

In a possible implementation, the method further includes: receiving, by the first network device, the service packet sent by the second network device, where a size of a payload (payload) part of the service packet is the TCP window, or an overall size of the service packet is the TCP window. In a possible implementation, the TCP packet is a TCP synchronization (SYN) packet or a TCP service packet, and the TCP service packet carries the service packet of a user.

In a possible implementation, a rate of an interface used by the first network device to receive the TCP service packet from the second network device is a first rate, and a rate of an interface used by the first network device to send the TCP service packet to the third network device is a second rate, where the first rate is greater than the second rate.

According to a second aspect, an embodiment of the present invention provides a method for sending a service packet. The method includes: receiving, by a controller, a service identifier sent by a first network device; determining, by the controller, a priority of a service corresponding to the service identifier based on the service identifier; calculating, by the controller, a TCP window based on the priority of the service, and sending the TCP window to the first network device, to trigger the first network device to send the TCP window to a second network device, where the TCP window is used by the second network device to calculate a size of a service packet to be sent to the first network device.

In the foregoing manner, the controller calculates the TCP window based on the service priority. Because the TCP window is calculated based on the service priority, different transmission requirements of services of different priorities can be met, and a size of a packet sent by a transmit end can be flexibly controlled, thereby reducing a loss of service packets.

In a possible implementation, when determining that the priority of the service is a first priority, the controller obtains, based on the service identifier, the service requirement information corresponding to the service, and the controller calculates the TCP window based on the service requirement information.

In a possible implementation, the service requirement information includes a throughput, and the throughput is used to identify traffic of a corresponding service that needs to be transmitted by the first network device within a unit time; and that the controller calculates a TCP window based on the service requirement information, including:
calculating the TCP window based on the throughput and the occupied buffer size in the buffer of the first network device.

In a possible implementation, the controller calculates the TCP window by using the following formula: <MAT> where.

In a possible design, the controller calculates the TCP window by using the following formula: <MAT> where.

In a possible implementation, the TCP window further meets the following formula: <MAT>.

According to a third aspect, an embodiment of the present invention provides a network device for sending a service packet, to perform the method in any one of the first aspect or the possible implementations of the first aspect. Specifically, the network device includes a unit configured to perform the method in the first aspect or any possible implementation of the first aspect. According to a fourth aspect, an embodiment of the present invention provides a controller for sending a service packet, to perform the method in any one of the second aspect or the possible implementations of the second aspect. Specifically, the controller includes a unit configured to perform the method of the second aspect or any possible implementation of the second aspect. According to a fifth aspect, a network device is provided, where the network device includes a processor, a network interface, and a memory. The memory may be configured to store program code. The processor is configured to invoke the program code in the memory to perform the method in the first aspect or any possible implementation of the first aspect. For details, refer to detailed descriptions in the method example.

According to a sixth aspect, a controller is provided, where the controller includes a processor, a network interface, and a memory. The memory may be configured to store program code. The processor is configured to invoke the program code in the memory to perform the method in the second aspect or any possible implementation of the second aspect. For details, refer to detailed descriptions in the method example.

According to a seventh aspect, a network device is provided, where the network device includes a main control board and an interface board. The main control board includes a first processor and a second memory. The interface board includes a second processor, a second memory, and an interface card. The second memory may be configured to store program code. The second processor is configured to invoke the program code in the second memory to perform the following operations: receiving a TCP packet sent by the second network device, where the TCP packet includes a service identifier; and sending the service identifier to the main control board. The first memory may be configured to store program code. The first processor is configured to invoke the program code in the first memory to perform the following operations: receiving a service identifier sent by an interface board, and obtaining, based on the service identifier, a priority of a service corresponding to the service identifier; and obtaining the TCP window based on the priority of the service.

The second processor is further configured to invoke the program code in the second memory to perform the following operation: sending a TCP ACK packet to the second network device, where the TCP ACK packet includes a TCP window.

In a possible implementation, an inter-process communication (IPC) control channel is established between the main control board and the interface board.

According to an eighth aspect, a system for sending a service packet is provided, where the system includes the first network device and the second network device that are provided in the foregoing aspects. The second network device is configured to: send a TCP packet to the first network device, where the TCP packet includes a service identifier; receive a TCP ACK packet sent by the first network device; and calculate, based on a TCP window in the TCP ACK packet, a size of a service packet to be sent to the first network device.

According to a ninth aspect, a computer storage medium is provided, where the computer storage medium is configured to store a computer software instruction used by the foregoing network device or the controller, and includes a program designed to perform the foregoing aspects.

To describe the technical solutions in the present invention more clearly, the following briefly describes the accompanying drawings used in the embodiments. Apparently, the accompanying drawings in the following description merely show some embodiments of the present invention, and a person of ordinary skill in the art can derive other technical solutions and accompanying drawings of the present invention from these accompanying drawings without creative efforts.

The following describes the embodiments of the present invention with reference to accompanying drawings.

<FIG> shows a possible application scenario according to an embodiment of the present invention. In this application scenario, a device <NUM> and a device <NUM> are user devices, for example, a mobile phone or a personal computer; a device <NUM> and a device <NUM> are user access devices, for example, an optical line terminal (optical line terminal, OLT) or an optical network unit (optical network unit, ONU); a device <NUM> is a forwarding device in a network, for example, a router or a switch; and a device <NUM> is a server in the network, for example, a content delivery network (content delivery network, CDN) server. An interface <NUM> and an interface <NUM> are two physical interfaces of the device <NUM>. When a transmission rate of the interface <NUM> is greater than that of the interface <NUM>, for example, when the transmission rate of the interface <NUM> is <NUM> Mbit/s (Mbit/s) and the transmission rate of the interface <NUM> is <NUM> Mbit/s, if the device <NUM> sends high service traffic to the server <NUM> within a unit time, the service traffic may smoothly pass through the interface <NUM> and reach the device <NUM>. However, because the transmission rate of the interface <NUM> is lower than that of the interface <NUM>, service traffic will be accumulated on the device <NUM>. When an entire buffer of the device <NUM> is occupied, packets of the service traffic may be lost. In another scenario, if a plurality of devices <NUM> and/or a plurality of devices <NUM> send service traffic to the device <NUM> within a unit time, the service traffic may also be accumulated on the device <NUM>. When the entire buffer of the device <NUM> is occupied, packets of the service traffic may be lost.

Embodiments of the present invention provide a method for sending a service packet, and a network device and a system based on this method. In this method, a TCP window is obtained based on a priority of a service, to flexibly control a size of a service packet sent by a transmit end, and reduce the loss of service packets while a service packet transmission requirement is met. The method, the network device, and the system are based on a same invention concept. The method, the network device, and the system have similar principles for resolving problems. Therefore, for implementation of the network device and the method, reference may be made to each other; and for implementation of the system and the method, reference may also be made to each other. No repeated description is provided.

Based on the application scenario shown in <FIG>, with reference to <FIG>, an embodiment of the present invention provides a method for establishing a connection and sending a packet based on TCP when devices transmit a service packet with each other by using the TCP. A transmit end in <FIG> may be the device <NUM> or the device <NUM> in <FIG>, and a receive end may be the device <NUM> in <FIG>. The method includes the following steps:.

<FIG> shows a method for sending a service packet provided in an embodiment of the present invention. Referring to <FIG>, the method includes the following steps:
S301. A first network device receives a TCP packet sent by a second network device, where the TCP packet includes a service identifier.

In an example, the first network device is the receive end in the method shown in <FIG>, and the second network device is the transmit end in the method shown in <FIG>.

In an example, the TCP packet may be an SYN packet sent by the second network device to the first network device in a TCP connection process, for example, the first SYN packet in S201 in <FIG>.

In an example, the TCP packet may be a TCP service packet to be sent to the first network device after a TCP connection is established between the second network device and the first network device, for example, the service packet in S204 in <FIG>. The TCP service packet carries a specific service.

In an example, the service identifier is used to identify a service, specifically, the service identifier may be a flow label (flow label, FL) or a service label.

In an example, if the second network device runs only one service, the service identifier includes a destination internet protocol (Internet Protocol, IP) address; or if the second network device runs a plurality of services at the same time, to distinguish between different services, the service identifier includes a destination IP address and a destination port (Port), or the service identifier includes a destination IP address, a destination port, a source IP address, and a source port.

The first network device determines, based on the service identifier, a priority of a service corresponding to the service identifier.

In an example, the first network device is a device corresponding to a destination address of the service packet, in other words, the first network device is a receive end of the service packet; for example, the first network device is the device <NUM> in <FIG>, or the first network device is an intermediate device on a service packet transmission path, for example, the first network device is the device <NUM> in <FIG>. When the first network device is the receive end of the service packet, the first network device may obtain service identifier in the following three manners:.

In an example, the first network device has already pre-stored a correspondence between the service identifier and a service priority. After receiving the TCP packet, the first network device can directly use the correspondence between the service identifier and the service priority to obtain the priority of the service corresponding to the service identifier.

For another implementation for the first network device to obtain the priority of the service corresponding to the service identifier based on the service identifier, refer to specific description in the embodiment shown in the following <FIG>. It can be understood that <FIG> provides only an example implementation; and this application does not impose any limitation on the manner of obtaining the priority of the service based on the service identifier, and does not provide details about another manner that a person skilled in the art can figure out on the basis of reading the content of this application.

The first network device obtains a TCP window based on the priority of the service. In the embodiment of the present invention, the TCP window specifically refers to the size of the TCP window or the value of the TCP window.

For a manner of obtaining the TCP window by the first network device based on the priority of the service, refer to specific description in an embodiment of <FIG> below. It can be understood that <FIG> provides only an example implementation; and this application does not impose any limitation on the manner of obtaining the TCP window, and does not provide details about another manner that a person skilled in the art can figure out on the basis of reading the content of this application.

The first network device sends the first TCP ACK packet to the second network device, where the first TCP ACK packet includes the TCP window.

Based on the method shown in <FIG>, an embodiment of the present invention provides a method for sending a service packet. Specifically, referring to <FIG>, an implementation in which a first network device obtains a TCP window based on a service identifier is provided.

The first network device receives a TCP packet sent by a second network device, where the TCP packet includes the service identifier.

After receiving the TCP packet, the first network device sends the service identifier in the TCP packet to a controller.

The controller stores a correspondence between the service identifier and a service priority. Optionally, the first network device may first obtain the service identifier in the TCP packet, and then send the service identifier to the controller. Alternatively, the first network device may directly make a copy of the TCP packet, and then send the copied TCP packet to the controller; and the controller obtains the service identifier based on the TCP packet.

After obtaining the service identifier, the controller obtains, based on a correspondence between the service identifier and the service priority, a priority of the service corresponding to the service identifier, and then sends the priority of the service to the first network device. The first network device receives the priority of the service that corresponds to the service identifier and that is sent by the controller.

In this embodiment of the present invention, the controller controls or manages a network device in a network. The controller may be a network management device or a controller in a software-defined networking (Software-defined networking, SDN) architecture. The network device in the embodiment of the present invention may be a router or a switch, or a forwarder under the SDN network architecture.

The first network device obtains the TCP window based on the priority of the service. The first network device sends a first TCP ACK packet to the second network device, where the first TCP ACK packet includes the TCP window.

In an example, the first network device receives a flow table sent by the controller, where the flow table is used to instruct the first network device to send the first TCP ACK packet to the second network device. The first network device stores the flow table delivered by the controller, and the first network device adds the obtained TCP window to the flow table. When the first network device needs to send the TCP window to the second network device, the first network device first obtains the TCP window from the flow table that includes the TCP window and that is stored in the first network device, then adds the TCP window to the first TCP ACK packet, and sends the first TCP ACK packet to the second network device.

<FIG> is a method for obtaining a TCP window based on a service priority according to an embodiment of the present invention. The method may be applied to step S303 in the embodiment shown in <FIG> or <FIG>. As shown in <FIG>, the method includes the following steps:.

According to an embodiment of this application, in step S3032, the computing device is the first network device. When determining that the priority of the service is the first priority, the first network device obtains service requirement information of the service, and calculates the TCP window based on the service requirement information.

In an example, when the computing device is the first network device, the first network device may obtain the service requirement information of the service in the following two manners:.

In an example, when the first network device determines that the priority of the service is the first priority, and an occupied buffer size in a buffer of the first network device is greater than or equal to a first threshold, the first network device obtains the service requirement information of the service, and calculates the TCP window based on the service requirement information. In this embodiment of the present invention, the size of the buffer may also be understood as a value of the buffer. The first threshold is a preset value. For example, a size of a buffer of the first network device is <NUM> (Mbit/s), and a value of the first threshold may be <NUM>. When the occupied buffer size in the buffer of the first network device is greater than or equal to <NUM>, the service requirement information of the service is obtained. In the foregoing manner, the first network device calculates the TCP window based on the service requirement information only when determining that the occupied buffer size in the buffer of the first network device is greater than or equal to the first threshold. Therefore, this avoids excessive occupation of a network resource caused by frequent calculation of the TCP window.

For specific calculation of the TCP window based on the service requirement information, refer to the following detailed description.

When determining that the priority of the service is a second priority, the computing device obtains an occupied buffer size in the buffer of the first network device, where the first priority is greater than the second priority, and a service corresponding to the second priority is a low-priority service.

The computing device determines whether an occupied buffer size in the buffer of the first network device is greater than or equal to a second threshold. Optionally, the buffer of the first network device refers to a total buffer size of the first network device.

When determining that the occupied buffer size in the buffer of the first network device is greater than or equal to a second threshold, the computing device sets the TCP window to <NUM>, or sets the TCP window to a smaller value. A value of the smaller value needs to ensure that the service is not interrupted. For example, the smaller value may be <NUM> or <NUM>. The second threshold is a preset value. For example, a size of a buffer of the first network device is <NUM>, and a value of the second threshold may be <NUM>. When the occupied buffer size in the buffer of the first network device is greater than or equal to <NUM>, the TCP window is set to <NUM>, or the TCP window is set to a smaller value. Values of the first threshold and the second threshold may be the same or different.

In an example, when the computing device determines that the occupied buffer size in the buffer of the first network device is less than the second threshold, the value of the TCP window is a default value. For example, the value of the TCP window may be a TCP window obtained through the latest calculation or a specific value.

In an example, in step S3032, the computing device is the first network device. In another example, the computing device may alternatively be the controller. In an implementation in which the controller is a computing device, when the first network device determines that the priority of the service is the first priority, the first network device sends a notification message to the controller, and the controller calculates the TCP window. The controller determines the service requirement corresponding to the service identifier based on the stored correspondence between the service identifier and the service requirement information, and calculates the TCP window based on the service requirement information. For a specific process of calculating the TCP window by the controller, refer to the following embodiment shown in <FIG>.

In an example, the service requirement information includes a throughput, and the throughput is used to identify traffic that is of a service corresponding to the service identifier and that needs to be transmitted by the first network device within a unit time. The computing device calculates the TCP window based on the throughput and an occupied buffer size in the buffer of the first network device. The computing device calculates the TCP window in the following two manners:.

When the first network device is the receive end of the service packet, for example, the first network device is the device <NUM> in <FIG>, the second network device may be the device <NUM> or the device <NUM> in <FIG>, and Δt is a processing delay of processing a service packet in the occupied buffer by the first network device. When the first network device is an intermediate device on the service packet transmission path, for example, when the first network device is the device <NUM> in <FIG>, the second network device may be the device <NUM> or the device <NUM> in <FIG>, and Δt is a transmission delay of an outbound interface used by the first network device to send the service packet.

When calculating the TCP window, the computing device also uses a transmission delay of an outbound interface used by the first network device to send a service packet, or a processing delay of processing a service packet in the occupied buffer by the first network device. In this way, a range of the TCP window is calculated more accurately. In particular, when the transmission delay of the outbound interface used by the first network device to send the service packet is relatively high, or the processing delay of processing the service packet in the occupied buffer by the first network device is relatively high, a range of the TCP window obtained through calculation is more accurate, so that a user service requirement can be met more accurately.

In an example, when the computing device calculates the TCP window in the foregoing two manners, a value of the TCP window further meets the following formula: <MAT>.

When the first network device calculates the TCP window, a remaining buffer size of the first network device is B-currentB. Therefore, the first network device may store only packets of the remaining buffer size at most. This formula is used as a supplement to calculate the TCP window, and a loss of service packets may be reduced to some extent.

In an example, based on the method for sending a service packet shown in <FIG>, an embodiment of the present invention further provides a method for sending a service packet. <FIG> is a schematic flowchart of the method. Referring to <FIG>, the method includes the following steps:.

In this embodiment of the present invention, steps S301, S302, S303, and S304 are the same as steps S301, S302, S303, and S304 in <FIG>. For detailed content, refer to the embodiment shown in <FIG>.

In this embodiment, the second network device is a transmit end of the service packet, the first network device is an intermediate device on a service packet transmission path, and the third network device is a receive end of the service packet. For example, the first network device is the device <NUM> in <FIG>, the second network device is the device <NUM> or the device <NUM> in <FIG>, and the third network device is the device <NUM> in <FIG>. As the intermediate device on the transmission path, the first network device actively intercepts the TCP packet, calculates the TCP window based on the service priority, and replaces the TCP window with a TCP window in the TCP ACK packet sent by a service packet receive end, so that a size of the service packet sent by the transmit end can be flexibly controlled. In addition, when the TCP window is calculated by using the method shown in <FIG>, the first network device calculates the TCP window based on the occupation status of the buffer of the first network device and the service requirement information, thereby more accurately ensuring service transmission for the forwarded service.

In an example, steps S302 and S303 may be performed before or after step S3032, and this is not specifically limited in this embodiment of the present invention.

In an example, the first network device may obtain the service identifier in the following four manners:.

In an example, the first network device receives the packet through a high-speed interface, and sends the packet through a low-speed interface. For example, a rate at which the first network device receives the TCP service packet from the second network device is a first rate, a rate at which the first network device sends the TCP service packet to the third network device is a second rate, and the first rate is greater than the second rate.

In an example, after step S304 in the method shown in <FIG>, <FIG>, or <FIG>, the method may further include:
receiving, by the first network device, a service packet that corresponds to the service identifier and that is sent by the second network device. A size of a payload (payload) part of the service packet is the TCP window obtained in step S303, or a size of the entire service packet is the TCP window obtained in step S303.

In an example, when the first network device serves as the intermediate device on the service packet transmission path, the first network device further sends the service packet received from the second network device to the receive end of the service packet. For example, the first network device is the device <NUM> in <FIG>, the second network device may be the device <NUM> or the device <NUM> in <FIG>, and after receiving the service packet from the second network device, the first network device further sends the service packet to the device <NUM> in <FIG>.

Based on the application scenario shown in <FIG>, an embodiment of the present invention further provides a method for sending a service packet. Referring to <FIG>, the method includes the following steps:.

In an example, the first network device is a receive end of the service packet, and the second network device is a transmit end of the service packet. For example, the first network device is the device <NUM> in <FIG>, and the second network device may be the device <NUM> or the device <NUM> in <FIG>.

In an example, the method shown in <FIG> further includes: sending, by the first network device, the TCP packet to a third network device, and receiving a second TCP ACK packet sent by the third network device. The first network device updates the TCP window in the second TCP ACK packet with the TCP window obtained through calculation in step S404, and generates the first TCP ACK packet in step S406. In this example, the first network device is an intermediate device on a service packet forwarding path, the second network device is the transmit end of the service packet, and the third network device is the receive end of the service packet. The first network device may be the device <NUM> in <FIG>, the second network device may be the device <NUM> or the device <NUM> in <FIG>, and the third network device is the device <NUM> in <FIG>.

In this embodiment of the present invention, the controller calculates the TCP window based on the service priority. Because the TCP window is calculated based on the service priority, different transmission requirements of services of different priorities can be met, and a size of a packet sent by a transmit end can be flexibly controlled, thereby reducing a loss of service packets.

<FIG> is a possible schematic structural diagram of a first network device used in the foregoing embodiments. The first network device <NUM> may implement functions of the first network device in the embodiment shown in <FIG>, <FIG>, <FIG>, <FIG>, or <FIG>. Referring to <FIG>, the first network device <NUM> includes: a receiving unit <NUM>, a determining unit <NUM>, a processing unit <NUM>, and a sending unit <NUM>. These units may perform corresponding functions of the first network device in the foregoing method embodiments. The receiving unit <NUM> is configured to support the first network device <NUM> to perform a process S301 in <FIG>, processes S301 and S3023 in <FIG>, processes S301 and S3035 in <FIG>, and/or processes S401 and S405 in <FIG>. The determining unit <NUM> is configured to support the first network device <NUM> to perform a process S302 in <FIG> and/or a process S302 in <FIG>. The sending unit <NUM> is configured to support the first network device <NUM> to perform a process S304 in <FIG>, processes S3021 and S304 in <FIG>, processes S3034 and S304 in <FIG>, and/or processes S402 and S407 in <FIG>. The processing unit <NUM> is configured to support the first network device <NUM> to perform a process S303 in <FIG>, a process S303 in <FIG>, processes S3031, S3032, S3033, S3034, and S3035 in <FIG>, processes S303 and S3036 in <FIG>, a process S406 in <FIG>, and/or another process performed by the first network device in the technology described in this specification. For example, the receiving unit <NUM> is configured to perform various information receiving functions performed by the first network device in the foregoing method embodiment. The determining unit <NUM> is configured to perform a determining action performed by the first network device in the foregoing method embodiment. The sending unit <NUM> is configured to perform various information sending functions performed by the first network device in the foregoing method embodiment. The processing unit <NUM> is configured to perform processing other than information receiving and sending and determining actions of the first network device in the foregoing method embodiment. For example, the receiving unit <NUM> is configured to receive a TCP packet sent by a second network device, where the TCP packet includes a service identifier. The determining unit <NUM> is configured to determine, based on the service identifier, a priority of a service corresponding to the service identifier. The processing unit <NUM> is configured to obtain a TCP window based on the priority of the service. The sending unit <NUM> is configured to send a first TCP ACK packet to the second network device, where the first TCP ACK packet includes the TCP window, and the TCP window is used by the second network device to calculate a size of a service packet to be sent to the first network device. For a specific execution process, refer to detailed descriptions of corresponding steps in the embodiment shown in <FIG>, <FIG>, <FIG>, <FIG>, or <FIG>.

When an integrated unit is used, <FIG> is a possible schematic structural diagram of a first network device used in the foregoing embodiments. The first network device <NUM> may implement functions of the first network device in the embodiment shown in <FIG>, <FIG>, <FIG>, <FIG>, or <FIG>. The first network device <NUM> includes a storage unit <NUM>, a processing unit <NUM>, and a communications unit <NUM>. The communications unit <NUM> is configured to support communication between the first network device <NUM> and another network entity, for example, communication with the third network device or the controller shown in <FIG>, <FIG>, or <FIG>. For example, the communications unit <NUM> is configured to support the first network device <NUM> to perform processes S301 and S304 in <FIG>, processes S301, S3021, S3023 and S304 in <FIG>, processes S301, S3034, S3035 and S304 in <FIG>, and/or processes S401, S402, S405 and S407 in <FIG>. The processing unit <NUM> is configured to control and manage an action of the first network device <NUM>. For example, the processing unit <NUM> is configured to support the first network device <NUM> to perform processes S302 and S303 in <FIG>, a process S303 in <FIG>, processes S3031, S3032, S3033, S3034, and S3035 in <FIG>, processes S302, S303, and S3036 in <FIG>, a process S406 in <FIG>, and/or another process performed by the first network device in the technology described in this specification. The storage unit <NUM> is configured to store program code and data of the first network device <NUM>. For a specific execution process, refer to detailed descriptions of corresponding steps in the embodiment shown in <FIG>, <FIG>, <FIG>, <FIG>, or <FIG>.

The processing unit <NUM> may be a processor, for example, a central processing unit (central processing unit, CPU), a general purpose processor, a digital signal processor (digital signal processor, DSP), an application-specific integrated circuit (application-specific integrated circuit, ASIC), a field programmable gate array (field programmable gate array, FPGA), or another programmable logical device, a transistor logical device, a hardware component, or a combination thereof. The processing unit may implement or execute various example logical blocks, modules, and circuits described with reference to content disclosed in this embodiment of the present invention. Alternatively, the processor may be a combination for implementing a computing function, for example, a combination of one or more microprocessors, or a combination of a DSP and a microprocessor. The communications unit <NUM> may be a transceiver. The storage unit <NUM> may be a memory.

When the processing unit <NUM> is a processor, the communications unit <NUM> is a transceiver, and the storage unit <NUM> is a memory, the first network device used in this embodiment of the present invention may be a first network device <NUM> shown in <FIG>.

Referring to <FIG>, the first network device <NUM> includes: a processor <NUM>, a transceiver <NUM>, a memory <NUM>, and a bus <NUM>. The processor <NUM>, the transceiver <NUM>, and the memory <NUM> are connected to each other by using the bus <NUM>. The bus <NUM> may be a peripheral component interconnect (peripheral component interconnect, PCI for short) bus, an extended industry standard architecture (extended industry standard architecture, EISA for short) bus, or the like. The bus may be classified into an address bus, a data bus, a control bus, and the like. For ease of denotation, the bus is indicated by using only one thick line in <FIG>. However, it does not indicate that there is only one bus or only one type of bus. The first network device <NUM> may implement functions of the first network device in the embodiment shown in <FIG>, <FIG>, <FIG>, <FIG>, or <FIG>. The processor <NUM> and the transceiver <NUM> may perform corresponding functions of the first network device in the foregoing method example. The transceiver <NUM> is configured to support the first network device <NUM> to perform processes S301 and S304 in <FIG>, processes S301, S3021, S3023 and S304 in <FIG>, processes S301, S3034, S3035 and S304 in <FIG>, and/or processes S401, S402, S405 and S407 in <FIG>. The processor <NUM> is configured to support the first network device <NUM> to perform processes S302 and S303 in <FIG>, a process S303 in <FIG>, processes S3031, S3032, S3033, S3034, and S3035 in <FIG>, processes S302, S303 and S3036 in <FIG>, a process S406 in <FIG>, and/or another process performed by the first network device in the technology described in this specification. The memory <NUM> is configured to store program code and data of the first network device <NUM>. For a specific execution process, refer to detailed descriptions of corresponding steps in the embodiment shown in <FIG>, <FIG>, <FIG>, <FIG>, or <FIG>.

Referring to <FIG>, an embodiment of the present invention provides another first network device <NUM>. The first network device <NUM> may be a router, a switch, or a network device that has a forwarding function. The first network device <NUM> can implement functions of the first network device in the foregoing method embodiment. The first network device <NUM> includes a main control board <NUM> and an interface board <NUM>. The main control board <NUM> includes a processor <NUM> and a memory <NUM>. The interface board <NUM> includes a processor <NUM>, a memory <NUM>, and an interface card <NUM>. The main control board <NUM> is coupled to the interface board <NUM>.

This hardware may perform corresponding functions in the foregoing method example. For example, the memory <NUM> may be configured to store program code of the interface board <NUM>. The processor <NUM> is configured to invoke the program code in the memory <NUM> to trigger the interface card <NUM> to perform various information sending and receiving functions performed by the first network device in the foregoing method embodiment. For example, the processor <NUM> invokes the program code in the memory <NUM> to trigger the interface card <NUM> to support the first network device <NUM> to perform processes S301 and S304 in <FIG>, processes S301, S3021, S3023 and S304 in <FIG>, processes S301, S3034, S3035 and S304 in <FIG>, and/or processes S401, S402, S405 and S407 in <FIG>. The processor <NUM> is further configured to send the service identifier to the main control board <NUM>. The memory <NUM> may be configured to store program code of the main control board <NUM>, and the processor <NUM> is configured to invoke the program code in the memory <NUM> to perform processing other than information receiving and sending of the first network device in the foregoing method embodiment. For example, the processor <NUM> is configured to support the first network device <NUM> to perform processes S302 and S303 in <FIG>, a process S303 in <FIG>, processes S3031, S3032, S3033, S3034, and S3035 in <FIG>, processes S302, S303 and S3036 in <FIG>, a process S406 in <FIG>, and/or another process performed by the first network device in the technology described in this specification. The memory <NUM> is configured to store program code and data of the main control board <NUM>. For a specific execution process, refer to detailed descriptions of corresponding steps in the embodiment shown in <FIG>, <FIG>, <FIG>, <FIG>, or <FIG>.

In a possible implementation, an IPC control channel is established between the main control board <NUM> and the interface board <NUM>, and communication is performed between the main control board <NUM> and the interface board <NUM> by using the IPC control channel.

<FIG> is a possible schematic structural diagram of the controller used in the foregoing embodiment. The controller may implement functions of the controller in the embodiment shown in <FIG>, <FIG>, or <FIG>. Referring to <FIG>, the controller <NUM> includes a receiving unit <NUM>, a determining unit <NUM>, a processing unit <NUM>, and a sending unit <NUM>. These units may perform corresponding functions of the controller in the foregoing method example. The receiving unit <NUM> is configured to support the controller <NUM> to perform a process S3021 in <FIG> and/or a process S402 in <FIG>. The determining unit <NUM> is configured to support the controller <NUM> to perform a process S3022 in <FIG> and a process S403 in <FIG>. The sending unit <NUM> is configured to support the controller <NUM> to perform a process S3023 in <FIG> and a process S405 in <FIG>. The processing unit <NUM> is configured to support the controller <NUM> to perform processes S3031, S3032, S3033, S3034, and S3035 in <FIG>, a process S404 in <FIG>, and/or another process performed by the controller in the technology described in this specification. For example, the receiving unit <NUM> is configured to perform various information receiving functions performed by the controller in the foregoing method embodiment. The determining unit <NUM> is configured to perform a determining action performed by the controller in the foregoing method embodiment. The sending unit <NUM> is configured to perform various information sending functions performed by the controller in the foregoing method embodiment. The processing unit <NUM> is configured to perform processing other than information receiving and sending and determining actions of the controller in the foregoing method embodiment. For example, the receiving unit <NUM> is configured to receive a service identifier sent by a first network device. The determining unit <NUM> is configured to determine, based on the service identifier, a priority of a service corresponding to the service identifier. The processing unit <NUM> is configured to calculate a TCP window based on the priority of the service. The sending unit <NUM> is configured to send the TCP window to the first network device, so that the first network device sends the TCP window to a second network device, where the TCP window is used by the second network device to calculate a size of a service packet to be sent to the first network device. For a specific execution process, refer to detailed descriptions of corresponding steps in the embodiment shown in <FIG>, <FIG>, or <FIG>.

It should be noted that unit division in the embodiments of the present invention is an example, and is merely logical function division. There may be another division manner in actual implementation. Function units in the embodiments of the present invention may be integrated into one processing unit, or each of the units may exist alone physically, or two or more units are integrated into one unit. For example, in the foregoing embodiment, the receiving unit and the sending unit may be a same unit or different units.

When an integrated unit is used, <FIG> is another possible schematic structural diagram of the controller used in the foregoing embodiment. The controller <NUM> may also implement functions of the controller in the embodiment shown in <FIG>, <FIG>, or <FIG>.

The controller <NUM> includes a storage unit <NUM>, a processing unit <NUM>, and a communications unit <NUM>. The communications unit <NUM> is configured to support communication between the controller <NUM> and another network entity, for example, is configured to support the controller <NUM> to perform processes S3021 and S3023 in <FIG> and processes S402 and S405 in <FIG>. The processing unit <NUM> is configured to control and manage an action of the controller <NUM>. For example, the processing unit <NUM> is configured to support the controller <NUM> to perform a process S3022 in <FIG>, processes S3031, S3032, S3033, S3034, and S3035 in <FIG>, a process S404 in <FIG>, and/or another process performed by the controller in the technology described in this specification. The storage unit <NUM> is configured to store program code and data of the controller <NUM>. For a specific processing process, refer to detailed descriptions of corresponding steps in the embodiment shown in <FIG>, <FIG>, or <FIG>.

The processing unit <NUM> may be a processor, for example, may be a CPU, a general purpose processor, a DSP, an ASIC, an FPGA or another programming logical device, a transistor logic device, a hardware component, or any combination thereof. The processing unit may implement or execute various example logical blocks, modules, and circuits described with reference to content disclosed in this embodiment of the present invention. Alternatively, the processor may be a combination for implementing a computing function, for example, a combination of one or more microprocessors, or a combination of a DSP and a microprocessor. The communications unit <NUM> may be a transceiver. The storage unit <NUM> may be a memory.

When the processing unit <NUM> is a processor, the communications unit <NUM> is a transceiver, and the storage unit <NUM> is a memory, the controller used in this embodiment of the present invention may be the controller <NUM> shown in <FIG>.

As shown in <FIG>, the controller <NUM> includes: a processor <NUM>, a transceiver <NUM>, a memory <NUM>, and a bus <NUM>. The transceiver <NUM>, the processor <NUM>, and the memory <NUM> are connected to each other by using the bus <NUM>. The bus <NUM> may be a PCI bus, an EISA bus, or the like. The bus may be classified into an address bus, a data bus, a control bus, and the like. For ease of denotation, the bus is indicated by using only one thick line in <FIG>. However, it does not indicate that there is only one bus or only one type of bus. The controller <NUM> may implement functions of the controller in the embodiment shown in <FIG> or <FIG>. The processor <NUM> and the transceiver <NUM> may perform corresponding functions of the controller in the foregoing method example. The transceiver <NUM> is configured to support the controller <NUM> to perform processes S3021 and S3023 in <FIG>, and/or processes S402 and S405 in <FIG>. The processor <NUM> is configured to support the controller <NUM> to perform a process S3022 in <FIG>, processes S3031, S3032, S3033, S3034, and S3035 in <FIG>, a process S404 in <FIG>, and/or another process performed by the controller in the technology described in this specification. The memory <NUM> is configured to store program code and data of the controller <NUM>. For a specific execution process, refer to detailed descriptions of corresponding steps in the embodiment shown in <FIG> or <FIG>.

Referring to <FIG>, an embodiment of the present invention provides another system <NUM> for sending a service packet. The system <NUM> is configured to implement the method for sending a service packet in the foregoing method embodiment. The system <NUM> includes a first network device <NUM> and a second network device <NUM>. The first network device <NUM> and the second network device <NUM> may respectively implement functions of the first network device and the second network device in the embodiment shown in <FIG>, <FIG>, <FIG>, <FIG>, or <FIG>. For example, the first network device <NUM> performs processes S301, S302, and S304 in <FIG>, processes S301, S3021, S3022, S3023, S303, and S304 in <FIG>, processes S3031, S3032, S3033, S3034, and S3035 in <FIG>, processes S301, S302, S303, S3034, S3035, S3036, and S304 in <FIG>, and/or another process performed by the first network device in the technology described in this specification. The second network device <NUM> is configured to: send a TCP packet to the first network device <NUM>, where the TCP packet includes a service identifier: and receive a first TCP ACK packet sent by the first network device <NUM>, where the first TCP ACK packet includes a TCP window obtained by the first network device <NUM>.

In an example, the system <NUM> further includes a third network device, where the third network device is configured to implement functions of the third network device in the embodiment shown in <FIG>. For example, the third network device receives the TCP packet sent by the first network device <NUM>, and sends an ACK packet corresponding to the TCP packet to the first network device <NUM>.

In an example, the system <NUM> further includes a controller, where the controller is configured to implement the functions of the controller in the embodiments shown in <FIG>, <FIG>, and <FIG>. For example, the controller receives a service identifier sent by the first network device <NUM>, obtains a service priority based on the service identifier, and calculates a TCP window; and sends the TCP window obtained through calculation to the first network device <NUM>.

An embodiment of the present invention further provides a storage medium, configured to store a software instruction used in the foregoing embodiment, where the storage medium includes a program used to perform the method shown in the foregoing embodiment, and when the program is executed on a computer or a device, the computer or the device is enabled to perform the method in the foregoing method embodiment.

"First" in the first network device mentioned in the embodiments of the present invention is merely used to identify a name, and does not mean the first in sequence. For the words "second" and "third", this rule also applies.

It should be noted that any apparatus embodiment described above is merely an example. Some or all the modules may be selected according to actual needs to achieve the objectives of the solutions of the embodiments. In addition, in the accompanying drawings of the first network device or the controller provided in the embodiments of the present invention, connection relationships between modules indicate that the modules have communication connections with each other, which may be specifically implemented as one or more communications buses or signal cables. A person of ordinary skill in the art may understand and implement the embodiments of the present invention without creative efforts. Methods or algorithm steps described in combination with the content disclosed in this embodiment of the present invention may be implemented by hardware, or may be implemented by a processor by executing a software instruction. The software instruction may include a corresponding software module. The software module may be stored in a random access memory (random access memory, RAM), a flash memory, a read-only memory (read only memory, ROM), an erasable programmable read only memory (erasable programmable ROM, EPROM), an electrically erasable programmable read only memory (electrically EPROM, EEPROM), a hard disk, a removable hard disk, a compact disc, or any other form of storage medium well-known in the art. For example, a storage medium is coupled to a processor, so that the processor can read information from the storage medium or write information into the storage medium. Certainly, the storage medium may be a component of the processor. The processor and the storage medium may be located in the ASIC. In addition, the ASIC may be located in a core network interface device. Certainly, the processor and the storage medium may exist in the core network interface device as discrete components.

A person skilled in the art should be aware that in the foregoing one or more examples, functions described in the present invention may be implemented by hardware, software, firmware, or any combination thereof. When the present invention is implemented by software, the foregoing functions may be stored in a computer-readable medium or transmitted as one or more instructions or code in the computer-readable medium. The computer-readable medium includes a computer storage medium and a communications medium, where the communications medium includes any medium that enables a computer program to be transmitted from one place to another. The storage medium may be any available medium accessible to a general-purpose or dedicated computer.

Claim 1:
A method for sending a service packet, comprising:
receiving (S301), by a first network device, a transmission control protocol, TCP, packet sent by a second network device, wherein the TCP packet comprises a service identifier;
determining (S302), by the first network device based on the service identifier, a priority of a service corresponding to the service identifier;
obtaining (S303), by the first network device, a TCP window based on the priority of the service; and
sending (S304), by the first network device, a first TCP ACK packet to the second network device, wherein the first TCP ACK packet comprises the TCP window, and the TCP window is used by the second network device to calculate a size of the service packet to be sent to the first network device;
wherein the obtaining, by the first network device, a TCP window based on the priority of the service comprises:
when the first network device determines that the priority of the service is a first priority, obtaining service requirement information of the service, and calculating the TCP window based on the service requirement information.