Joost Kraaijeveld
2007-Jun-19 11:47 UTC
Why does this script noet work (bandwidth, tc en u32)
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 -- Groeten, Joost Kraaijeveld Askesis B.V. Molukkenstraat 14 6524NB Nijmegen tel: 024-3888063 / 06-51855277 fax: 024-3608416 web: www.askesis.nl
On Tue, 2007-06-19 at 13:47 +0200, Joost Kraaijeveld wrote:> 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> 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 10mbitOne 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.> # 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.> # 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 >
Joost Kraaijeveld
2007-Jun-19 20:48 UTC
Re: Why does this script noet work (bandwidth, tc en u32)
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> 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 -- Groeten, Joost Kraaijeveld Askesis B.V. Molukkenstraat 14 6524NB Nijmegen tel: 024-3888063 / 06-51855277 fax: 024-3608416 web: www.askesis.nl
Frank Remetter
2007-Jun-19 21:41 UTC
Re: Why does this script noet work (bandwidth, tc en u32)
Hey,> # 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 -- Frank Remetter http://www.remetter.de/ GPG-FP: 2B07 B7D8 5C27 AB94 7A37 8B0B DEBE DD89 D68B 7BE6
On Tue, 19 Jun 2007, Frank Remetter wrote:> Hey, > >> # 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 10Yeah, 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.