CN104917692B - A kind of method and apparatus for distributing token - Google Patents
A kind of method and apparatus for distributing token Download PDFInfo
- Publication number
- CN104917692B CN104917692B CN201510372385.9A CN201510372385A CN104917692B CN 104917692 B CN104917692 B CN 104917692B CN 201510372385 A CN201510372385 A CN 201510372385A CN 104917692 B CN104917692 B CN 104917692B
- Authority
- CN
- China
- Prior art keywords
- queue
- cir
- token
- sections
- priority
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L47/00—Traffic control in data switching networks
- H04L47/10—Flow control; Congestion control
- H04L47/215—Flow control; Congestion control using token-bucket
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
The present invention proposes a kind of method and apparatus for distributing token.Method includes:Permission forwarding rate (CIR) based on each queue and the last time token distribution time of each queue, this for determining each queue should distribute token number;This based on each queue should distribute token number, determine the highest-priority queue in whole queue;Token number should be distributed based on this of the highest-priority queue in whole queues, distribute token for the highest-priority queue in whole queues.
Description
Technical field
The invention belongs to flow control technique field, particularly a kind of method and apparatus for distributing token.
Background technology
Traffic shaping (Traffic Shaping, TS) is a kind of technology of active control flow output speed.On network
It is various using species, well operated to ensure that master is to be applied, it is necessary to flow control be carried out on network, as universal flow is whole
Shape (Generic Traffic Shaping, GTS).
At present, generally use token bucket algorithm realizes GTS.In token bucket algorithm, according to the permission forwarding rate of message
(Committed Information Rate, CIR) adds token in token bucket, i.e., every the 1/CIR times in token bucket
Add a token.When token bucket is filled it up with, newly generated token will be dropped.When there is enough tokens in token bucket
When, message can be sent;When the token in token bucket is insufficient, message cannot be sent, and only wait until to generate in token bucket
During new token, message can just be sent.Ensure that message output speed is less than or equal to token generation speed by token bucket algorithm
Degree, so as to achieve the purpose that to limit flow.
In the GTS of the prior art, when there is multiple message queues to need to distribute token, based on identical time interval week
Distribute token for each queue poll to phase property.However, there may be CIR differences between multiple queues, for the team that CIR is larger
Row, need the token number distributed more, may cause distribution token operational burst when being polled to, for the less queues of CIR,
It may need not distribute token when being polled at all, so that cause distribution token operation idle, the poll machine of this without differences
System may cause the queue with greater need for distribution token to obtain priority treatment, therefore there are token to distribute inefficient lack
Point.
The content of the invention
The present invention proposes a kind of method and apparatus of distribution token, so as to improve token distribution efficiency.
The technical solution of embodiment of the present invention is as follows:
The one side of embodiment according to the present invention, proposes a kind of method for distributing token, this method comprises the following steps:
CIR based on each queue and its last time token distribution time, this for determining each queue should distribute token number;
This based on each queue should distribute token number, determine the highest-priority queue in whole queue;
Token number should be distributed based on this of the highest-priority queue in whole queues, in whole queues
Highest-priority queue distribution token.
Preferably, this method further includes:
N number of CIR sections are set, the CIR based on each queue determines the CIR sections residing for each queue, wherein N for 2 with
On positive integer;
This based on each queue should distribute token number, determine the highest-priority queue bag in whole queues
Include:
Between the queue in same CIR sections is belonged to, token number should be distributed based on this and be ranked up, and determined each
Highest-priority queue in CIR sections;
Between highest-priority queue in each CIR sections, token number should be distributed based on this and be ranked up, and really
Highest-priority queue in fixed whole queues.
Preferably, this method further includes:
N number of CIR sections are set, and wherein N is more than 2 positive integer, wherein each CIR sections have CIR setting values;
The CIR based on each queue and the last time token of each queue distribution time, determine each queue this
Token number, which should be distributed, to be included:
CIR based on each queue determines the CIR sections residing for each queue, and based on the CIR in identified CIR sections
Setting value and the last time token of each queue distribution time, this for determining each queue should distribute token number;
This based on each queue should distribute token number, determine the highest-priority queue bag in whole queues
Include:
Between the queue in same CIR sections is belonged to, token number should be distributed based on this and be ranked up, and determined each
Highest-priority queue in CIR sections;
Between highest-priority queue in each CIR sections, token number should be distributed based on this and be ranked up, and really
Highest-priority queue in fixed whole queues.
Preferably, the CIR setting values are the maximum or average value in the CIR sections.
Preferably, the last time token distribution time is Tlast, current time Tcurrent;Described this should distribute token
Number is Add;It is described to determine that this distribute token number and be:Add=(Tcurrent-Tlast)×CIR。
Preferably, this method also includes in advance:
Determine the currently available token number of each queue, and currently available token number is arranged to not for the queue of nonnegative number
Distribute token;And/or
The CIR queues for being zero are arranged to regardless of board of issuing an order.
The another aspect of embodiment according to the present invention, proposes a kind of device for distributing token, which includes:
Token number computing module, for the CIR based on each queue and the last time token of each queue distribution time, determines
This of each queue should distribute token number;
Priority Determination module, should distribute token number for this based on each queue, determine in whole queues most
High-priority queue;
Token distribution module, for token should to be distributed based on this of the highest-priority queue in whole queues
Number, distributes token for the highest-priority queue in whole queues.
Preferably, Priority Determination module, for setting N number of CIR sections, the CIR based on each queue determines each team
The residing CIR sections of row, wherein N are more than 2 positive integer;, should based on this between the queue in same CIR sections is belonged to
Distribution token number is ranked up, and determines the highest-priority queue in each CIR sections;Highest in each CIR sections
Between priority query, token number should be distributed based on this and be ranked up, and determine the limit priority in whole queues
Queue.
Preferably, Priority Determination module, for setting N number of CIR sections, wherein N is more than 2 positive integer, wherein often
A CIR sections have CIR setting values;
Token number computing module, the CIR sections residing for each queue are determined for the CIR based on each queue, and are based on
The CIR setting values in identified CIR sections and the last time token of each queue distribution time, this for determining each queue should divide
Send out token number;
Priority Determination module, between the queue in same CIR sections is belonged to, token number should to be distributed based on this
It is ranked up, and determines the highest-priority queue in each CIR sections;The team of limit priority in each CIR sections
Between row, token number should be distributed based on this and be ranked up, and determine the highest-priority queue in whole queues.
Preferably, the CIR setting values are the maximum or average value in the CIR sections.
Preferably, the last time token distribution time is Tlast, current time Tcurrent;Described this should distribute token
Number is Add;It is described to determine that this distribute token number and be:Add=(Tcurrent-Tlast)×CIR。
Further include:
Setup module, is nonnegative number for determining the currently available token number of each queue, and by currently available token number
Queue be arranged to regardless of board of issuing an order;And/or it is arranged to for the queue for being zero by CIR regardless of board of issuing an order.
In the present invention, CIR based on each queue and its last time token distribution time, this for determining each queue should
Distribute token number;This based on each queue should distribute token number, determine the highest-priority queue in whole queue;It is based on
This of highest-priority queue in whole queues should distribute token number, for the highest-priority queue distribution in whole queues
Token.As it can be seen that the present invention is no longer the periodicity poll distribution token of without differences, but according to the last time token of each queue
Distribution time and CIR configuration attributes determine the queue of preecedence requirement distribution token, and actively select with greater need for distribution token
Queue carries out token distribution operation, so as to improve token distribution efficiency.
Moreover, in embodiment of the present invention, queue larger CIR is more likely to higher priority, therefore is more had an opportunity
Distribute token, so as to effectively avoid the token number in polling mechanism from happening suddenly;The less queues of CIR are more likely to have relatively low preferential
Level, so that it is idle effectively to avoid the distribution token in polling mechanism from operating.
In addition, in embodiments of the present invention, for the queue that current token number is non-negative and CIR is zero, without token
Dispensing action, so as to further improve the efficiency of distribution token.
Brief description of the drawings
Fig. 1 is the method flow diagram of present invention distribution token;
Fig. 2 is the method flow diagram of the distribution token of first embodiment of the invention;
Fig. 3 is the method flow diagram of the distribution token of second embodiment of the invention;
Fig. 4 is the structure drawing of device of present invention distribution token;
Fig. 5 is the structure drawing of device of the distribution token of third embodiment of the invention.
Embodiment
To make the object, technical solutions and advantages of the present invention clearer, the present invention is made below in conjunction with the accompanying drawings further
Detailed description.
In the prior art, when there is multiple (being more than one) queues to need to distribute token, since the CIR of each queue is poor
Different, periodic polling mechanism causes queue plus token action becomes uneven.Embodiment of the present invention is no longer without differences
Periodicity poll distribution token, but differentiation treats each queue, according to the last time token of each queue distribute the time and
CIR configuration attributes determine the queue of preecedence requirement distribution token, and actively select the queue of preecedence requirement distribution token to carry out
Token distribution operation.
Fig. 1 is the method flow diagram of present invention distribution token, and this method is suitable for the application environment with multiple queues.
As shown in Figure 1, this method includes:
Step 101:The last time token distribution time of CIR and each queue based on each queue, determine each queue
This should distribute token number.
Herein, at current point in time, be based respectively on each queue CIR and the queue last time token distribution when
Between, this for calculating each queue should distribute token number.
Such as, it is assumed that have a M queue, M be at least 2 positive integer, current time Tcurrent。
For m-th of queue, the last time token distribution time is Tlast_m, it is Add_m that this, which should distribute token number,;CIR is
The value range of CIR_m, m are [1, M];
So, this of m-th of queue should distribute token number and be:Add_m=(Tcurrent-Tlast_m)×CIR_m;
Based on above-mentioned algorithm, can calculate respective this of M queue should distribute token number.
Step 102:This based on each queue should distribute token number, determine the limit priority team in whole queue
Row.
Herein, can be by after respective this that all M queues are calculated in step 101 should distribute token number
Token number should be distributed it is ranked up according to each queue this, and the limit priority in whole queues is determined based on ranking results
There is maximum this should distribute token number for queue, highest-priority queue in whole queues.
Such as the order according to value from big to small, each queue this should be distributed by token number is ranked up, and will
The queue of ranking first is determined as the highest-priority queue in whole queues.Alternatively, the order according to value from small to large, right
This of each queue should distribute token number and be ranked up, and excellent by the highest that last queue is determined as in whole queues is ranked
First level queue.
Step 103:This based on the highest-priority queue in whole queues should distribute token number, in whole queues
Highest-priority queue distribution token.
After step 102 determines the highest-priority queue in whole queues, the whole that is calculated based on step 101
This of highest-priority queue in queue should distribute token number, for the highest-priority queue distribution order in whole queues
Board, and other queues are temporarily regardless of board of issuing an order.Then, when the last time token of the highest-priority queue in whole queues is distributed
Between be updated to current time, return to step 101 performs the token distribution procedure of next round, and circulates and perform this method flow.
In one embodiment, this method also includes in advance:
Determine the currently available token number of queue;Currently available token number is arranged to regardless of issuing an order for the queue of nonnegative number
Board.Because currently available token number is non-negative, i.e., workable token is still suffered from for the queue, without adding new token
It can complete the forwarding of message, then the queue is arranged to the queue regardless of board of issuing an order, and token distribution is not performed in epicycle
Operation.When start perform lower whorl distribution token when, if it find that because currently available token number be nonnegative number be arranged to regardless of
The currently available token number of queue of board of issuing an order is changed into negative, which is arranged to distribution token, and the flow with reference to shown in Fig. 1
Participate in performing the distribution of queue token.
In one embodiment, this method also includes in advance:The CIR queues for being zero are arranged to regardless of board of issuing an order.Cause
CIR is zero to be arranged to queue regardless of board of issuing an order, and token distribution operation is not performed in epicycle.Made when starting execution lower whorl distribution
During board, if it find that because CIR is zero and this regardless of the current CIR of the queue for board of issuing an order no longer is zero, which is arranged to
Distribute token, and the flow with reference to shown in Fig. 1 participates in performing the distribution of queue token.
In one embodiment, this method further includes:
N number of CIR sections (preferably, N number of adjacent CIR sections) are set, based on the CIR of each queue, determine each team
The residing CIR sections of row, wherein N are more than 2 positive integer;
This in step 102 based on each queue should distribute token number, determine the limit priority team in whole queue
Row specifically include:Between the queue in same CIR sections is belonged to, token number should be distributed based on this and be ranked up, and determined
Highest-priority queue in each CIR sections;, should based on this between highest-priority queue in each CIR sections
Distribution token number is ranked up, and determines the highest-priority queue in whole queues.
Fig. 2 is the method flow diagram of the distribution token of first embodiment of the invention.
As shown in Fig. 2, this method includes:
Step 201:N number of adjacent CIR sections are set, based on the CIR of each queue, determine the CIR residing for each queue
Section, wherein N are at least 2 positive integer.
Step 202:CIR based on each queue and its last time token distribution time, this for determining each queue should divide
Send out token number.
Step 203:Between the queue in same CIR sections is belonged to, token number should be distributed based on this and be ranked up, and
Determine the highest-priority queue in each CIR sections.
Step 204:Between the queue of the limit priority in each CIR sections, token number should be distributed based on this and carried out
Sequence, and determine the highest-priority queue in whole queues.
Step 205:This based on the highest-priority queue in whole queues should distribute token number, for whole queues
Highest-priority queue distributes token.
An instantiation is enumerated below, and flow shown in Fig. 2 is described in detail.
Such as, it is assumed that there are 3 (i.e. N is equal to 3) a CIR sections, be respectively (0,1M], (1M, 10M] and (10M, 20M], wherein
1M=1000Kbps.Queue one shares 12, is respectively L0, L1, L2, L3, M0, M1, M2, M3, H0, H1, H2 and H3.L0's
CIR is 0.5M;The CIR of L1 is 0.4M;The CIR of L2 is 0.6M;The CIR of L3 is 0.8M;The CIR of M0 is 2M;The CIR of M1 is 3M;
The CIR of M2 is 4M;The CIR of M3 is 5M;The CIR of H0 is 12M;The CIR of H1 is 13M;The CIR of H2 is 14M;The CIR of H3 is 15M.
As it can be seen that the CIR of H0, H1, H2 and H3 belong to section (10M, 20M];The CIR of M0, M1, M2 and M3 belong to section (1M,
10M];The CIR of L0, L1, L2 and L3 belong to section (0,1M].
For section (0,1M], respectively determine L0, L1, L2 and L3 this should distribute token number (Add), current time is
Tcurrent;
It can obtain:
The Add_ of L0L0=(Tcurrent-Tlast_L0)×0.5M;Wherein Tlast_L0Distribute the time for L0 last time token;
The Add_ of L1L1=(Tcurrent-Tlast_L1)×0.4M;Wherein Tlast_L1Distribute the time for L1 last time token;
The Add_ of L2L2=(Tcurrent-Tlast_L2)×0.6M;Wherein Tlast_L2Distribute the time for L2 last time token;
The Add_ of L3L3=(Tcurrent-Tlast_L3)×0.8M;Wherein Tlast_L3Distribute the time for L3 last time token.
For section (1M, 10M], respectively determine M0, M1, M2 and M3 this should distribute token number (Add), current time
For Tcurrent;It can obtain:
The Add_ of M0M0=(Tcurrent-Tlast_M0)×2M;Wherein Tlast_M0Distribute the time for M0 last time token;
The Add_ of M1M1=(Tcurrent-Tlast_M1)×3M;Wherein Tlast_M1Distribute the time for M1 last time token;
The Add_ of M2M2=(Tcurrent-Tlast_M2)×4M;Wherein Tlast_M2Distribute the time for M2 last time token;
The Add_ of M3M3=(Tcurrent-Tlast_M3)×5M;Wherein Tlast_M3Distribute the time for M3 last time token.
For section (10M, 20M], respectively determine H0, H1, H2 and H3 this should distribute token number (Add), when current
Between be Tcurrent;It can obtain:
The Add_ of H0H0=(Tcurrent-Tlast_H0)×12M;Wherein Tlast_H0Distribute the time for H0 last time token;
The Add_ of H1H1=(Tcurrent-Tlast_H1)×13M;Wherein Tlast_H1Distribute the time for H1 last time token;
The Add_ of H2H2=(Tcurrent-Tlast_H2)×14M;Wherein Tlast_H2Distribute the time for H2 last time token;
The Add_ of H3H3=(Tcurrent-Tlast_H3)×15M;Wherein Tlast_H3Distribute the time for H3 last time token.
Belong to section (0,1M] L0, L1, L2 and L3 between, token number should be distributed based on this and be ranked up, and base
In ranking results determine each queue section (0,1M] in priority, it is assumed that Add_L0>Add_L1>Add_L2>Add_L3, that
:L0 section (0,1M] in there is limit priority, L1 section (0,1M] it is interior there is the second priority, L2 section (0,
1M] in there is third priority, L3 section (0,1M] interior there is the 4th priority.
Belong to section (1M, 10M] M0, M1, M2 and M3 between, token number should be distributed based on this and be ranked up, and
Based on ranking results determine each queue section (1M, 10M] in priority, it is assumed that Add_M0>Add_M1>Add_M2>Add
_M3, then:M0 section (1M, 10M] there is limit priority, M1 section (1M, 10M] there is the second priority, M2 is in area
Between (1M, 10M] there is third priority, M3 section (1M, 10M] there is the 4th priority.
Belong to section (10M, 20M] H0, H1, H2 and H3 between, token number should be distributed based on this and be ranked up, and
Based on ranking results determine each queue section (10M, 20M] in priority, it is assumed that Add_H0>Add_H1>Add_H2>
Add_H3, then:H0 section (10M, 20M] there is limit priority, H1 section (10M, 20M] there is the second priority, H2
Section (10M, 20M] there is third priority, H3 section (10M, 20M] there is the 4th priority.
Then, between the queue of the limit priority in each CIR sections (i.e. between H0, M0 and L0), be based respectively on H0,
This of M0 and L0 should distribute token number and be ranked up, and the limit priority team in whole queues is determined based on ranking results
Row, wherein this, which should distribute the bigger queue of token number, has higher priority.Such as if Add_M0Respectively greater than
Add_L0And Add_H0, then M0 is the highest-priority queue of whole queues, and distributes token number in step 103 for M0
Add_M0.For another example, if Add_L0Respectively greater than Add_M0And Add_H0, then L0 is the limit priority team in whole queues
Row, and distribute token number Add_ in step 103 for L0L0。
In one embodiment, this method further includes:
N number of CIR sections (preferably, N number of adjacent CIR section) are set, and wherein N is more than 2 positive integer, wherein often
A CIR sections have CIR setting values.Preferably, CIR setting values are the maximum or average value in the CIR sections.
The last time token distribution time of CIR and each queue based on each queue in step 101, determine each queue
This should distribute token number and include:Based on the CIR of each queue, the CIR sections residing for each queue are determined, and be based on determining
The CIR setting values in CIR sections and the last time token distribution time of the queue, this for determining each queue should distribute token
Number;
This in step 102 based on each queue should distribute token number, determine the limit priority team in whole queue
Row include:Between the queue in same CIR sections is belonged to, token number should be distributed based on this and be ranked up, and determined each
Highest-priority queue in CIR sections;Between highest-priority queue in each CIR sections, it should be distributed based on this
Token number is ranked up, and determines the highest-priority queue in whole queues.
Fig. 3 is the method flow diagram of the distribution token of second embodiment of the invention.
As shown in figure 3, this method includes:
Step 301:N number of adjacent CIR sections are set, and wherein N is more than 2 positive integer, and is set for each CIR sections
CIR setting values.
Step 302:Based on the CIR of each queue, the CIR sections residing for each queue are determined, and based on identified CIR
The CIR setting values in section and the last time token of queue distribution time, this for determining each queue should distribute token number.
Step 303:Between the queue in same CIR sections is belonged to, token number should be distributed based on this and be ranked up, and
Determine the highest-priority queue in each CIR sections.
Step 304:Between queue to the limit priority in each CIR sections, token number should be distributed based on this and carried out
Sequence, and determine the highest-priority queue in each CIR sections.
Step 305:Between highest-priority queue in each CIR sections, token number should be distributed based on this and carried out
Sequence, and determine the highest-priority queue in whole queues based on ranking results.
An instantiation is enumerated below, and flow shown in Fig. 3 is described in detail.
Such as, it is assumed that there are 3 CIR sections, be respectively (0,1M], (1M, 10M] and (10M, 20M], wherein 1M=
1000Kbps.(0,1M] setting value be 1M;(1M, 10M] setting value be 10M;(10M, 20M] setting value be 20M.
Queue one shares 12, is respectively L0, L1, L2, L3, M0, M1, M2, M3, H0, H1, H2 and H3.The CIR of L0 is
0.5M;The CIR of L1 is 0.4M;The CIR of L2 is 0.6M;The CIR of L3 is 0.8M;The CIR of M0 is 2M;The CIR of M1 is 3M;M2's
CIR is 4M;The CIR of M3 is 5M;The CIR of H0 is 12M;The CIR of H1 is 13M;The CIR of H2 is 14M;The CIR of H3 is 15M.
As it can be seen that the CIR of H0, H1, H2 and H3 belong to section (10M, 20M];The CIR of M0, M1, M2 and M3 belong to section (1M,
10M];The CIR of L0, L1, L2 and L3 belong to section (0,1M].
For section (0,1M], respectively determine L0, L1, L2 and L3 this should distribute token number (Add), current time is
Tcurrent;
It can obtain:
The Add_ of L0L0=(Tcurrent-Tlast_L0)×1M;Wherein Tlast_L0Distribute the time for L0 last time token.
The Add_ of L1L1=(Tcurrent-Tlast_L1)×1M;Wherein Tlast_L1Distribute the time for L1 last time token.
The Add_ of L2L2=(Tcurrent-Tlast_L2)×1M;Wherein Tlast_L2Distribute the time for L2 last time token.
The Add_ of L3L3=(Tcurrent-Tlast_L3)×1M;Wherein Tlast_L3Distribute the time for L3 last time token.
For section (1M, 10M], respectively determine M0, M1, M2 and M3 this should distribute token number (Add), current time
For Tcurrent;It can obtain:
The Add_ of M0M0=(Tcurrent-Tlast_M0)×10M;Wherein Tlast_L0Distribute the time for M0 last time token.
The Add_ of M1M1=(Tcurrent-Tlast_M1)×10M;Wherein Tlast_L1Distribute the time for M1 last time token.
The Add_ of M2M2=(Tcurrent-Tlast_M2)×10M;Wherein Tlast_L2Distribute the time for M2 last time token.
The Add_ of M3M3=(Tcurrent-Tlast_M3)×10M;Wherein Tlast_L3Distribute the time for M3 last time token.
For section (10M, 20M], respectively determine H0, H1, H2 and H3 this should distribute token number (Add), when current
Between be Tcurrent;It can obtain:
The Add_ of H0H0=(Tcurrent-Tlast_H0)×20M;Wherein Tlast_H0Distribute the time for M0 last time token.
The Add_ of H1H1=(Tcurrent-Tlast_H1)×20M;Wherein Tlast_H1Distribute the time for M1 last time token.
The Add_ of H2H2=(Tcurrent-Tlast_H2)×20M;Wherein Tlast_H2Distribute the time for M2 last time token.
The Add_ of H3H3=(Tcurrent-Tlast_H3)×20M;Wherein Tlast_H3Distribute the time for M3 last time token.
During in above-mentioned calculating, this should distribute token number, the maximum based on CIR sections sets CIR setting values.In fact,
It is also based on the other modes such as the average value in CIR sections and CIR setting values is set, embodiment of the present invention is to this and is not limited.
Then, belong to section (0,1M] L0, L1, L2 and L3 between, token number should be distributed based on this and be ranked up,
And based on ranking results determine each queue section (0,1M] in priority, it is assumed that Add_L0>Add_L1>Add_L2>Add
_L3, then:L0 section (0,1M] in there is limit priority, L1 section (0,1M] it is interior there is the second priority, L2 is in area
Between (0,1M] in there is third priority, L3 section (0,1M] interior there is the 4th priority.
Belong to section (1M, 10M] M0, M1, M2 and M3 between, token number should be distributed based on this and be ranked up, and
Based on ranking results determine each queue section (1M, 10M] in priority, it is assumed that Add_M0>Add_M1>Add_M2>Add
_M3, then:M0 section (1M, 10M] there is limit priority, M1 section (1M, 10M] there is the second priority, M2 is in area
Between (1M, 10M] there is third priority, M3 section (1M, 10M] there is the 4th priority.
Belong to section (10M, 20M] H0, H1, H2 and H3 between, token number should be distributed based on this and be ranked up, and
Based on ranking results determine each queue section (10M, 20M] in priority, it is assumed that Add_H0>Add_H1>Add_H2>
Add_H3, then:H0 section (10M, 20M] there is limit priority, H1 section (10M, 20M] there is the second priority, H2
Section (10M, 20M] there is third priority, H3 section (10M, 20M] there is the 4th priority.
Then, between the queue of the limit priority then in each CIR sections (i.e. between H0, M0 and L0), it is based respectively on
This of H0, M0 and L0 should distribute token number and be ranked up, and the limit priority team of whole queues is determined based on ranking results
Row, wherein this, which should distribute the bigger queue of token number, has higher priority.Such as if Add_M0Respectively greater than
Add_L0And Add_H0, then M0 is the highest-priority queue of whole queues, and distributes token number in step 103 for M0
Add_M0.For another example, if Add_L0Respectively greater than Add_M0And Add_H0, then L0 is the limit priority team in whole queues
Row, and distribute token number Add_ in step 103 for L0L0。
Based on above-mentioned detailed description, embodiment of the present invention also proposed a kind of device for distributing token, which is applicable in
In the application environment with multiple queues.
Fig. 4 is the structure drawing of device of present invention distribution token.
As shown in figure 4, the device 400 includes:
Token number computing module 401, distributes the time for the CIR based on each queue and the last time token of each queue,
This for determining each queue should distribute token number;
Priority Determination module 402, should distribute token number for this based on each queue, determine in whole queues
Highest-priority queue;
Token distribution module 403, should distribute token number for this based on the highest-priority queue in whole queues,
Distribute token for the highest-priority queue in whole queues.
In one embodiment, which further includes:
Setup module 404, is non-negative for determining the currently available token number of each queue, and by currently available token number
Several queues are arranged to regardless of board of issuing an order;And/or it is arranged to for the queue for being zero by CIR regardless of board of issuing an order.
In one embodiment, Priority Determination module 402, for setting N number of CIR sections, based on each queue
CIR determines the CIR sections residing for each queue, and wherein N is more than 2 positive integer;Belong to the queue in same CIR sections it
Between, token number should be distributed based on this and be ranked up, and determine the highest-priority queue in each CIR sections;In each CIR
Between highest-priority queue in section, token number should be distributed based on this and be ranked up, and determined in whole queues
Highest-priority queue.
In one embodiment, Priority Determination module 402, for setting N number of CIR sections, wherein N is more than 2
Positive integer, and each CIR sections have CIR setting values;
Token number computing module 401, the CIR sections residing for each queue, and base are determined for the CIR based on each queue
In identified CIR sections CIR setting values and each queue last time token distribute the time, determine each queue this should
Distribute token number;
Priority Determination module 402, between the queue in same CIR sections is belonged to, order should to be distributed based on this
Board number is ranked up, and determines the highest-priority queue in each CIR sections;Limit priority in each CIR sections
Queue between, token number should be distributed based on this and be ranked up, and determine the highest-priority queue in whole queues.
In one embodiment, CIR setting values are the maximum or average value in the CIR sections.
In one embodiment, the last time token distribution time is Tlast, current time Tcurrent;Described this should divide
Hair token number is Add;It is described to determine that this distribute token number and be:
Add=(Tcurrent-Tlast)×CIR。
Based on above-mentioned analysis, Fig. 5 is the structure drawing of device of the distribution token of third embodiment of the invention.
In Figure 5, TOKEN is a register, for preserving the current token value of each queue.CIR is a register, is used
In the CIR for preserving each queue.SUB_TOKEN is first in first out (FIFO) register, has queue messages to be sent out for working as
After going, provide queue token to token distribution module and reduce number.Timer module, for recording current time TcurrentIt is and each
The last time distribution token time T of a queuelast.ADDQ is a register, and the queue name of distribution token is currently needed for for preserving.
HIGH, MID, LOW are three registers, corresponding to the CIR sections of high, medium and low three kinds of speed, HIGH, MID,
Storage each corresponds to the queue name in section respectively in LOW registers.
After having queue messages to be transmitted, SUB_TOKEN provides queue token to token distribution module and reduces number.Order
Board distribution module is based on queue token and reduces number, and the token number of the correspondence queue in TOKEN is accordingly reduced.
Token number computing module, for the CIR from each queue of CIR register reads, each queue is read from timer
Last time token distribution time Tlast, and determine each queue this should distribute token number.
Priority Determination module, should distribute token number for this to each queue and be ranked up, and based on sequence knot
Fruit determines the priority of each queue, and it is the limit priority in whole queues that wherein this, which should distribute the highest queue of token number,
Queue, and the queue name of the highest-priority queue in whole queues is written to register ADDQ.
Token distribution module, obtains the queue name of the highest-priority queue in whole queues from register ADDQ, and
Token number should be distributed by obtaining this of the highest-priority queue in the whole queue from token number computing module, and by TOKEN
In the token number of highest-priority queue in the whole queue accordingly increase.Moreover, in timer in the whole queue most
The last time distribution token time value of high-priority queue is updated to current time value.
In conclusion in the present invention, CIR and its last time token distribution time based on each queue, determine each team
This of row should distribute token number;This based on each queue should distribute token number, determine that the highest in whole queue is preferential
Level queue;This based on the highest-priority queue in whole queues should distribute token number, excellent for the highest in whole queues
Token is distributed in first level queue.As it can be seen that the present invention is no longer the periodicity poll distribution token of without differences, but according to each team
The last time token distribution time of row and CIR configuration attributes determine the queue of preecedence requirement distribution token, and actively select more to need
The queue for distributing token carries out token distribution operation, so as to improve token distribution efficiency.
Moreover, in embodiment of the present invention, queue larger CIR is more likely to higher priority, therefore is more had an opportunity
Distribute token, so as to effectively avoid the token number in polling mechanism from happening suddenly;The less queues of CIR are more likely to have relatively low preferential
Level, so that it is idle effectively to avoid the distribution token in polling mechanism from operating.
In addition, in embodiments of the present invention, for the queue that current token number is non-negative and CIR is zero, without token
Dispensing action, so as to further improve the efficiency of distribution token.
The foregoing is only a preferred embodiment of the present invention, is not intended to limit the scope of the present invention.It is all
Within the spirit and principles in the present invention, any modification, equivalent replacement, improvement and so on, should be included in the protection of the present invention
Within the scope of.
Claims (8)
- A kind of 1. method for distributing token, it is characterised in that this method comprises the following steps:The last time token distribution time of permission forwarding rate CIR and each queue based on each queue, determine each queue This should distribute token number;This based on each queue should distribute token number, determine the highest-priority queue in whole queue;Token number should be distributed based on this of the highest-priority queue in whole queues, in whole queues most High-priority queue distributes token;This method further includes:N number of CIR sections are set, and the CIR based on each queue determines the CIR sections residing for each queue, and wherein N is more than 2 Positive integer;This based on each queue should distribute token number, determine that the highest-priority queue in whole queues includes: Between the queue in same CIR sections is belonged to, token number should be distributed based on this and be ranked up, and determine each CIR sections Interior highest-priority queue;Between highest-priority queue in each CIR sections, based on this should distribute token number into Row sequence, and determine the highest-priority queue in whole queues;OrThis method further includes:N number of CIR sections are set, and wherein N is more than 2 positive integer, wherein each CIR sections have CIR setting values;It is described to be based on The CIR of each queue and the last time token distribution time of each queue, this for determining each queue should distribute token number and include: CIR based on each queue determines the CIR sections residing for each queue, and CIR setting values based on identified CIR sections and The last time token distribution time of each queue, this for determining each queue should distribute token number;It is described based on each queue This should distribute token number, determine that the highest-priority queue in whole queue includes:Belonging to the queue in same CIR sections Between, token number should be distributed based on this and be ranked up, and determine the highest-priority queue in each CIR sections;Each Between highest-priority queue in CIR sections, token number should be distributed based on this and be ranked up, and determine whole queues In highest-priority queue.
- 2. the method for distribution token according to claim 1, it is characterised in that the CIR setting values are the CIR sections Maximum or average value.
- 3. the method for the distribution token according to any one of claim 1-2, it is characterised in that the last time token distribution Time is Tlast, current time Tcurrent;It is Add that described this, which should distribute token number,;It is described to determine that this distribute token number For:Add=(Tcurrent-Tlast)×CIR。
- 4. the method for the distribution token according to any one of claim 1-2, it is characterised in that this method is also wrapped in advance Include:Determine the currently available token number of each queue, and currently available token number is arranged to not distribute for the queue of nonnegative number Token;And/orThe CIR queues for being zero are arranged to regardless of board of issuing an order.
- 5. a kind of device for distributing token, it is characterised in that the device includes:Token number computing module, distributes for the permission forwarding rate CIR based on each queue and the last time token of each queue Time, this for determining each queue should distribute token number;Priority Determination module, should distribute token number for this based on each queue, determine that the highest in whole queues is excellent First level queue;Token distribution module, for that should distribute token number based on this of the highest-priority queue in whole queues, is Highest-priority queue distribution token in the whole queue;Wherein described Priority Determination module, for setting N number of CIR sections, the CIR based on each queue determines each queue institute The CIR sections at place, wherein N are more than 2 positive integer;Between the queue in same CIR sections is belonged to, it should be distributed based on this Token number is ranked up, and determines the highest-priority queue in each CIR sections;Highest in each CIR sections is preferential Between level queue, token number should be distributed based on this and be ranked up, and determine the highest-priority queue in whole queues; OrWherein described Priority Determination module, for setting N number of CIR sections, wherein N is more than 2 positive integer, wherein each CIR sections have CIR setting values;Token number computing module, determines residing for each queue for the CIR based on each queue CIR sections, and the CIR setting values based on identified CIR sections and the last time token distribution time of each queue, determine each This of queue should distribute token number;Priority Determination module, between the queue in same CIR sections is belonged to, being based on This should distribute token number and be ranked up, and determine the highest-priority queue in each CIR sections;In each CIR sections Limit priority queue between, token number should be distributed based on this and be ranked up, and determined in whole queues most High-priority queue.
- 6. the device of distribution token according to claim 5, it is characterised in that the CIR setting values are the CIR sections Maximum or average value.
- 7. the device of the distribution token according to any one of claim 5-6, it is characterised in that the last time token distribution Time is Tlast, current time Tcurrent;It is Add that described this, which should distribute token number,;It is described to determine that this distribute token number For:Add=(Tcurrent-Tlast)×CIR。
- 8. the device of the distribution token according to any one of claim 5-6, it is characterised in that further include:Setup module, for determining the currently available token number of each queue, and the team by currently available token number for nonnegative number Row are arranged to regardless of board of issuing an order;And/or it is arranged to for the queue for being zero by CIR regardless of board of issuing an order.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510372385.9A CN104917692B (en) | 2015-06-26 | 2015-06-26 | A kind of method and apparatus for distributing token |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510372385.9A CN104917692B (en) | 2015-06-26 | 2015-06-26 | A kind of method and apparatus for distributing token |
Publications (2)
Publication Number | Publication Date |
---|---|
CN104917692A CN104917692A (en) | 2015-09-16 |
CN104917692B true CN104917692B (en) | 2018-05-11 |
Family
ID=54086411
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510372385.9A Active CN104917692B (en) | 2015-06-26 | 2015-06-26 | A kind of method and apparatus for distributing token |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104917692B (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112737970B (en) * | 2019-10-28 | 2024-06-14 | 华为技术有限公司 | Data transmission method and related equipment |
CN113489657B (en) * | 2021-06-29 | 2022-09-09 | 中国银联股份有限公司 | Distributed flow velocity control system and operation method thereof |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1620782A (en) * | 2002-02-22 | 2005-05-25 | 连宇通信有限公司 | Priority control method in wireless pocket data channel |
CN101621457A (en) * | 2008-07-01 | 2010-01-06 | 大唐移动通信设备有限公司 | Multi-service scheduling method and system |
CN102035732A (en) * | 2010-11-25 | 2011-04-27 | 华为技术有限公司 | Service scheduling method and device |
CN102694740A (en) * | 2012-06-28 | 2012-09-26 | 迈普通信技术股份有限公司 | Method and device for scheduling queue |
CN103813481A (en) * | 2013-09-23 | 2014-05-21 | 杭州优能通信系统有限公司 | Intelligent terminal device and business processing method thereof |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8397099B2 (en) * | 2010-09-10 | 2013-03-12 | Microsoft Corporation | Using pulses to control work ingress |
-
2015
- 2015-06-26 CN CN201510372385.9A patent/CN104917692B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1620782A (en) * | 2002-02-22 | 2005-05-25 | 连宇通信有限公司 | Priority control method in wireless pocket data channel |
CN101621457A (en) * | 2008-07-01 | 2010-01-06 | 大唐移动通信设备有限公司 | Multi-service scheduling method and system |
CN102035732A (en) * | 2010-11-25 | 2011-04-27 | 华为技术有限公司 | Service scheduling method and device |
CN102694740A (en) * | 2012-06-28 | 2012-09-26 | 迈普通信技术股份有限公司 | Method and device for scheduling queue |
CN103813481A (en) * | 2013-09-23 | 2014-05-21 | 杭州优能通信系统有限公司 | Intelligent terminal device and business processing method thereof |
Also Published As
Publication number | Publication date |
---|---|
CN104917692A (en) | 2015-09-16 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9568975B2 (en) | Power balancing to increase workload density and improve energy efficiency | |
CN110808922B (en) | Message processing method and device, storage medium and electronic equipment | |
CN107239336B (en) | Method and device for realizing task scheduling | |
US20160378570A1 (en) | Techniques for Offloading Computational Tasks between Nodes | |
CN107959636B (en) | Method and device for sending BGP (Border gateway protocol) message | |
CN107197015A (en) | A kind of message treatment method and device based on Message Queuing system | |
CN108363615A (en) | Method for allocating tasks and system for reconfigurable processing system | |
WO2017166643A1 (en) | Method and device for quantifying task resources | |
CN109714268A (en) | A kind of flow control methods and relevant apparatus of virtual private cloud | |
CN101951411A (en) | Cloud scheduling system and method and multistage cloud scheduling system | |
KR20110073344A (en) | Systems and methods for energy efficient load balancing at server clusters | |
CN105159779B (en) | Method and system for improving data processing performance of multi-core CPU | |
CN101651615A (en) | Method and device for scheduling messages | |
CN104125166A (en) | Queue scheduling method and computing system | |
CN104917692B (en) | A kind of method and apparatus for distributing token | |
Shen et al. | Goodbye to fixed bandwidth reservation: Job scheduling with elastic bandwidth reservation in clouds | |
CA2399186C (en) | Data transfer apparatus and data transfer method | |
CN111988345B (en) | Information synchronization method and device | |
WO2014075488A1 (en) | Queue management method and apparatus | |
CN104281587B (en) | A kind of method and device for establishing connection | |
CN112995058B (en) | Token adjusting method and device | |
CN111190541B (en) | Flow control method of storage system and computer readable storage medium | |
CN106209676A (en) | The data processing method of cloud host computer systems based on many equipment and device | |
CN114116220B (en) | GPU sharing control method, GPU sharing control device and storage medium | |
CN103338159B (en) | Polling dispatching implementation method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
CB02 | Change of applicant information |
Address after: 310052 Binjiang District Changhe Road, Zhejiang, China, No. 466, No. Applicant after: Xinhua three Technology Co., Ltd. Address before: 310052 Binjiang District Changhe Road, Zhejiang, China, No. 466, No. Applicant before: Huasan Communication Technology Co., Ltd. |
|
CB02 | Change of applicant information | ||
GR01 | Patent grant | ||
GR01 | Patent grant |