(19)
(11) EP 3 089 413 A1

(12) EUROPEAN PATENT APPLICATION
published in accordance with Art. 153(4) EPC

(43) Date of publication:
02.11.2016 Bulletin 2016/44

(21) Application number: 14873941.0

(22) Date of filing: 20.05.2014
(51) International Patent Classification (IPC): 
H04L 12/815(2013.01)
(86) International application number:
PCT/CN2014/077926
(87) International publication number:
WO 2015/096362 (02.07.2015 Gazette 2015/26)
(84) Designated Contracting States:
AL AT BE BG CH CY CZ DE DK EE ES FI FR GB GR HR HU IE IS IT LI LT LU LV MC MK MT NL NO PL PT RO RS SE SI SK SM TR
Designated Extension States:
BA ME

(30) Priority: 25.12.2013 CN 201310731611

(71) Applicant: Zhongxing Microelectronics Technology Co., Ltd.
Nanshan District Shenzhen (CN)

(72) Inventors:
  • CAI, Xuequan
    Shenzhen Guangdong 518085 (CN)
  • ZENG, Min
    Nanshan District Shenzhen (CN)
  • XIA, Gang
    Nanshan District Shenzhen (CN)
  • YUAN, Kaixin
    Nanshan District Shenzhen (CN)

(74) Representative: Potter Clarkson LLP 
The Belgrave Centre Talbot Street
Nottingham NG1 5GG
Nottingham NG1 5GG (GB)

   


(54) METHOD AND APPARATUS FOR ADDING TOKEN IN TRAFFIC SHAPING


(57) Disclosed are a method and an apparatus for adding a token in traffic shaping, wherein the method comprises: configuring a weight of each data flow, and adding the each data flow to corresponding token schedulers based on the weight of the each data flow; based on a weight of each token scheduler, sequentially adding the each token scheduler to corresponding token scheduler groups, and aggregating all the token scheduler groups into a token scheduler of a total data flow; adding the token scheduler of the total data flow to a top token scheduler; and based on a preset cycle, assigning a token to the token scheduler of the total data flow in the top token scheduler, and delivering the assigned token to each token scheduler group or delivering the token to the each data flow.




Description

TECHNICAL FIELD



[0001] The present disclosure relates to the field of mobile communication, especially to a method and an apparatus for adding a token in traffic shaping.

BACKGROUND



[0002] With development of the network, the transmission mode of shared medium becomes the mainstream of the network. The service level of one connection may be defined from three aspects, i.e., an effectiveness of connection, a time delay of connection, and a bandwidth of connection. The three aspects decide the quality of service. The traffic management system plays an important role in the aspect of controlling the time delay and the bandwidth of the connection, thereby affecting the quality of service (QoS) of the connection. One important method for ensuring the quality of service is performing traffic management by the traffic management system. The functions of the traffic management system mainly include: classification, traffic supervision, traffic shaping, scheduling, and statistics. The traffic shaping means forwarding data packets at a preset rate so as to follow an engagement with downstream devices, smooth an output of traffic, and reduce congestion at downstream. During the traffic shaping, adding tokens for a mass of different data streams is a key factor for affecting the effect of the traffic shaping.

[0003] At present, a WFQ (Weighted Fair Queuing) method is generally utilized for traffic shaping. This method is particularly performed by: setting one weight corresponding to one maximum rate, converting a shaping rate configured for each data stream into a corresponding weight, and distributing the remained weight to one idle flow so as to occupy the remained bandwidth. However, when using the above WFQ method to add tokens for a mass of data flows having the same relatively small rate, there is a situation in which the tokens are intensively added into the idle flow and no data flow acquires the token during a period of time. In addition, the WFQ method can only allocate the bandwidth proportionally. When a sum of rates for shaping the data flow is greater than the set maximum weight, there is no idle flow. In this case, the data flow can only acquire the tokens according to the weight proportion, and thus the number of tokens which may be acquired by each data flow cannot reach the number deserved by the configured weight.

SUMMARY



[0004] Given the above situation, the embodiments of the present disclosure provide a method and an apparatus for adding a token in traffic shaping, which can improve a utilization rate of bandwidth of a system via issuing tokens evenly.

[0005] The embodiments of the present disclosure provide a method for adding a token in traffic shaping, including:

configuring a weight of each data flow, and adding respective data flow into a corresponding token scheduler according to the weight of each data flow;

adding respective token scheduler into a corresponding token scheduler group sequentially according to a weight of each token scheduler, and aggregating all the token scheduler groups into a total data flow token scheduler;

adding the total data flow token scheduler into a top token scheduler; and

assigning a token to the total data flow token scheduler in the top token scheduler according to a preset period, and issuing the assigned token by the top token scheduler to respective token scheduler groups, or to respective data flow.

The embodiments of the present disclosure also provide an apparatus for adding a token in traffic shaping, including: a configuration module, a bandwidth allocation module, a distribution module, and an information storage module, wherein

