Skip to main content Help Control Panel

Rod Morison Software —  Technotes

Home «   Linux «   Sysadmin «  

Better Broadband Bandwidth Utilization Using Wondershaper on a Linux Router to Limit the Uplink

Since I did some streaming video experiments in the early years of this century I've known that maxing both directions of an internet connection kills throughput. I did some experiments, initially to improve my SIP Phone performance (when my son is playing online games, TBH) and came up with a "low-hanging fruit" solution.
I'll spare the gory details, but if you study "canonical" TCP congestion algorithms and experiment on how they behave, you quickly find that maxing out both directions of a full duplex TCP pipe just kills performance all around. If you're interested in the ground up details, the best place to start is the classic work, TCP/IP Illustrated Vol 1. Much of this book's lore was woven into early network devices (and drivers) and remains much intact, afaict.

!!! To use Wondershaper, you'll have to use a Linux computer as your router. Afaik, most basic broadband routers don't provide traffic limiting features. Setting up a Linux router for your broadband is not a good first-time Linux project. For more info, perhaps look at http://en.wikipedia.org/wiki/List_of_router_or_firewall_distributions or http://www.stanford.edu/~fenn/linux/ . It's not terribly difficult to do with a standard Ubuntu Server distro, which is what I use.

If you want to cut to the chase, and improve your internet connection bandwidth, here's how I finagled the problem. First, I went to my ISPs bandwidth testing site late at night, when I knew not much else was happening on my connection. This effect can be had by shutting down everything except one bandwidth testing computer and your router. Better is to take that computer straight into the internet connection, but that was way too much work for my purposes. (And, would have involved way too much time in my basement!)

For me www.speakeasy.net provides a nice testing service at http://www.speakeasy.net/speedtest/ . I can't say whether this will suffice for non-speakeasy users. However, after running this test several times, I settled on a 3621 kbits/sec downlink and a 630 kbits/sec uplink as a baseline.

Then, use whatever traffic shaping tool you have to experiment with throughput at and below those values. The easiest, admittedly blunt knife, tool that I've found is Wondershaper. Wondershaper is available in Ubuntu, i.e.
sudo apt-get install wondershaper
Also, in the Ubuntu docs, you may find http://ubuntuforums.org/archive/index.php/t-25911.html useful...I certainly did.

In my case, with the 3621/630 profile, I tried Wondershaper at 3500/650, 4000/650, 4000/625 and 4000/600. To stress the connection, I tried a series of tests with 1-2 downloads and 0-2 uploads. I used scp to a hosted server of mine that can reliably max out my connection. Scp is nice because it prints out its bandwidth when it's done, or ^C'd. Yes, scp introduces some overhead, and it doesn't measure true "line" bits. The Flash based Speakeasy test uses the Flash plugin, but this isn't rocket science, right? Suffice it to say, there are far bigger holes in my methodology...but time is money, as they say, and I declared "victory" without having to be more precise.

Without getting into details (you can back my inference out of the graphs below) I concluded that my connection is insensitive to downlink shaping, but terribly sensitive to uplink shaping. Without shaping, whenever an upload was going full-bore, I lost 80-90% of my download bandwidth. By throttling uplink to 90-95% of the max, I got a big chunk of that back. With the throttled uplink my downloads only lost 10-30% of their speed, quite an improvement.

No time or space for the rationale, but anyone familiar with the term "TCP Round Trip ACK" can quickly imagine why. See Wikipedia's TCP entry. Better yet, get the Steven's Book, it's one of the best technical books every written, IMHO.

So here's the pretty picture. Bandwidth on the Y axis. My 5 traffic scenarios on the X. And a differently colored line for each shaping scenario. Which would you rather have?

TrafficShapingChart.png

And, even if you don't want to shape your traffic, when your teenager's Youtube upload brings everyones browsing in the house to a crawl, at least you'll know why. Which begs the question: why aren't these features built into home broadband routers or, better yet, into the TCP framework of broadband service providers!?

Postscript: For those interested, a good bit of research has been done on this problem, particularly under the name of FastTCP. http://fastsoft.com is commercial spinoff of that project and has some pertinent white papers on the subject.


Stay tuned
recent comments
podcasted files
AddThis.com