Menu

Earn Premium with Referrals

Invite your friends and earn Premium rewards through our referral program.

See how it works and start inviting friends.

Reliability, Flow & Congestion Control
CN

Reliability, Flow & Congestion Control

How TCP manages traffic and ensures every byte arrives: Sliding Windows and AIMD explained.

TCP provides three critical services beyond basic data transport: reliability, flow control, and congestion control.

Reliability

  • Checksums — every segment includes a checksum. Receiver drops corrupted segments.
  • ACKs — receiver sends acknowledgment for bytes received. Cumulative ACK = “I received up to byte N.”
  • Retransmission — sender re-sends if ACK not received before timeout (Retransmission Timeout — RTO). Also: Fast Retransmit (send 3 duplicate ACKs → retransmit immediately, don’t wait for timeout).
  • Sequence numbers — receiver reorders out-of-order segments.

Flow Control (Protecting the Receiver)

The receiver advertises its available buffer space via the Advertised Window field in TCP headers. The sender must not exceed this window.

Sender                      Receiver
  ├── segment 1 ──────────→  [buffer: 10KB free]
  ├── segment 2 ──────────→  
  ├── segment 3 ──────────→  
  │←── ACK(win=5KB) ──────  "Received up to byte 3000, 5KB free now"

If the receiver’s buffer fills up (Advertised Window = 0), the sender stops and periodically sends Window Probes to check if space opened up.

Congestion Control (Protecting the Network)

The sender maintains a Congestion Window (cwnd) — it can send up to min(cwnd, advertised_window) bytes.

Slow Start

  • Start with cwnd = 1 segment (MSS)
  • Double cwnd every RTT (exponential growth)
  • Continue until packet loss detected or slow start threshold (ssthresh) reached

Congestion Avoidance (AIMD)

  • Additive Increase: cwnd += 1 MSS per RTT (linear growth)
  • Multiplicative Decrease: on packet loss, cwnd = cwnd/2; ssthresh = cwnd/2
PhaseGrowthTrigger to change
Slow StartExponential (double per RTT)Loss or ssthresh
Congestion AvoidanceLinear (+1 per RTT)Loss → cut cwnd in half

Q: What’s the difference between Flow Control and Congestion Control?

A: Flow control protects the receiver — prevents the sender from overflowing the receiver’s buffer. Congestion control protects the network — prevents the sender from overloading intermediate routers/switches.

Q: Explain AIMD (Additive Increase Multiplicative Decrease).

A: If the network is healthy, TCP increases the congestion window by 1 segment per RTT (slow linear growth). If packet loss is detected (congestion), TCP cuts the window by 50% (sharp reduction). This gives TCP its characteristic “sawtooth” throughput pattern.

Q: Why is the sliding window better than Stop-and-Wait?

A: Stop-and-Wait keeps the link idle while waiting for each ACK. The sliding window allows multiple outstanding segments, keeping the link fully utilized. Throughput becomes window_size / RTT instead of segment_size / RTT.

Q: How does Fast Retransmit work?

A: If the receiver gets an out-of-order segment, it immediately sends a duplicate ACK for the last byte it received in order. After 3 duplicate ACKs, the sender retransmits the missing segment without waiting for the retransmission timer.

My Private Notes

Notes are auto-saved locally to this device.