Re: limit bandwidth per host question

Linux Advanced Routing and Traffic Control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Andy Furniss wrote:

tc class add dev eth2 parent 1:0 classid 1:2 htb rate 255kbit burst 255kbit

Burst is a good idea

Actually you need to specify burst and cburst for it to work and I suppose the law doesn't stop you being more generous than 255kbit - I just tried 100k (= 100k byte) and browsing isn't too bad.

Browsing and downloading together with just fifo is horrible though. I tried htb with the prio qdisc and it was dissapointing WRT latency. HTB class prio was far better. In both cases I also had sfq on the leaf of the tcp class, which makes browsing while downloading nicer and for tcp games didn't hurt latency too much.

I was only testing with one user though I scripted two, I'll get round to playing with curl loader one day. There's bound to be a mistake somewhere, but I paste below what I did. class/flowids are hex and you have 0-ffff after : (minor) to play with - you'll need a more sensible numbering system that I chose.

Policing was also not too bad.

Andy.

cat htb-255-eth0-prio-htb

set -x
IP=/sbin/ip
TC=/sbin/tc

$TC qdisc del dev eth0 root &>/dev/null

if [ "$1" = "stop" ]
then
        echo "stopping"
        exit
fi

$TC qdisc add dev eth0 root handle 1: htb

$TC class add dev eth0 parent 1: classid 1:1 htb rate 255kbit burst 100k cburst 100k $TC class add dev eth0 parent 1:1 classid 1:11 htb prio 0 rate 200kbit ceil 255kbit burst 10k cburst 10k
$TC qdisc add dev eth0 parent 1:11 bfifo limit 50k
$TC class add dev eth0 parent 1:1 classid 1:12 htb prio 1 rate 55kbit ceil 255kbit burst 90k cburst 90k
$TC qdisc add dev eth0 parent 1:12 sfq limit 30

$TC filter add dev eth0 parent 1: protocol ip prio 1 u32 match ip dst 192.168.0.3 flowid 1:1 $TC filter add dev eth0 parent 1:1 protocol ip prio 1 u32 match ip protocol 6 0xff flowid 1:12 $TC filter add dev eth0 parent 1:1 protocol ip prio 2 u32 match u32 0 0 flowid 1:11

$TC class add dev eth0 parent 1: classid 1:2 htb rate 255kbit burst 100k cburst 100k $TC class add dev eth0 parent 1:2 classid 1:21 htb prio 0 rate 200kbit ceil 255kbit burst 10k cburst 10k
$TC qdisc add dev eth0 parent 1:21 bfifo limit 50k
$TC class add dev eth0 parent 1:2 classid 1:22 htb prio 1 rate 55kbit ceil 255kbit burst 90k cburst 90k
$TC qdisc add dev eth0 parent 1:22 sfq limit 30

$TC filter add dev eth0 parent 1: protocol ip prio 1 u32 match ip dst 192.168.0.99 flowid 1:2 $TC filter add dev eth0 parent 1:2 protocol ip prio 1 u32 match ip protocol 6 0xff flowid 1:22 $TC filter add dev eth0 parent 1:2 protocol ip prio 2 u32 match u32 0 0 flowid 1:21


cat htb-255-eth0-prio


set -x
IP=/sbin/ip
TC=/sbin/tc

$TC qdisc del dev eth0 root &>/dev/null

if [ "$1" = "stop" ]
then
        echo "stopping"
        exit
fi

$TC qdisc add dev eth0 root handle 1: htb

$TC class add dev eth0 parent 1: classid 1:1 htb rate 255kbit burst 100k cburst 100k $TC qdisc add dev eth0 parent 1:1 handle 2: prio bands 2 priomap 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
$TC qdisc add dev eth0 parent 2:1 bfifo limit 50k
$TC qdisc add dev eth0 parent 2:2 sfq limit 30

$TC filter add dev eth0 parent 1: protocol ip prio 1 u32 match ip dst 192.168.0.3 flowid 1:1 $TC filter add dev eth0 parent 2: protocol ip prio 1 u32 match ip protocol 6 0xff flowid 2:2 $TC filter add dev eth0 parent 2: protocol ip prio 2 u32 match u32 0 0 flowid 2:1

$TC class add dev eth0 parent 1: classid 1:2 htb rate 255kbit burst 100k cburst 100k $TC qdisc add dev eth0 parent 1:2 handle 3: prio bands 2 priomap 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
$TC qdisc add dev eth0 parent 3:1 bfifo limit 50k
$TC qdisc add dev eth0 parent 3:2 sfq limit 30

$TC filter add dev eth0 parent 1: protocol ip prio 1 u32 match ip dst 192.168.0.99 flowid 1:2 $TC filter add dev eth0 parent 3: protocol ip prio 1 u32 match ip protocol 6 0xff flowid 3:2 $TC filter add dev eth0 parent 3: protocol ip prio 2 u32 match u32 0 0 flowid 3:1


_______________________________________________
LARTC mailing list
LARTC@xxxxxxxxxxxxxxx
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc

[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux