Skip to contentSkip to conversation

Weighted packet shaping?

LARTC Mark Williams (MWP) 5 participants 19 messages Dec 21, 2004 – Jan 4, 2005

lore
Share & tools
lore
#0 lore raw

Hi all,

Im new to all this, and am still trying to get my head qround some of the concepts of how this all works.
Ive read the howto's, man pages etc.

Ive setup packet shaping on my router/server box using HTB and SFQ, but its not working the way i would like.

Im after shaping that has "weights" for classes so that a lower priority class will slow down when a higher class wants to flow more data.
As far as i can see, HTB wont do this...

Ive looked at WRR which i have compiled into my 2.6.8.1 kernel and iproute2, but it seems this really only works with multiple sources (client PCs), rather than the iptables MARK system i want to use so i can organise local and client PC traffic.

Does anyone know how i can do what im after?

Thanks,
Mark Williams.
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#1 lore raw

Anyone?

Quoted 18 lines

Hi all,

Im new to all this, and am still trying to get my head qround some of the concepts of how this all works.
Ive read the howto's, man pages etc.

Ive setup packet shaping on my router/server box using HTB and SFQ, but its not working the way i would like.

Im after shaping that has "weights" for classes so that a lower priority class will slow down when a higher class wants to flow more data.
As far as i can see, HTB wont do this...

Ive looked at WRR which i have compiled into my 2.6.8.1 kernel and iproute2, but it seems this really only works with multiple sources (client PCs), rather than the iptables MARK system i want to use so i can organise local and client PC traffic.

Quoted 8 lines

Does anyone know how i can do what im after?

Thanks,
Mark Williams.
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#2 lore raw
In reply to Mark Williams (MWP)
Quoted 6 lines

Im after shaping that has "weights" for classes so that a lower priority class will slow down when a higher class wants to flow more data.
As far as i can see, HTB wont do this...

I'm not quite sure what you mean? HTB itself dequeues at a rate limited pace. However, by combining several HTB classes, each with a different priority and using the tc/mark to filter certain traffic into each bucket you will achieve what you want I think?

I'm sure wondershaper and all the other example scripts have this kind of thing setup as well?

However, the problem I think with the "weighting" is that it's not really designed to be used like this. The idea is that each class limits traffic to it's stated bandwidth and only the excess is shared based on priority...

I didn't know there was a WRR module though? Where did you find it?

Perhaps you could describe the real problem a little more and someone might have a better way for you to do this

Ed W
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#3 lore raw
In reply to Mark Williams (MWP)
Quoted 6 lines · Mark Williams (MWP)

Hi all,

Im new to all this, and am still trying to get my head qround some of the concepts of how this all works.
Ive read the howto's, man pages etc.

Quoted 6 lines

Ive setup packet shaping on my router/server box using HTB and SFQ, but its not working the way i would like.

Im after shaping that has "weights" for classes so that a lower priority class will slow down when a higher class wants to flow more data.
As far as i can see, HTB wont do this...

As Ed says - I think you probably can do it with rate/ceil/prio - detail depends on you set up and exactly what you want to happen/

Quoted 2 lines

Ive looked at WRR which i have compiled into my 2.6.8.1 kernel

There is a TC options related bug in 2.6.8.1 you'll probably need to update/patch. This fixed it for me.

http://www.linuxhq.com/kernel/v2.6/9-rc2/net/sched/sch_api.c

Andy.

and iproute2, but

Quoted 4 lines

it seems this really only works with multiple sources (client PCs), rather than the iptables MARK system i want to use so i can organise local and client PC traffic.

Quoted 8 lines

Does anyone know how i can do what im after?

Thanks,
Mark Williams.
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#4 lore raw
In reply to Mark Williams (MWP)

Ok.

My Linux (which is connected to the ADLS modem) box runs HTTP, FTP, etc services and also runs bittorrent, edonkey, etc.
I have two other PCs (both windows) which connect to the internet via the Linux
box (MASQ).

Now, i want data like SSH, ICMP, DNS from any source to ppp0 to get top priority. I want the two windows PCs to get 2nd priority.
I want services to get 3rd, and the rest (torrents, etc) to get the lowest priority.

