The tcp_recvspace tunable

The tcp_recvspace tunable specifies how many bytes of data the receiving system can buffer in the kernel on the receiving sockets queue.

The tcp_recvspace tunable is also used by the TCP protocol to set the TCP window size, which TCP uses to limit how many bytes of data it will send to the receiver to ensure that the receiver has enough space to buffer the data. The tcp_recvspace tunable is a key parameter for TCP performance because TCP must be able to transmit multiple packets into the network to ensure the network pipeline is full. If TCP can not keep enough packets in the pipeline, then performance suffers.

You can set the tcp_recvspace tunable using the following methods:

  • The setsockopt() system call from a program
  • The no -o tcp_recvspace=[value] command
  • The tcp_recvspace ISNO parameter
A common guideline for the tcp_recvspace tunable is to set it to a value that is at least 10 times less than the MTU size. You can determine the tcp_recvspace tunable value by dividing the bandwidth-delay product value by 8, which is computed with the following formula:
bandwidth-delay product = capacity(bits)= bandwidth(bits/second) x round-trip time (seconds)
Dividing the capacity value by 8 provides a good estimate of the TCP window size needed to keep the network pipeline full. The longer the round-trip delay and the faster the network speed, the larger the bandwidth-delay product value, and thus the larger the TCP window. An example of this is a 100 Mbit network with a round trip time of 0.2 milliseconds. You can calculate the bandwidth-delay product value with the formula above:
bandwidth-delay product = 100000000 x 0.0002 = 20000
20000/8 = 2500
Thus, in this example, the TCP window size needs to be at least 2500 bytes. On 100 Mbit and Gigabit Ethernet on a single LAN, you might want to set the tcp_recvspace and tcp_sendspace tunable values to at least 2 or 3 times the computed bandwidth-delay product value for best performance.