![]() |
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. Need for Token Bucket Algorithm
Flow Characteristics of Token Bucket AlgorithmFour types of characteristics are attributed to a flow: reliability, delay, jitter, and bandwidth. ![]() Types of Characteristics for Quality of Service Reliability It implies packet reached or not, information lost or not. Lack of reliability means losing a packet or acknowledgement, which entails re-transmission. Reliability requirements may differ from program to program. For example, it is more important that electronic mail, file transfer and internet access have reliable transmissions than telephony or audio conferencing. DelayIt denotes source-to-destination delay. Different applications can tolerate delay in different degrees. Telephony, audio conferencing, video conferencing, and remote log-in need minimum delay, while delay in file transfer or e-mail is less important. JitterJitter is the variation in delay for packets belonging in same flow. High jitter means the difference between delays is large; low jitter means the variation is small. For example, if packets 0,1,2,3s arrive at 6,7,8,9s it represents same delay. Jitter would signify that packets departed at 0,1,2,3s reach destination at 4,6,10,15s. Audio and video applications don’t allow jitter. BandwidthDifferent applications need different bandwidths. In video conferencing we need to send millions of bits per second to refresh a color screen while the total number of bits in an e-mail may not reach even a million. Techniques to Improve QoSThere are several ways to improve QoS like Scheduling and Traffic shaping ,We will see each and every part of this in brief. SchedulingPackets from different flows arrive at a switch or router for processing. A good scheduling technique treats the different flows in a fair and appropriate manner. Three scheduling techniques are:
To learn more about the scheduling techniques visit this article on packet queuing and dropping. Traffic ShapingIt is a mechanism to control the amount and the rate of the traffic sent to the network. The techniques used to shape traffic are: leaky bucket and token bucket. Difference Between Token Bucket Algorithm and Leaky Bucket AlgorithmThe differences between leaky and token bucket algorithm are:
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. Working of Token Bucket AlgorithmIt allows bursty traffic at a regulated maximum rate. It allows idle hosts to accumulate credit for the future in the form of tokens. The system removes one token for every cell of data sent. For each tick of the clock the system send n tokens to the bucket. If n is 100 and host is idle for 100 ticks, bucket collects 10000 tokens. Host can now consume all these tokens with 10 cells per tick. Token bucket can be easily implemented with a counter. The token is initiated to zero. Each time a token is added, counter is incremented to 1. Each time a unit of data is sent, counter is decremented by 1. When the counter is zero, host cannot send data. ![]() Process depicting how token bucket algorithm works Steps Involved in Token Bucket AlgorithmStep 1: Creation of Bucket: An imaginative bucket is assigned a fixed capacity, known as “rate limit”. It can hold up to a certain number of tokens. Step 2: Refill the Bucket: The bucket is dynamic; it gets periodically filled with tokens. Tokens are added to the bucket at a fixed rate. Step 3: Incoming Requests: Upon receiving a request, we verify the presence of tokens in the bucket. Step 4: Consume Tokens: If there are tokens in the bucket, we pick one token from it. This means the request is allowed to proceed. The time of token consumption is also recorded. Step 5: Empty Bucket: If the bucket is depleted, meaning there are no tokens remaining, the request is denied. This precautionary measure prevents server or system overload, ensuring operation stays within predefined limits. Advantage of Token Bucket over Leaky Bucket
Disadvantages of Token Bucket Algorithm
Frequently Asked Questions on Token Bucket AlgorithmWhat is leaky bucket algorithm?
Where is token bucket algorithm used?
What are the disadvantages of token bucket?
|
Reffered: https://www.geeksforgeeks.org
Computer Networks |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 12 |