One page at a time, or all 500 at once
Think in bytes rather than packets or link speed. The receive window, often written rwnd, protects space at the receiver. The congestion window, or cwnd, is maintained by the sender to limit pressure on the network. A large receive window does not mean the path is uncongested, and a small congestion window does not mean the receiving laptop has run out of memory.
On small screens, swipe sideways or focus the diagram and use the arrow keys.
Here rwnd is 6000 bytes and cwnd is 4000 bytes. With 3000 bytes still unacknowledged, the sender has room for at most 1000 more within that simple budget. Other rules may restrict sending further. A window describes a byte allowance, not a rate in megabits per second. Round-trip time, loss and application behaviour also affect the throughput you observe.
Suppose you send a long letter one page at a time and wait for a “got it” reply after every page before you post the next. It would take far too long. Now suppose you post all 500 pages at once to a friend with a tiny letterbox. Most of them would end up in the rain. TCP needs a middle way: send several pieces at once, but never more than the other side can accept.
The receiver decides how much can be in flight
The window is the number of bytes a sender may send before it must stop and wait for an acknowledgement. The receiver sets it: every segment it sends back carries a window size field that says “I have this much free buffer space right now”. A buffer is memory where received data waits until the application reads it.
Device key: Sender (server) · Receiver (laptop)
Lines show the example’s network connections. Thick links: uplinks/WAN, as labelled. The coloured path and envelope follow the current step; its text identifies the sender, receiver and traffic type.
- 1. Send the whole window. The receiver offered 5840 bytes, so the sender sends four 1460-byte segments without waiting.
- 2. ACK and a new window. The receiver acknowledges all four segments and says it still has 5840 bytes free.
- 3. The window slides forward. The sender sends the next four segments. This is why it is called a sliding window.
- 4. Receiver full. The application is slow to read the data, so the window drops to zero. The sender pauses until a larger window is advertised.
Flow control, zero windows and window scaling
Using the window to protect the receiver is called flow control. A fast server cannot flood a slow phone, because the phone keeps shrinking the window as its buffer fills. A window of 0 means “stop sending”. The sender then sends a tiny window probe from time to time to check whether space has become free.
The window field is only 16 bits, so on its own it can describe at most 65,535 bytes. On fast, long-distance links that is far too small. The window scale option, agreed in the handshake, multiplies the value by a power of two, allowing windows of up to about 1 GB.
The window is often the real limit on a single transfer over a long link. A sender can push at most one window per round trip, so a 64 KB window on a path with a 100 ms round trip tops out at roughly 5 Mbit/s, however fast the link is. When one file copy between distant sites crawls while the link is mostly idle, the window is a good first suspect.
Congestion control: the sender's own limit
Flow control protects the receiver. But the network in between can also be overloaded, for example when a router's queue is full. So the sender keeps a second limit of its own, the congestion window. It may only have as much data in flight as the smaller of the two windows allows.
| Flow control | Congestion control | |
|---|---|---|
| Protects | The receiver | The network path |
| Who sets the limit | The receiver, in the window field | The sender, based on what it observes |
| Signal to slow down | A smaller window is advertised | Lost segments (or ECN marks) |
The sender changes its congestion window in phases:
- Slow start: a new connection starts small and roughly doubles its window every round trip, to find the available speed quickly.
- Congestion avoidance: after a threshold, the growth becomes more cautious. The exact growth rule depends on the congestion-control algorithm; classic Reno uses additive growth.
- Back off: when a segment is lost, the sender may treat it as a congestion signal and reduce its sending allowance. Different algorithms and loss-recovery conditions use different responses; this is not one universal percentage. A retransmission timeout can require a much more conservative restart.
Why backing off on loss keeps a shared link usable
Waiting for an ACK after every segment wastes the time the data spends in flight; a window keeps the link busy. Letting the receiver set the window prevents its buffer from overflowing. Backing off on loss means that when many connections share a busy link, they all slow down a little and share it fairly, instead of all pushing until nothing gets through. Sharing is not guaranteed to be equal: round-trip times and algorithms also matter. UDP has no built-in congestion control, but a responsible application or protocol layered over UDP must manage its traffic; it need not send at a fixed unlimited rate.
Reading window sizes in show tcp
On a Cisco router, show tcp shows the windows for each TCP session that ends on the router, here an SSH session. The output below is based on Cisco documentation, not captured from a lab device, and is shortened.
R1#show tcp Stand-alone TCP connection to host 10.1.1.50 Connection state is ESTAB, I/O status: 1, unread input bytes: 0 Local host: 10.1.1.1, Local port: 22 Foreign host: 10.1.1.50, Foreign port: 51544 iss: 2310155321 snduna: 2310158007 sndnxt: 2310158007 irs: 1754312908 rcvnxt: 1754313934 sndwnd: 64128 scale: 7 maxrcvwnd: 4128 rcvwnd: 4128 scale: 0 delrcvwnd: 0 SRTT: 98 ms, RTTO: 300 ms, RTV: 202 ms, KRTT: 0 ms Datagrams (max data segment is 1460 bytes):
sndwnd is the window the PC (10.1.1.50) advertised. It is one constraint, not permission to send 64,128 new bytes regardless of data already outstanding or congestion control. rcvwnd is the window the router advertises back. iss and irs are the two initial sequence numbers from the handshake (sent and received). The last line shows the MSS: 1460 bytes.Test yourself on windowing
A phone downloading a large file is busy, and its TCP stack advertises a window of 0. What does the server do?
A receiver advertises a 64 KB window, but the sender's congestion window is only 16 KB because of recent loss. How much unacknowledged data can the sender have in flight?
In this classic loss-based TCP example without an ECN signal, which listed event can cause the sender to reduce its congestion window?
Technical references
RFC 9293: base TCP header, connection state, sequence space and delivery; RFC 5681: classic congestion control and fast retransmit.