This commit is contained in:
Thomas Forgione 2019-09-05 14:58:45 +02:00
parent 4a611f8cf6
commit e8ce4afea0
No known key found for this signature in database
GPG Key ID: BFD17A2D71B3B5E7
1 changed files with 13 additions and 13 deletions

26
bin/bw
View File

@ -1,26 +1,26 @@
#!/usr/bin/env bash #!/usr/bin/env bash
unlimit() { unlimit() {
sudo tc qdisc del dev lo root tc qdisc del dev lo root
} }
limit() { limit() {
if [ "$1" = "5Mbps" ]; then if [ "$1" = "5Mbps" ]; then
sudo tc qdisc del dev lo root tc qdisc del dev lo root
sudo tc qdisc add dev lo handle 1: root htb default 11 tc qdisc add dev lo handle 1: root htb default 11
sudo tc class add dev lo parent 1:1 classid 1:11 htb rate 5000kbit tc class add dev lo parent 1:1 classid 1:11 htb rate 5000kbit
sudo tc qdisc add dev lo parent 1:11 handle 10: netem delay 38ms loss 0.09% tc qdisc add dev lo parent 1:11 handle 10: netem delay 38ms loss 0.09%
elif [ "$1" = "10Mbps" ]; then elif [ "$1" = "10Mbps" ]; then
sudo tc qdisc del dev lo root tc qdisc del dev lo root
sudo tc qdisc add dev lo handle 1: root htb default 11 tc qdisc add dev lo handle 1: root htb default 11
sudo tc class add dev lo parent 1:1 classid 1:11 htb rate 10000kbit tc class add dev lo parent 1:1 classid 1:11 htb rate 10000kbit
sudo tc qdisc add dev lo parent 1:11 handle 10: netem delay 32ms loss 0.09% tc qdisc add dev lo parent 1:11 handle 10: netem delay 32ms loss 0.09%
elif [ "$1" = "20Mbps" ]; then elif [ "$1" = "20Mbps" ]; then
sudo tc qdisc del dev lo root tc qdisc del dev lo root
sudo tc qdisc add dev lo handle 1: root htb default 11 tc qdisc add dev lo handle 1: root htb default 11
sudo tc class add dev lo parent 1:1 classid 1:11 htb rate 20000kbit tc class add dev lo parent 1:1 classid 1:11 htb rate 20000kbit
sudo tc qdisc add dev lo parent 1:11 handle 10: netem delay 25ms loss 0.09% tc qdisc add dev lo parent 1:11 handle 10: netem delay 25ms loss 0.09%
else else
echo -e >&2 "\x1B[31;1merror:\x1B[0m preset $1 not found" echo -e >&2 "\x1B[31;1merror:\x1B[0m preset $1 not found"
exit 1 exit 1