Transport Layer Congestion Control and Leaky Bucket vs Token Bucket

Transport Layer Congestion Control and Leaky Bucket vs Token Bucket

Verified Sources
Nov 4, 2026

Transport-layer congestion control prevents a sender from injecting traffic faster than the network can handle. In practice, transport protocols accomplish this via a feedback loop that uses loss and delay/ACK behavior as congestion signals, then adjusts the sending rate by changing the sender’s control variables (e.g., TCP’s congestion window).

Transport-layer congestion control and congestion window (cwnd) are tightly linked: TCP grows cwndcwnd when the network appears healthy, and reduces it when congestion is inferred.

A key idea is that TCP uses:

  • slow start
  • congestion avoidance
  • fast retransmit
  • fast recovery

Important note (scope): There are multiple congestion-control designs across protocols. The most widely taught mechanism in textbooks is TCP Reno-style behavior. Other TCP variants (CUBIC, BBR) and QUIC congestion control differ in details, but the feedback-and-rate-adjustment principle remains the same.

TCP Congestion Control (cwnd, ssthresh, fast retransmit/fast recovery) — Tutorial

1) How transport-layer congestion control provides stability

At a high level, congestion control aims to keep the network in a regime where queues remain bounded and packet loss (or ECN marks) is rare.

TCP-style closed-loop control (conceptual)

  1. Start conservatively with a small cwndcwnd to avoid overwhelming routers.
  2. Probe for capacity:
    • If ACKs arrive without congestion indications, increase cwndcwnd.
  3. React to congestion:
    • Loss / timeout suggests queues are overflowing; reduce cwndcwnd sharply.
    • Duplicate ACKs suggest segment loss but route is still delivering other segments; reduce cwndcwnd less drastically and recover faster.

This yields a control law that alternates between probing and backing off, preventing persistent overload.

Relationship to reliability mechanisms

TCP also has reliability mechanisms (ACKs and retransmissions). Congestion control is different: retransmissions can occur due to link errors, but congestion control treats certain retransmission patterns as congestion evidence and reduces future sending rate accordingly.

Duplicate ACK is therefore central: it provides earlier, finer-grained feedback than waiting for a timeout.

Transport-layer (TCP-style) congestion-control loop

  1. 1
    Step 1

    Start with a small congestion window and a slow-start threshold; send up to cwndcwnd worth of unacknowledged data.

  2. 2
    Step 2

    Use incoming ACKs to measure how much data the receiver successfully got and infer network health.

  3. 3
    Step 3

    If cwnd<ssthreshcwnd < ssthresh, increase cwndcwnd rapidly (commonly exponentially) per successful acknowledgments.

  4. 4
    Step 4

    If cwnd≥ssthreshcwnd \ge ssthresh, increase cwndcwnd more slowly (commonly roughly linearly) to probe capacity gently.

  5. 5
    Step 5

    If a segment is lost, you’ll typically observe duplicate ACKs or eventually a timeout.

  6. 6
    Step 6

    On duplicate ACKs, retransmit the missing segment and reduce cwndcwnd (often multiplicatively) without returning to slow start.

  7. 7
    Step 7

    On timeout, treat it as stronger congestion evidence: reduce cwndcwnd substantially and return toward slow start behavior.

  8. 8
    Step 8

    Continue the loop to converge around the path’s sustainable sending rate.

Pro Tip: Think in terms of “rate control with feedback”

Congestion control is essentially a feedback controller: ACK patterns and loss events act as sensor signals, and cwndcwnd (or pacing rate) is the actuator.

Warning: Loss is not always congestion

Packet loss can come from wireless errors or link-layer problems. TCP often treats loss as congestion anyway—this can temporarily underutilize a clean link. ECN and modern algorithms aim to reduce this ambiguity.

2) Leaky Bucket vs Token Bucket: definitions and differentiation

Both leaky bucket and token bucket are classic traffic shaping and rate limiting algorithms used in the data plane (often implemented in routers/switches). They control how bursts are handled while enforcing a long-term average rate.

Key parameters:

  • For token bucket: token generation rate and bucket capacity (burst size).
  • For leaky bucket: drain rate and queue/buffer capacity.

Traffic shaping and rate limiting are the general goals.

Leaky bucket (queue that “leaks” at constant rate)

  • Concept: A bucket holds up to BB bytes (or tokens representing bytes).
  • A constant rate process removes (“leaks”) one unit per time interval.
  • If packets arrive faster than the leak rate:
    • buffer fills up to BB
    • once full, arrivals are dropped (or delayed if implemented with queueing semantics).

This tends to create a smoother, more regular output stream.

Token bucket (bucket fills with tokens; sending consumes tokens)

  • Tokens are generated at a fixed average rate rr up to a maximum capacity BB.
  • To send/forward 11 unit of data, you must “spend” (consume) 11 token.
  • If a packet arrives and tokens are available, it is forwarded immediately.
  • If tokens are insufficient:
    • the packet is typically delayed until enough tokens accumulate, or dropped depending on the implementation policy.

This allows bursty traffic up to the capacity BB while still enforcing the average rate rr over time.

3) Direct comparison table

FeatureLeaky BucketToken Bucket
Output shapeSmoother, more “regular” rateAllows bursts up to bucket size
Core mechanismQueue drains at constant rateTokens accumulate at constant rate
Burst behaviorGenerally limited by buffer; bursts get clipped by dropping when fullBursts can pass as long as tokens were accumulated (up to BB)
Long-term rate enforcementYes (average drain rate)Yes (average token generation rate)
Typical action on excessDrop when bucket/queue fullDelay until tokens available or drop if configured
Intuition“Leak fixed; overflow is waste”“Accumulate credits; spend to send”

Intuition: Burst tolerance vs smoothing (conceptual)

Higher means the algorithm more naturally allows bursts before enforcement (ignoring implementation-specific drop/delay policies).

Edge cases and practical implementation details

Rate control behavior over time (conceptual)

Initial state

t0

Token bucket may start with some tokens (up to BB); leaky bucket starts with an empty/initial queue."

Burst arrival

High arrival burst

Token bucket forwards immediately while tokens last; leaky bucket buffers then drops once buffer is full."

Sustained rate exceeds limit

Enforcement phase

Both maintain average constraints: token bucket runs out of tokens and delays/drops; leaky bucket leaks at a fixed rate and overflows."

Traffic returns to compliant rate

Recovery

Token bucket regains tokens; leaky bucket buffer drains back toward empty."

Knowledge Check

Question 1 of 4
Q1Single choice

In TCP congestion control, what is the main purpose of the congestion window (cwnd)?