the configuration module is configured to: configure a weight of each data flow, and add respective data flow into a corresponding token scheduler according to the weight of each data flow; add respective token scheduler into a corresponding token scheduler group sequentially according to a weight of each token scheduler, and aggregate all the token scheduler groups into a total data flow token scheduler; add the total data flow token scheduler into a top token scheduler; and save the weights of respective data flow into the information storage module;

the bandwidth allocation module is configured to assign a token to the total data flow token scheduler in the top token scheduler according to a preset period, and send the assigned token to the distribution module;

the distribution module is configured to issue the token to respective token scheduler groups, or issue the token to respective data flow; and

the information storage module is configured to save the weights of respective data flow.



[0006] Through the method and apparatus for adding a token in traffic shaping provided by the embodiments of the present disclosure, corresponding shaping rates and shaping weights can be configured for different data flows, and the different data flows are aggregated into a total data flow; during the token distribution, the distribution is firstly carried out in the top token scheduler for fairly scheduling, and thus the tokens are issued evenly. Thereby, through evenly issuing the tokens, the system can shape multiple data flows, so as to improve the utilization rate of the bandwidth.

BRIEF DESCRIPTION OF THE DRAWINGS



[0007] 

Fig. 1 is a first flowchart of a method for adding a token in traffic shaping according to an embodiment of the present disclosure;

Fig. 2 illustrates an example of a procedure of distributing a token according to an embodiment of the present disclosure;

Fig. 3 is a second flowchart of a method for adding a token in traffic shaping according to an embodiment of the present disclosure;

Fig. 4 is a schematic diagram of structural composition of the apparatus for adding a token in traffic shaping according to an embodiment of the present disclosure;

Fig. 5-1 illustrates storage content and format of information of the idle flow according to an embodiment of the present disclosure;

Fig. 5-2 illustrates storage content and format of information of the total data flow according to an embodiment of the present disclosure;

Fig. 6-1 illustrates storage content and format of scheduler information in an information storage module according to an embodiment of the present disclosure;

Fig. 6-2 illustrates storage content and format of information of the data flow in the information storage module according to an embodiment of the present disclosure;

Fig. 7 is a flowchart of distributing bandwidths by a bandwidth allocating module in the present disclosure; and

Fig. 8 is a flowchart of distributing tokens by a token distributing module in the present disclosure.


DETAILED DESCRIPTION



[0008] Hereinafter, further detailed explanations to the present disclosure would be given in combination with the drawings and specific embodiments.

First Embodiment



[0009] Embodiments of the present disclosure provide a method for adding a token in traffic shaping. As shown in Fig. 1, the method includes the following steps.

In step 101, a weight of each data flow is configured, and each data flow is added into a corresponding token scheduler according to the weight of each data flow.

In step 102, each token scheduler is added into a corresponding token scheduler group in turn according to a weight of each token scheduler, and all the token scheduler groups are aggregated into a total data flow token scheduler.

In step 103, the total data flow token scheduler is added into a top token scheduler.

In step 104, a token is assigned to the total data flow token scheduler in the top token scheduler according to a preset period, and the top token scheduler issues the assigned token to respective token scheduler groups, or issues the token to respective data flow.

The step of configuring the weight of each data flow includes: configuring a shaping rate of each data flow, and converting the shaping rate into the weight corresponding to respective data flow. The converting method belongs to the related art, and is not elaborated herein.



[0010] Preferably, before performing step 101, the method further includes: configuring the shaping rate of current idle flow to be a maximum rate, and converting the shaping rate of the idle flow into the weight.

[0011] Before performing step 101, the method further includes: presetting the number of layers of the token scheduler group. For example, the token scheduler group may include two layers, i.e., the data flow is directly added into the total data flow token scheduler; or the token scheduler group may be set to have three layers, i.e., a middle layer group is added, and the data flow within a certain weight range is added into this middle layer group.

[0012] Before adding respective token schedulers into corresponding token scheduler group according to the weights of respective token schedulers, the weights of respective token schedulers may be calculated. The calculation may include calculating a sum of weights of all the data flows hooked by respective token schedulers, or a sum of weights of all the token schedulers hooked by respective token schedulers.

[0013] Preferably, when aggregating all the token scheduler groups into the total data flow token scheduler, the method further includes: calculating a weight of the total data flow and a weight of the idle flow, wherein the calculating the weight of the total data flow is calculating a sum of the weights of all the hooked token scheduler groups or data flow.

[0014] Preferably, before issuing the token to respective token scheduler groups or issuing the token to respective data flow by the top token scheduler according to the preset period, the method further includes: adjusting the weight of the total data flow. In particular, the adjusting the weight of the total data flow is performed by: determining whether the weight of the total data flow is greater than or equal to a preset system maximum weight; if yes, increasing the number of the tokens issued within each period by a designated value to obtain the adjusted number of tokens issued within each period, and calculating a weight adjusting coefficient of the total data flow according to the number of the tokens issued within each period, and then multiplying the weight adjusting coefficient by the weight of the original total data flow so as to obtain the adjusted weight of the total data flow.

