Throttling Bandwidth On A Mac 7


Throttling Bandwidth On A Mac


Since most of us have a limited Internet connection where we can only download so much data, it can be useful to throttle our bandwidth so we don’t use so much. This post is in response to a submission by Grant to the sort of tips he would like to see. Although you can’t specifically limit the amount of data sent by each person, you can limit your overall network usage. There are many applications out there that can do this sort of technique, although the ones I have tried are not that good. Just using Terminal seems to be the quickest.

The first step is to understand how this works. You will enter a small piece of code into your Mac’s firewall, this it the UNIX one that your computer is running off. This piece of code will attach to a port, you can then limit the amount of data you can download through that port. If you limit the amount of data you can download per second, you can limit the amount you download overall. For example if you have a 500kb/s download speed but only 10Gb download limit you will burn through it pretty quickly, whereas if you only have a 100kb/s (with limiting) your overall bandwidth should last a lot longer. Its slightly complicated but it does work. The good thing about this tip is that you can control the amount of data for each port, so you can have http running at full speed and bittorrent limited. You can customize it a lot, there is probably an option to have a cap but I haven’t had time to have a good dig through.

The first step is to open Terminal and add a new pipe. I am not 100% sure what is meant by a pipe, all of the tutorials mention it.

sudo ipfw pipe 1 config bw 50KByte/s

Set the bandwidth (bw) limit to any number you want. For example you could have a 15kb pipe for X application and then a 100kb pipe for another application and attach things to those pipes. If a port isn’t attached to a pipe, it runs at full speed. Change the number (in this case 1) to a different number for a different pipe.

The next step is to attach your port.

sudo ipfw add 1 pipe 1 src-port 80

In this case anything on port 80 (http) will be set to a limit of 50Kbyte/s. If you want to attach a second port to this pipe, repeat the command but change the port number at the end.

You can now test this and see how slow the Internet runs at. You can change the speed value to something suitable by running the first command again. You are now throttling your Internet and you shouldn’t be downloading as much. Great if you have some background traffic and you don’t want it to use up all of your bandwidth. Although I haven’t tested this, if you have some spare time you could change “src-port” to an IP address, this would be useful if you have other computers connecting through your computer. You would have to do some research. You could also replace the number 80 to a star (*) to capture all ports, you would have to have a play. Check the man page for the Terminal command.

If you want to delete the throttle simply type the following:

sudo ipfw delete 1

The pipe is deleted and you are back to normal. I hope this tip helps you control how much you download.

If you want to take your skills with Terminal a bit further I recommend you check out the Terminal Category on this site. If you fancy reading a book there is a couple on Amazon that I regularly see mentioned and recommend, O’reilly Unix Geeks and Unix Under the Hood both are designed for Mac OS X and take Terminal further.

Found Via

If you want to keep up with the latests post from Mac Tricks And Tips I recommend you subscribe to the RSS Feed.

Where To Next?

  • Subscribe To Mac Tricks And Tips