Code360 powered by Coding Ninjas X Code360 powered by Coding Ninjas X
Table of contents
What is Congestion Control in Computer Networks?
Effects of Congestion Control
Congestion Control Algorithms
Leaky Bucket Algorithm
Token bucket Algorithm
Need of token bucket Algorithm
Steps of this algorithm can be described as follows:The token bucket algorithm is an algorithm that constantly works to refill, consume, and process the packet that comes along. The algorithm goes as discussed below:
Ways in which token bucket is superior to leaky bucket
Frequently asked questions
Which layer is responsible for congestion control?
How can congestion control be done in any network?
Why is congestion control important in networking?
Which protocols support congestion control?
Last Updated: Mar 28, 2024

Congestion Control in Computer Networks

Author Vivek Tiwari
Computer networks
Free guided path
11 chapters
46+ problems
Earn badges and level up


Sometimes, we have faced the situation when our data does not get transferred properly or takes a lot of time to get delivered. To resolve this difficulty, a congestion control process is followed. In this article, readers will get a brief understanding of congestion control in computer networks. This article will define what congestion means in the context of Computer Networks. The article will also explain the negative effects of congestion, including degraded network performance, increased latency, and packet loss.

congestion control

What is Congestion Control in Computer Networks?

Congestion occurs when the amount of data transmitted over a network exceeds its capacity, leading to a slowdown or interruption of data transmission. Congestion control is necessary to ensure that data can be transmitted efficiently and effectively over a network, even when the network is under heavy load. 

Effective congestion control can prevent network outages, minimize delays, and reduce the risk of data loss. With congestion control, network performance can improve significantly, improving user experience. 

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job

Effects of Congestion Control

The effects of congestion control include

  • Improved network performance: Congestion control techniques help prevent congestion and reduce packet loss, resulting in improved network performance and better end-user experience.
  • Fairness: Congestion control mechanisms ensure that network resources are shared fairly among all users, preventing one user from dominating the network.
  • Efficient use of network resources: Congestion control techniques help ensure that network resources are used efficiently, preventing wastage and maximizing the network's capacity.
  • Reduced latency: Congestion control mechanisms help to reduce network latency by preventing network congestion and packet loss.
  • Improved scalability: Congestion control mechanisms help to ensure that the network can handle increasing amounts of traffic without becoming congested, thus improving the scalability of the network.

Congestion Control Algorithms

Congestion control algorithms manage network data traffic to avoid bottlenecks by adjusting how much data can be sent at a time. They monitor network performance and adapt data transmission rates accordingly. Examples include TCP Tahoe, Reno, and BBR, which balance efficiency and fairness to prevent network congestion while maximizing data transfer speed.

Leaky Bucket Algorithm

The Leaky Bucket Algorithm is a traffic-shaping algorithm used in computer networks to control the rate at which data is transmitted.  It regulates the flow of packets to ensure that they are transmitted at a controlled and steady rate, preventing bursts of traffic that can lead to network congestion. The Leaky Bucket Algorithm helps to provide a smoother transmission experience and prevents network congestion. It is generally used in quality of service (QoS) implementations, bandwidth allocation, and network traffic management.

Let us consider an example to understand:

Consider there is a bucket in which data gets loaded. The bucket has a hole in it. The bucket can only transfer the data that can be accumulated in that hole. That means when data packets arrive in a bucket, only those packets that can be transferred from that hole only get moved onto the network layer. When the bucket is full, no further data is accepted. Either the data is kept in the queue or discarded as the bucket size is full but once the bucket has space, it starts accepting the data, and in this way the congestion control of the data takes place.

Token bucket Algorithm

The Token Bucket Algorithm is a traffic-shaping algorithm used in computer networks to control the rate of data transmission. It allows for burst traffic while maintaining an overall average transmission rate. The Token Bucket Algorithm ensures the transmission rate stick to the defined average rate. This helps to manage network congestion and enforce quality of service (QoS) policies.

Need of token bucket Algorithm

In networking and computer systems, the Token Bucket Algorithm is typically used for traffic shaping and rate restriction. It aids in regulating how quickly a system handles incoming requests or data, ensuring fair usage and reducing congestion.

The requirement for the token bucket is as follows:

  • Congestion Avoidance: The Token Bucket Algorithm controls the data flow to help reduce congestion when network or system resources are constrained. It ensures that traffic stays within a certain rate, preventing overloading and preserving consistent performance.
  • Traffic Control: It's crucial to control the speed at which data is transferred or processed in network environments, particularly when several users or applications share resources. The Token Bucket Algorithm aids in preventing abrupt spikes in traffic that can cause congestion and deterioration of service.
  • Rate Limiting: The token bucket algorithm is used to enforce rate limitations on data transmissions or requests. The method makes sure that only a certain quantity of data may be communicated over a specific period by regulating the rate at which tokens (representing units of data) are added to the bucket. This stops resource abuse or indiscriminate use.

