Let’s say your home has an internet connection that isn’t all that great and you’re in the middle of a non-resumable download on your computer, and you want to stream a movie from a different media device. You start the stream and it buffers like crazy, stutters, re-buffers, and is therefor generally unwatchable. There isn’t enough bandwidth to both support your download and stream the movie. Ideally you could just tone down the bandwidth on your computer so that the download is restricted to a certain subset of your overall bandwidth.
This is actually easy to do on Mac OS X (and other nix variants). Let’s say you want to slow your bandwidth consumption to 30kb/sec.
ipfw pipe 1 config bw 30Kbytes/s ipfw add 1 pipe 1 tcp from any to me
Great. Now you watch your movie and all is well. But after you’re done with your movie you want to unthrottle. That’s easy enough too:
ipfw delete 1
In fact since you’re probably a developer you can script this to embrace the lazyness trademark of a good developer:
#!/bin/sh LIMITDOWN="30Kbytes/s" LIMITUP="10Kbytes/s" if [[ $EUID -ne 0 ]]; then echo "This script must be run as root." 1>&2 exit 1 fi ipfw pipe 1 config bw $LIMITDOWN ipfw pipe 2 config bw $LIMITUP ipfw add 1 pipe 1 tcp from any to me ipfw add 2 pipe 2 tcp from me to any
#!/bin/sh if [[ $EUID -ne 0 ]]; then echo "This script must be run as root." 1>&2 exit 1 fi ipfw delete 1 ipfw delete 2
Happy downloading/streaming.comments powered by Disqus
(c) 2013 Ben Lakey
The words here do not reflect those of my employer.