#!/bin/bash # 10kbit up (..KB) => 30kbit down # 20kbit up (5.2KB) => ..kbit down # 100kbit up (KB) => ..kbit down # also a possible notation: # 15kbps UPLINK=60kbit start() { sudo tc qdisc del dev eth0 root 2>/dev/null sudo tc qdisc add dev eth0 root tbf rate $UPLINK latency 50ms burst 1540 } stop() { sudo tc qdisc del dev eth0 root 2>/dev/null } status() { echo -e "** Local Routing Table **\n" ip route list table local echo -e "\n** Main Routing Table **\n" ip route list table main echo -e "\n** Qdisc Parameters **\n" tc qdisc ls dev eth0 echo -e "\n** Class Parameters **\n" tc class ls dev eth0 echo -e "\n** Filter Parameters **\n" tc filter ls dev eth0 } usage() { echo -e "Usage: " $0 " [ start | stop | status | info ]\n" echo -e " start - start traffic shaping" echo -e " stop - stop traffic shaping" echo -e " status - display traffic-shaping information" echo -e " info - display some pre-defined shaping values" } if [ ! $1 ] ; then usage exit 1 fi if [ $1 = "start" ] ; then start exit 0 elif [ $1 = "stop" ] ; then stop exit 0 elif [ $1 = "status" ] ; then status exit 0 elif [ $1 = "info" ] ; then info exit 0 fi