Friday, April 25, 2008

Linksys WRT54GL Routers: Improving Performance

This page contains some work I've done to enhance the open-source Linux router firmware Tomato which is available at http://www.polarcloud.com/tomato.

Tomato SpeedMod

This mod enhances the Tomato firmware to gain higher performance from the router. These are some of the changes that I've made:

1. Patched ip_conntrack to increase NAT hashtable size and optimized conntrack hash bucket selection filter from modulo to bitwise AND.

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

3. Added fixes for network hash exploits in Linux 2.4.20 (SpeedMod 110).

4. Patched ip_conntrack_core to Linux 2.4.29 (SpeedMod 112).

5. Replaced Jenkins' lookup2 hash with lookup3 which is faster, this should improve overall speed (SpeedMod 119).

With these changes, these little routers should be able to handle thousands of 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.

NEW "BETA" QoS features in SpeedMod 120

WARNING: Advanced users only!

1. Implemented the TC-ATM patch. This enables QoS to work accurately for ADSL users.

2. Enhanced the SFQ qdisc: Changed the SFQ hash to use Jenkins' lookup3 hash and increased the hash bucket size from 1K to 16K which will result in less collisions.

3. Turned off HTB hysteresis for more accurate traffic shaping.

The ATM calculations are not enabled by the QoS GUI in Tomato. You need to manually configure tc using a firewall script. You also need to use the correct overhead amount for your type of ADSL connection.

TC-ATM details at http://ace-host.stuart.id.au/russell/files/tc/tc-atm/.

Note: I did NOT implement the "nohyst" option in the tc command line because I already disabled HTB hyteresis in the source code.

From the table given in Russell Stuart's website, assuming my overheads are 32 for outbound and 32 for inbound, an example line in the tc command for my outbound interface is:

tc class change dev ppp0 classid 1:10 htb prio 1 rate 800kbit ceil 800kbit overhead 32 atm

And for inbound IMQ:

tc class add dev imq0 parent 1:1 classid 1:10 htb prio 1 rate 10000kbit ceil 10000kbit overhead 32 atm

For fellow firmware hackers, here is the source code for the TC ATM patches.

[ If you like my work CLICK HERE to buy me a drink via Paypal! ]

DOWNLOADS (Updated 30-Jul-10) Tomato 1.28 + SpeedMod 120:

Click HERE to download SpeedMod-patched Tomato 1.28 firmware for:

  • Buffalo WHR-HP-G54 / WHR-G54S
  • Linksys WRT54GL / WRT54G v1-v4
  • Linksys WRT54GS v1-v3
  • Linksys WRT54GS v4
  • Linksys WRTSL54GS
  • Motorola WR850G
Click HERE to download SpeedMod-patched Tomato 1.28 New Driver for:
  • Buffalo WHR-G125 and Asus WL-520GU
  • Linksys WRT54GL / WRT54G v4 / WRT54GS v1-v4 (experimental)
Click HERE to download current SpeedMod source code.

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, download the source and follow the procedures to recompile Tomato, then untar my patches over the source directory.

With these patches, in the web admin page Advanced > Conntrack > Maximum Connections you should be able to increase the value to around 8192 (for 16MB RAM routers) and still get good response from the router. Be careful when increasing this value, because the router might run out of RAM, depending on which other features of Tomato you use.

UPDATE: QOS SFQ vs PFIFO

I no longer recommend using the PFIFO qdisc for QOS, and recommend using the (default) SFQ qdisc. If you have previously used the hidden setting to enable PFIFO, you can disable it by:

nvram unset qos_pfifo
nvram commit
reboot

106 comments:

Anonymous said...

What sort of performance difference did you see between Murmur and Jenkins? I haven't had the opportunity to test it on any embedded systems.

-Austin (author of Murmurhash)

Anonymous said...

Thanks Very much. I have upgraded from ver 1.15 and it looks more stable and fast...

Anonymous said...

Hi! I got a WRT54GS with 32MB RAM, will Tomato or your mod make full use of that as well? Just thought about it since you said that the RAM the problem.

/currently running tomato 1.18

Rodney Chua said...

To anonymous with WRT54GS / 32MB RAM. You're one of the lucky ones! By default I've tuned Tomato to handle a maximum of about 8192 connections. Since you have so much more RAM, you could theoretically have more connections than that, but I don't think you will need more than 8192...

I recommend you set your connection limit to 8192 and you can probably still use a lot of Tomato's features, e.g. traffic bandwidth history, etc. with no problems.

Anonymous said...

Using 1.19-ND on a WRT54GL, I have noticed that "Measure Noise Floor" causes the router to disconnect and become unresponsive - requiring a reboot.

This does not occur with the non-ND version.

I'd rather use the ND version - How important is it to "Measure Noise Floor?" Occasionally, what I've noticed is if the noise floor is not measured, then the hostnames of some clients do not show up(although, the MAC address does)

Rodney Chua said...

I found the same thing with the ND version on WRT54GL. Measure Noise Floor will make the WiFi disconnect. Its probably because the ND version has the new WiFi drivers which may have broken Tomato's "Measure Noise Floor" compatibility. But its okay since I seldom use that function anyway.

New SpeedMod update out soon, maybe tonight. I've found that the Murmurhash is actually slower than Jenkins' Lookup3, so I am going to move back to Jenkins' Lookup3. Also going to make some changes to ip route cache size.

BTW, the Rusty's brain error was due to those users hitting the ip route cache size limit, maybe because they ran out of RAM.

Anonymous said...

1. Both Safari and Firefox on two different computers didn't like your download links, they start displaying the .7z file in the browser. On other sites, like Jon's, I can download .7z files without issue. IE saw it as a download ok, however.

2. The experimental v1.19.8423 ND build for Linksys WRT54GL/Gv4 seems to be working fine on my old 32MB RAM WRT54GS v2.0.

I will pound the crap out of the WLAN the next few days doing torrents and Skype over wireless and let you know how it holds up.

Rodney Chua said...

@Mr. Zarniwoop,

Thanks for the note on the .7z file opening in the browser. It was a missing mime-type in my web-server. Just fixed it.

Anonymous said...

Rodney,

Thanks for this mod! Would it possible to "brand" it? For example in the web UI banner, change the version from "Version 1.19" to something like "Version 1.19 speedMod"?

Anyhow, thanks again!
-Int15

Rodney Chua said...

Hi Int15,

No plans to change the 'branding' in Tomato's UI. This is still basically Tomato, no new features except some tweaking of the Linux core. At the moment I distinguish it using the build number only. :)

Anonymous said...

After about a week of pounding the crap out the experimental v1.19.8427 ND build on my old 32MB RAM WRT54GS v2.0 doing torrents and Skype over wireless, I can say SpeedMod really does perform better than stock Tomato when there are a lot of connections.

When I had under 2,000 or so connections, nothing seems very different compared to stock Tomato. But, when I have large numbers of connections (up to a maximum of about 4,000 or so this past week) my home network was still very responsive and I could happily surf the web or send large emails without the "pauses" that seem to happen with stock Tomato when it has to handle lots of connections.

I use QoS and have rules to prioritize Skype and de-prioritize torrents, but with stock Tomato once there are tons of connections everything network-related just "feels" unresponsive and sluggish. With every firmware I've tried in those situations, for example, waiting 5-20 seconds for a page load that normally takes about a second was typical. With SpeedMod, over 4,000 connections doesn't "feel" any different than just a few dozen connections and web pages remain responsive.

Good stuff, hope SpeedMod it makes its way into the stock firmware.

Rodney Chua said...

Thanks for sharing your experience Mr. Zarniwoop. Thats exactly the kind of experience I wanted SpeedMod to give.

The reason I got into playing with the source code myself was because I got fed up of the 'pauses' in all the other firmwares that you mentioned when there are lots of connections.

SpeedMod's still not done though. The area I'm looking into most now is the tuning of the route cache and its garbage collector. Still trying to figure out the best combination of parameters to allow for a large hashtable but avoid overflows.

Anonymous said...

The link for the ND driver is corrupted. I can't extract the .7z, it gives me a 'file is broken' error every time. I tried downloading it several times, even using different browsers. Same thing.

Rodney Chua said...

Just tested the ND archive and it seems fine from my end. Please try to clear your browser's cache and try to download it again, or try later maybe. I suspect it could be due to a web proxy / transparent proxy caching an incomplete copy of the file.

Anonymous said...

