https://hpbn.co/building-blocks-of-tcp/#congestion-control-avoidance
retransmission of lost data
in-order delivery
congestion control and avoidance
data integrity
congestion control
Congestion control is a recognized problem in complex networks.there will be unusual congestion problem caused by interactions between the TCP and datagram layer.
Should the roundtrip time(RRT) exceed the maximum retransmission interval for any host, that host will begin to introduce more and more copies of the same datagrams into the net. eventually all available buffers in the switching nodes will be full and packets will be dropped .
to address this issue , mutiple mechanisms were implented in TCP to goven the rate with which the data can be sent in both directions:
flow control
congestion control
congestion avoidence
flow control( advertised by receiver)
a mechanism to prevent the sender from overwhelming the receiver with data it may not be able to process
each side of the connection advertises its own receive windows size(rwnd), which communicate the windo size of the aviailable buffer space to hold the incoming data.
if the window size is 0, then the sender should stop sending data until the data in the buffer has been clear by the application layer.
This workflow continues throughout the lifetime of every TCP connection: each ACK packet carries the latest rwnd value for each side, allowing both sides to dynamically adjust the data flow rate to the capacity and processing speed of the sender and receiver.
window scaling :
default there is allocated 16 bit for the window size (65535) which is no enough to get optimal performance especially in networks that exhibit high bandwidth delay product, to address this , windows scaling allow us to raise the max receive window size from 65535 to 1 gitbit.
slow start :
The problem was that flow control prevented the sender from overwhelming the receiver, but there was no mechanism to prevent either side from overwhelming the underlying network: neither the sender nor the receiver knows the available bandwidth at the beginning of a new connection, and hence need a mechanism to estimate it and also to adapt their speeds to the continuously changing conditions within the network.
Van Jacobson documented several algorithms to address these problems: slow-start, congestion avoidance, fast retransmit, and fast recovery. All four quickly became a mandatory part of the TCP specification.
The only way to estimate the available capacity between the client and the server is to measure it by exchanging data, and this is precisely what slow-start is designed to do. To start, the server initializes a new congestion window (cwnd) variable per TCP connection,The cwnd variable is not advertised or exchanged between the sender and receiverthe maximum amount of data in flight (not ACKed) between the client and the server is the minimum of the rwnd and cwnd variables.
how do the server and the client determine optimal values for their congestion window sizes?
The solution is to start slow and to grow the window size as the packets are acknowledged: slow-start! Originally, the cwnd start value was set to 1 network segment,or every received ACK, the slow-start algorithm indicates that the server can increment its cwnd window size(exponential growth)
Increasing TCP’s Initial Congestion Window
Increasing the initial cwnd size on the server to the new RFC 6928 value of 10 segments (IW10) is one of the simplest ways to improve performance for all users and all applications running over TCP.
Once you develop an intuition for the mechanics of TCP congestion control, dozens of optimizations such as keepalive, pipelining, and multiplexing will require little further motivation.
Congestion Avoidance
It is important to recognize that TCP is specifically designed to use packet loss as a feedback mechanism to help regulate its performance.Slow-start initializes the connection with a conservative window and, for every roundtrip, doubles the amount of data in flight until it exceeds the receiver’s flow-control window, a system-configured congestion threshold (ssthresh) window, or until a packet is lost, at which point the congestion avoidance algorithm takes over.
Once the congestion window is reset, congestion avoidance specifies its own algorithms for how to grow the window to minimize further loss. At a certain point, another packet loss event will occur, and the process will repeat once over.