[0015] The step of increasing the number of the tokens issued within each period by the designated value to obtain the adjusted number of the tokens issued within the each period includes: adding the number of the tokens issued within each period by 1, so as to obtain the adjusted number N+1 of the tokens within each period.

[0016] The step of calculating the weight adjusting coefficient of the total data flow according to the number of the tokens issued within each period includes: using a ratio between the number N of the tokens issued within each period and the adjusted number N+1 of the tokens issued within each period as the weight adjusting coefficient.

[0017] The length of the period may be preset.

[0018] The step of adding the total data flow token scheduler into the top token scheduler includes: adding the total data flow token scheduler and an idle flow token scheduler into the top token scheduler according to the weight of the total data flow and the weight of the idle flow.

[0019] In particular, the scheduler has N scheduling queues and one cyclical clock according to precision. The data flow which is added into the scheduler for the first time (moment 0) may be added into a corresponding queue according to the weight of this data flow. Each moment at which the scheduler serves corresponds to one scheduling queue. After the service to all the flows (when there are many layers, the scheduler group may be deemed as a flow from an upper layer of view) in the scheduling queue at the current service moment are completed, the scheduler may calculate a next service moment according to the current service moment and the scheduling queue in which the flow exists in the system, and after jumping to the next service moment, the scheduling queue corresponding to the next moment starts to be served. Every time the flow in the scheduling queue is served, the flow in the scheduling queue may calculate a next timing at which the flow would be served according to the weight itself and the current service moment, and the flow is hooked to a corresponding scheduling queue.

[0020] The step of issuing the tokens to respective data flow may be as follows: the number of the tokens obtained by respective data flow is determined by the weight of the data flow. The system serves the corresponding scheduling queue according to the scheduling moment, and respective data flow is added into the corresponding scheduling queue according to the weights thereof. The probability of serving the data flow having a high weight is high. According to the WFQ scheduling algorithm, during one round of scheduling, the proportion of obtaining the tokens by respective data flow is equal to their weight proportion. The WFQ scheduling algorithm belongs to the prior art, and is not elaborated herein.

[0021] The step of issuing the tokens to respective token scheduling group, or issuing the tokens to respective data flow by the top token scheduler according to the preset period includes: the top token scheduler determines whether the token is issued to the idle flow or to the total data flow in the current period according to a service period pointer; and if the token is issued to the idle flow, the top token scheduler calculates a next service period pointer of the idle flow according to the weight of the idle flow;
and if the token is issued to the total data flow, the top token scheduler calculates a next service period pointer corresponding to the total data flow according to the weight of the total data flow, sends the token to a lower scheduler of the total data flow, uses the lower scheduler as the current layer scheduler, and determines whether the current layer scheduler is hooked to the data flow; if yes, then adds corresponding number of tokens into a token bucket of the data flow, and calculates a next service period pointer according to the weight of the data flow, and thereby the present distribution of the tokens is completed; otherwise, calculates the next service period pointer according to the current layer token scheduler.

[0022] Preferably, after the top token scheduler issues the tokens to respective token scheduler group, or issues the tokens to respective data flow according to the preset period, the method further includes: after any of data flow obtains the tokens, the number of shaping bytes corresponding to the data flow is determined according to the number of shaping bytes corresponding to the tokens. In particular, the traffic shaping system cooperates with an external system, and may calculate a total bandwidth of the system according to a clock period and the number of bytes of each issuing. Thus, at the beginning of the design, the system determines the total bandwidth and the clock period of each issuing, thereby the corresponding relationship between the number of tokens and the number of shaping bytes of each issuing is decided.

[0023] Before assigning the tokens to the total data flow token scheduler in the top token scheduler based on the preset period, the method further includes: generating a token based on the preset period.

[0024] Through the embodiments of the present disclosure, the manner of WFQ scheduling is hierarchical, thereby corresponding shaping rates and shaping weights are configured for different data flows and then the data flows are aggregated into a total data flow; when distributing the tokens, the bandwidth of the top layer is extended according to requirements first, so as to fairly schedule the summation of the data flow and the idle flow, in this way, the tokens are issued evenly; also, it is selectable to average again the tokens of data flow of respective group bandwidth in the middle layer WFQ, so as to achieve the shaping to the multiple data flows, and obtain a good effect.

[0025] When adopting the embodiments of the present disclosure, the procedure of distributing the tokens may be as shown in Fig. 2.

At 1T moment, the tokens are distributed to the data flow IDLE.

At 2T moment, the tokens are distributed to the data flow IDLE.

At 3T moment, the tokens are distributed to the data flow A.

At 4T moment, the tokens are distributed to the idle flow IDLE.

At 5T moment, the tokens are distributed to the data flow IDLE.

At 6T moment, the tokens are distributed to the data flow B.

At 7T moment, the tokens are distributed to the data flow IDLE.

At 8T moment, the tokens are distributed to the data flow IDLE.

