This is a long message. Please use a monospace font :)
I'm trying to shape the traffic between my LAN and the Internet. My link is an
ADSL 512/128 line. The network is shaped like this:
LAN GATEWAY ROUTER
------------------ ------------- ------------
| 192.168.0.1/16 | <----> | 192.168.0.1 | <----> | 10.0.0.138 | <--> INET
------------------ ------------- ------------
NAT/PAT/MASQ occurs in two places. From gateway to router (192.168.0.1/16 ->
10.0.0.1/8) and from router to net. I've put the shaper in my gateway and am
trying to shape both incoming & outgoing traffic by placing shapers at both
eth0 (download) & eth1 (upload). This to keep my connection usable while i'm
running emule or other mass downloader/p2p programs.
What i'm trying to do is shape every upload to max 90kbit/s but give priority
to HTTP,SSH,TELNET,POP3,SMTP,DNS & low priority to everything else. The same
thing for the downloads but this time for 450kbit/s.
What happens is emule works as normal but HTTP gives lots of timeouts on
connecting, and even when it connects, it continues to timeout on the images
of the pages for example. But i've been able to determine by listening to a
shoutcast stream that uses port 80 that once the connection is made it stays
stable. So the problem seems to be establishing new connections. I dont know
if the other protocols dont suffer from this problem or they have larger
timeouts.
I've changed every htb.init option i could think of and i couldnt fix it. If
someone has an idea please say something.
Thanks.
Attached are the commands generated by htb.ini compile & the list from
htb.init list & htb.init stats.
The class files on eth1 (upload) are:
-------------/-------------
root@xxxxxxxx:/etc/sysconfig/htb# ls eth1*
eth1 eth1-2.root eth1-2:10.high eth1-2:20.normal eth1-2:30.low
root@xxxxxxxx:/etc/sysconfig/htb# cat eth1
DEFAULT=30
R2Q=1
root@xxxxxxxx:/etc/sysconfig/htb# cat eth1-2.root
# root class for outgoing traffic
RATE=90Kbit
LEAF=sfq
root@xxxxxxxx:/etc/sysconfig/htb# cat eth1-2\:10.high
# class for outgoing high priority traffic
RATE=30Kbit
CEIL=prate
#BURST=15k
LEAF=sfq
# HTTP
RULE=*:80
# SSH
RULE=*:22
# TELNET
RULE=*:23
# SMTP
RULE=*:25
# DNS
RULE=*:53
# POP3
RULE=*:110
root@xxxxxxxx:/etc/sysconfig/htb# cat eth1-2\:20.normal
# class for outgoing normal traffic
RATE=30Kbit
CEIL=prate
# BURST=15k
LEAF=sfq
# IRC
RULE=*:6667
root@xxxxxxxx:/etc/sysconfig/htb# cat eth1-2\:30.low
# default class for unclassified traffic
RATE=20Kbit
CEIL=prate
# BURST=15k
LEAF=sfq
# EMULE
RULE=*:3000
RULE=*:3000,
RULE=*:3010
RULE=*:3010,
RULE=*:4662
RULE=*:4662,
--------------/-------------------
The class files for eth0 download:
-------------/--------------------
root@xxxxxxxx:/etc/sysconfig/htb# ls eth0*
eth0 eth0-2.root eth0-2:10.high eth0-2:20.normal eth0-2:30.low
root@xxxxxxxx:/etc/sysconfig/htb# cat eth0
DEFAULT=30
R2Q=10
root@xxxxxxxx:/etc/sysconfig/htb# cat eth0-2.root
# root class for outgoing traffic
RATE=450Kbit
#BURST=15k
LEAF=sfq
root@xxxxxxxx:/etc/sysconfig/htb# cat eth0-2\:10.high
# class for outgoing high priority traffic
RATE=150Kbit
CEIL=prate
#BURST=15k
LEAF=sfq
# HTTP
RULE=*:80,
# SSH
RULE=*:22,
# TELNET
RULE=*:23,
# SMTP
RULE=*:25,
# DNS
RULE=*:53,
# POP3
RULE=*:110,
root@xxxxxxxx:/etc/sysconfig/htb# cat eth0-2\:20.normal
# class for outgoing normal traffic
RATE=150Kbit
CEIL=prate
# BURST=15k
LEAF=sfq
# IRC
RULE=*:6667,
root@xxxxxxxx:/etc/sysconfig/htb# cat eth0-2\:30.low
# class for low priority traffic
RATE=150Kbit
CEIL=prate
# BURST=15k
LEAF=sfq
# EMULE
RULE=*:3000,
RULE=*:3010,
RULE=*:4662,
RULE=*:3000
RULE=*:3010
RULE=*:4662
--------------------/-------------------
tc qdisc del dev eth0 root
tc qdisc add dev eth0 root handle 1 htb default 30 r2q 10
tc qdisc del dev eth1 root
tc qdisc add dev eth1 root handle 1 htb default 30 r2q 1
tc class add dev eth0 parent 1: classid 1:2 htb rate 450Kbit
tc qdisc add dev eth0 parent 1:2 handle 2 sfq perturb 10
tc class add dev eth0 parent 1:2 classid 1:10 htb rate 150Kbit ceil 450Kbit
tc qdisc add dev eth0 parent 1:10 handle 10 sfq perturb 10
tc filter add dev eth0 parent 1:0 protocol ip prio 100 u32 match ip sport 80 0xffff classid 1:10
tc filter add dev eth0 parent 1:0 protocol ip prio 100 u32 match ip sport 22 0xffff classid 1:10
tc filter add dev eth0 parent 1:0 protocol ip prio 100 u32 match ip sport 23 0xffff classid 1:10
tc filter add dev eth0 parent 1:0 protocol ip prio 100 u32 match ip sport 25 0xffff classid 1:10
tc filter add dev eth0 parent 1:0 protocol ip prio 100 u32 match ip sport 53 0xffff classid 1:10
tc filter add dev eth0 parent 1:0 protocol ip prio 100 u32 match ip sport 110 0xffff classid 1:10
tc class add dev eth0 parent 1:2 classid 1:20 htb rate 150Kbit ceil 450Kbit
tc qdisc add dev eth0 parent 1:20 handle 20 sfq perturb 10
tc filter add dev eth0 parent 1:0 protocol ip prio 100 u32 match ip sport 6667 0xffff classid 1:20
tc class add dev eth0 parent 1:2 classid 1:30 htb rate 150Kbit ceil 450Kbit
tc qdisc add dev eth0 parent 1:30 handle 30 sfq perturb 10
tc filter add dev eth0 parent 1:0 protocol ip prio 100 u32 match ip sport 3000 0xffff classid 1:30
tc filter add dev eth0 parent 1:0 protocol ip prio 100 u32 match ip sport 3010 0xffff classid 1:30
tc filter add dev eth0 parent 1:0 protocol ip prio 100 u32 match ip sport 4662 0xffff classid 1:30
tc filter add dev eth0 parent 1:0 protocol ip prio 100 u32 match ip dport 3000 0xffff classid 1:30
tc filter add dev eth0 parent 1:0 protocol ip prio 100 u32 match ip dport 3010 0xffff classid 1:30
tc filter add dev eth0 parent 1:0 protocol ip prio 100 u32 match ip dport 4662 0xffff classid 1:30
tc class add dev eth1 parent 1: classid 1:2 htb rate 90Kbit
tc qdisc add dev eth1 parent 1:2 handle 2 sfq perturb 10
tc class add dev eth1 parent 1:2 classid 1:10 htb rate 30Kbit ceil 90Kbit
tc qdisc add dev eth1 parent 1:10 handle 10 sfq perturb 10
tc filter add dev eth1 parent 1:0 protocol ip prio 100 u32 match ip dport 80 0xffff classid 1:10
tc filter add dev eth1 parent 1:0 protocol ip prio 100 u32 match ip dport 22 0xffff classid 1:10
tc filter add dev eth1 parent 1:0 protocol ip prio 100 u32 match ip dport 23 0xffff classid 1:10
tc filter add dev eth1 parent 1:0 protocol ip prio 100 u32 match ip dport 25 0xffff classid 1:10
tc filter add dev eth1 parent 1:0 protocol ip prio 100 u32 match ip dport 53 0xffff classid 1:10
tc filter add dev eth1 parent 1:0 protocol ip prio 100 u32 match ip dport 110 0xffff classid 1:10
tc class add dev eth1 parent 1:2 classid 1:20 htb rate 30Kbit ceil 90Kbit
tc qdisc add dev eth1 parent 1:20 handle 20 sfq perturb 10
tc filter add dev eth1 parent 1:0 protocol ip prio 100 u32 match ip dport 6667 0xffff classid 1:20
tc class add dev eth1 parent 1:2 classid 1:30 htb rate 20Kbit ceil 90Kbit
tc qdisc add dev eth1 parent 1:30 handle 30 sfq perturb 10
tc filter add dev eth1 parent 1:0 protocol ip prio 100 u32 match ip dport 3000 0xffff classid 1:30
tc filter add dev eth1 parent 1:0 protocol ip prio 100 u32 match ip sport 3000 0xffff classid 1:30
tc filter add dev eth1 parent 1:0 protocol ip prio 100 u32 match ip dport 3010 0xffff classid 1:30
tc filter add dev eth1 parent 1:0 protocol ip prio 100 u32 match ip sport 3010 0xffff classid 1:30
tc filter add dev eth1 parent 1:0 protocol ip prio 100 u32 match ip dport 4662 0xffff classid 1:30
tc filter add dev eth1 parent 1:0 protocol ip prio 100 u32 match ip sport 4662 0xffff classid 1:30
### eth0: queueing disciplines
qdisc sfq 30: quantum 1514b perturb 10sec
qdisc sfq 20: quantum 1514b perturb 10sec
qdisc sfq 10: quantum 1514b perturb 10sec
qdisc htb 1: r2q 10 default 30 direct_packets_stat 79
### eth0: traffic classes
class htb 1:10 parent 1:2 leaf 10: prio 0 rate 150Kbit ceil 450Kbit burst 1791b cburst 2175b
class htb 1:2 root rate 450Kbit ceil 450Kbit burst 2175b cburst 2175b
class htb 1:20 parent 1:2 leaf 20: prio 0 rate 150Kbit ceil 450Kbit burst 1791b cburst 2175b
class htb 1:30 parent 1:2 leaf 30: prio 0 rate 150Kbit ceil 450Kbit burst 1791b cburst 2175b
### eth0: filtering rules
filter parent 1: protocol ip pref 100 u32
filter parent 1: protocol ip pref 100 u32 fh 800: ht divisor 1
filter parent 1: protocol ip pref 100 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:10
match 00500000/ffff0000 at 20
filter parent 1: protocol ip pref 100 u32 fh 800::801 order 2049 key ht 800 bkt 0 flowid 1:10
match 00160000/ffff0000 at 20
filter parent 1: protocol ip pref 100 u32 fh 800::802 order 2050 key ht 800 bkt 0 flowid 1:10
match 00170000/ffff0000 at 20
filter parent 1: protocol ip pref 100 u32 fh 800::803 order 2051 key ht 800 bkt 0 flowid 1:10
match 00190000/ffff0000 at 20
filter parent 1: protocol ip pref 100 u32 fh 800::804 order 2052 key ht 800 bkt 0 flowid 1:10
match 00350000/ffff0000 at 20
filter parent 1: protocol ip pref 100 u32 fh 800::805 order 2053 key ht 800 bkt 0 flowid 1:10
match 006e0000/ffff0000 at 20
filter parent 1: protocol ip pref 100 u32 fh 800::806 order 2054 key ht 800 bkt 0 flowid 1:20
match 1a0b0000/ffff0000 at 20
filter parent 1: protocol ip pref 100 u32 fh 800::807 order 2055 key ht 800 bkt 0 flowid 1:30
match 0bb80000/ffff0000 at 20
filter parent 1: protocol ip pref 100 u32 fh 800::808 order 2056 key ht 800 bkt 0 flowid 1:30
match 0bc20000/ffff0000 at 20
filter parent 1: protocol ip pref 100 u32 fh 800::809 order 2057 key ht 800 bkt 0 flowid 1:30
match 12360000/ffff0000 at 20
filter parent 1: protocol ip pref 100 u32 fh 800::80a order 2058 key ht 800 bkt 0 flowid 1:30
match 00000bb8/0000ffff at 20
filter parent 1: protocol ip pref 100 u32 fh 800::80b order 2059 key ht 800 bkt 0 flowid 1:30
match 00000bc2/0000ffff at 20
filter parent 1: protocol ip pref 100 u32 fh 800::80c order 2060 key ht 800 bkt 0 flowid 1:30
match 00001236/0000ffff at 20
### eth1: queueing disciplines
qdisc sfq 30: quantum 1514b perturb 10sec
qdisc sfq 20: quantum 1514b perturb 10sec
qdisc sfq 10: quantum 1514b perturb 10sec
qdisc htb 1: r2q 1 default 30 direct_packets_stat 100
### eth1: traffic classes
class htb 1:10 parent 1:2 leaf 10: prio 0 rate 30Kbit ceil 90Kbit burst 1637b cburst 1714b
class htb 1:2 root rate 90Kbit ceil 90Kbit burst 1714b cburst 1714b
class htb 1:20 parent 1:2 leaf 20: prio 0 rate 30Kbit ceil 90Kbit burst 1637b cburst 1714b
class htb 1:30 parent 1:2 leaf 30: prio 0 rate 20Kbit ceil 90Kbit burst 1624b cburst 1714b
### eth1: filtering rules
filter parent 1: protocol ip pref 100 u32
filter parent 1: protocol ip pref 100 u32 fh 800: ht divisor 1
filter parent 1: protocol ip pref 100 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:10
match 00000050/0000ffff at 20
filter parent 1: protocol ip pref 100 u32 fh 800::801 order 2049 key ht 800 bkt 0 flowid 1:10
match 00000016/0000ffff at 20
filter parent 1: protocol ip pref 100 u32 fh 800::802 order 2050 key ht 800 bkt 0 flowid 1:10
match 00000017/0000ffff at 20
filter parent 1: protocol ip pref 100 u32 fh 800::803 order 2051 key ht 800 bkt 0 flowid 1:10
match 00000019/0000ffff at 20
filter parent 1: protocol ip pref 100 u32 fh 800::804 order 2052 key ht 800 bkt 0 flowid 1:10
match 00000035/0000ffff at 20
filter parent 1: protocol ip pref 100 u32 fh 800::805 order 2053 key ht 800 bkt 0 flowid 1:10
match 0000006e/0000ffff at 20
filter parent 1: protocol ip pref 100 u32 fh 800::806 order 2054 key ht 800 bkt 0 flowid 1:20
match 00001a0b/0000ffff at 20
filter parent 1: protocol ip pref 100 u32 fh 800::807 order 2055 key ht 800 bkt 0 flowid 1:30
match 00000bb8/0000ffff at 20
filter parent 1: protocol ip pref 100 u32 fh 800::808 order 2056 key ht 800 bkt 0 flowid 1:30
match 0bb80000/ffff0000 at 20
filter parent 1: protocol ip pref 100 u32 fh 800::809 order 2057 key ht 800 bkt 0 flowid 1:30
match 00000bc2/0000ffff at 20
filter parent 1: protocol ip pref 100 u32 fh 800::80a order 2058 key ht 800 bkt 0 flowid 1:30
match 0bc20000/ffff0000 at 20
filter parent 1: protocol ip pref 100 u32 fh 800::80b order 2059 key ht 800 bkt 0 flowid 1:30
match 00001236/0000ffff at 20
filter parent 1: protocol ip pref 100 u32 fh 800::80c order 2060 key ht 800 bkt 0 flowid 1:30
match 12360000/ffff0000 at 20
### eth0: queueing disciplines
qdisc sfq 30: quantum 1514b perturb 10sec
Sent 217128823 bytes 400593 pkts (dropped 0, overlimits 0)
qdisc sfq 20: quantum 1514b perturb 10sec
Sent 402075 bytes 2659 pkts (dropped 0, overlimits 0)
qdisc sfq 10: quantum 1514b perturb 10sec
Sent 38096835 bytes 39328 pkts (dropped 0, overlimits 0)
qdisc htb 1: r2q 10 default 30 direct_packets_stat 79
Sent 255653075 bytes 442662 pkts (dropped 0, overlimits 9189)
### eth0: traffic classes
class htb 1:10 parent 1:2 leaf 10: prio 0 rate 150Kbit ceil 450Kbit burst 1791b cburst 2175b
Sent 38099783 bytes 39330 pkts (dropped 0, overlimits 0)
rate 18962bps 20pps
lended: 33297 borrowed: 6033 giants: 0
tokens: -32766 ctokens: 5462
class htb 1:2 root rate 450Kbit ceil 450Kbit burst 2175b cburst 2175b
Sent 255639226 bytes 442610 pkts (dropped 0, overlimits 0)
rate 53115bps 94pps
lended: 224141 borrowed: 0 giants: 0
tokens: -19522 ctokens: -19522
class htb 1:20 parent 1:2 leaf 20: prio 0 rate 150Kbit ceil 450Kbit burst 1791b cburst 2175b
Sent 402075 bytes 2659 pkts (dropped 0, overlimits 0)
rate 59bps
lended: 2659 borrowed: 0 giants: 0
tokens: 70656 ctokens: 29012
class htb 1:30 parent 1:2 leaf 30: prio 0 rate 150Kbit ceil 450Kbit burst 1791b cburst 2175b
Sent 217137368 bytes 400621 pkts (dropped 0, overlimits 0)
rate 33973bps 72pps
lended: 182513 borrowed: 218108 giants: 0
tokens: -54574 ctokens: 344
### eth0: filtering rules
filter parent 1: protocol ip pref 100 u32
filter parent 1: protocol ip pref 100 u32 fh 800: ht divisor 1
filter parent 1: protocol ip pref 100 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:10
match 00500000/ffff0000 at 20
filter parent 1: protocol ip pref 100 u32 fh 800::801 order 2049 key ht 800 bkt 0 flowid 1:10
match 00160000/ffff0000 at 20
filter parent 1: protocol ip pref 100 u32 fh 800::802 order 2050 key ht 800 bkt 0 flowid 1:10
match 00170000/ffff0000 at 20
filter parent 1: protocol ip pref 100 u32 fh 800::803 order 2051 key ht 800 bkt 0 flowid 1:10
match 00190000/ffff0000 at 20
filter parent 1: protocol ip pref 100 u32 fh 800::804 order 2052 key ht 800 bkt 0 flowid 1:10
match 00350000/ffff0000 at 20
filter parent 1: protocol ip pref 100 u32 fh 800::805 order 2053 key ht 800 bkt 0 flowid 1:10
match 006e0000/ffff0000 at 20
filter parent 1: protocol ip pref 100 u32 fh 800::806 order 2054 key ht 800 bkt 0 flowid 1:20
match 1a0b0000/ffff0000 at 20
filter parent 1: protocol ip pref 100 u32 fh 800::807 order 2055 key ht 800 bkt 0 flowid 1:30
match 0bb80000/ffff0000 at 20
filter parent 1: protocol ip pref 100 u32 fh 800::808 order 2056 key ht 800 bkt 0 flowid 1:30
match 0bc20000/ffff0000 at 20
filter parent 1: protocol ip pref 100 u32 fh 800::809 order 2057 key ht 800 bkt 0 flowid 1:30
match 12360000/ffff0000 at 20
filter parent 1: protocol ip pref 100 u32 fh 800::80a order 2058 key ht 800 bkt 0 flowid 1:30
match 00000bb8/0000ffff at 20
filter parent 1: protocol ip pref 100 u32 fh 800::80b order 2059 key ht 800 bkt 0 flowid 1:30
match 00000bc2/0000ffff at 20
filter parent 1: protocol ip pref 100 u32 fh 800::80c order 2060 key ht 800 bkt 0 flowid 1:30
match 00001236/0000ffff at 20
### eth1: queueing disciplines
qdisc sfq 30: quantum 1514b perturb 10sec
Sent 57345159 bytes 382332 pkts (dropped 17828, overlimits 0)
backlog 71p
qdisc sfq 20: quantum 1514b perturb 10sec
Sent 193238 bytes 3292 pkts (dropped 0, overlimits 0)
qdisc sfq 10: quantum 1514b perturb 10sec
Sent 8872705 bytes 27808 pkts (dropped 0, overlimits 0)
qdisc htb 1: r2q 1 default 30 direct_packets_stat 100
Sent 66429758 bytes 413534 pkts (dropped 17828, overlimits 435709)
backlog 71p
### eth1: traffic classes
class htb 1:10 parent 1:2 leaf 10: prio 0 rate 30Kbit ceil 90Kbit burst 1637b cburst 1714b
Sent 8872771 bytes 27809 pkts (dropped 0, overlimits 0)
rate 5001bps 11pps
lended: 22409 borrowed: 5400 giants: 0
tokens: 335787 ctokens: 117405
class htb 1:2 root rate 90Kbit ceil 90Kbit burst 1714b cburst 1714b
Sent 66217756 bytes 413399 pkts (dropped 0, overlimits 0)
rate 11693bps 71pps
lended: 277237 borrowed: 0 giants: 0
tokens: -30821 ctokens: -30821
class htb 1:20 parent 1:2 leaf 20: prio 0 rate 30Kbit ceil 90Kbit burst 1637b cburst 1714b
Sent 193238 bytes 3292 pkts (dropped 0, overlimits 0)
rate 34bps
lended: 3292 borrowed: 0 giants: 0
tokens: 339199 ctokens: 118543
class htb 1:30 parent 1:2 leaf 30: prio 0 rate 20Kbit ceil 90Kbit burst 1624b cburst 1714b
Sent 57346186 bytes 382348 pkts (dropped 17828, overlimits 0)
rate 6496bps 58pps backlog 50p
lended: 110461 borrowed: 271837 giants: 0
tokens: -152254 ctokens: -7707
### eth1: filtering rules
filter parent 1: protocol ip pref 100 u32
filter parent 1: protocol ip pref 100 u32 fh 800: ht divisor 1
filter parent 1: protocol ip pref 100 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:10
match 00000050/0000ffff at 20
filter parent 1: protocol ip pref 100 u32 fh 800::801 order 2049 key ht 800 bkt 0 flowid 1:10
match 00000016/0000ffff at 20
filter parent 1: protocol ip pref 100 u32 fh 800::802 order 2050 key ht 800 bkt 0 flowid 1:10
match 00000017/0000ffff at 20
filter parent 1: protocol ip pref 100 u32 fh 800::803 order 2051 key ht 800 bkt 0 flowid 1:10
match 00000019/0000ffff at 20
filter parent 1: protocol ip pref 100 u32 fh 800::804 order 2052 key ht 800 bkt 0 flowid 1:10
match 00000035/0000ffff at 20
filter parent 1: protocol ip pref 100 u32 fh 800::805 order 2053 key ht 800 bkt 0 flowid 1:10
match 0000006e/0000ffff at 20
filter parent 1: protocol ip pref 100 u32 fh 800::806 order 2054 key ht 800 bkt 0 flowid 1:20
match 00001a0b/0000ffff at 20
filter parent 1: protocol ip pref 100 u32 fh 800::807 order 2055 key ht 800 bkt 0 flowid 1:30
match 00000bb8/0000ffff at 20
filter parent 1: protocol ip pref 100 u32 fh 800::808 order 2056 key ht 800 bkt 0 flowid 1:30
match 0bb80000/ffff0000 at 20
filter parent 1: protocol ip pref 100 u32 fh 800::809 order 2057 key ht 800 bkt 0 flowid 1:30
match 00000bc2/0000ffff at 20
filter parent 1: protocol ip pref 100 u32 fh 800::80a order 2058 key ht 800 bkt 0 flowid 1:30
match 0bc20000/ffff0000 at 20
filter parent 1: protocol ip pref 100 u32 fh 800::80b order 2059 key ht 800 bkt 0 flowid 1:30
match 00001236/0000ffff at 20
filter parent 1: protocol ip pref 100 u32 fh 800::80c order 2060 key ht 800 bkt 0 flowid 1:30
match 12360000/ffff0000 at 20