Skip to contentSkip to conversation

Why does this script noet work (bandwidth, tc en u32)

LARTC Joost Kraaijeveld 3 participants 5 messages Jun 19, 2007 – Jun 20, 2007

lore
Share & tools
lore
#0 lore raw

Hi,

Can anyone point me out where the script below is wrong?

All I want is that host 172.31.1.1 can only use 10 megabit. If I run this script on the in-between router nothing happens (the host uses still the full 100 mbit, tested with iperf) , so i assume that something must be wrong....

#!/bin/sh

# LAN1 NIC
tc qdisc del dev eth0 root
tc qdisc add dev eth0 root handle 1: htb
tc class add dev eth0 parent 1: classid 1:1 htb rate 100mbit

# my machine
tc class add dev eth0 parent 1:1 classid 1:2 htb rate 1mbit ceil 10mbit
# filter 
tc filter add dev eth0 parent 1:1 protocol ip prio 1 u32 match ip dst 172.31.1.1 flowid 1:2

# LAN2 NIC
tc qdisc del dev eth1 root
tc qdisc add dev eth1 root handle 1: htb
tc class add dev eth1 parent 1: classid 1:1 htb rate 100mbit

# my machine
tc class add dev eth1 parent 1:1 classid 1:2 htb rate 1mbit ceil 10mbit
# filter 
tc filter add dev eth1 parent 1:1 protocol ip prio 1 u32 match ip src 172.31.1.1 flowid 1:2

TIA

Signature · 13 lines
Groeten,

Joost Kraaijeveld
Askesis B.V.
Molukkenstraat 14
6524NB Nijmegen
tel: 024-3888063 / 06-51855277
fax: 024-3608416
web: www.askesis.nl
_______________________________________________
LARTC mailing list
[email protected]
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc
#1 lore raw
Quoted 3 lines · Joost Kraaijeveld

Hi,

Can anyone point me out where the script below is wrong?

Maybee, I'm new to this stuff and having trouble getting some things to work myself. :S

Quoted 8 lines

All I want is that host 172.31.1.1 can only use 10 megabit. If I run this script on the in-between router nothing happens (the host uses still the full 100 mbit, tested with iperf) , so i assume that something must be wrong....

#!/bin/sh

Quoted 7 lines

# LAN1 NIC
tc qdisc del dev eth0 root
tc qdisc add dev eth0 root handle 1: htb
tc class add dev eth0 parent 1: classid 1:1 htb rate 100mbit

# my machine
tc class add dev eth0 parent 1:1 classid 1:2 htb rate 1mbit ceil 10mbit

One thing I find useful (especially when debugging) is to replace the default fifo qdisc on the leaf with one that _does_ maintain statistics
- which you can see with 'tc -s qdisc show dev ...'. Makes it a bit easier to see where your traffic is going, and if that matches your expectations/intentions.

Quoted 3 lines
# filter 
tc filter add dev eth0 parent 1:1 protocol ip prio 1 u32 match ip dst 172.31.1.1 flowid 1:2

Try attaching the filter to the root qdisc (parent 1:0). What I think might be happening is that the root qdisc had no idea what to do with the packets - there are no filters there, and you did not specify a "default" class. So it just sends the packets directly to the interface.

Or you could try adding "default 1" to the root htb qdisc. From there your filter should do the rest. Only I don't know if "default" can point to a non-leaf class, if you try let me know if it works or not.

HTH,
Mark.

Quoted 5 lines

# LAN2 NIC
tc qdisc del dev eth1 root
tc qdisc add dev eth1 root handle 1: htb
tc class add dev eth1 parent 1: classid 1:1 htb rate 100mbit

Quoted 9 lines
# my machine
tc class add dev eth1 parent 1:1 classid 1:2 htb rate 1mbit ceil 10mbit
# filter 
tc filter add dev eth1 parent 1:1 protocol ip prio 1 u32 match ip src 172.31.1.1 flowid 1:2

TIA