Ok.. the ND link works now. How odd.. Must have been something with a proxy somewhere.

Anyhow, awesome mod :) I've been using tomato since about 1.05 or so, and I've noticed a huge difference with your SppedMod. I'm able to set my max connections in uTorrent MUCH higher, and still maintain a solid, trouble-free connection.

THANKS!

Anonymous said...

I feel likes the build 8427 get more download speed on bittorrent than build 8500. I'm using build 8500ND on WRT54GS v2 and i used to download 5-10 BTs at speed above 1MBps/sec and now on build 8500 I can get like half of that (500-600kbps/sec). Can you upload build 8427 again? Thanks

Rodney Chua said...

@Anonymous, the only difference between build 8500 and 8427 is the route cache parameters. It should not affect your BT speed so drastically, it could be different torrents or your ISPs changed something. I don't recommend you use 8247 as the changes in 8500 are meant to optimize the route cache garbage collector, so it should actually be a bit faster than 8427.

Anonymous said...

Thanks for this product!

Since installing this firmware in my WRT54G, I have not had any random dropped connections which were so frequent under the Linksys code.

I have one problem : I use Avira Security Suite and the Webguard module often reports this error : ERROR WRITING TO SOCKET

According to Avira this error usually means that the socket is blocked by another security application.

Could something in the Tomato configuration be causing this?

Thanks in advance for any suggestions

Rodney Chua said...

To anonymous, the error from Avira Security Suite is something to do with your PC's configuration. Maybe as you say, there is another security application running.

Tomato only runs on the router and wont affect security software running on your PC.

Anonymous said...

Would it be hard to add better ack packed prioritizing modification as well. What i mean is that ack would be prioritized according to to class. If you had class low packets ack would be little higher in priority between medium and low so it would effect packets in medium priority.
Current example bittorrent is flooding connection with acks and if you have prioritize acks on then your ping/latency is lousy when playing games etc.

Anonymous said...

I think i found the culprit behind my high pings when using ACK prioritizing and bittorrent. It seem that when i used that tomato 1.18 hidden setting to set it to use pfifo my pings got bad. Anyway works fine now when pfifo is disabled.

Rodney Chua said...

@posti: Tomato puts ACKs and pings in the highest QoS band. The pfifo or sfq qdiscs should have little effect for the highest band, since that band's bandwidth shouldn't be exceeding your total upload capacity. If you are still seeing high pings, it could be that your upload bandwidth is set too high, which will cause QoS to have little to no effect. For most cases, you have to set the upload bandwidth in the QoS config to about 85% of your actual upload bandwidth. For example, if your advertised upload bandwidth is 1000kbit/sec, then QoS only becomes effective if you set the upload bandwidth in the config to around 850kbit/sec.

Anonymous said...

I had ADSL sync at 2445 and upstream cap set to 2100 and latencies where great while i uploaded and downloaded around 200KB/s.
But after i started to download around 450KB/s and over they when really bad around 150-300ms.
My downstream is 9000kbit so i can download around 900KB/s. So downstream wasn't saturated.
After i lowered upstream cap to 2000 and latencies are good again. It's odd since if that upstream cap includes those acks this shouldn't have happenen.
I used pfifo in this case.
Maybe there is bug somewhere, and those ack's aren't included in upstream cap/max bandwidth calculation.

Anonymous said...

Addition to my last comment.

When uploaded fast as I can and downloaded around 200KB/s with bittorrent latencies where great. But after started downloading around 450KB/s + my latencies whent bad. More download speed mean more ack's. I had optimize ack packets set on.
If those ack packets are included in upstream cap then my latency should have stayed allmost the same.

Rodney Chua said...

@posti: acks and pings (icmp) are put in the "Highest" QoS band. did you set the bandwidth to 100%-100% for the "Highest" band? i'm pretty sure the acks are correctly going to the right band. you can check this by looking at the qos graphs page in tomato. i normally use "Highest" only for tcp acks/other small packets, icmp, dns and voip (udp). everything else goes to lower bands. also, i find that its pointless and actually slower to use too many bands - i myself use only 3 bands (Highest 100%-100%, High 10%-90%, Medium 1%-70%). Highest is for tcp small packets, icmp, dns, voip. High is for user applications and my servers. Medium is for bulk traffic (P2P, etc.) my downlink is about 10mbit, uplink is 1mbit.

Anonymous said...

Setting highest to 100%-100% helped. It seems that around 80% of adsl upstream sync i get excellent latency even with high download speed around 800-900KB/s.

Also some wierd stuff has been going on with my adsl line for couple of days. Noticed it yesterday line sync was jumping from 2600->2300->1900->1300 and between no connection.

Then i removed Annex M and set ADSL2+ to ADSL2 and everything worked again with upstream cap set to 1000. Disabling annex m lowers my upstream to around 1280kbit and don't use those new frequencies to get that 3mbit upstream. Changing ADSL2+ to ADSL2 probably didn't do anything.

Also when i used annex m even with 80% and less my latency was bad. Even with sync of 2600 and with cap 1500 my latency was bad. Probably due to lot of errors in connection.
My ISP is looking into it.
Thanks for your help.

Anonymous said...

posti ,

there are only a handful of good CPE devices that have decent Annex M firmware - most are ordinary.

With the right CPE, Annex M is far superior to Annex A for stability.

What CPE model/firmware do you have?

Anonymous said...

Hi Rod, now that speedmod makes this router perform so much better, I and I am sure many others, feel that it is able to really support multiple users in our residential blocks/hotels. But the default Static DNS and RESTRICTION settings of of 50 make it difficult to control access. Also, UPNP settings seem to be limited to 25, with no timeout, which isn't much use for our application. The table fills up very quickly with 50-70 users. I'm sure it not only can be done, but would work well now you've spruced up the firmware. There seems to be a big demand for an easy to use router for this type of application, but I can not find one on the market. Can you help?

Thanks from us all to you and Jon for your hard work. It's appreciated.

Anonymous said...

Apologies for the anonymous post, rectified here...

regards, Keith

Anonymous said...

Hi,rod
how to recompile Tomato_ND firmware.

i'm recompile Tomato it's fine,but Tomato_ND cannt.


Thank your help

Anonymous said...

To compile the ND version just delete the .c files in the release/src/shared folder that are giving you errors. You will see the duplicate .c files and .o files. Keep the prebuild .o files.

Anonymous said...

Is the Buffalo WHR-G125 currently still the best router that supports Tomato speed mod firmware, or is the new Netgear WGR614L better? If so, will there be future support for the Netgear WGR614L router?

Drft3

Anonymous said...

Does Tomato support the new ASUS WL-500gP V2 8MB/32MB routers based on bcm5354 chips. They are suppose to be exactly the same as the WHR-G125, with the added USB port, removable antenna, double the flash and ram, and built in print server.

Anonymous said...

I'm using a 500gP V2 with tomato, no
problems, works very well.
I had informed the tomato author that my V2 runs very well but he did not update his homepage. :(

And also with the initial 1.20 Tomato firmware I have no problems at all.

Unknown said...

Tomato_ND & WL-500GPV2

problems

1.AIR LED cannt off automatic,when turn off Wireless.

2.RESET & SES button not support.

Rodney Chua said...

Official Tomato 1.21 Speedmod released now. I've added links to the older 1.19 version just in case.

Thanks My Zarniwoop for rhester72's earlier links. I've remove them to avoid confusion.

Louis said...

Apparently, this 1.21 Speedmod doesn't work for my WL-520GU (16M RAM). It start to stall (unable to create new TCP session) and lose telnet session when approaching 3K connection. Wait for long time still no fix. Need to reboot to fix.

Even officially 1.21 speedmod can't take 4k sessions. Once it hits the 4k mark and fallback to ~300 connections after timeout. Still no tcp session can be created, sampling by Web browsing. However, if I configure it to run 3K sessions max, and it survives.

I'm using an IP traffic generator to send 4000 UDP sessions from 100 to 500 session/s.

Rodney Chua said...

Hi Louis,

Interesting test. From your description I suspect that maybe your router ran out of free RAM.

If you haven't already tried, you can turn off unnecessary features in Tomato to increase free RAM. You can turn of logging, bandwidth history, don't use CIFS.

I've used this firmware on a 16MB router up to 6000-8000 connections before with no problem (with enough free RAM).

Anonymous said...

Hi rod,
Thanks for the hard work.
I have a WHR-G125 so i downloaded
Tomato121ND-SpeedMod-8502.7z
there isnt a bin firmware for my router only a *.trx file name.
Please advice.
Is this firmware safe for my router?
Wont brick it when flashed to it?
Thanks for any help
I have contact jon an ask him if he has plans to implemment support for this router in his official one. I hope you can work together to make this firmware even better!

Anonymous said...

Demetris,
Buffalo uses .trx so yes it's safe. Uptime is 22 days on my WHR-G125. A bad lightning storm ruined my uptime :P

Anonymous said...

Where can I get this IP traffic generator?

Matt said...

I hate to be a newb, but what's the difference between regular and "New Driver"?

Anonymous said...

which one firmware file good for asus WL-520GU?

Anonymous said...

Another way you can improve performance is by adjusting..

the ammount of address your router can handle.
which explains here.
link

You can also set your dns settings to a more better server...

which a list can be found here.
link

Anonymous said...

I have been using this modified version of Tomato on my Linksys WRT54G for a few months now and just wanted to add my thanks to Rod for all of the work he has put into the changes.

Thought I would share this with you.

A couple of weeks ago I came across an article about using the router to store the HOSTS file, rather than it residing on the computer.

Using a script provided by the author of the article as a staring point, I now keep the HOSTS file on the router, and each Friday the router downloads the current HOSTS file from http://www.mvps.org, performs some maintenance on the file, and then creates a file that DNSMASQ looks for.
On my laptop, I use the router address for both the Default Gateway and Preferred DNS Server.

I have not noticed any effect on performare

Anonymous said...

Hey Rodney,

Can you update your speedmod?

Thanks :D

Anonymous said...

hi, anyone can help-me?? i dont talk very much inglish but lets try. the speedmod work great for me. thanks all of you. i post my question in live chat on this page but no answer. my problem is:
i've upnp enable, and a schedule reboot every day. but when reboot, it clear upnp list. i've to close emule and open it again to automatic forward ports.
is there anyway to save upnp list to nvram??

Anonymous said...

tomato 1.23 is out now! :)

Anonymous said...

QOS pfifo is no longer available in clean build?

Anonymous said...

Yes it is. I'm using 1.23 and qos pfifo.
I'm doing some test in qos configuration that sims work better with emule. If i'm rigth, i will share with all of you to try it (if i can explain it in ingish. we will see)

Anonymous said...

I access the Tomato GUI through Firefox, and since I upgraded to 1.23 (from 1.22) I have noticed heaps of Javascript errors in the Firefox Error Console, the majority being "assignment to undeclared variables". Another is "Use of getBoxObjectFor() is deprecated. Try to use element.getBoundingClientRect
() if possible."

Anyone else seeing these entries?

Rodney Chua said...

Hi people, just came back from a long overseas trip. Speedmod just updated to 1.23.

Anonymous said...

I'm experiencing many wireless disconnections with tomato v1.23. I have a buffalo whr hp 54G router. Is tomato the cause?

Anonymous said...

I'he very wireless disconnects too. Betwen 8h and 13h, my wireless keep disconnect, then it comes again, then disconnect, and comes again. I've tried all mods and it's the same. I was affraid that it could be interference but i have tried all channels, 5mw to 251 and it's the same. I have a WL500gp v2. On linksys seems to work fine

Rodney Chua said...

Hi guys, Tomato shouldn't cause any problems with wireless disconnects, vs other firmwares. Try changing to a different Wifi channel if you have disconnects.

Or you can also try implementing nvram settings fix for "Intel 2200BG cards", not sure if will help or not.

Anonymous said...

Hi rod. I'm sorry, because it's an interference in my network that makes the wireless disconnect. I just change the firmware and the day after, all my wireless slow down. Now i see that is not a firmware problem. In my case it's interference. Sorry

web design India said...

very cool post

Anonymous said...

Hello,

I'm using the modified version of 1.23 that enables the USB port on the Asus WL-520GU (the default version does not support the USB). Can you supply a version of the USB capable 1.23 with your speed mods?

Thanks!

Anonymous said...

New official version !!!

http://www.polarcloud.com/tomato_125

lofi said...

Hi all,

I recently upgrade the tomato v1.25 firmware through tomato GUI to my buffalo WHR-HP-G54 router.

