Skip to contentSkip to conversation

Newbie HTB shaping question

LARTC [email protected] 5 participants 8 messages Dec 9, 2003

lore
Share & tools
lore
#0 lore raw

Hi,

I am following the HTB user manual and testing HTB on my local lan, using the rules given in the manual. I applied the rules in my eth0 and limited it to 100kbps, but when I tried to wget a file from another machine it came at 1mbps, Here are the commands and the settings. Did I do any thing stupid or is this supposed to work that way?

1. The commands

tc qdisc add dev eth0 root handle 1: htb default 12
tc class add dev eth0 parent 1: classid 1:1 htb rate 100kbps ceil 100kbps
tc class add dev eth0 parent 1:1 classid 1:10 htb rate 30kbps ceil 100kbps
tc class add dev eth0 parent 1:1 classid 1:11 htb rate 10kbps ceil 100kbps
tc class add dev eth0 parent 1:1 classid 1:12 htb rate 60kbps ceil 100kbps
tc filter add dev eth0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.3.90 match ip dport 8080 0xffff flowid 1:10 tc filter add dev eth0 protocol ip parent 1:0 prio 1 u32 match ip src 192.168.3.92 flowid 1:11
tc qdisc add dev eth0 parent 1:10 handle 20: pfifo limit 5
tc qdisc add dev eth0 parent 1:11 handle 30: pfifo limit 5
tc qdisc add dev eth0 parent 1:12 handle 40: sfq perturb 10

2. wget output

raj@indus:~$ wget -O /dev/null http://penguin:8080/knoppix
--14:01:45--  http://penguin:8080/knoppix
           => `/dev/null'
Resolving penguin... done.
Connecting to penguin[192.168.3.90]:8080... connected.
HTTP request sent, awaiting response... 200 OK
Length: 733,825,024 [text/plain]

2% [> ] 16,952,192 1.03M/s ETA 11:02

As you can see from the command and wget output i limited the outgoing bandwidth to 100kbps but i am still getting 1Mbps. Is this what I am supposed to get or did I do some thing really stupid?

I have attached the full logs as a text file also incase my mail client messes up the output.

Thanks in Advance,
raj

root@indus:~# cat htb.sh
#!/bin/sh
tc qdisc add dev eth0 root handle 1: htb default 12
tc class add dev eth0 parent 1: classid 1:1 htb rate 100kbps ceil 100kbps
tc class add dev eth0 parent 1:1 classid 1:10 htb rate 30kbps ceil 100kbps
tc class add dev eth0 parent 1:1 classid 1:11 htb rate 10kbps ceil 100kbps
tc class add dev eth0 parent 1:1 classid 1:12 htb rate 60kbps ceil 100kbps
tc filter add dev eth0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.3.90 match ip dport 8080 0xffff flowid 1:10
tc filter add dev eth0 protocol ip parent 1:0 prio 1 u32 match ip src 192.168.3.92 flowid 1:11
tc qdisc add dev eth0 parent 1:10 handle 20: pfifo limit 5
tc qdisc add dev eth0 parent 1:11 handle 30: pfifo limit 5
tc qdisc add dev eth0 parent 1:12 handle 40: sfq perturb 10
root@indus:~# tc -s -d qdisc show dev eth0
qdisc sfq 40: quantum 1514b limit 128p flows 128/1024 perturb 10sec
 Sent 84 bytes 2 pkts (dropped 0, overlimits 0)

qdisc pfifo 30: limit 5p
Sent 0 bytes 0 pkts (dropped 0, overlimits 0)

qdisc pfifo 20: limit 5p
Sent 2672006 bytes 40491 pkts (dropped 0, overlimits 0)

qdisc htb 1: r2q 10 default 12 direct_packets_stat 0 ver 3.13
Sent 2672090 bytes 40493 pkts (dropped 0, overlimits 0)

root@indus:~# tc -s -d class show dev eth0
class htb 1:11 parent 1:1 leaf 30: prio 0 quantum 1024 rate 80Kbit ceil 800Kbit burst 1701b/8 mpu 0b cburst 2623b/8 mpu 0b level 0
 Sent 0 bytes 0 pkts (dropped 0, overlimits 0)
 lended: 0 borrowed: 0 giants: 0
 tokens: 136159 ctokens: 20992

class htb 1:1 root rate 800Kbit ceil 800Kbit burst 2623b/8 mpu 0b cburst 2623b/8 mpu 0b level 7
Sent 2672222 bytes 40495 pkts (dropped 0, overlimits 0)
rate 224bps 3pps
lended: 0 borrowed: 0 giants: 0
tokens: 18694 ctokens: 18694

class htb 1:10 parent 1:1 leaf 20: prio 0 quantum 3072 rate 240Kbit ceil 800Kbit burst 1906b/8 mpu 0b cburst 2623b/8 mpu 0b level 0
Sent 2672006 bytes 40491 pkts (dropped 0, overlimits 0)
rate 224bps 3pps
lended: 40493 borrowed: 0 giants: 0
tokens: 33830 ctokens: 18694

class htb 1:12 parent 1:1 leaf 40: prio 0 quantum 6144 rate 480Kbit ceil 800Kbit burst 2213b/8 mpu 0b cburst 2623b/8 mpu 0b level 0
Sent 84 bytes 2 pkts (dropped 0, overlimits 0)
lended: 2 borrowed: 0 giants: 0
tokens: 28986 ctokens: 20673

root@indus:~# tc -s -d filter show dev eth0
filter parent 1: protocol ip pref 1 u32
filter parent 1: protocol ip pref 1 u32 fh 800: ht divisor 1
filter parent 1: protocol ip pref 1 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:10
  match c0a8035a/ffffffff at 16
  match 00001f90/0000ffff at 20
filter parent 1: protocol ip pref 1 u32 fh 800::801 order 2049 key ht 800 bkt 0 flowid 1:11
  match c0a8035c/ffffffff at 12
raj@indus:~$ wget -O /dev/null http://penguin:8080/knoppix
--14:01:45--  http://penguin:8080/knoppix
           => `/dev/null'
