Wednesday, April 12, 2006

TCP/IP tweaking

ifconfig eth0 -mtu 1412(default is 1500)
or editing /etc/ppp/option

Tuning TCP for Linux 2.4 and 2.6



The maximum buffer sizes for all sockets can be set with /proc variables:


	/proc/sys/net/core/rmem_max       - maximum receive window
/proc/sys/net/core/wmem_max - maximum send window


These determine the maximum acceptable values for SO_SNDBUF and SO_RCVBUF
(arguments to setsockopt() system call). The kernel sets the actual memory
limit to twice the requested value (effectively doubling rmem_max and
wmem_max) to provide for sufficient memory overhead.



The per connections memory space defaults are set with two 3 element arrays:


	/proc/sys/net/ipv4/tcp_rmem       - memory reserved for TCP rcv buffers
/proc/sys/net/ipv4/tcp_wmem - memory reserved for TCP snd buffers

These are arrays of three values: minimum, default and maximum that are used to
bound autotuning and balance memory usage while under global memory stress.



The following values would be reasonable for path with a 4MB BDP (You
must be root):



echo 2500000 /proc/sys/net/core/wmem_max
echo 2500000 /proc/sys/net/core/rmem_max
echo "4096 5000000 5000000" /proc/sys/net/ipv4/tcp_rmem
echo "4096 65536 5000000" /proc/sys/net/ipv4/tcp_wmem


All Linux 2.4 and 2.6 versions include sender side autotuning, so the actual
sending socket buffer (wmem value)
will be dynamically updated for each connection.
You can check to see if receiver side autotuning is present an enabled by
looking at the file:


	/proc/sys/net/ipv4/tcp_moderate_rcvbuf

If it is present and enabled (value 1) the receiver socket buffer size (rmem value) will be
dynamically updated for each connection. If it is not present
you may want to get a newer kernel. Generally autotuning should not be
disabled unless there is a specific need, e.g. comparison studies of TCP
performance.
If you do not have autotuning (Linux 2.4 before 2.4.27 or 2.6 before 2.6.7) you may
want to set the default tcp_rmem value (the middle value) to a more
accurate estimate of the actual path BDP, to minimize possible interactions with
other applications.



Do not adjust tcp_mem unless you know exactly what
you are doing. This array determines how the system balances the total network
memory usage against other memory usage, such as disk buffers. It is
initialized at boot time to appropriate fractions of total system memory.



No comments:

Post a Comment