TCP flow control and the sliding window

Transmission Control Protocol (TCP) uses a sliding window for flow control. Before you tune any TCP/IP settings, first understand how the TCP sliding window works.

The TCP sliding window determines the number of unacknowledged bytes, x, that one system can send to another. Two factors determine the value of x:
  • The size of the send buffer on the sending system
  • The size and available space in the receive buffer on the receiving system

The sending system cannot send more bytes than space that is available in the receive buffer on the receiving system. TCP on the sending system must wait to send more data until all bytes in the current send buffer are acknowledged by TCP on the receiving system.

On the receiving system, TCP stores received data in a receive buffer. TCP acknowledges receipt of the data, and advertises (communicates) a new receive window to the sending system. The receive window represents the number of bytes that are available in the receive buffer. If the receive buffer is full, the receiving system advertises a receive window size of zero, and the sending system must wait to send more data. After the receiving application retrieves data from the receive buffer, the receiving system can then advertise a receive window size that is equal to the amount of data that was read. Then, TCP on the sending system can resume sending data.

The available space in the receive buffer depends on how quickly data is read from the buffer by the receiving application. TCP keeps the data in its receive buffer until the receiving application reads it from that buffer. After the receiving application reads the data, that space in the buffer is available for new data. The amount of free space in the buffer is advertised to the sending system, as described in the previous paragraph.

Ensure that you understand the TCP window size when you use sliding window for flow control. The window size is the amount of data that can be managed. You might need to adjust the window size if the receive buffer receives more data than it can communicate. For more information about optimizing the TCP window size, see Optimization of window size for different operations on the same system.

How the send and receive buffers interact has the following consequences:
  • The maximum number of unacknowledged bytes that a system can send is the smaller of two numbers:
    • The send buffer size on the sending system
    • The receive window size that the receiving system advertises to the sending system
  • When the receiving application reads data as fast as the sending system can send it, the receive window stays at or near the size of the receive buffer. The result is that data flows smoothly across the network. If the receiving application can read the data fast enough, a larger receive window can improve performance.
  • When the receive buffer is full, the receiving system advertises a receive window size of zero. The sending system must pause and temporarily cannot send any more data.
  • In general, more frequent occurrences of zero size for the receive window results in overall slower data transmission across the network. Every time the receive window is zero, the sending system must wait before sending more data.

Typically, you set the send window and the receive window sizes separately for an operating system. In AIX®, for example, the tcp_sendspace and tcp_recvspace parameters of the no command can be used to set the send and receive window sizes.

The sliding window that is used by Tivoli Storage Manager operations is controlled with the TCPWINDOWSIZE option.