Sub topic 15
Stop-and-Wait Utilization and Window Sizing
This chapter assumes you can compute transmission delay (packet size divided by rate) and propagation delay (distance divided by signal speed). It also assumes you know what the bandwidth-delay product is. If any of these feels shaky, review the delay and bandwidth-delay chapters first.
Why a fast link can sit idle
A link is only useful while bits are on it. Under stop-and-wait, the sender transmits one frame and then does nothing until the acknowledgment (ACK) returns. For a short link this wait is negligible. For a long or fast link it dominates, and the link stays idle for most of each cycle.
Two quantities describe one cycle:
- Transmission time (Tt) is the time to push one frame onto the link: frame bits divided by rate.
- Round-trip time (RTT) is the time for a signal to reach the receiver and for the ACK to come back. Ignoring queuing and processing, RTT = 2 × Tp, where Tp is the one-way propagation delay.
The sender is busy for Tt and then idle for about RTT. Only the Tt part carries useful data.
The utilization formula
Utilization is the fraction of time the sender spends transmitting useful data:
U = Tt / (Tt + RTT)
Throughput follows directly: effective throughput = U × link rate. Equivalently, stop-and-wait delivers exactly one frame per cycle, so throughput = frame bits / (Tt + RTT).
Three simplifications are standard in GATE problems unless the question says otherwise:
- The ACK is so small that its transmission time is ignored.
- Processing and queuing delays are zero.
- No frames are lost or corrupted.
Some textbooks write the cycle as Tt + 2·Tp, which is the same thing. Others add the ACK transmission time, giving Tt + 2·Tp + Tack. Use the version the question's data supports.
Worked example with code
Take a 100 Mbps link, a 20 ms RTT, and 12,000-bit frames. Then Tt = 12,000 / 10⁸ = 0.12 ms, and the cycle is 0.12 + 20 = 20.12 ms. So U = 0.12 / 20.12 ≈ 0.00597, which is about 0.6%. The 100 Mbps link behaves like a 0.6 Mbps link.
def bandwidth_delay_product(rate_bps, rtt_s):
return rate_bps * rtt_s # bits that fit in the pipe for one round trip
def stop_and_wait_utilization(packet_bits, rate_bps, rtt_s):
transmission = packet_bits / rate_bps
return transmission / (transmission + rtt_s)
# 100 Mbps link, 20 ms round-trip time, 12000-bit frames
print(bandwidth_delay_product(100_000_000, 0.020)) # 2000000.0 bits = 250000 bytes
print(round(stop_and_wait_utilization(12_000, 100_000_000, 0.020), 5)) # 0.00597The BDP is 2,000,000 bits, but one frame is only 12,000 bits. The sender puts about 0.6% of a pipe-full in flight at a time. That ratio is the utilization.
Fixing it: more frames in flight
The cure is to let the sender transmit several frames before it needs an ACK. This is a sliding window protocol, and the window size W is the number of frames that may be unacknowledged at once.
With window W, the sender sends W frames back to back (W × Tt), then waits for the first ACK. If W × Tt is shorter than the full cycle Tt + RTT, the link still idles. So:
U = min(1, W × Tt / (Tt + RTT))
U reaches 100% when W × Tt ≥ Tt + RTT. The smallest sufficient window is therefore:
W = ceil(1 + RTT / Tt) = ceil((Tt + RTT) / Tt)
The window is the BDP measured in frames, plus one frame for the one being transmitted. That is why this chapter follows the bandwidth-delay product: the window must cover the pipe.
import math
def window_utilization(window, packet_bits, rate_bps, rtt_s):
tt = packet_bits / rate_bps
return min(1.0, window * tt / (tt + rtt_s))
def min_window(packet_bits, rate_bps, rtt_s):
"""Smallest window (in frames) that keeps the link fully busy."""
tt = packet_bits / rate_bps
return math.ceil((tt + rtt_s) / tt)
# Same link: 100 Mbps, 20 ms RTT, 12000-bit frames
print(min_window(12_000, 100_000_000, 0.020)) # 168
print(round(window_utilization(1, 12_000, 100_000_000, 0.020), 5)) # 0.00597
print(round(window_utilization(10, 12_000, 100_000_000, 0.020), 5)) # 0.05964
print(window_utilization(168, 12_000, 100_000_000, 0.020)) # 1.0Utilization grows linearly with W until it saturates at 1. A window of 10 gives ten times the stop-and-wait utilization, and anything beyond 168 adds nothing.
Floating-point division can push an exact answer just above an integer, so math.ceil may return one more than the hand calculation. When a problem is built from round numbers, compute the ratio by hand or round it first.
Sequence numbers limit the window
Frames carry sequence numbers in a header field of k bits, so only 2^k distinct numbers exist. The window must be small enough that the receiver never confuses a new frame with an old retransmission.
| Protocol | Maximum window | Sequence numbers needed |
|---|---|---|
| Stop-and-wait | 1 | 2 (numbers 0 and 1) |
| Go-Back-N | 2^k − 1 | W + 1 |
| Selective Repeat | 2^(k−1) | 2W |
If the computed W is 168, Go-Back-N needs 169 distinct numbers, so k = 8 (256 values). Selective Repeat needs 336, so k = 9 (512 values). With too few bits, the window you can use is capped below the one you need, and utilization is limited by the cap: U = (2^k − 1) × Tt / (Tt + RTT) for Go-Back-N.
Common errors
- Forgetting the factor of two. The wait is a round trip. Using one-way Tp in the denominator overstates utilization.
- Mixing units. Convert Mbps to bits per second and ms to seconds before dividing. A frame in bytes must be multiplied by 8.
- Treating BDP as a window in frames. BDP is in bits. Divide by the frame size to get frames, then add one if the question counts the frame being sent.
- Applying U > 1. Utilization cannot exceed 1. If W × Tt exceeds the cycle, cap it.
- Ignoring frame loss when the question gives it. With loss probability p and independent losses, the expected number of transmissions per frame is 1 / (1 − p), so effective utilization is roughly multiplied by (1 − p).
Summary of the method
- Convert all quantities to bits, bits per second and seconds.
- Compute Tt = frame bits / rate and RTT = 2 × Tp.
- For stop-and-wait, compute U = Tt / (Tt + RTT).
- For a window W, compute U = min(1, W × Tt / (Tt + RTT)).
- For the window that fills the link, compute W = ceil(1 + RTT / Tt), then find the sequence number bits for the chosen protocol.
Exercise
A 1 Mbps link carries 1000-bit frames. The one-way propagation delay is 49.5 ms, and ACK transmission time and processing are ignored. (a) What is the stop-and-wait utilization? (b) What window size gives 100% utilization? (c) How many sequence number bits does Go-Back-N need for that window?
Show answer
Tt = 1000 / 10^6 = 1 ms. RTT = 2 × 49.5 = 99 ms. (a) U = 1 / (1 + 99) = 0.01, or 1%. (b) W = ceil(1 + 99/1) = 100 frames. (c) Go-Back-N needs W + 1 = 101 sequence numbers. Since 2^6 = 64 is too small and 2^7 = 128 is enough, k = 7 bits.
Exercise
On the same link, the sender uses a window of 25 frames. What is the utilization and the effective throughput?
Show answer
U = 25 × 1 ms / (1 ms + 99 ms) = 25 / 100 = 0.25. Effective throughput = 0.25 × 1 Mbps = 250 kbps. The window of 25 is below the 100 needed, so the link is not saturated.