I have this setup atm using HTB and SFQ.

Now this is what happens:
I have bittorrent going as fast as possible outbound. I then use my linux box to send FTP data over the same link.

Im finding that packet shaping is splitting the outbound bandwidth (256kbit) equally between the two.

This is not what im after... want the windows box to take more bandwidth off bittorrent than 50% like it is atm.

Does this explain my problem better?

Thanks!

Quoted 22 lines
Quoted 6 lines · Mark Williams (MWP)

Hi all,

Im new to all this, and am still trying to get my head qround some of the concepts of how this all works.
Ive read the howto's, man pages etc.

Quoted 8 lines

Ive setup packet shaping on my router/server box using HTB and SFQ, but its not
working the way i would like.

Im after shaping that has "weights" for classes so that a lower priority class
will slow down when a higher class wants to flow more data. As far as i can see, HTB wont do this...

As Ed says - I think you probably can do it with rate/ceil/prio - detail depends on you set up and exactly what you want to happen/

Quoted 2 lines

Ive looked at WRR which i have compiled into my 2.6.8.1 kernel

Quoted 24 lines

There is a TC options related bug in 2.6.8.1 you'll probably need to update/patch. This fixed it for me.

http://www.linuxhq.com/kernel/v2.6/9-rc2/net/sched/sch_api.c

Andy.

and iproute2, but

Quoted 14 lines

it seems this really only works with multiple sources (client PCs), rather than
the iptables MARK system i want to use so i can organise local and client PC
traffic.

Does anyone know how i can do what im after?

Thanks,
Mark Williams.
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#5 lore raw
In reply to Mark Williams (MWP)
Quoted 18 lines · Mark Williams (MWP)

Ok.

My Linux (which is connected to the ADLS modem) box runs HTTP, FTP, etc services and also runs bittorrent, edonkey, etc.
I have two other PCs (both windows) which connect to the internet via the Linux
box (MASQ).

Now, i want data like SSH, ICMP, DNS from any source to ppp0 to get top priority. I want the two windows PCs to get 2nd priority.
I want services to get 3rd, and the rest (torrents, etc) to get the lowest priority.

I have this setup atm using HTB and SFQ.

Now this is what happens:
I have bittorrent going as fast as possible outbound. I then use my linux box to send FTP data over the same link.

Quoted 7 lines

Im finding that packet shaping is splitting the outbound bandwidth (256kbit) equally between the two.

This is not what im after... want the windows box to take more bandwidth off bittorrent than 50% like it is atm.

Does this explain my problem better?

Yes, you can do this with htb.

You'll need to back off a bit from 256kbit to allow for overheads - this is tweakable with patch Ed posted to the list - you could also shape incoming, but you would need IMQ which involves patching/doing new kernel.

For now try making a parent with rate and ceil 220kbit. Have 4 child/leaf classes like - (assuming 1 is highest priority)

class 1 rate 120 ceil 220 prio 0
class 2 rate 50 ceil 220 prio 1
class 3 rate 25 ceil 220 prio 2
class 4 rate 25 ceil 220 prio 3

There are other tweaks you can try, it depends how much you care about latency. You could also share the windows boxes bandwidth by IP.

I don't do it quite like the above - so if it doesn't work, say and I'll think again.

Andy.

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#6 lore raw
In reply to Mark Williams (MWP)
Quoted 46 lines
Quoted 25 lines · Mark Williams (MWP)

Ok.

My Linux (which is connected to the ADLS modem) box runs HTTP, FTP, etc services and also runs bittorrent, edonkey,
etc.
I have two other PCs (both windows) which connect to the internet via the Linux
box (MASQ).

Now, i want data like SSH, ICMP, DNS from any source to ppp0 to get top priority.
I want the two windows PCs to get 2nd priority.
I want services to get 3rd, and the rest (torrents, etc) to get the lowest priority.

I have this setup atm using HTB and SFQ.

Now this is what happens:
I have bittorrent going as fast as possible outbound. I then use my linux box to send FTP data over the same link.

Im finding that packet shaping is splitting the outbound bandwidth (256kbit)
equally between the two.

Quoted 5 lines

This is not what im after... want the windows box to take more bandwidth off
bittorrent than 50% like it is atm.

