Sub topic 7
Flow Control with the Receiver Window
Prerequisites and the core idea
Assume you know the layered network model, TCP sequence and acknowledgement numbers, and the meaning of round-trip time (RTT). This chapter focuses on flow control, which prevents a fast sender from overwhelming a slow receiver.
The receiver stores arriving bytes in a buffer. TCP reports the amount of unused buffer space in the receive window, written as rwnd. The receiver advertises this value in the Window field of its ACK segments.
The sender tracks bytes that it has sent but the receiver has not yet acknowledged. These bytes must fit within the advertised window:
last_byte_sent - last_byte_acknowledged <= rwnd
The receiver window is different from the congestion window, cwnd. The congestion window protects the network from overload. The receive window protects the receiving host. Therefore, the sender's usable window is:
usable window = min(rwnd, cwnd)
Sliding-window operation
TCP does not wait for one byte or one segment to be acknowledged before sending the next. It can send a range of bytes called the sender window. As ACKs arrive, the left edge advances, and the sender can transmit more data.
Suppose the receiver has acknowledged every byte through byte 999 and advertises rwnd = 3000. The sender may send bytes 1000 through 3999. If the receiver then acknowledges through byte 1999 and advertises 2000 bytes of free space, the allowed range becomes bytes 2000 through 3999.
The advertised window is measured in bytes, not in packets. TCP sequence numbers also count bytes. If a segment begins with sequence number 1000 and carries 500 bytes, the next expected sequence number is 1500.
Window and throughput calculations
If the sender is limited only by a window of W bytes and the RTT is T seconds, the approximate throughput is:
throughput = W / T
For example, with a 12,000-byte receive window and an RTT of 0.06 seconds:
12,000 / 0.06 = 200,000 bytes/second
In bits per second, this is 1,600,000 bits/second. If the path bandwidth is lower than this value, bandwidth becomes the limiting factor. In general:
throughput <= min(path bandwidth, usable window / RTT)
| Quantity | Meaning |
|---|---|
| `rwnd` | Free buffer space advertised by the receiver |
| `cwnd` | Sender's estimate of safe network capacity |
| `min(rwnd, cwnd)` | Maximum usable amount of unacknowledged data |
| `RTT` | Time for data and its ACK to complete a round trip |
Common errors
- Using
rwnd + cwndinstead ofmin(rwnd, cwnd). - Treating the window as a number of segments when the problem gives bytes.
- Forgetting to convert bytes per second to bits per second by multiplying by 8.
- Confusing RTT with one-way propagation delay.
- Assuming an ACK always increases the window. The receiver may advertise a smaller window because its buffer is filling.
If the receiver advertises a zero window, the sender must stop normal data transmission. TCP uses window probes so the sender can discover when the receiver has space again.
Exercise
A TCP connection has rwnd = 8,000 bytes, cwnd = 12,000 bytes, and RTT = 40 ms. What is the maximum window-limited throughput in bits per second?
Show answer
The usable window is min(8,000, 12,000) = 8,000 bytes. Throughput is 8,000 / 0.04 = 200,000 bytes/second, or 1,600,000 bits/second.