Traffic Control with tc
This weekend I had an interesting dilemma. I needed to transfer about 2GB worth of data to a remote machine. That's not really a lot to download, but it can be quite a pain on an asynchronous upload home Internet connection where your upload speed is pitiful! So, I began the transfer, and wouldn't you know that halfway through, my roommate returned from work. Now, since my roommate works at a startup called Blinkx in downtown San Francisco, he has work to do pretty much 24/7. I didn't want to disturb his work, but I also didn't want to cancel my transfer. What was a hacker to do :-(
After feeling defeated for about five minutes and having no idea how to shape the current traffic connection, I stumbled onto something. tc! Yes, tc can do everything you need to shape traffic. Amazing. A little man page reading later, and in ten minutes, I was now happily transferring data and not hogging all the upload bandwidth from my roommate. Here's how I was able to limit my upload to ~30KB/sec, from our cap of ~100KB/sec.
# tc qdisc add dev eth1 root handle 1: tbf rate 300kbit burst 300kbit latency 1
Now, this command is quite a hack. I didn't actually bother to find the best options for the job, but then again, I didn't have much time. The command above merely limits the connection of my wireless device to ~30KB/sec using the Token Bucket Filter mechanism.
I highly encourage the reader to find more advanced usage of tc and craft some beautiful shaping rules. If you don't want as much control, then you may consider other useful tools such as trickle/trickled (user-space) and wondershaper. Happy hacking :-)
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems
Free to Linux Journal readers.Register Now!
|Security Hardening with Ansible||Aug 18, 2014|
|Monitoring Android Traffic with Wireshark||Aug 14, 2014|
|IndieBox: for Gamers Who Miss Boxes!||Aug 13, 2014|
|Non-Linux FOSS: a Virtualized Cisco Infrastructure?||Aug 11, 2014|
|Linux Security Threats on the Rise||Aug 08, 2014|
|Android Candy: Oyster—Netflix for Books!||Aug 07, 2014|
- Security Hardening with Ansible
- NSA: Linux Journal is an "extremist forum" and its readers get flagged for extra surveillance
- Monitoring Android Traffic with Wireshark
- Tech Tip: Really Simple HTTP Server with Python
- RSS Feeds
- Readers' Choice Awards 2013
- Returning Values from Bash Functions
- Linux Security Threats on the Rise
- IndieBox: for Gamers Who Miss Boxes!
- [<Megashare>] Watch Mrs Brown's Boys Movie Online Full Movie HD 2014