Does this explain my problem better?

Yes, you can do this with htb.

You'll need to back off a bit from 256kbit to allow for overheads - this is tweakable with patch Ed posted to the list - you could also shape incoming, but you would need IMQ which involves patching/doing new kernel.

For now try making a parent with rate and ceil 220kbit. Have 4 child/leaf classes like - (assuming 1 is highest priority)

class 1 rate 120 ceil 220 prio 0
class 2 rate 50 ceil 220 prio 1
class 3 rate 25 ceil 220 prio 2
class 4 rate 25 ceil 220 prio 3

Quoted 5 lines

There are other tweaks you can try, it depends how much you care about latency. You could also share the windows boxes bandwidth by IP.

I don't do it quite like the above - so if it doesn't work, say and I'll think again.

Well im currently using:

#root device
$TC qdisc add dev $INTERFACE root handle 1: htb default 25

#root class
$TC class add dev $INTERFACE parent 1: classid 1:1 htb rate 256kbit

#20 - ICMP, DNS, SYN, SSH
$TC class add dev $INTERFACE parent 1:1 classid 1:20 htb rate 128kbit ceil 256kbit prio 1 $TC qdisc add dev $INTERFACE parent 1:20 handle 20: sfq perturb 10
$TC filter add dev $INTERFACE parent 1:0 prio 0 protocol ip handle 20 fw flowid 1:20

#21 - HTTP/FTP out
$TC class add dev $INTERFACE parent 1:1 classid 1:21 htb rate 128kbit ceil 256kbit prio 2 $TC qdisc add dev $INTERFACE parent 1:21 handle 21: sfq perturb 10
$TC filter add dev $INTERFACE parent 1:0 prio 0 protocol ip handle 21 fw flowid 1:21

#22 - All cool.comp traffic
$TC class add dev $INTERFACE parent 1:1 classid 1:22 htb rate 128kbit ceil 256kbit prio 3 $TC qdisc add dev $INTERFACE parent 1:22 handle 22: sfq perturb 10
$TC filter add dev $INTERFACE parent 1:0 prio 0 protocol ip handle 22 fw flowid 1:22

#23 - All ian.comp traffic
$TC class add dev $INTERFACE parent 1:1 classid 1:23 htb rate 64kbit ceil 256kbit prio 4 $TC qdisc add dev $INTERFACE parent 1:23 handle 23: sfq perturb 10
$TC filter add dev $INTERFACE parent 1:0 prio 0 protocol ip handle 23 fw flowid 1:23

#24 - HTTP/FTP in
$TC class add dev $INTERFACE parent 1:1 classid 1:24 htb rate 64kbit ceil 256kbit prio 5 $TC qdisc add dev $INTERFACE parent 1:24 handle 24: sfq perturb 10
$TC filter add dev $INTERFACE parent 1:0 prio 0 protocol ip handle 24 fw flowid 1:24

#25 - Everything else
$TC class add dev $INTERFACE parent 1:1 classid 1:25 htb rate 20kbit ceil 64kbit prio 8 $TC qdisc add dev $INTERFACE parent 1:25 handle 25: sfq perturb 10
$TC filter add dev $INTERFACE parent 1:0 prio 0 protocol ip handle 25 fw flowid 1:25

Ill do some more tests and link to a rates graph when done. It should illustrate the problem.

Thanks again,
Mark.
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#7 lore raw
In reply to Mark Williams (MWP)
Quoted 48 lines · Mark Williams (MWP)
Quoted 8 lines

For now try making a parent with rate and ceil 220kbit. Have 4 child/leaf classes like - (assuming 1 is highest priority)

class 1 rate 120 ceil 220 prio 0
class 2 rate 50 ceil 220 prio 1
class 3 rate 25 ceil 220 prio 2
class 4 rate 25 ceil 220 prio 3

Quoted 5 lines

There are other tweaks you can try, it depends how much you care about latency. You could also share the windows boxes bandwidth by IP.

I don't do it quite like the above - so if it doesn't work, say and I'll think again.

Well im currently using:

#root device
$TC qdisc add dev $INTERFACE root handle 1: htb default 25