In the middle of the process it showed the error "Error erase MTD block" then follow by a reboot. After that i can't access the router.

May i know does it have any other way to access the router and re-flash the firmware?I had google it but unfortunately i can't get any relevant info.

Thanks

Rodney Chua said...

@lofi

Try the TFTP procedure mentioned here:

http://www.dd-wrt.com/wiki/index.php/Recover_from_a_Bad_Flash#Buffalo_WHR-HP-G54_soft_repair

Anonymous said...

Hi, I read all the comments and one person asked what is the difference between the "New Driver" version and the regular one.

No response was given but I'd also like to know the answer. What is the difference?

Rodney Chua said...

Use ND only for certain newer routers. Check this thread for more info:

http://www.linksysinfo.org/forums/showthread.php?t=59920

Anonymous said...

From Johnee:
This firmware is the best. Makes my router run fast and lean! When is the next iteration coming, and could you also support USB (FTP server) as a lean and mean combo?

Anonymous said...

Hi Rod,

This post http://www.linksysinfo.org/forums/showpost.php?p=338606&postcount=1 seems to imply the latest tomato has the wireless lan mod. Does that mean your "TIP: Fix for ND versions and Intel 2200BG cards:" is no longer needed for your latest verson?

Anonymous said...

Yes, it appears to be fixed in 1.25 speedmod as well. I'm pretty sure I never applied this fix myself long ago since I don't own a intel laptop so I had no problems, if someone else could confirm that reset their router settings after flashing 1.25 would be good.

# nvram get wl_reg_mode
off
# nvram get wl0_reg_mode
off
#

Rodney Chua said...

SpeedMod 118 changes:
- Changed hash functions for Linux IP fragment code (net hash exploit fix)
- Using Murmurhash instead of Jenkins for IP fragment code
- Some adjustments to the re-hash secret interval

Unknown said...

hi Rod,

from speedmod 1.17,
i'll just upgrade directly to 1.18?
or i should do some nvram reset?

Rodney Chua said...

@junianto: no nvram reset necessary, just upgrading is fine

Anonymous said...

Have you ever looked into tweaking dns? I put cache-size=10000 into Dnsmasq: Custom Configuration and after testing with ns_bench I did not notice any slowdown despite the bigger cache.

Default (150)
29.98 MB / 18.63 MB (62.14%)

Custom (10000)
29.98 MB / 17.95 MB (59.88%)


There's also a beta out for the first time so we will probably get 1.26 stable soon!
http://www.polarcloud.com/tomato

Rodney Chua said...

Yup, tweaking dnsmasq DNS cache configuration definitely helps. But it also depends, sometimes if your ISP has fast DNS servers, it might be faster to just bypass the DNS caching.

Teddy said...

It seems there's an error in the MurmurHash2 implementation in the latest SpeedMod 118. Parameter len passed to the jhash2() function is the number of *u32s* in the key. However, it's handled inside as if it was the number of *bytes*. This also affects all variations of jhash_Nword(). In my tests on the mips platform the fixed version actually was a little bit slower than lookup3. Please correct me if I'm missing something here...

Rodney Chua said...

@Teddy

Yes you are probably right. I wasnt sure how to do a direct translation of MurmurHash into a jhash2 compatible function, so probably made some mistakes there.

Any suggestions on a better implementation of the hash?

Rodney Chua said...

SpeedMod 119 changes only the hash algorithm to lookup3 instead of Murmurhash. Lookup3 looks like it performs better for this application, but the differences are minor.

Anonymous said...

Tomato 1.27 (minor update) is out

Unknown said...

Thanks for all your work on SpeedMod. I use it regularly.

Question: You write: "the router might run out of RAM, depending on which other features of Tomato you use". From your experience, which are the most RAM-intensive features of Tomato? i.e. Where can I free up more memory for connection tracking?

gvsly2008 said...

Once you flash this, is there a need to enable TCP Vegas anymore?

Rodney Chua said...

@Ben:
I personally don't use much of Tomato's additional features. One memory hog is definitely the CIFS client (but its off by default). Turning off logging also helps.

@gvsly2008:
TCP Vegas on a router has no effect on QoS. TCP Vegas is a TCP congestion control mechanism, and as such is only effective when implemented on TCP end-points like Clients (e.g. PCs) and Servers.

It was a misconception that turning on TCP Vegas on the router firmware helped to do some sort of QoS, but this misconception was recently cleared up.

So no, you don't need to enable TCP Vegas (although the configuration options are still there).

Anonymous said...

Any technical reason that this Tomato mod cannot support OpenVPN? Just curious. I've been using this Speedmod for a 1.5 years, and wanted to know if this mod might support OpenVPN feature?

damentz said...

@Rod

TCP Vegas reduces starvation when one connection is saturating all the bandwidth of your link. It throttles it enough so that concurrent connections don't achieve high latencies. It measures packet _delay_ instead of packet _loss_. This is more preventative and legitimately performs what can easily be described as QoS in the form of TCP fair per connection congestion management.

This allows a user on your LAN to upload a file at the maximum speed of your uplink, but another user on the same LAN can browse the web without any discernible difference, or play an online game with only a minor increase in latency.

Saying that TCP Vegas actually doesn't do anything is bogus. Whoever proved that doesn't use it gave no real evidence that it does nothing.

Rodney Chua said...

Hi damentz,

Vegas is a TCP congestion control algorithm and works only at the TCP end-points (your PC and the server). Windows Vista & 7 include something similar called CTCP.

As you mentioned, algos like Vegas & CTCP try to find the 'optimum/maximum' speed of each TCP connection. However, they only work at the TCP end-points.

Tomato is a router which is in between the end-points, so TCP Vegas on Tomato will do nothing for the QoS of the LAN. Vegas on Tomato would only work for TCP connections originating *from* Tomato, of which there aren't any because Tomato is a NAT router, not a proxy.

The author of the Vegas mods for Tomato has also acknowledged this:

http://www.linksysinfo.org/forums/showpost.php?p=346361&postcount=34

There are more effective ways to make the router's QoS better. I'm currently testing one of them - the TC ATM patch, which is really effective for ADSL users. Might release it later.

damentz said...

@Rod

I'm very interested in the TC ATM patch. Can you release the firmware with this patch as a beta?

Anonymous said...

Yeah, Vegas turned out to be some hyped up crap from the bloated dd-wrt implemented by people that does not know enough about networks that they should be making router firmwares.

I can't believe it spread to tomato, Jon should remove it I think. Anything to help ADSL users sounds interesting to me though!

Rodney Chua said...

Alright, released a beta version with the QoS enhancements. Note that TC-ATM is not enabled via the QoS page on the GUI, so its only useful for people who use their own QoS scripts.

Anonymous said...

Hi Rod,

I see this in my log for the Tomato 1.27 + SpeedMod 119 ND version for my router. Is this fault?

user.info init[1]: Buffalo WHR-G125
cron.err crond[1034]: crond (busybox 1.14.4) started, log level 9

Anonymous said...

Hi Rod, I am interested in the tc atm patch and would like to try it with my tomato firmware. Please post it on your site.

Rodney Chua said...

@Anonymous,

The tc atm firmware as well as the source code (basically tc atm ported to Linux 2.4) is available on this page.

Unknown said...

when there will be Tomato 1.27 + SpeedMod 120 NOT beta?

orbitoclast said...

Hello Rod, can you please post your qos script for WRT54GL somewhere?

Unknown said...

is there any source codes for the linksys wap54gx ver. 1 ?

Anonymous said...

Have you considered adding OpenVPN to your distribution?

Anonymous said...

Just adding to the comment above. I'm assuming i could take the openvpn source and add your patches per your description, correct?

Audiophile said...

I love Tomato firmware and I wanna try out the speed mod but the link not is working at all :(

Unknown said...

Anyone know if Speedmod works on the Netgear WNR3500L? This open-source 802.11n router has Tomato 1.27 in beta builds. I want to switch, but I also want my Speedmod... it's indispensable.

Rodney Chua said...

@Ben: SpeedMod's modifications are mostly specific to the Linux 2.4 kernel code. Tomato beta for those newer 802.11n routers uses Linux kernel 2.6, so SpeedMod won't work on them - they'll need modifications that are 2.6-specific. I might look into it when 2.6 builds become more mainstream, but I definitely don't have the time to nowadays.

Anonymous said...

@Ben: it looks like at least some of the SpeedMod changes (specifically - Jenkins lookup3 hash) are included into kernel 2.6 Tomato beta: http://repo.or.cz/w/tomato.git/commitdiff/aaaaf7d83f6cd82b0da7bee433c1e27ce7d88706
The rest of changes are probably not.

@Rod: are other changes needed for 2.6?

Anonymous said...

I read people talking about getting 2000+ connections on their tomato router however anything over 800 and I am no longer make new connections (even with my max connections set to 4000, 8196, etc...).

The router remains responsive and the load average is around .2 with 40% free memory. Clearing the idle connections usually fixes the problem and allows me to do dns lookups again only to get full again after a few minutes.

I am running 1.27 w/ SpeedMod 120 on a Linksys WRT54GS 2.1 (8mb / 32mb). Shouldn't that be enough to handle more traffic than this?

Any recommendations?

Rodney Chua said...

@anonymous, Your router has more than enough ram to handle >4000 connections.

Can you telnet to the router and show the output of:
# dmesg | grep buckets
# free

Also, could it be that you are exceeding your Internet connection's bandwidth?

Anonymous said...

It is unlikely I an exceeding my internet connection bandwidth. I can normally get my connection up to 600 k/s down but have utorrent capped at 300 k/s. The bandwidth monitor in tomato confirms I am well under the limit (I have the bandwidth graph disabled though to save resources, along with logging).

These commands were run when there were 950 open connections and the router was starting to not allow any more connections.

# dmesg | grep buckets
IP: routing cache hash table of 16384 buckets, 128Kbytes
ip_conntrack version 2.1 (32768 buckets, 8192 max) - 368 bytes per conntrack


# free
total used free shared buffers
Mem: 30736 10432 20304 0 1240
Swap: 0 0 0
Total: 30736 10432 20304

Rodney Chua said...

@anonymous: your router seems fine. maybe its something else, like your adsl/cable modem? if you are doing a double NAT, the other NAT might be the bottleneck.

Ryan said...

(Logging in instead of posting anonymous)

@Rod It is very strange. My dsl modem is also doing nat. My setup before this configuration was a linux pc doing nat and all I have done is replace the linux pc with a tomato router. With the linux pc I had no issues pushing the connection to the max (6mbit) with thousands of connections.

I noticed that the slow down does not appear to be related to number of open connections. I had a torrent downloading at 400k/s (capped) and limited utorrent to 20 connections and still experienced an inability to make new connections despite the router reporting only 300 connections were currently being used.

This may have something to do with the DSL modem doing NAT and forwarding my torrent port to the tomato router that in turn forwards it to the torrent machine.

Ill report back in case my findings help someone.

Rodney Chua said...

@crumley: double NAT is always bad! especially with DSL modems whose NAT performance usually sucks.

what is your WAN connection in tomato now? try switching to PPPoE on tomato and switch your DSL modem also to 'PPPoE bridge' mode. that will get rid of the double NAT.

Ryan said...

@Rod: Sure enough turning bridge mode on in the router fixed the problem. Tomato is hitting over 1k connections no problem.

What is odd is that my previous setup looked like this:

(2wire dsl router) <-> (linux pc) <-> (network)

This setup had no issues with double nat. However replacing (linux pc) with a tomato router was very slow. Just to be sure I unplugged the wan to tomato and plugged into the linux pc (and updated my routes) and sure enough it was fast again. Must be something in the linux 2.6 ubuntu configuration that agreed with the dsl router.

Summary:
2wire 1070-b in router mode w/ tomato router = slow. Disable the routing feature of the dsl modem (bridge mode) for much better performance.

Thanks for your help Rod. Great firmware and mods!

Anonymous said...

Hi, keep on the good work. can someone post the "tc add" line for cable connection.

Anonymous said...

Can you please add SNMPD?

Anonymous said...

Speed Up Tomato would be great - I've to try it. My Tomato Router is really slow.

Nice Feature would be to choose premium functions which other firmwares enables with their custom build. E.g. wireless ethernet bridge and wireless clients with wpa2, vlans for wireless and cable connections (to serve guest ssid), dual-wan to connect via umts as fallback. Great features wich i think they should be in one firmware - maybe some modules must be enabled to work with them, but this would be really great - all tomato version in one. Is this possible? Maybe also for jon.

Sorry about my bad english :)