TCP - Congestion control
TCP congestion control is a set of algorithms that are used to manage the amount of data that can be sent on a TCP connection. Its goal is to optimize the network utilization, while minimizing the packet loss, latency, and congestion.
Here is how TCP congestion control typically works:
Slow Start: When a TCP connection is first established, the sender starts with a small congestion window (cwnd) and then increases it exponentially with each acknowledgment (ACK) received. This phase continues until either a timeout occurs, a packet loss is detected, or the cwnd reaches a threshold called the "slow start threshold" (ssthresh).
Congestion Avoidance: Once the cwnd reaches the ssthresh, the sender transitions to the congestion avoidance phase. In this phase, the cwnd is increased more slowly, typically by one maximum segment size (MSS) for each round-trip time (RTT). This continues until packet loss is detected.
Fast Retransmit: When the sender receives three duplicate acknowledgments (three ACKs for the same data), it assumes that a packet has been lost and immediately retransmits the missing packet without waiting for a timeout. This is called "fast retransmit".
Fast Recovery: After a fast retransmit, the cwnd is reduced (usually to half of its current value), and the sender enters the "fast recovery" phase. In this phase, the cwnd is increased by one MSS for each duplicate ACK received, and by one MSS for each RTT without any lost packets. This continues until the sender receives an ACK for all the data it has sent, at which point it transitions back to the congestion avoidance phase.
These algorithms work together to optimize the data transmission rate, while minimizing the impact of congestion on the network. It's important to note that there are different variants of the TCP congestion control algorithms, and the specifics can vary depending on the implementation. For example, some implementations might use different algorithms or parameters, or might have additional phases or features, like "slow start restart" or "selective acknowledgments".