A device implemented for use in QoS applications. A token bucket is a technique for deciding how to mark packets to be considered out of profile. The token bucket allows for a small degree of burstiness within a particular traffic class while generally enforcing a lower long-term (average) rate limit.
Tokens are added to a "bucket" at some fixed rate X (tokens per second) and are removed from the bucket whenever a packet arrives. A bucket also has a finite depth--it never will contain more than Y tokens.
Now, how this applies to traffic is thus: when a packet arrives and at least one token is avaiable, the token is removed and the packet is considered to be in profile. If no tokens are in the bucket when a packet arrives, that packet is declared to be out of profile. The token replensihment rate X represents the long-term average rate limit if packets are to remain in profile. By tuning X and Y one can tune Quality of Service attributes in respect to burst rates with ease.
Token Bucket Token Bucket Token Bucket
[-------------------] [-------------------] [-------------------]
Packet | | Packet | | Packet | |
Arrives | [---------------] | Arrives | [---------------] | Arrives | [---------------] | ^
| | | | | | | | | | | | |
| | [---------------] | | | [---------------] | | | [---------------] | | B
| | | | | | | | | | u
| | [---------------] | | | [---------------] | | | [---------------] | | f
| | | | | | | | | | | | | | | | f
| | [---------------] | | | [---------------] | | | [---------------] | | e
| | | | | | | | | | r
| | [---------------] | | | [---------------] | | | [---------------] | |
| | | | | | | | | | | | | | | |
| | [---------------] | | | [---------------] | | | [---------------] | |
| | | | | | | | | | D
| | [---------------] | | | [---------------] | | | [---------------] | | e
| | |###############| | | | | | | | | | | | | p
V | [---------------] | V | [---------------] | V | [---------------] | | t
| | | | | | | h
Takes | [---------------] | Takes | [---------------] | No | [---------------] | |
Token ----> | |###############| | Token ----> | |###############| | Token ----> | | | | |
| [---------------] | | [---------------] | | [---------------] | V
| | | | | |
[-------------------] [-------------------] [-------------------]
Result: In Profile Result: In Profile Result: Out of Profile
See also: CQS, MPLS, & Traffic Engineering