#root class
$TC class add dev $INTERFACE parent 1: classid 1:1 htb rate 256kbit

#20 - ICMP, DNS, SYN, SSH
$TC class add dev $INTERFACE parent 1:1 classid 1:20 htb rate 128kbit ceil 256kbit prio 1 $TC qdisc add dev $INTERFACE parent 1:20 handle 20: sfq perturb 10
$TC filter add dev $INTERFACE parent 1:0 prio 0 protocol ip handle 20 fw flowid 1:20

#21 - HTTP/FTP out
$TC class add dev $INTERFACE parent 1:1 classid 1:21 htb rate 128kbit ceil 256kbit prio 2 $TC qdisc add dev $INTERFACE parent 1:21 handle 21: sfq perturb 10
$TC filter add dev $INTERFACE parent 1:0 prio 0 protocol ip handle 21 fw flowid 1:21

#22 - All cool.comp traffic
$TC class add dev $INTERFACE parent 1:1 classid 1:22 htb rate 128kbit ceil 256kbit prio 3 $TC qdisc add dev $INTERFACE parent 1:22 handle 22: sfq perturb 10
$TC filter add dev $INTERFACE parent 1:0 prio 0 protocol ip handle 22 fw flowid 1:22

#23 - All ian.comp traffic
$TC class add dev $INTERFACE parent 1:1 classid 1:23 htb rate 64kbit ceil 256kbit prio 4 $TC qdisc add dev $INTERFACE parent 1:23 handle 23: sfq perturb 10
$TC filter add dev $INTERFACE parent 1:0 prio 0 protocol ip handle 23 fw flowid 1:23

#24 - HTTP/FTP in
$TC class add dev $INTERFACE parent 1:1 classid 1:24 htb rate 64kbit ceil 256kbit prio 5 $TC qdisc add dev $INTERFACE parent 1:24 handle 24: sfq perturb 10
$TC filter add dev $INTERFACE parent 1:0 prio 0 protocol ip handle 24 fw flowid 1:24

Quoted 4 lines

#25 - Everything else
$TC class add dev $INTERFACE parent 1:1 classid 1:25 htb rate 20kbit ceil 64kbit prio 8 $TC qdisc add dev $INTERFACE parent 1:25 handle 25: sfq perturb 10
$TC filter add dev $INTERFACE parent 1:0 prio 0 protocol ip handle 25 fw flowid 1:25

Try to make it look like I said - back off from 256 ceil, make rates add up to master rate (220), give interactive more rate than it will ever need.

Class 24 does not make sense to me, and you may also find that ftp goes to default - It can be hard to mark and I can't see how you are marking it.

Andy.

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#8 lore raw
In reply to Mark Williams (MWP)
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

For now try making a parent with rate and ceil 220kbit. Have 4 child/leaf classes like - (assuming 1 is highest priority)

class 1 rate 120 ceil 220 prio 0
class 2 rate 50 ceil 220 prio 1
class 3 rate 25 ceil 220 prio 2
class 4 rate 25 ceil 220 prio 3

There are other tweaks you can try, it depends how much you care about latency. You could also share the windows boxes bandwidth by IP.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

I don't do it quite like the above - so if it doesn't work, say and I'll think again.

<snip>

Try to make it look like I said - back off from 256 ceil, make rates add up to master rate (220), give interactive more rate than it will ever need.

Ok, im now trying:

class add dev $INTERFACE parent 1: classid 1:1 htb rate 220kbit
class add dev $INTERFACE parent 1:1 classid 1:20 htb rate 70kbit ceil 220kbit prio 1 class add dev $INTERFACE parent 1:1 classid 1:21 htb rate 50kbit ceil 220kbit prio 2 class add dev $INTERFACE parent 1:1 classid 1:22 htb rate 25kbit ceil 220kbit prio 3 class add dev $INTERFACE parent 1:1 classid 1:23 htb rate 25kbit ceil 220kbit prio 4 class add dev $INTERFACE parent 1:1 classid 1:24 htb rate 25kbit ceil 220kbit prio 5 class add dev $INTERFACE parent 1:1 classid 1:25 htb rate 25kbit ceil 220kbit prio 8

