Think of a token bucket as a piggy bank. Every day you can insert a dollar into the piggy bank (the token bucket). At any given time, you can only spend what you have saved up in the piggy bank. On the average, if your saving rate is a dollar per day, your long-term average spending rate will be one dollar per day if you constantly spend what you saved. However, if you do not spend any money on a given day, you can build up your savings in the piggy bank up to the maximum limit that the piggy bank can hold. For example, if the size of the piggy bank is limited to hold five dollars and if you save and do not spend for five straight days, the piggy bank will contain five dollars. When the piggy bank fills to its capacity, you will not be able to put any more money in it. Then, at any time, you can spend up to five dollars (bursting above the long-term average rate of one dollar per day).
Conforming rate, using the piggy bank example, means that if you have two dollars in the piggy bank and you try to spend one dollar, that is considered conforming because you are not spending more than what you have saved in the piggy bank.
Exceeding rate, using the piggy bank example, means that if you have two dollars in the piggy bank and you try to spend three dollars, it is considered exceeding because you are spending more than what you have saved in the piggy bank.
This topic describes how traffic can be policed using a single token bucket scheme.
Single Token Bucket Class-Based Policing
Bc is normal burst size
Tc is the time interval
CIR is the committed information rate
Token bucket operations rely on parameters such as CIR, committed burst (Bc), and committed time window (Tc). Bc is known as the normal burst size. The mathematical relationship between CIR, Bc, and Tc is as follows:
With traffic policing, new tokens are added into the token bucket based on the interpacket arrival rate and the CIR. Every time a packet is policed, new tokens are added back into the token bucket. The number of tokens added back into the token bucket is calculated as follows:
(Current Packet Arrival Time - Previous Packet Arrival Time) * CIR
An amount (Bc) of tokens is forwarded without constraint in every time interval (Tc). For example, if 8000 bits (Bc) worth of tokens are placed in the bucket every 250 milliseconds (Tc), the router can steadily transmit 8000 bits every 250 milliseconds if traffic constantly arrives at the router.
CIR (normal burst rate) = 8000 bits (Bc) / 0.25 seconds (Tc) = 32 kbps
Without any excess bursting capability, if the token bucket fills to capacity (Bc of tokens), the token bucket will overflow and newly arriving tokens will be discarded. Using the example, in which the CIR is 32 kbps (Bc = 8000 bits and Tc = 0.25 seconds), the maximum traffic rate can never exceed a hard rate limit of 32 kbps.
This topic describes how traffic can be policed using a dual token bucket scheme.
Dual Token Bucket (Single Rate) Class-Based Policing
Was this article helpful?