Steps of this algorithm can be described as follows:
The token bucket algorithm is an algorithm that constantly works to refill, consume, and process the packet that comes along. The algorithm goes as discussed below:

  1. It is a control algorithm that sets when the token should go from the bucket and the capacity of the bucket to hold the data. The capacity of the bucket is the number of tokens it can hold.
  2. It looks for the time when the bucket has to be refilled. At certain levels, or periodically, the token bucket is filled with the maximum capacity.
  3. Whenever the data packet arrives, it checks the token bucket; if the token bucket is empty, it sends the packet, and if it cannot accommodate, the packet is either delayed or marked with lower priority.
  4. Based on the size of the packet, tokens are removed from the bucket. When excess packets arrive or bursts happen, either the packet is at lower priority or is delayed.
  5. This process constantly runs and helps decide the data packet to be transmitted and received.

Let’s understand with an example.

Consider a bucket that can hold 5 tokens at a time. The token bucket arrival rate is three tokens and the packet size is 2. At first, the token bucket is initially empty, and all the packets are transferred. After every transmission, the token size is checked and if the size is less or equal the packet is transferred. If excess packets arrive it is either set for lower priority or is kept in queue. The bucket can only accommodate packets equal to its token size. In this manner, token bucket algorithm helps in congestion control flow of data. 

Ways in which token bucket is superior to leaky bucket

The ways in which the token bucket algorithm is considered superior to the leaky bucket algorithm are mentioned below:

  • Burst Handling: The token bucket algorithm is better at handling burst traffic. This algorithm adds tokens to the bucket at a constant rate. It must acquire a token from the bucket to be transmitted when a packet arrives. This allows the token bucket algorithm to accommodate short traffic bursts by utilizing tokens accumulated during idle periods. In comparison, the leaky bucket algorithm releases packets at a fixed rate, which may not efficiently handle sudden bursts.
  • Traffic Control Flexibility: The token bucket algorithm provides more flexibility in traffic control. The rate at which tokens are added to the bucket can be dynamically adjusted. It is based on the desired traffic-shaping policy. This enables variable rate limiting, where different traffic flows can be assigned different token arrival rates based on their specific criteria. On the other hand, the leaky bucket algorithm has a fixed rate at which packets are released, making it less adaptable to varying traffic conditions.
  •  Efficiency and Simplicity: The token bucket algorithm is simpler to implement and more efficient than the leaky bucket algorithm. It involves simple token counting and management operations, making it easier to understand and implement in network systems. On the other hand, the leaky bucket algorithm may require more complex mechanisms to regulate the packet release rate and manage the bucket.
  • Handling Peak Traffic: The token bucket algorithm is generally more capable of handling peak traffic conditions. During periods of high traffic, the token bucket can accumulate a burst of tokens. This allows a higher packet transmission rate for the algorithm to handle temporary traffic more efficiently. On the other hand, a leaky bucket limits the output rate based on a fixed leak rate, which may lead to congestion or packet loss during peak periods.
  • Smoother Traffic Shaping: In the leaky bucket algorithm, packets are released at a fixed rate, which can lead to a more uneven transmission pattern. On the other hand, The token bucket algorithm provides smoother traffic shaping compared to the leaky bucket algorithm. Tokens in the token bucket represent permission to transmit a packet. When tokens are available, packets are transmitted, and the corresponding number of tokens is consumed. This provides a smoother transmission pattern as the token bucket maintains a more adjustable and continuous flow of packets.

Frequently asked questions

Which layer is responsible for congestion control?

The Transport Layer is the layer between application and network layer, and it is the best layer responsible for congestion control in computer networks. Since this layer provides multiplexing, demultiplexing, and error detection  features.

How can congestion control be done in any network?

Congestion control in a network can be controlled through various methods, like implementing traffic shaping algorithms, utilizing congestion feedback mechanisms, optimizing routing protocols, employing Quality of Service (QoS) mechanisms, and utilizing flow control mechanisms.

Why is congestion control important in networking?

Congestion control is a crucial part of networking. Several algorithms are designed to prevent congestion in computer networks. Proper allocation of resources, quality delivery, and improved efficiency are some of the major reasons of using congestion control in networking. 

Which protocols support congestion control?

Congestion control is supported by TCP(Transmission Control Protocol ), UDP(User Datagram Protocol), Stream Control Transmission Protocol (SCTP), QUIC (Quick UDP Internet Connections) etc. Congestion management is used by these protocols to control network congestion, avoid packet loss, and keep everything steady.


The conclusion of an article on congestion control in computer networks will typically include a summary of the key congestion control techniques and standards discussed in the article. This summary may highlight the strengths and weaknesses of different techniques and standards and their suitability for different networks and applications.

You can learn the Basics of Java and data structures and algorithms in Java on Coding Ninjas. Refer to our guided path on code studio to learn more about DSA Competitive ProgrammingJavascriptSystem Design, etc. Enroll in our courses and refer to the mock test and Problems available. Also, look at the Interview Experiences for placement preparations.

Previous article
Hamming Code in Computer Network With Examples
Next article
Leaky Bucket Algorithm
Guided path
Computer networks
11 chapters
46+ Problems
Earn badges and level up
Live masterclass