Difference Between Token Bucket Algorithm and Leaky Bucket Algorithm
The differences between leaky and token bucket algorithm are:
Token Bucket Algorithm |
Leaky Bucket Algorithm |
---|---|
It depends on tokens. |
It does not depend on tokens. |
If bucket is full, token is discarded but not the packet. |
If bucket is full, then packets are discarded. |
Packets can only transmit when there are enough tokens. |
Packets are transmitted continuously. |
Allows large bursts to be sent at faster rate. Bucket has maximum capacity. |
Sends the packet at a constant rate. |
The bucket holds tokens generated at regular intervals of time. |
When the host has to send a packet , packet is thrown in bucket. |
If there is a ready packet , a token is removed from Bucket and packet is send. |
Bursty traffic is converted into uniform traffic by leaky bucket. |
If there is no token in the bucket, then the packet cannot be sent. |
In practice bucket is a finite queue outputs at finite rate. |
Leaky bucket algorithm shapes bursty traffic into fixed-rate traffic by averaging the data rate. It may drop the packets if the bucket is full. But this technique is very restrictive. It does not credit an idle host. For example, if a host is not sending for a while, its bucket becomes empty. If the host has bursty data, the leaky bucket allows only an average rate. The time when the host is idle is not take into account. On the other hand, token bucket algorithm allows idle hosts to accumulate credit for the future in the form of tokens. And that is how it overcomes the shortcoming of leaky bucket algorithm.
Token Bucket Algorithm
The Token Bucket algorithm is a popular and simple method used in computer networking and telecommunications for traffic shaping and rate limiting. It is designed to control the amount of data that a system can send or receive in some sort of period, ensuring that the traffic conforms to a specified rate.
It refers to traffic control mechanisms that seek to either differentiate performance based on application or network-operator requirements or provide predictable or guaranteed performance to applications, sessions, or traffic aggregates. It is something that data flow seeks to attain.