Saturday, 7 November 2026

TCP Sliding Window Protocol & Flow Control: rwnd, cwnd, ACKs, Numericals and MCQs

Computer Networks · Transport Layer · Lesson 07

TCP Sliding Window Protocol and Flow Control — Receiver Window, Cumulative ACKs, Lost Segments & Numericals

Understand exactly which bytes can be sent, which bytes must wait, and how TCP recovers from gaps. This tutorial follows Tanenbaum and Forouzan with exam-focused explanations, original responsive diagrams and interactive demonstrations.

APPSC Assistant ProfessorUGC NETGATE CSRGUKT LecturerTanenbaum + Forouzan

TCP sliding window is a byte-oriented, dynamically sized mechanism that permits multiple bytes to be in transit while keeping the sender within the receiver's available buffer space. In practice, the sender's transmission is limited by both the receive window (rwnd) and the congestion window (cwnd).

1. What Is the TCP Sliding Window Protocol?

TCP uses a sliding window to allow a sender to transmit more than one piece of data before waiting for an acknowledgement. Instead of a stop-and-wait exchange, TCP keeps a pipeline of bytes in flight. As acknowledgements arrive, the left boundary of the send window advances and new data can become eligible for transmission.

Byte oriented

TCP numbers individual bytes. A single segment may cover many consecutive byte numbers.

Variable sized

The permitted window can change as the receiver consumes data and network conditions change.

Cumulative ACKs

An ACK indicates the next contiguous byte expected, not the most recently arrived segment.

Textbook comparison: Forouzan §23.3 calls TCP's window byte-oriented and variable-sized, whereas the earlier data-link-layer windows in that book are frame-oriented and illustrated as fixed-size. TCP may buffer out-of-order bytes rather than automatically discarding them.

2. The Four Regions of a TCP Sender Window

Visualize the TCP byte stream as four groups: acknowledged bytes, sent but unacknowledged bytes, bytes that can be sent now, and bytes temporarily blocked outside the current window.

Original concept diagram — a 9-byte effective window

ACK = 200rwnd = 9 bytescwnd = 20 bytes
199ACKed
200Sent
201Sent
202Sent
203Can send
204Can send
205Can send
206Can send
207Can send
208Can send
209Blocked
Based on the logic of Forouzan Example 23.6 (p. 731, Fig. 23.23). Window bytes 200–208 are eligible; bytes 200–202 are already outstanding; six additional bytes 203–208 may be sent. Byte 209 waits until the window advances or opens.
Window rightmost byte = ACK + Window size − 1
New-data allowance ≈ Effective window − Bytes already in flight

Here the window contains min(9,20)=9 bytes. Of those, three are outstanding, so six new bytes are currently allowed.

Opening: right boundary moves right and allows additional bytes. Sliding (closing the left): acknowledgements advance the left boundary. Shrinking: moving the right edge backward is strongly discouraged because the sender may already have transmitted bytes relying on the earlier permission.

3. Receiver Window (rwnd) vs. Congestion Window (cwnd)

rwnd — Receiver flow-control limit

Determined by the receiving TCP from available buffer capacity. Advertised to the sender in TCP's Window field (with scaling when negotiated).

cwnd — Sender congestion-control limit

Maintained by the sender, based on congestion-control logic and feedback. Not a value directly transmitted in the TCP header.

Effective sending window = min(rwnd, cwnd)
Simplified rwnd = Receive buffer capacity − Bytes occupying buffer

Forouzan Examples 23.4 and 23.5 illustrate both calculations. With a 5000-byte buffer holding 1000 unread bytes, rwnd=4000. If rwnd=3000 and cwnd=3500, the effective window is 3000 bytes.

Exam trap: An ACK and a receiver-window advertisement carry different information. A receiver may acknowledge previously arrived bytes yet still advertise a zero window because its application has not removed them from the buffer.

4. Interactive TCP Receive-Buffer and Window Demonstration

Consider a receiver with a 4096-byte buffer, an empty starting buffer, and a sender whose first data byte is numbered 1000. Click through the steps to see how ACK and rwnd change independently. This is a numerically adjusted recreation of the concept in Tanenbaum Figure 6-40.

Receive buffer: eight cells, 512 bytes each

Step 0 · Empty bufferUsed: 0 / 4096 B

Next ACK

1000

Advertised rwnd

4096 B

New step

No bytes sent

Receiver empty: cumulative ACK=1000, available rwnd=4096 B. The sender may fill the advertised space, subject to cwnd.
Model assumes no receiver-window scaling and no other unprocessed bytes. The 512-byte cells are only a teaching visualization; real TCP buffers are not restricted to eight fixed cells.
TCP SenderData segments
TCP ReceiverReceive buffer
2 KB
ACK

