Flow Control in the Data Link Layer: Stop-and-Wait, Sliding Window, and Worked Examples

See Stop-and-Wait, sliding windows, Go-Back-N, and Selective Repeat as parts of one system. One link carries every calculation from efficiency to sequence bits.

KnowledgeGate Team

Exam prep & CS education

Updated 9 Aug 20266 min read

Flow-control questions can look like unrelated ideas: Stop-and-Wait, Go-Back-N, Selective Repeat, efficiency, throughput, and sequence bits. They are parts of one machine. One link, 1 Mbps run over 700 km, produces every one of them: a = 3.5, Stop-and-Wait at 12.5%, a window of 8 at 100%, and a 4-bit sequence field.

What flow control actually solves

A sender may push frames faster than the receiver can process them. The buffer fills and later frames may be dropped. Flow control prevents this by pacing the sender.

Keep three ideas separate:

  • Flow control manages the speed difference between one sender and one receiver.

  • Error control detects lost or damaged frames and arranges retransmission.

  • Congestion control deals with overload across the wider network.

At the data link layer, flow and error control meet in Automatic Repeat reQuest, or ARQ. ACKs tell the sender what may proceed. Stop-and-Wait and sliding window use this feedback. Rate-based control fixes the sending rate and is mainly a higher-layer idea.

The same window idea reappears at the transport layer, where TCP sizes its window against the receiver and the network together. TCP Congestion Control for GATE works through that sizing.

Three quantities drive each calculation:

  • Transmission time, Tt = L / B, is the time needed to place all bits of one frame on the link.

  • Propagation time, Tp = d / v, is the time needed for a bit to travel from sender to receiver.

  • The ratio a = Tp / Tt measures the link length in frame-transmission times.

Take one link: B = 1 Mbps = 10^6 bits per second, and L = 1000 bits. Therefore:

Tt = 1000 / 10^6 = 10^-3 s = 1 ms

The distance is d = 700 km = 7 x 10^5 m, and signal velocity is v = 2 x 10^8 m/s:

Tp = (7 x 10^5) / (2 x 10^8) = 3.5 x 10^-3 s = 3.5 ms

So a = 3.5 / 1 = 3.5, and the full-pipe factor is 1 + 2a = 1 + 7 = 8. A window of 8 keeps the sender busy until the first ACK returns.

Stop-and-Wait sends one frame, then waits for its ACK. Its window is 1. With negligible ACK transmission and processing time, efficiency is useful transmission time divided by cycle time:

eta = Tt / (Tt + 2Tp) = 1 / (1 + 2a)

For this link:

eta = 1 / (1 + 2 x 3.5) = 1 / 8 = 0.125 = 12.5%

Throughput is efficiency multiplied by bit rate:

Throughput = 0.125 x 10^6 = 125000 bps = 125 kbps

Check the cycle itself. It takes Tt + 2Tp = 1 + 2(3.5) = 8 ms and carries 1000 bits. Therefore 1000 / 0.008 = 125000 bps, the same result. The sender works for 1 ms and idles for 7 ms; waste grows with a.

Stop-and-Wait still needs a 1-bit sequence number. After a lost ACK causes retransmission, alternating labels 0 and 1 identify the duplicate.

Stop-and-Wait space-time diagram: a 1 ms frame, 3.5 ms propagation each way, an 8 ms cycle, and 12.5% efficiency at 125 kbps.

Sliding window: keeping the pipe full

A sliding-window sender may keep N unacknowledged frames in flight. Each ACK moves the window and opens space, avoiding an idle propagation interval.

For an error-free link:

eta = min(N, 1 + 2a) / (1 + 2a)

Here the denominator is 8. With N = 4, efficiency is 4 / 8 = 0.50 = 50%, so throughput is 0.50 x 10^6 = 500000 bps = 500 kbps. With N = 8, efficiency is 8 / 8 = 1.00 = 100%, and throughput reaches 1 x 10^6 bps = 1 Mbps.

A window of at least 1 + 2a fills the pipe; a larger one adds no throughput on this error-free link. Stop-and-Wait is N = 1 at 12.5% efficiency. Moving to N = 8 raises efficiency eightfold to 100%. Sliding Window Protocols for GATE runs the same two formulas on a longer link, 1 Mbps over 2000 km with 1000-byte frames, where a = 1.25 and the saturating window is 4.

