TCP is one of the main transport layer protocols that is used for many applications such as HTTPS, FTP, SMTP, and SSH. It is a very reliable protocol providing sequencing and acknowledgements unlike its counterpart UDP. Another important feature of TCP is flow control. Flow control is a mechanism used by TCP to avoid the sending host from overwhelming the receiving host by sending data at too fast a rate that it can handle. This is common for setups where the receiving host application is processing data slower than the sending server or host. In order to avoid dropped packets and retransmissions which increase processing overhead, flow control allows the sender to slow down its transmission rate and dynamically adjust speeds.
Sliding Window- The main way flow control is implemented in TCP is through a sliding window mechanism. When a receiver is receiving data, there is something called a “buffer” which is where data is temporarily stored in the TCP receive buffer in the operating system. In a typical TCP design without the receiver-based flow control when this buffer is filled up to its max, any segments received afterward are dropped. These dropped packets will not be acknowledged, causing the sender to keep retransmitting the segments. After a while, the sender will realize that the segments are being dropped and then finally reduce its transmission rate. As you can see the result is many dropped segments and a bunch of retransmissions after.
Window Size- The sliding window mechanism has implemented a way for a fast sender to slow down its transmission rate without dropped packets and endless retransmissions. Every time a receiver sends an ACK, it will include a field called a “window size,” and this window size will indicate how much buffer space is available in the receiver’s layer 4 temporary buffer. When the device receives this “ACK” flag with the window size, it will be able to know exactly how much data (bytes) it can send without receiving an ACK. The window size will go up when more data is being processed, and the window size will go down when the buffer is currently more filled hence the name “sliding window” as the window size is completely dynamic. When the window size is set to 0, the sender knows not to send anything until it receives an updated window size within the next segments with the ACK flag set. This reduces retransmission by a lot, and provides bidirectional control over how much data should be sent.
Leave a Reply