Jump to: navigation, search
This graph shows how download (green) almost dies completely when maximum upload starts and no traffic shaping is in affect.
The same situation with traffic shaping. Maximum upload does not limit download at all.
Many years ago, when I got my first broadband Internet connection, I bought myself a small router to allow me to share the connection between my computers at home. I soon experienced some irritating issues which I apparently shared with many other router owners. My download speed always seemed to drop to almost zero if I was using my upload heavily at the same time. Also, my ping to the game servers I visited, was very high and irregular while upload was in progress. I wanted to understand why this happened and what I could to do to prevent it and my search finally led me to this article explaining the technical problem. The solution proposed in the article was to manipulate the outgoing data packets by rearranging them and making sure the used upload bandwidth never exceeded the available bandwidth. The tool to accomplish this was a traffic shaping framework called ALTQ but this framework also needed some kind of controlling mechanism and the suggested software for this was pf, the native firewall of the operating system OpenBSD. This was back in 2003 and without any prior UNIX knowledge I eventually got this to work and have used this technique since then. For various reasons I did however switch to FreeBSD when pf was ported to this operating system in 2004.

Since then, I have helped several of my friends to build their own FreeBSD routers. Due to the complexity of the installation, I eventually found it necessary to write down the steps involved, allowing me to build new routers without missing any important configuration steps. This wiki is the result of that work and I share it here with you in case you find it useful and want to build a router of your own.

To better understand what a FreeBSD-based router can do for you, let's establish a few goals.

Primary goals

  • Allow full utilization of upload and download bandwidth simultaneously.
  • Maintain low and stable ping for online gaming regardless of upload bandwidth utilization.
  • Allow low bandwidth tasks (like browsing and emailing) to be performed without latency regardless of upload bandwidth utilization.
  • Deploy a secure and efficient stateful firewall.
  • Provide NAT, DHCP and other basic network services to the computers on your home LAN.
  • Stability - you should be able to run this router for years without rebooting it.

It's important to understand that the goals involving low latency and stable ping only can be achieved as long as they depend on the upload bandwidth because this is the only traffic you can shape. If you download heavily, it doesn't matter what you do with the traffic once it reaches your router, because it has already crossed your DSL or cable connection by then and rearranging the data packets at that point doesn't make any difference. Heavy downloading will continue to delay other traffic and the only way around that would be to prioritize the traffic at your ISP's upstream router which you probably don't have access to.

Secondary goals

  • This graph shows the automatic distribution of upload bandwidth between queues with different priority. From green (lowest priority) to red (highest priority).
    Automatically give your friends priority to your upload bandwidth when needed.
  • Create a web publishing platform with Apache, MySQL and PHP.

There is of course another purpose to this wiki too. I don't claim to be an expert in any way on the things I explain here. The initial version of this wiki will build upon the experience and knowledge I've gathered for five years using OpenBSD and FreeBSD. There are many things I still don't comprehend and lots of functionality I'd like to add to my own router but can't since I simply don't understand certain concepts. My hope is that people who read this wiki will help by adding their own knowledge and experience and in that process teach me the things I don't know.


Personal tools