the daily dub

December 22nd, 2006

Tune your IP Stack

Posted by rdub in

In addition to improving performance at the HTTP level, here’s a tweak that works for all network activity, not just browsing, at the socket level:

On OS X, open up Terminal (Applications/Utilities), and run the following commands:

sudo sysctl -w kern.ipc.maxsockbuf=8000000
sudo sysctl -w net.inet.tcp.sendspace=4000000
sudo sysctl -w net.inet.tcp.recvspace=4000000
sudo sysctl -w net.inet.tcp.mssdflt=1440

sudo will ask for your login password.

The first three lines boost the recv and send buffers at the socket level, increasing performance (the above sets the combined buffers to just under 8 MB – a huge increase over the default of 256 kB).

The last one sets the maximum data segment size in a packet (should be set to your network’s Maximum Transmission Unit minus TCP and IP header size minus options size). FYI: the MTU for ethernet (or wireless) is 1500, setting this to 1440 should be quite reasonable. The default is 512, which is horrible for performance.

A quick sanity check showed download speed increases from ~250 KB/s to ~300 KB/s on my 3 Mbit/s line.

There are analogs in Linux, BSD, and Windows. Read more here:
http://www.psc.edu/networking/projects/tcptune/

submit to reddit

Leave a reply

You must be logged in to post a comment.