Method and apparatus for queue scheduling - Patents.com
The method addresses network latency and congestion in queue scheduling by ensuring fixed bandwidth allocation and consistent dequeuing times, enhancing network performance in high-latency scenarios.
Patent Information
- Application Number
- JP2022577688
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2020-06-19
- Filing Date
- 2021-06-18
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2041-06-18
AI Technical Summary
Existing queue scheduling methods, such as Deficit Round Robin (DRR), do not effectively address network latency issues, particularly in scenarios requiring ultra-reliable and low-latency communications (URLLC), leading to network congestion and increased latency due to traffic bursts.
A method and apparatus for queue scheduling that ensures fixed bandwidth resource allocation by consuming a packet balance before scheduling subsequent queues, ensuring consistent time periods for dequeuing packets, thereby reducing network latency and preventing congestion.
The proposed method reduces network latency and prevents congestion by maintaining consistent bandwidth utilization across queues, ensuring that each queue is dequeued within a fixed time period, thus improving network performance in high-latency scenarios.
Smart Images

Figure 0007559093000001 
Figure 0007559093000002 
Figure 0007559093000003
Abstract
Description
[Technical field]
[0001] This application claims priority to Chinese Patent Application No. 202010566274.2, entitled “METHOD AND APPARATUS FOR QUEUE SCHEDULING”, filed with the State Intellectual Property Office of the People's Republic of China on June 19, 2020, which is hereby incorporated by reference in its entirety.
[0002] The present application relates to the field of communications, and in particular to a method and apparatus for queue scheduling. [Background technology]
[0003] Quality of service (QoS) is an index that reflects network conditions, including network latency or network congestion. Queue scheduling is an important technique to meet the high requirements for QoS networks. Specifically, queue scheduling is a technique for dequeuing packets buffered in multiple queues according to a specific policy.
[0004] Deficit Round Robin (DRR) scheduling method is a widely used queue scheduling method. In the queue scheduling method, the network bandwidth resources of the device are maximized and used to dequeue packets buffered in each of multiple queues. The queue scheduling method does not take into account the problem of network latency. Therefore, the queue scheduling method is not suitable for application scenarios with high requirements for packet transfer latency, such as the 5th generation (5th generation, 5G) Mobile Communication Technology Technique This is not applicable to the application scenario of Ultra-reliable and Low Latency Communications (URLLC) in the field of wireless LAN. Summary of the Invention [Means for solving the problem]
[0005] The embodiments of the present application provide a method and apparatus for queue scheduling to reduce network latency in a packet transmission process.
[0006] According to a first aspect, a method for queue scheduling is provided. The method may be applied to a first device. The first device may be a network device such as a router or a switch, or may be other devices configured to perform queue scheduling. The method may specifically include the following steps: when the first device schedules a first queue, the first device may obtain a first packet balance and schedule a second queue based on the first packet balance. The first packet balance indicates an amount of packets that can be dequeued from the first queue, and the first queue and the second queue may each be a queue with a high requirement for latency. In other words, an opportunity for scheduling the second queue is determined based on the first packet balance of the first queue to ensure that the bandwidth resources occupied by the first queue and the bandwidth resources occupied by the second queue are essentially in a fixed state, respectively. Compared with a conventional DRR scheduling scheme in which the bandwidth resources occupied by each queue are not fixed, the present application may reduce latency problems caused by network congestion caused by traffic bursts.
[0007] In a possible implementation, the first device may schedule the second queue in the following two manners.
[0008] In the first scheme, the first device may schedule the second queue after the first packet balance is consumed. The first packet balance identifies an amount of packets that can be dequeued from the first queue. The first device may consume the first packet balance by dequeuing packets from the first queue, or may consume the first packet balance by scheduling other queues, or may consume the first packet balance by scheduling the first queue to a waiting state. When the first device cannot consume the first packet balance or after the first packet balance is exhausted, the first device may schedule the second queue. In this way, the total time period of each time of scheduling packets in the first queue may be the same, i.e., it is guaranteed that the time period consumed by the first device each time of scheduling the first queue is essentially the same.
[0009] In the second scheme, the first device may further schedule the second queue when the first packet balance is less than the amount of the leading packet buffered in the first queue. The leading packet buffered in the first queue may be a packet at a first dequeued position in the first queue, and the amount of the leading packet may be the number of bytes of the leading packet, i.e., the length of the leading packet. The first packet balance indicates the amount of packets that can be dequeued from the first queue. If the first packet balance is less than the amount of the leading packet buffered in the first queue, it indicates that the remaining amount of packets that can be dequeued from the first queue cannot meet the requirement for dequeuing the leading packet. Therefore, the first device cannot schedule the packets buffered in the first queue to be dequeued by using the first packet balance, i.e., the scheduling of the first queue ends here. Thus, the first device may schedule the second queue. In this way, the packet scheduling opportunity obtained by the first queue over a long period of time may be equal to or greater than the share (sub-allocation amount) configured for the first queue. In other words, after the first queue is scheduled multiple times, it is guaranteed that the average period of time consumed by the first device to schedule the first queue each time is essentially equal.
[0010] In a possible implementation, the first device may consume the first packet balance in four ways:
[0011] In the first scheme, the amount of packets buffered in the first queue is not 0 and is less than a first packet allocation, the first packet allocation is a sum of a preset total amount of packets that may be dequeued from the first queue during every queue scheduling and a first packet balance obtained during the previous time of scheduling the first queue, and the first packet balance is a difference between the first packet allocation and the amount of packets dequeued from the first queue. Since the amount of packets buffered in the first queue is less than the first packet allocation, when the packets buffered in the first queue are dequeued, the amount of packets buffered in the first queue is reduced to 0. When the amount of packets buffered in the first queue is 0, i.e., when there are no packets to be dequeued from the first queue, the first device cannot consume the first packet balance by scheduling the packets buffered in the first queue to be dequeued. Thus, the first device may consume the remaining first packet balance. In the process of consuming the first packet balance, the first device may schedule a third queue or schedule the first queue to a standby state. The third queue may be a queue that does not have a high requirement for latency, i.e., a queue with a low priority. In this way, each time the first queue is scheduled, the first device may increase the first packet allocation amount based on a preset total amount of packets that can be dequeued from the first queue during each queue scheduling. Therefore, each time the first queue is scheduled, the total amount of packets that can be newly added to and dequeued from the first queue is basically fixed. In addition, since the first device schedules the second queue only after consuming the first packet balance, the time period consumed each time the first queue is scheduled is also basically fixed, i.e., the time period consumed each time the first queue is scheduled by the first device is basically equal.In this way, it can be guaranteed that the network bandwidth resources occupied by the first queue are not occupied by the second queue, so as to prevent network congestion and latency caused by traffic bursts. Furthermore, scheduling the third queue when the amount of packets buffered in the first queue is 0 is equivalent to scheduling the third queue by using the first packet balance that cannot be used by the first queue. This can improve the utilization of network bandwidth resources, on the premise of guaranteeing the latency of the first queue.
[0012] In the second scheme, the amount of packets buffered in the first queue is not 0 but is greater than the first packet quota, the first packet quota being the sum of the preset total amount of packets that can be dequeued from the first queue during every queue scheduling and the first packet balance obtained during the previous time of scheduling the first queue, and the first packet balance being the difference between the first packet quota and the amount of packets dequeued from the first queue. Because the amount of packets buffered in the first queue is greater than the first packet quota, in the process of scheduling the first queue, when the packets buffered in the first queue are dequeued, the amount of packets buffered in the first queue decreases from M1 to M2. When the amount of packets buffered in the first queue M2 is greater than the first packet balance, it indicates that the remaining total amount of packets that can be dequeued from the first queue cannot meet the requirement for dequeuing the remaining amount of packets buffered in the first queue. Therefore, the first device may stop scheduling the first queue and start consuming the first packet balance. In the process of consuming the first packet balance, the first device may schedule the third queue. The third queue may be a queue that does not have a high requirement for latency, i.e., a queue with a low priority. In this way, each time the first queue is scheduled, the first device may increase the first packet allocation amount based on a preset total amount of packets that can be dequeued from the first queue during each queue scheduling. Therefore, each time the first queue is scheduled, the total amount of packets that can be newly added to and dequeued from the first queue is fixed. In addition, since the first device schedules the second queue only after consuming the first packet balance, the time period consumed each time the first queue is scheduled is also fixed, i.e., the time period consumed each time the first queue is scheduled by the first device is essentially equal.In this way, it can be guaranteed that the network bandwidth resources occupied by the first queue are not occupied by the second queue, so as to prevent network congestion and latency caused by traffic bursts. In addition, scheduling the third queue when the amount of packets buffered in the first queue is 0 is equivalent to scheduling the third queue by using the first packet balance that cannot be used by the first queue. This can improve the utilization of network bandwidth resources, subject to guaranteeing the latency of the first queue.
[0013] In the third scheme, the amount of packets buffered in the first queue is not 0 and is greater than the first packet quota, the first packet quota is a preset total amount of packets that can be dequeued from the first queue during every queue scheduling, and the first packet balance is a difference between the first packet quota and the amount of packets dequeued from the first queue. Because the amount of packets buffered in the first queue is less than the first packet quota, in the process of scheduling the first queue, when the packets buffered in the first queue are dequeued, the amount of packets buffered in the first queue decreases from M1 to M2. When the amount of packets buffered in the first queue M2 is greater than the first packet balance, it indicates that the remaining total amount of packets that can be dequeued from the first queue cannot meet the requirement for dequeuing the remaining amount of packets buffered in the first queue. Therefore, the first device may stop scheduling the first queue and start consuming the first packet balance. In the process of consuming the first packet balance, the first device may schedule a third queue. The third queue may be a queue that does not have a high requirement for latency, i.e., a queue with a low priority. In this way, each time the first queue is scheduled, the first device may increase the first packet allocation amount based on a preset total amount of packets that can be dequeued from the first queue during each queue scheduling. Therefore, each time the first queue is scheduled, the total amount of packets that can be newly added to and dequeued from the first queue is fixed. In addition, since the first device schedules the second queue only after consuming the first packet balance, the time period consumed each time the first queue is scheduled is also fixed, i.e., the time period consumed each time the first queue is scheduled by the first device is essentially equal.In this way, it can be guaranteed that the network bandwidth resources occupied by the first queue are not occupied by the second queue, so as to prevent network congestion and latency caused by traffic bursts. In addition, scheduling the third queue when the amount of packets buffered in the first queue is 0 is equivalent to scheduling the third queue by using the first packet balance that cannot be used by the first queue. This can improve the utilization of network bandwidth resources, subject to guaranteeing the latency of the first queue.
[0014] In the fourth scheme, the amount of packets buffered in the first queue is 0, the first packet quota is a preset total amount of packets that may be dequeued from the first queue during every queue scheduling, and the first packet balance is the first packet quota. Thus, when the first queue is scheduled here, the amount of packets dequeued from the first queue is 0, the first packet balance is the first packet quota, and the first packet quota is a preset total amount of packets that may be dequeued from the first queue during every queue scheduling. Before scheduling the second queue, the first device may consume the first packet balance. In the process of consuming the first packet balance, the first device may schedule the third queue or schedule the first queue to a standby state. In this way, even if there are no packets buffered in the first queue, the first device may still schedule the second queue after the first packet balance is exhausted to prevent the second queue from occupying the network bandwidth resources of the first queue.
[0015] In a possible implementation, the first device may schedule the third queue based on the second packet quota. The second packet quota may be a preset total amount of packets that may be dequeued from the third queue during every queue scheduling. When scheduling the third queue, the first device may first obtain the second packet quota, and when the first packet balance is greater than the second packet quota, schedule the packets buffered in the third queue to be dequeued to consume the second packet quota. Thus, every time the first device schedules the first queue, the total amount of packets that may be dequeued from the third queue is limited by the second packet quota. In this way, the third queue cannot over-occupy the network bandwidth resources of the first queue, and the network bandwidth resources of the third queue are not occupied by queues with a priority lower than that of the third queue, so that the latency of the third queue may be reduced.
[0016] In a possible implementation, if the second packet allocation amount is greater than the first packet balance, it indicates that the remaining total amount of packets that can be dequeued from the first queue cannot meet the requirement of the preset total amount of packets that can be dequeued from the third queue during every queue scheduling. Thus, the first device consumes the first packet balance when scheduling the packets buffered in the third queue to be dequeued.
[0017] In a possible implementation, when the first packet balance is greater than the second packet quota, there is a remaining first packet balance after the first device uses up the second packet quota. Thus, the first device may obtain the second packet balance and consume the first packet balance by scheduling the packets buffered in the fourth queue to be dequeued. The second packet balance may be the difference between the first packet balance and the second packet quota, and the fourth queue may be another low-priority queue that has a lower requirement on latency or network bandwidth than the third queue, i.e., the priority of the fourth queue is lower than that of the third queue. In this way, the utilization rate of the first packet balance may be improved, provided that the network bandwidth resource of the third queue is guaranteed not to be occupied by the fourth queue.
[0018] In a possible implementation, the first device may further obtain a second packet quota and a third packet quota, where the second packet quota is a preset total amount of packets that may be dequeued from the third queue during every queue scheduling, and the third packet quota is a product of the first packet balance and a preset weight, where the preset weight is greater than 0 and less than 1. The first device may compare values of the second packet quota and the third packet quota. When the third packet quota is greater than the second packet quota, the first device may consume the second packet quota to schedule packets buffered in the third queue to be dequeued.
[0019] In a possible implementation, the first device may further obtain a second packet quota and a third packet quota, where the second packet quota is a preset total amount of packets that may be dequeued from the third queue during every queue scheduling, and the third packet quota is a product of the first packet balance and a preset weight, where the preset weight is greater than 0 and less than 1. The first device may compare the values of the second packet quota and the third packet quota. When the third packet quota is less than or equal to the second packet quota, the first device may consume the third packet quota to schedule the packets buffered in the third queue to be dequeued. In this way, the first device may schedule the packets buffered in the third queue to be dequeued based on the smaller value of the second packet quota and the third packet quota, so as to prevent the third queue from occupying an excessively large amount of network bandwidth resources and prevent the latency and network congestion of the first queue caused by the traffic burst of the third queue.
[0020] According to a second aspect, a method for queue scheduling is provided. The method is for scheduling a queue set and may be applied to a first device. The first device may be a network device such as a router or a switch, or other device configured to perform queue scheduling. The method may specifically include the following steps: the first device may obtain a first packet balance when scheduling the queue set for the Nth time. The first device may schedule the queue set for the (N+1)th time after the first packet balance is consumed. The queue set includes at least two queues, namely a first queue and a second queue. The first packet balance indicates an amount of packets that can be dequeued from the first queue and the second queue. The first queue and the second queue may each be a queue with a high requirement for latency, and N is an integer equal to or greater than 1. In other words, after the amount of packets that can be dequeued from the first queue and the second queue is exhausted, the first device performs the next queue set scheduling. In other words, the (N+1)th scheduling opportunity is determined based on the first packet balance of the queue set, and the first queue in the queue set is scheduled. To Bandwidth resources occupied by and Ensure that the bandwidth resource occupied by the second queue is essentially fixed. Compared with the traditional DRR scheduling scheme in which the bandwidth resource occupied by each queue is not fixed, the present application can reduce the latency problem caused by the network congestion caused by traffic bursts.
[0021] In a possible implementation, the first device may consume the first packet balance in the following five ways:
[0022] In a first scheme, the scheduling of the second queue is later than the scheduling of the first queue, and the amount of packets buffered in the second queue is not 0 and is less than the second packet quota. The first packet balance includes a second packet balance and a third packet balance, the second packet balance is a difference between the second packet quota and an amount of packets dequeued from the first queue, the second packet quota is a sum of a preset total amount of packets that may be dequeued from the first queue during every queue-set scheduling and the second packet balance obtained during the previous queue-set scheduling, and the third packet balance is a difference between the third packet quota and an amount of packets dequeued from the second queue, and the third packet quota is a sum of a preset total amount of packets that may be dequeued from the second queue during every queue-set scheduling and the third packet balance obtained during the previous queue-set scheduling. Since the amount of packets buffered in the second queue is less than the second packet allocation, when the packets buffered in the second queue are dequeued, the amount of packets buffered in the second queue is reduced to 0. Also, since the scheduling of the first queue is finished, the first device schedules the packets buffered in the first queue or the packets buffered in the second queue to be dequeued. Thus, the first device may consume the first packet balance. In the process of consuming the first packet balance, the first device may schedule the third queue or schedule the queue set to a standby state. The third queue may be a queue that does not have a high requirement for latency, i.e., a queue that has a low priority. In this way, when scheduling the queue set for the Nth time, the first device may increase the first packet allocation based on the preset total amount of packets that may be dequeued from the first queue during every queue scheduling.Therefore, each time the first queue is scheduled, the total amount of packets that can be newly added to and dequeued from the first queue is essentially fixed. In addition, since the first device schedules the queue set for the (N+1)th time only after consuming the first packet balance, the time period consumed each time the queue set is scheduled is also essentially fixed, i.e., the time period consumed each time the queue set is scheduled by the first device is essentially equal. In this way, the first queue in the queue set. To Bandwidth resources occupied by and It can ensure that the bandwidth resource occupied by the second queue is essentially fixed. Furthermore, scheduling the third queue when the amount of packets buffered in the first queue is 0 is equivalent to scheduling the third queue by using the first packet balance that cannot be used by the first queue and the second queue. This can improve the utilization of network bandwidth resources, subject to guaranteeing the latency of the first queue and the second queue.
[0023] In a second scheme, the scheduling of the second queue is later than the scheduling of the first queue, and the amount of packets buffered in the second queue is not 0 and is greater than the second packet quota. The first packet balance includes a second packet balance and a third packet balance, the second packet balance is a difference between the second packet quota and an amount of packets dequeued from the first queue, the second packet quota is a sum of a preset total amount of packets that may be dequeued from the first queue during every queue-set scheduling and the second packet balance obtained during the previous queue-set scheduling, the third packet balance is a difference between the third packet quota and an amount of packets dequeued from the second queue, and the third packet quota is a sum of a preset total amount of packets that may be dequeued from the second queue during every queue-set scheduling and the third packet balance obtained during the previous queue-set scheduling. Since the amount of packets buffered in the second queue is greater than the second packet allocation amount, when the queue set is scheduled for the Nth time, the amount of packets buffered in the second queue decreases from M1 to M2 when the packets buffered in the second queue are dequeued. When the amount of packets buffered in the second queue M2 is greater than the second packet balance, it indicates that the remaining total amount of packets that can be dequeued from the second queue cannot meet the requirement for dequeuing the remaining amount of packets buffered in the second queue. Therefore, the first device may stop scheduling the second queue and start consuming the first packet balance. In the process of consuming the first packet balance, the first device may schedule a third queue or schedule the queue set to a standby state. The third queue may be a queue that does not have a high requirement on latency, i.e., a queue that has a low priority.In this way, when scheduling the queue set for the Nth time, the first device may increase the first packet allocation amount based on the preset total amount of packets that can be dequeued from the first queue during each queue scheduling. Therefore, each time the first queue is scheduled, the total amount of packets that can be newly added to and dequeued from the first queue is essentially fixed. In addition, since the first device schedules the queue set for the (N+1)th time only after consuming the first packet balance, the time period consumed each time the queue set is scheduled is also essentially fixed, i.e., the time period consumed each time the queue set is scheduled by the first device is essentially equal. In this way, the first queue in the queue set. To Bandwidth resources occupied by and It can ensure that the bandwidth resource occupied by the second queue is essentially fixed. Furthermore, scheduling the third queue when the amount of packets buffered in the first queue is 0 is equivalent to scheduling the third queue by using the first packet balance that cannot be used by the first queue and the second queue. This can improve the utilization of network bandwidth resources, subject to guaranteeing the latency of the first queue and the second queue.
[0024] In a third implementation, the scheduling of the second queue is later than the scheduling of the first queue, and the amount of packets buffered in the second queue is not zero and is less than the second packet quota. The first packet balance includes a second packet balance and a third packet balance, the second packet balance being a difference between the second packet quota and the amount of packets dequeued from the first queue, the second packet quota being a preset total amount of packets that may be dequeued from the first queue during every queue set scheduling, and the third packet balance being a difference between the third packet quota and the amount of packets dequeued from the second queue, the third packet quota being a preset total amount of packets that may be dequeued from the second queue during every queue set scheduling. Because the amount of packets buffered in the second queue is less than the second packet quota, when the packets buffered in the second queue are dequeued, the amount of packets buffered in the second queue is reduced to zero. Also, since the scheduling of the first queue is finished, the first device schedules the packets buffered in the first queue or the packets buffered in the second queue to be dequeued. Thus, the first device may consume the first packet balance. In the process of consuming the first packet balance, the first device may schedule the third queue or schedule the queue set to a standby state. The third queue may be a queue that does not have a high requirement for latency, i.e., a queue that has a low priority. In this way, when scheduling the queue set for the Nth time, the first device may increase the first packet allocation amount based on the preset total amount of packets that can be dequeued from the first queue during each queue scheduling. Thus, each time the first queue is scheduled, the total amount of packets that can be newly added to and dequeued in the first queue is basically fixed.In addition, since the first device schedules the queue set for the (N+1)th time only after consuming the first packet balance, the time period consumed each time the queue set is scheduled is also essentially fixed, i.e., the time period consumed each time the queue set is scheduled by the first device is essentially equal. In this manner, the first queue in the queue set. To Bandwidth resources occupied by and It can ensure that the bandwidth resource occupied by the second queue is essentially fixed. Furthermore, scheduling the third queue when the amount of packets buffered in the first queue is 0 is equivalent to scheduling the third queue by using the first packet balance that cannot be used by the first queue and the second queue. This can improve the utilization of network bandwidth resources, subject to guaranteeing the latency of the first queue and the second queue.
[0025] In a fourth implementation, the scheduling of the second queue is later than the scheduling of the first queue, and the amount of packets buffered in the second queue is not 0 and is greater than the second packet quota. The first packet balance includes a second packet balance and a third packet balance, the second packet balance being a difference between the second packet quota and the amount of packets dequeued from the first queue, the second packet quota being a preset total amount of packets that may be dequeued from the first queue during every queue set scheduling, and the third packet balance being a difference between the third packet quota and the amount of packets dequeued from the second queue, the third packet quota being a preset total amount of packets that may be dequeued from the second queue during every queue set scheduling. Because the amount of packets buffered in the second queue is greater than the second packet quota, when the queue set is scheduled for the Nth time, the amount of packets buffered in the second queue decreases from M1 to M2 when the packets buffered in the second queue are dequeued. When the amount M2 of packets buffered in the second queue is greater than the second packet balance, it indicates that the remaining total amount of packets that can be dequeued from the second queue cannot meet the requirement to dequeue the remaining amount of packets buffered in the second queue. Therefore, the first device may stop scheduling the second queue and start consuming the first packet balance. In the process of consuming the first packet balance, the first device may schedule a third queue or schedule the queue set to a standby state. The third queue may be a queue that does not have a high requirement for latency, i.e., a queue with a low priority. In this way, when scheduling the queue set for the Nth time, the first device may increase the first packet allocation amount based on the preset total amount of packets that can be dequeued from the first queue during every queue scheduling.Therefore, each time the first queue is scheduled, the total amount of packets that can be newly added to and dequeued from the first queue is essentially fixed. In addition, since the first device schedules the queue set for the (N+1)th time only after consuming the first packet balance, the time period consumed each time the queue set is scheduled is also essentially fixed, i.e., the time period consumed each time the queue set is scheduled by the first device is essentially equal. In this way, the first queue in the queue set. To Bandwidth resources occupied by and It can ensure that the bandwidth resource occupied by the second queue is essentially fixed. Furthermore, scheduling the third queue when the amount of packets buffered in the first queue is 0 is equivalent to scheduling the third queue by using the first packet balance that cannot be used by the first queue and the second queue. This can improve the utilization of network bandwidth resources, subject to guaranteeing the latency of the first queue and the second queue.
[0026] In a fifth implementation, both the amount of packets buffered in the first queue and the amount of packets buffered in the second queue are 0. The first packet balance includes a second packet balance and a third packet balance, the second packet balance is a difference between the second packet quota and the amount of packets dequeued from the first queue, the second packet quota is a preset total amount of packets that may be dequeued from the first queue during every queue-set scheduling, the third packet balance is a difference between the third packet quota and the amount of packets dequeued from the second queue, the third packet quota is a preset total amount of packets that may be dequeued from the second queue during every queue-set scheduling. Since there are no packets in the first queue and the second queue, the second packet balance is equal to the second packet quota, the third packet balance is equal to the third packet quota, and the first packet balance is equal to the sum of the second packet quota and the third packet quota. In this case, before scheduling the queue set for the (N+1)th time, the first device may consume the first packet balance. In the process of consuming the first packet balance, the first device may schedule a third queue or schedule the first queue to a standby state. In this way, even if there are no packets buffered in the queue set, the first device can still schedule the first queue in the queue set after the first packet balance is exhausted. To Bandwidth resources occupied by and It may ensure that the bandwidth resources occupied by the second queue remain essentially fixed.
[0027] In a possible implementation, the first device may schedule the third queue based on the fourth packet quota. The fourth packet quota may be a preset total amount of packets that may be dequeued from the third queue during every queue scheduling. When scheduling the third queue, the first device may first obtain the fourth packet quota, and when the first packet balance is greater than the fourth packet quota, schedule the packets buffered in the third queue to be dequeued to consume the fourth packet quota. Thus, every time the first device schedules the first queue, the total amount of packets that may be dequeued from the third queue is limited by the fourth packet quota. In this way, the third queue cannot over-occupy the network bandwidth resources of the first queue, and the network bandwidth resources of the third queue are not occupied by queues with a priority lower than that of the third queue, so that the latency of the third queue may be reduced.
[0028] In a possible implementation, when the first packet balance is greater than the fourth packet quota, there is a remaining first packet balance after the first device uses up the fourth packet quota. Thus, the first device may obtain the fourth packet balance and consume the first packet balance by scheduling the packets buffered in the fourth queue to be dequeued. The second packet balance may be the difference between the first packet balance and the fourth packet quota, and the fourth queue may be another low-priority queue that has a lower requirement on latency or network bandwidth than the third queue, i.e., the priority of the fourth queue is lower than that of the third queue. In this way, the utilization rate of the first packet balance may be improved, provided that the network bandwidth resource of the third queue is guaranteed not to be occupied by the fourth queue.
[0029] In a possible implementation, if the fourth packet allocation amount is greater than the first packet balance, it indicates that the remaining total amount of packets that can be dequeued from the first queue cannot meet the requirement of the preset total amount of packets that can be dequeued from the third queue during every queue scheduling. Thus, the first device consumes the first packet balance when scheduling the packets buffered in the third queue to be dequeued.
[0030] According to a third aspect, an apparatus for queue scheduling is provided. The apparatus has a corresponding function for implementing the method for queue scheduling in the first aspect or any one of the possible implementations of the first aspect. The apparatus includes at least one unit, and the at least one unit is configured to implement the method for queue scheduling provided in the first aspect or any one of the possible implementations of the first aspect. In one implementation, the apparatus includes a first obtaining unit configured to obtain a first packet balance when the first queue is scheduled, the first packet balance indicating an amount of packets that can be dequeued from the first queue, and a first scheduling unit configured to schedule the second queue based on the first packet balance.
[0031] According to a fourth aspect, an apparatus for queue scheduling is provided. The apparatus has a corresponding function for implementing the method for queue scheduling in the second aspect or any one of the possible implementations of the second aspect. The apparatus includes at least one unit, and the at least one unit is configured to implement the method for queue scheduling provided in the second aspect or any one of the possible implementations of the second aspect. In one implementation, the apparatus includes a first obtaining unit configured to obtain a first packet balance when a queue set is scheduled for an Nth time, the queue set includes a first queue and a second queue, the first packet balance indicates an amount of packets that can be dequeued from the first queue and the second queue, N being an integer equal to or greater than 1, and a first scheduling unit configured to schedule the queue set for an (N+1)th time after the first packet balance is consumed.
[0032] According to a fifth aspect, an apparatus for queue scheduling is provided. The apparatus includes a processor and a memory, the memory being configured to store a program supporting the apparatus in performing the method for queue scheduling provided in the first or second aspect, and to store data used to implement the method for queue scheduling provided in the first or second aspect. The processor is configured to execute the program stored in the memory. The apparatus may further include a communication bus, the communication bus being configured to establish a connection between the processor and the memory.
[0033] According to a sixth aspect, there is provided a computer readable storage medium storing instructions which, when executed on a computer, enable the computer to perform a method for queue scheduling according to the first or second aspect.
[0034] According to a seventh aspect, there is provided a computer program product comprising instructions which, when run on a computer, enable the computer to perform a method for queue scheduling according to the first or second aspect. [Brief description of the drawings]
[0035] [Figure 1] 1 is a schematic diagram of the architecture of a system 10 according to an embodiment of the present application. [Diagram 2] 2 is a flowchart of a method for queue scheduling according to an embodiment of the present application. [Diagram 3] 4 is a flowchart of another method for queue scheduling according to an embodiment of the present application. [Figure 4] 13 is a flowchart of yet another method for queue scheduling according to an embodiment of the present application. [Diagram 5] 13 is a flowchart of yet another method for queue scheduling according to an embodiment of the present application. [Figure 6] 13 is a flowchart of yet another method for queue scheduling according to an embodiment of the present application. [Figure 7] 13 is a flowchart of yet another method for queue scheduling according to an embodiment of the present application. [Figure 8] 7 is a schematic diagram of the structure of an apparatus 700 for queue scheduling according to an embodiment of the present invention. [Figure 9] FIG. 8 is a schematic diagram of the structure of another apparatus 800 for queue scheduling according to an embodiment of the present application. [Figure 10] 1 is a schematic diagram of the structure of a device 1000 according to an embodiment of the present application. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0036] DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS The following describes the method and apparatus for queue scheduling provided in the prior art and in the embodiments of the present application with reference to the accompanying drawings.
[0037] In a typical DRR scheduling method, the network bandwidth resource of the device is maximized and used to dequeue the packets buffered in each of the multiple queues. Specifically, the device sequentially schedules the multiple DRR queues included in the DRR queue set of the device, where sequential scheduling refers to scheduling the multiple DRR queues one by one according to a specific scheduling order, and the scheduling order may be determined based on priority or system settings. For example, the DRR queue set includes a first DRR queue and a second DRR queue. In each queue scheduling process, the device A schedules according to the order of the first DRR queue and the second DRR queue. When the device A determines that there are packets buffered in the first DRR queue (packets waiting to be dequeued), the device A obtains a packet quota corresponding to the first DRR queue, and schedules the packets buffered in the first DRR queue to be dequeued by using the packet quota corresponding to the first DRR queue. The packet quota corresponding to the first DRR queue is a preset total amount of packets that may be dequeued from the first DRR queue during every queue scheduling. If the device A determines that there are no buffered packets in the first DRR queue, the device A schedules the second DRR queue. If the device A determines that there are buffered packets in the second DRR queue (packets waiting to be dequeued), the device A obtains the packet quota corresponding to the second DRR queue and schedules the buffered packets in the second DRR queue to be dequeued by using the packet quota corresponding to the second DRR queue. The packet quota corresponding to the second DRR queue is a preset total amount of packets that may be dequeued from the second DRR queue during every queue scheduling.The ratio of the packet quota corresponding to the first DRR queue to the packet quota corresponding to the second DRR queue may be fixed, for example, 1:2 or 3:1. This ratio is the same as the ratio of the port bandwidth occupied by the first DRR queue to the port bandwidth occupied by the second DRR queue. For example, the port rate corresponding to the DRR queue set is 300 Mbps, the packet quota corresponding to the first DRR queue is 1000 bytes, and the packet quota corresponding to the second DRR queue is 2000 bytes. Packets buffered in the first DRR queue may be dequeued at a maximum rate of (1000 / (2000+1000))*300=100 Mbps, and packets buffered in the second DRR queue may be dequeued at a maximum rate of (2000 / (2000+1000))*300=200 Mbps. If all packets buffered in the first DRR queue are dequeued before the packet quota corresponding to the first DRR queue is exhausted, the device A directly schedules the second DRR queue. The case where the DRR queue set includes three or more DRR queues is similar to this case, and the details are not described again here. In the process of the device A performing queue scheduling for multiple DRR queues in the DRR queue set, if at least one DRR queue is often in a state where it does not buffer packets, other DRR queues included in the DRR queue set may obtain scheduling opportunities that exceed the proportion of the port bandwidth of other DRR queues, that is, other DRR queues in the DRR queue set may occupy an excessively large amount of bandwidth. For example, if the first DRR queue is always empty (no packets are buffered), packets buffered in the second DRR queue may be dequeued at a rate of 300 Mbps. If a traffic burst occurs in a DRR queue that occupies an excessively large amount of bandwidth, network congestion may occur, causing long latency in packet transmission.For example, device A sends packets buffered in a first DRR queue to device B and sends packets buffered in a second DRR queue to device C. If the maximum rate at which device B receives packets and the maximum rate at which device C receives packets are both 200 Mbps, and device A sends packets buffered in the second DRR queue to device C at a rate of 300 Mbps, packet congestion will occur at device C, resulting in long latency.
[0038] To solve the aforementioned latency problem, the embodiments of the present application provide a method and apparatus for queue scheduling to reduce the latency in the packet transmission process and meet the packet transmission requirements in scenarios with high requirements on latency.
[0039] 1 is a schematic diagram of an architecture of a system 10 according to an embodiment of the present application. As shown in FIG. 1, the system 10 includes a first device 11, a second device 12, and a third device 13. The first device 11 can communicate with the second device 12 and the third device 13. The first device 11, the second device 12, and the third device 13 may each be a device having a forwarding function, such as a router or a switch, or may be a device having a forwarding function, such as a server or a terminal device.
[0040] A terminal device is a device or a chip disposed in a device that provides voice and / or data connectivity to a user. Currently, some examples of terminal devices are wireless terminals in industrial control, wireless terminals in self driving, wireless terminals in remote medical surgery, wireless terminals in smart grids, wireless terminals in transportation safety, wireless terminals in smart cities, wireless terminals in smart homes, residential gateway devices (5G-residential gateways, 5G-RGs) supporting 5G access, etc.
[0041] Fig. 2 is a flow chart of a method for queue scheduling according to an embodiment of the present application. In this embodiment, scheduling is performed by using a queue as a unit, that is, a queue is scheduled every time. With reference to Fig. 2, the following describes the method for queue scheduling provided in this embodiment of the present application.
[0042] S201: A first device obtains a first packet balance when scheduling a first queue, where the first packet balance indicates an amount of packets that can be dequeued from the first queue.
[0043] For example, the first packet quota is a preset total amount of packets that may be dequeued from the first queue during every queue scheduling, or the first packet quota is a sum of the preset total amount of packets that may be dequeued from the first queue during every queue scheduling and a first packet balance obtained during the previous time of scheduling the first queue. The first device may schedule the packets buffered in the first queue to be dequeued by using the first packet quota. For example, after the first packet buffered in the first queue is dequeued, the first packet quota is decreased by a value corresponding to the first packet. The first packet balance is less than or equal to the first packet quota. In other words, when there are packets buffered in the first queue, after the packets buffered in the first queue are dequeued, the value of the first packet quota is decreased to obtain the first packet balance. The amount of packets may be a length of packets or a quantity of packets. If the amount of packets is a quantity of packets, the lengths of all packets may be equal. The specific form of the amount of packets can be set according to requirements.
[0044] In this embodiment of the present application, the first packet balance, the first packet quota, the subsequent second packet balance, the subsequent second packet quota, etc., indicating the amount of packets that may be dequeued from the queue, may be calculated by using a counter corresponding to the queue or tokens in a token bucket.
[0045] S202: The first device schedules the second queue based on the first packet balance.
[0046] In this embodiment of the present application, the first device schedules the second queue in the following two ways: Method 1: The first device schedules the second queue after the first packet balance is consumed. Method 2: When the first packet balance is less than the amount of the leading packet buffered in the first queue, the first device schedules the second queue. For Method 1, the first device may schedule the third queue or schedule the first queue to a waiting state in the process of consuming the first packet balance. Compared with the first queue, the third queue may be a queue that does not have a high requirement on latency or a queue that has a lower priority. The third queue is scheduled by using the first packet balance, so that the utilization rate of the port bandwidth corresponding to the third queue may be improved under the premise of guaranteeing the latency. In the case of the method 2, when the first packet balance is equal to or greater than the amount of the leading packet buffered in the first queue, the first device may perform the method of scheduling the packets buffered in the first queue to be dequeued as described in S201. The second queue is scheduled in the method 1, so that the total time period of each time of scheduling the packets in the first queue may be the same. The second queue is scheduled in the method 2, so that the packet scheduling opportunity obtained by the first queue over a long period of time may be equal to or greater than the share (sub-allocation amount) configured for the first queue.
[0047] In the following, using Scheme 1 as an example, a related description of six schemes is provided for the first device to schedule the first queue and the third queue before scheduling the second queue. In the following scheduling schemes, the third queue can be a best effort (BE) queue or a Surplus Round-Robin (SRR) queue.
[0048] Scheduling method 1: A first device schedules packets buffered in a first queue to be dequeued, the first device consumes a first packet balance when the amount of packets buffered in the first queue is 0, and the first device schedules a third queue in the process of consuming the first packet balance.
[0049] Scheduling method 2: The first device schedules packets buffered in the first queue to be dequeued, the first device consumes a first packet balance when the amount of packets buffered in the first queue is 0, and the first device schedules the first queue to a waiting state in the process of consuming the first packet balance. Scheduling the first queue to a waiting state means not scheduling packets buffered in the first queue to be dequeued.
[0050] In the above-mentioned scheduling method 1 and scheduling method 2, the amount of packets buffered in the first queue is not 0, and the first packet allocation amount can meet the requirement for dequeuing the packets buffered in the first queue. In other words, after all packets buffered in the first queue are dequeued, the first packet balance is not 0. In this case, the first device consumes the first packet balance before scheduling the second queue.
[0051] Scheduling method 3: The first device schedules packets buffered in the first queue to be dequeued, and the amount of packets buffered in the first queue is M1, where M1 is an integer greater than or equal to 1, and the first device consumes the first packet balance when the amount of packets buffered in the first queue, M2, is greater than the first packet balance, where M2 is less than or equal to M1, and the amount of packets dequeued from the first queue is the difference between M1 and M2, and the first device schedules the third queue in the process of consuming the first packet balance.
[0052] Scheduling method 4: The first device schedules packets buffered in the first queue to be dequeued, where an amount of packets buffered in the first queue is M1, where M1 is an integer equal to or greater than 1, the first device consumes the first packet balance when the amount of packets buffered in the first queue M2 is greater than the first packet balance, where M2 is equal to or less than M1, and the amount of packets dequeued from the first queue is the difference between M1 and M2, and the first device schedules the first queue to a waiting state in the process of consuming the first packet balance. Scheduling the first queue to a waiting state means not scheduling packets buffered in the first queue to be dequeued.
[0053] In the above-mentioned scheduling method 3 and scheduling method 4, the amount of packets buffered in the first queue is not 0, and the first packet allocation amount cannot meet the requirement for dequeuing the packets buffered in the first queue, that is, the first packet balance does not meet the requirement for dequeuing the packets buffered in the first queue. In other words, the first packet balance is less than the amount of packets buffered in the first queue. In this case, the first device consumes the first packet balance before scheduling the second queue.
[0054] In any one of the above-mentioned scheduling methods 1 to 4, the first packet allocation amount is S201 The first packet balance may be any packet quota in the first queue, and the first packet balance is the difference between the first packet quota and the amount of packets dequeued from the first queue. In the following scheduling scheme 5 and scheduling scheme 6, the first packet balance is the first packet quota, the first packet quota is a preset total amount of packets that may be dequeued from the first queue during every queue scheduling, and the amount of packets initially buffered in the first queue is 0, i.e., the first queue is initially an empty queue.
[0055] Scheduling method 5: The first device consumes a first packet balance when the amount of packets buffered in the first queue is 0, and the first device schedules the third queue in the process of consuming the first packet balance.
[0056] Scheduling method 6: The first device consumes a first packet balance when the amount of packets buffered in the first queue is 0, and the first device schedules the first queue to a waiting state in the process of consuming the first packet balance. Scheduling the first queue to a waiting state means not scheduling the packets buffered in the first queue to be dequeued.
[0057] In the above six scheduling schemes, in the process of consuming the first packet balance, the first device may schedule the third queue in the following four schemes:
[0058] Scheduling scheme 1: the first device obtains a second packet quota, the second packet quota being a preset total amount of packets that may be dequeued from the third queue during every queue scheduling, and the first device consumes the second packet quota to schedule the packets buffered in the third queue to be dequeued when the first packet balance is greater than the second packet quota. Optionally, after the packets buffered in the third queue are scheduled to be dequeued in the scheduling scheme, the method further includes: the first device obtains a second packet balance, the second packet balance being a difference between the first packet balance and the second packet quota, and the first device consumes the second packet balance to schedule the packets buffered in the fourth queue to be dequeued. Compared with the third queue, the fourth queue may be a queue with a lower priority or a queue with a lower requirement for latency.
[0059] Scheduling method 2: The first device obtains a second packet quota, the second packet quota being a preset total amount of packets that may be dequeued from the third queue during every queue scheduling, and the first device schedules packets buffered in the third queue to be dequeued by consuming the first packet balance when the first packet balance is less than or equal to the second packet quota.
[0060] Scheduling Scheme 3: The first device obtains a second packet quota and a third packet quota, where the second packet quota is a preset total amount of packets that may be dequeued from the third queue during every queue scheduling, and the third packet quota is a product of the first packet balance and a preset weight, where the preset weight is greater than 0 and less than 1, and when the third packet quota is greater than the second packet quota, the first device consumes the second packet quota to schedule the packets buffered in the third queue to be dequeued. Optionally, after the packets buffered in the third queue are scheduled to be dequeued in the scheduling scheme, the method further includes: the first device obtains a third packet balance, where the third packet balance is a difference between the third packet quota and the second packet quota, and the first device consumes the third packet balance to schedule the packets buffered in the fourth queue to be dequeued.
[0061] Scheduling method 4: The first device obtains a second packet quota and a third packet quota, the second packet quota being a preset total amount of packets that may be dequeued from the third queue during every queue scheduling, the third packet quota being a product of the first packet balance and a preset weight, the preset weight being greater than 0 and less than 1, and when the third packet quota is less than or equal to the second packet quota, the first device consumes the third packet quota to schedule packets buffered in the third queue to be dequeued.
[0062] In the above four scheduling schemes, the first device may schedule the third queue by using a conventional scheduling method, such as a First-in First-out (FIFO) scheduling method or a Hierarchical Quality of Service (HQoS) scheduling method, which is not limited in this embodiment of the present application.
[0063] In another embodiment provided in the present application, based on the method provided in the embodiment corresponding to FIG. 2, the first device may obtain a corresponding duration based on the port bandwidth allocated to the queue, any acquired packet quota, or any acquired packet balance, and perform queue scheduling based on the duration. The concept of performing queue scheduling by the first device based on the duration is the same as the above-mentioned concept of performing queue scheduling based on the packet quota and the packet balance, except that the step of consuming the packet balance or the step of consuming the packet quota is replaced with the step of making a timeout decision based on the duration. The packet quota can be any packet quota mentioned in this embodiment of the present application. The packet balance can be any packet balance mentioned in this embodiment of the present application.
[0064] In yet another embodiment provided in the present application, after consuming the first packet balance, the first device may not schedule the second queue and continue to schedule the first queue based on the method provided in the embodiment corresponding to Fig. 2. For the manner in which the first device schedules the first queue, please refer to the method provided in the embodiment corresponding to Fig. 2.
[0065] FIG. 3 is a flowchart of a method for queue scheduling according to an embodiment of the present application. In this embodiment, queue scheduling is performed by using a queue set as a unit, that is, a queue set is scheduled every time. The queue set in this embodiment includes a first queue and a second queue. A scenario in which a queue set includes three or more queues is not described again in this embodiment of the present application. For details, please refer to the method provided in the following embodiment. With reference to FIG. 3, the method for queue scheduling provided in this embodiment of the present application is described below.
[0066] S301: A first device obtains a first packet balance when scheduling a queue set for the Nth time, the first packet balance indicating a sum of an amount of packets that can be dequeued from a first queue and an amount of packets that can be dequeued from a second queue, where N is an integer greater than or equal to 1.
[0067] For example, the first packet balance indicates the sum of the amount of packets that can be dequeued from all queues included in the queue set. For the meaning of the amount of packets in this embodiment of the present application, please refer to the corresponding content in the embodiment corresponding to FIG. 2. The first packet balance includes a second packet balance and a third packet balance. The second packet balance is the difference between the second packet quota and the amount of packets dequeued from the first queue. The second packet quota is the sum of the preset total amount of packets that can be dequeued from the first queue during every queue set scheduling and the second packet balance obtained during the previous queue set scheduling, or the second packet quota is the preset total amount of packets that can be dequeued from the first queue during every queue set scheduling. The third packet balance is the difference between the third packet quota and the amount of packets dequeued from the second queue. The third packet allocation amount is a sum of a preset total amount of packets that may be dequeued from the second queue during every queue-set scheduling and a third packet balance obtained during a previous queue-set scheduling, or the third packet allocation amount is a preset total amount of packets that may be dequeued from the second queue during every queue-set scheduling.
[0068] S302: The first device schedules the queue set for the (N+1)th time after the first packet balance is consumed.
[0069] For the method in which the first device schedules the queue set for the (N+1)th time, please refer to the method in which the first device schedules the queue set for the Nth time in this embodiment, and the details will not be described again here.
[0070] In this embodiment, before scheduling the queue set for the (N+1)th time, the first device may consume the obtained first packet balance in the following four manners: The first device first schedules the first queue, and schedules the second queue after completing the scheduling of the first queue; The first device may obtain a second packet quota and a second packet balance in the process of scheduling the first queue; The first device may obtain a third packet quota and a third packet balance in the process of scheduling the second queue; The subsequent third queue may be a BE queue or an SRR queue. This is not limited in this embodiment of the present application.
[0071] Scheduling method 1: The first device schedules packets buffered in the second queue to be dequeued, and the scheduling of the second queue during every queue set scheduling is later than the scheduling of the first queue, the first device consumes the first packet balance when the amount of packets buffered in the second queue is 0, and the first device schedules the third queue in the process of consuming the first packet balance.
[0072] Scheduling method 2: the first device schedules packets buffered in the second queue to be dequeued, the scheduling of the second queue during every queue set scheduling is later than the scheduling of the first queue, the first device consumes the first packet balance when the amount of packets buffered in the second queue is 0, and the first device schedules the queue set to a waiting state in the process of consuming the first packet balance. Scheduling the queue set to a waiting state means not scheduling packets buffered in any queue in the queue set to be dequeued.
[0073] Scheduling method 3: The first device schedules packets buffered in a second queue to be dequeued, and an amount of packets buffered in the second queue is M1, where M1 is an integer equal to or greater than 1, and the scheduling of the second queue during each queue set scheduling is later than the scheduling of the first queue, and the first device consumes the first packet balance when the amount of packets buffered in the second queue is greater than a third packet balance, where M2 is less than or equal to M1, and 2 The amount of packets dequeued from the queue is the difference between M1 and M2, and the first device schedules the third queue in the process consuming the first packet balance.
[0074] Scheduling method 4: The first device schedules packets buffered in a second queue to be dequeued, and an amount of packets buffered in the second queue is M1, where M1 is an integer equal to or greater than 1, and the scheduling of the second queue during each queue set scheduling is later than the scheduling of the first queue, and the first device consumes the first packet balance when the amount of packets buffered in the second queue is greater than a third packet balance, where M2 is less than or equal to M1, and 2 The amount of packets dequeued from the queues is the difference between M1 and M2, and the first device schedules the queue set to a standby state in the process of consuming the first packet balance. Scheduling the queue set to a standby state means not scheduling any buffered packets to be dequeued in any queue in the queue set.
[0075] In the above four scheduling schemes, the second packet allocation amount may be any second packet allocation amount mentioned in S301, and the third packet allocation amount may be any third packet allocation amount mentioned in S301.
[0076] In the following scheduling scheme 5 and scheduling scheme 6, both the first queue and the second queue are empty queues, and the sequence of scheduling the first queue and the second queue by the first device is the same as the sequence of scheduling queues in the above four scheduling schemes. The second packet quota is a preset total amount of packets that may be dequeued from the first queue during every queue set scheduling. The third packet quota is a preset total amount of packets that may be dequeued from the second queue during every queue set scheduling.
[0077] Scheduling method 5: The first device consumes the first packet balance when the amount of packets buffered in the second queue is 0, and the scheduling of the second queue during every queue set scheduling is later than the scheduling of the first queue, and the first device schedules the third queue in the process of consuming the first packet balance.
[0078] Scheduling method 6: The first device consumes the first packet balance when the amount of packets buffered in the second queue is 0, and the scheduling of the second queue during every queue set scheduling is later than the scheduling of the first queue, and the first device schedules the queue set to a waiting state in the process of consuming the first packet balance.
[0079] In the six scheduling schemes mentioned above, the first device may schedule the third queue in the following four schemes.
[0080] Scheduling scheme 1: the first device obtains a fourth packet quota, the fourth packet quota being a preset total amount of packets that may be dequeued from the third queue during every scheduling, and the first device consumes the fourth packet quota to schedule the packets buffered in the third queue to be dequeued when the first packet balance is greater than the fourth packet quota. Optionally, after the packets buffered in the third queue are scheduled to be dequeued, the method further includes: the first device obtains a fourth packet balance, the fourth packet balance being a difference between the first packet balance and the fourth packet quota, and the first device consumes the fourth packet balance to schedule the packets buffered in the fourth queue to be dequeued.
[0081] Scheduling method 2: The first device obtains a fourth packet quota, the fourth packet quota being a preset total amount of packets that may be dequeued from the third queue during every scheduling, and when the first packet balance is less than or equal to the fourth packet quota, the first device consumes the first packet balance to schedule packets buffered in the third queue to be dequeued.
[0082] Scheduling scheme 3: the first device obtains a fourth packet quota and a fifth packet quota, the fourth packet quota being a preset total amount of packets that may be dequeued from the third queue during every scheduling, the fifth packet quota being a product of the first packet quota and a weight, the weight being greater than 0 and less than 1, and the first device consumes the fourth packet quota to schedule the packets buffered in the third queue to be dequeued when the fifth packet quota is greater than the fourth packet quota. Optionally, after the packets buffered in the third queue are scheduled to be dequeued, the method further includes the first device obtaining a fourth packet balance, the fourth packet balance being a difference between the fifth packet quota and the fourth packet quota, and the first device consuming the fourth packet balance to schedule the packets buffered in the fourth queue to be dequeued.
[0083] Scheduling method 4: The first device obtains a fourth packet quota and a fifth packet quota, the fourth packet quota being a preset total amount of packets that may be dequeued from the third queue during every scheduling, the fifth packet quota being a product of the first packet quota and a weight, the weight being greater than 0 and less than 1, and the first device schedules to consume the fifth packet quota to dequeue packets buffered in the third queue when the fifth packet quota is less than or equal to the fourth packet quota.
[0084] In another embodiment provided in the present application, based on the method provided in the embodiment corresponding to FIG. 3, the first device may obtain a corresponding duration based on the port bandwidth allocated to the queue, any acquired packet quota, or any acquired packet balance, and perform queue scheduling based on the duration. The concept of performing queue scheduling by the first device based on the duration is the same as the above-mentioned concept of performing queue scheduling based on the packet quota and the packet balance, except that the step of consuming the packet balance or the step of consuming the packet quota is replaced with the step of making a timeout decision based on the duration. The packet quota can be any packet quota mentioned in this embodiment of the present application. The packet balance can be any packet balance mentioned in this embodiment of the present application.
[0085] 4 is a flowchart of a method for queue scheduling according to an embodiment of the present application. With reference to FIG. 4, the following describes the method for queue scheduling provided in this embodiment of the present application.
[0086] S401: A first device acquires a deficit surplus round robin (DSRR) queue set and parameters corresponding to each DSRR queue included in the DSRR queue set.
[0087] For example, the deficit surplus round robin queue set may be the queue set mentioned in the embodiment corresponding to Fig. 3. The DSRR queue may be the first queue or the second queue in the embodiment corresponding to Fig. 2 or Fig. 3. The DSRR queue set may include at least two DSRR queues, and the at least two DSRR queues are used for packet transmission. The parameters corresponding to each DSRR queue in the DSRR queue set include a packet sub-quota, a packet quota, and a packet balance corresponding to the DSRR queue.
[0088] In the following, the parameters corresponding to the DSRR queues are described by using an example in which the DSRR queue set includes a first DSRR queue. The packet quota corresponding to the first DSRR queue may be a preset amount of packets that can be dequeued from the first DSRR queue during every queue scheduling, or the packet quota corresponding to the first DSRR queue may be a sum of a preset amount of packets that can be dequeued from the first DSRR queue during every queue scheduling and a packet balance corresponding to the first DSRR queue during the last time of the scheduling corresponding to the first DSRR queue. The preset amount of packets that can be dequeued from the first DSRR queue during every queue scheduling may be referred to as a packet sub-quota corresponding to the first DSRR queue. Dequeuing refers to sending a packet from the queue. The packet quota corresponding to the first DSRR queue may be a first packet quota in an embodiment corresponding to FIG. 2. The packet balance corresponding to the first DSRR queue indicates a remaining amount of packets that can be dequeued from the first DSRR queue. The packet balance corresponding to the first DSRR queue may be a first packet balance in an embodiment corresponding to FIG. 2. In this embodiment of the present application, the packet balance corresponding to the first DSRR queue may be the difference between the packet quota corresponding to the first DSRR queue and the amount of packets dequeued from the first DSRR queue.
[0089] As mentioned above, the amount of packets may represent the length of a packet or may represent the quantity of packets. For ease of explanation, the length of a packet is uniformly used as an example for the following explanation. When the amount of packets indicates the length of a packet, the units of the three parameters, i.e., packet sub-allocation amount, packet allocation amount, and packet balance, may be units of data, such as bit (b), byte (B), and kilobyte (KB). For example, if the packet sub-allocation amount corresponding to the first DSRR queue is 1000 bits, the total length of packets that can be dequeued from the first DSRR queue during every scheduling can be further increased by 1000 bits. If the packet allocation amount corresponding to the first DSRR queue is 1100 bits, it indicates that packets with a total length of 1100 bits in the first DSRR queue can be dequeued in sum during this queue scheduling. If the packet balance corresponding to the first DSRR queue is 1100 bits, it indicates that packets with a total length of 1100 bits still remain in the first DSRR queue and can be dequeued. For ease of later description, the DSRR queue set in this embodiment includes M DSRR queues, where M is an integer equal to or greater than 2. The packet sub-quota corresponding to the i-th DSRR queue among the M DSRR queues is represented by Q1[i], the packet quota corresponding to the i-th DSRR queue is represented by Q2[i], and the packet balance corresponding to the i-th DSRR queue is represented by DC[i], where the value range of i can be represented as 1≦i≦M.
[0090] In the following, for the purpose of explanation, an example is used in which the first device processes the i-th DSRR queue. The first device may be the first device 11 in FIG. 1 or the first device in the embodiment corresponding to FIG. 2, and the i-th DSRR queue may be any DSRR queue in the DSRR queue set. For how the first device processes all DSRR queues in the DSRR queue set, please refer to how the first device processes the i-th DSRR queue. Examples are not described one by one.
[0091] S402: The first device modifies a packet quota corresponding to the i-th DSRR queue based on a packet sub-quota corresponding to the i-th DSRR queue.
[0092] For example, when the first device processes the i-th DSRR queue, the first device may first determine the packet quota corresponding to the i-th DSRR queue. For example, the first device may obtain the sum of Q1[i] and DC[i] obtained during the previous queue scheduling, and assign the sum to Q2[i]. Therefore, the total length of packets that can be dequeued from the i-th DSRR queue during the current queue scheduling is Q2[i]. For example, the packet sub-quota Q1[i] corresponding to the i-th DSRR queue is equal to 1000 bits, and the packet balance DC[i] corresponding to the i-th DSRR queue during the previous queue scheduling is equal to 10 bits. During the current queue scheduling, the packet quota Q2[i] corresponding to the i-th DSRR queue is 1000+10=1010 bits. Specifically, the total length of packets that can be dequeued from the i-th DSRR queue during the current queue scheduling is 1010 bits.
[0093] S403: The first device determines whether there is a packet to be dequeued from the i-th DSRR queue. If there is no packet to be dequeued from the i-th DSRR queue, the first device performs S406, or if there is a packet to be dequeued from the i-th DSRR queue, the first device performs S404.
[0094] For example, the first device sets a counter with an initial value of 0 for the i-th DSRR queue in the DSRR queue set. Each time a packet enters the i-th DSRR queue, the value of the counter corresponding to the i-th DSRR queue is increased by 1. Each time a packet is dequeued from the i-th DSRR queue, the value of the counter corresponding to the i-th DSRR queue is decreased by 1. In this way, by determining whether the value of the counter corresponding to the i-th DSRR queue is 0, the first device can determine whether there is a packet to be dequeued from the i-th DSRR queue. Of course, the first device can further determine whether there is a packet to be dequeued from the i-th DSRR queue by determining whether the packet is buffered in the storage space corresponding to the i-th DSRR queue.
[0095] S404: The first device determines whether the length of the head packet in the i-th DSRR queue is greater than the packet balance corresponding to the i-th DSRR queue. If the length of the head packet corresponding to the i-th DSRR queue is less than or equal to the packet balance corresponding to the i-th DSRR queue, the first device performs S405, or if the length of the head packet in the i-th DSRR queue is greater than the packet balance corresponding to the i-th DSRR queue, the first device performs S407.
[0096] For example, packets buffered in the i-th DSRR queue are dequeued sequentially. When there is at least one packet dequeued from the i-th DSRR queue, the packet that is in the first dequeued position and is within the at least one dequeued packet may be referred to as the leading packet. The leading packet of the i-th DSRR queue is the packet that is dequeued first from the i-th DSRR queue. The length of the leading packet of the i-th DSRR queue is represented by L[i]. The length L[i] of the leading packet of the i-th DSRR queue does not need to be a fixed value, and the length value changes based on the change of the leading packet of the i-th DSRR queue.
[0097] For example, before the head packet in the i-th DSRR queue is dequeued, the first device may determine whether the length L[i] of the head packet to be dequeued is greater than DC[i], and perform S405 or S407 based on the determination result. Specifically, if L[i] is less than or equal to DC[i], the first device performs S405, or if L[i] is greater than DC[i], the first device performs S407.
[0098] S405: The first device dequeues the head packet buffered in the i-th DSRR queue, subtracts the length of the head packet corresponding to the i-th DSRR queue from the packet balance corresponding to the i-th DSRR queue, and returns to perform S403.
[0099] For example, the packet balance DC[i] corresponding to the i-th DSRR queue indicates the total length of the remaining packets that can be dequeued from the i-th DSRR queue. When L[i] is less than or equal to DC[i], it indicates that the packet balance corresponding to the i-th DSRR queue meets the requirements for dequeuing the leading packet, that is, the leading packet can be dequeued. The first device may move the leading packet in the i-th DSRR queue from the i-th DSRR queue and send the leading packet to another device. For example, when the first device is the device 11 shown in FIG. 1, the first device may send the leading packet in the i-th DSRR queue to the device 12.
[0100] For example, when S403 is performed for the first time after S402, the value of DC[i] may be equal to the packet allocation amount Q2[i] of the i-th DSRR queue. However, when performing S405, after the top packet in the i-th DSRR queue is dequeued, the first device may subtract L[i] from DC[i] and reallocate the difference between L[i] and DC[i] to DC[i], i.e., update DC[i]. The first device updates DC[i], which indicates that the action of dequeuing the top packet causes the consumption of the length of L[i] in the total length of the remaining packets that can be dequeued from the i-th DSRR queue. For example, if the packet balance DC[i] corresponding to the i-th DSRR queue before the packet is dequeued is 1010 bits, and the length L[i] of the top packet in the i-th DSRR queue is 100 bits, the first device may update DC[i] to 910 bits after the packet having a length of 100 bits is dequeued.
[0101] For example, after the head packet in the i-th DSRR queue is dequeued, the first device performs S403 to determine again whether the i-th DSRR queue is empty, and performs corresponding processing according to the determination result until there is no packet to be dequeued from the i-th DSRR queue or the packet balance corresponding to the i-th DSRR queue is less than the length of the head packet. If there is a head packet in the i-th DSRR queue and the length of the head packet is less than or equal to the packet balance corresponding to the i-th DSRR queue, the packet in the i-th DSRR queue can be dequeued. If the total length of k (k≧0) packets located at the head of the i-th DSRR queue is less than DC[i] and the total length of k+1 packets is greater than DC[i], the first device can dequeue k packets during a single queue scheduling and process the (k+1)th packet during the next queue scheduling. In this way, it can be guaranteed that the first device dequeues multiple packets having a total length shorter than DC[i] and closest to DC[i] during queue scheduling, so as to improve the utilization efficiency of network bandwidth resources. For example, there are a total of five packets in the i-th DSRR queue, and the lengths of the five packets are 100 bits, 500 bits, 200 bits, 210 bits, and 800 bits, respectively. The first four packets of the five packets are 100 bits, 500 bits, 200 bits, and 210 bits, respectively, in order. When performing S402, the first device obtains that the packet allocation amount corresponding to the i-th DSRR queue is 1100 bits. In this case, only the first four packets in the queue can be dequeued in this queue scheduling, and the packet balance obtained after processing is 90 bits. The last packet with a length of 800 bits cannot be dequeued and needs to be processed during the next queue scheduling. The first device may compare the remaining packet balance with the length of the current leading packet in the i-th DSRR queue.Since the remaining packet balance is only 90 bits and the requirement to dequeue the leading packet having a length of 800 bits cannot be met, the first device can reserve the remaining packet balance having a length of 90 bits for use during the next queue scheduling and reserve the leading packet having a length of 800 bits for processing during the next queue scheduling.
[0102] S406: The first device determines a waiting duration corresponding to the i-th DSRR queue during the current queue scheduling based on the packet balance corresponding to the i-th DSRR queue, and performs S407 after the waiting duration expires.
[0103] For example, after there are no packets to be dequeued from the i-th DSRR queue, the first device may determine a waiting duration corresponding to the i-th DSRR queue during the current queue scheduling based on the remaining packet balance of the i-th DSRR queue, and perform S407 after the waiting duration expires. The waiting duration corresponding to the i-th DSRR queue indicates the duration required to consume the remaining packet balance of the i-th DSRR queue.
[0104] In the conventional DRR technology, since the packet transmission speed of the first device is relatively constant, the larger the amount of packets processed by the first device, the longer the time period for consumption. If the time period t1 consumed to process the i-th DSRR queue by the first device during the first queue scheduling of the DSRR queue set is shorter than the time period t2 consumed to process the i-th DSRR queue by the first device during the second queue scheduling of the DSRR queue set, it is obvious that the time period T1 consumed during the first queue scheduling can be shorter than the time period T2 consumed during the second queue scheduling. Furthermore, if there are always packets in the k-th DSRR queue in the DSRR queue set, and packets with a total length Q1[k] are dequeued during each of the two queue schedulings of the DSRR queue set, the network bandwidth resource obtained by the k-th DSRR queue during the first queue scheduling is Q1[k] / T1, and the network bandwidth resource obtained by the k-th DSRR queue during the second queue scheduling is Q1[k] / T2. Since T1 < T2, the network bandwidth resource occupied by the k-th DSRR queue during the first queue scheduling is larger than the network bandwidth resource occupied by the k-th DSRR queue during the second queue scheduling. Since the total amount of the network bandwidth resources of the first device is limited, it is obvious that the k-th DSRR queue occupies the network bandwidth resources of other DSRR queues.
[0105] It can be seen that, in order to ensure that any DSRR queue in the DSRR queue set cannot occupy the network bandwidth resources of other DSRR queues, the first device can control the time period consumed each time it performs queue scheduling on the DSRR queue set to be close. Thus, the first device can determine the waiting duration corresponding to the i-th DSRR queue in the current queue scheduling based on the remaining DC[i], and wait based on the waiting duration. The waiting duration is used to compensate for the time period consumed by the first device to process the i-th DSRR queue when the i-th DSRR queue is empty. Specifically, assuming that the port of the first device has a portrait of c, the waiting duration of the current queue scheduling can be the ratio of DC[i] to the portrait of c. The port of the first device can be an egress port. For example, during the current queue scheduling, DC[i] is 2000 bits, and the portrait of c is 500 bits / second. In this case, the waiting duration t obtained through calculation is 4s, and the first device can perform S407 after waiting for 4s.
[0106] S407: The first device determines whether there is an unprocessed DSRR queue in the DSRR queue set. If there is still an unprocessed DSRR queue in the DSRR queue set, the first device performs S402 to S406 on the unprocessed DSRR queue.
[0107] For example, after completing the processing of the i-th DSRR queue, the first device may determine whether there are still any unprocessed DSRR queues in the DSRR queue set. For example, when performing queue scheduling for the DSRR queue set, the first device may first set the value of i to 1 and start processing from the first DSRR queue. After completing the processing of the i-th DSRR queue, the first device may increase the value of i by 1 and process the next DSRR queue. When the value of i is less than or equal to the total amount M of DSRR queues in the DSRR queue set, it indicates that there are still any unprocessed DSRR queues in the DSRR queue set, and the first device may continue to perform the method shown in S402 to S406 for the i-th DSRR queue. After all DSRR queues in the DSRR queue set are processed, it indicates that the first device has completed one round of queue scheduling for the DSRR queue set, and the first device may perform the next round of queue scheduling.
[0108] Since the waiting duration corresponding to the i-th DSRR queue set is determined based on the remaining packet balance of the i-th DSRR queue, the waiting duration corresponding to the i-th DSRR queue set is equal to the duration required for the virtual queues not belonging to the DSRR queue set to exhaust the completely unused packet balance in the i-th DSRR queue during the current queue scheduling. In this case, the duration consumed to process the i-th DSRR queue is equal to the duration required to consume the length of the packets dequeued from the i-th DSRR queue and the duration required to consume the length of the packets not dequeued from the i-th DSRR queue. Since the total length of the packets that can be dequeued each time the i-th DSRR queue is scheduled is limited by Q1[i], and the speed at which the first device schedules the packets to be dequeued or processes the packets is relatively fixed, after multiple queue schedulings, the time period consumed during each queue scheduling approaches a fixed value T. The value of T is close to the ratio of the sum of the packet sub-allocation amounts corresponding to all DSRR queues in the DSRR queue set to the rate at which the first device schedules packets. In this way, the maximum rate at which packets are dequeued from the i-th DSRR queue cannot exceed Q1[i] / T. Because the maximum rate at which packets are dequeued from each DSRR queue in the DSRR queue set is limited, the network bandwidth resources that can be occupied by the DSRR queues are also limited. In this way, any DSRR queue in the DSRR queue set does not occupy an excessively large amount of network bandwidth resources because other DSRR queues are empty. This prevents network congestion and latency caused by traffic bursts.
[0109] In order to better use the first duration, specifically, to utilize the remaining packet balance of the DSRR queue, in some other implementations, the first device may schedule a DSRR queue set and one BE queue set. The DSRR queue set may include at least two DSRR queues. The BE queue set may include at least one BE queue. FIG. 5 is a flowchart of a method for queue scheduling according to an embodiment of the present application. In this embodiment, the first device may perform queue scheduling on the DSRR queue set and the BE queue set. This embodiment is described by using an example in which the BE queue set includes one BE queue. When the BE queue set includes multiple BE queues, the first device may perform scheduling according to a pre-set scheduling policy when scheduling the BE queue set. In the process of single-time queue scheduling, the first device may first process any DSRR queue in the DSRR queue set, and after completing the processing of the DSRR queue, process the BE queue based on the remaining packet balance of the DSRR queue. With reference to FIG. 5, the method for queue scheduling provided in this embodiment will be described below.
[0110] S501: The first device obtains parameters corresponding to each DSRR queue included in the DSRR queue set and parameters corresponding to the BE queue.
[0111] For example, the first device may obtain parameters corresponding to each DSRR queue included in the DSRR queue set, and may further obtain parameters corresponding to the BE queue in the manner of S401 in the embodiment corresponding to Fig. 4. Both the DSRR queue and the BE queue may be used for packet transmission.
[0112] For example, during a single queue scheduling, the first device may process a BE queue after completing the processing of a DSRR queue in the DSRR queue set, and process the next DSRR queue in the DSRR queue set after completing the processing of the BE queue. The scheduling of the next DSRR queue in the DSRR queue set is later than the scheduling of the scheduled DSRR queue. In the following, an example in which the first device processes the i-th DSRR queue and the BE queue is used for explanation. The i-th DSRR queue can be any DSRR queue in the DSRR queue set. For how the first device processes all DSRR queues in the DSRR queue set, please refer to how the first device processes the i-th DSRR queue. The examples are not described one by one. The parameters corresponding to the BE queue may include a packet quota and a packet balance corresponding to the BE queue. The packet quota corresponding to the BE queue indicates the total length of packets that can be dequeued from the BE queue during the current queue scheduling. The packet quota corresponding to the BE queue is equal to the sum of the packet balance DC[i] of the i-th DSRR queue and the packet balance of the BE queue obtained after the previous queue scheduling. The packet balance corresponding to a BE queue indicates the length of the remaining packets that can be dequeued from the BE queue. The packet balance corresponding to a BE queue is the difference between the packet quota corresponding to the BE queue and the length of the packets dequeued from the BE queue. The DSRR queue set in this embodiment includes M DSRR queues, where M is an integer equal to or greater than 2. The packet quota corresponding to a BE queue is represented by Q[BE], and the packet balance corresponding to a BE queue is represented by DC[BE]. In addition, the packet balance corresponding to the i-th DSRR queue may be represented by DC[i], where the range of values of i may be represented as 1≦i≦M.
[0113] When the BE queue set includes multiple BE queues, parameters corresponding to each BE queue in the BE queue set and a method for scheduling the multiple BE queues are obtained in this step. Optionally, when the BE queue set includes multiple BE queues, priorities corresponding to each of the multiple BE queues may be further obtained in this step.
[0114] S502: The first device processes the i-th DSRR queue, and obtains a packet quota corresponding to a BE queue based on the packet balance of the i-th DSRR queue.
[0115] For example, the i-th DSRR queue may be the first queue in the embodiment corresponding to FIG. 2. The first device may process the i-th DSRR queue first. For a specific processing method, see steps S402 to S404 in the embodiment corresponding to FIG. S407 Please refer to. Details will not be described again here. After completing the processing of the i-th DSRR queue, the first device may obtain the packet allocation amount Q[BE] corresponding to the BE queue based on the packet balance DC[i] corresponding to the i-th DSRR. For example, the first device may obtain the sum of DC[i] and the packet balance DC[BE] corresponding to the BE queue during the previous queue scheduling, and use the sum as Q[BE] during the current queue scheduling. The remaining packet balance DC[i] of the i-th DSRR queue may represent the packet balance that cannot be fully used by the i-th DSRR queue during the current queue scheduling, for example, may be DC[i] when the amount of packets buffered in the i-th DSRR queue is 0, or may be the packet allocation amount Q2[i] when the amount of packets buffered in the i-th DSRR queue is 0. If the packet balance DC[BE] corresponding to the BE queue during the previous queue scheduling is 0, or if the BE queue is scheduled for the first time, the packet allocation amount Q[BE] corresponding to the BE queue may be the packet balance DC[BE] corresponding to the i-th DSRR queue during the previous queue scheduling. queueis equal to the packet balance DC[i] corresponding to
[0116] S503: The first device determines whether there is a packet to be dequeued from the BE queue. If there is no packet to be dequeued from the BE queue, the first device performs S506, or if there is a packet to be dequeued from the BE queue, the first device performs S504.
[0117] S504: Determine whether the length of the head packet in the BE queue is greater than the packet balance corresponding to the BE queue. If the length of the head packet in the BE queue is greater than the packet balance corresponding to the BE queue, the first device performs S507, or if the length of the head packet in the BE queue is equal to or less than the packet balance corresponding to the BE queue, the first device performs S505.
[0118] For example, in this embodiment, the length of the head packet in a BE queue may be represented as L[BE]. When the head packet of a BE queue changes, L[BE] changes accordingly. When the first device performs queue scheduling on a BE queue set and the BE queue set includes multiple BE queues, the head packet in the BE queue may be the packet that is first dequeued from a BE queue included in the BE queue set. In the method in which the first device schedules multiple BE queues included in a BE queue set, the first device may use the method in which the first device schedules multiple DSRR queues included in a DSRR queue set, or may perform queue scheduling on multiple BE queues based on the priorities of the multiple BE queues or the sorting of the multiple BE queues. Details are not described here.
[0119] For example, the first device may determine whether there is a packet to be dequeued from the BE queue by using the method shown in S403 included in the embodiment corresponding to FIG. 4. If there is no packet to be dequeued from the BE queue, the first device may perform S506. When there is a packet to be dequeued from the BE queue, the first device may continue to determine whether the length of the leading packet in the BE queue is greater than the packet balance DC[BE] corresponding to the BE queue. When the first device performs S504 for the first time, the value of DC[BE] may be equal to the packet quota Q[BE] corresponding to the BE queue.
[0120] For example, if the first device detects that the length L[BE] of the head packet in the BE queue is less than or equal to DC[BE], it indicates that the packet balance DC[BE] corresponding to the current BE queue can meet the requirements for dequeuing the head packet from the BE queue, and the first device may perform S505. If the first device detects that L[BE] is greater than DC[BE], it indicates that the packet balance DC[BE] corresponding to the current BE queue cannot meet the requirements for dequeuing the head packet from the BE queue, i.e., the head packet cannot be dequeued from the BE queue. In this case, the first device may perform S507, specifically, it may directly process the next DSRR queue in the DSRR queue set, and the remaining packet balance used to output the head packet in the BE queue may be accumulated for use during the next time of scheduling the BE queue. If there is a long-length packet in the BE queue, the packet balance DC[BE] corresponding to the BE queue may be continuously accumulated during queue scheduling. Thus, the aforementioned requirement for dequeuing packets with long length is met, and congestion of the BE queue caused by failure to dequeue packets with long length in time is prevented.
[0121] In some possible implementations, to ensure that the duration consumed is the same each time the DSRR queue is scheduled, the first device may perform S507 when L[BE] is greater than DC[BE], and consume DC[BE] (waiting for the duration obtained based on the ratio of DC[BE] to expire) to further reduce the latency corresponding to the DSRR queue.
[0122] S505: The first device dequeues the head packet from the BE queue, subtracts the length of the head packet in the BE queue from the packet balance of the BE queue, and performs S503.
[0123] In this embodiment, the first device may dequeue the head packet in the BE queue when DC[BE] is equal to or greater than L[BE]. After the head packet in the BE queue is dequeued, the first device may obtain the difference between DC[BE] and L[BE] and reallocate the difference to DC[BE]. This causes DC[BE] to be decreased after the head packet in the BE queue is dequeued. This prevents packets buffered in the BE queue from being dequeued indefinitely. For example, if the packet balance DC[BE] corresponding to the BE queue is 500 bits and the length L[BE] of the head packet in the BE queue is 100 bits, the first device may dequeue this packet having a length of 100 bits and update DC[BE] to 400 bits.
[0124] After completing the update of DC[BE], the first device may go back to S504 and determine again whether the BE queue is empty and whether the length of the leading packet in the BE queue is greater than the updated packet balance corresponding to the BE queue. In this way, during a single queue scheduling, if there is a leading packet in the BE queue and the length of the leading packet is not greater than the packet balance corresponding to the BE queue, the packets in the BE queue can be dequeued continuously. In this way, multiple packets with a total length that meets the requirements in the BE queue are dequeued, and the network bandwidth resources are guaranteed to be fully utilized.
[0125] S506: The first device consumes the packet balance corresponding to the BE queue, and performs S507 after the consumption.
[0126] For example, in one implementation, the first device may schedule the low priority queue using the packet balance corresponding to the BE queue, and perform S507 after the packet balance corresponding to the BE queue is consumed. In another implementation, when there is no packet to be dequeued from the BE queue, the first device may determine the waiting duration required during this queue scheduling based on DC[BE], and wait. The manner of determining the waiting duration is similar to S407 in the embodiment corresponding to FIG. 4. After the waiting duration expires, the first device performs S507.
[0127] S507: The first device determines whether there is an unprocessed DSRR queue in the DSRR queue set. If there is still an unprocessed DSRR queue in the DSRR queue set, the first device performs S502 to S506 on the unprocessed DSRR queue.
[0128] For example, after completing the scheduling of the BE queue, the first device may determine that there is still an unprocessed DSRR queue in the DSRR queue set in the method of step 18 of the embodiment corresponding to FIG. 4. When there is an (i+1)-th unprocessed DSRR queue in the DSRR queue set, the first device may perform the method of S502 to S506 for the (i+1)-th DSRR queue. When the queue scheduling is completed for all DSRR queues included in the DSRR queue set, it indicates that the first device has completed one queue scheduling of the DSRR queue set, and the first device may perform the next queue scheduling.
[0129] In this embodiment, after completing the processing of the i-th DSRR queue, the first device uses the packet balance corresponding to the i-th DSRR queue to schedule the packets buffered in the BE queue. In this way, the packet balance that is not completely used by the DSRR queue can be used to schedule the packets buffered in the BE queue. In this way, the utilization of network bandwidth resources is improved, subject to setting the maximum rate at which packets in the multiple DSRR queues in the DSRR queue set are dequeued.
[0130] In some possible implementation forms, the first device may alternatively first schedule packets buffered in multiple DSRR queues in the DSRR queue set after all DSRR queues included in the DSRR queue set have been scheduled, and schedule packets buffered in the BE queue based on the sum of the remaining packet balances of the multiple DSRR queues, i.e., perform S507 directly after completing S502, and then perform S504 after completing processing of the multiple DSRR queues in the DSRR queue set.
[0131] Furthermore, considering that for an originally empty DSRR queue, a new packet may be acquired in the process of dequeuing a packet in the BE queue, in some possible implementations, after determining that the DSRR queue is empty and updating DC[BE] based on DC[i], the first device may not directly clear DC[i]. Instead, after the head packet in the BE queue or the head packet in the DSRR queue consumes DC[BE], the first device subtracts L[BE] from both DC[i] and DC[BE]. In this way, it is assumed that a new packet is added to the i-th DSRR queue, which was originally empty, in the process of dequeuing a packet from the BE queue. If the length of the packet is less than DC[BE], the packet may be directly dequeued without waiting for the next queue scheduling.
[0132] In the above embodiment, for multiple DSRR queues in the DSRR queue set, the first device may set a maximum rate at which packets in the multiple DSRR queues are dequeued to prevent the DSRR queue from occupying an excessively large amount of network bandwidth resources when other DSRR queues are empty, and reduce the maximum latency of packets in the DSRR queue, i.e., a latency upper limit is provided for packets in the DSRR queue. In the case of a BE queue, the first device may provide as much network bandwidth resource as possible for the BE queue while guaranteeing the latency upper limit of packets in the DSRR queue.
[0133] In some possible implementations, the first device may further schedule one or more queues that have certain requirements for network bandwidth resources but do not have high requirements for latency limits. In this embodiment of the present application, these queues may be referred to as SRR queues. When the first device schedules multiple SRR queues, the multiple SRR queues may be collectively referred to as an SRR queue set.
[0134] In this embodiment, the DSRR queue may be the first queue in an embodiment corresponding to FIG. 2 or FIG. 3, the SRR queue may be the third queue in an embodiment corresponding to FIG. 2 or FIG. 3, the BE queue may be the fourth queue in an embodiment corresponding to FIG. 2 or FIG. 3, and the DSRR queue set may be the first queue set in an embodiment corresponding to FIG. 3.
[0135] Figure 6 is a flow chart of a method for queue scheduling according to an embodiment of the present application. In this embodiment, a first device can perform queue scheduling on multiple DSRR queues in a DSRR queue set. In a single queue scheduling process, the first device can first process multiple DSRR queues in a DSRR queue set, then process an SRR queue, and finally process a BE queue. With reference to Figure 6, the method for queue scheduling provided in this embodiment will be described below.
[0136] S601: The first device obtains parameters corresponding to each DSRR queue included in the DSRR queue set, parameters corresponding to each SRR queue included in the SRR queue set, and parameters corresponding to the BE queue.
[0137] For example, in addition to obtaining parameters corresponding to each DSRR queue included in the DSRR queue set and parameters corresponding to the BE queue in the manner shown in S501 of the embodiment corresponding to FIG. 5, the first device may further obtain parameters corresponding to each SRR queue included in the SRR queue set. The parameters corresponding to the SRR queue may include packet sub-allocation amount, theoretical packet sub-allocation amount, packet allocation amount, and packet balance corresponding to the SRR queue. In the following, the parameters corresponding to the SRR queue will be described by using an example in which the SRR queue set includes a first SRR queue. The packet sub-allocation amount corresponding to the first SRR queue indicates the total length of packets that can be dequeued and further added to the first SRR queue during one queue scheduling. The packet sub-allocation amount corresponding to the first SRR queue is the smaller value of the theoretical packet sub-allocation amount of the first SRR queue and the packet balance of the i-th DSRR queue. For example, if the theoretical packet sub-quota of the first SRR queue is 1000 bits, but the packet balance corresponding to the i-th DSRR queue is 500 bits during the time of queue scheduling, then during the current queue scheduling, the packet sub-quota of the first SRR queue is 500 bits. The theoretical packet sub-quota of the first SRR queue may be the preset maximum length of packets that may be dequeued from the first SRR queue during every queue scheduling. The packet quota of the first SRR queue may be the sum of the packet sub-quota of the first SRR queue and the packet balance of the first SRR queue during the previous queue scheduling. The packet balance of the first SRR queue may indicate the length of remaining packets that may be dequeued from the first DSRR queue. Similar to the DSRR queue, in this embodiment of the present application, the packet balance of the first SRR queue may be the difference between the packet quota of the first SRR queue and the length of packets dequeued from the first SRR queue.
[0138] For example, the DSRR queue set includes N DSRR queues, and the SRR queue set includes M SRR queues, where N is an integer equal to or greater than 2, and M is an integer equal to or greater than 1. The packet sub-quota corresponding to the j-th SRR queue of the M SRR queues is represented by Q1[j], the theoretical packet sub-quota corresponding to the j-th SRR queue is represented by Q1*[j], the packet quota corresponding to the j-th SRR queue is represented by Q2[j], and the packet balance corresponding to the j-th SRR queue is represented by DC[j]. In addition, the packet balance corresponding to the i-th DSRR queue may be represented by DC[i], and the packet quota and packet balance corresponding to the BE queue may be represented by Q[BE] and DC[BE], respectively. The range of values of i may be represented as 1≦i≦N, and the range of values of j may be represented as 1≦j≦M.
[0139] S602: The first device processes the i-th DSRR queue in the DSRR queue set.
[0140] For example, the first device may process the i-th DSRR queue first. For specific processing methods, please refer to step S402 to step S18 in the embodiment corresponding to Fig. 4. The details will not be described again here.
[0141] S603: The first device determines whether the packet balance of the i-th DSRR queue is greater than 0. If the packet balance of the i-th DSRR queue is equal to 0, the first device performs S611; or if the packet balance of the i-th DSRR queue in the DSRR queue set is greater than 0, the first device performs S604.
[0142] S604: Determine whether the SRR queue set includes an SRR queue in which the dequeued packet is buffered. If the SRR queue set includes an SRR queue in which the dequeued packet is buffered, S605 is performed, or if all SRR queues in the SRR queue set are empty queues (the dequeued packet is not buffered), S606 is performed.
[0143] For example, after completing queue scheduling of the i-th DSRR queue, the first device may first determine whether the packet balance DC[i] of the i-th DSRR queue is equal to 0. If DC[i] is equal to 0, it indicates that there is no unconsumed packet balance in the i-th DSRR queue, and the first device cannot schedule the packets buffered in any SRR queue in the SRR queue set and the packets buffered in the BE queue to be dequeued by using DC[i]. Then, the first device performs S610 to process the next DSRR queue or perform the next queue scheduling of the DSRR queue set. If DC[i] is greater than 0, it indicates that there is an unconsumed packet balance in the i-th DSRR queue, and the first device may schedule the packets buffered in the SRR queue in the SRR queue set and the packets buffered in the BE queue to be dequeued by using DC[i]. The first device may continue to determine whether the SRR queue set includes an SRR queue in which the packet to be dequeued is buffered. If all SRR queues included in the SRR queue set are empty queues, which indicates that the first device cannot schedule the buffered packet to any SRR queue in the SRR queue set to be dequeued by using DC[i], and the first device may perform S606. If at least one SRR queue included in the SRR queue set buffers the packet to be dequeued, the first device may schedule an SRR queue that is in the SRR queue set and in which the packet to be dequeued is buffered by using DC[i], and the first device may perform S605.
[0144] S605: The first device processes multiple SRR queues in the SRR queue set based on a packet balance corresponding to the i-th DSRR queue.
[0145] For example, the first device may perform queue scheduling for one or more SRR queues in the SRR queue set based on DC[i]. When DC[i] is equal to or greater than the packet quota corresponding to all SRR queues included in the SRR queue set, the first device may perform queue scheduling for the SRR queue set one or more times based on DC[i]. When DC[i] is less than the packet quota corresponding to all SRR queues included in the SRR queue set, the first device cannot perform one queue scheduling for all SRR queues in the SRR queue set by using DC[i], and may perform queue scheduling for only some SRR queues in the SRR queue set. With reference to the method provided in FIG. 7, the following describes an example in which the first device schedules SRR queues in the SRR queue set. FIG. 7 is a schematic flowchart of a method for queue scheduling according to an embodiment of the present application. The following uses an example in which the first device processes the j-th SRR queue in the SRR queue set for description. The j-th SRR queue can be any SRR queue in the SRR queue set. For how the first device processes all SRR queues in the SRR queue set, please refer to how the first device processes the j-th SRR queue. Examples are not given one by one.
[0146] S6051: The first device determines whether there is a packet to be dequeued from the j-th SRR queue. If there is no packet to be dequeued from the j-th SRR queue, the first device performs S6057, or if there is a packet to be dequeued from the j-th SRR queue, the first device performs S6052.
[0147] For example, the first device may determine whether there is a packet to be dequeued from the j-th SRR queue in the method of S403 in the embodiment corresponding to Fig. 4. When there is a packet to be dequeued from the j-th SRR queue, the first device may perform S6052, or when there is no packet to be dequeued from the j-th SRR queue, the first device may perform S6057.
[0148] S6052: The first device determines a packet sub-allocation amount corresponding to the j-th SRR queue based on a theoretical packet sub-allocation amount corresponding to the j-th SRR queue, and updates a packet allocation amount corresponding to the j-th SRR queue and a packet balance corresponding to the i-th DSRR queue based on the packet sub-allocation amount corresponding to the j-th SRR queue.
[0149] For example, when there is a packet to be dequeued from the j-th SRR queue, the first device may select the smaller value of the theoretical packet sub-allocation amount Q1*[j] corresponding to the j-th SRR queue and the packet balance DC[i] corresponding to the i-th DSRR queue, and use the selected value as the packet sub-allocation amount Q1[j] corresponding to the j-th SRR queue. The first device may update the packet allocation amount Q2[j] corresponding to the j-th SRR queue and the packet balance DC[i] corresponding to the i-th DSRR queue based on Q1[j]. Specifically, the first device may first obtain the sum of Q1[j] and the packet balance DC[j] corresponding to the j-th SRR queue during the previous queue scheduling, and assign the sum to Q2[j]. The first device may further obtain the difference between the packet balance DC[i] corresponding to the i-th DSRR queue and the packet sub-allocation amount Q1[j] corresponding to the j-th SRR queue, and reallocate the difference to the packet balance DC[i] corresponding to the i-th DSRR queue. Thus, when Q2[j] increases, DC[i] decreases synchronously. This is equivalent to the first device extracting the packet balance with value Q1[j] from the packet balance that is not completely used by the i-th DSRR queue, transferring the packet balance with value Q1[j] that is not completely used to Q2[j], and then performing queue scheduling for the j-th SRR queue. For example, during the time of queue scheduling, DC[i] is 2000 bits, Q1*[j] is 1000 bits, and the packet balance DC[j] obtained by the j-th SRR queue in the previous queue scheduling is 10 bits. During the current queue scheduling, the packet sub-allocation Q1[j] corresponding to the j-th SRR queue is 1000 bits, the packet allocation Q2[j] corresponding to the j-th SRR queue is 1000+10=1010 bits, and the packet balance DC[i] corresponding to the i-th DSRR queue is 2000-1000=1000 bits.
[0150] S6053: The first device determines whether the length of the head packet in the jth SRR queue is greater than the packet balance corresponding to the jth SRR queue. If the length of the head packet in the jth SRR queue is greater than the packet balance corresponding to the jth SRR queue, the first device performs S6057, or if the length of the head packet in the jth SRR queue is equal to or less than the packet balance corresponding to the jth SRR queue, the first device performs S6054.
[0151] For example, similar to the DSRR queue and the BE queue, the packets buffered in the SRR queue are dequeued in order. When there is at least one packet to be dequeued from the SRR queue, the packet at the first position of the queue and within the at least one dequeued packet may be referred to as the leading packet. The length of the leading packet of the jth SRR queue is represented as L[j]. When the leading packet of the jth SRR queue changes, L[j] changes accordingly. If the length L[j] of the leading packet in the jth SRR queue is less than or equal to DC[j], it indicates that the packet balance corresponding to the jth SRR queue can meet the requirements for dequeuing the leading packet from the jth SRR queue, and the first device may perform S6054. If L[j] is greater than DC[j], it indicates that the packet balance corresponding to the jth SRR queue cannot meet the requirements for dequeuing the leading packet from the jth SRR queue, i.e., the leading packet cannot be dequeued from the jth SRR queue, and the first device may perform S6057. When a long packet exists in the j-th SRR queue, DC[j] may continuously accumulate during multiple queue schedulings performed by the first device on the SRR queue set to satisfy the requirement for dequeuing the long packet and prevent the j-th SRR queue from being congested due to the long packet not being able to be transmitted in time. When the first device performs S6053 for the first time, the value of DC[j] may be equal to the packet allocation amount Q2[j] corresponding to the j-th SRR queue.
[0152] S6054: The first device schedules the top packet to be dequeued from the jth SRR queue, and subtracts the length L[j] of the top packet in the jth SRR queue from the packet balance DC[j] corresponding to the jth SRR queue.
[0153] For example, after determining that L[j] is less than or equal to DC[j], the first device may dequeue the top packet in the jth SRR queue, obtain the difference between DC[j] and L[j], and reallocate the difference to DC[j] to update DC[j].
[0154] S6055: The first device determines whether there is a packet to be dequeued from the j-th SRR queue. If there is no packet to be dequeued from the j-th SRR queue, the first device performs S6056, or if there is a packet to be dequeued from the j-th SRR queue, the first device performs S6053.
[0155] For example, after completing the update of DC[j], the first device may again determine whether there is a packet to be dequeued from the j-th SRR queue in the method of S403 provided in the embodiment corresponding to Fig. 4, and when there is a packet to be dequeued from the j-th SRR queue, return to S6053 to determine whether a new head packet in the j-th SRR queue can be dequeued. If there is no packet to be dequeued from the j-th SRR queue, the first device may perform S6056.
[0156] For example, during a single queue scheduling of the SRR queue set, if there is a head packet in the jth SRR queue and the head packet's packet balance is not larger than the packet balance corresponding to the jth SRR queue, the packets in the jth SRR queue may be dequeued consecutively. Thus, the first device may dequeue multiple packets having a total length that meets the requirements in the jth SRR queue to fully utilize the network bandwidth resources.
[0157] S6056: The first device updates a packet balance corresponding to the i-th DSRR queue based on the packet balance corresponding to the j-th SRR queue.
[0158] For example, after determining that there are no packets to be dequeued from the j-th SRR queue, the first device may update DC[i] based on DC[j]. For example, the first device may obtain the sum of DC[j] and DC[i], reassign the sum to DC[i], and update DC[i]. After completing the update of DC[i], the first device may end the scheduling of the j-th SRR queue and perform S6057.
[0159] For example, when there are no packets to be dequeued from the jth SRR queue, the first device cannot consume the packet balance corresponding to the jth SRR queue by scheduling a packet buffered in the jth SRR queue to be dequeued. DC[j] is the excess packet balance for the jth SRR queue. Thus, the first device may transfer the value of DC[j] to DC[i], so that other SRR queues in the SRR queue set use the packet balance that cannot be consumed in the jth SRR queue.
[0160] S6057: The first device determines whether there is an unprocessed SRR queue in the SRR queue set. If there is still an unprocessed SRR queue in the SRR queue set, the first device performs S6051 for the unprocessed SRR queue, or if there is no unprocessed SRR queue in the SRR queue set, the first device performs S604.
[0161] For example, after determining that L[j] is greater than DC[j] or that there are no packets to be dequeued from the j-th SRR queue, the first device may end queue scheduling for the j-th SRR queue and determine whether there are still unprocessed SRR queues in the SRR queue set. For example, the first device may determine that there are still unscheduled SRR queues in the SRR queue set in the method of S407 of the embodiment corresponding to FIG. 4. When there are still unscheduled SRR queues in the SRR queue set, the first device performs the method shown in S6051 to S6056 for the unscheduled SRR queues until queue scheduling for all SRR queues in the SRR queue set is completed.
[0162] For example, the first device may perform queue scheduling for multiple SRR queues in the SRR queue set by periodically performing S6051 to S6056. When there is no unscheduled SRR queue in the SRR queue set, it indicates that the first device has completed queue scheduling for all SRR queues in the SRR queue set, and the current queue scheduling ends. Therefore, the first device may return to perform S604 and determine whether the next queue scheduling needs to be performed for the SRR queue set.
[0163] S606: The first device determines a packet allocation amount corresponding to a BE queue based on a packet balance corresponding to the i-th DSRR queue.
[0164] For example, when there are no SRR queues with packets to be dequeued from the SRR queue set and DC[i] is not 0, the first device cannot consume the packet balance DC[i] that is not entirely used by the DSRR queues by scheduling packets buffered in any SRR queue in the SRR queue set to be dequeued. The first device may consume DC[i] by scheduling packets buffered in a BE queue to be dequeued.
[0165] Before scheduling the packets buffered in the BE queue to be dequeued, the first device may first determine a packet quota Q[BE] corresponding to the BE queue. The first device may obtain the sum of DC[i] and the remaining packet balance DC[BE] of the BE queue during the previous processing, and use the sum as Q[BE] for subsequent processing.
[0166] S607: The first device determines whether there is a packet to be dequeued from the BE queue. If there is no packet to be dequeued from the BE queue, the first device performs S610, or if there is a packet to be dequeued from the BE queue, the first device performs S608.
[0167] S608: Determine whether the length of the head packet in the BE queue is greater than the packet balance corresponding to the BE queue. If the length of the head packet in the BE queue is greater than the packet balance corresponding to the BE queue, S611 is performed, or if the length of the head packet in the BE queue is equal to or less than the packet balance corresponding to the BE queue, S609 is performed.
[0168] Similar to the previous embodiment, the first device may determine whether there is a packet to be dequeued from the BE queue in the manner of S503 in the embodiment corresponding to FIG. 5. If there is no packet to be dequeued from the BE queue, it indicates that the first device cannot consume the packet balance corresponding to the BE queue by scheduling a packet buffered in the BE queue, and the first device may perform S610. If there is a packet to be dequeued from the BE queue, the first device may continue to determine whether the length of the head packet in the BE queue is greater than the packet balance DC[BE] corresponding to the BE queue. If the length L[BE] of the head packet in the BE queue is less than or equal to DC[BE], it indicates that the packet balance DC[BE] corresponding to the current BE queue can meet the requirement for dequeuing the head packet from the BE queue, and the first device may perform S609. If L[BE] is greater than DC[BE], it indicates that the packet balance DC[BE] corresponding to the current BE queue cannot meet the requirement for dequeuing the head packet from the BE queue, i.e., the head packet cannot be dequeued from the BE queue. In this case, the first device may perform S611, specifically, may directly process the next DSRR queue in the DSRR queue set, and the remaining packet balance used for outputting the head packet in the BE queue may be accumulated for scheduling the packet to be dequeued next from the BE queue. In this way, when there is a long packet with a long length in the BE queue, the packet balance DC[BE] corresponding to the BE queue can be continuously accumulated during queue scheduling. Therefore, the requirement for dequeuing the packet with a long length is met, and the BE queue is not stacked by the head packet with a long length.
[0169] S609: The first device dequeues the top packet from the BE queue, subtracts the length of the top packet in the BE queue from the packet balance corresponding to the BE queue, and performs S607.
[0170] When there is a packet to be dequeued from the BE queue and L[BE] is equal to or less than DC[BE], the first device may dequeue the head packet from the BE queue and update DC[BE] in the manner shown in S504. Details will not be described again here.
[0171] S610: The first device consumes the packet balance corresponding to the BE queue, and performs S611 after the consumption.
[0172] For example, the first device may determine a packet balance corresponding to the i-th DSRR queue during the current queue scheduling in the manner of S506 in the embodiment corresponding to Fig. 5, and perform S611 after the packet balance is consumed. Details will not be described again here.
[0173] S611: The first device determines whether there is an unprocessed DSRR queue in the DSRR queue set. If there is still an unprocessed DSRR queue in the DSRR queue set, the first device performs S604 to S610 on the unprocessed DSRR queue.
[0174] After completing the scheduling of the BE queue, the first device may determine that there are still unprocessed DSRR queues in the DSRR queue set in the method of step 18 of the embodiment corresponding to FIG. 4. When there are unprocessed DSRR queues in the DSRR queue set, the first device may continue to perform the method of S604 to S38 for the unprocessed DSRR queues. After all DSRR queues in the DSRR queue set are processed, which indicates that the first device has completed the current queue scheduling of the DSRR queue set, the first device may perform the next queue scheduling.
[0175] In this embodiment, the first device may schedule the DSRR queue set, the SRR queue set, and the BE queue. By performing the method provided in this embodiment, the first device may prioritize packet scheduling for the DSRR queue, and set the maximum rate at which packets in all DSRR queues in the DSRR queue set are dequeued, to provide a forwarding service that meets the requirements for packets with strict requirements for the latency upper limit. The first device further schedules the SRR queue after scheduling the DSRR queue, and the step of scheduling the SRR queue is similar to the step of scheduling the DSRR queue, so that as much network bandwidth resources as possible can be allocated to the SRR queue under the premise of ensuring the normal operation of the DSRR queue. The first device finally schedules the BE queue, so that the utilization of network bandwidth resources can be improved without affecting the DSRR queue and the SRR queue.
[0176] In some possible implementations, the first device may alternatively first schedule packets buffered in multiple DSRR queues in a DSRR queue set for processing, and after processing all DSRR queues, process the SRR queue set or the BE queues based on the remaining packet balance of the multiple DSRR queues, i.e., directly perform S611 after completing S602, and then perform S604 after completing processing of the multiple DSRR queues in the DSRR queue set.
[0177] To balance the network bandwidth resources obtained by multiple SRR queues in an SRR queue set, 603 After step 100 is skipped, the first device may record the progress of this time of scheduling the SRR queue, so that step 100 is skipped. 603 The next time, the previous progress in scheduling the SRR queue continues.
[0178] Specifically, the first device may replace the theoretical packet sub-quota Q1*[j] with the remaining packet sub-quota corresponding to the j-th SRR queue to determine Q1[j]. The remaining packet sub-quota corresponding to the j-th SRR queue indicates the remaining packet sub-quota that may be allocated to the j-th SRR queue by the first device during the current queue scheduling of the SRR queue set. In this embodiment of the present application, the remaining packet sub-quota corresponding to the j-th SRR queue is represented by LQ1[j].
[0179] Before performing queue scheduling for the set SRR queue set each time, the first device may adjust the remaining packet sub-allocation corresponding to each SRR queue in the SRR queue set to the theoretical packet sub-allocation corresponding to the j-th SRR queue, i.e., set the initial value of LQ1[j] to Q1*[j]. When scheduling the j-th SRR queue in the SRR queue set, the first device may determine Q1[j] based on LQ1[j] and DC[i], and first determine Q2[j] based on Q1[j]. The first device may further obtain the difference between LQ1[j] and Q1[j], and reallocate the difference to LQ1[j]. Thus, after the new packet sub-allocation is allocated to the j-th SRR queue, LQ1[j] may be decreased accordingly. The first device may select the smaller of DC[i] and LQ1[j] as Q1[j]. Therefore, as LQ1[j] decreases continuously, when the value of LQ1[j] is 0, the obtained Q1[j] is 0, and a new packet sub-allocation amount cannot be allocated to the j-th SRR queue. Therefore, during a single round of queue scheduling of the SRR queue set, the largest packet with a total length of Q1*[j] in the j-th SRR queue can be dequeued. The first device may process multiple SRR queues in the SRR queue set in the above-mentioned manner for processing the j-th SRR queue. After all SRR queues in the SRR queue set are processed, the current queue scheduling of the SRR queue set is terminated, and the first device may perform the next queue scheduling of the SRR queue set.
[0180] LQ1[j] indicates the maximum value of the total length of the remaining packets that can be added and dequeued from the j-th SRR queue, which indicates that the first device needs to further allocate a packet sub-quota with a length of LQ1[j] to the j-th SRR queue during the current queue scheduling of the SRR queue set in order to complete the processing of the j-th SRR queue. In this way, when allocating a new packet sub-quota to the SRR queue, the first device updates the remaining packet sub-quota accordingly. This is equivalent to recording the progress of the current queue scheduling performed by the first device for the SRR queue set in the remaining packet sub-quota corresponding to the multiple SRR queues in the SRR queue set. In this way, the queue scheduling performed by the first device for the SRR queue set each time can still be interrupted due to insufficient DC[i], but the progress when the queue scheduling performed for the SRR queue set each time is interrupted is stored in the remaining packet sub-quota corresponding to the multiple SRR queues in the SRR queue set. The first device again steps 603 When performing the above, the first device may follow the progress of the previous process to continue performing queue scheduling for the SRR queue set. In this way, the queue scheduling performed by the first device for the SRR queue set still depends on the packet balance that is not fully used by the DSRR queue, but the specific process of the first device performing queue scheduling for the SRR queue set is not affected by the progress of the queue scheduling performed by the first device for the DSRR queue set. In other words, to ensure that the proportion of network bandwidth resources allocated to the multiple SRR queues in the SRR queue set matches the proportion of the theoretical packet sub-allocation of the multiple SRR queues, the queue scheduling performed by the first device for the SRR queue set and the queue scheduling performed by the first device for the DSRR queue set are independent of each other.
[0181] For example, assume that an SRR queue set includes an SRR queue A and an SRR queue B, and the theoretical packet sub-quota Q1*[A] corresponding to SRR queue A is 800 bits, and the theoretical packet sub-quota Q1*[B] corresponding to SRR queue B is 700 bits. Before initiating queue scheduling for the SRR queue set, the first device may first determine that the remaining packet sub-quota LQ1[A] of SRR queue A is 800 bits, and the remaining packet sub-quota LQ1[B] of SRR queue B is 700 bits.
[0182] After the first device processes the i-th DSRR queue in the DSRR queue set, the packet balance Q[i] corresponding to the i-th DSRR queue is 500 bits. Because LQ1[A] is greater than DC[i], the first device may determine that the packet sub-quota Q1[A] of SRR queue A is 500 bits, obtain the difference between LQ1[A] and Q1[A], and reallocate the difference to LQ1[A]. When the processing for the currently set SRR queue is completed, LQ1[A] changes to 300 bits. Because the first device does not allocate the packet sub-quota to SRR queue B (the first device does not schedule queue B during the current queue scheduling), LQ1[B] is still 700 bits.
[0183] After the first device processes the k-th DSRR queue, the packet balance Q[k] corresponding to the k-th DSRR queue is 800 bits. In this case, LQ1[A] is smaller than DC[k], so the first device may determine that Q1[A] is 300 bits and update DC[k] to 500 bits. After completing the processing of SRR queue A, the first device may process SRR queue B. Since LQ1[B] is larger than DC[k], the first device may determine that the packet sub-allocation Q1[B] corresponding to SRR queue B is 500 bits and update LQ1[B] to 200 bits. After the scheduling of this SRR queue set time is completed, LQ1[A] changes to 0 bits and LQ1[B] changes to 200 bits.
[0184] After the first device processes the nth queue, the packet balance Q[n] corresponding to the nth DSRR queue is 300 bits. In this case, LQ1[A] is 0, and the first device does not process SRR queue A, but processes SRR queue B directly. Because LQ1[B] is smaller than DC[n], the first device may determine that Q1[B] is 200 bits, update LQ1[B] to 0 bits, and update DC[n] to 100 bits. After completing the processing of SRR queue B, the first device may determine that the current queue scheduling of the SRR queue set is finished based on the values of LQ1[A] and LQ1[B] being both 0. In this case, the first device may update LQ1[A] to 800 bits again, update LQ1[B] to 700 bits, and process SRR queue A and SRR queue B based on DC[n] to perform the next queue scheduling of the SRR queue set.
[0185] In some possible implementations, considering the principle of equal allocation among multiple SRR queues, the first device may further determine a packet sub-allocation amount corresponding to each SRR queue in the SRR queue set based on a preset weight corresponding to each SRR queue in the SRR queue set and a packet balance corresponding to the DSRR queue. Specifically, the first device may multiply the preset weight corresponding to the jth SRR queue by the packet balance DC[i] corresponding to the ith DSRR queue to obtain a packet sub-allocation amount Q1[j] corresponding to the jth SRR queue. The preset weight may be actively configured by those skilled in the art, or may be determined by the first device based on a theoretical packet sub-allocation amount corresponding to each SRR queue in the SRR queue set. For example, the first device first obtains the sum of multiple theoretical packet sub-allocation amounts respectively corresponding to multiple SRR queues in the SRR queue set, calculates the proportion occupied by the theoretical packet sub-allocation amount of each SRR queue in the sum of the theoretical packet sub-allocation amount, and uses the ratio as the preset weight of the SRR queue. For example, assume that the SRR queue set includes SRR queue A and SRR queue B, the theoretical packet sub-quota Q1*[A] corresponding to SRR queue A is 1000 bits, and the theoretical packet sub-quota Q1*[B] corresponding to SRR queue B is 1500 bits. During the time of queue scheduling, the packet balance DC[i] corresponding to the i-th DSRR queue in the DSRR queue set is 500 bits. Since the ratio of Q1*[A] to Q1*[B] is 2:3, when determining the packet sub-quota corresponding to SRR queue A and the packet sub-quota corresponding to SRR queue B, the first device may use 2 / 5 of DC[i] as the packet sub-quota corresponding to SRR queue A and 3 / 5 of DC[i] as the packet sub-quota corresponding to SRR queue B. Thus, the packet sub-quota corresponding to SRR queue A is 200 bits, and the packet sub-quota corresponding to SRR queue B is 300 bits.
[0186] Please refer to FIG. 8. An embodiment of the present application further provides an apparatus 800 for queue scheduling. The apparatus 800 may be disposed in a first device to perform step S201 and step S202 in the embodiment shown in FIG. 2. Alternatively, the first device may be the apparatus 800, and may include a first obtaining unit 801 and a first scheduling unit 802. The first obtaining unit 801 may be configured to perform step S201 in the embodiment shown in FIG. 2, and the first scheduling unit 802 may be configured to perform step S202 in the embodiment shown in FIG. 2. Specifically, the first obtaining unit 801 is configured to obtain a first packet balance when scheduling the first queue, where the first packet balance indicates an amount of packets that may be dequeued from the first queue. The first scheduling unit 802 schedules the second queue based on the first packet balance. The first scheduling unit 802 is specifically configured to schedule the second queue after the first packet balance is consumed. Alternatively, the first scheduling unit 801 is specifically configured to schedule the second queue when the first packet balance is less than the amount of the leading packet buffered in the first queue. The apparatus 800 disposed in the first device in this embodiment of the present application may be further configured to implement a corresponding method for performing queue scheduling by using a single queue as a unit in the embodiments corresponding to Figures 4 to 7.
[0187] For example, the first packet balance is a difference between the first packet allocation amount and the amount of packets dequeued from the first queue, and the first packet allocation amount is a sum of a preset total amount of packets that may be dequeued from the first queue during every queue scheduling and the first packet balance obtained during the previous time of scheduling the first queue. The apparatus 800 further includes a second scheduling unit 803 configured to schedule packets buffered in the first queue to be dequeued before the first scheduling unit 801 schedules the second queue, a first consuming unit 804 configured to consume the first packet balance when the amount of packets buffered in the first queue is 0, and a third scheduling unit 805 configured to schedule a third queue or schedule the first queue to a waiting state in the process of consuming the first packet balance.
[0188] For example, the first packet balance is a difference between the first packet allocation amount and the amount of packets dequeued from the first queue, and the first packet allocation amount is a sum of a preset total amount of packets that may be dequeued from the first queue during every queue scheduling and the first packet balance obtained during the previous time of scheduling the first queue. The apparatus 800 further includes a second scheduling unit 803 configured to schedule packets buffered in the first queue to be dequeued before the first scheduling unit 801 schedules the second queue, where an amount of packets buffered in the first queue is M1, where M1 is an integer greater than or equal to 1; a first consuming unit 804 configured to consume the first packet balance when the amount of packets buffered in the first queue is M2 greater than the first packet balance, where M2 is less than or equal to M1, where the amount of packets dequeued from the first queue is a difference between M1 and M2; and a third scheduling unit 805 configured to schedule a third queue or schedule the first queue to a waiting state in the process of consuming the first packet balance.
[0189] For example, the first packet balance is a difference between the first packet quota and the amount of packets dequeued from the first queue, and the first packet quota is a preset total amount of packets that may be dequeued from the first queue during every queue scheduling. The apparatus 800 further includes a second scheduling unit 803 configured to schedule packets buffered in the first queue to be dequeued before the first scheduling unit 801 schedules the second queue, where the amount of packets buffered in the first queue is M1, where M1 is an integer equal to or greater than 1, a first consuming unit 804 configured to consume the first packet balance when the amount of packets buffered in the first queue is 0, and a third scheduling unit 805 configured to schedule a third queue or schedule the first queue to a waiting state in the process of consuming the first packet balance.
[0190] For example, the amount of packets buffered in the first queue is 0, the first packet balance is the first packet quota, and the first packet quota is a preset total amount of packets that may be dequeued from the first queue during every queue scheduling. A first scheduling unit 801 a second consuming unit 806 configured to consume the first packet balance when an amount of packets buffered in the first queue is 0 before scheduling the second queue; The second consumer unit 806 and a third scheduling unit 805 configured to schedule the third queue or schedule the first queue into a standby state in the process of consuming the first packet balance.
[0191] Specifically, the third scheduling unit 805 may schedule the third queue in the following manners:
[0192] Scheme 1: The third scheduling unit 805 is specifically configured to obtain a second packet quota, where the second packet quota is a preset total amount of packets that may be dequeued from the third queue during every queue scheduling. The third scheduling unit 805 is specifically configured to consume the second packet quota to schedule the packets buffered in the third queue to be dequeued when the first packet balance is greater than the second packet quota. In one implementation, after the third queue is scheduled, the apparatus 800 further includes a second obtaining unit 807 configured to obtain a second packet balance, where the second packet balance is a difference between the first packet balance and the second packet quota, and a third consuming unit 806 configured to consume the second packet balance to schedule the packets buffered in the fourth queue to be dequeued. The fourth queue may be a queue whose priority is lower than the priority of the third queue or whose scheduling order is later than the scheduling order of the third queue.
[0193] Scheme 2: The third scheduling unit 805 is specifically configured to obtain a second packet quota, where the second packet quota is a preset total amount of packets that may be dequeued from the third queue during every queue scheduling, and the third scheduling unit 805 is specifically configured to consume the first packet balance to schedule packets buffered in the third queue to be dequeued when the first packet balance is less than or equal to the second packet quota.
[0194] Scheme 3: The third scheduling unit 805 is specifically configured to obtain a second packet quota and a third packet quota, where the second packet quota is a preset total amount of packets that may be dequeued from the third queue during every queue scheduling, and the third packet quota is a product of the first packet balance and a preset weight, where the preset weight is greater than 0 and less than 1. The third scheduling unit 805 is specifically configured to consume the second packet quota to schedule packets buffered in the third queue to be dequeued when the third packet quota is greater than the second packet quota. In one implementation, after the third queue is scheduled, the apparatus 800 further includes a third obtaining unit 808 configured to obtain a third packet balance, where the third packet balance is a difference between the third packet quota amount and the second packet quota amount, and a fourth consuming unit 809 configured to consume the third packet balance to schedule the packets buffered in the fourth queue to be dequeued. The fourth queue may be a queue whose priority is lower than the priority of the third queue or whose scheduling order is later than the scheduling order of the third queue.
[0195] Scheme 4: The third scheduling unit 805 is specifically configured to obtain a second packet quota and a third packet quota, where the second packet quota is a preset total amount of packets that may be dequeued from the third queue during every queue scheduling, and the third packet quota is a product of the first packet balance and a preset weight, where the preset weight is greater than 0 and less than 1. The third scheduling unit 805 is specifically configured to consume the third packet quota to schedule packets buffered in the third queue to be dequeued when the third packet quota is less than or equal to the second packet quota.
[0196] Please refer to FIG. 9. An embodiment of the present application further provides an apparatus 900 for scheduling queues in a queue set. The apparatus 900 is used in a first device, and the first device may perform step S301 and step S302 in the embodiment shown in FIG. 3. The apparatus 900 may include a first obtaining unit 901 and a first scheduling unit 902. The first obtaining unit 901 may be configured to perform step S301 in the embodiment shown in FIG. 3, and the first scheduling unit 902 may be configured to perform step S302 in the embodiment shown in FIG. 3. Specifically, the first obtaining unit 901 is configured to obtain a first packet balance when the queue set is scheduled for an Nth time, the queue set includes a first queue and a second queue, the first packet balance indicates an amount of packets that can be dequeued from the first queue and the second queue, and N is an integer equal to or greater than 1. The first scheduling unit 902 is configured to schedule the queue set for the (N+1)th time after the first packet balance is consumed. The apparatus 900 disposed in the first device in this embodiment of the present application may be further configured to implement a corresponding method for queue scheduling by using a queue set including multiple queues as a unit in the embodiment corresponding to Figures 4 to 7.
[0197] In a possible implementation, the first packet balance includes a second packet balance and a third packet balance, the second packet balance being a difference between the second packet quota and an amount of packets dequeued from the first queue, the second packet quota being a sum of a preset total amount of packets that may be dequeued from the first queue during every queue set scheduling and the second packet balance obtained during the previous queue set scheduling, and the third packet balance being a difference between the third packet quota and an amount of packets dequeued from the second queue, the third packet quota being a sum of a preset total amount of packets that may be dequeued from the second queue during every queue set scheduling and the third packet balance obtained during the previous queue set scheduling. The apparatus 900 further includes a second scheduling unit 903 configured to schedule packets buffered in the second queue to be dequeued before the first scheduling unit 902 schedules the (N+1)th queue set, where the scheduling of the second queue during every queue set scheduling is later than the scheduling of the first queue; a first consuming unit 904 configured to consume a first packet balance when the amount of packets buffered in the second queue is 0; and a third scheduling unit 905 configured to schedule a third queue or schedule the queue set to a waiting state in the process of consuming the first packet balance.
[0198] In a possible implementation, the first packet balance includes a second packet balance and a third packet balance, the second packet balance being a difference between the second packet quota and an amount of packets dequeued from the first queue, the second packet quota being a sum of a preset total amount of packets that may be dequeued from the first queue during every queue set scheduling and the second packet balance obtained during the previous queue set scheduling, and the third packet balance being a difference between the third packet quota and an amount of packets dequeued from the second queue, the third packet quota being a sum of a preset total amount of packets that may be dequeued from the second queue during every queue set scheduling and the third packet balance obtained during the previous queue set scheduling. The apparatus 900 further includes a second scheduling unit 903 configured to schedule packets buffered in the second queue to be dequeued before the first scheduling unit 902 schedules the (N+1)th queue set, where an amount of packets buffered in the second queue is M1, where M1 is an integer equal to or greater than 1, and the scheduling of the second queue during every queue set scheduling is later than the scheduling of the first queue; a first consuming unit 904 configured to consume the first packet balance when the amount of packets buffered in the second queue M2 is greater than a third packet balance, M2 is less than or equal to M1, and the amount of packets dequeued from the first queue is a difference between M1 and M2; and a third scheduling unit 905 configured to schedule the third queue or schedule the queue set to a waiting state in the process of consuming the first packet balance.
[0199] In a possible implementation, the first packet balance includes a second packet balance and a third packet balance, the second packet balance being a difference between the second packet quota and an amount of packets dequeued from the first queue, the second packet quota being a preset total amount of packets that may be dequeued from the first queue during every queue set scheduling, and the third packet balance being a difference between the third packet quota and an amount of packets dequeued from the second queue, the third packet quota being a preset total amount of packets that may be dequeued from the second queue during every queue set scheduling. The apparatus 900 further includes a second scheduling unit 903 configured to schedule packets buffered in the second queue to be dequeued before the first scheduling unit 902 schedules the (N+1)th queue set, where the scheduling of the second queue during every queue set scheduling is later than the scheduling of the first queue; a first consuming unit 904 configured to consume a first packet balance when the amount of packets buffered in the second queue is 0; and a third scheduling unit 905 configured to schedule a third queue or schedule the queue set to a waiting state in the process of consuming the first packet balance.
[0200] In a possible implementation, the first packet balance includes a second packet balance and a third packet balance, the second packet balance being a difference between the second packet quota and an amount of packets dequeued from the first queue, the second packet quota being a preset total amount of packets that may be dequeued from the first queue during every queue set scheduling, and the third packet balance being a difference between the third packet quota and an amount of packets dequeued from the second queue, the third packet quota being a preset total amount of packets that may be dequeued from the second queue during every queue set scheduling. The apparatus 900 further includes a second scheduling unit 903 configured to schedule packets buffered in the second queue to be dequeued before the first scheduling unit 902 schedules the (N+1)th queue set, where an amount of packets buffered in the second queue is M1, where M1 is an integer equal to or greater than 1, and the scheduling of the second queue during every queue set scheduling is later than the scheduling of the first queue; a first consuming unit 904 configured to consume the first packet balance when the amount of packets buffered in the second queue M2 is greater than a third packet balance, M2 is less than or equal to M1, and the amount of packets dequeued from the first queue is a difference between M1 and M2; and a third scheduling unit 905 configured to schedule the third queue or schedule the queue set to a waiting state in the process of consuming the first packet balance.
[0201] In a possible implementation, the amount of packets buffered in the first queue and the second queue is zero, the first packet balance includes a second packet balance and a third packet balance, the second packet balance is a difference between the second packet quota and an amount of packets dequeued from the first queue, the second packet quota is a preset total amount of packets that may be dequeued from the first queue during every queue set scheduling, and the third packet balance is a difference between the third packet quota and an amount of packets dequeued from the second queue, the third packet quota is a preset total amount of packets that may be dequeued from the second queue during every queue set scheduling. The apparatus 900 further includes a first consuming unit 904 configured to consume a first packet balance when an amount of packets buffered in the second queue is 0 before the queue set is scheduled for the (N+1)th time, where the scheduling of the second queue is later than the scheduling of the first queue during every queue set scheduling, and a third scheduling unit 905 configured to schedule a third queue or schedule the queue set to a waiting state in the process of consuming the first packet balance.
[0202] Specifically, the third scheduling unit 905 in this embodiment of the present application may schedule the third queue in the following multiple manners: Manner 1: The third scheduling unit 905 is specifically configured to obtain a fourth packet quota, where the fourth packet quota is a preset total amount of packets that may be dequeued from the third queue during each scheduling. The third scheduling unit 905 is specifically configured to consume the fourth packet quota to schedule the packets buffered in the third queue to be dequeued when the first packet balance is greater than the fourth packet quota. In a possible implementation form, the apparatus 900 further includes a second obtaining unit 906 configured to obtain a fourth packet balance, where the fourth packet balance is a difference between the first packet balance and the fourth packet quota, and a second consuming unit 907 configured to consume the fourth packet balance to schedule the packets buffered in the fourth queue to be dequeued. The fourth queue may be a queue whose priority is lower than that of the third queue, or whose scheduling order is later than that of the third queue. Scheme 2: The third scheduling unit 905 obtains a fourth packet quota, where the fourth packet quota is a preset total amount of packets that may be dequeued from the third queue during every scheduling, and is configured to consume the first packet balance to schedule packets buffered in the third queue to be dequeued when the first packet balance is less than or equal to the fourth packet quota.
[0203] An embodiment of the present application further provides a device for queue scheduling, corresponding to the apparatus 800 for queue scheduling. The device includes a processor and a memory. The memory is configured to store instructions. The processor is configured to execute the instructions in the memory to perform the method for queue scheduling provided in the embodiment shown in FIG. 2 and performed by a first device.
[0204] An embodiment of the present application further provides a device for queue scheduling, corresponding to the apparatus 900 for queue scheduling. The device includes a processor and a memory. The memory is configured to store instructions. The processor is configured to execute the instructions in the memory to perform the method for queue scheduling provided in the embodiment shown in FIG. 3 and performed by a first device.
[0205] The structure shown in FIG. 10 can be used as the hardware structure of both the device for queue scheduling corresponding to the device 800 and the device for queue scheduling corresponding to the device 900. FIG. 10 is a schematic diagram of the structure of the device according to one embodiment of the present application. Please refer to FIG. 10. The device 1000 includes a processor 1010, a communication interface 1020, and a memory 1030. There may be one or more processors 1010 in the device 1000, and one processor 1010 is used as an example in FIG. 10. In this embodiment of the present application, the processor 1010, the communication interface 1020, and the memory 1030 may be connected by using a bus system or in other manners. In FIG. 10, an example is used in which the processor 1010, the communication interface 1020, and the memory 1030 are connected by using a bus system 1040. The processor 1010 may be a central processing unit (CPU), a network processor (NP), or a combination of a CPU and a NP. In one implementation, the processor 101 may alternatively be a traffic management (TM) chip, or a hardware that integrates the NP and the TM chip, and the TM chip, or the hardware that integrates the NP and the TM chip, may perform the method for queue scheduling provided in the embodiment of the present application on the queue in the TM chip. The processor 1010 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof.The PLD may be the aforementioned complex programmable logic device (CPLD), field-programmable gate array (FPGA), generic array logic (GAL), or any combination thereof. The memory 1030 may include a volatile memory, such as a random-access memory (RAM). Alternatively, the memory 1030 may include a non-volatile memory, such as a flash memory, a hard disk drive (HDD), or a solid-state drive (SSD). The memory 1030 may further include a combination of the aforementioned types of memory. The memory 1030 stores an operating system and programs, executable modules or data structures, a subset thereof, or an extension thereof. The programs may include various operating instructions used to implement various operations. The operating system may include various system programs to implement various basic services and handle hardware-based tasks. The bus system 1040 may be a peripheral component interconnect (PCI) bus, an extended industry standard architecture (EISA) bus, etc. The bus system 1040 may be categorized as an address bus, a data bus, a control bus, etc. Although the bus system 1040 is represented in FIG. 10 by using only one thick line, this does not imply that there is only one bus or only one type of bus.
[0206] An embodiment of the present application further provides a computer-readable storage medium including instructions, which, when executed on a computer, enable the computer to perform a method for queue scheduling provided in the embodiment of the method described above and performed by a first device.
[0207] An embodiment of the present application further provides a computer program product including instructions, which when executed on a computer, enable the computer to perform a method for queue scheduling provided in the aforementioned method embodiment and performed by a first device.
[0208] In the embodiments provided in the present application, the apparatus and method may be implemented in other ways. For example, the unit division is merely a logical module division, and other division ways may exist in the actual implementation form. For example, multiple units or components may be combined or integrated into one module. The unit may be implemented in the form of hardware, or in the form of a software module unit. When the unit is implemented in the form of a software module unit and sold or used as an independent product, the unit may be stored in a computer-readable storage medium. The apparatus provided in the embodiments of the present application may be implemented in the form of a software product. The computer software product is stored in a storage medium and includes multiple instructions for instructing a computer device (which may be a personal computer, a server, or a network device) to perform all or part of the steps of the method described in the embodiments of the present application.
[0209] The above embodiments are only for illustrating the technical solutions of the present application, and are not intended to limit the present application. Although the present application has been described in detail with reference to the above embodiments, those skilled in the art should understand that, without departing from the scope of the technical solutions of the embodiments of the present application, modifications can still be made to the technical solutions described in the above embodiments, or equivalent substitutions can be made for some technical features thereof. [Explanation of symbols]
[0210] 10. System 11 First Device 12 Second Device 13 Third Device 700 equipment 800 equipment 801 First Acquisition Unit 802 First Scheduling Unit 803 Second Scheduling Unit 804 1st consumer unit 805 Third Scheduling Unit 806 Secondary consumer unit 807 Second Acquisition Unit 808 Third Acquisition Unit 809 4th consumption unit 900 equipment 901 First Acquisition Unit 902 First Scheduling Unit 903 Second Scheduling Unit 904 1st consumption unit 905 Third Scheduling Unit 906 Second Acquisition Unit 907 Secondary consumption unit 1000 devices 1010 Processor 1020 Communication Interface 1030 Memory 1040 Bus System
Claims
1. 1. A method for queue scheduling, the method comprising: obtaining, by a first device, a first packet balance when scheduling a first queue, the first packet balance indicating an amount of packets that may be dequeued from the first queue; scheduling, by the first device, packets buffered in the first queue to be dequeued; When an amount of packets buffered in the first queue is 0, consuming the first packet balance by scheduling, by the first device, a third queue, the third queue being a best effort queue or an excess round robin queue; after the first packet balance is consumed by the first device, scheduling a second queue that is next to the first queue in a scheduling order based on the first packet balance; A method comprising:
2. A method for queue scheduling, the method comprising: obtaining, by a first device, a first packet balance when scheduling a first queue, the first packet balance indicating an amount of packets that may be dequeued from the first queue; scheduling, by the first device, packets buffered in the first queue to be dequeued; determining, by the first device, a wait duration corresponding to the first queue based on a remaining packet balance of the first queue when an amount of packets buffered in the first queue is 0; scheduling, by the first device, a second queue that is next to the first queue in a scheduling order based on the first packet balance after the wait duration expires; A method comprising:
3. The step of scheduling, by the first device, a second queue based on the first packet balance, further comprising:
3. The method of claim 1, further comprising: scheduling, by the first device, the second queue when the first packet balance is less than an amount of a leading packet buffered in the first queue.
4. 3. The method of claim 1, wherein the first packet balance is a difference between a first packet quota and an amount of packets dequeued from the first queue, the first packet quota being a sum of a preset total amount of packets that may be dequeued from the first queue during every queue scheduling and the first packet balance obtained during a previous scheduling of the first queue.
5. A method for queue scheduling, the method comprising: obtaining, by a first device, a first packet balance when scheduling a first queue, the first packet balance indicating an amount of packets that may be dequeued from the first queue, the first packet balance being a difference between a first packet quota and an amount of packets dequeued from the first queue, the first packet quota being a sum of a preset total amount of packets that may be dequeued from the first queue during every queue scheduling and the first packet balance obtained during a previous scheduling of the first queue; scheduling, by the first device, packets buffered in the first queue to be dequeued, where an amount of packets buffered in the first queue is M1, where M1 is an integer equal to or greater than 1; M2 is less than or equal to M1, and the amount of packets dequeued from the first queue is the difference between M1 and M2, and when the amount of packets buffered in the first queue, M2, is greater than the first packet balance; consuming the first packet balance by scheduling, by the first device, a third queue, the third queue being a best effort queue or an excess round robin queue; or determining, by the first device, a wait duration corresponding to the first queue based on a remaining packet balance of the first queue; scheduling, by the first device, a second queue that is next to the first queue in a scheduling order based on a remaining packet balance of the first queue after the first packet balance is consumed or after the wait duration expires; A method comprising:
6. The method described in claim 4, wherein, in the step of scheduling by the first device to dequeue packets buffered in the first queue, the amount of packets buffered in the first queue is M1, where M1 is an integer greater than or equal to 1.
7. 3. The method of claim 1, wherein an amount of packets buffered in the first queue is 0, and the first packet balance is a first packet quota, the first packet quota being a preset total amount of packets that may be dequeued from the first queue during every queue scheduling.
8. The step of scheduling a third queue in a process of consuming the first packet balance by the first device includes: obtaining, by the first device, a second packet quota, the second packet quota being a preset total amount of packets that may be dequeued from the third queue during every queue scheduling; scheduling, by the first device, when the first packet balance is greater than the second packet quota, to consume the second packet quota and dequeue packets buffered in the third queue; 6. The method of claim 1 or 5, comprising:
9. 1. An apparatus for queue scheduling, the apparatus comprising: a first obtaining unit configured to obtain a first packet balance when a first queue is scheduled, the first packet balance indicating an amount of packets that may be dequeued from the first queue; a second scheduling unit configured to schedule packets buffered in the first queue to be dequeued; a third scheduling unit configured to schedule a third queue, the third queue being a best effort queue or a surplus round robin queue, to consume the first packet balance when an amount of packets buffered in the first queue is 0; a first scheduling unit configured to schedule a second queue that is next to the first queue in a scheduling order based on the first packet balance after the first packet balance is consumed.
10. An apparatus for queue scheduling, comprising: a first obtaining unit configured to obtain a first packet balance when a first queue is scheduled, the first packet balance indicating an amount of packets that may be dequeued from the first queue; a second scheduling unit configured to schedule packets buffered in the first queue to be dequeued; a third scheduling unit configured to determine a waiting duration corresponding to the first queue based on a remaining packet balance of the first queue when an amount of packets buffered in the first queue is 0; and a first scheduling unit configured to schedule a second queue that is next to the first queue in a scheduling order based on the first packet balance after the wait duration expires.
11. The apparatus according to claim 9 or 10, wherein the first scheduling unit is particularly configured to schedule the second queue when the first packet balance is less than an amount of a leading packet buffered in the first queue.
12. 11. The apparatus of claim 9 or 10, wherein the first packet balance is a difference between a first packet quota and an amount of packets dequeued from the first queue, the first packet quota being a sum of a preset total amount of packets that may be dequeued from the first queue during every queue scheduling and the first packet balance obtained during a previous scheduling of the first queue.
13. An apparatus for queue scheduling, comprising: a first obtaining unit configured to obtain a first packet balance when a first queue is scheduled, the first packet balance indicating an amount of packets that may be dequeued from the first queue, the first packet balance being a difference between a first packet allocation amount and an amount of packets dequeued from the first queue, the first packet allocation amount being a sum of a preset total amount of packets that may be dequeued from the first queue during every queue scheduling and the first packet balance obtained during a previous scheduling of the first queue; a second scheduling unit configured to schedule packets buffered in the first queue to be dequeued, the amount of packets buffered in the first queue being M1, where M1 is an integer equal to or greater than 1; a third scheduling unit, wherein M2 is less than or equal to M1, the amount of packets dequeued from the first queue is a difference between M1 and M2, and when the amount of packets buffered in the first queue, M2, is greater than the first packet balance; scheduling a third queue, the third queue being a best effort queue or a surplus round robin queue, to consume the first packet balance; or a third scheduling unit configured to determine a waiting duration corresponding to the first queue based on a remaining packet balance of the first queue; a first scheduling unit configured to schedule a second queue that is next to the first queue in a scheduling order based on the first packet balance after the first packet balance is consumed or after the wait duration expires.
14. The apparatus described in claim 12, wherein the second scheduling unit is configured to schedule packets buffered in the first queue to be dequeued, and the amount of packets buffered in the first queue is M1, where M1 is an integer greater than or equal to 1.
15. 11. The apparatus of claim 9 or 10, wherein an amount of packets buffered in the first queue is 0, and the first packet balance is a first packet quota, the first packet quota being a preset total amount of packets that may be dequeued from the first queue during every queue scheduling.
16. The third scheduling unit: obtaining a second packet quota, the second packet quota being a preset total amount of packets that may be dequeued from the third queue during every queue scheduling; When the first packet balance is greater than the second packet allocation, the second packet allocation is consumed to schedule packets buffered in the third queue to be dequeued.
10. The device according to claim 9, specifically adapted for:
Citation Information
Patent Citations
Prioritized continuous-deficit round robin scheduling
US6914881B1
