Linksys WRT54GL Routers : Improving Performance

If you have a shared broadband (DSL, cable) connection at home, then I'm sure it is a common occurence that you find that your Internet connection becomes very slow or unusable if somebody in your home is running P2P software (BitTorrent, Kazaa, eMule, eDonkey, etc.).

This is most likely because the router that "shares" your internet connection is being overloaded by the huge number of connections that P2P softwares make. Most home routers in their default configuration, cannot meet the connection demands of P2P software.

IMHO, the best and also cheapest option for a home router is to buy a router which is capable of being updated to 3rd party Linux firmware. A few of the more popular routers which meet this criteria are the Linksys WRT54GL and the Buffalo WHR-HP-G54. I recommend the new Buffalo WHR-G125 which has a faster CPU than the older models (240Mhz vs 200Mhz) and a better WiFi chipset.

As for which 3rd party Linux firmware to use, I highly recommend the Tomato firmware, which is both easy to use and powerful. Downloads, installation instructions and source code available at Tomato Firmware | polarcloud.com.

Tomato SpeedMod

Aside from just using Tomato, I have also been working on tweaking the stock Tomato firmware to gain higher performance from the router. These are some of the changes that I've made to the stock firmware:

1. Patched ip_conntrack and ip_route components from Linux kernel version 2.4.20 to 2.4.36, and optimized conntrack hash bucket selection filter from modulo to bitwise AND.

2. Increased the hashtable sizes for ip_conntrack and IP route cache to speed up routing when there are many connections (>4000).

3. Patched conntrack, route and IP fragment to use Jenkins' hash which should be better / faster and more resistant to hash exploits, compared to the hash in kernel 2.4.20. These changes are the same ones done in Linux kernel version 2.4.21 and later.

4. Updated Jenkins' hash from lookup2 to the newer lookup3 version.

With these changes, these little routers should be able to handle around 6000 connections and still remain responsive. I've been in contact with Jon (author of the Tomato firmware) and he may integrate some or all these changes into the stock firmware in the future.

UPDATE 24-May-08 build 8502:

* Modified IP route cache parameters to be more resistant to "dst cache overflow" and "Rusty's brain broke" errors.

* Expect about 700kbytes more RAM usage if there are a high number of connections.

* If you have build 8501 and don't want to upgrade to 8502, you can implement the same changes by putting these lines into your startup script:

echo 16384 > /proc/sys/net/ipv4/route/gc_thresh
echo 32768 > /proc/sys/net/ipv4/route/max_size

Tourist In Paradise: Linksys WRT54GL Routers: Improving Performance SpeedMod-patched Tomato 1.19 firmware for:

* Buffalo WHR-HP-G54 / WHR-G54S
* Linksys WRT54GL / WRT54G v1-v4
* Linksys WRT54GS v1-v3
* Linksys WRT54GS v4
* Linksys WRTSL54GS
* Motorola WR850G

Tourist In Paradise: Linksys WRT54GL Routers: Improving Performance SpeedMod-patched Tomato 1.19 New Driver for:

* Buffalo WHR-G125
* Linksys WRT54GL / WRT54G v4 / WRT54GS v1-v4 (experimental)

Not sure which version WRT54G/GS you have? Click here to check.

These patched versions were built from the Tomato sources with my patches on top. They work on my WRT54GL and WHR-HP-G54. Try them at your own risk, no guarantees!

For the geeks, if you want to recompile the Tomato source code yourself and implement my patches, you can download the patch source here. Just follow the procedures to recompile Tomato, then untar my patches over the source directory to updates some files.

With these patches, in the web admin page Advanced > Conntrack > Maximum Connections you should be able to increase the value to around 6000 (recommended for 16MB RAM routers) and still get good response from the router.

If you have more RAM, you can try going up to 10240 maximum connections. Be careful when increasing this value, because the router might run out of RAM, depending on which other features of Tomato you use.

TIP: Hidden QoS setting in Tomato:

There is a hidden setting in Tomato 1.18 and above, that should improve QoS performance for P2P traffic or large numbers of connections (more than 1000). It changes the QoS qdiscs from SFQ to PFIFO, which use less CPU and scales better to large numbers of connections.

This is how to apply it.

1. Telnet to your Tomato router.

2. Enter the following commands:
# nvram set qos_pfifo=1
# nvram commit

3. Reboot your router or restart QoS to make the change take effect.

4. To check if the change was effective:
# tc -s qdisc show

Before change:
qdisc sfq 20: dev vlan1 limit 128p quantum 1518b perturb 10sec
Sent 22744765 bytes 19407 pkts (dropped 0, overlimits 0)
qdisc sfq 10: dev vlan1 limit 128p quantum 1518b perturb 10sec
Sent 72658471 bytes 954697 pkts (dropped 0, overlimits 0)
qdisc htb 1: dev vlan1 r2q 10 default 30 direct_packets_stat 39
Sent 436565347 bytes 1371000 pkts (dropped 772, overlimits 698391)
backlog 87p

After change:
qdisc pfifo 20: dev vlan1 limit 256p
Sent 63 bytes 1 pkts (dropped 0, overlimits 0)
qdisc pfifo 10: dev vlan1 limit 256p
Sent 27430 bytes 493 pkts (dropped 0, overlimits 0)
qdisc htb 1: dev vlan1 r2q 10 default 30 direct_packets_stat 66
Sent 280901 bytes 885 pkts (dropped 0, overlimits 370)

5. If you want to remove the change, issue the following commands then reboot the router or restart QoS.
# nvram unset qos_pfifo
# nvram commit

Source : Tourist In Paradise: Linksys WRT54GL Routers: Improving Performance
 
Back
Top