How can I change the TCP/IP tuning parameters?
by The editorial team
All TCP/IP tuning parameters are located under the /proc/sys/net/ directory. For example, here is a list of the most important tuning parameters, along with a short description of their meaning:
- /proc/sys/net/core/rmem_max – Maximum TCP Receive Window.
- /proc/sys/net/core/wmem_max – Maximum TCP Send Window.
- /proc/sys/net/ipv4/tcp_timestamps – Timestamp ( RFC 1323) add 12 bytes to the TCP headers.
- /proc/sys/net/ipv4/tcp_sack – TCP selective acknowledgments.
- /proc/sys/net/ipv4/tcp_window_scaling – support for large TCP Windows (RFC 1323). Needs to be set to 1 if the Max TCP Window is over 65535.
- mem_default = Default Receive Window.
- rmem_max = Maximum Receive Window.
- wmem_default = Default Send Window.
- wmem_max = Maximum Send Window.
Everything under /proc is volatile, so any changes made are lost after a reboot.
Applying TCP/IP Parameters at System Boot:
Place the following code in /etc/rc.local so that they get applied on the system while booting:
echo 256960 > /proc/sys/net/core/rmem_default
echo 256960 > /proc/sys/net/core/rmem_max
echo 256960 > /proc/sys/net/core/wmem_default
echo 256960 > /proc/sys/net/core/wmem_max
echo 0 > /proc/sys/net/ipv4/tcp_timestamps
echo 1 > /proc/sys/net/ipv4/tcp_sack
echo 1 > /proc/sys/net/ipv4/tcp_window_scaling
The TCP/IP parameters are self-explanatory. It is setting up the TCP Window to 256960, disabling timestamps (to avoid 12 byte
headers overhead), and enabling tcp window scaling and selective acknowledgments.
Change the values above as desired, depending on the internet connection and maximum bandwidth/latency.
Note:Above values can be used but are just a part of example.
Another method to reapply the values upon boot is to include the following in the /etc/sysctl.conf file.
net.core.rmem_default = 256960
net.core.rmem_max = 256960
net.core.wmem_default = 256960
net.core.wmem_max = 256960
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_sack =1
net.ipv4.tcp_window_scaling = 1
contributed by Kaustabh Chaudhari







January 27th, 2007 at 5:27 am
There is an error in the “Meaning of Parameters” part, the sixth parameter is “mem_default” which should be corrected to “rmem_default”.
January 31st, 2007 at 1:43 pm
So now we’ve been reminded about the magic of the /proc filesystem, but how do we go about determining good values for the various window parameters? Some explanation of what the windows are might also be good for those with little or no knowledge of low-level networking.
January 31st, 2007 at 3:14 pm
Once you calculate the bandwidth Delay product to determine the TCP window sizes (and if scaling is required) these proc settings will give you substantial increases in throughput. How about an explanation of using the different congestion algorithms in Linux and the trade offs when using them?
January 31st, 2007 at 4:45 pm
Kaustabh, I agree with scollins. If these changes are so good, why doesn’t Red Hat ship with them by default?
January 31st, 2007 at 6:24 pm
From my experience, to get a really high tcp performance it’s important to tune connection closing and timeouts like:
tcp_fin_timeout
and those reagarding to tcp keepalive
… to make sure you are not keeping up allready closed connections. Web clients usually are unable to close the connection corretly because firewall or lb- level breaks the connection when it sees the first fin or clients just disappear (just close the browser). If you don’t tune up for example fin_timeout, you might have millions of FIN-WAIT-2- connections that hanging around there.
February 1st, 2007 at 8:00 am
Is ther a way to deactivate IPV6 alltogether ?
I notice that the name resolving ask firts for a ipv6 addr and after a timeout ask for a ipv4 one.
February 1st, 2007 at 11:50 am
This article is a cut-and-paste from several going back years and is not germane to current kernels. See this 2003 article for recognizable paragraphs.
http://www.speedguide.net/read_articles.php?id=121
Kernels after 2.6.17 (I think) have TCP autotuning. The steps in this article may hurt performance. To determine if you have autotuning do:
cat /proc/sys/net/ipv4/tcp_moderate_rcvbuf
If this is set, the buffer sizes are default and max buffer sizes are adjusted dynamically for throughput, UNLESS they are statically overridden by sysctl.
February 2nd, 2007 at 1:08 pm
$ cat /proc/sys/net/ipv4/tcp_moderate_rcvbuf
1
Soooo…is that set, or unset?
February 3rd, 2007 at 12:56 pm
Carla – if set to one (1) as you show, it is enabled/set.
February 4th, 2007 at 6:32 pm
Thanks Bill. Oskar Andreasson’s howto might be helpful to some folks:
http://ipsysctl-tutorial.frozentux.net/
Even if you don’t need to mess with tuning, this is great stuff for understanding iptables better, and for understanding some of the mysterious stuff in tcpdump or Wireshark output.
February 6th, 2007 at 5:47 pm
lalo: take a look at /etc/sysconfig/network-scripts/init.ipv6-global for parameters to control IPv6
January 24th, 2008 at 3:18 pm
low interest payday loan low interest rate payday loan
As mentioned info phone remember ringtones best payday loan
January 24th, 2008 at 4:34 pm
ericsson klingeltöne
Basado en ericsson klingeltöne free logo nokia ringtones
May 20th, 2009 at 10:51 am
I have a setup with a client doing a TCP download from a server(Both are Linux Fedora Core 10).I changed the rmem_max and wmem_max from 64KBytes to 256KBytes.My purpose is to check the throughput at different TCP Window size. But unfortunately I get same at all sizes.