Last active
April 4, 2022 02:23
-
-
Save ffund/6bc7d9be930f863de063e9925d88d608 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iface=$(ifconfig | grep -B1 "inet 10.10.1.1" | head -n1 | cut -f1 -d:) | |
sudo tc qdisc del dev $iface root | |
sudo tc qdisc add dev $iface root handle 1: htb default 3 | |
sudo tc class add dev $iface parent 1: classid 1:3 htb rate 10Mbit | |
sudo tc qdisc add dev $iface parent 1:3 handle 3: pfifo limit 100 | |
scale="$2" | |
f="$1" | |
while true; do | |
tail -n +2 "$f" | tr -d '\r' | while IFS=, read -r tput u | |
do | |
unit=$(echo "$u" | cut -d's' -f1) | |
if [ "$tput" = "0" ] ; then | |
tput=1 | |
fi | |
tputScaled=$(expr $scale*$tput | bc) | |
echo "$tputScaled $unit/second" | |
cmd="sudo tc class replace dev $iface parent 1: classid 1:3 htb rate ${tputScaled}${unit}" | |
eval "$cmd" | |
sleep 1 | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment