The Data Link Layer

the sliding window

Think of a long row of numbered packages and a moving frame that highlights just a few of them at a time — the ones you are currently allowed to ship before getting confirmations. As the earliest highlighted package is confirmed delivered, the frame slides forward to reveal the next one. That moving frame is the sliding window: the set of sequence numbers a sender may have in flight (unacknowledged) at any moment, which advances as acknowledgments come back.

Both sender and receiver keep a window. The sender's window holds the frames it has sent but not yet had acknowledged; when the lowest-numbered frame is ACKed, the window slides up and the sender may send a new frame at the top. The receiver's window describes which incoming sequence numbers it is currently willing to accept. The window's SIZE caps how much data can be unacknowledged at once, and that single number controls throughput: too small and the link sits idle waiting for ACKs (the stop-and-wait problem); large enough and the link stays continuously full.

The right window size is tied to the bandwidth-delay product — the link's data rate multiplied by its round-trip time, which is how many bits can be in transit at once. To keep a pipe full you want a window at least that large; this is why a fast, long-distance link (high bandwidth, high delay) needs a big window to perform well, and why an undersized window can throttle even a fast connection. Both go-back-N and selective repeat are sliding-window protocols, and TCP uses sliding windows for both flow control and congestion control. A common confusion: the window limits OUTSTANDING data, not the total amount you may ever send.

A 1 Gbps link with a 50 ms round-trip time has a bandwidth-delay product of about 6.25 MB. A 64 KB window would leave the link more than 99% idle; you need roughly a 6 MB window to keep this fast, far link continuously full.

Window size must match the bandwidth-delay product to keep a fast, long link busy.

The window bounds unacknowledged (in-flight) data, not total data. Size it to the bandwidth-delay product: too small starves a fast, high-delay link no matter how much raw bandwidth it has — adding bandwidth alone will not help if the window is the bottleneck.

Also called
windowingsliding-window protocol視窗滑動