Data scheduling method for switch and switch
By combining queue weights and data packet count in the switch and adjusting the queue position, the limitations of existing queue scheduling algorithms in fine control and efficient management are solved, and fine management and efficient scheduling of data traffic are realized, network resource utilization and traffic fairness are improved.
Patent Information
- Application Number
- CN202411928679.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-04-08
Smart Images

Figure CN119788616A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data scheduling, and in particular to a data scheduling method for a switch and the switch. Background Art
[0002] When the switch forwards data, it needs to sort the data to be forwarded in the cache, and this process is achieved through queues. The queue is actually a logical structure that arranges data in order in the cache. When the rate of network traffic exceeds the bandwidth limit of the interface, or exceeds the bandwidth threshold specially set for the traffic, the data will be temporarily stored in the cache in the form of a queue.
[0003] The time and order of data leaving the queue, as well as the relationship between data leaving different queues, are all determined by queue scheduling algorithms. These algorithms ensure the orderly transmission and efficient management of network traffic.
[0004] Among the many queue scheduling algorithms, DWRR (Deficit Weighted Round Robin) scheduling algorithm and WFQ (Weighted Fair Queuing) scheduling algorithm are two common choices. However, they each have some limitations. Although the DWRR scheduling algorithm is relatively simple to implement, in some cases, its scheduling effect on data packets may not be ideal and cannot meet the needs of highly refined control of network traffic. The WFQ scheduling algorithm is known for its fairness and efficiency, and can ensure fair distribution between different traffic, but this also correspondingly increases the requirements for hardware, which may face higher costs and complexity in actual deployment. Summary of the invention
[0005] In view of the problems existing in the prior art, the present invention provides a data scheduling method for a switch, wherein a plurality of data queues to be forwarded are cached in the switch, each data queue includes a plurality of data packets, and each data queue is associated with a corresponding queue weight and the number of data packets; the data scheduling method comprises:
[0006] Step S1, the switch adds each data queue to a real-time queue to be forwarded according to the queue weight of each data queue;
[0007] Step S2, the switch sends a data packet from the first data queue of the real-time queue to be forwarded and reduces the number of data packets associated with it by one, and then the switch calculates a corresponding scheduling value for each data queue in the real-time queue to be forwarded according to the number of associated data packets and the queue weight;
[0008] In step S3, the switch adjusts the position of the first data queue in the real-time queue to be forwarded according to each scheduling value, obtains the scheduled queue to be forwarded as the real-time queue to be forwarded, and then returns to step S2 to send packets until all the data packets in the data queues are sent out and then exits.
[0009] Preferably, the step S2 includes:
[0010] Step S21, the switch sends a data packet from the first data queue of the queue to be forwarded and reduces the number of data packets associated with the data packet by one;
[0011] Step S22: For each of the data queues in the to-be-forwarded queues, the switch divides the number of data packets in the data queue by the queue weight to obtain the corresponding scheduling value.
[0012] Preferably, step S3 comprises:
[0013] Step S31, the switch calculates a scheduling average value according to all the scheduling values and the total number of the data queues;
[0014] Step S32, the switch determines whether the scheduling value of the first data queue is greater than the scheduling average value:
[0015] If yes, moving the first data queue to behind the second data queue of the real-time queue to be forwarded;
[0016] If not, moving the first data queue to the end of the real-time queue to be forwarded;
[0017] In step S33, the switch obtains the scheduled queue to be forwarded as the real-time queue to be forwarded, and then returns to step S2 to send packets until all the data packets in the data queues are sent.
[0018] Preferably, the step S33 includes:
[0019] Step S331, the switch obtains the queue to be forwarded after scheduling, and then removes the data queue whose number of data packets is not greater than zero from the queue to be forwarded after scheduling;
[0020] In step S332, the switch uses the scheduled queue to be forwarded as the real-time queue to be forwarded, and then returns to step S2 to send packets until all the data packets in the data queues are sent out and then exits.
[0021] Preferably, before executing step S21, step S2 further includes:
[0022] Step S20, the switch determines whether there is only one data queue in the real-time queue to be forwarded:
[0023] If yes, the data packets in the existing data queue are sent out in sequence, and then exit;
[0024] If not, go to step S21.
[0025] The present invention also provides a switch, applying the above-mentioned data scheduling method, comprising:
[0026] A cache module, caching multiple data queues to be forwarded, each data queue including multiple data packets, each data queue being associated with a corresponding queue weight and number of data packets;
[0027] An initial module, connected to the cache module, configured to add each of the data queues to a real-time queue to be forwarded according to the queue weight of each of the data queues;
[0028] a packet sending module, connected to the initial module, configured to send a data packet to the first data queue in the real-time queue to be forwarded and reduce the number of data packets associated with it by one, and then for each data queue in the real-time queue to be forwarded, calculate a corresponding scheduling value according to the number of associated data packets and the queue weight;
[0029] The scheduling module is connected to the packet sending module and is used to adjust the position of the first data queue in the real-time queue to be forwarded according to each scheduling value, and obtain the scheduled queue to be forwarded as the real-time queue to be forwarded and feed it back to the packet sending module.
[0030] Preferably, the packet sending module includes:
[0031] A packet sending unit, used for sending a data packet to the first data queue in the queue to be forwarded and reducing the number of data packets associated with the first data queue by one;
[0032] A scheduling value calculation unit is connected to the packet sending unit and is used for the switch to obtain the corresponding scheduling value by dividing the number of data packets in the data queue by the queue weight for each data queue in the queue to be forwarded.
[0033] Preferably, the scheduling module includes:
[0034] An average calculation unit, used for calculating a scheduling average value according to all the scheduling values and the total number of the data queues;
[0035] a scheduling unit, connected to the average calculation unit, configured to move the first data queue to the back of the second data queue of the real-time queue to be forwarded when it is determined that the scheduling value of the first data queue is greater than the scheduling average value, and to move the first data queue to the end of the real-time queue to be forwarded when it is determined that the scheduling value of the first data queue is not greater than the scheduling average value;
[0036] A feedback unit is connected to the scheduling unit and is used to obtain the scheduled queue to be forwarded as the real-time queue to be forwarded, and then feed back to the packet sending module.
[0037] Preferably, the feedback unit comprises:
[0038] a clearing subunit, configured to obtain the queue to be forwarded after scheduling, and then remove the data queue whose number of data packets is not greater than zero from the queue to be forwarded after scheduling;
[0039] A feedback subunit is connected to the clearing subunit and is used to use the scheduled queue to be forwarded as the real-time queue to be forwarded, and then feed back to the packet sending module.
[0040] Preferably, the packet sending module also includes:
[0041] The single queue sending unit is used to send out the data packets in the only existing data queue in sequence when there is only one data queue in the real-time queue to be forwarded.
[0042] The above technical solution has the following advantages or beneficial effects:
[0043] 1. The scheduling value is calculated by combining the queue weight and the number of packets, and the position of the first data queue in the real-time forwarding queue is adjusted accordingly, thus achieving fine management and efficient scheduling of data traffic.
[0044] 2. By considering the queue weight and the number of packets, it can ensure that the data queues with high priority or important services get more sending opportunities, while not ignoring the sending needs of low priority queues. This balancing mechanism improves the overall utilization of network resources and avoids idle or over-occupied resources.
[0045] 3. This method dynamically adjusts the queue position so that data packets can be processed and sent faster, which reduces the waiting time and transmission delay of data packets and improves the efficiency of data packet sending. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 A schematic flow chart of a data scheduling method for a switch in a preferred embodiment of the present invention;
[0047] Figure 2 This is a schematic diagram of a sub-process of S3 in a preferred embodiment of the present invention;
[0048] Figure 3 This is a schematic diagram of a sub-process of S2 in a preferred embodiment of the present invention;
[0049] Figure 4 This is a schematic diagram of a sub-process of S33 in a preferred embodiment of the present invention;
[0050] Figure 5 The figure is a schematic diagram of the structure of a switch in a preferred embodiment of the present invention. DETAILED DESCRIPTION
[0051] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. The present invention is not limited to this embodiment, and other embodiments may also fall within the scope of the present invention as long as they conform to the gist of the present invention.
[0052] In a preferred embodiment of the present invention, based on the above problems existing in the prior art, a data scheduling method for a switch is provided, wherein a plurality of data queues to be forwarded are cached in the switch, each data queue includes a plurality of data packets, and each data queue is associated with a corresponding queue weight and number of data packets; Figure 1 As shown, the data scheduling method includes:
[0053] Step S1, the switch adds each data queue to the real-time queue to be forwarded according to the queue weight of each data queue;
[0054] Step S2, the switch sends a data packet from the first data queue of the real-time forwarding queue and reduces the number of data packets associated with it by one, and then the switch calculates the corresponding scheduling value for each data queue in the real-time forwarding queue according to the number of associated data packets and the queue weight;
[0055] In step S3, the switch adjusts the position of the first data queue in the real-time queue to be forwarded according to each scheduling value, obtains the scheduled queue to be forwarded as the real-time queue to be forwarded, and then returns to step S2 to send packets until all data packets in all data queues are sent out and then exits.
[0056] Specifically, in this embodiment, the scheduling value is calculated by combining the queue weight and the number of data packets, and the position of the first data queue in the queue in the real-time forwarding queue is adjusted accordingly, thereby achieving fine management and efficient scheduling of data traffic. The beneficial effects of this method are mainly reflected in the following aspects:
[0057] Improve network resource utilization:
[0058] By considering the queue weight and the number of packets, this method can ensure that the data queues with high priority or important services get more sending opportunities, while not neglecting the sending needs of the low priority queues. This balancing mechanism improves the overall utilization of network resources and avoids idle or over-occupied resources.
[0059] Enhance network traffic fairness:
[0060] By calculating the scheduling value and adjusting the queue position accordingly, this method ensures that different data queues can obtain relatively fair transmission opportunities. This helps to avoid the "starvation" phenomenon caused by some data queues not being served for a long time, thereby improving the fairness of network traffic and service quality.
[0061] Improve data packet sending efficiency:
[0062] The method enables data packets to be processed and sent faster by dynamically adjusting the queue position, thereby reducing the waiting time and transmission delay of data packets and improving the efficiency of data packet sending.
[0063] Enhance network adaptability:
[0064] This method can adjust the scheduling strategy in real time according to the weights and number of packets of different data queues, so as to adapt to the dynamic changes of network traffic. This adaptability enables the network to maintain stable performance when facing burst traffic or traffic fluctuations.
[0065] Simplified scheduling algorithm implementation:
[0066] Compared with some complex scheduling algorithms, this method can achieve efficient traffic scheduling through simple calculations and queue adjustments. This not only reduces the difficulty and cost of algorithm implementation, but also improves the stability and reliability of the algorithm.
[0067] In summary, the data scheduling method of the present invention realizes fine management and efficient scheduling of network traffic by comprehensively considering queue weights and the number of data packets. This method has shown significant beneficial effects in improving network resource utilization, enhancing network traffic fairness, improving data packet transmission efficiency, enhancing network adaptability, and simplifying scheduling algorithm implementation.
[0068] In a preferred embodiment of the present invention, Figure 2 As shown, step S3 includes:
[0069] Step S31, the switch calculates a scheduling average value according to all scheduling values and the total number of data queues;
[0070] Step S32: The switch determines whether the scheduling value of the first data queue is greater than the scheduling average value:
[0071] If yes, the first data queue is moved to behind the second data queue of the real-time forwarding queue;
[0072] If not, the first data queue is moved to the end of the real-time queue to be forwarded;
[0073] In step S33, the switch obtains the scheduled queue to be forwarded as the real-time queue to be forwarded, and then returns to step S2 to send packets until all data packets in all data queues are sent.
[0074] Specifically, in the scheduling algorithm of the present invention, the switch caches multiple data queues to be forwarded, each data queue includes multiple data packets, and the switch first sorts the data queues according to the queue weights of the data queues to form a data queue to be forwarded;
[0075] Subsequently, the switch controls the data queue at the head of the queue to be forwarded to send a data packet, and the number of data packets associated with the data queue is reduced by one. At this time, the DWRR algorithm will directly move the data queue at the head of the queue to the end of the queue, and the WFQ algorithm will find the data queue with the largest (number of data packets / queue weight) in the queue to be sent and put it at the head of the queue. For these two algorithms, the DWRR algorithm has a fast scheduling speed and low hardware requirements, but its scheduling effect is not ideal. The WFQ algorithm has a good scheduling effect but high hardware requirements. The scheduling algorithm in this embodiment adjusts the position of the first data queue by comparing the scheduling value of the first data queue with the average scheduling value of all data queues.
[0076] Compared with the DWRR algorithm:
[0077] The data scheduling method of the present invention not only considers the weight of the data queue, but also realizes more refined traffic scheduling by calculating the scheduling value and adjusting the queue position accordingly. The DWRR algorithm mainly relies on the weight and the shortage counter for polling scheduling, and the scheduling process is relatively simple.
[0078] In the scheduling method of the present invention, even if the weight of the low priority queue is low, it has the opportunity to obtain the sending opportunity during the scheduling process, thereby avoiding the problem that the low priority queue is not served for a long time. Although the DWRR algorithm improves the problem of low priority queue starvation in the PQ (Priority Queuing) algorithm to a certain extent, in some cases, the low priority queue may still face a long waiting time.
[0079] In the scheduling method of the present invention, by calculating the scheduling value and dynamically adjusting the queue position, it can more flexibly adapt to changes in network traffic. However, the DWRR algorithm mainly relies on fixed weights and shortage counters for scheduling, and lacks such dynamic adjustment capabilities.
[0080] Compared with WFQ algorithm
[0081] In the scheduling method of the present invention, while achieving fair traffic scheduling, the hardware requirements are lower than those of the WFQ algorithm. The WFQ algorithm needs to maintain the virtual clock of each data flow and complex weight calculation, which places high requirements on the performance and cost of the hardware. The scheduling method of the present invention can achieve a fair scheduling effect through simple calculation and queue adjustment.
[0082] In the scheduling method of the present invention, the scheduling efficiency is improved by reducing unnecessary calculations and complex queue management mechanisms. In contrast, the WFQ algorithm needs to maintain multiple queues and virtual clocks, which increases the complexity and delay of scheduling.
[0083] The scheduling method of the present invention is not only applicable to data queues with fixed weights, but also can adapt to situations where the weights change dynamically, which makes the algorithm more adaptable when dealing with different types of network traffic and business requirements.
[0084] In summary, the data scheduling algorithm of the present invention reduces the hardware requirements and improves the scheduling efficiency while maintaining the scheduling effect. In addition, the algorithm is also highly adaptable and can cope with different types of network traffic and business requirements. These advantages make the algorithm have a wide range of application prospects in the field of network traffic scheduling.
[0085] In a preferred embodiment of the present invention, Figure 3 As shown, step S2 includes:
[0086] Step S21, the switch sends a data packet from the first data queue of the queue to be forwarded and reduces the number of data packets associated with it by one;
[0087] Step S22: For each data queue in the to-be-forwarded queue, the switch divides the number of data packets in the data queue by the queue weight to obtain a corresponding scheduling value.
[0088] Specifically, in this embodiment, the calculation formula of the scheduling value is:
[0089] T = credit / weight
[0090] Among them, T is the scheduling value, credit is the number of packets, and weight is the queue weight.
[0091] After the packet is sent, the scheduling value is calculated based on the number of packets after the first data queue has sent the packet and the queue weight. Even if the number of packets in the first data queue is zero at this time (that is, the last packet in the data queue has just been sent), the corresponding scheduling value can be calculated to schedule the data queue, even if it is zero.
[0092] Of course, another approach can be adopted. If there is only one data packet in the first data queue, two data packets can be sent continuously, one is the last data packet in the first data queue, and the other is the data packet in the second data queue. This approach can omit one scheduling process. Because the scheduling value of zero must be less than the average scheduling value, the first data queue must be moved to the end of the queue, and then the data packet in the next data queue is sent.
[0093] In a preferred embodiment of the present invention, Figure 4 As shown, step S33 includes:
[0094] Step S331, the switch obtains the queue to be forwarded after scheduling, and then removes the data queue whose number of data packets is not greater than zero from the queue to be forwarded after scheduling;
[0095] In step S332, the switch uses the scheduled queue to be forwarded as the real-time queue to be forwarded, and then returns to step S2 to send packets until all data packets in all data queues are sent out and then exits.
[0096] Specifically, in this embodiment, in step S331, the switch removes the data queue with the number of data packets not greater than zero from the queue to be forwarded after scheduling. This operation ensures the effective use of system resources (such as cache and processing capacity). When all data packets in a data queue have been sent, removing it from the queue can reduce unnecessary resource occupation, so that these resources can be used by other data queues that still need to send data packets.
[0097] By removing the data queues that have been sent, the real-time queues to be forwarded that are re-determined in step S332 will only contain queues that still have data packets to be sent. This simplifies the complexity of subsequent scheduling because the scheduler does not need to consider those queues that are already vacant. This simplification can improve the efficiency of scheduling, allowing data packets to be processed and forwarded faster.
[0098] In traditional scheduling algorithms such as DWRR or WFQ, if the queues that have been sent are not removed, the scheduler may continue to perform unnecessary checks and operations on these queues. This not only wastes processing time, but may also introduce additional delays. In this embodiment, by explicitly removing these queues, these invalid operations are avoided, thereby improving the overall performance.
[0099] From an implementation perspective, removing the queue of sent data also simplifies the implementation of the algorithm. This reduces the data structure and logic complexity that needs to be processed, making the algorithm easier to understand and implement.
[0100] In a preferred embodiment of the present invention, step S2 further includes before executing step S21:
[0101] Step S20: The switch determines whether there is only one data queue in the real-time queue to be forwarded:
[0102] If yes, the only data packets in the existing data queue will be sent out in sequence, and then exit;
[0103] If not, go to step S21.
[0104] Specifically, in this embodiment, the judgment logic of step S20 allows the switch to directly send out all data packets in the queue in sequence when there is only one data queue in the real-time forwarding queue, and then exit the processing flow. This processing method avoids unnecessary scheduling calculations and queue management operations, thereby simplifying the processing flow and improving overall efficiency.
[0105] When there is only one data queue in the real-time forwarding queue, it is meaningless to perform complex scheduling calculations, because no matter how the scheduling is performed, the result is that the data packets in this queue are sent in sequence. Through the judgment of step S20, the switch can skip these unnecessary calculations, thereby reducing scheduling overhead and improving system performance.
[0106] When there is only one data queue that needs to send data packets, sending these data packets directly in sequence can minimize the waiting time and increase the speed of data packet sending. This is especially important for application scenarios that require fast data transmission.
[0107] The introduction of step S20 enables the algorithm to adapt to different network environments and traffic conditions more flexibly. In light load or specific scenarios, when the number of data queues in the real-time forwarding queue is small, the algorithm can respond quickly and process data packets efficiently.
[0108] In some cases, if the scheduling algorithm still performs complex scheduling calculations when there is only one data queue, potential errors or inconsistencies may be introduced. Through the judgment of step S20, these potential problems can be avoided and the correctness and stability of the algorithm can be ensured.
[0109] Next, an example is used to demonstrate the effect of the data scheduling algorithm of the present invention.
[0110] Assume there are 5 queues, Q4, Q3, Q2, Q1, Q0, their weights are 16, 8, 4, 2, 1, and the number of credit packets is also 16, 8, 4, 2, 1;
[0111] The effect of using the WFQ scheduling algorithm is to output data packets in the following order:
[0112] Q4-Q3-Q2-Q1-Q0-Q4-Q4-Q3-Q4-Q4-Q3-Q2-Q4-Q4-Q3-Q4-Q4-Q3-Q2-Q1-Q4-Q4-Q3-Q4-Q4-Q3-Q2-Q4-Q4-Q3-Q4
[0113] The maximum continuous transmission length is 2;
[0114] The effect of using the DWRR scheduling algorithm is that data packets are output in the following order:
[0115] Q4-Q3-Q2-Q1-Q0-Q4-Q3-Q2-Q1-Q4-Q3-Q2-Q4-Q3-Q2-Q4-Q3-Q4-Q3-Q4-Q3-Q4-Q3-Q4-Q4-Q4-Q4-Q4-Q4-Q4-Q4
[0116] The maximum continuous transmission length is 8;
[0117] The effect of using the DWRR improved algorithm is that data packets are output in the following order:
[0118] Q4-Q3-Q2-Q1-Q0-Q4-Q3-Q4-Q3-Q4-Q2-Q4-Q1-Q4-Q3-Q4-Q2-Q4-Q3-Q4-Q3-Q4-Q2-Q4-Q3-Q4-Q3-Q4-Q4-Q4-Q4
[0119] The maximum continuous transmission length is 4;
[0120] If the number of queues is n, weight(Qn) = 2^n, then the maximum transmission length is as follows:
[0121]
[0122] It is not difficult to see that the algorithm in the present invention significantly improves the original DWRR scheduling effect, and when the number of queues is 8 or more, it is very close to WFQ. Even if the number of queues is larger, it has a better scheduling effect than DWRR, and the larger the number of queues, the more obvious the effect difference.
[0123] Summarize:
[0124] Overall
[0125] Scheduling effect of the algorithm: WFQ algorithm > the algorithm of the present invention > DWRR algorithm
[0126] Hardware overhead of the algorithm: WFQ algorithm > the algorithm of the present invention > DWRR algorithm
[0127] When the number of queues is large
[0128] Scheduling effect of the algorithm: WFQ algorithm ≈ the algorithm of the present invention > DWRR algorithm
[0129] Algorithm hardware overhead: WFQ algorithm>>algorithm of the present invention>DWRR algorithm
[0130] The present invention also provides a switch, which applies the above data scheduling method, such as Figure 5 As shown, including:
[0131] A cache module 1, caching a plurality of data queues to be forwarded, each data queue including a plurality of data packets, each data queue being associated with a corresponding queue weight and number of data packets;
[0132] The initial module 2 is connected to the cache module 1 and is used to add each data queue to the real-time queue to be forwarded according to the queue weight of each data queue;
[0133] The packet sending module 3 is connected to the initial module 2 and is used to send a data packet to the first data queue in the real-time forwarding queue and reduce the number of its associated data packets by one, and then for each data queue in the real-time forwarding queue, the corresponding scheduling value is calculated according to the number of associated data packets and the queue weight;
[0134] The scheduling module 4 is connected to the packet sending module 3 and is used to adjust the position of the first data queue in the real-time queue to be forwarded according to each scheduling value, and the queue to be forwarded after scheduling is fed back to the packet sending module as the real-time queue to be forwarded.
[0135] In a preferred embodiment of the present invention, the packet sending module 3 includes:
[0136] The packet sending unit 31 is used to send a data packet to the first data queue in the queue to be forwarded and reduce the number of data packets associated with it by one;
[0137] The scheduling value calculation unit 32 is connected to the packet sending unit 31 and is used for the switch to obtain a corresponding scheduling value for each data queue in the queue to be forwarded by dividing the number of data packets in the data queue by the queue weight.
[0138] In a preferred embodiment of the present invention, the scheduling module 4 includes:
[0139] An average calculation unit 41, used to calculate a scheduling average value according to all scheduling values and the total number of data queues;
[0140] The scheduling unit 42 is connected to the average calculation unit 41 and is used to move the first data queue to the back of the second data queue of the real-time forwarding queue when it is determined that the scheduling value of the first data queue is greater than the scheduling average value, and to move the first data queue to the end of the real-time forwarding queue when it is determined that the scheduling value of the first data queue is not greater than the scheduling average value;
[0141] The feedback unit 43 is connected to the scheduling unit 42 and is used to obtain the queue to be forwarded after scheduling as the real-time queue to be forwarded, and then feed it back to the packet sending module.
[0142] In a preferred embodiment of the present invention, the feedback unit 43 includes:
[0143] A clearing subunit 431 is used to obtain a queue to be forwarded after scheduling, and then remove a data queue with a number of data packets not greater than zero from the queue to be forwarded after scheduling;
[0144] The feedback subunit 432 is connected to the clearing subunit 431 and is used to use the scheduled queue to be forwarded as a real-time queue to be forwarded and then feed back to the packet sending module.
[0145] In a preferred embodiment of the present invention, the packet sending module 3 also includes:
[0146] The single queue sending unit 30 is used to send out the data packets in the only existing data queue in sequence when there is only one data queue in the real-time forwarding queue.
[0147] The above are only preferred embodiments of the present invention, and are not intended to limit the implementation methods and protection scope of the present invention. Those skilled in the art should be aware that all solutions obtained by equivalent substitutions and obvious changes made using the contents of this specification and illustrations should be included in the protection scope of the present invention.
Claims
1. A data scheduling method for a switch, characterized in that: A plurality of data queues to be forwarded are cached in the switch, each data queue includes a plurality of data packets, and each data queue is associated with a corresponding queue weight and number of data packets; the data scheduling method includes: Step S1, the switch adds each data queue to a real-time queue to be forwarded according to the queue weight of each data queue; Step S2, the switch sends a data packet from the first data queue of the real-time queue to be forwarded and reduces the number of data packets associated with it by one, and then the switch calculates a corresponding scheduling value for each data queue in the real-time queue to be forwarded according to the number of associated data packets and the queue weight; In step S3, the switch adjusts the position of the first data queue in the real-time queue to be forwarded according to each scheduling value, obtains the scheduled queue to be forwarded as the real-time queue to be forwarded, and then returns to step S2 to send packets until all the data packets in the data queues are sent out and then exits.
2. The data scheduling method according to claim 1, characterized in that: The step S2 includes: Step S21, the switch sends a data packet from the first data queue of the queue to be forwarded and reduces the number of data packets associated with the data packet by one; Step S22: For each of the data queues in the to-be-forwarded queues, the switch divides the number of data packets in the data queue by the queue weight to obtain the corresponding scheduling value.
3. The data scheduling method according to claim 1, characterized in that: The step S3 comprises: Step S31, the switch calculates a scheduling average value according to all the scheduling values and the total number of the data queues; Step S32, the switch determines whether the scheduling value of the first data queue is greater than the scheduling average value: If yes, moving the first data queue to behind the second data queue of the real-time queue to be forwarded; If not, moving the first data queue to the end of the real-time queue to be forwarded; In step S33, the switch obtains the scheduled queue to be forwarded as the real-time queue to be forwarded, and then returns to step S2 to send packets until all the data packets in the data queues are sent.
4. The data scheduling method according to claim 3, characterized in that: The step S33 comprises: Step S331, the switch obtains the queue to be forwarded after scheduling, and then removes the data queue whose number of data packets is not greater than zero from the queue to be forwarded after scheduling; In step S332, the switch uses the scheduled queue to be forwarded as the real-time queue to be forwarded, and then returns to step S2 to send packets until all the data packets in the data queues are sent out and then exits.
5. The data scheduling method according to claim 2, characterized in that: The step S2 further includes, before executing the step S21: Step S20, the switch determines whether there is only one data queue in the real-time queue to be forwarded: If yes, the data packets in the existing data queue are sent out in sequence, and then exit; If not, go to step S21.
6. A switch, characterized in that: Applying the data scheduling method as described in any one of claims 1 to 5, comprising: A cache module, caching multiple data queues to be forwarded, each data queue including multiple data packets, each data queue being associated with a corresponding queue weight and number of data packets; An initial module, connected to the cache module, configured to add each of the data queues to a real-time queue to be forwarded according to the queue weight of each of the data queues; a packet sending module, connected to the initial module, configured to send a data packet to the first data queue in the real-time queue to be forwarded and reduce the number of data packets associated with it by one, and then for each data queue in the real-time queue to be forwarded, calculate a corresponding scheduling value according to the number of associated data packets and the queue weight; The scheduling module is connected to the packet sending module and is used to adjust the position of the first data queue in the real-time queue to be forwarded according to each scheduling value, and obtain the scheduled queue to be forwarded as the real-time queue to be forwarded and feed it back to the packet sending module.
7. The switch according to claim 6, characterized in that: The packet sending module includes: A packet sending unit, used for sending a data packet to the first data queue in the queue to be forwarded and reducing the number of data packets associated with the first data queue by one; A scheduling value calculation unit is connected to the packet sending unit and is used for the switch to obtain the corresponding scheduling value by dividing the number of data packets in the data queue by the queue weight for each data queue in the queue to be forwarded.
8. The switch according to claim 6, characterized in that: The scheduling module includes: An average calculation unit, used for calculating a scheduling average value according to all the scheduling values and the total number of the data queues; a scheduling unit, connected to the average calculation unit, configured to move the first data queue to the back of the second data queue of the real-time queue to be forwarded when it is determined that the scheduling value of the first data queue is greater than the scheduling average value, and to move the first data queue to the end of the real-time queue to be forwarded when it is determined that the scheduling value of the first data queue is not greater than the scheduling average value; A feedback unit is connected to the scheduling unit and is used to obtain the scheduled queue to be forwarded as the real-time queue to be forwarded, and then feed back to the packet sending module.
9. The switch according to claim 8, characterized in that: The feedback unit comprises: a clearing subunit, configured to obtain the queue to be forwarded after scheduling, and then remove the data queue whose number of data packets is not greater than zero from the queue to be forwarded after scheduling; A feedback subunit is connected to the clearing subunit and is used to use the scheduled queue to be forwarded as the real-time queue to be forwarded, and then feed back to the packet sending module.
10. The switch according to claim 7, characterized in that: The packet sending module also includes: The single queue sending unit is used to send out the data packets in the only existing data queue in sequence when there is only one data queue in the real-time queue to be forwarded.