Animated concept: the blue data packet moves sender → receiver while the green ACK moves receiver → sender. Motion illustrates exchanges rather than actual network timing. Motion pauses when requested and respects reduced-motion preferences.

5. Cumulative ACKs, Lost Segments and Out-of-Order Reception

The TCP acknowledgement number represents the next byte expected in order. If data arrive beyond a missing range, the cumulative ACK normally stays at the beginning of the gap. Modern implementations commonly buffer those later bytes; SACK, when enabled, can report the out-of-order ranges separately.

Try a lost-segment scenario

500 bytes per segmentStep 0 / 5
No segment delivered yet. Receiver expects byte 1000, so cumulative ACK=1000.
Original illustration of TCP's cumulative ACK rule (Tanenbaum pp. 567–568 and Forouzan pp. 731–733). Lost bytes 1500–1999 keep ACK at 1500 despite the arrival of later ranges; when the retransmission fills the gap, ACK jumps to 3000.
Lost packet vs. lost ACK: If an ACK is lost but a later cumulative ACK arrives, the later ACK can cover the previously acknowledged bytes. If a data segment is missing, however, the receiver cannot cumulatively acknowledge beyond that hole.

6. Zero Window, Window Probes, Delayed ACK, Nagle and Silly Window Syndrome

6.1 Zero receiver window (rwnd = 0)

If the application reads no data and the buffer fills, the receiver may advertise rwnd=0. A sender normally stops new data transmission until more room becomes available. In Tanenbaum Figure 6-40, ACK moves forward as bytes arrive, but the advertised window can simultaneously fall to zero.

6.2 Window probes and the persist problem

Suppose the receiver later frees space and sends a window-update segment, but that update is lost. The sender still believes the window is zero and may wait indefinitely. TCP can transmit a window probe to elicit the receiver's latest ACK and window advertisement. The textbook discusses a 1-byte probe exception.

6.3 Delayed ACK

Instead of immediately sending a standalone ACK for every arriving segment, a receiver can delay it briefly in the hope that useful outgoing data will allow piggybacking. Tanenbaum's historical discussion mentions up to 500 ms; this is a textbook explanation, not a recommendation to use 500 ms in every current implementation.

6.4 Nagle's algorithm

The sender transmits the first small piece promptly, then buffers subsequent small writes while an earlier small piece is still unacknowledged, unless enough bytes accumulate to transmit a full MSS. This reduces the number of small packets but can introduce delay for interactive workloads. The socket option TCP_NODELAY is commonly used to disable Nagle's algorithm where appropriate.

6.5 Silly window syndrome (SWS)

When the receiving application reads only one byte at a time, the receiver may repeatedly advertise one byte of free space; the sender responds with 1-byte data segments and disproportionate header overhead. In the textbook's Clark approach, the receiver avoids issuing tiny updates until it can accept at least an MSS or half its buffer, whichever is smaller.

Nagle → Sender side

Controls tiny writes from sending applications, preferring fewer, larger segments.

Clark → Receiver side

Controls tiny window advertisements caused by receiver reads, preferring useful space increments.

Do not confuse: A zero advertised window usually indicates receiver buffer pressure. Congestion-related limitation is instead represented by the sender's cwnd. Both can limit sending, but they solve different problems.

7. Flow Control vs. Error Control vs. Congestion Control

AspectFlow controlError controlCongestion control
Primary concernReceiver cannot accept more bytesBytes lost/corrupted/out of orderNetwork cannot carry offered load
Key TCP signalsAdvertised rwndACK, sequence numbers, SACK, retransmission timerSender's cwnd, loss/ECN feedback
Important mechanismVariable-size sliding windowChecksum, cumulative ACK, retransmissionSlow Start, AIMD, congestion avoidance
Can sender continue?Only while permitted by receive windowMay retransmit lost dataSubject to current congestion window

Forouzan comparison: TCP's window has aspects of both Go-Back-N and Selective Repeat. Cumulative ACKing resembles Go-Back-N; buffering out-of-order data resembles Selective Repeat. However, TCP is byte-oriented, not simply either of those frame-oriented protocols.

8. Solved TCP Sliding-Window Numerical Problems

Example 1 — Receiver-window calculation (Forouzan Example 23.4)

Given: Receive buffer capacity = 5000 B; unread data = 1000 B.

rwnd = 5000 − 1000 = 4000 B

Answer: rwnd = 4000 bytes.