Go-Back-N vs Selective Repeat

Both use a sliding sender window. They differ when a frame is lost and later frames arrive out of order.

Go-Back-N has receiver window WR = 1. It accepts only the next expected frame and discards arrivals beyond a gap. Its sender window is WS = 2^m - 1, but one loss can waste several transmissions.

Selective Repeat uses WR = WS. It buffers and individually acknowledges valid out-of-order frames, so only missing frames are retransmitted. Its rule is WS = WR = 2^(m-1). This saves capacity but needs more buffering and re-sequencing.

Use a window of 8 with frames 0 through 7 in flight, and let frame 2 be lost. Go-Back-N discards frames 3 through 7, then resends frames 2 through 7: 6 retransmitted frames. Selective Repeat buffers frames 3 through 7 and resends only frame 2: 1 retransmitted frame.

Go-Back-N versus Selective Repeat after frame 2 is lost from a window of 8: Go-Back-N resends 6 frames, Selective Repeat resends 1.

Sequence numbers: how many bits you actually need

An m-bit sequence field supplies 2^m labels. Window bounds prevent old frames being mistaken for new ones after wraparound.

Stop-and-Wait has WS = 1 and WR = 1, so 1 bit provides labels 0 and 1.

For Go-Back-N, WS = 2^m - 1. To run WS = 8:

2^m - 1 >= 8, so 2^m >= 9, so m = 4 bits

Four bits provide labels 0 through 15 and allow WS up to 15. Three bits allow 2^3 - 1 = 7, limiting efficiency to 7 / 8 = 0.875 = 87.5%.

For Selective Repeat, the sequence space covers both windows: 2^m >= WS + WR. With WS = WR = 8, 2^m >= 16, so m = 4. Equivalently, 2^(m-1) = 2^3 = 8 exactly.

Protocol

WS

WR

Minimum bits for this example

Stop-and-Wait

1

1

1 bit

Go-Back-N

8

1

4 bits

Selective Repeat

8

8

4 bits

Traps that quietly cost marks

  • Dropping the return propagation time: Using Tt + Tp gives 1 / (1 + a) = 1 / 4.5. The ACK must travel back, so the cycle here is Tt + 2Tp and efficiency is 1 / 8.

  • Swapping window bounds: Go-Back-N uses WS = 2^m - 1. Selective Repeat uses WS = 2^(m-1), half the sequence space.

  • Assuming a larger window always helps: Once N reaches 1 + 2a = 8, efficiency is 100%. N = 16 adds buffering but no throughput on this error-free link.

  • Forgetting the receiver window: Go-Back-N always has WR = 1. A protocol that buffers valid out-of-order frames is Selective Repeat, not Go-Back-N.

  • Ignoring stated delays: If a question gives ACK transmission time or processing time, include it in the cycle. The shorter formula omits them only when they are negligible or the question says to ignore them.

How GATE and interviews test flow control, and the short version

A GATE-style numerical may give B, L, distance, and propagation velocity, then ask for efficiency, throughput, a saturating window, or sequence bits. Conceptual questions compare Go-Back-N and Selective Repeat. Interviews often ask why each rule exists.

The official GATE 2026 Computer Science syllabus places the data link layer and flow control inside Computer Networks. Read the topic list there rather than trusting remembered weightage.

The short version is five rules: calculate a = Tp / Tt; use 1 / (1 + 2a) for Stop-and-Wait efficiency; use min(N, 1 + 2a) / (1 + 2a) for sliding-window efficiency; remember Go-Back-N as WS = 2^m - 1, WR = 1; and remember Selective Repeat as WS = WR = 2^(m-1).

For a guided treatment across Computer Networks, follow GATE Guidance by Sanchit Sir. If you are building the foundations for interviews and placements, use CS Fundamentals for Placements by Sanchit Sir. The Computer Networks learn module places flow control alongside the rest of the subject. Then solve the same link once by hand, first with N = 1 and then with N = 8, until the full-pipe factor 8 becomes obvious.