Flow Control and Reliable Transmission

Flow Control Overview

Flow control is one of the core functions of the data link layer. It coordinates the rate difference between sender and receiver so that a fast sender cannot overwhelm a slow receiver, overflow its buffer, and lose data.

Flow Control

Flow control is a mechanism that limits the sending rate of the sender so that it does not exceed the receiving and processing capacity of the receiver, thereby guaranteeing reliable transmission of data.

Flow control is closely tied to error control; together they form the reliable transmission mechanism. The core idea of reliable transmission is to use acknowledgment (ACK) and timeout retransmission so that data arrives at the receiver correctly and in order.

Stop-and-Wait Protocol

Stop-and-wait is the simplest reliable transmission protocol.

How It Works

  1. After sending one frame, the sender stops sending and waits for the receiver’s acknowledgment (ACK)
  2. After receiving a correct frame, the receiver sends an ACK back to the sender
  3. Only after receiving the ACK does the sender transmit the next frame
  4. If the sender does not receive the ACK within the timeout period (timeout timer), it retransmits that frame

To deal with duplicate frames — the ACK is lost, the sender retransmits, and the receiver ends up with two identical frames — frames must be numbered. Stop-and-wait uses a 1-bit sequence number (0 and 1), and the ACK carries a sequence number too, indicating “the sequence number of the next frame expected”.

Channel Utilization Analysis

The biggest problem with stop-and-wait is low efficiency. The channel sits idle while the sender waits for the ACK.

Let:

  • TtT_t: the frame transmission delay (time to send one frame) = frame length / data rate
  • TpT_p: the signal propagation delay = link length / signal propagation speed
  • TaT_a: the transmission delay of the ACK (usually very small and negligible)

A complete cycle is: sending the frame TtT_t + propagation to the receiver TpT_p + sending the ACK TaT_a + propagation of the ACK back to the sender TpT_p

The channel utilization (the fraction of the cycle during which the sender is busy) is:

U=TtTt+2Tp+Ta≈TtTt+2TpU = \frac{T_t}{T_t + 2T_p + T_a} \approx \frac{T_t}{T_t + 2T_p}

Sliding Window Protocol

The sliding window protocol allows the sender to transmit several frames in a row before any acknowledgment arrives, which greatly increases channel utilization.

Basic Concepts

  • Send window: the range of sequence numbers for frames the sender may transmit but has not yet had acknowledged. The window size is denoted WTW_T.
  • Receive window: the range of sequence numbers for frames the receiver is willing to accept. The window size is denoted WRW_R.
  • Window sliding: when the sender receives an ACK the send window slides forward; when the receiver receives a frame and sends an ACK the receive window slides forward.

Sequence Number Space

Frame sequence numbers are represented by nn bits, giving a range of 0∼2n−10 \sim 2^n - 1. To avoid confusing old and new frame sequence numbers — that is, to avoid the receiver being unable to tell a retransmitted old frame from a new one — the send window size must satisfy:

WT+WR≤2nW_T + W_R \leq 2^n

For the GBN protocol, WR=1W_R = 1, so WT≤2n−1W_T \leq 2^n - 1. For the SR protocol, WT=WRW_T = W_R, so WT≤2n−1W_T \leq 2^{n-1}.

Go-Back-N (GBN) Protocol

GBN is an implementation of the sliding window protocol in which the receive window size is 1, meaning the receiver accepts frames strictly in order.

How It Works

  1. The sender may transmit several frames from its send window without waiting for acknowledgments
  2. The receiver accepts only frames that arrive in order. If an out-of-order frame arrives (because an earlier frame was lost), the receiver discards that frame and sends a duplicate ACK for the last in-order frame received
  3. When the sender receives a duplicate ACK or times out, it retransmits the erroneous frame and every frame sent after it that has not yet been acknowledged — that is, it “goes back N frames”

Cumulative Acknowledgment

GBN uses cumulative acknowledgment: ACK nn means that frame nn and all frames before it have been received correctly. As a result, if an ACK is lost, a later ACK can piggyback the confirmation of the earlier frames.

Characteristics

  • Advantages: simple receiver implementation (no buffering of out-of-order frames), and the cumulative acknowledgment mechanism is robust
  • Disadvantages: on error it may retransmit frames that were already received correctly, wasting bandwidth; inefficient in environments with a high error rate
  • Suitable for: networks with a low error rate, such as wired networks

Selective Repeat (SR) Protocol

SR is the other sliding window protocol, in which the receive window size is greater than 1, so the receiver can buffer frames that arrive out of order.

