# Congestion Control
## What is Congestion
Congestion in a network occurs when the amount of traffic attempting to pass through a network element exceeds its capacity to handle that traffic. When a router or link becomes congested, packets must wait in queues for transmission. When queues are full, new arriving packets are dropped. Congestion leads to increased latency, reduced throughput, and packet loss. If congestion is not managed, it can cause a collapse where the throughput of the entire network falls dramatically despite high levels of traffic, because most capacity is consumed by retransmissions.
## Open Loop Congestion Control
Open loop congestion control tries to prevent congestion from occurring in the first place through careful traffic management. Traffic shaping controls the rate at which traffic enters the network. The leaky bucket algorithm enforces a constant output rate regardless of the input rate, smoothing bursty traffic. The token bucket algorithm allows bursts up to a certain size by accumulating tokens when the link is underutilized and consuming them during bursts. Admission control prevents new flows from entering the network if doing so would cause congestion.
## Closed Loop Congestion Control
Closed loop congestion control reacts to congestion after it has occurred. Routers monitor their queue lengths and drop rates to detect congestion. When congestion is detected, signals are sent to sources to reduce their transmission rate. Explicit Congestion Notification allows routers to mark packets to signal congestion to endpoints, allowing sources to reduce their rate before packet loss occurs. TCP's congestion control mechanisms respond to detected packet loss and RTT increases by reducing the congestion window.
## TCP Congestion Control
TCP implements congestion control in the transport layer. When TCP starts a connection, it begins with a small congestion window and grows it rapidly during the slow start phase. When the window reaches the slow start threshold, TCP enters congestion avoidance and grows the window more slowly. When packet loss is detected, TCP reduces the window. With the Reno algorithm, a timeout causes the window to be reset to 1 and slow start begins again. Three duplicate acknowledgments trigger fast retransmit and fast recovery, which cuts the window in half rather than resetting to 1.
## Random Early Detection
Random Early Detection or RED is a router queue management technique that randomly drops packets before the queue is completely full, based on the average queue length. By dropping packets early and randomly, RED signals congestion to TCP senders before the queue overflows, causing them to reduce their rates. This prevents synchronization of many TCP flows, which can cause oscillating congestion.Back to Subject