how/network
How does TCP "know" how fast to send data? It does not. It tries faster and faster until it hits a wall. Then it cuts the rate in half and tries again.
When you download a file, your TCP does not know the bandwidth of the link. Nobody handed it a slip saying "you have 100 Mbit/s". To find out, it has to try.
TCP starts with a small window (cwnd = congestion window: how many
segments are "in flight" at once), grows it gradually, and when it
hits packet loss it figures "this is my ceiling", cuts the rate,
and keeps going more carefully.
This algorithm is called AIMD (Additive Increase, Multiplicative Decrease): linear growth and halving on loss. On a graph it draws the distinctive "sawtooth", which is the "voice of TCP".
Press ▶ to watch cwnd grow from 1 segment to its maximum, catch a loss, and continue.
After the three-way handshake the TCP stack gets to work.
The initial cwnd (congestion window) = 1 segment (or 10
on modern Linux with initcwnd=10).
This means: "the sender may have no more than 1 packet in flight without an ACK". Next we will increase it.
The main question: by how much, and how fast, do we increase it?
recap
What to remember:
sysctl net.ipv4.tcp_congestion_control.
Available ones: cat /proc/sys/net/ipv4/tcp_available_congestion_controlThis is closely tied to [[tcp-retransmission|retransmission]]: fast-retransmit triggers halving of cwnd (those are the "teeth of the sawtooth" on the graph).