Typorithm · hard

Flow & Congestion Control

tcp-flow-controlnetworksflow-controlcongestionwindow
Saved on this device
Full lesson · 8 learning steps Open any exercise for focused practice
1

Step 1 of 8 · intro card

Learn Flow & Congestion Control

0%

L4 — Transport Layer

Flow control protects the receiver: the advertised receive window (rwnd) caps how much unacknowledged data is in flight. Congestion control protects the network: the sender's congestion window (cwnd) grows via slow start then congestion avoidance (cubic/bbr). ACKs clock the window, and window scaling enables large windows on high bandwidth-delay paths.

Flow control keeps a fast sender from overwhelming a slow receiver. The receiver advertises a receive window (rwnd) — the amount of data it can buffer — and the sender keeps in-flight, unacknowledged data within that limit.

Congestion control instead protects the shared network. The sender maintains a congestion window (cwnd) that grows from a small value during slow start, then more cautiously during congestion avoidance. Algorithms like cubic and bbr decide exactly how cwnd reacts to ACKs and loss.

The sender may send only up to the smaller of rwnd and cwnd. Incoming ACKs clock the window forward, releasing more data as bytes are confirmed. On long, fast paths the basic 16-bit window is too small, so window scaling multiplies it to keep the pipe full.

01

rwnd (receiver) is flow control; cwnd (sender) is congestion control.

02

cwnd grows via slow start, then congestion avoidance (cubic/bbr).

03

Window scaling enables large windows on high bandwidth-delay paths.

ss -ti
sysctl net.ipv4.tcp_congestion_control
# rwnd (receiver) vs cwnd (sender)
sysctl net.ipv4.tcp_window_scaling
tc qdisc show

Read the implementation

Connect each part of the code to the concept before you type.

1. TCP internals

ss -ti shows per-socket TCP info including the current congestion window and round-trip time.

ss -ti

2. Congestion algorithm

This sysctl reports the active congestion-control algorithm, such as cubic or bbr.

sysctl net.ipv4.tcp_congestion_control

3. Two windows

rwnd is the receiver's flow-control window; cwnd is the sender's congestion window. The sender uses the smaller of the two.

# rwnd (receiver) vs cwnd (sender)

4. Window scaling

Window scaling lets the advertised window exceed 64 KB, needed for high bandwidth-delay paths.

sysctl net.ipv4.tcp_window_scaling

5. Queue discipline

tc qdisc show lists the queueing disciplines that shape how packets leave each interface.

tc qdisc show

A complete learning loop

01

Understand

Read the concept map and follow the code breakdown.

02

Reconstruct

Type the implementation, repair mistakes and work through every recall exercise.

03

Verify

Use the final check without hints; revisit weak concepts in short practice sessions.

Flow & Congestion Control: Lesson & Practice · Typorithm | ApplyDjinn