Its simply not working.
Bittorrent is using ~22kb/sec on class 25, leaving the FTP upload (class 22) sitting on only ~3kb/sec.

Any ideas?

Thanks!
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#9 lore raw
In reply to Mark Williams (MWP)
Quoted 31 lines · Mark Williams (MWP)
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

For now try making a parent with rate and ceil 220kbit. Have 4 child/leaf classes like - (assuming 1 is highest priority)

class 1 rate 120 ceil 220 prio 0
class 2 rate 50 ceil 220 prio 1
class 3 rate 25 ceil 220 prio 2
class 4 rate 25 ceil 220 prio 3

There are other tweaks you can try, it depends how much you care about latency. You could also share the windows boxes bandwidth by IP.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

I don't do it quite like the above - so if it doesn't work, say and I'll think again.

<snip>

Try to make it look like I said - back off from 256 ceil, make rates add up to master rate (220), give interactive more rate than it will ever need.

Ok, im now trying:

class add dev $INTERFACE parent 1: classid 1:1 htb rate 220kbit
class add dev $INTERFACE parent 1:1 classid 1:20 htb rate 70kbit ceil 220kbit prio 1 class add dev $INTERFACE parent 1:1 classid 1:21 htb rate 50kbit ceil 220kbit prio 2 class add dev $INTERFACE parent 1:1 classid 1:22 htb rate 25kbit ceil 220kbit prio 3 class add dev $INTERFACE parent 1:1 classid 1:23 htb rate 25kbit ceil 220kbit prio 4 class add dev $INTERFACE parent 1:1 classid 1:24 htb rate 25kbit ceil 220kbit prio 5 class add dev $INTERFACE parent 1:1 classid 1:25 htb rate 25kbit ceil 220kbit prio 8

Quoted 5 lines

Its simply not working.
Bittorrent is using ~22kb/sec on class 25, leaving the FTP upload (class 22) sitting on only ~3kb/sec.

Any ideas?

Are you sure that FTP is going to class 22 and not default -

tc -s qdisc ls dev $INTERFACE or tc -s class ls dev $INTERFACE will show counters.

Andy.

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#10 lore raw
In reply to Mark Williams (MWP)
Quoted 44 lines
Quoted 43 lines · Mark Williams (MWP)
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines

For now try making a parent with rate and ceil 220kbit. Have 4 child/leaf classes like - (assuming 1 is highest priority)

class 1 rate 120 ceil 220 prio 0
class 2 rate 50 ceil 220 prio 1
class 3 rate 25 ceil 220 prio 2
class 4 rate 25 ceil 220 prio 3

There are other tweaks you can try, it depends how much you care about latency. You could also share the windows boxes bandwidth by IP.

I don't do it quite like the above - so if it doesn't work, say and I'll think again.

Quoted 6 lines
Quoted 1 line

<snip>

Try to make it look like I said - back off from 256 ceil, make rates add up to master rate (220), give interactive more rate than it will ever need.

Ok, im now trying:

class add dev $INTERFACE parent 1: classid 1:1 htb rate 220kbit class add dev $INTERFACE parent 1:1 classid 1:20 htb rate 70kbit ceil 220kbit prio 1
class add dev $INTERFACE parent 1:1 classid 1:21 htb rate 50kbit ceil 220kbit prio 2
class add dev $INTERFACE parent 1:1 classid 1:22 htb rate 25kbit ceil 220kbit prio 3
class add dev $INTERFACE parent 1:1 classid 1:23 htb rate 25kbit ceil 220kbit prio 4
class add dev $INTERFACE parent 1:1 classid 1:24 htb rate 25kbit ceil 220kbit prio 5
class add dev $INTERFACE parent 1:1 classid 1:25 htb rate 25kbit ceil 220kbit prio 8

Its simply not working.
Bittorrent is using ~22kb/sec on class 25, leaving the FTP upload (class
22)
sitting on only ~3kb/sec.

Quoted 7 lines
Quoted 1 line

Any ideas?

Are you sure that FTP is going to class 22 and not default -

tc -s qdisc ls dev $INTERFACE or tc -s class ls dev $INTERFACE will show counters.

I am.
I graph using "tc -s qdisc show dev ppp0" with rrdtool.

