commit 88c8d06a9ea085ada9ebbf26a2e7625a3e8a82a4 Author: Will Bradley Date: Fri May 22 18:37:20 2015 -0700 Initial commit diff --git a/LICENSING.txt b/LICENSING.txt new file mode 100644 index 0000000..68a49da --- /dev/null +++ b/LICENSING.txt @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to diff --git a/README.md b/README.md new file mode 100644 index 0000000..d63a039 --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +TC Slowify +========== + +Shell scripts to help you simulate slow network connections +----------------------------------------------------------- + +*Requirements (generally included in Ubuntu, Fedora, OpenSuse, Gentoo, Debian, Mandriva, etc)*: +- tc (a Linux command, part of the iproute2 package) +- netem (included in the 2.6 Linux kernel) + +*Usage*: + +- ./apply.sh + - Applies limiting rules; prompts you to select an interface name, rate, and latency +- ./remove.sh + - Removes limiter from that interface +- ./status.sh + - Shows rules on that interface (sometimes other rules may already exist, that's ok) + +*License*: + +The Unlicense, see LICENSING.txt diff --git a/apply.sh b/apply.sh new file mode 100755 index 0000000..7ae8e6a --- /dev/null +++ b/apply.sh @@ -0,0 +1,20 @@ +# TC Slowify +# Shell scripts to help you simulate slow network connections +# By Will Bradley +# Thanks to https://gist.github.com/trongthanh/1196596 +# Released via the Unlicense (see LICENSING.txt) + +echo "" +read -e -i "lo" -p "Interface name to limit (ex: `ls -C /sys/class/net | sed 's/\s\+/, /g'`): " ifname +read -e -i "56kbps" -p "Limit amount (including units, ex: 56kbps): " limit +read -e -i "200ms" -p "Latency amount (including units, ex: 200ms): " latency + +sudo tc qdisc add dev $ifname root handle 1: htb default 12 +sudo tc class add dev $ifname parent 1:1 classid 1:12 htb rate $limit ceil $limit +sudo tc qdisc add dev $ifname parent 1:12 netem delay $latency + +echo "" +echo "Set limiter on $ifname to:" +echo "" + +sudo tc -s qdisc ls dev $ifname diff --git a/remove.sh b/remove.sh new file mode 100755 index 0000000..6db1d5e --- /dev/null +++ b/remove.sh @@ -0,0 +1,17 @@ +# TC Slowify +# Shell scripts to help you simulate slow network connections +# By Will Bradley +# Thanks to https://gist.github.com/trongthanh/1196596 +# Released via the Unlicense (see LICENSING.txt) + + +echo "" +read -e -i "lo" -p "Interface name to un-limit (ex: `ls -C /sys/class/net | sed 's/\s\+/, /g'`): " ifname + +sudo tc qdisc del dev $ifname root + +echo "" +echo "Removed limiter; $ifname is now:" +echo "" + +sudo tc -s qdisc ls dev $ifname diff --git a/status.sh b/status.sh new file mode 100755 index 0000000..45b5d95 --- /dev/null +++ b/status.sh @@ -0,0 +1,8 @@ +# TC Slowify +# Shell scripts to help you simulate slow network connections +# By Will Bradley +# Thanks to https://gist.github.com/trongthanh/1196596 +# Released via the Unlicense (see LICENSING.txt) + + +sudo tc -s qdisc ls dev eth3