ip route commands.
Find your routes
Find your current route settings by using the
ip route command:
┌(foo@server)─(12:26 PM Tue Jun 26)─(~) └> ip route default via 192.168.1.1 dev wan 192.168.1.0/24 dev wan proto kernel scope link src 192.168.1.1 192.168.2.0/24 dev br0 proto kernel scope link src 192.168.2.1
Enhance initcwnd and initrwnd
The header on every TCP segment contains a 16-bit field advertising its current receive window size, 0 through 65,535, and a 32-bit field reporting the acknowledgement number. This means that everything up to the acknowledgement position in the stream has been received, and the receiver has enough TCP buffer memory for the sender to transmit up to the window size in bytes beyond the latest acknowledgement.
The idea is to more efficiently stream data by using buffers along the way to store segments and acknowledgements "in flight" in either direction. Across a fast switched LAN the improvement comes from allowing the receiver to keep filling the buffer while doing something else, putting off an acknowledgement packet until the receive buffer starts to fill.
Increases in the initial TCP window parameters can significantly improve performance. The initial receive window size or
initrwnd specifies the receive window size advertised at the beginning of the connection, in segments, or zero to force Slow Start.
The initial congestion window size or
initcwnd limits the number of TCP segments the server is willing to send at the beginning of the connection before receiving the first ACK from the client, regardless of the window size the client advertise. The server might be overly cautious, only sending a few kbytes and then waiting for an ACK because its initial congestion window is too small. It will send the smaller of the receiver's window size and the server's initcwnd. We have to put up with whatever the client says, but we can crank up the initcwnd value on the server and usually make for a much faster start.
Researchers at Google studied this. Browsers routinely open many connections to load a single page and its components, each of which will otherwise start slow. They recommend increasing initcwnd to at least 10.
CDN Planet has an interesting and much simpler article showing that increasing initcwnd to 10 cuts the total load time for a 14 kbyte file to about half the original time. They also found that many content delivery networks use an initcwnd of 10 and some set it even higher.
You can tune Linux's initcwnd and initrwnd windows using
ip route change on the routes displayed from
ip route. To set both windows on the 192.168.2.1 route shown above to 25, you would issue:
ip route change 192.168.2.0/24 dev br0 proto kernel scope link src 192.168.2.1 initcwnd 25 initrwnd 25
To set all routes to the Linux default window sizes of 10, you would issue:
ip route | while read p; do ip route change $p initcwnd 10 initrwnd 10; done