At 9T moment, the tokens are distributed to the data flow C.

At 10T moment, the tokens are distributed to the data flow IDLE.



[0026] Similarly, using 10T as one period, and according to the above-mentioned steps, the distribution of the tokens is repeated, in this way, the data flow A obtains one-tenth tokens, the shaping tokens obtained by the data flow A is 1Gbps, the shaping tokens obtained by the data flow B and the data flow C are also 1Gbps, and the idle flow consumes 7Gbps shaping tokens. When the present disclosure is not adopted, the moments of acquiring the tokens by the data flow and by the idle flow are relatively concentrated; and when adopting the present disclosure, the moments of acquiring the tokens by the data flow and by the idle flow are relatively even.

[0027] The period interval T of generating tokens may be adjusted according to the bandwidth and the clock frequency of the traffic management system. In the case of the same bandwidth and clock frequency of the traffic management system, and different intervals T, each of the shaping tokens may represent different numbers of bytes of tokens.

[0028] After extending the bandwidth of the top layer, the processing capability of the traffic management system may be broken through, and the token whose number is coincided with the configured bandwidth is distributed for respective data flow, thereby improving the bandwidth utilization of the system.

Second Embodiment



[0029] Fig. 3 is a flowchart of a method for distributing a shaping token to respective data flow according to the present disclosure. The main implementing procedure is as follows.

In step 300, WFQ in each layer is initialized, and weights of respective WFQ and total data flow are set to be 0.

In step 301, a shaping rate of idle flow is configured to be maximum, and the shaping rate of the idle flow is converted into the weight, and then the idle flow is added into a top token scheduler.

In step 302, it is determined whether all the current data flow has been completely configured; if yes, step 307 is performed; otherwise, step 303 is performed.

In step 303, any data flow is selected from the data flow without configuration of the shaping rate as the current data flow, the shaping rate of the current data flow is configured, and the shaping rate of the current data flow is converted into the weight of the current data flow.

In step 304, the current data flow is added into a corresponding WFQ token scheduler group according to the weight of the current data flow; or the WFQ token scheduler is added into a corresponding token scheduler group according to the weight of the WFQ token scheduler.

In step 305, the weight of the WFQ token scheduler group and the weight of the current data flow are added to obtain an updated weight of the WFQ token scheduler group.

In step 306, it is determined whether the WFQ token scheduler group is the total data flow; if yes, the process proceeds to step 302; otherwise, step 304 is performed.

In step 307, it is determined whether the weight of the current total data flow is greater than or equal to a preset system maximum weight; if yes, step 308 is performed; otherwise, step 310 is performed.

In step 308, the number N of the tokens issued in every period is added by 1, so that the adjusted number of the tokens issued in every period is N+1.

In step 309, the weight of the total data flow is adjusted to N/N+1 times of the current weight, so as to obtain the adjusted weight of the total data flow, and then the process proceeds to step 307.

In step 310, the weight of the current total data flow is subtracted from the system maximum weight, so as to obtain the updated weight of the idle flow.

In step 311, the total data flow WFQ token scheduler is added into the top token scheduler.

In step 312, a bandwidth allocation module is enabled, so as to distribute the tokens to the total data flow or the idle flow in the top token scheduler.

In step 313, the process waits until a moment for issuing tokens is arrived, then the top token scheduler determines whether the tokens received at the current moment are the tokens of idle flow or the tokens of total data flow; if the received tokens are the tokens of idle flow, then step 314 would be performed; and if the received tokens are the tokens of total data flow, then step 315 would be performed.
Herein, the tokens are obtained by the top token scheduler based on the WFQ scheduling algorithm. For example, the scheduler may select a first flow in the scheduling queue to be served according to the current scheduling moment. There are only two flows, i.e., the total data flow and the idle flow, in the top scheduling. It is possible that one queue is served each time in the same scheduling queue at a certain moment, and then the queue which has been served may be transferred to be added into other scheduling queue.

In step 314, a next service moment is calculated according to the weight of the idle flow, and the idle flow is transferred to the corresponding scheduling queue, then the process goes to step 313.
The calculation may be based on the WFQ scheduling algorithm. For example, after a certain data flow has been served, the next service moment of the data flow may be calculated according to the current moment corresponding to the scheduler where the data flow is located and the weight of the data flow, and then the flow is added into the scheduling queue corresponding to this moment.

In step 315, a next service moment is calculated according to the weight of the total data flow.

In step 316, the tokens are issued to the data flow or the scheduler in the lower layer.
For example, when the lower layer is the data flow, the token value of the current system is directly added for the data flow.
When the lower layer is the scheduler, it is required for the scheduler to issue the tokens according to the WFQ scheduling algorithm, and finally add the tokens into the data flow being served in the lowest layer. During each period of scheduling the data flow from the top layer to the lowest layer, only one data flow would obtain the tokens at last.

In step 317, it is determined whether the current layer (the lower layer in step 316) is a scheduler, if yes, the token is started to be issued to the scheduler in the current layer.

