Bird
Raised Fist0
Computer Networksknowledge~10 mins

TCP congestion control in Computer Networks - Step-by-Step Execution

Choose your learning style10 modes available
Concept Flow - TCP congestion control
Start Connection
↓
Initialize cwnd = 1 MSS
↓
Send packets
↓
Receive ACKs?
No→Timeout or Loss Detected
↓
Reduce cwnd (slow start or congestion avoidance)
↓
Increase cwnd
↓
Check cwnd vs ssthresh
↓
Slow Start
↓
Repeat Sending Packets
TCP congestion control starts with a small window, increases it when ACKs arrive, and reduces it when packet loss or timeout occurs, switching between slow start and congestion avoidance phases.
Execution Sample
Computer Networks
cwnd = 1  # start with 1 MSS
while sending data:
    send packets up to cwnd
    if ACK received:
        if cwnd < ssthresh:
            cwnd *= 2  # slow start
        else:
            cwnd += 1  # congestion avoidance
This code shows how TCP increases its congestion window size based on ACKs to control network congestion.
Analysis Table
Stepcwnd (MSS)ssthresh (MSS)EventActionResulting cwnd
118Start connectionInitialize cwnd and ssthreshcwnd=1, ssthresh=8
218ACK receivedcwnd < ssthresh, slow start: cwnd *= 2cwnd=2
328ACK receivedcwnd < ssthresh, slow start: cwnd *= 2cwnd=4
448ACK receivedcwnd < ssthresh, slow start: cwnd *= 2cwnd=8
588ACK receivedcwnd >= ssthresh, congestion avoidance: cwnd += 1cwnd=9
698ACK receivedcwnd >= ssthresh, congestion avoidance: cwnd += 1cwnd=10
7108Packet loss detectedTimeout: ssthresh = cwnd/2, cwnd=1 (slow start restart)ssthresh=5, cwnd=1
815ACK receivedcwnd < ssthresh, slow start: cwnd *= 2cwnd=2
925ACK receivedcwnd < ssthresh, slow start: cwnd *= 2cwnd=4
1045ACK receivedcwnd < ssthresh, slow start: cwnd *= 2cwnd=8
1185ACK receivedcwnd >= ssthresh, congestion avoidance: cwnd += 1cwnd=9
1295No more data or stopTransmission endsFinal cwnd=9
💡 Transmission ends after step 12 or when no more data to send.
State Tracker
VariableStartAfter 1After 2After 3After 4After 5After 6After 7After 8After 9After 10After 11Final
cwnd12488910124899
ssthresh8888888555555
Key Insights - 3 Insights
Why does cwnd double during slow start but only increase by 1 during congestion avoidance?
During slow start (cwnd < ssthresh), TCP increases cwnd exponentially (doubling) to quickly find the network capacity (see steps 2-4). After reaching ssthresh, it increases linearly by 1 MSS per RTT to avoid congestion (steps 5-6).
What happens to cwnd and ssthresh when packet loss is detected?
When packet loss occurs (step 7), TCP assumes congestion and reduces ssthresh to half of current cwnd, then resets cwnd to 1 MSS to restart slow start, controlling congestion.
Why does cwnd sometimes stay the same after an ACK?
In this simplified trace, cwnd always changes on ACKs, but in real TCP, if ACKs are delayed or duplicate, cwnd may not increase immediately. Here, each ACK triggers an increase as shown in the table.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the value of cwnd after step 4?
A8
B4
C2
D1
💡 Hint
Check the 'Resulting cwnd' column at step 4 in the execution_table.
At which step does TCP detect packet loss and reduce cwnd?
AStep 6
BStep 7
CStep 9
DStep 11
💡 Hint
Look for the 'Packet loss detected' event in the execution_table.
If ssthresh was initially 4 instead of 8, what would cwnd be after the second ACK?
A4
B2
C1
D8
💡 Hint
Refer to variable_tracker and how cwnd doubles during slow start until it reaches ssthresh.
Concept Snapshot
TCP congestion control manages data flow to avoid network overload.
Starts with cwnd=1 MSS, increases cwnd exponentially in slow start until ssthresh.
After ssthresh, cwnd grows linearly (congestion avoidance).
On packet loss, ssthresh halves and cwnd resets to 1 MSS.
This cycle repeats to balance speed and network safety.
Full Transcript
TCP congestion control is a method to prevent too much data from overwhelming the network. It begins by sending a small amount of data, called the congestion window or cwnd, starting at 1 maximum segment size (MSS). When acknowledgments (ACKs) come back, TCP increases cwnd quickly by doubling it during the slow start phase until it reaches a threshold called ssthresh. After that, it grows cwnd more slowly by adding 1 MSS per round trip time, called congestion avoidance. If TCP detects packet loss or a timeout, it assumes the network is congested, so it cuts ssthresh in half and resets cwnd to 1 MSS to start slow start again. This process repeats, balancing sending speed with network capacity to avoid congestion and packet loss.

