TCP congestion control is a mechanism used to control the congestion in a TCP network. TCP is the underlying transport-layer protocol which is utilised by HTTP to transfer packets (data) between two nodes (servers). With this in mind, TCP congestion control is used to manage the amount of data sent in a network given the current congestion level of the network. We will explore further.
Principles behind congestion control
Simply put, congestion control works (primarily) using the following mechanisms :
- Slow Start
- Congestion avoidance
- Fast retransmit
- Fast recovery
The slow start algorithm works by the sender probing the recieving server gradually to confirm that a particular size of packets can be sent on the network. To put this formally, the congestion window (cwnd) is the maximum size of packets that can be across the network during a given round-trip (RTT - Trip between sender and reciever). If the reciever recieved the packet it sends an acknowledgement that the packet has been recieved, the sender then sends two packets, then four packets and so forth. The idea behind this is to ensure that the recieving server is not overwhelmed with more data than it can handle; this is quite an intuitive way of doing this and is used as a mechanism to prevent congestion today on the world wide web. Ok, so there is a bit more to cover. The slow start algorithm is used in the network when the cwnd is less than something called the slow start threshold (ssthresh). The ssthresh is set as a high number to begin with, but then must be reduced depending on the congestion in the network, meaning that it changes and is not a static property. Again, if the cwnd is less than the ssthresh then the slow start algorithm is used.
The slow start algorithm is used when the congestion window size is less than the slow start threshold.
Once the cwnd is more than the ssthresh then the congestion avoidance algorithm is used. As revealed in its name, congestion avoidance is used to avoid congestion in the network. After the exponential increase in packet transfer caused by the slow start algorithm, congestion avoidance increases the cwnd by once per round-trip. Once in this stage, the network is trying to avoid congestion which is detected and then handled by reducing the cwnd and returning to the slow start phase to probe the network again until the threshold requirements are met, as discussed in the previous section (on slow start).
The congestion avoidance is used when the congestion window size is more than the slow start threshold.
Perhaps I will write another article about fast retransmission and recovery in more detail, but this is just an overview on these two foundational concepts in TCP congestion control :)
-  - https://tools.ietf.org/html/rfc5681#page-4