Flow Control and Reliable Transmission
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.
Definition
A definition is a precise description of what a concept, a term, or an object means. Understanding definitions is the foundation of learning any field, and every concept has its own exact meaning.
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 is the simplest reliable transmission protocol.
How It Works
- After sending one frame, the sender stops sending and waits for the receiver’s acknowledgment (ACK)
- After receiving a correct frame, the receiver sends an ACK back to the sender
- Only after receiving the ACK does the sender transmit the next frame
- 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:
- : the frame transmission delay (time to send one frame) = frame length / data rate
- : the signal propagation delay = link length / signal propagation speed
- : the transmission delay of the ACK (usually very small and negligible)
A complete cycle is: sending the frame + propagation to the receiver + sending the ACK + propagation of the ACK back to the sender
The channel utilization (the fraction of the cycle during which the sender is busy) is:
When the propagation delay is much larger than the transmission delay — a satellite link, where is about 250 ms, is the classic case — the channel utilization of stop-and-wait becomes extremely low, potentially below 1%. This is why the sliding window protocol is needed.
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 .
- Receive window: the range of sequence numbers for frames the receiver is willing to accept. The window size is denoted .
- 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 bits, giving a range of . 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:
For the GBN protocol, , so . For the SR protocol, , so .
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
- The sender may transmit several frames from its send window without waiting for acknowledgments
- 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
- 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 means that frame 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
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
- The sender may transmit several frames from its send window
- 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
- 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)
- 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
| Characteristic | Stop-and-Wait | GBN | SR |
|---|---|---|---|
| Send window size | 1 | , | , |
| Receive window size | 1 | 1 | |
| Acknowledgment style | Individual | Cumulative | Individual |
| Retransmission policy | Retransmit the current frame | Retransmit the erroneous frame and all frames after it | Retransmit only the erroneous frame |
| Receiver buffering | Not needed | Not needed | Needed |
| Channel utilization | Low | Moderate | High |
| Implementation complexity | Simple | Moderate | Complex |
| Suitable for | Low-delay links | Low-error-rate links | High-error-rate links |
TCP is in essence a selective repeat protocol that uses cumulative acknowledgment. It combines the advantages of GBN and SR: cumulative acknowledgment (like GBN), but a fast retransmit mechanism that retransmits only the lost segment (like SR).
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%?
Approach: compute the transmission delay, then apply the utilization formulas for stop-and-wait and for a sliding window.
Steps:
-
Compute the transmission delay:
-
The propagation delay is
-
The channel utilization of stop-and-wait:
-
The channel utilization of the sliding window protocol is approximately: (when the window is large enough)
Requiring :
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?
Approach: interpret ACK 4 as a cumulative acknowledgment, then slide the window forward by the acknowledged frames.
Steps:
- 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.
- 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.
- The new send window is [5, 6, 7, 0, 1] (with 3-bit sequence numbers, 6 is followed by 7, 0, 1).
- 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?
Approach: apply the constraint with , then examine what a too-large window does to sequence number reuse.
Steps:
- In the SR protocol, the send window and the receive window have equal sizes and must satisfy .
- With , , so and .
- The maximum window size is 8.
- If the window size is set to 9 (), then 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.
Exercise 1
Compare the stop-and-wait, GBN, and SR protocols in terms of their retransmission policies and receiver buffering.
Approach: compare the three protocols along the two axes named in the question.
Steps:
-
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
-
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
-
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.
Approach: compute the transmission delay and apply the stop-and-wait utilization formula.
Steps:
- Transmission delay:
- Propagation delay:
- Channel utilization:
Answer: the channel utilization is about 10.7%.
| Term | Abbreviation | Explanation |
|---|---|---|
| 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-N | GBN | Retransmits the erroneous frame and the frames after it on error |
| Selective Repeat | SR | Retransmits only the erroneous frame |
| Automatic Repeat reQuest | ARQ | A reliable transmission mechanism based on acknowledgment and timeout retransmission |
| Acknowledgment | ACK | The 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 |
