Rate this page del.icio.us  Digg slashdot StumbleUpon

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:

  1. /proc/sys/net/core/rmem_max - Maximum TCP Receive Window.
  2. /proc/sys/net/core/wmem_max - Maximum TCP Send Window.
  3. /proc/sys/net/ipv4/tcp_timestamps - Timestamp ( RFC 1323) add 12 bytes to the TCP headers.
  4. /proc/sys/net/ipv4/tcp_sack - TCP selective acknowledgments.
  5. /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.
  6. mem_default = Default Receive Window.
  7. rmem_max = Maximum Receive Window.
  8. wmem_default = Default Send Window.
  9. 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

Red Hat’s customer service and support teams receive technical support questions from users all over the world. Red Hat technicians add the questions and answers to Red Hat Knowledgebase on a daily basis. Access to Red Hat Knowledgebase is free. Every month, Red Hat Magazine offers a preview into the Red Hat Knowledgebase by highlighting some of the most recent entries.

13 responses to “How can I change the TCP/IP tuning parameters?”

  1. zhaoke says:

    There is an error in the “Meaning of Parameters” part, the sixth parameter is “mem_default” which should be corrected to “rmem_default”.

  2. scollins says:

    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.

  3. rlevay says:

    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?

  4. Brian says:

    Kaustabh, I agree with scollins. If these changes are so good, why doesn’t Red Hat ship with them by default?

  5. hpniemi says:

    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.

  6. lalo says:

    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.

  7. Dave Turvene says:

    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.

  8. Carla says:

    $ cat /proc/sys/net/ipv4/tcp_moderate_rcvbuf
    1

    Soooo…is that set, or unset?

  9. Bill Diego says:

    Carla - if set to one (1) as you show, it is enabled/set.

  10. Carla says:

    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.

  11. SGhosh says:

    lalo: take a look at /etc/sysconfig/network-scripts/init.ipv6-global for parameters to control IPv6

  12. free lg ringtones tracfone says:

    low interest payday loan low interest rate payday loan

    As mentioned info phone remember ringtones best payday loan

  13. handy klingeltöne download says:

    ericsson klingeltöne

    Basado en ericsson klingeltöne free logo nokia ringtones

Leave a reply