Example 2 — Effective window (Forouzan Example 23.5)

Given: rwnd = 3000 B, cwnd = 3500 B.

Effective window = min(3000, 3500) = 3000 B

Answer: 3000 bytes; receiver window is limiting.

Example 3 — Outstanding bytes and usable space (Forouzan Example 23.6)

Given: ACK = 200, rwnd = 9, cwnd = 20; bytes 200–202 already sent.

The effective window covers bytes 200–208, so 3 are outstanding and 6 new bytes remain sendable.

Allowance = min(9, 20) − 3 = 6 B

Answer: bytes 203–208 may be sent; byte 209 cannot.

Example 4 — TCP cumulative acknowledgement after a gap

Received 1000–1499; missing 1500–1999; received and buffered 2000–2499 and 2500–2999.

Answer before retransmission: ACK = 1500.

After the missing 1500–1999 bytes arrive:

Next expected byte = 3000

Answer after retransmission: ACK = 3000.

Example 5 — How much data can be sent next?

Given: rwnd = 12 KiB; cwnd = 8 KiB; bytes still unacknowledged = 3 KiB.

New allowance = min(12,8) − 3 = 5 KiB

Answer: 5 KiB, under the simplified aligned-window assumption.

Example 6 — Zero-window reopening

Given: Receiver buffer = 4096 B, initially full (rwnd = 0). Application reads 1536 B, and no additional data arrive.

Updated rwnd = 4096 − (4096 − 1536) = 1536 B

Answer: Receiver can advertise a 1536-byte window when it sends a window update.

Example 7 — Window scaling

Given: Advertised TCP window field = 3000 and negotiated window-scale shift = 3.

Effective advertised rwnd = 3000 × 2³ = 24,000 B

Answer: 24,000 bytes (assumes scaling successfully negotiated).

Example 8 — Window-limited throughput

Given: An effective window of 65,536 B and round-trip time = 0.100 seconds.

Rate ≈ (65,536 × 8) / 0.100 = 5,242,880 bit/s

Answer: approximately 5.243 Mbps.

This is a simplified window/RTT estimate, not guaranteed TCP goodput.

Example 9 — Calculate send window right edge

Given: Cumulative ACK=8000, advertised rwnd=2500 bytes, and no extra cwnd restriction.

Right edge = 8000 + 2500 − 1 = 10,499

Answer: Byte positions 8000–10,499 fall inside the advertised receive window.

Example 10 — Sequence and ACK with two in-order segments

Segment A starts SEQ=10,001 and carries 1000 B. Segment B starts SEQ=11,001 and carries another 1000 B; both arrive in order.

Cumulative ACK = 10,001 + 2,000 = 12,001

Answer: ACK = 12,001.

These problems are original exam exercises unless explicitly attributed to a numbered Forouzan example.

9. APPSC / UGC NET / GATE — 20 Practice MCQs

The questions below are original exam-style practice questions, not claims of verbatim previous-year questions. Choose one answer per question, then click Check Answers.

20 questions · 1 mark each0 / 20 answered

1. TCP sliding-window units are primarily:

Answer: B. TCP numbers data bytes individually. Forouzan contrasts this byte-oriented window with frame-oriented data-link windows.

2. The TCP advertised receiver window chiefly prevents:

Answer: B. rwnd describes how much data the receiving endpoint can accept without overflowing its buffer.

3. If rwnd=4000 bytes and cwnd=6000 bytes, the effective window is:

Answer: B. The sender is limited by the smaller of rwnd and cwnd: min(4000,6000)=4000.

4. A receiver buffer is 5000 bytes and 1000 bytes are unread. What is rwnd?

Answer: B. Assuming no other reservations, rwnd = 5000−1000 = 4000 bytes (Forouzan Example 23.4).

5. ACK=200 and rwnd=9 advertise a receive window covering which bytes?

Answer: A. The left edge is the next expected byte 200; the right edge is 200 + 9 − 1 = 208.

6. In Forouzan Example 23.6, bytes 200–202 are unacknowledged, rwnd=9. How many new bytes may be sent?

Answer: B. The window spans 200–208; 3 bytes are already outstanding, leaving 6 bytes 203–208.

7. TCP cumulative ACK number usually specifies:

Answer: B. The receiver acknowledges the next byte expected in sequence; later out-of-order data cannot advance that cumulative ACK over a gap.

8. Seq=3000, data length=500, no SYN/FIN: next expected ACK?

Answer: C. The data covers byte positions 3000 through 3499, so the next contiguous byte is 3500.

