I found a good example which described what I wanted to achieve (limit my uploads to 83.3 kB/s) here. Using the examples on that page, I wrote a little script to allow me to start and stop the limited uploads easily:
#!/bin/bashYou'll note I've set a $burstRate value of 100MB/s. This is probably not necessary, but with the same $burstRate value as used in $maxRate, I was seeing significant slowdown in the responsiveness of the remote session; I hope this high burst rate will alleviate that slowdown.
# Script to throttle uploads during the times when Virgin
# won't allow unlimited uploads.
#
# Those times are between 1500 and 2000 no more than
# 1.5GB must be uploaded, so the upload speed needs to be
# capped at 83.3kB/s.
maxRate=83.3kbps
burstRate=100000kbps
interface=eth0
clearRule(){
# First things first, clear the old rule
tc qdisc del dev eth0 root
}
makeRule(){
# Now add the throttling rule
tc qdisc add dev $interface root handle 1:0 htb default 10
tc class add dev $interface parent 1:0 classid 1:10 htb rate $maxRate ceil $burstRate prio 0
}
listRules(){
tc -s qdisc ls dev $interface
}
case "$1" in
'start')
clearRule
makeRule
;;
'stop')
clearRule
;;
'status')
listRules
;;
*)
echo "Usage: $0 {start|stop|status}"
;;
esac
I saved this script somewhere where root only could get it and then added the following cronjobs to root's crontab:
# Add networking throttling between 1500 and 2000So far, the process appears to be working, insofar as my daily uploads from home to work have slowed to approximately 80kB/s during the times when Virgin monitor uploads.
00 15 * * * /root/throttle_uploads.sh start
00 20 * * * /root/throttle_uploads.sh stop
No comments:
Post a Comment