TCP congestion control in Computer Networks - Time & Space Complexity
When studying TCP congestion control, it is important to understand how the time to send data changes as network conditions vary.
We want to know how the control process scales as more data is sent and network congestion changes.
Analyze the time complexity of the following simplified TCP congestion control steps.
cwnd = 1 // congestion window size
while data_to_send > 0:
send min(cwnd, data_to_send) packets
wait for ACKs
if no loss detected:
cwnd += 1 // increase window size
else:
cwnd = cwnd / 2 // reduce window size
data_to_send -= min(cwnd, data_to_send)
This code simulates how TCP adjusts the amount of data it sends based on network feedback.
Identify the loops, recursion, array traversals that repeat.
- Primary operation: The while loop that sends packets and adjusts the congestion window.
- How many times: The loop runs until all data is sent, repeating many times depending on network conditions.
As the amount of data to send grows, the number of loop cycles increases roughly in proportion to the data size divided by the congestion window.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 packets | About 10 cycles or fewer due to window growth |
| 100 packets | More than 10 cycles but less than 100 due to window increasing |
| 1000 packets | Many cycles but fewer than 1000 because window grows over time |
Pattern observation: The number of steps grows slower than the data size because the congestion window increases, allowing more data sent per cycle.
Time Complexity: O(\sqrt{n})
This means the time to send all data grows roughly proportional to the square root of the amount of data, adjusted by how the congestion window changes.
[X] Wrong: "TCP congestion control always sends data at a fixed rate regardless of network conditions."
[OK] Correct: TCP changes its sending rate based on feedback, so the time to send data depends on network congestion and window size.
Understanding how TCP congestion control scales with data size shows your grasp of real network behavior and adaptive algorithms, a useful skill in many tech roles.
"What if the congestion window increased by 2 packets each cycle instead of 1? How would the time complexity change?"
Practice
Solution
Step 1: Understand TCP congestion control role
TCP congestion control manages how much data is sent to avoid overwhelming the network.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.Final Answer:
To prevent network overload by adjusting data sending rates -> Option AQuick Check:
TCP congestion control = prevent overload [OK]
- Confusing congestion control with encryption
- Thinking it assigns IP addresses
- Believing it increases packet size
Solution
Step 1: Recall Slow Start behavior
Slow Start begins with a low sending rate and increases it gradually to detect network capacity.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.Final Answer:
It gradually increases the data sending rate to avoid congestion -> Option DQuick Check:
Slow Start = gradual increase [OK]
- Thinking Slow Start sends max data immediately
- Believing it decreases rate after each packet
- Assuming it ignores network feedback
Solution
Step 1: Understand doubling pattern
The window size doubles each round: start at 1, then 2, 4, 8, 16...Step 2: Calculate after 4 rounds
Start (0 rounds): 1, After 1st round: 2, 2nd: 4, 3rd: 8, 4th: 16.Final Answer:
16 -> Option AQuick Check:
1x2⁴ = 16 [OK]
- Counting rounds incorrectly (off by one)
- Choosing 8 instead of 16
- Confusing doubling with adding
Solution
Step 1: Understand congestion window reduction role
Reducing window size after packet loss helps avoid network overload by slowing sending rate.Step 2: Analyze effect of not reducing window
If window size never reduces, the sender keeps sending too much data, causing congestion and overload.Final Answer:
The connection will ignore congestion and cause network overload -> Option CQuick Check:
No window reduction = overload risk [OK]
- Thinking it causes slow sending
- Assuming connection closes automatically
- Confusing congestion control with encryption
Solution
Step 1: Identify strategies for packet loss
Fast Retransmit and Fast Recovery help detect and recover from packet loss quickly without restarting Slow Start.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.Final Answer:
Use Fast Retransmit and Fast Recovery to quickly recover from losses -> Option BQuick Check:
Fast Retransmit + Recovery = balance throughput & avoid congestion [OK]
- Ignoring packet loss effects
- Assuming max rate always best
- Disabling congestion control harms network
Ready to prove it?
Pass the test and this pattern moves unknown