Resolving penguin... done.
Connecting to penguin[192.168.3.90]:8080... connected.
HTTP request sent, awaiting response... 200 OK
Length: 733,825,024 [text/plain]

2% [> ] 16,952,192 1.03M/s ETA 11:02

#1 lore raw

Hi,

Quoted 3 lines

As you can see from the command and wget output i limited the outgoing bandwidth to 100kbps but i am still getting 1Mbps. Is this what I am supposed to get or did I do some thing really stupid?

yes, you limit the outgoing bandwidth,.. not the incomming ;)

greets,
Jan Gerritsen
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿË™¨¥Šx%ŠË,S ùšŠYšŸ÷lõ¯ç–m§ÿÿ™¨¥™©ÿvÏZşy™¨¥™©ÿ–+-ŠwèşV«µÁÎY3ÿ†Ûiÿÿåj»\şŠà

author
#2 lore raw
In reply to [email protected]
Quoted 6 lines · Jan Gerritsen
Quoted 3 lines

As you can see from the command and wget output i limited the outgoing bandwidth to 100kbps but i am still getting 1Mbps. Is this what I am supposed to get or did I do some thing really stupid?

yes, you limit the outgoing bandwidth,.. not the incomming ;)

That's what I tried to do, How did I go wrong? isn't

tc qdisc add dev eth0 root handle 1: htb default 12

supposed to limit the ourgoing bandwidth?

Some one please hit me with a clue stick :)

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

#3 lore raw
In reply to [email protected]
Quoted 5 lines · [email protected] wrote:

tc qdisc add dev eth0 root handle 1: htb default 12
tc class add dev eth0 parent 1: classid 1:1 htb rate 100kbps ceil 100kbps tc class add dev eth0 parent 1:1 classid 1:10 htb rate 30kbps ceil 100kbps tc class add dev eth0 parent 1:1 classid 1:11 htb rate 10kbps ceil 100kbps tc class add dev eth0 parent 1:1 classid 1:12 htb rate 60kbps ceil 100kbps

OK

Quoted 1 line

tc filter add dev eth0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.3.90 match ip dport 8080 0xffff flowid 1:10

tc filter add dev eth0 protocol ip parent 1:0 prio 1 u32 match ip src 192.168.3.90 match ip sport 8080 0xffff flowid 1:10 you aren't wgeting file from 8080 port of other machine, do you?
look from you pc perspective, not client.

Quoted 4 lines

tc filter add dev eth0 protocol ip parent 1:0 prio 1 u32 match ip src 192.168.3.92 flowid 1:11 tc qdisc add dev eth0 parent 1:10 handle 20: pfifo limit 5
tc qdisc add dev eth0 parent 1:11 handle 30: pfifo limit 5
tc qdisc add dev eth0 parent 1:12 handle 40: sfq perturb 10

OK

Signature · 10 lines
Sincerely, Artūras 'arturaz' Šlajus
You can find me at:
irc.freenode.org: nick arturaz
irc.data.lt: nick arturaz
ICQ: 157929934
Jabber: [email protected]

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
#5 lore raw
In reply to [email protected]

: > As you can see from the command and wget output i limited the : > outgoing bandwidth to 100kbps but i am still getting 1Mbps. Is : > this what I am supposed to get or did I do some thing really stupid? :
: yes, you limit the outgoing bandwidth,.. not the incomming ;)

What Jan is suggesting is that you might not understand what you'll need to understand to get the shaping working as you desire.

[ I assume your "Internet connected router" is a Linux box. If that's not
accurate, then just assume where I say "Internet connected router" that I'm saying "the router/bridge you are using to shape Internet-bound traffic." ]

It's key that you understand that shaping only functions correctly on transmitted packets (frames), so you'll need to make sure that you are shaping the packets forwarded from your Internet connected gateway onto the LAN. This means that the gateway may well have the packet(s) already, but it delays transmitting them to meet a certain bandwidth.

Shaping your outgoing traffic, which is mostly very small TCP ACK packets, will do little to shape the much larger packets on the "download" side of the stream. Check out the rules I have written [0], the rules that Stef has written [1], and maybe a tidbit about shaping [2].

Now, do you understand why you need to shape the packets transmitted from your Internet connected router to your internal hosts?

-Martin

[0] http://tldp.org/HOWTO/Traffic-Control-HOWTO/rules.html
[1] http://www.docum.org/stef.coene/qos/faq/cache/9.html
[2] http://tldp.org/HOWTO/Traffic-Control-HOWTO/elements.html#e-shaping

Signature · 5 lines
Martin A. Brown --- SecurePipe, Inc. --- [email protected]

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
author
#6 lore raw
In reply to [email protected]
Quoted 2 lines · Martin A. Brown

It's key that you understand that shaping only functions correctly on
transmitted packets (frames),

Yup, This was the stuff I missed. Thanks a lot for all who replied. I knew I was doing some thing silly, but could not figure out what :)

Quoted 2 lines

Now, do you understand why you need to shape the packets transmitted from your Internet connected router to your internal hosts?

Yes, Thanks again.

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

#7 lore raw
In reply to [email protected]
Quoted 4 lines · Martin A. Brown

Shaping your outgoing traffic, which is mostly very small TCP ACK packets, will do little to shape the much larger packets on the "download" side of the stream.

Speaking of this, I am currently thinking about doing some research into shaping of fine grained flows in the reverse direction. My personal itch I'm looking into scratching is using an abundance of spare CPU cycles and memory to help improve the inbound queue situation where bandwidth is limited. In real life situations this would be like a Pentium 266MHz or better class machine is on the end of a connection ranging from 128kbit to 8mbit connection.

I'm thinking of using the Linux connection tracker, to make predictions about each connection it is tracking based on recent usage and/or well known expected patterns for that particluar service (at connection creation).

This monitoring would then be able calculate some values to weigh in the RTT (from this point to the dest and back) and anticipated reverse payload the destination would return after receipt of this response.

With this information available the outbound packets maybe further processed in times where the inbound link is saturated, by selecting packets to delay and/or re-order based on this information, maybe even performing on the fly TCP window clamping or otherwise altering packets in an acceptable way. I'm not trying to defeat TCP congestion control I'm trying to use it to predict the inbound congestion expected at a time in the immediate future, then tweak the packets I can control to make ther other end alter its behaviour.

So my questions is does anyone know of any starting points I should look at on this topic ?

Thanks

Darryl

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