Thanks,
Mark.
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#11 lore raw
In reply to Mark Williams (MWP)
Quoted 9 lines · Mark Williams (MWP)
Quoted 5 lines

Are you sure that FTP is going to class 22 and not default -

tc -s qdisc ls dev $INTERFACE or tc -s class ls dev $INTERFACE will show counters.

I am.
I graph using "tc -s qdisc show dev ppp0" with rrdtool.

Ahh, I assume you patched and recompiled your 2.6.8.1.

I just tried the script below on 2.4.24 and 2.6.8.1 and it works as I expect.

I checked rates with iptraf and tc -s class ls dev ppp0. If you use htb's rate counter than be aware it uses a long average >60 sec and I notice that on my 2.6.8.1 setup it says bit where it probably should say bps (= bytes per sec).

Does it work for you ?

If you want to graph then add some queues.

Andy.

TC=/sbin/tc
IPTABLES=/usr/local/sbin/iptables

$IPTABLES -t mangle -D POSTROUTING -o ppp0 -p tcp --src 192.168.0.2 -j MARK --set-mark 21 &>/dev/null
$IPTABLES -t mangle -D POSTROUTING -o ppp0 -p tcp --src 192.168.0.3 -j MARK --set-mark 22 &>/dev/null
$IPTABLES -t mangle -D POSTROUTING -o ppp0 -p ! tcp -j MARK --set-mark 20 &>/dev/null
$IPTABLES -t mangle -D POSTROUTING -o ppp0 -p tcp -m length --length :128 -j MARK --set-mark 20 &>/dev/null

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

if ( [ "$1" = "stop" ] )
then
exit
fi

$TC qdisc add dev ppp0 root handle 1: htb default 23
$TC class add dev ppp0 parent 1: classid 1:1 htb rate 220kbit $TC class add dev ppp0 parent 1:1 classid 1:20 htb rate 120kbit ceil 220kbit prio 1
$TC class add dev ppp0 parent 1:1 classid 1:21 htb rate 50kbit ceil 220kbit prio 2
$TC class add dev ppp0 parent 1:1 classid 1:22 htb rate 25kbit ceil 220kbit prio 3
$TC class add dev ppp0 parent 1:1 classid 1:23 htb rate 25kbit ceil 220kbit prio 4

$TC filter add dev ppp0 parent 1:0 prio 0 protocol ip handle 20 fw flowid 1:20
$TC filter add dev ppp0 parent 1:0 prio 1 protocol ip handle 21 fw flowid 1:21
$TC filter add dev ppp0 parent 1:0 prio 2 protocol ip handle 22 fw flowid 1:22

$IPTABLES -t mangle -A POSTROUTING -o ppp0 -p tcp --src 192.168.0.2 -j MARK --set-mark 21
$IPTABLES -t mangle -A POSTROUTING -o ppp0 -p tcp --src 192.168.0.3 -j MARK --set-mark 22
$IPTABLES -t mangle -A POSTROUTING -o ppp0 -p ! tcp -j MARK --set-mark 20 $IPTABLES -t mangle -A POSTROUTING -o ppp0 -p tcp -m length --length :128 -j MARK --set-mark 20

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#12 lore raw
In reply to Mark Williams (MWP)
Quoted 19 lines
Quoted 8 lines · Mark Williams (MWP)
Quoted 5 lines

Are you sure that FTP is going to class 22 and not default -

tc -s qdisc ls dev $INTERFACE or tc -s class ls dev $INTERFACE will show counters.

I am. I graph using "tc -s qdisc show dev ppp0" with rrdtool.

Ahh, I assume you patched and recompiled your 2.6.8.1.

I just tried the script below on 2.4.24 and 2.6.8.1 and it works as I expect.

I checked rates with iptraf and tc -s class ls dev ppp0. If you use htb's rate counter than be aware it uses a long average >60 sec and I notice that on my 2.6.8.1 setup it says bit where it probably should say bps (= bytes per sec).

Quoted 5 lines

Does it work for you ?

If you want to graph then add some queues.

Andy.

Ok...
Using your script gave the following (from 17:30 onwards):

http://www.overclockers.com.au/~mwp/temp/tc-1hour-yours.png