How It Works

  1. The sender may transmit several frames from its send window
  2. The receiver sends an individual ACK for every correctly received frame (not a cumulative acknowledgment). A frame that arrives out of order but is correct is buffered and not yet delivered to the layer above
  3. The sender maintains an independent timeout timer for each frame. If a frame times out, only that frame is retransmitted (the frames after it are not)
  4. Once the missing frame arrives correctly, the receiver delivers the buffered frames to the layer above in order

Characteristics

  • Advantages: retransmits only the erroneous frame, which avoids unnecessary retransmissions and is efficient in environments with a high error rate
  • Disadvantages: the receiver must buffer out-of-order frames, which complicates the implementation; each frame needs individual acknowledgment and timing
  • Suitable for: networks with a high error rate, such as wireless networks

Comparison of the Three Protocols

CharacteristicStop-and-WaitGBNSR
Send window size1>1>1, ≤2n−1\leq 2^n-1>1>1, ≤2n−1\leq 2^{n-1}
Receive window size11>1>1
Acknowledgment styleIndividualCumulativeIndividual
Retransmission policyRetransmit the current frameRetransmit the erroneous frame and all frames after itRetransmit only the erroneous frame
Receiver bufferingNot neededNot neededNeeded
Channel utilizationLowModerateHigh
Implementation complexitySimpleModerateComplex
Suitable forLow-delay linksLow-error-rate linksHigh-error-rate links

Worked Examples

Example 1: Channel Utilization of Stop-and-Wait

On a channel with a data rate of 1 Mbps and a propagation delay of 20 ms, the stop-and-wait protocol transmits frames of 1000 bytes. Find the channel utilization. If the sliding window protocol is used instead, what is the minimum window size that achieves a channel utilization of 80%?

Stop-and-WaitChannel UtilizationSliding WindowTransmission Delay

Approach: compute the transmission delay, then apply the utilization formulas for stop-and-wait and for a sliding window.

Steps:

  1. Compute the transmission delay: Tt=frame lengthdata rate=1000×81×106=8000106=8 msT_t = \frac{\text{frame length}}{\text{data rate}} = \frac{1000 \times 8}{1 \times 10^6} = \frac{8000}{10^6} = 8 \text{ ms}

  2. The propagation delay is Tp=20 msT_p = 20 \text{ ms}

  3. The channel utilization of stop-and-wait: U=TtTt+2Tp=88+2×20=848=16≈16.7%U = \frac{T_t}{T_t + 2T_p} = \frac{8}{8 + 2 \times 20} = \frac{8}{48} = \frac{1}{6} \approx 16.7\%

  4. The channel utilization of the sliding window protocol is approximately: U≈W×TtTt+2TpU \approx \frac{W \times T_t}{T_t + 2T_p} (when the window is large enough)

    Requiring U≥80%U \geq 80\%: W×848≥0.8\frac{W \times 8}{48} \geq 0.8 W≥0.8×488=4.8W \geq \frac{0.8 \times 48}{8} = 4.8

    So the window size must be at least 5.

Answer: the channel utilization of stop-and-wait is about 16.7%; a sliding window of at least 5 is needed to reach a utilization of 80%.

Example 2: Sequence Numbers and Windows in GBN

A GBN protocol uses 3-bit sequence numbers and a send window size of 5. At a certain moment the sender’s send window is [2, 3, 4, 5, 6] (the sequence numbers of frames sent but not yet acknowledged). The sender then receives ACK 4. (1) What is the new send window? (2) Which sequence numbers may the sender transmit next?

GBNSliding WindowCumulative AcknowledgmentSequence Number

Approach: interpret ACK 4 as a cumulative acknowledgment, then slide the window forward by the acknowledged frames.

Steps:

  1. GBN uses cumulative acknowledgment, so ACK 4 means that frame 4 and all frames before it (0, 1, 2, 3, 4) have been received correctly.
  2. The original send window was [2, 3, 4, 5, 6]. After ACK 4 the window slides forward and the acknowledged frames 2, 3, 4 are removed.
  3. The new send window is [5, 6, 7, 0, 1] (with 3-bit sequence numbers, 6 is followed by 7, 0, 1).
  4. Of these, 5 and 6 have been sent but not acknowledged, while 7, 0, 1 are new frames that may be transmitted.

Answer: (1) the new send window is [5, 6, 7, 0, 1]; (2) the frames with sequence numbers 7, 0, and 1 may be transmitted next.

Example 3: The Sequence Number Space of SR

A selective repeat protocol uses 4-bit sequence numbers, and the send window and the receive window have equal sizes. What is the maximum window size? What goes wrong if the window size is set to 9?

Selective RepeatSequence Number SpaceWindow SizeSR

