Lab 07 - TCP Congestion Control

Back to Labs

Lab Objective

To understand the concept of TCP Congestion Control, its phases, mechanisms, and how TCP dynamically adjusts the data transmission rate to prevent congestion in a network.

Overview

Congestion occurs when the rate of data sent to the network exceeds the network’s capacity. TCP implements congestion control mechanisms to prevent packet loss and ensure fair bandwidth usage among users.

TCP Congestion Control works primarily by adjusting a parameter called Congestion Window (cwnd) based on network feedback (ACKs and packet loss).

Phases of TCP Congestion Control

1. Slow Start (SS)

• Initially, cwnd starts with 1 MSS (Maximum Segment Size).
• Each ACK received doubles the cwnd — exponential growth.
• Continues until it reaches a threshold called ssthresh.

Formula: cwnd = cwnd × 2 (for each RTT)

2. Congestion Avoidance (CA)

• Once cwnd ≥ ssthresh, TCP enters linear growth mode.
• cwnd increases by 1 MSS for every RTT.
• Aims to find the network’s optimal capacity without causing congestion.

Formula: cwnd = cwnd + 1 (per RTT)

3. Congestion Detection

TCP detects congestion when it notices packet loss. This can happen in two ways:

  • Timeout: No ACK is received within the expected time.
  • Triple Duplicate ACKs (3 DUP ACK): Receiver keeps acknowledging the same segment, indicating one segment is lost.

4. Fast Retransmit

Triggered when 3 Duplicate ACKs are received.

  • The sender retransmits the missing segment immediately without waiting for a timeout.
  • This indicates mild congestion, not full collapse.

5. Fast Recovery & Reaction to Loss

⚡ Case 1: Packet Loss Detected by Timeout

  • Interpreted as severe congestion.
  • ssthresh = cwnd / 2
  • cwnd is reset to 1 MSS (Restart Slow Start)

⚡ Case 2: Packet Loss Detected by Triple Duplicate ACKs

  • Interpreted as mild congestion.
  • ssthresh = cwnd / 2
  • cwnd = ssthresh (or some TCP variants use cwnd = ssthresh + 3 MSS to continue sending)
  • Then continue with Congestion Avoidance (linear increase).

TCP Congestion Control Diagram

TCP Congestion Control Diagram

Figure: The growth of cwnd during Slow Start, Congestion Avoidance, and Fast Recovery phases.

Important Terms

  • cwnd (Congestion Window): Controls how many bytes can be sent without ACK.
  • ssthresh (Slow Start Threshold): Determines when TCP switches from exponential to linear growth.
  • RTT (Round Trip Time): Time taken for a packet to reach destination and its ACK to return.
  • MSS (Maximum Segment Size): Maximum amount of data TCP can send in one segment.

Concept of Window Size

1. What is Window Size?

The window size in TCP defines how much data can be sent before requiring an acknowledgment (ACK) from the receiver. It ensures that the sender does not overwhelm the receiver or the network by sending too much data at once.

2. Types of TCP Windows

  • Congestion Window (cwnd): Maintained by the sender and adjusts dynamically based on network congestion. It increases or decreases depending on ACKs and packet loss.
  • Receiver Window (rwnd): Maintained by the receiver and represents how much data it can buffer. It is sent in every ACK to inform the sender of available space.

3. Effective Window Size

The actual number of bytes the sender can transmit at any given time is limited by the smaller of the two windows:

Effective Window = min(cwnd, rwnd)

This ensures that the sender respects both the receiver’s capacity and the network’s congestion state.

4. Role in Congestion Control

During the connection, TCP continuously updates cwnd:

  • In Slow Start — cwnd doubles every RTT (exponential growth).
  • In Congestion Avoidance — cwnd increases linearly by 1 MSS per RTT.
  • When packet loss occurs — cwnd is reduced, often to half its value or back to 1 MSS.
This adaptive adjustment of window size helps TCP maintain a balance between throughput and congestion control.

5. Example

Suppose:

  • cwnd = 8 MSS
  • rwnd = 6 MSS
Then, the sender can send only 6 MSS worth of data before waiting for ACKs, because the receiver window is smaller and limits the flow.

Flow Summary

Start

cwnd = 1 MSS

Slow Start

Exponential increase of cwnd

Threshold Reached

cwnd = ssthresh

Congestion Avoidance

Linear increase of cwnd

Packet Loss Detected

Reduce cwnd & enter Fast Recovery

Resume

Return to congestion avoidance

Lab Resources

Lab 07 Task

Download PDF