LARTC
[Top] [All Lists]

Re: [LARTC] limit bandwidth per host question

To: lists@andyfurniss.entadsl.com
Subject: Re: [LARTC] limit bandwidth per host question
From: Andy Furniss <lists@andyfurniss.entadsl.com>
Date: Fri, 11 May 2007 10:52:48 +0100
Cc: lartc@mailman.ds9a.nl
Delivered-to: sp-com-lists@consult.net
Delivered-to: lartc-list@securepoint.com
Delivered-to: lartc@outpost.ds9a.nl
In-reply-to: <46423F8C.1090905@andyfurniss.entadsl.com>
List-archive: <http://mailman.ds9a.nl/pipermail/lartc>
List-help: <mailto:lartc-request@mailman.ds9a.nl?subject=help>
List-id: "Mailinglist of the Linux Advanced Routing &amp; Traffic Control project" <lartc.mailman.ds9a.nl>
List-post: <mailto:lartc@mailman.ds9a.nl>
List-subscribe: <http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc>, <mailto:lartc-request@mailman.ds9a.nl?subject=subscribe>
List-unsubscribe: <http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc>, <mailto:lartc-request@mailman.ds9a.nl?subject=unsubscribe>
References: <463FD790.8010709@studentergaarden.dk> <46423F8C.1090905@andyfurniss.entadsl.com>
Reply-to: lists@andyfurniss.entadsl.com
Sender: lartc-bounces@mailman.ds9a.nl
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.8.1.2) Gecko/20070227 SeaMonkey/1.1.1
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@mailman.ds9a.nl
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc

<Prev in Thread] Current Thread [Next in Thread>