In step 318, it is determined whether the token scheduler of the current layer is hooked to the data flow; if yes, step 320 would be performed; otherwise, step 319 would be performed.

In step 319, a next service moment is calculated according to the weight of the token scheduler, and the process goes to step 316.

In step 320, a corresponding number of tokens are added into a token bucket of the data flow.

In step 321, a next service moment of the data flow is calculated according to the weight of the data flow, and the current token issuing is completed.


Third Embodiment



[0030] Corresponding to the method described in the Second Embodiment, the embodiments of the present disclosure further propose an apparatus for implementing traffic shaping. As shown in Fig. 4, the apparatus includes: a configuration module 401, a bandwidth allocation module 402, a distribution module 403, and an information storage module 404.

[0031] The configuration module 401 is configured to: configure a weight of each data flow, and add each data flow into a corresponding token scheduler according to the weight of each data flow; add each token scheduler into a corresponding token scheduler group in turn according to a weight of each token scheduler, and aggregate all the token scheduler groups into a total data flow token scheduler; add the total data flow token scheduler into a top token scheduler; and save the weights of respective data flow into the information storage module 404.

[0032] The bandwidth allocation module 402 is configured to assign a token to the total data flow token scheduler in the top token scheduler according to a preset period, and send the assigned token to the distribution module 403.

[0033] The distribution module 403 is configured to issue the token to respective token scheduler groups, or issue the token to respective data flow.

[0034] The information storage module 404 is configured to save the weights of respective data flow.

[0035] The configuration module 401 is configured to configure a shaping rate of each data flow, and convert the shaping rate into the weight corresponding to each data flow.

[0036] The apparatus further includes: an idle flow module 405 configured to configure a shaping rate of the current idle flow to be a maximum rate, and convert the shaping rate of the idle flow into a weight.

[0037] The configuration module 401 is configured to determine whether the weight of the total data flow is greater than or equal to a preset system maximum weight; if yes, the number of the tokens issued within each period is increased by a designated value to obtain the adjusted number of tokens issued within each period, and a weight adjusting coefficient of the total data flow is calculated according to the number of the tokens issued within each period, and then the weight adjusting coefficient is multiplied by the weight of the original total data flow so as to obtain the adjusted weight of the total data flow; otherwise, no adjustment is made.

[0038] The configuration module is configured to add the number N of the tokens issued in each period by 1, so as to obtain the adjusted number N+1 of the tokens within each period; and use a ratio between the number N of the tokens issued within each period and the adjusted number N+1 of the tokens issued within each period as the weight adjusting coefficient; wherein N is the number of tokens issued by the system each time.

[0039] The bandwidth allocation module 402 is configured to determine whether the token is issued to the idle flow or to the total data flow in the current period according to a service period pointer; and if the token is issued to the idle flow, calculate a next service period pointer of the idle flow according to the weight of the idle flow; and if the token is issued to the total data flow, calculate a next service period pointer corresponding to the total data flow according to the weight of the total data flow, and send the token to the distribution module 403. Accordingly, the distribution module 403 is configured to use a lower scheduler of the total data flow as the current layer scheduler, determine whether the current layer scheduler is hooked to the data flow; if yes, then add corresponding tokens into a token bucket of the data flow, and calculate a next service period pointer according to the weight of the data flow, and thus the present distribution of the tokens is completed; otherwise, the next service period pointer is calculated according to the current layer token scheduler.

[0040] The apparatus further includes: a token generating module 406 configured to generate a token based on the preset period, and send the token to the bandwidth allocation module 402. Correspondingly, the bandwidth allocation module 402 is configured to receive the token sent from the token generating module 406.

[0041] The configuration module 401 is configured to configure a shaping rate for each data flow and convert the shaping rate into a shaping weight, store the shaping weight into the information storage module 404, and add respective data flow into the token distribution module 403 according to the shaping weight of the data flow.

[0042] The idle flow module 405 is configured to, when receiving the shaping weight of the data flow configured by the configuration module 401, add the weight of the current total data flow by the shaping weight of new data flow to obtain a new total data flow weight; and when the total data flow weight is greater than a maximum weight, perform a proportional adjustment to obtain a new total data flow weight, subtract the maximum weight of system by the shaping weight of the total data flow to obtain a new idle flow shaping weight, and add the new idle flow shaping weight into the bandwidth allocation module 402 according to the shaping weights of the idle flow and the total data flow.

[0043] The bandwidth allocation module 402 is configured to distribute the token for the idle flow or distribute the token for the token distribution module 403 according to the weight of the total data flow or the idle flow.

[0044] The token distribution module 403 is configured to pass the tokens on according to the set weight of the token scheduler or the data flow, and finally distribute the token for each data flow.

[0045] The information storage module 404 is configured to store the weights of the total data flow and the idle flow, the number N of the tokens issued every time, weight information and linked list information of each data flow and middle layer WFQ, and the number of the tokens received by respective data flow.

[0046] The apparatus further includes the token generating module 406, which is configured to periodically generate tokens in a preset interval according to a processing capability of a traffic management system, and transfer the tokens to the bandwidth allocation module 402.

[0047] The idle flow module 405 is configured to, after the system is powered on, configure the shaping weight of the total data flow to be 0, and configure the shaping weight of the idle flow to be a maximum value.

[0048] The configuration module 401 is configured to convert the shaping rate of the newly added data flow into a shaping weight, store the weights of respective data flow into the information storage module 404, calculate a service moment of the newly added data flow according to the weight of the newly added data flow, then add the newly added data flow into the distribution module 403, and at the same time, notify the shaping weight of the newly added data flow to the idle flow module 405.

[0049] The idle flow module 405 is configured to, after the system is powered on, configure the shaping weight of the total data flow to be the maximum value, and configure the shaping weight of the idle flow to be 0; when receiving the shaping weight of the data flow configured by the configuration module 401, add the shaping weight of the current total data flow into the shaping weight of the data flow to obtain a new shaping weight of total data flow, and when the maximum weight is exceeded, proportionally adjust the weight to obtain a new shaping weight of the total data flow, subtract the system maximum weight by the shaping weight of the current total data flow to obtain a new shaping weight of the idle flow, and at the same time, the idle flow module 405 is also stored with the number of tokens issued each time, next pointer information in the WFQ scheduling linked lists of the total data flow and the idle flow.

[0050] The token generating module 406 is configured to periodically generate tokens in a preset interval according to a processing capability of a traffic management system, and transfer the tokens to the bandwidth allocation module 402 to implement further distribution of the tokens.

[0051] The bandwidth allocation module 402 is configured to issue the tokens to the idle flow or issues the tokens to the distribution module 403 according to the weight of the total data flow or the idle flow, and the module manages the total data flow and the idle flow in a linked list manner.

[0052] The distribution module 403 is configured to transfer the tokens layer by layer so as to distribute the tokens to each data flow according to the configured token scheduler at each layer and the weight of each data flow, and the module manages the respective token schedulers and the data flow in a linked list manner.

[0053] The information storage module 404 is configured to store the weight information and the linked list information of respective token schedulers and data flow such that the distribution module 403 is able to serve respective schedulers or the data flow one by one according to the linked list and jump according to the weight. Meanwhile, the information storage module 404 is configured to store the number of the tokens received by respective data flow.

[0054] During distribution of the tokens, respective schedulers and data flow are connected with each other via the linked list.

[0055] The configuration module 401, the bandwidth allocation module 402, the distribution module 403, the idle flow module 405, and the token generating module 406 may be implemented via hardware, such as a DSP or a CPU. The information storage module 404 may be a memory, such as a ROM or a RAM.

[0056] Fig. 5-1 illustrates information storage content and format of idle flow in the idle flow module 405. The information of the idle flow includes a next flag (NextFlag). When the next flag is 1, it is indicated that the total data flow would receive the token immediately after the idle flow. When the next flag is 0, it is indicated that an idle flow is immediately after the idle flow. The information of the idle flow further includes an idle flow shaping weight (IDLE Weight). The idle flow shaping weight is used for the bandwidth allocation module 402 to calculate the moment at which the idle flow is served next time.

[0057] Fig. 5-2 illustrates information storage content and format of the total data flow in the idle flow module 405. The information of the total data flow includes a next flag (NextFlag). When the next flag is 1, it is indicated that the total data flow would receive the token immediately after the total data flow. When the next flag is 0, it is indicated that an idle flow is immediately after the total data flow. The information of the total data flow further includes a total data flow shaping weight (SUM Weight). The total data flow shaping weight is used for the bandwidth allocation module 402 to calculate the moment at which the total data flow is served next time. The information of the total data flow further includes the number of tokens (Token), and the number of the tokens is used as the number of tokens added into the data flow each time by the token distribution module 403.

[0058] Fig. 6-1 illustrates storage content and format of the token scheduler in a middle layer in the information storage module 404405. The information of the scheduler includes a next pointer (NextPtr), which parameter is used for storing a serial number of the scheduler for indicating a number of scheduler which would receive the token immediately after this scheduler flow in the token distribution module 403. The scheduler information further includes a scheduler weight (SCH Weight), which parameter is used for calculating the moment at which the scheduler is served next time in the token distribution module 403.

[0059] Fig. 6-2 illustrates storage content and format of information of the data flow in the information storage module 404405. The information of the data flow includes a next pointer (NextPtr), which parameter is used for storing a serial number of the data flow for indicating a number of data flow which would receive the token immediately after this data flow during the token distribution of the data flow. The data flow information further includes a data flow shaping weight (Flow Weight), which parameter is used for calculating the moment at which the data flow is served next time in the token distribution module 403. The data flow information further includes a data flow shaping token (Flow Token) for storing the number of the tokens received by this data flow.

Fourth Embodiment



[0060] Fig. 7 is a flowchart of distributing tokens by a bandwidth allocating module in the embodiments of the present disclosure. The flow includes the following steps.

In step 700, a token generating module is enabled to assign a token according to a preset interval.

In step 701, it is determined whether a top token scheduler receives the token; if yes, step 702 would be performed; otherwise, the process continues waiting.

In step 702, a current pointer of the top token scheduler is acquired.

In step 703, it is determined whether the current pointer points to an idle flow; if yes, step 704 would be performed; otherwise, step 707 would be performed.

In step 704, a weight of the idle flow is taken.

In step 705, a next service moment of the idle flow is calculated according to the weight of the idle flow.

In step 706, the idle flow is connected, according to the next service moment of the idle flow, to a scheduling queue corresponding to the next service moment, and step 711 is performed.

In step 707, the token is sent to a token distribution module 403.

In step 708, a weight of the total data flow is acquired.

In step 709, a next service moment of the total data flow is calculated according to the weight of the total data flow.

In step 710, the total data flow is connected to a corresponding position according to the next service moment of the total data flow, and step 711 is performed.

In step 711, the current pointer of the top token scheduler is updated, and the process goes to step 701.


Fifth Embodiment



[0061] Fig. 8 is a flowchart of distributing tokens by a token distributing module in the embodiments of the present disclosure. The flow includes the following steps.

In step 800, a current pointer of the current layer WFQ is acquired.

In step 801, it is determined whether the current pointer points to a data flow; if yes, step 802 would be performed; otherwise, step 807 would be performed.
The data flow mentioned herein is a concept corresponding to the scheduler. In the case of data flow, the data flow directly obtains the token; and in the case of scheduler, the token needs to be distributed further, until the underlying data flow acquires the token.
The process described herein is equal to a procedure of one recursive operation, thereby the middle layer WFQ scheduler groups should be not too much, otherwise, the efficiency of system shall be affected. In a simplest implementation, there may be no middle layer WFQ, i.e., the data flow is immediately after the total data flow.

In step 802, a token is assigned to the data flow pointed by the current pointer.

In step 803, a weight of the current corresponding data flow is taken.

In step 804, a next service moment of the data flow is calculated according to the weight of the data flow.

In step 805, the data flow is connected to a next pointer of certain data flow according to the next service moment of the data flow.
The next pointer of certain data flow is a next pointer of a last data flow in the scheduling queue corresponding to the next service moment of the data flow. For example, in Fig. 6-2, data stored in each data flow contains one next pointer, after the scheduling queue serves one data flow, the current pointer of the scheduling queue may point to a next pointer of the data flow, then a next service moment of the data flow is calculated according to the current scheduling moment and the weight of the data flow, and the data flow transfers to the corresponding scheduling queue.

In step 806, the current pointer of the current layer WFQ is updated.

In step 807, a weight of the scheduler in the current group is acquired.

In step 808, a next service moment of the scheduler is calculated according to the weight of the scheduler in the current group.
The calculating method is consistent with the above-mentioned method for calculating the data flow. The next service moment of the scheduler is calculated according to the weight of the scheduler and a current service moment of an upper layer scheduler where the scheduler locates, and the scheduler is transferred to a corresponding scheduling queue, and is linked to a next pointer of a last scheduler in the scheduling queue.

In step 809, the scheduler is linked to the next pointer of a certain scheduler according to the next service moment of the scheduler.

In step 810, the current pointer of the present layer WFQ is updated.

In step 811, the token is continued to be distributed to a lower layer WFQ, and the process goes to step 800.



[0062] The above-mentioned contents are only the preferred embodiments of the present disclosure, and do not intend to limit the protection scope of the present disclosure.


Claims

1. A method for adding a token in traffic shaping, comprising:

configuring a weight of each data flow, and adding respective data flow into a corresponding token scheduler according to the weight of each data flow;

adding respective token scheduler into a corresponding token scheduler group sequentially according to a weight of each token scheduler, and aggregating all the token scheduler groups into a total data flow token scheduler;

adding the total data flow token scheduler into a top token scheduler; and

assigning tokens to the total data flow token scheduler in the top token scheduler according to a preset period, and issuing the assigned tokens by the top token scheduler to respective token scheduler groups, or to respective data flow.


 
2. The method of claim 1, wherein the configuring the weight of each data flow comprises:

configuring a shaping rate of each data flow, and converting the shaping rate into the weight corresponding to respective data flow.


 
3. The method of claim 1, wherein before the configuring the weight of each data flow, the method comprises:

configuring the shaping rate of current idle flow to be a maximum rate, and converting the shaping rate of the idle flow into the weight.


 
4. The method of any one of claims 1-3, wherein before assigning the tokens to the total data flow token scheduler in the top token scheduler according to the preset period, and issuing the assigned tokens by the top token scheduler to respective token scheduler groups, or to respective data flow, the method further comprise:

