Traffic shaping uses a token bucket metaphor to shape traffic. A token bucket is a formal definition of a rate of transfer.
It has three components: a burst size, a mean rate, and a time interval (Tc). Although the mean rate is generally represented
as bits per second, any two values may be derived from the third by the relation shown as follows:
mean rate = burst size / time interval
Here are some definitions of these terms:
-
Mean rate--Also called the committed information rate (CIR), it specifies how much data can be sent or forwarded per unit
time on average.
-
Burst size--Also called the committed burst (Bc) size, it specifies in bits (or bytes) per burst how much traffic can be sent
within a given unit of time to not create scheduling concerns. (For a traffic shaper, it specifies bits per burst.)
-
Time interval--Also called the measurement interval, it specifies the time quantum in seconds per burst.
By definition, over any integral multiple of the interval, the bit rate of the interface will not exceed the mean rate. The
bit rate, however, may be arbitrarily fast within the interval.
A token bucket is used to manage a device that regulates the data in a flow. For example, the regulator might be a traffic
shaper. A token bucket itself has no discard or priority policy. Rather, a token bucket discards tokens and leaves to the
flow the problem of managing its transmission queue if the flow overdrives the regulator.
In the token bucket metaphor, tokens are put into the bucket at a certain rate. The bucket itself has a specified capacity.
If the bucket fills to capacity, newly arriving tokens are discarded. Each token is permission for the source to send a certain
number of bits into the network. To send a packet, the regulator must remove from the bucket a number of tokens equal in representation
to the packet size.
If not enough tokens are in the bucket to send a packet, the packet waits until the bucket has enough tokens. If the bucket
is already full of tokens, incoming tokens overflow and are not available to future packets. Thus, at any time, the largest
burst a source can send into the network is roughly proportional to the size of the bucket.
Note that the token bucket mechanism used for traffic shaping has both a token bucket and a data buffer, or queue; if it did
not have a data buffer, it would be a traffic policer. For traffic shaping, packets that arrive that cannot be sent immediately
are delayed in the data buffer.
For traffic shaping, a token bucket permits burstiness but bounds it. It guarantees that the burstiness is bounded so that
the flow will never send faster than the capacity of the token bucket plus the time interval multiplied by the established
rate at which tokens are placed in the bucket. It also guarantees that the long-term transmission rate will not exceed the
established rate at which tokens are placed in the bucket.