9. Segments 1000–1499 received, 1500–1999 lost, 2000–2499 received: cumulative ACK?

Answer: C. The gap begins at byte 1500, so cumulative ACK stays 1500 even though later bytes were buffered.

10. When the missing 1500–1999 bytes then arrive, and 2000–2499 are buffered, ACK becomes:

Answer: D. All bytes from 1000 through 2499 are contiguous, so ACK advances to 2500.

11. What does a TCP advertised window of 0 normally mean?

Answer: B. A zero advertised receiver window indicates no currently available receive buffer space; probes and other specified exceptions exist.

12. Why does TCP use zero-window probes?

Answer: B. A probe can elicit an updated ACK/window advertisement if an earlier reopening update was lost.

13. Which issue is associated with advertising repeated tiny windows?

Answer: A. Tiny window advertisements and tiny segments waste bandwidth and header overhead.

14. Clark’s receiver-side approach to silly window syndrome waits for:

Answer: B. The textbook advises withholding tiny window updates until a reasonable amount of space becomes available.

15. Nagle’s algorithm primarily aims to reduce:

Answer: B. Nagle buffers subsequent small writes while an earlier small segment is unacknowledged, or sends when enough data accumulates.

16. What can a delayed acknowledgement try to achieve?

Answer: A. Delayed ACKs can reduce standalone ACK packets by waiting briefly for useful outgoing data.

17. TCP's receiver window and congestion window are:

Answer: C. rwnd is advertised by receiver; cwnd is independently maintained by sender as a congestion control variable.

18. Window scaling with shift count 3 and header window 3000 gives:

Answer: D. When window scaling was negotiated, effective advertised rwnd = 3000 × 2³ = 24,000 bytes.

19. Which is a valid outcome of out-of-order TCP reception in the textbook?

Answer: B. Receiver-side TCP can hold out-of-order bytes temporarily, but delivers data in sequence.

20. If effective window=8192 B and 3072 B remain outstanding, what is the simplified new-send allowance?

Answer: C. Allowance = effective window − bytes in flight = 8192 − 3072 = 5120 bytes, assuming both limits share the stated send-window base.

10. FAQs and Quick Revision

What is the TCP sliding window?

It is the moving range of bytes a TCP sender is permitted to have outstanding. Its effective size is limited by receiver flow control and network congestion control.

Is TCP sliding window based on bytes or segments?

TCP sliding-window accounting is byte-oriented. A segment can carry many numbered bytes.

How is the TCP receiver window calculated?

For a simplified receive buffer: rwnd = buffer capacity − currently occupied receive bytes. The receiver advertises its available space.

What is the difference between rwnd and cwnd?

rwnd protects the receiver and is advertised by it; cwnd is maintained by the sender to help avoid congesting the network.

Can a TCP ACK advance across a missing segment?

Not as a cumulative ACK. It remains at the first missing byte, although SACK can separately report later received ranges.

What happens when the receiver advertises a zero window?

New normal data transmission pauses; TCP can use a window probe to discover when the receiver window reopens.

What is silly window syndrome?

It is inefficient TCP behavior involving tiny window updates or tiny transmitted segments, leading to disproportionate header and acknowledgement overhead.

What is Nagle's algorithm?

A sender-side optimization that combines small application writes into larger segments while limiting unacknowledged small sends.

How does a sliding window improve link utilization?

It permits multiple bytes or segments to remain in flight during a round-trip time instead of stopping after every send.

What is the formula for a TCP window-limited throughput estimate?

An approximate upper bound, when a fixed window is the bottleneck, is 8 × window bytes / RTT seconds, in bits per second.

Last-minute formula sheet

FormulaApplication
rwnd = Buffer − OccupiedSimplified receiver buffer availability
Effective window = min(rwnd,cwnd)Actual limiting TCP window (basic exam model)
Available send = Effective − In-flightAdditional new data, given compatible window boundaries
Right edge = ACK + rwnd − 1Receive-window byte range
Next ACK = first missing byteCumulative ACK logic
Window scaling = field × 2^shiftWhen negotiated
Rate ≈ Window × 8 / RTTIdeal window-limited throughput in bit/s

Textbook references

0 comments :

Post a Comment

Note: only a member of this blog may post a comment.

NumPy Tutorial

More

Advertisement

Java Tutorial

More

UGC NET CS TUTORIAL

MFCS
COA
PL-CG
DBMS
OPERATING SYSTEM
SOFTWARE ENG
DSA
TOC-CD
ARTIFICIAL INT

C Programming

More

Python Tutorial

More

Data Structures

More

computer Organization

More
Top