CN100568849C - A kind of message rate-limiting method based on token bucket - Google Patents

A kind of message rate-limiting method based on token bucket Download PDF

Info

Publication number
CN100568849C
CN100568849C CNB2005100937424A CN200510093742A CN100568849C CN 100568849 C CN100568849 C CN 100568849C CN B2005100937424 A CNB2005100937424 A CN B2005100937424A CN 200510093742 A CN200510093742 A CN 200510093742A CN 100568849 C CN100568849 C CN 100568849C
Authority
CN
China
Prior art keywords
message
token
data segment
time
length
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
Application number
CNB2005100937424A
Other languages
Chinese (zh)
Other versions
CN1925455A (en
Inventor
滕焕勇
吴中文
杨平
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sanechips Technology Co Ltd
Original Assignee
ZTE Corp
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by ZTE Corp filed Critical ZTE Corp
Priority to CNB2005100937424A priority Critical patent/CN100568849C/en
Publication of CN1925455A publication Critical patent/CN1925455A/en
Application granted granted Critical
Publication of CN100568849C publication Critical patent/CN100568849C/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The present invention proposes a kind of method of the message rate-limiting based on token bucket, comprising: when receiving the data segment of a certain message, trigger the operation of once filling token, in described token bucket, fill the token of some; Judge that whether the token in the token bucket surpasses the length of message data section, if token number more than or equal to data segment, length, then allows this data segment to pass through, and deducts the pairing token number of message data segment length from token bucket; If token number is less than the length of message data section, then abandon this data segment, whole message under this data segment all is dropped, and the data segment follow-up to this message no longer carries out the judgement of token number, and the data segment corresponding token number that has passed through before this message is returned to described token bucket.The inventive method since adopted when message fragment carried out message rate-limiting token number relatively, reduced in the system message forwarding time of delay; Adopt also regularly scan the time of reception of dual port RAM recorded message data segment, improved the accuracy of message rate-limiting in the system.

Description

A kind of message rate-limiting method based on token bucket
Technical field
The present invention relates to the method for message rate-limiting in a kind of field of data networks, specifically, relate to the hardware implementation method that adopts token bucket that message rate is limited in a kind of data network.
Background technology
In existing data network,, usually can cause network congestion because message flow is sudden.A kind of method that solves network congestion is, limits in the speed of receiving terminal to message, if the speed of message is lower than the speed of regulation, then normally receives message; If the speed of message surpasses the speed of regulation,, perhaps reduce priority of messages etc. then with packet loss.
The method that generally adopts is to utilize token bucket that message is carried out speed limit at present.As shown in Figure 1, system's speed is in accordance with regulations constantly filled token in token bucket, till token bucket is filled.When message arrives, follow the token number in the token bucket to compare the length of message, if enough tokens are arranged in the token bucket, then message allows to pass through, and deducts the pairing token number of message length simultaneously from token bucket; If the token in the token bucket is not enough,, perhaps reduce the transmission priority of message then with packet loss.
In above-mentioned existing method, the fill rate of token has limited the speed that receives message, and the capacity of token bucket then provides certain property held to the burst flow of message.In this method, the filling of token is regularly, promptly adds certain token every the regular hour in token bucket.This time is fixed, and can have contradiction on size is selected.If it is less that this time interval is selected, then token need be filled continually by system, and system loading is heavier, and for the slower message of speed, speed limit efficient is very low; If it is bigger that the time interval is selected, then, might lose the effect of speed limit for speed message faster.
The Chinese application number of the patent of Huawei Tech Co., Ltd " adopting Token Bucket to carry out the method for message flow limitation ": 03109091.5 application has proposed a kind of new token filling mode, fills token with message to being used as trigger condition.Time interval when this method need be calculated current message and the arrival of a last message according to the timer of internal system.If the maximum magnitude interval greater than the internal system timer between two messages, the time interval that then comes out is inaccurate.In other words, this method has requirement on the scope to the time interval between two messages, has certain limitation.
In addition, above-mentioned two class methods are all just carried out the speed limit of message after receiving a complete message.If the speed of message has surpassed the speed of regulation, and length is very long, could be but still will receive whole message with packet loss, then be unfavorable for reducing in the system message forwarding time of delay.
Therefore, also there is certain defective in prior art, and awaits improving and development.
Summary of the invention
The object of the present invention is to provide a kind of method of the message rate-limiting based on token bucket, at inefficiency in the existing message rate-limiting technology, and be unfavorable for reducing defectives such as message forward delay, a kind of improved message rate-limiting method is proposed, message is carried out segmentation by regular length, is that unit carries out speed limit to message with the data segment; Simultaneously, use a dual port RAM (random access storage device: Random Access Memory) come the time difference between continuous two data segments in the accounting message, being used for the filling token number of computational token bucket, message forwarding time of delay in the minimizing system.
Technical scheme of the present invention is as follows:
A kind of message rate-limiting method based on token bucket, it comprises the steps:
A, when receiving the data segment of a certain message, trigger the operation once fill token, in described token bucket, fill the token of some;
B, judge that whether the token in the token bucket surpasses the length of message data section, if token number more than or equal to data segment, length, then allows this data segment to pass through, and deducts the pairing token number of message data segment length from token bucket;
If the C token number is less than the length of message data section, then abandon this data segment, whole message under this data segment all is dropped, and the data segment follow-up to this message no longer carries out the judgement of token number, and the data segment corresponding token number that has passed through of this message is returned to described token bucket.
Described method, wherein, described method also is provided with a memory, and described steps A also comprises:
A1, judge that whether the current data section is first data segment of the message that token bucket is handled in the system, if, change steps A 4, otherwise, steps A 2 changeed;
A2, from described memory, read the time of reception of previous data segment,, calculate the time difference between two data segments according to the time in the current system timer;
A3, according to the time difference between two message data sections and the fill rate of token, calculate current token number of need filling, carry out the operation of filling token;
A4, current system time is write into described memory, cover original data segment time of reception record.
Described method, wherein, described data segment is a regular length, the minimum length of the message of being supported in the employing system.
Described method wherein, also is provided with a timer, is used for system time is counted, and all messages are all shared a system timer.
Described method, wherein, comprise also regularly described memory scanned that the token bucket required time that fills up a sky with the token fill rate of minimum is the time difference maximum, for the difference of those and current system time the peaked memory cell of overtime difference identified.
Described method, wherein, described memory adopts dual port RAM, is used for the calculating of time difference flatly, is used for the scanning of time difference flatly.
The method of a kind of message rate-limiting based on token bucket provided by the present invention, because the token number when employing is carried out message rate-limiting to message fragment relatively, can identify above the message of schedule speed in the short period of time and abandoned, reduce in the system message forwarding time of delay; In addition, the inventive method adopts the time of reception of a dual port RAM recorded message data segment and regularly scans, and can accurately calculate the time difference between the adjacent two data section in the message, thereby improve the accuracy of message rate-limiting in the system.
Description of drawings
Fig. 1 is the method schematic diagram that the employing token bucket of prior art carries out the message rate restriction;
Fig. 2 is the flow chart of the message rate method for limiting that proposes of the present invention;
Fig. 3 is the flow chart that calculates the time difference of the inventive method;
Fig. 4 is the flow chart of the time difference scanning of the inventive method.
Embodiment
Below in conjunction with accompanying drawing, will be described in detail the method for the invention.
The method of the message rate-limiting based on token bucket of the present invention specifically, when whenever receiving the data segment of regular length in the message, promptly triggers the operation of once filling token, fills the token of some in token bucket.Judge that then whether the token in the token bucket surpasses the length of message data section, if token number more than or equal to data segment, length, then allows this data segment to pass through, and deducts the pairing token number of message data segment length from token bucket; If token number less than the length of message data section, then abandons this data segment, the whole message under this data segment all will be dropped simultaneously, and the follow-up data segment of this message no longer carries out the judgement of token number.That is to say, have only all data segments of message all allow by the time, this message could pass through, and has so just reduced and has judged the waste of whole data segment to resource, has improved treatment effeciency and speed.
The key step of the method for the invention comprises as shown in Figure 2:
(1) the message data section of reception regular length;
(2) judge whether the current data section is first data segment that token bucket is handled in the system, if, change step (6), otherwise, step (3) changeed.
(3) from RAM, read the time of reception of previous message data section;
(4), calculate the time difference between two message data sections according to the time in the current system timer;
(5) according to the time difference between two message data sections and the fill rate of token, calculate the current token number that needs filling, be filled in the middle of the token bucket then;
(6) current system time is write into RAM, cover original message data section time of reception;
(7) judge that token in the token bucket whether greater than the length of current data section, if token number more than or equal to the length of data segment, then receives the current data section, deducts data segment corresponding token number from token bucket, and the data length that passed through of accounting message; If token number less than the length of data segment, then abandons the current data section, simultaneously with whole packet loss, the recovery of board of playing drinking games of going forward side by side is about to the pairing token number of data length that message passed through and is added back in the token bucket.In other words, the message that is dropped does not consume the token in the token bucket.
After current message data section was passed through, the data segment, length that needs the affiliated message of statistics current data section to pass through judged simultaneously whether current message data section is last data segment of message.If not last data segment, then proceed the rate limit of next message data section; If last data segment, then finish the rate limit of current message, carry out the rate limit of next message.Have only after all data segments of message all pass through, this message just passes through.In case the message data section that receives is the control by token bucket not, then whole message is dropped, the board of playing drinking games of going forward side by side recovers, the pairing token number of data segment of this message that has passed through before is added back in the token bucket, finish the rate limit of current message then, carry out the rate limit of next message.
After system finished initialization, token bucket was in full state, so first data segment does not need to add token in token bucket when arriving.
In the inventive method, the length of data segment is fixed in the message, the minimum length of the message of being supported in the suggestion employing system.If the length of last data segment of message is less than L, then the physical length with data segment compares with the token in the token bucket.
The inventive method needs in the token bucket quantity of filling token equal the token fill rate and multiply by time difference between a current message data section and the last message data section when receiving the data segment of a message.Because the capacity of token bucket is limited, so fill the capacity that the quantity of token the most very much not can surpass token bucket at every turn.With the needed time of token bucket that the token fill rate of minimum fills up a sky, be the maximum of time difference.That is to say that if the actual time between two message data sections, difference surpassed above-mentioned time difference maximum, then can calculate with the maximum of time difference needs the token number of filling.
When the time difference of adding up between two message data sections, need a timer, system time is counted.The scope of timer is limited, generally adopts the maximum of above-mentioned time difference.In data network, for the needs of service quality (QoS:Quality of Service) are provided, at first message to be classified, dissimilar messages has different rate limit.Have a large amount of type of messages in the General System, it is unpractical on hardware is realized that every type message all adopts a timer, and therefore, in the inventive method, all messages are all shared a system timer.When certain message data section arrives, the numerical value of this moment system timer is kept in the internal storage, when next message data section arrives, utilize the numerical value in the current time system timer, calculate the time difference between two message data sections, simultaneously the numerical value in the current time system timer is kept in the internal storage, covers original numerical value, be used to calculate the next time difference.
Because timer is a cycle count, and the time difference between two data segments is arbitrarily, therefore, must regularly scan internal storage, for the difference of those and current system time the peaked memory cell of overtime difference identified.Concerning memory, the calculating of time difference and the scanning of time difference are two independently processes, and memory adopts dual port RAM among the present invention, are used for the calculating of time difference flatly, are used for the scanning of time difference flatly.
Be the schematic flow sheet that the time difference calculates among the present invention as shown in Figure 3.
Suppose that it is T that token fill rate with minimum fills up a needed time of empty token bucket Max, the binary number of corresponding n bit wide.Surpass T when the time interval of two message data sections MaxThe time, the time difference Δ T of required calculating is T Max
The form that is kept at the time value among the RAM is schematically as follows:
Title The position Explanation
The overflow indicator position N+1 Time difference overflow indicator position is obtained by time difference scanning.After overflowing, Δ T=T Max
Carry flag bit n The carry flag of system timer.
When the message data section arrives (n-1 The number of system timer when receiving the message data section
Carve ): 0 Value.
Whenever receiving length when being the message data section of L, just trigger the computational process of a time difference.Value T with current system timer 2With the last message data section moment T that is kept among the RAM 1Compare, draw two time difference Δ T between the message data section.
T in reading RAM 1After the value, if T 1The overflow indicator position be 1, expression elapsed time difference scanning, this time difference is the maximum of overtime difference, so Δ T=T Max
If T 1Still do not overflow, then compare T 1And T 2Carry flag.If T 1And T 2Carry flag identical, and T 2>T 1, then represent from T 1Constantly begin not circulation of system timer (the timer meter is to maximum reset-to-zero reclocking afterwards), then Δ T=T to current time 2-T 1If T 1And T 2Carry flag identical, and T 2≤ T 1, then represent from T 1Constantly begin to current time, system's meter has circulated twice, then Δ T=T Max
If T 1And T 2The carry flag difference, then represent from T 1Constantly begin to current time, system timer is circulated throughout once.If T 2>T 1, Δ T=T then MaxIf T 2≤ T 1, Δ T=T then Max+ T 2-T 1
Be the process schematic diagram of time difference scanning among the present invention as shown in Figure 4.
The scanning process of time difference and the compute classes of time difference seemingly but trigger different constantly.In the inventive method, in the time difference maximum of T MaxIn cycle, need carry out single pass successively to all unit of RAM, judge that the moment of preserving in each unit compares constantly with its scanning, whether the time difference has exceeded maximum of T MaxIf the time difference has exceeded maximum, then with corresponding overflow indicator position 1, expression Δ T=T Max
During scanning, with current time T 3With the last message data section moment T that is kept among the RAM 1Compare.If T 1Overflow indicator be 1, during time difference scanning before then being illustrated in, the time difference of this unit overflows, any operation is not done in current scanning, carries out the scanning of next ram cell.
If T 1Overflow indicator be 0, then the express time difference is not also overflowed.Compare T 1And T 3Carry flag.If T 1And T 3Carry flag identical, and T 3>T 1, then represent from T 1Constantly begin to current time, system timer is circulation not, and then the time difference does not overflow, and finishes the scanning of current ram cell, carries out the scanning of next unit.If T 1And T 3Carry flag identical, and T 3≤ T 1, then represent from T 1Constantly begin to current time, system's meter has circulated twice, and then the time difference overflows, and with overflow indicator position 1, carries out the scanning of next ram cell then.
If T 1And T 3The carry flag difference, then represent from T 1Constantly begin to current time, system timer is circulated throughout once.If T 3>T 1, then the time difference overflows, and with overflow indicator position 1, carries out the scanning of next ram cell then.If T 3≤ T 1, then the time difference does not overflow as yet, finishes the scanning of current ram cell, carries out the scanning of next unit.
Concerning each ram cell, the time interval of twice scanning is T Max, so just guaranteed to be no more than 2 * T according to a carry flag MaxTime in, whether in time judge the pairing time difference of time that this ram cell preserves overflows.
The calculating of time difference is constantly relevant with the arrival of message data section, fix the sweep time of time difference, so might carry out time difference calculating and time difference scanning simultaneously to the same unit in the memory RAM, promptly the same address of dual port RAM be carried out read-write operation simultaneously.In fact, time difference scanning also is to calculate a kind of time difference, therefore, for fear of the same unit of memory is operated simultaneously, if the time difference calculates and time difference scanning takes place simultaneously, then only carries out the time difference and calculates, and ignores time difference scanning.
The method of the message rate-limiting based on token bucket of the present invention, since adopted when message fragment carried out message rate-limiting token number relatively, identify the message that surpasses schedule speed in the short period of time and abandoned, reduced in the system message forwarding time of delay; The inventive method also adopts the time of reception of a dual port RAM recorded message data segment and regularly scans simultaneously, can accurately calculate the time difference between the adjacent two data section in the message, thereby improved the accuracy of message rate-limiting in the system, computational efficiency and speed have been improved, the used resources conservation of computing.
Should be understood that above-mentioned description at specific embodiment is comparatively detailed, can not therefore think the restriction to scope of patent protection of the present invention, scope of patent protection of the present invention should be as the criterion with claims.

Claims (5)

1, a kind of message rate-limiting method based on token bucket, it comprises the steps:
A, when receiving the data segment of a certain message, trigger the operation once fill token, in described token bucket, fill the token of some;
B, judge that whether the token in the token bucket surpasses the length of message data section, if token number more than or equal to data segment, length, then allows this data segment to pass through, and deducts the pairing token number of message data segment length from token bucket;
If the C token number is less than the length of message data section, then abandon this data segment, whole message under this data segment all is dropped, and the data segment follow-up to this message no longer carries out the judgement of token number, and the data segment corresponding token number that has passed through before this message is returned to described token bucket;
Described method also is provided with the time of reception of memory record data segment, and described steps A specifically comprises:
A1, judge that whether the current data section is first data segment of the message that token bucket is handled in the system, if, change steps A 4, otherwise, steps A 2 changeed;
A2, from described memory, read the time of reception of previous data segment,, calculate the time difference between two data segments according to the time in the current system timer;
A3, according to the time difference between two message data sections and the fill rate of token, calculate current token number of need filling, carry out the operation of filling token;
A4, current system time is write into described memory, cover original data segment time of reception record.
2, method according to claim 1 is characterized in that, described data segment is a regular length, the minimum length of the message of being supported in the employing system.
3, method according to claim 1 is characterized in that, described method also is provided with a timer, is used for system time is counted, and all messages are all shared a system timer.
4, method according to claim 3, it is characterized in that, described method also comprises regularly described memory is scanned, the token bucket required time that fills up a sky with the token fill rate of minimum is the time difference maximum, for the difference of those and current system time the peaked memory cell of overtime difference identified.
5, according to any described method of claim of claim 1 to 4, it is characterized in that described memory adopts dual port RAM, be used for the calculating of time difference flatly, be used for the scanning of time difference flatly.
CNB2005100937424A 2005-08-29 2005-08-29 A kind of message rate-limiting method based on token bucket Active CN100568849C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2005100937424A CN100568849C (en) 2005-08-29 2005-08-29 A kind of message rate-limiting method based on token bucket

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2005100937424A CN100568849C (en) 2005-08-29 2005-08-29 A kind of message rate-limiting method based on token bucket

Publications (2)

Publication Number Publication Date
CN1925455A CN1925455A (en) 2007-03-07
CN100568849C true CN100568849C (en) 2009-12-09

Family

ID=37817926

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2005100937424A Active CN100568849C (en) 2005-08-29 2005-08-29 A kind of message rate-limiting method based on token bucket

Country Status (1)

Country Link
CN (1) CN100568849C (en)

Families Citing this family (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101110716B (en) * 2007-08-13 2010-08-11 杭州华三通信技术有限公司 Method and device for monitoring flux of slicing messages
CN101478494B (en) * 2009-02-16 2011-03-16 中兴通讯股份有限公司 Data packet processing method and apparatus based on token barrel algorithm
CN101951339B (en) * 2010-08-24 2012-08-15 北京星网锐捷网络技术有限公司 Message speed limitation method, device and network equipment
CN102567549A (en) * 2011-11-18 2012-07-11 中国船舶重工集团公司第七二四研究所 Leaky token bucket algorithm based self-adaptive data recording/replaying technology and realizing method thereof
EP2661027A4 (en) * 2012-01-21 2014-09-24 Huawei Tech Co Ltd Message forwarding method and device
CN104580396B (en) * 2014-12-19 2018-07-20 华为技术有限公司 A kind of method for scheduling task, node and system
FR3044188B1 (en) * 2015-11-25 2017-12-22 Kalray FLOW LIMITER OF TYPE "BUCKET BUCKET"
CN105721331A (en) * 2016-01-21 2016-06-29 盛科网络(苏州)有限公司 Method of controlling transmitting speed of built-in throughput capacity testing processing engine
CN106413002B (en) * 2016-11-22 2019-12-10 京信通信系统(中国)有限公司 Method and device for controlling terminal rate and base station
CN109246026B (en) * 2018-08-13 2022-05-03 中国平安人寿保险股份有限公司 Flow control method, device, equipment and storage medium
CN110611623B (en) * 2019-08-30 2023-07-21 江苏苏宁物流有限公司 Current limiting method and device
CN112134808B (en) * 2020-07-21 2024-02-02 上海寻梦信息技术有限公司 Method and device for issuing bin allocation service speed control, electronic equipment and storage medium
CN113742114A (en) * 2020-09-28 2021-12-03 北京沃东天骏信息技术有限公司 System current limiting method and device
CN116016356A (en) * 2021-09-30 2023-04-25 迈普通信技术股份有限公司 Message processing method and device
CN114915596B (en) * 2022-05-10 2024-06-14 北京奇艺世纪科技有限公司 Data transmission method, device, equipment and storage medium
CN116582496B (en) * 2023-07-13 2024-04-19 广东睿江云计算股份有限公司 Token bucket packet loss optimization method and system

Also Published As

Publication number Publication date
CN1925455A (en) 2007-03-07

Similar Documents

Publication Publication Date Title
CN100568849C (en) A kind of message rate-limiting method based on token bucket
US7733892B2 (en) Buffer management method based on a bitmap table
US6704321B1 (en) Traffic shaper
Choudhury et al. Dynamic queue length thresholds for shared-memory packet switches
US7929431B2 (en) Port rate smoothing in an avionics network
JPH07297840A (en) Priority control method for output buffer type atm switch
CN110134366B (en) Method and device for parallel writing in multi-channel FIFO
US6415366B1 (en) Method and apparatus for load distribution across memory banks with constrained access
CN105573711B (en) A kind of data cache method and device
CN103888377A (en) Message cache method and device
CN101616441B (en) Method and device for calculating arrival time interval of message
CN102882809B (en) Network speed-limiting method and device based on message buffering
RU2641250C2 (en) Device and method of queue management
CN101227689B (en) Method and apparatus for reporting information
CN101645830A (en) Method for packet scheduling of multi-hop network and node device
CN102143377A (en) Video stream delay factor monitoring method and video stream delay factor monitoring device
CN105681864A (en) IP-based transmission flow jitter removing method and device
JP2820106B2 (en) Traffic shaper device
CN110825308B (en) Data space management method and device
CN101651614A (en) Method and device for scheduling multiport queues
CN111131066A (en) Traffic shaping method and device
CN111654886B (en) Method and device for limiting user bandwidth
CN103514111A (en) Method and device for replacing data in Cache
JP5571826B1 (en) Packet transfer processing apparatus and method
CN111126584A (en) Data write-back system

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
EE01 Entry into force of recordation of patent licensing contract

Application publication date: 20070307

Assignee: SANECHIPS TECHNOLOGY Co.,Ltd.

Assignor: ZTE Corp.

Contract record no.: 2015440020319

Denomination of invention: Message speed limiting method based on token barrel

Granted publication date: 20091209

License type: Common License

Record date: 20151123

LICC Enforcement, change and cancellation of record of contracts on the licence for exploitation of a patent or utility model
TR01 Transfer of patent right

Effective date of registration: 20221116

Address after: 518055 Zhongxing Industrial Park, Liuxian Avenue, Xili street, Nanshan District, Shenzhen City, Guangdong Province

Patentee after: SANECHIPS TECHNOLOGY Co.,Ltd.

Address before: 518057 Department of law, Zhongxing building, South hi tech Industrial Park, Nanshan District hi tech Industrial Park, Guangdong, Shenzhen

Patentee before: ZTE Corp.

TR01 Transfer of patent right