Flow Control in Data Link Layer
Flow Control Mechanisms
Read aloud is unavailable in this browser.
Implementing Flow Control: From Concept to Protocol
We've established why flow control is necessary, analyzed sender-receiver speed dynamics, and explored buffer management strategies. Now we turn to the mechanisms—the specific protocols and procedures that implement flow control in practice.
Flow control mechanisms vary dramatically in complexity, efficiency, and applicability. From the simplest Stop-and-Wait protocol that restricts a sender to one outstanding frame, to sophisticated credit-based systems that can fully utilize multi-gigabit links, each mechanism represents a different point in the tradeoff space between simplicity, efficiency, and implementation cost.
In this page, we'll systematically examine each major flow control mechanism, understanding its operation, analyzing its efficiency, and identifying its appropriate use cases.
By the end of this page, you will understand Stop-and-Wait and its efficiency limitations, master Sliding Window protocol operation and window size selection, learn Ethernet PAUSE and Priority Flow Control, explore credit-based and rate-based mechanisms, and be able to select appropriate mechanisms for given scenarios.
Stop-and-Wait Protocol
Stop-and-Wait is the simplest flow control mechanism: the sender transmits one frame, then waits for an acknowledgment (ACK) before transmitting the next. This fundamentally prevents overflow because the receiver has time to process each frame before the next arrives.
Protocol Operation
- Sender transmits frame N
- Sender waits (cannot send anything else)
- Receiver processes frame N
- Receiver sends ACK for frame N
- Sender receives ACK
- Sender transmits frame N+1
- Repeat...
Why It Works for Flow Control
Stop-and-Wait inherently limits the sender's rate. The maximum transmission rate is:
$$R_{max} = \frac{L}{RTT + T_{proc}}$$
Where:
- L = Frame size in bits
- RTT = Round-trip time
- Tproc = Processing time at receiver
Even if the sender could transmit faster, it's blocked waiting for ACKs. This 'pacing' prevents receiver overflow.
Efficiency Analysis
The critical metric is link utilization—the fraction of time spent actually transmitting data versus waiting.
$$Utilization = \frac{T_{trans}}{T_{trans} + RTT}$$
Where:
- Ttrans = L/R = Transmission time for one frame
- RTT = Round-trip time (propagation + ACK transmission + processing)
Or, in terms of the propagation-bandwidth product:
$$U = \frac{1}{1 + 2a}$$
Where a = (propagation delay × bandwidth) / frame size = one-way BDP/frame size
This reveals the fundamental problem: as links get faster or longer, utilization plummets.
Stop-and-Wait Efficiency Calculation
Comparing Stop-and-Wait on a LAN versus WAN link
Scenario 1: Local Ethernet (100m)
- Link speed: 1 Gbps
- Propagation delay: 0.5 μs (100m ÷ 2×10⁸ m/s)
- Frame size: 1500 bytes = 12,000 bits
- Transmission time: 12 μs
- RTT: ≈ 1 μs (2 × 0.5 μs)
$$U = \frac{12 \mu s}{12 \mu s + 1 \mu s} = 92.3%$$
Scenario 2: Cross-country link (3000 km)
- Link speed: 1 Gbps
- Propagation delay: 15 ms (3×10⁶m ÷ 2×10⁸ m/s)
- Frame size: 1500 bytes = 12,000 bits
- Transmission time: 12 μs
- RTT: ≈ 30 ms
$$U = \frac{12 \mu s}{12 \mu s + 30ms} = 0.04%$$
Stop-and-Wait works reasonably (92%) for a LAN but wastes 99.96% of a cross-country link! This is why Stop-and-Wait is used only for low-speed or low-delay links.
Stop-and-Wait's simplicity comes at a severe efficiency cost for high-bandwidth or high-delay links. It's appropriate for serial connections, low-speed wireless, or links where simplicity of implementation outweighs throughput concerns. Never use it for high-performance connections.
Sliding Window Protocol
Sliding Window protocols solve Stop-and-Wait's efficiency problem by allowing multiple frames to be 'in flight' simultaneously. The sender maintains a window of sequence numbers it's allowed to transmit; the receiver controls flow by adjusting this window.
Core Concepts
Sender Window (Ws): Range of sequence numbers the sender may transmit without waiting for acknowledgment. As ACKs arrive, the window 'slides' forward.
Receiver Window (Wr): Range of sequence numbers the receiver will accept. Frames outside this range are discarded or cause errors.
Window Size: Maximum number of unacknowledged frames allowed. Larger window = more frames in flight = higher potential throughput.
Sequence Number Space: Typically 0 to 2^n - 1 for n-bit sequence numbers. Must be larger than window size to avoid ambiguity.
Flow Control via Window Adjustment
The receiver controls sending rate by adjusting the window it advertises:
- Large window advertised: Sender can have many frames in flight, high throughput
- Small window advertised: Sender is constrained, lower throughput
- Zero window: Sender must stop completely until window opens
Window Advertisement Process
- Receiver includes window size in every ACK: 'I've received up to N, and you may have up to W frames outstanding'
- Sender calculates usable window: min(advertised window, congestion window)
- Sender transmits up to the usable window limit
- As receiver processes frames and frees buffer space, it advertises larger window
- As receiver's buffer fills, it advertises smaller window
Efficiency with Sliding Window
For window size W frames:
$$U = \begin{cases} 1 & \text{if } W \geq 1 + 2a \ \frac{W}{1 + 2a} & \text{if } W < 1 + 2a \end{cases}$$
Where a = propagation delay × bandwidth / frame size
This means: if the window is large enough to cover the BDP (plus one for the frame being sent), we achieve full utilization.
| Link Scenario | BDP (bits) | BDP (frames) | Min Window Size |
|---|---|---|---|
| LAN 100m, 1 Gbps | 1,000 bits | < 1 frame | 1-2 frames |
| Metro 50 km, 10 Gbps | 5 Mbits | 417 frames | ~420 frames |
| Continental 3000 km, 10 Gbps | 300 Mbits | 25,000 frames | ~25,000 frames |
| Satellite 35,000 km, 50 Mbps | 35 Mbits | 2,917 frames | ~3,000 frames |
Sliding Window vs Stop-and-Wait
Comparing efficiency on the same cross-country link
Link Parameters:
- Speed: 1 Gbps
- RTT: 30 ms
- Frame size: 1500 bytes = 12 Kbits
Stop-and-Wait (Window = 1): $$U = \frac{12 \mu s}{30 ms} = 0.04%$$
Sliding Window (Window = 3000 frames): BDP = 1 Gbps × 30 ms = 30 Mbits = 2500 frames Window (3000) > BDP (2500) $$U = 100%$$
Effective Throughput:
- Stop-and-Wait: 0.04% × 1 Gbps = 400 Kbps
- Sliding Window: 100% × 1 Gbps = 1 Gbps
Sliding Window achieves 2500× the throughput of Stop-and-Wait on this link by allowing enough frames in flight to cover the BDP.
The sequence number space must be at least twice the window size to avoid ambiguity between old and new frames. For Go-Back-N: seq# ≥ W+1. For Selective Repeat: seq# ≥ 2W. Using insufficient sequence numbers causes protocol failures that are very difficult to debug.
Ethernet PAUSE Frames (IEEE 802.3x)
Ethernet PAUSE provides link-level flow control for full-duplex Ethernet. When a receiver's buffers approach exhaustion, it sends a PAUSE frame instructing the sender to stop transmission for a specified duration.
PAUSE Frame Structure
| Field | Size | Value/Purpose |
|---|---|---|
| Destination MAC | 6 bytes | 01:80:C2:00:00:01 (reserved multicast) |
| Source MAC | 6 bytes | Sender's MAC address |
| EtherType | 2 bytes | 0x8808 (MAC Control) |
| MAC Control Opcode | 2 bytes | 0x0001 (PAUSE) |
| Pause Time | 2 bytes | Quanta of pause (1 quantum = 512 bit times) |
| Padding | 42 bytes | Zero padding to minimum frame size |
| FCS | 4 bytes | Frame check sequence |
Pause Duration Calculation
Pause time is measured in 'quanta,' where 1 quantum = time to transmit 512 bits.
For 10 Gbps Ethernet:
- 1 quantum = 512 bits ÷ 10 Gbps = 51.2 ns
- Maximum pause (0xFFFF quanta) = 65,535 × 51.2 ns ≈ 3.36 ms
Protocol Operation
- Receiver's buffer occupancy exceeds threshold
- Receiver sends PAUSE frame with desired pause duration
- Sender receives PAUSE, stops transmission
- Sender waits specified duration or until PAUSE with 0 duration received
- Sender resumes transmission
Advantages of PAUSE Frames
- Simple: Binary on/off control, easy to implement in hardware
- Fast: Operates at line speed, minimal processing delay
- Effective: Completely prevents overflow when properly configured
- Standard: Widely supported in networking equipment
Limitations of PAUSE Frames
- All-or-nothing: When PAUSE is asserted, ALL traffic stops—including latency-sensitive traffic that wasn't causing the problem
- Head-of-line blocking: High-priority traffic blocked because low-priority traffic filled buffers
- Congestion spreading: PAUSE can cascade backwards, spreading congestion through the network
- No prioritization: Cannot differentiate between traffic classes
When to Use PAUSE
- Point-to-point links between trusted devices
- Storage networks (iSCSI, NFS over Ethernet) where lossless operation is required
- FCoE (Fibre Channel over Ethernet) which mandates lossless Ethernet
- Situations where all traffic is equally important
PAUSE Frame Timing Example
Calculating PAUSE parameters for a 10 Gbps switch port
Scenario: Switch with 10 Gbps port, 100 KB input buffer, connected to server.
Given:
- Link speed: 10 Gbps
- Buffer capacity: 100 KB = 800 Kbits
- PAUSE threshold: 75% = 75 KB used
- Resume threshold: 50% = 50 KB used
Calculations:
Time to overflow from threshold: Remaining buffer = 100 KB - 75 KB = 25 KB = 200 Kbits Time to overflow = 200 Kbits ÷ 10 Gbps = 20 μs
Minimum PAUSE quanta needed: 1 quantum = 512 bits ÷ 10 Gbps = 51.2 ns Minimum quanta = 20 μs ÷ 51.2 ns ≈ 391 quanta
Practical PAUSE value: Use 500 quanta (25.6 μs) for safety margin
Recovery time: Drain from 75 KB to 50 KB = 25 KB Processing at ~9 Gbps effective = 22 μs Send PAUSE with 0 quanta to resume early if needed
PAUSE frame with 500 quanta stops transmission for 25.6 μs, providing time for the receiver to process frames and drop buffer occupancy below the resume threshold.
When a device sends PAUSE, its sender stops... but its sender's buffers now fill, potentially triggering another PAUSE. This cascade can propagate across multiple hops, freezing large portions of the network. This is why PAUSE is generally avoided in shared network environments.
Priority Flow Control (IEEE 802.1Qbb)
Priority Flow Control (PFC) extends Ethernet PAUSE to support per-priority-class flow control. Instead of stopping all traffic, PFC can pause only specific priority classes while allowing others to continue.
The Problem PFC Solves
Consider a link carrying both storage traffic (must be lossless) and general data (can tolerate drops). With basic PAUSE:
- When storage traffic fills buffers, PAUSE stops everything
- Latency-sensitive data traffic is unnecessarily delayed
- When data traffic fills buffers, PAUSE stops everything
- Storage traffic performance degraded by unrelated congestion
PFC allows:
- Storage traffic: Priority 3, enabled for PFC (lossless)
- Data traffic: Priority 0, not enabled for PFC (lossy)
- Storage congestion triggers PAUSE only for priority 3
- Data traffic continues unaffected
PFC Frame Structure
PFC uses the same MAC Control frame type as PAUSE (0x8808) but with a different opcode:
| Field | Size | Value/Purpose |
|---|---|---|
| Destination MAC | 6 bytes | 01:80:C2:00:00:01 |
| Source MAC | 6 bytes | Sender's MAC address |
| EtherType | 2 bytes | 0x8808 (MAC Control) |
| Opcode | 2 bytes | 0x0101 (PFC) |
| Priority Enable Vector | 2 bytes | Bitmap: which priorities to pause |
| Time[0] through Time[7] | 16 bytes | Pause time for each of 8 priorities |
| Padding | 26 bytes | Zero padding |
| FCS | 4 bytes | Frame check sequence |
Priority Enable Vector
An 8-bit bitmap indicating which priorities are being paused:
- Bit 0 = Priority 0
- Bit 1 = Priority 1
- ...
- Bit 7 = Priority 7
Each paused priority has its own timer, allowing independent control.
| Feature | Standard PAUSE | Priority Flow Control |
|---|---|---|
| Granularity | All traffic | Per-priority class (8 classes) |
| Frame type | 0x8808, opcode 0x0001 | 0x8808, opcode 0x0101 |
| Pause timers | Single timer | 8 independent timers |
| Mixed traffic support | Poor (all stops) | Excellent (selective pause) |
| Complexity | Low | Medium |
| Use case | Simple point-to-point | Converged networks (DCB) |
Data Center Bridging (DCB) Context
PFC is a key component of Data Center Bridging (DCB), a set of IEEE standards for lossless Ethernet in data centers:
- 802.1Qbb: Priority Flow Control (PFC)
- 802.1Qaz: Enhanced Transmission Selection (ETS) - bandwidth allocation
- 802.1Qau: Congestion Notification (QCN) - endpoint congestion management
- DCBX: Discovery and capability exchange protocol
Together, these enable 'converged' data center networks carrying storage, compute, and management traffic on shared Ethernet infrastructure.
PFC Best Practices
- Limit PFC-enabled priorities: Enable only for traffic that truly requires lossless delivery (typically just 1-2 classes)
- Configure headroom properly: Sufficient buffer for in-flight frames after PFC is sent
- Monitor PFC statistics: High PFC pause counts may indicate congestion or misconfiguration
- Avoid PFC deadlock: Circular buffer dependencies can cause permanent freezes (requires careful network design)
Modern switches implement 'PFC watchdog'—if a priority remains paused for an abnormally long time (indicating potential deadlock or misconfiguration), the watchdog disables PFC for that priority, dropping frames but allowing the network to recover. This prevents indefinite freezes at the cost of some data loss.
Credit-Based Flow Control
Credit-based flow control represents the most sophisticated approach to preventing receiver overflow. Instead of reactive PAUSE signals, the receiver proactively grants 'credits' representing permission to send a specific amount of data. The sender can only transmit when it has credits; credits are replenished as the receiver frees buffer space.
Core Mechanism
- Receiver allocates buffer space for sender and issues initial credits
- Credits represent bytes (or frames) the sender may transmit
- Sender decrements credit counter with each transmission
- When credits reach zero, sender must stop
- Receiver issues new credits as it frees buffer space
- Sender receives credits and can resume
Key Advantages
- Lossless by design: Sender cannot over-send if credits are properly managed
- Fine-grained control: Credits can be issued in precise amounts
- Works with long links: Credits account for BDP—receiver issues credits equal to buffer size plus BDP
- No head-of-line blocking: Can issue credits per-destination or per-class
Credit Sizing
For lossless operation, total credits issued must be:
$$Credits \geq Buffer_Size + BDP$$
Where BDP accounts for credits in transit from receiver to sender plus data in transit from sender to receiver.
Credit-Based in Practice: InfiniBand
InfiniBand High-Speed Interconnect uses credit-based flow control extensively:
Virtual Lanes (VLs):
- Up to 16 virtual lanes per link
- Each VL has independent credit pool
- Enables quality-of-service without head-of-line blocking
Credit Exchange:
- Receiver hardware tracks buffer availability
- Credits sent in 'Credit ACK' packets
- Sender maintains per-VL credit counters
- Hardware automatically stops transmission when credits exhausted
Guaranteed Lossless:
- Properly configured InfiniBand never drops frames due to congestion
- Critical for RDMA operations that bypass error recovery
- Enables 'cut-through' message passing without buffering
Credit-Based in Fibre Channel
Fibre Channel, the storage networking standard, uses Buffer-to-Buffer (BB) credits:
- Each port has BB credit count representing receive buffer frames
- Sender consumes credit with each frame sent
- Receiver returns credit with R_RDY primitive signal
- Link goes idle when credits exhausted
- Buffer space calculated for distance: longer links need more credits
| Characteristic | PAUSE Frames | Sliding Window | Credit-Based |
|---|---|---|---|
| Control granularity | Binary (on/off) | Window size | Byte/frame precise |
| Proactive/Reactive | Reactive | Mixed | Proactive |
| BDP handling | Must size thresholds | Window ≥ BDP | Credits ≥ Buffer + BDP |
| Implementation complexity | Low | Medium | High |
| Hardware requirements | Timer logic | Sequence tracking | Per-flow credit counters |
| Typical use case | Ethernet link | WAN protocols | InfiniBand, Fibre Channel |
Fibre Channel Credit Calculation
Determining BB credits for a 16 Gbps FC link over 10 km
Given:
- Link speed: 16 Gbps
- Distance: 10 km
- Frame size: 2112 bytes (typical max FC frame)
- Propagation speed: 2×10⁸ m/s
Calculations:
One-way propagation delay: $$d = \frac{10,000m}{2 \times 10^8 m/s} = 50 \mu s$$
Round-trip time: $$RTT = 100 \mu s$$
Data in flight during RTT: $$BDP = 16 \times 10^9 \times 100 \times 10^{-6} = 1.6 Mbits = 200 KB$$
Frames in flight: $$\frac{200 KB}{2112 bytes} \approx 97 frames$$
BB Credits needed: Minimum: 97 credits (for full link utilization) Practical: 100+ credits (safety margin for credit transit time)
A 10 km 16 Gbps Fibre Channel link requires approximately 100 BB credits to fully utilize the link without flow control throttling.
Credit-based systems can suffer 'credit starvation' if credit return messages are delayed or lost. Robust implementations include credit update timeouts, redundant credit signaling, and credit recovery protocols. Without these, a single lost credit message could permanently reduce link throughput.
Rate-Based Flow Control
Rate-based flow control takes a fundamentally different approach: instead of controlling how much data is outstanding, it controls the rate at which data is transmitted. The sender is limited to a specific transmission rate that the receiver can sustain.
Approach
- Sender and receiver negotiate a transmission rate
- Sender transmits at exactly that rate (using token bucket, leaky bucket, or similar)
- Receiver can keep up because rate matches its capacity
- No buffer overflow occurs (in steady state)
Rate Limiting Mechanisms
Token Bucket:
- Bucket holds 'tokens' representing permission to transmit
- Tokens arrive at fixed rate r
- Each byte/frame transmitted consumes a token
- Bucket has maximum capacity b (burst size)
- When bucket empty, transmission waits
- Allows short bursts up to b, sustained rate r
Leaky Bucket:
- Data enters bucket at variable rate
- Data leaves bucket at fixed rate r
- Bucket has maximum capacity b
- Smooths traffic to constant rate
- Excess data dropped (or queued) when bucket full
Rate Negotiation
For rate-based flow control to work, both parties must agree on the rate:
Explicit Negotiation:
- During connection setup, exchange rate capabilities
- Agree on rate = min(sender capability, receiver capability, link capacity)
- Used in ATM, MPLS with traffic engineering
Dynamic Adjustment:
- Start with initial rate
- Monitor for overflow signals or ACK patterns
- Increase rate when no congestion, decrease when detected
- Similar to TCP congestion control but at Layer 2
Quantized Congestion Notification (QCN)
IEEE 802.1Qau QCN implements rate-based flow control for Ethernet:
- Congested switch generates Congestion Notification Messages (CNMs)
- CNM sent to original traffic source (traced via MAC)
- Source reduces transmission rate based on feedback intensity
- Rate gradually increased when no further CNMs received
- Provides proportional response—heavier congestion = larger rate reduction
- •Predictable, smooth traffic flow
- •No buffering oscillations
- •Works for long-distance links
- •Can guarantee Quality of Service
- •Sender controls its own timing
- •Wastes capacity when receiver could go faster
- •Complex rate negotiation required
- •Slow adaptation to changing conditions
- •Requires precise timing at sender
- •Under-utilization if rate set too low
Rate-based flow control excels when traffic characteristics are predictable and consistent (CBR audio/video), when guaranteed service levels are required, or when the overhead of per-frame acknowledgments is prohibitive. It's less suitable for bursty, unpredictable traffic where window-based approaches can better match instantaneous available capacity.
Mechanism Selection Guide
Selecting the appropriate flow control mechanism requires understanding your specific requirements and constraints. Here's a systematic decision framework:
Decision Factors
- Link characteristics: Speed, distance, error rate
- Traffic type: Latency-sensitive, bulk, mixed
- Loss tolerance: Lossless required or acceptable drops
- Implementation complexity: Hardware vs. software, development cost
- Interoperability: Standard protocols vs. proprietary
- Multi-traffic-class: Need to differentiate traffic types
| Scenario | Recommended Mechanism | Rationale |
|---|---|---|
| Low-speed serial link | Stop-and-Wait | Simple, adequate efficiency at low BDP |
| LAN switch port, mixed traffic | No flow control or tail drop | TCP handles loss recovery, simplicity |
| Storage network (iSCSI, NFS) | PAUSE frames | Lossless required, single traffic class |
| Converged data center | PFC with DCB | Lossless for storage, lossy for data |
| InfiniBand cluster | Credit-based | Native to InfiniBand, RDMA requirements |
| Fibre Channel SAN | BB Credits | Standard FC flow control, long distance |
| Video streaming server | Rate-based + PAUSE backup | Smooth delivery, prevent overflow |
| High-speed WAN | Sliding Window (TCP) | Transport layer handles flow control |
Common Combinations
Real-world systems often combine multiple mechanisms:
Enterprise Network (edges):
- Edge ports: No DLL flow control (rely on TCP)
- Storage ports: PFC for storage priority class
- Uplinks: PFC or no control depending on oversubscription
Data Center Spine-Leaf:
- Leaf-to-server: PFC for RoCE/iSCSI traffic
- Leaf-to-spine: Often no flow control (large buffers + ECN)
- Spine-to-spine: ECN-based congestion control
Storage Array Backend:
- InfiniBand fabric: Credit-based flow control
- FC connections: BB credit flow control
- Ethernet front-end: Standard TCP/IP or iSER with PFC
High-Frequency Trading:
- Kernel bypass NICs: Hardware flow control
- Ultra-low-latency switches: Cut-through with minimal buffering
- Often disable flow control entirely, rely on over-provisioning
Mismatched flow control configurations between link partners cause problems. If one side expects PAUSE and the other ignores it, drops occur. If one side sends unexpected PAUSE, the other may ignore it or treat it as an error. Always verify configuration consistency across links.
KEEP LEARNING
There’s more to understand.
You’re reading the introduction. Create a free account to read the complete lesson, save notes and keep track of your progress.