This is a great question asking me to distinguish between TCP receive window (rwnd) and congestion window (cwnd). The student has already provided the key insight, so let me expand on this with clear explanations and examples.
Let me structure this comprehensively:
-
TCP Receive Window (rwnd)
- Definition and purpose
- How it's advertised
- Flow control mechanism
-
Congestion Window (cwnd)
- Definition and purpose
- How it evolves
- Congestion control mechanism
-
The sending limit formula
- Why it's the minimum of both
- Practical implications
-
Examples and scenarios
Let me provide detailed explanations:
TCP Receive Window (rwnd) - Flow Control
What it is:
- The amount of data the receiver is willing to accept
- Advertised by the receiver to the sender in every TCP ACK
- Indicates available buffer space at the receiver
- Static or dynamic based on application consuming data from buffer
Purpose:
- Prevents the sender from overwhelming the receiver's buffer
- Receiver says: "I can handle up to X bytes without my buffer overflowing"
- If application isn't consuming data from the buffer, rwnd shrinks
How it works:
- Receiver maintains a buffer for incoming data
- rwnd = buffer_size - (data_received - data_consumed_by_app)
- Receiver includes rwnd value in TCP header of ACKs
- If rwnd becomes 0, sender must stop sending (enters persist mode)
Example:
Receiver has 64KB buffer
Application reads 10KB every second
If sender sends 20KB/sec, rwnd will decrease
When rwnd reaches 0, sender must wait
Congestion Window (cwnd) - Congestion Control
What it is:
-
Internal variable at the sender
-
Sender's estimate of how much data the network can handle
-
NOT advertised to receiver; receiver doesn't know about it
-
Inferred by observing packet loss and round-trip time changes
Purpose:
- Prevents the sender from overwhelming the network
- Sender says: "I estimate the network can handle X bytes in flight"
- Adapts to network conditions (packet losses indicate congestion)
How it works:
- Starts small (typically 10 segments or 14.6KB in modern TCP)
- Increases during slow start and congestion avoidance phases
- Decreases sharply upon detecting congestion (packet loss, ECN)
- Algorithms: Tcp Reno, Cubic, BBR, Westwood, etc.
Example:
Network can handle ~
100KB/sec
If sender transmits faster, packets get dropped
Lost packets detected → cwnd reduced
TCP adjusts sending rate based on packet loss signals
Sending Limit Formula
Key Principle:
Data to send ≤ min(cwnd, rwnd) - (data_sent - data_acked)
Or thinking about it as window sizes:
Effective sender window = min(cwnd, rwnd)
Why minimum?
- If rwnd < cwnd: Receiver buffer is the bottleneck → respect rwnd
- If cwnd < rwnd: Network is the bottleneck → respect cwnd
- Whichever is smaller is the limiting factor
Side-by-side Comparison
| Aspect | Receive Window (rwnd) | Congestion Window (cwnd) |
|--------|----------------------|
-------------------------|
| Managed by | Receiver | Sender |
| Communicated by | ACKs | Not communicated |
| Represents | Receiver buffer capacity | Network capacity estimate |
| Purpose | Flow control | Congestion control |
| Based on | Buffer space available | Packet loss/RTT observations |
| Initial value | Advertised by receiver | ~10 segments (14.6KB) |
| Can be 0 | Yes (buffer full) | Not really (minimum 1 MSS) |
| Scaling | Negotiated via window scale option | Cannot scale |
Practical Scenarios
Scenario 1: Slow Receiver
Remote receiver with 65KB buffer, slow application
Receiver advertises: rwnd = 10KB (buffer mostly full)
Sender has: cwnd = 50KB (network has capacity)
Result: Sender limited to 10KB (min of both)
Reason: Don't overwhelm receiver's buffer
Scenario 2: Congested Network
Receiver with 1MB buffer, fast application
Receiver advertises: rwnd = 1MB (buffer empty)
Sender estimates: cwnd = 100KB (network congested, many losses)
Result: Sender limited to 100KB (min of both)
Reason: Don't overwhelm the network
Scenario 3: Both Plentiful
Fast local network, fast receiver
Receiver advertises: rwnd = 1MB
Sender estimates: cwnd = 500KB (network fast)
Result: Sender can send ~500KB (min of both)
Reason: Receiver buffer has capacity and network can handle it
The sender always respects whichever constraint is tighter—if the receiver's buffer is the bottleneck, flow control dominates; if network congestion is the issue, congestion control takes precedence. Both windows work together to determine the actual sending rate.
Flow Control vs Congestion Control
Flow control protects the receiver by advertising available buffer space, while congestion control protects the network by estimating available capacity. The receiver explicitly signals rwnd through TCP headers, whereas cwnd exists only at the sender and adapts based on packet loss and RTT feedback. Flow control is deterministic and can completely halt transmission, but congestion control allows some loss while preventing network collapse.
TCP Window Fields
The receiver communicates rwnd in the TCP header's Window Size field (16 bits, scalable), while cwnd never appears on the wire—it's purely a sender-side mechanism. As the application consumes data, rwnd can change every round trip, whereas cwnd evolves according to the congestion control algorithm through phases like slow start and congestion avoidance.
The Binding Constraint
The sender must honor whichever window is smaller at any moment. Respecting only rwnd would let senders flood the network with traffic, while ignoring rwnd would overflow receiver buffers. Both constraints are essential—one ensures the receiver doesn't get overwhelmed, the other prevents network congestion that would harm all users.
TCP Receive Window vs Congestion Window
Your summary captures the key distinction perfectly. Here's a detailed breakdown:
Receive Window (rwnd) — Flow Control
| Aspect | Details |
|---|
| Managed by | Receiver |
| Represents | Available buffer space at receiver |
| Communicated via | TCP ACK packets (advertised each RTT) |
| Purpose | Prevent overwhelming receiver's buffer |
| Calculation | rwnd = buffer_size - (bytes_received - bytes_consumed_by_app) |
| Can reach zero | Yes → sender must pause |
Example:
Receiver buffer: 64 KB total
Data in buffer: 50 KB (app consuming slowly)
rwnd advertised: 14 KB ← only this much more accepted
Congestion Window (cwnd) — Congestion Control
| Aspect | Details |
|---|
| Managed by | Sender alone |
| Represents | Sender's estimate of safe network capacity |
| Communicated via | NOT communicated (internal state) |
| Purpose | Prevent overwhelming the network |
| Starts at | ~10–14.6 KB (IW10) |
| Changes based on | Packet losses, ACK arrival rate, RTT changes |
Example:
Network can sustain ~100 KB/sec
Sender observes packet losses
cwnd reduced by 50% → sender backs off
Effective Sending Limit
bytes_in_flight = min(cwnd, rwnd) - (bytes_sent - bytes_acked)
Why the Minimum?
| Scenario | Action | Reason |
|---|
rwnd = 10 KB, cwnd = 100 KB | Send ≤ 10 KB | Receiver buffer is bottleneck |
rwnd = 100 KB, cwnd = 10 KB | Send ≤ 10 KB | Network is bottleneck |
| Both small | Send ≤ smaller | Most constraining factor wins |
Visual Comparison
SENDER RECEIVER
┌─────────────────┐ ┌──────────────┐
│ State at │ │ Buffer │
│ sender │◄──ACKs + rwnd────│ Status │
│ │ │ │
│ cwnd ──────┐ │ └──────────────┘
│ (estimated │ │
│ network │ │
│ capacity) └──→├──DATA──────────►
│ │
│ Limit = │
│ min(cwnd,rwnd) │
└─────────────────┘
Practical Scenario: Slow Receiver
Receiver application paused (reading data slowly):
• rwnd drops to 5 KB (buffer nearly full)
• cwnd is still 100 KB (network fine)
Sender limit = min(5 KB, 100 KB) = 5 KB
Result: Sender throttled by slow receiver, not network
Key Differences Summary
| Receive Window | Congestion Window |
|---|
| Sender respects receiver's capacity? | ✓ YES (rwnd) | ✓ YES (cwnd) |
| Determined by | Receiver's buffer | Network's health |
| Visible to receiver? | Receiver creates it | Receiver never sees it |
| Reaches zero regularly? | Yes (can stall) | Rarely (recovers quickly) |
| Negotiated at connection setup? | Yes | No |
Why Both Matter
Without rwnd: Sender would crash receiver's memory even on fast networks
Without cwnd: Senders would collapse the internet with congestion collapse
Together they enable: High-speed transfers with no receiver buffer overflow and no network congestion.