Skip to content

Try “polymorphism”, “TCP handshake” or “git rebase”.

    Computer Basics / Networking 2: TCP, UDP and Ports

    Flow Control and Congestion Control

    Flow control protects the receiver. Every ACK carries a receive window: "I have room for this

    Chapter 7 of 123 min read

    The Plain Picture#

    Two different reasons a courier might slow down:

    1. The receiver's storeroom is full — "Stop, I can only take 10 more boxes until I unpack." That's about the receiver.

    2. The roads are jammed — if every courier keeps pushing trucks onto a jammed highway, nobody moves at all. Everyone needs to back off. That's about the network in between.

    The Real Names#

    • Flow control protects the receiver. Every ACK carries a receive window: "I have room for this many more bytes." The sender never sends more than that without an ACK.

    • Congestion control protects the network. The sender keeps a congestion window: its own guess of how much data can be in flight without overloading the routers along the path. It sends at most the smaller of the two windows.

    Under the Hood — congestion control in one diagram#

      data in flight
           │                         packet loss! → cut back
           │                    ╱│
           │                  ╱  │         ╱
           │                ╱    │       ╱        slowly grow again
           │              ╱      │     ╱
           │   slow     ╱        │   ╱
           │   start  ╱          │ ╱
           │        ╱            │╱
           │      ╱
           │   _╱   (doubles every round trip)
           └──────────────────────────────────────────▶ time
    1. Slow start: a new connection begins with a small window — about 10 segments (~14 KB) — and doubles it every round trip while ACKs keep coming.

    2. When a packet is lost, TCP takes it as a sign of congestion and cuts the window, then grows it more carefully.

    3. Modern algorithms (like CUBIC, the Linux default, and Google's BBR) differ in exactly how they grow and cut.

    Why this matters to you: a brand-new connection is slow at first, because it starts small. A 14 KB first round trip means a 1 MB download needs several round trips just to ramp up. That's another reason to reuse warm connections (Ch 12) — and why keeping web pages' initial size small helps them load fast (Frontend Performance, Accessibility and Security (coming soon)).

    Check yourself

    3 questions
    1

    What's the difference between flow control and congestion control?

    Show answer

    Flow control stops the sender from overwhelming the receiver (receive window); congestion control stops it from overwhelming the network (congestion window).

    2

    What is slow start?

    Show answer

    Starting a connection with a small window and doubling it every round trip until loss occurs.

    3

    What does TCP treat as a signal that the network is congested?

    Show answer

    Packet loss.