Approach: apply the constraint WT+WR≤2nW_T + W_R \leq 2^n with WT=WRW_T = W_R, then examine what a too-large window does to sequence number reuse.

Steps:

  1. In the SR protocol, the send window WTW_T and the receive window WRW_R have equal sizes and must satisfy WT+WR≤2nW_T + W_R \leq 2^n.
  2. With n=4n=4, 24=162^4 = 16, so 2WT≤162W_T \leq 16 and WT≤8W_T \leq 8.
  3. The maximum window size is 8.
  4. If the window size is set to 9 (WT=WR=9W_T = W_R = 9), then WT+WR=18>16W_T + W_R = 18 > 16 and sequence numbers become ambiguous:
    • Suppose the receiver’s window is [0, 1, …, 8]. After receiving all the frames and sending ACKs, the window slides to [9, 10, …, 0] (that is, 9, 10, 11, 12, 13, 14, 15, 0, 1).
    • If all the earlier ACKs were lost, the sender times out and retransmits the frame with sequence number 0.
    • The receiver’s expected new frames now also include sequence number 0, and it cannot tell a retransmitted old frame from a new one.
    • The protocol therefore fails.

Answer: the maximum window size is 8; setting it to 9 causes sequence number ambiguity, and the receiver can no longer distinguish retransmitted old frames from new ones.


Exercises

Exercise 1

Compare the stop-and-wait, GBN, and SR protocols in terms of their retransmission policies and receiver buffering.

Protocol ComparisonStop-and-WaitGBNSR

Approach: compare the three protocols along the two axes named in the question.

Steps:

  1. Retransmission policy:

    • Stop-and-wait: retransmits the current frame after a timeout (only one frame is ever in flight)
    • GBN: after a timeout or a duplicate ACK, retransmits the erroneous frame and every frame sent after it that is still unacknowledged (go back N frames)
    • SR: every frame has its own timer, and after a timeout only the erroneous frame is retransmitted
  2. Receiver buffering:

    • Stop-and-wait: receive window = 1, no buffering needed (only one frame is accepted)
    • GBN: receive window = 1, frames are accepted in order and out-of-order frames are discarded, so no buffering is needed
    • SR: receive window > 1, out-of-order but correct frames are buffered and delivered in order once the missing frame arrives
  3. Acknowledgment style:

    • Stop-and-wait: individual acknowledgment
    • GBN: cumulative acknowledgment (ACK n means n and everything before it has been received)
    • SR: individual acknowledgment (one ACK per frame)

Answer: stop-and-wait retransmits the current frame and needs no buffering; GBN retransmits the erroneous frame and all later frames and needs no buffering; SR retransmits only the erroneous frame but must buffer out-of-order frames.

Exercise 2

On a channel with a data rate of 10 Mbps and a propagation delay of 5 ms, the stop-and-wait protocol transmits frames of 1500 bytes. Find the channel utilization.

Channel UtilizationStop-and-WaitTransmission Delay

Approach: compute the transmission delay and apply the stop-and-wait utilization formula.

Steps:

  1. Transmission delay: Tt=1500×810×106=12000107=1.2 msT_t = \frac{1500 \times 8}{10 \times 10^6} = \frac{12000}{10^7} = 1.2 \text{ ms}
  2. Propagation delay: Tp=5 msT_p = 5 \text{ ms}
  3. Channel utilization: U=TtTt+2Tp=1.21.2+10=1.211.2≈10.7%U = \frac{T_t}{T_t + 2T_p} = \frac{1.2}{1.2 + 10} = \frac{1.2}{11.2} \approx 10.7\%

Answer: the channel utilization is about 10.7%.


Glossary

TermAbbreviationExplanation
Flow Control-Limits the sending rate to prevent buffer overflow
Reliable Transmission-Ensures data arrives correctly and in order
Stop-and-Wait-The simplest ARQ protocol
Sliding Window-A mechanism that allows several frames to be sent back to back
Go-Back-NGBNRetransmits the erroneous frame and the frames after it on error
Selective RepeatSRRetransmits only the erroneous frame
Automatic Repeat reQuestARQA reliable transmission mechanism based on acknowledgment and timeout retransmission
AcknowledgmentACKThe receiver notifies the sender that data has arrived
Timeout Retransmission-Retransmission when no ACK arrives before the timeout
Cumulative ACK-ACK n means that n and all frames before it have been received
Channel Utilization-The fraction of time the sender is busy
Send Window-The range of frames that may be sent but are not yet acknowledged
Receive Window-The range of frames that may be received

Found an issue with this content?

Tell us what could be improved.