Purple is class 23; all other traffic, in this case bittorrent. Blue is class 21; a windows box, in this case an FTP transfer.

Shouldnt class 23 still be dropping off further than that?
It seems HTB is wanting to share traffic equally among on the classes rather than by priority.

You script is pretty much having the same effect as mine :(

BTW... this is now with kernel 2.6.10, not that seems to have changed its behaviour.

Thanks again!
Mark Williams.
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#13 lore raw
In reply to Mark Williams (MWP)
Quoted 5 lines · Mark Williams (MWP)

Ok...
Using your script gave the following (from 17:30 onwards):

http://www.overclockers.com.au/~mwp/temp/tc-1hour-yours.png

This is strange I just tested again and it works for me.

http://www.jessingale.dsl.pipex.com/tc-speed-1.png

Blue is lowest with rate 20kbit green next low with 40kbit Red highest.

It may be worth trying with ceils even lower - just incase you get radsl adaption and don't really have the bandwidth.

I suppose you should also use tc from new iproute2 that matches your kernel.

rrdtool seems complicated - I suppose it could be averaging strangely, I used -

#set -x

/usr/local/rrdtool-1.0.49/bin/rrdtool create tcstats1.rrd --step 10 \
             DS:cls21:COUNTER:30:U:U   \
             DS:cls22:COUNTER:30:U:U  \
             DS:cls23:COUNTER:30:U:U  \
             RRA:AVERAGE:0.5:1:100

while [ 1 ]
do

         C21=`tc -s qdisc ls dev ppp0 | grep "21:" -A 1 | grep Sent | 
awk '{print $2}'`
         C22=`tc -s qdisc ls dev ppp0 | grep "22:" -A 1 | grep Sent | 
awk '{print $2}'`
         C23=`tc -s qdisc ls dev ppp0 | grep "23:" -A 1 | grep Sent | 

awk '{print $2}'`
/usr/local/rrdtool-1.0.49/bin/rrdtool update tcstats1.rrd
N:$C21:$C22:$C23
sleep 10
done

Andy.

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#14 lore raw
In reply to Mark Williams (MWP)
Quoted 10 lines
Quoted 4 lines

Ok...
Using your script gave the following (from 17:30 onwards):

http://www.overclockers.com.au/~mwp/temp/tc-1hour-yours.png

This is strange I just tested again and it works for me.

http://www.jessingale.dsl.pipex.com/tc-speed-1.png

Blue is lowest with rate 20kbit green next low with 40kbit Red highest.

The result your getting is exactly what im after.
So whats different with what im doing... hrm.

Quoted 2 lines

It may be worth trying with ceils even lower - just incase you get radsl adaption and don't really have the bandwidth.

Nah, i have firm 256kbit up.

Quoted 1 line

I suppose you should also use tc from new iproute2 that matches your kernel.

Ok, where is the correct place to get it from?
I havnt been able to find the official "release site" for iproute2.

Quoted 17 lines

rrdtool seems complicated - I suppose it could be averaging strangely, I used -

#set -x

/usr/local/rrdtool-1.0.49/bin/rrdtool create tcstats1.rrd --step 10 \
            DS:cls21:COUNTER:30:U:U   \
            DS:cls22:COUNTER:30:U:U  \
            DS:cls23:COUNTER:30:U:U  \
            RRA:AVERAGE:0.5:1:100

while [ 1 ]
do

        C21=`tc -s qdisc ls dev ppp0 | grep "21:" -A 1 | grep Sent | 
awk '{print $2}'`
        C22=`tc -s qdisc ls dev ppp0 | grep "22:" -A 1 | grep Sent | 
awk '{print $2}'`
        C23=`tc -s qdisc ls dev ppp0 | grep "23:" -A 1 | grep Sent | 
Quoted 5 lines

awk '{print $2}'`
/usr/local/rrdtool-1.0.49/bin/rrdtool update tcstats1.rrd
N:$C21:$C22:$C23
sleep 10
done

Thats very similar to what im doing, nothing too complex about it. I also know the graph is correct as the estimated rates from TC are the same as shown on the graph.

So this is becoming an unknown problem?

Thanks.
Mark Williams.
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#15 lore raw
In reply to Mark Williams (MWP)

Mensaje citado por "Mark Williams (MWP)" <[email protected]>:

Quoted 6 lines
Quoted 1 line

I suppose you should also use tc from new iproute2 that matches your

kernel.

Ok, where is the correct place to get it from?
I havnt been able to find the official "release site" for iproute2.

http://developer.osdl.org/dev/iproute2/

Regards,
Francisco.

-------------------------------------------------------------
La Tienda del Portal esta de fiesta!
http://tienda.montevideo.com.uy
-------------------------------------------------------------

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#16 lore raw
In reply to Mark Williams (MWP)
Quoted 4 lines · Mark Williams (MWP)

I also know the graph is correct as the estimated rates from TC are the same as shown on the graph.

So this is becoming an unknown problem?

There must be something :-)

One thing I thought of, if you are getting any congestion/packet loss on the ftp upload, then you would expect results more like you see.

I would take a closer look at what is happening to the upload connection.

You could get an idea of whether you are dropping by doing some netstat -s | grep retrans on the box running the upload.

You could also do a tcpdump to look at what window the server is letting you use / see drops.

Looking at backlogs with tc -s class ... should show the FTP class as backloged all the time - if it's empty(not there) sometimes then that's another sign that something else is limiting it.

Andy.

Quoted 4 lines

Thanks.
Mark Williams.

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#17 lore raw
In reply to Mark Williams (MWP)
Quoted 6 lines · Mark Williams (MWP)

Ok...
Using your script gave the following (from 17:30 onwards):

http://www.overclockers.com.au/~mwp/temp/tc-1hour-yours.png

Quoted 7 lines

Purple is class 23; all other traffic, in this case bittorrent. Blue is class 21; a windows box, in this case an FTP transfer.

Shouldnt class 23 still be dropping off further than that?
It seems HTB is wanting to share traffic equally among on the classes rather than by priority.

You script is pretty much having the same effect as mine :(

ok, maybe i'm wrong, but i try to run the same script, and i think that the script have problem setting prio 0 on filters:

running:

$TC filter add dev $IFNAME parent 1:0 prio 0 protocol ip handle 22 fw flowid 1:20
$TC filter add dev $IFNAME parent 1:0 prio 2 protocol ip handle 21 fw flowid 1:21

gave me:

# tc filter list dev eth0
filter parent 1: protocol ip pref 2 fw 
filter parent 1: protocol ip pref 2 fw handle 0x15 classid 1:21 
filter parent 1: protocol ip pref 49152 fw 
filter parent 1: protocol ip pref 49152 fw handle 0x16 classid 1:20 

----------------------------------^^^^^

don't blame me if this is obvious/wrong/stupid. :)

2.6.10, with lastest iproute2

Signature · 6 lines
BOFH excuse #212:

Of course it doesn't work. We've performed a software upgrade.
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
#18 lore raw
In reply to Mark Williams (MWP)
Quoted 19 lines · marco ghidinelli

ok, maybe i'm wrong, but i try to run the same script, and i think that the script have problem setting prio 0 on filters:

running:

$TC filter add dev $IFNAME parent 1:0 prio 0 protocol ip handle 22 fw flowid 1:20
$TC filter add dev $IFNAME parent 1:0 prio 2 protocol ip handle 21 fw flowid 1:21

gave me:

# tc filter list dev eth0
filter parent 1: protocol ip pref 2 fw 
filter parent 1: protocol ip pref 2 fw handle 0x15 classid 1:21 
filter parent 1: protocol ip pref 49152 fw 
filter parent 1: protocol ip pref 49152 fw handle 0x16 classid 1:20 
Quoted 3 lines

----------------------------------^^^^^

don't blame me if this is obvious/wrong/stupid. :)

Well spotted - you are right, I see the same, so it looks like 0 is not the highest prio when used on filters - I shall use 1 in future.

As for affecting this test - I don't think it will make any difference in this case because it just affects the order that the matches get tested against the packets. With only 3 tests and low packets/sec it should makes no difference.

It's still usefull to know for other setups, though - thanks.

Andy.

Quoted 3 lines

2.6.10, with lastest iproute2

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/