increasing Networkspeed

Thilo Six T.Six at gmx.de
Sun Aug 27 17:45:19 UTC 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

Vincent Trouilliez wrote the following on 27.08.2006 18:31:

<snip>
> Of course I am interested.. who wouldn't ?? :-)
> 
> Vince

OK now that you have asked... ;)

1. /etc/sysctl.conf
=======================================================================
With this file you can edit your kernel directly. We want to edit the
TCP-Buffers. per default it is quite small, which is bad for throughput.

<-----------------------------------------------
# increase TCP max buffer size
net.core.rmem_max = 4194304
net.core.wmem_max = 4194304
# increase Linux autotuning TCP buffer limits
# min, default, and max number of bytes to use
net.ipv4.tcp_rmem = 4096 87380 4194304
net.ipv4.tcp_wmem = 4096 87380 4194304
- ----------------------------------------------->

you can play with this settings, just make sure the number of
net.core.rmem_max / net.core.wmem_max and the last number in
net.ipv4.tcp_rmem / net.ipv4.tcp_wmem are the same!
Here it is set 4MB, devide it by 2 or even 4 if your RAM is small.

you can activate it instandly with:
$ sudo sysctl -p


2. mtu settings
=======================================================================

MTU = Maximum Transmission Unit (TCP/IP)

It has a quite big affect to throughput.

Let me explain it a bit:
Ethernet uses a MTU of 1500 (you can check with ifconfig).
This means every frame through ethernet has gross 1500 Byte (max).
Now when sending data through DSL (pppoe = Point-to-Point Protocol Over
Ethernet) we use a modified ethernet protocol.
Modified here means the frame over pppoe has a greater overhead of 8 Byte.

This means the following:
Lets say you downlaod a file from a server (the server uses obviously
normal ethernet, whereas you use pppoe).
This means the server will send you packets with a frame langth of 1500
Byte, but this will not go through your DSL line.
Therefor the missing bits will fold into a second frame.
But this second frame is only partly used and therfore we waste bandwith.
Got the idea?  ;)

Theoretical:
Lets say we have a DSL line with a Bandwith of 1 frame per second (1500
Byte gross per second).
This would mean, everytime a frame is folded we would loose 50%
(relative error) of our bandwith.
Of course the higher our bandwith is the lower the relative error.
(when sending 10 frames and 1 gets folded it is 10%).

This means the lower your bandwith over dsl is, the higher is the impact
of a correct mtu setting!

Here i got in downstream an extra from ~235kB/s to ~245kB/s and
upstream from ~21kB/s to ~31kB/s.


so far, so good, what do we about it?



first we check if this also valid for you:
$ ping google.com -c 1 -M do -s 1464    (sorry google ;-)
this should give us:
64 bytes from 72.14.207.99: icmp_seq=1 ttl=241 (truncated)


if we do:
$ ping google.com -c 1 -M do -s 1465
that should give us
.....icmp_seq=1 Frag needed and DF set (mtu = 1492)


What had happened here?
with "ping google.com -c 1 -M do -s 1464" we tell ping to send a ping
frame with a payload (therefor the 1464, which is 1492 - 28 Byte Header)
that is _NOT_ allowed to fold in an other frame.

Same with "ping google.com -c 1 -M do -s 1465"
but here the frame is to big and therefor does not get send out.

If you have this effect the same way you mtu is 1492, too!



So lets check our config:

2a.
with direct pppoe /etc/ppp/ip-up.d/0clampmss
with dhcp and router over pppoe /etc/network/if-up.d/0clampmss
<-----------------------------------------------
#!/bin/sh
# Enable MSS clamping (autogenerated by pppoeconf)

iptables -o "$PPP_IFACE" --insert FORWARD 1 -p tcp --tcp-flags SYN,RST
SYN -m tcpmss --mss 1452 -j TCPMSS --clamp-mss-to-pmtu
- ----------------------------------------------->
(this must go on one line, the important part here is 1452)


2b. with direct pppoe /etc/ppp/peers/dsl-provider
<-----------------------------------------------
change
#mtu 1492
to
mtu 1492
- ----------------------------------------------->


2c. /etc/network/interfaces
<-----------------------------------------------
with direct pppoe change the line:
pre-up /sbin/ifconfig eth0 up
to
pre-up /sbin/ifconfig eth0 mtu 1492 up


with dhcp you should add this line after your config
pre-up /sbin/ifconfig eth0 mtu 1492 up
- ----------------------------------------------->

OK i think that´s it! ;)

$ sudo /etc/init.d/networking restart

...and have fun.

Thilo
- --
i am on Ubuntu 2.6 KDE
- - some friend of mine

gpg key: Ox4A411E09

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFE8dougkdHiUpBHgkRA1ySAKDNEeaCRILmG2dPhXt3tjN0llbBSwCeIjTv
x5W/rPLyv04Qpq/Gfq6oxQQ=
=WflV
-----END PGP SIGNATURE-----





More information about the ubuntu-users mailing list