TBF can bound the traffic, but has no support for classes. But you can use it as qdisc on a CBQ class to bound that class. CBQ can also bound a class, but is not so accurate. So I tested the accuracy of the tbf qdisc.
Used script (download)
RATE_MAX=$1`echo kbps` IP=kriek DEV="dev eth0" tc qdisc del $DEV root tc qdisc add $DEV root handle 10: tbf rate $RATE_MAX buffer 20Kb/8 limit 15Kb iptables -F iptables -X iptables -N acc_0 iptables -A OUTPUT -t mangle -j MARK --set-mark 1 iptables -A OUTPUT -j acc_0 iptables -A OUTPUT -j ACCEPTAnd I used another script that executes the tbf script with different parameters. Each time the monitor.pl script is executed and when the average speed didn't changed fot 10 times, the value is logged to a file.
Used script (download)
Each time the traffic was allmost perfect bounded. So the results are very good. This setup test the accuracy of tbf on a long periode. How tbf is dealing with short data bursts, is for a next test.
If have a non-duplex 10Mbit connection. When you want to transmit to much data, the link get congested. The maximum throughput is reached when I bound the traffic to 960 Kbyte/s. When you want to transmit more data, you loose bandwidth due to overhead and collisions.
You can download the logfile here.
TODO : try different options.