determining whether the weight of the total data flow is greater than or equal to a preset system maximum weight; if yes, increasing a number of the tokens issued within each period by a designated value to obtain an adjusted number of tokens issued within each period, calculating a weight adjusting coefficient of the total data flow according to the number of the tokens issued within each period, and multiplying the weight adjusting coefficient by an original weight of the total data flow so as to obtain an adjusted weight of the total data flow.


 
5. The method of claim 4, wherein the increasing the number of the tokens issued within each period by the designated value to obtain the adjusted number of tokens issued within each period comprises:

adding the number of the tokens issued within each period by 1, so as to obtain the adjusted number of the tokens within each period; and

correspondingly, calculating the weight adjusting coefficient of the total data flow according to the number of the tokens issued within each period comprises:

using a ratio between the number of the tokens issued within each period and the adjusted number of the tokens issued within each period as the weight adjusting coefficient.


 
6. The method of claim 4, wherein the assigning the tokens to the total data flow token scheduler in the top token scheduler according to the preset period, and issuing the assigned tokens by the top token scheduler to respective token scheduler groups, or to respective data flow comprises:

determining whether the tokens are issued to the idle flow or to the total data flow in a current period according to a service period pointer of the top token scheduler; if the tokens are issued to the idle flow, calculating a next service period pointer of the idle flow according to the weight of the idle flow;

and if the tokens are issued to the total data flow, calculating a next service period pointer corresponding to the total data flow according to the weight of the total data flow, sending the tokens to a lower scheduler of the total data flow, using the lower scheduler as the current layer scheduler, and determining whether the current layer scheduler is hooked to the data flow; if yes, then adding a corresponding number of tokens into a token bucket of the data flow, and calculating a next service period pointer of the data flow according to the weight of the data flow, and terminating the present distribution of the tokens; otherwise, calculating the next service period pointer of the current layer token scheduler according to the current layer token scheduler.


 
7. The method of claim 1, wherein before assigning the tokens to the total data flow token scheduler in the top token scheduler according to the preset period, the method further comprises: generating a token.
 
8. An apparatus for adding a token in traffic shaping, comprising: a configuration module, a bandwidth allocation module, a distribution module, and an information storage module, wherein
the configuration module is configured to: configure a weight of each data flow, and add respective data flow into a corresponding token scheduler according to the weight of each data flow; add respective token scheduler into a corresponding token scheduler group sequentially according to a weight of each token scheduler, and aggregate all the token scheduler groups into a total data flow token scheduler; add the total data flow token scheduler into a top token scheduler; and save the weights of respective data flows into the information storage module;
the bandwidth allocation module is configured to assign tokens to the total data flow token scheduler in the top token scheduler according to a preset period, and send the assigned tokens to the distribution module;
the distribution module is configured to issue the tokens to respective token scheduler groups, or issue the tokens to respective data flow; and
the information storage module is configured to save the weights of respective data flow.
 
9. The apparatus of claim 8, wherein
the configuration module is configured to configure a shaping rate of each data flow, and convert the shaping rate into the weight corresponding to respective data flow.
 
10. The apparatus of claim 8, further comprising: an idle flow module configured to configure a shaping rate of a current idle flow to be a maximum rate, and convert the shaping rate of the idle flow into the weight.
 
11. The apparatus of any one of claims 8-10, wherein
the configuration module is configured to determine whether the weight of the total data flow is greater than or equal to a preset system maximum weight; if yes, increase the number of the tokens issued within each period by a designated value to obtain the adjusted number of tokens issued within each period, calculate a weight adjusting coefficient of the total data flow according to the number of the tokens issued within each period, and multiply the weight adjusting coefficient by the weight of the original total data flow so as to obtain the adjusted weight of the total data flow.
 
12. The apparatus of claim 11, wherein
the configuration module is configured to add the number of the tokens issued in each period by 1, so as to obtain the adjusted number of the tokens within each period; and
use a ratio between the number of the tokens issued within each period and the adjusted number of the tokens issued within each period as the weight adjusting coefficient.
 
13. The apparatus of claim 11, wherein the bandwidth allocation module is configured to determine whether the token is issued to the idle flow or to the total data flow in the current period according to a service period pointer of the top token scheduler; if the token is issued to the idle flow, calculate a next service period pointer of the idle flow according to the weight of the idle flow; and if the token is issued to the total data flow, calculate a next service period pointer corresponding to the total data flow according to the weight of the total data flow, and send the tokens to the distribution module; and
correspondingly, the distribution module is configured to use a lower scheduler of the total data flow as a current layer scheduler, determine whether the current layer scheduler is hooked to the data flow; if yes, then add a corresponding token into a token bucket of the data flow, and calculate a next service period pointer of the data flow according to the weight of the data flow, and terminate the present distribution of the tokens; otherwise, calculate the next service period pointer of the current layer token scheduler according to the weight of the current layer token scheduler.
 
14. The apparatus of claim 8, further comprising: a token generating module configured to generate a token, and send the token to the bandwidth allocation module; and
correspondingly, the bandwidth allocation module is configured to receive the token sent from the token generating module.
 




Drawing






















Search report