_______________________________________________
LARTC mailing list
[email protected]
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc

#2 lore raw
In reply to Joost Kraaijeveld

Hi Mark,

After changing the script in this way it seems to work (MI think that this is what you mend with attaching the filter to the root qdisk):

# downlink
tc qdisc del dev eth0 root

tc qdisc add dev eth0 root handle 1: htb
tc class add dev eth0 parent 1: classid 1:1 htb rate 100mbit
tc class add dev eth0 parent 1:1 classid 1:2 htb rate 1mbit ceil 10mbit
tc filter add dev eth0 parent 1: protocol ip prio 1 u32 match ip dst 172.31.1.1 flowid 1:2

# uplink
tc qdisc del dev eth1 root

tc qdisc add dev eth1 root handle 1: htb
tc class add dev eth1 parent 1: classid 1:1 htb rate 100mbit
tc class add dev eth1 parent 1:1 classid 1:2 htb rate 1mbit ceil 10mbit
tc filter add dev eth1 parent 1: protocol ip prio 1 u32 match ip src 172.31.1.1 flowid 1:2

Quoted 5 lines

One thing I find useful (especially when debugging) is to replace the default fifo qdisc on the leaf with one that _does_ maintain statistics
- which you can see with 'tc -s qdisc show dev ...'. Makes it a bit easier to see where your traffic is going, and if that matches your expectations/intentions.

Could you elaborate on this? Which "other fifo qdisc" that maintains statistics? Any hints on the right syntax?

TIA

Signature · 13 lines
Groeten,

Joost Kraaijeveld
Askesis B.V.
Molukkenstraat 14
6524NB Nijmegen
tel: 024-3888063 / 06-51855277
fax: 024-3608416
web: www.askesis.nl
_______________________________________________
LARTC mailing list
[email protected]
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc
#3 lore raw
In reply to Joost Kraaijeveld

Hey,

Quoted 11 lines
# uplink
tc qdisc del dev eth1 root

tc qdisc add dev eth1 root handle 1: htb
tc class add dev eth1 parent 1: classid 1:1 htb rate 100mbit tc class add dev eth1 parent 1:1 classid 1:2 htb rate 1mbit ceil 10mbit tc filter add dev eth1 parent 1: protocol ip prio 1 u32 match ip src 172.31.1.1 flowid 1:2

Could you elaborate on this? Which "other fifo qdisc" that maintains statistics? Any hints on the right syntax?

i guess he is talking of e.g. sfq:
tc qdisc add dev eth1 parent 1:2 handle 2: sfq perturb 10

Signature · 7 lines
Frank Remetter
http://www.remetter.de/
GPG-FP: 2B07 B7D8 5C27 AB94 7A37  8B0B DEBE DD89 D68B 7BE6
_______________________________________________
LARTC mailing list
[email protected]
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc
#4 lore raw
In reply to Joost Kraaijeveld
Quoted 11 lines · Frank Remetter

Hey,

Quoted 8 lines
# uplink
tc qdisc del dev eth1 root

tc qdisc add dev eth1 root handle 1: htb
tc class add dev eth1 parent 1: classid 1:1 htb rate 100mbit tc class add dev eth1 parent 1:1 classid 1:2 htb rate 1mbit ceil 10mbit tc filter add dev eth1 parent 1: protocol ip prio 1 u32 match ip src 172.31.1.1 flowid 1:2

Quoted 5 lines
Quoted 2 lines

Could you elaborate on this? Which "other fifo qdisc" that maintains statistics? Any hints on the right syntax?

i guess he is talking of e.g. sfq:
tc qdisc add dev eth1 parent 1:2 handle 2: sfq perturb 10

Yeah, that's what I meant. But forget I said it. According to the man page pfifo_fast "Does not maintain statistics and does not show up in tc qdisc ls." but I just noticed that it does so it doesn't make a difference.

Regards,
Mark.

_______________________________________________
LARTC mailing list
[email protected]
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc