8.3 The Token Bucket Algorithm 281
buffers such that both the tokens and the packets depart at the same rate which varies
depending on the states of both queues.
Figure 8.5(b) shows the events of packet arrival and departure as well as token
arrival (indicated by the grey circles). Depending on the data arrival rate and the
state of occupancy of the token buffer, the following scenarios could take place.
1. No data arrive and tokens are stored in the buffer and count as credit for the
source. This is similar to the situation before the arrival of packet 1 in Fig. 8.5(b).
2. Data arrive at a rate lower than the token issue rate. In that cases, data will be
accepted and the excess tokens will be stored in the token buffer as credit since
the source is conforming. This is similar to the arrival of packets 1, 2 and 3 in
Fig. 8.5(b). More token arrive than data and token buffer starts filling up.
3. Data arrive at a rate higher than the token issue rate. In that cases, data will be
accepted as long as there are tokens in the buffer. This is similar to the arrival of
packets 4 and 5 in Fig. 8.5(b). Packets 4 and 5 go through although no tokens
have arrived because the token buffer was not empty. When the token buffer
becomes empty, data will be treated as in the following step.
4. Data arrive but no tokens are present. Only a portion of the data will be ac-
cepted at a rate equal to the token issue rate. The excess data can be discarded
or tagged as nonconforming. This is similar to the arrival of packets 6, 7, and 8
in Fig. 8.5(b). Packets 6 and 7 arrive when the token buffer is empty and do not
go through. The packets get stored in the packet buffer and when a token arrives
packet 6 goes through.
Figure 8.6 shows the variation of output data rate in relation to the input data
rate. Grey areas indicate input data rate and solid black lines indicate output data
rate. The dashed line in the middle of the figure indicates the token arrival rate. We
see that output data rate can temporarily exceed the token rate but only for a short
time. The duration of this burst depends on the amount of tokens stored in the token
buffer. Bigger token buffer size allows for longer bursts from the source. However,
a bursty source will not allow the token buffer enough time to fill up.
On the other hand, the packet buffer allows for temporary storage of arriving
packets when there are no tokens in the token buffer.
Time
0
Token arrival rate
Data rate
Fig. 8.6 Control of data rate by the token bucket algorithm. Data rate at the input is indicated by
the grey areas, data rate at the output is indicated by the black lines and the dashed line is the token
issue rate