Explain TCP congestion control: slow start, congestion avoidance, fast retransmit and fast recovery.
HardConceptFlow & Congestion Control
Answer
TCP congestion control lets each sender discover how much the network can carry by increasing its rate until loss occurs, then backing off. The sender keeps a congestion window (cwnd, counted here in segments) and a threshold, ssthresh, where cautious growth begins.
- Slow start:
cwndstarts small (1 segment in textbooks, about 10 in modern systems) and grows by one segment per ACK, which doubles it every RTT until it reachesssthresh. - Congestion avoidance: above
ssthresh,cwndgrows by only about one segment per RTT, a linear (additive) increase. - Fast retransmit: three duplicate ACKs signal that one segment was lost but later ones arrived, so the sender resends it without waiting for a timeout.
- Fast recovery (TCP Reno):
ssthresh = cwnd / 2andcwndcontinues from that halved value, not from 1. A timeout is treated as more serious:ssthresh = cwnd / 2,cwnd = 1, and slow start begins again.
Example: ssthresh = 16, starting from cwnd = 1:
RTT: 1 2 3 4 5 6 7 8 | 3 dup ACKs | 9 10
cwnd: 1 2 4 8 16 17 18 19 | ssthresh=9 | 9 10
Growth is exponential up to 16, then linear. At cwnd = 19, three duplicate ACKs set ssthresh = 9 (19 ÷ 2, rounded down), and linear growth resumes from 9.