├── throttle.sh └── README.md /throttle.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | LIMIT_TEXT="Kbytes/s" 4 | LIMIT=$1$LIMIT_TEXT 5 | 6 | if [[ $EUID -ne 0 ]]; then 7 | echo "This script must be run as root." 1>&2 8 | exit 1 9 | fi 10 | 11 | case $1 in 12 | "stop") 13 | ipfw delete 1 14 | echo "Throttling Stopped" 1>&2 15 | ;; 16 | "gprs") 17 | ipfw pipe 1 config bw 30$LIMIT_TEXT 18 | ipfw add 1 pipe 1 tcp from any to me 19 | echo "Throttling download to 30$LIMIT_TEXT" 1>&2 20 | ;; 21 | "edge") 22 | ipfw pipe 1 config bw 200$LIMIT_TEXT 23 | ipfw add 1 pipe 1 tcp from any to me 24 | echo "Throttling download to 200$LIMIT_TEXT" 1>&2 25 | ;; 26 | "3g") 27 | ipfw pipe 1 config bw 14000$LIMIT_TEXT 28 | ipfw add 1 pipe 1 tcp from any to me 29 | echo "Throttling download to 14000$LIMIT_TEXT" 1>&2 30 | ;; 31 | "4g") 32 | ipfw pipe 1 config bw 3000000$LIMIT_TEXT 33 | ipfw add 1 pipe 1 tcp from any to me 34 | echo "Throttling download to 3000000$LIMIT_TEXT" 1>&2 35 | ;; 36 | *) 37 | ipfw pipe 1 config bw $LIMIT 38 | ipfw add 1 pipe 1 tcp from any to me 39 | echo "Throttling download to $LIMIT" 1>&2 40 | ;; 41 | esac -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OSx Bandwidth Throttler (this will work for any *nix) 2 | 3 | ## Basic Usage 4 | 5 | - Download throttle.sh. 6 | - Make the file executable with `chmod +x throttle.sh` 7 | - Run it as the admin with `sudo ./throttle.sh 45` 8 | - Turn everything off by running `sudo ./throttle.sh stop` 9 | 10 | ## Values 11 | 12 | - Numerical values will adjust to that speed in Kbytes/s e.g. `sudo ./throttle.sh 54` 13 | - Typing stop will reset back to what it should be e.g. `sudo ./throttle.sh stop` 14 | - Typing some predefined constants will result in some throttling e.g. `sudo ./throttle.sh 3g` 15 | 16 | ## Constants taken from here (http://www.which.co.uk/technology/phones/guides/mobile-broadband/mobile-broadband-speed-and-usage-limits/) 17 | 18 | - gprs - 30 19 | - edge - 200 20 | - 3g - 14000 21 | - 4g - 3000000 22 | 23 | ## Help! 24 | 25 | If you manage to throttle your speed but can't get it to go back to normal you should run this command: `sudo ipfw delete 1` 26 | 27 | ## Thanks 28 | 29 | The initial code for building this was inspired by this article by Ben Lakey - http://benlakey.com/2012/10/14/throttle-bandwidth-on-mac-os-x/ --------------------------------------------------------------------------------