0
0
Computer Networksknowledge~6 mins

TCP congestion control in Computer Networks - Full Explanation

Choose your learning style9 modes available
Introduction
Imagine a busy highway where too many cars try to pass at once, causing traffic jams and slow movement. Networks face a similar problem when too much data is sent at the same time, leading to delays and lost information. TCP congestion control is the way computers manage this traffic to keep data flowing smoothly without overwhelming the network.
Explanation
Congestion Window (cwnd)
The congestion window is a limit set by the sender on how much data can be sent before waiting for an acknowledgment. It changes dynamically based on network conditions to avoid overwhelming the path between sender and receiver. When the network is clear, the window grows to allow more data; when congestion is detected, it shrinks to reduce traffic.
The congestion window controls the amount of data sent to prevent network overload.
Slow Start
Slow start is the initial phase where TCP begins sending data cautiously with a small congestion window. It increases the window size exponentially with each acknowledgment received, quickly probing the network capacity. This helps find the available bandwidth without causing sudden congestion.
Slow start rapidly increases data flow from a small base to find network capacity safely.
Congestion Avoidance
After slow start, TCP enters congestion avoidance to increase the congestion window more slowly, usually linearly. This cautious growth helps maintain stable data flow and prevents sudden congestion by carefully testing the network limits. It balances sending enough data while avoiding overload.
Congestion avoidance grows data flow steadily to maintain network stability.
Fast Retransmit and Fast Recovery
When TCP detects lost packets through duplicate acknowledgments, it quickly retransmits the missing data without waiting for a timeout (fast retransmit). Then, it reduces the congestion window but avoids going back to slow start by entering fast recovery, allowing data flow to continue smoothly. This speeds up recovery from packet loss.
Fast retransmit and recovery quickly fix lost data and keep traffic flowing.
Timeout and Window Reduction
If acknowledgments are not received in time, TCP assumes severe congestion and drastically reduces the congestion window, often resetting it to one segment. This forces the sender to slow down significantly and restart slow start to avoid worsening the congestion. It acts as a safety mechanism for heavy network traffic.
Timeout triggers a sharp slowdown to protect the network from heavy congestion.
Real World Analogy

Imagine a group of people trying to cross a narrow bridge. At first, only one person crosses to test if the bridge can hold more. If it holds well, more people cross quickly. But if the bridge starts shaking, fewer people cross at a time, and if it shakes badly, everyone stops and waits before trying again.

Congestion Window (cwnd) → The number of people allowed on the bridge at once
Slow Start → Starting with one person and quickly letting more cross as the bridge holds
Congestion Avoidance → Carefully adding people one by one to avoid shaking the bridge
Fast Retransmit and Fast Recovery → Quickly helping a person who slipped and letting others continue crossing
Timeout and Window Reduction → Stopping everyone when the bridge shakes badly and starting over slowly
Diagram
Diagram
┌───────────────────────────────┐
│          TCP Sender            │
│                               │
│  ┌───────────────┐            │
│  │ Congestion    │            │
│  │ Window (cwnd) │◄───────────┤
│  └───────────────┘            │
│         │                     │
│         ▼                     │
│  ┌───────────────┐            │
│  │ Slow Start    │            │
│  └───────────────┘            │
│         │                     │
│         ▼                     │
│  ┌───────────────┐            │
│  │ Congestion    │            │
│  │ Avoidance     │            │
│  └───────────────┘            │
│         │                     │
│         ▼                     │
│  ┌───────────────┐            │
│  │ Fast Retrans- │            │
│  │ mit & Recovery│            │
│  └───────────────┘            │
│         │                     │
│         ▼                     │
│  ┌───────────────┐            │
│  │ Timeout &     │            │
│  │ Window Reduce │            │
│  └───────────────┘            │
└─────────┬─────────────────────┘
          │
          ▼
┌───────────────────────────────┐
│          Network               │
│  (Data packets and ACKs flow) │
└───────────────────────────────┘
This diagram shows the TCP sender's congestion control phases and how the congestion window guides data flow through the network.
Key Facts
Congestion Window (cwnd)A dynamic limit on the amount of data TCP can send before receiving acknowledgments.
Slow StartTCP phase where the congestion window grows exponentially to quickly find network capacity.
Congestion AvoidanceTCP phase where the congestion window grows linearly to maintain stable data flow.
Fast RetransmitTCP mechanism to resend lost packets quickly upon detecting duplicate acknowledgments.
TimeoutEvent when TCP stops and reduces sending rate drastically due to missing acknowledgments.
Common Confusions
Believing slow start means TCP always sends data slowly.
Believing slow start means TCP always sends data slowly. Slow start begins cautiously but quickly increases sending rate exponentially to find available bandwidth.
Thinking congestion window size is fixed.
Thinking congestion window size is fixed. The congestion window changes dynamically based on network feedback to avoid congestion.
Assuming packet loss always means network failure.
Assuming packet loss always means network failure. Packet loss often signals congestion, prompting TCP to reduce sending rate to help the network recover.
Summary
TCP congestion control manages data flow to prevent network overload and packet loss.
It uses phases like slow start and congestion avoidance to adjust sending rates based on network feedback.
Fast retransmit and timeout mechanisms help recover from lost packets and maintain smooth communication.