Practice

(1/5)
1. What is the main purpose of TCP congestion control in computer networks?
easy
A. To prevent network overload by adjusting data sending rates
B. To encrypt data packets for security
C. To assign IP addresses to devices
D. To increase the size of data packets

Solution

  1. Step 1: Understand TCP congestion control role

    TCP congestion control manages how much data is sent to avoid overwhelming the network.
  2. Step 2: Compare options with this role

    Only To prevent network overload by adjusting data sending rates describes adjusting sending rates to prevent overload, matching the purpose.
  3. Final Answer:

    To prevent network overload by adjusting data sending rates -> Option A
  4. Quick Check:

    TCP congestion control = prevent overload [OK]
Hint: Focus on network traffic management, not security or addressing [OK]
Common Mistakes:
  • Confusing congestion control with encryption
  • Thinking it assigns IP addresses
  • Believing it increases packet size
2. Which of the following is a correct description of the TCP Slow Start algorithm?
easy
A. It ignores network feedback and sends data at a fixed rate
B. It immediately sends the maximum possible data to the network
C. It decreases the data sending rate after every packet sent
D. It gradually increases the data sending rate to avoid congestion

Solution

  1. Step 1: Recall Slow Start behavior

    Slow Start begins with a low sending rate and increases it gradually to detect network capacity.
  2. Step 2: Match options to this behavior

    It gradually increases the data sending rate to avoid congestion correctly states the gradual increase to avoid congestion, unlike others.
  3. Final Answer:

    It gradually increases the data sending rate to avoid congestion -> Option D
  4. Quick Check:

    Slow Start = gradual increase [OK]
Hint: Slow Start means start slow, then speed up carefully [OK]
Common Mistakes:
  • Thinking Slow Start sends max data immediately
  • Believing it decreases rate after each packet
  • Assuming it ignores network feedback
3. Consider this simplified TCP congestion window size sequence during Slow Start: it starts at 1, then doubles each round (1, 2, 4, 8, ...). What will be the window size after 4 rounds?
medium
A. 16
B. 8
C. 4
D. 32

Solution

  1. Step 1: Understand doubling pattern

    The window size doubles each round: start at 1, then 2, 4, 8, 16...
  2. Step 2: Calculate after 4 rounds

    Start (0 rounds): 1, After 1st round: 2, 2nd: 4, 3rd: 8, 4th: 16.
  3. Final Answer:

    16 -> Option A
  4. Quick Check:

    1x2⁴ = 16 [OK]
Hint: Double window size each round; 2^4 = 16 [OK]
Common Mistakes:
  • Counting rounds incorrectly (off by one)
  • Choosing 8 instead of 16
  • Confusing doubling with adding
4. A TCP connection uses Slow Start but never reduces its congestion window size after packet loss. What problem will most likely occur?
medium
A. The connection will send data too slowly
B. The connection will close immediately
C. The connection will ignore congestion and cause network overload
D. The connection will encrypt data incorrectly

Solution

  1. Step 1: Understand congestion window reduction role

    Reducing window size after packet loss helps avoid network overload by slowing sending rate.
  2. Step 2: Analyze effect of not reducing window

    If window size never reduces, the sender keeps sending too much data, causing congestion and overload.
  3. Final Answer:

    The connection will ignore congestion and cause network overload -> Option C
  4. Quick Check:

    No window reduction = overload risk [OK]
Hint: Always reduce window on loss to prevent overload [OK]
Common Mistakes:
  • Thinking it causes slow sending
  • Assuming connection closes automatically
  • Confusing congestion control with encryption
5. In a network with frequent packet loss, which TCP congestion control strategy best balances throughput and congestion avoidance?
hard
A. Use Slow Start only, ignoring packet loss
B. Use Fast Retransmit and Fast Recovery to quickly recover from losses
C. Send data at maximum rate regardless of network state
D. Disable congestion control to improve speed

Solution

  1. Step 1: Identify strategies for packet loss

    Fast Retransmit and Fast Recovery help detect and recover from packet loss quickly without restarting Slow Start.
  2. Step 2: Evaluate options for balancing throughput and congestion

    Use Fast Retransmit and Fast Recovery to quickly recover from losses uses these algorithms to maintain good speed while avoiding overload, unlike others that ignore loss or disable control.
  3. Final Answer:

    Use Fast Retransmit and Fast Recovery to quickly recover from losses -> Option B
  4. Quick Check:

    Fast Retransmit + Recovery = balance throughput & avoid congestion [OK]
Hint: Fast Retransmit + Recovery handle loss efficiently [OK]
Common Mistakes:
  • Ignoring packet loss effects
  • Assuming max rate always best
  • Disabling congestion control harms network
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard