Skip to contentSkip to conversation

Need help with HTB

LARTC Mihai Tanasescu 3 participants 5 messages Oct 27, 2003 – Oct 29, 2003

lore
Share & tools
lore
#0 lore raw

Hello,

1.

I currently have a 128kbps cable link to the internet..and I'm sharing this connection with others.
I've made the following script(for alocating bandwidth depending on the services used: browsing, squid, games like counter-strike, icmp, ssh), which unfortunately isn't working very well as the response times I'm getting upon pinging the server are almost the same I get without the htb script being loaded.
Any ideas ?

Here goes my script:
where eth1 = the internal network card
eth0 = the link to my ISP

ipt="/sbin/iptables"
tc="/sbin/tc"
IF_EXT=eth0
IF_LOC=eth1

########################################################################
#####
$tc qdisc del dev $IF_EXT root
$tc qdisc add dev $IF_EXT handle 1: root htb default 99 r2q 1 $tc class add dev $IF_EXT parent 1: classid 1:1 htb rate 100kbit $tc class add dev $IF_EXT parent 1:1 classid 1:2 htb rate 20kbit ceil 20kbit prio 1
$tc class add dev $IF_EXT parent 1:1 classid 1:3 htb rate 60kbit ceil 90kbit prio 3
$tc class add dev $IF_EXT parent 1:1 classid 1:99 htb rate 20kbit ceil 90kbit prio 7

//I'm letting 1:2 use FIFO...for low-latency
$tc qdisc add dev $IF_EXT parent 1:3 handle 30: sfq perturb 10 $tc qdisc add dev $IF_EXT parent 1:99 handle 990: sfq perturb 10

# ICMP

 $tc filter add dev $IF_EXT protocol ip prio 1 parent 1: u32 \
         match ip protocol 1 0xff flowid 1:2

#Counter-strike

 $tc filter add dev $IF_EXT protocol ip prio 1 parent 1: u32 \
         match ip dport 27015 0xffff flowid 1:3
 $tc filter add dev $IF_EXT protocol ip prio 1 parent 1: u32 \
         match ip dport 28015 0xffff flowid 1:3

# TOS Minimum Delay (ssh, NOT scp) in 1:10:

 $tc filter add dev $IF_EXT protocol ip prio 2 parent 1: u32 \
       match ip tos 0x10 0xff  flowid 1:3

######################################
#acks

 $tc filter add dev $IF_EXT parent 1: protocol ip prio 2 u32 \
    match ip protocol 6 0xff \
    match u8 0x05 0x0f at 0 \
    match u16 0x0000 0xffc0 at 2 \
    match u8 0x10 0xff at 33 \
    flowid 1:3
 #dns query-uri
 $tc filter add dev $IF_EXT protocol ip prio 2 parent 1: u32 \
         match ip dport 53 0xffff flowid 1:3

#############################################

 # other services - web + irc
 $tc filter add dev $IF_EXT parent 1: protocol ip prio 2 u32 \
         match ip dport 80 0xffff flowid 1:3
 $tc filter add dev $IF_EXT parent 1: protocol ip prio 2 u32 \
         match ip dport 6667 0xffff flowid 1:3
 #############################################
 # All others go to 1:99
 $tc filter add dev $IF_EXT protocol ip prio 2 parent 1: u32 \
        match ip dst 0.0.0.0/0 flowid 1:99

########################################################################
##################

and for download I have the following:

$tc qdisc del dev $IF_LOC root
$tc qdisc add dev $IF_LOC handle 2: root htb default 99 r2q 1 $tc class add dev $IF_LOC parent 2: classid 2:1 htb rate 100kbit

$tc class add dev $IF_LOC parent 2:1 classid 2:2 htb rate 70kbit ceil 90kbit prio 1
$tc class add dev $IF_LOC parent 2:1 classid 2:99 htb rate 30kbit ceil 90kbit prio 5

#PRIO FIFO...for 2:2 = low latency for counter-strike packets $tc qdisc add dev $IF_LOC parent 2:99 handle 299: sfq perturb 10

#Counter-strike

 $tc filter add dev $IF_LOC protocol ip prio 1 parent 2: u32 \
         match ip dport 27005 0xffff flowid 2:2
 #WEB
 $tc filter add dev $IF_LOC protocol ip prio 1 parent 2: u32 \
         match ip sport 80 0xffff flowid 2:2
 #SQUID
 $tc filter add dev $IF_LOC protocol ip prio 1 parent 2: u32 \
         match ip sport 3128 0xffff flowid 2:2

# Restu

 $tc filter add dev $IF_LOC protocol ip prio 1 parent 2: u32 \
        match ip dst 0.0.0.0/0 flowid 2:99

pinging the server without htb script loaded:

 [[email protected]]$ ping -c 5 ip
 PING ip(ip) from .....: 56(84) bytes of data.
 64 bytes from ip: icmp_seq=1 ttl` time”.0 ms
 64 bytes from ip: icmp_seq=2 ttl` timeA.3 ms
 64 bytes from ip: icmp_seq=3 ttl` time.4 ms
 64 bytes from ip: icmp_seq=4 ttl` time%.5 ms
 64 bytes from ip: icmp_seq=5 ttl` time.1 ms

--- ip ping statistics ---
5 packets transmitted, 5 received, 0% loss, time 4036ms rtt min/avg/max/mdev = 10.454/37.105/94.057/30.443 ms

pinging the server with htb script loaded:

[mihai@.. mihai]$ ping -c 5 ip_addr
PING ip(ip) from ...: 56(84) bytes of data.
64 bytes from ip: icmp_seq=1 ttl` time1.1 ms
64 bytes from ip: icmp_seq=2 ttl` time.8 ms
64 bytes from ip: icmp_seq=3 ttl` time8.5 ms
64 bytes from ip: icmp_seq=4 ttl` time”.8 ms
64 bytes from ip: icmp_seq=5 ttl` time1.5 ms

--- ip ping statistics ---
5 packets transmitted, 5 received, 0% loss, time 4041ms rtt min/avg/max/mdev = 11.839/41.584/94.829/28.064 ms

and tc -s qdisc shows:
tc -s qdisc
qdisc sfq 990: dev eth0 quantum 1514b perturb 10sec
Sent 7574 bytes 75 pkts (dropped 0, overlimits 0)

qdisc sfq 30: dev eth0 quantum 1514b perturb 10sec Sent 123614 bytes 1413 pkts (dropped 0, overlimits 0)

qdisc htb 1: dev eth0 r2q 1 default 99 direct_packets_stat 0 Sent 149780 bytes 1678 pkts (dropped 87, overlimits 0)

qdisc sfq 299: dev eth1 quantum 1514b perturb 10sec Sent 824005 bytes 1000 pkts (dropped 0, overlimits 0) backlog 3p

qdisc htb 2: dev eth1 r2q 1 default 99 direct_packets_stat 2 Sent 1055635 bytes 1398 pkts (dropped 0, overlimits 2046)

2.

I have the same problem with a htb script on an adsl connection (with the htb script I get ping response times of 80-90..without it I get 200-300 ms...but these response times aren't very stable..it's
something
like I'm getting 40 ms..then 100 ms..then 50 ms..)

Sorry about the size of this message.

Hope you can help,
Mihai Tanasescu

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

#1 lore raw
Quoted 11 lines · Mihai Tanasescu

I currently have a 128kbps cable link to the internet..and I'm sharing this connection with others.
I've made the following script(for alocating bandwidth depending on the services used: browsing, squid, games like counter-strike, icmp, ssh), which unfortunately isn't working very well as the response times I'm getting upon pinging the server are almost the same I get without the htb script being loaded.
Any ideas ?

2.

Quoted 7 lines

I have the same problem with a htb script on an adsl connection (with the htb script I get ping response times of 80-90..without it I get 200-300 ms...but these response times aren't very stable..it's
something
like I'm getting 40 ms..then 100 ms..then 50 ms..)

Sorry about the size of this message.

No problem.
I don't see a problem with your script, but can you also post the output of tc -s -d class show dev eth0. And for eth1?

Stef

Signature · 8 lines
[email protected]
 "Using Linux as bandwidth manager"
     http://www.docum.org/
     #lartc @ irc.openprojects.net

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

This is the output I get from tc -s -d class show dev eth0 and eth1:

serv:~# tc -s -d class show dev eth0

class htb 1:99 parent 1:1 leaf 990: prio 7 quantum 2560 rate 20Kbit ceil 90Kbit burst 1624b/8 mpu 0b cburst 1714b/8 mpu 0b level 0
Sent 4693480 bytes 28021 pkts (dropped 0, overlimits 0) rate 470bps 2pps
lended: 26883 borrowed: 1138 giants: 0
tokens: 502079 ctokens: 117973

class htb 1:1 root rate 100Kbit ceil 100Kbit burst 1727b/8 mpu 0b cburst 1727b/8 mpu 0b level 7
Sent 38956319 bytes 489172 pkts (dropped 0, overlimits 0) rate 1771bps 18pps
lended: 2994 borrowed: 0 giants: 0
tokens: 101376 ctokens: 101376

class htb 1:2 parent 1:1 prio 1 quantum 2560 rate 20Kbit ceil 20Kbit burst 1624b/8 mpu 0b cburst 1624b/8 mpu 0b level 0
Sent 33941 bytes 221 pkts (dropped 0, overlimits 0)
lended: 221 borrowed: 0 giants: 0
tokens: 333119 ctokens: 333119

class htb 1:3 parent 1:1 leaf 30: prio 3 quantum 7680 rate 60Kbit ceil 90Kbit burst 1675b/8 mpu 0b cburst 1714b/8 mpu 0b level 0
Sent 34228898 bytes 460930 pkts (dropped 0, overlimits 0) rate 1362bps 17pps
lended: 459074 borrowed: 1856 giants: 0
tokens: 163413 ctokens: 111717

serv:~# tc -s -d class show dev eth1

class htb 2:99 parent 2:1 leaf 299: prio 5 quantum 3840 rate 30Kbit ceil 90Kbit burst 1637b/8 mpu 0b cburst 1714b/8 mpu 0b level 0
Sent 109217144 bytes 335470 pkts (dropped 0, overlimits 0) rate 1927bps 13pps
lended: 277195 borrowed: 58275 giants: 0
tokens: 244309 ctokens: 103297

class htb 2:1 root rate 100Kbit ceil 100Kbit burst 1727b/8 mpu 0b cburst 1727b/8 mpu 0b level 7
Sent 172060944 bytes 480526 pkts (dropped 0, overlimits 0) rate 2186bps 14pps
lended: 68187 borrowed: 0 giants: 0
tokens: 96257 ctokens: 96257

class htb 2:2 parent 2:1 prio 1 quantum 8960 rate 70Kbit ceil 90Kbit burst 1688b/8 mpu 0b cburst 1714b/8 mpu 0b level 0
Sent 62843800 bytes 145056 pkts (dropped 18, overlimits 0) rate 259bps
lended: 135144 borrowed: 9912 giants: 0
tokens: 150034 ctokens: 118543

Quoted 2 lines · Mihai Tanasescu
Quoted 1 line

I currently have a 128kbps cable link to the internet..and I'm

sharing

Quoted 2 lines
Quoted 2 lines

this connection with others.
I've made the following script(for alocating bandwidth depending on

the

Quoted 1 line
Quoted 1 line

services used: browsing, squid, games like counter-strike, icmp,

ssh),

Quoted 1 line
Quoted 1 line

which unfortunately isn't working very well as the response times

I'm

Quoted 1 line
Quoted 1 line

getting upon pinging the server are almost the same I get without

the

Quoted 6 lines
Quoted 6 lines

htb script being loaded.
Any ideas ?

2.

I have the same problem with a htb script on an adsl connection

(with

Quoted 8 lines
Quoted 6 lines

the htb script I get ping response times of 80-90..without it I get 200-300 ms...but these response times aren't very stable..it's
something
like I'm getting 40 ms..then 100 ms..then 50 ms..)

Sorry about the size of this message.

No problem.
I don't see a problem with your script, but can you also post the

output of tc

Quoted 10 lines

-s -d class show dev eth0. And for eth1?

Stef

--
[email protected]
"Using Linux as bandwidth manager"
http://www.docum.org/
#lartc @ irc.openprojects.net

Quoted 4 lines

_______________________________________________
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/

#3 lore raw
In reply to Mihai Tanasescu
Quoted 48 lines · Mihai Tanasescu

This is the output I get from tc -s -d class show dev eth0 and eth1:

serv:~# tc -s -d class show dev eth0

class htb 1:99 parent 1:1 leaf 990: prio 7 quantum 2560 rate 20Kbit ceil 90Kbit burst 1624b/8 mpu 0b cburst 1714b/8 mpu 0b level 0
Sent 4693480 bytes 28021 pkts (dropped 0, overlimits 0) rate 470bps 2pps
lended: 26883 borrowed: 1138 giants: 0
tokens: 502079 ctokens: 117973

class htb 1:1 root rate 100Kbit ceil 100Kbit burst 1727b/8 mpu 0b cburst 1727b/8 mpu 0b level 7
Sent 38956319 bytes 489172 pkts (dropped 0, overlimits 0) rate 1771bps 18pps
lended: 2994 borrowed: 0 giants: 0
tokens: 101376 ctokens: 101376

class htb 1:2 parent 1:1 prio 1 quantum 2560 rate 20Kbit ceil 20Kbit burst 1624b/8 mpu 0b cburst 1624b/8 mpu 0b level 0
Sent 33941 bytes 221 pkts (dropped 0, overlimits 0)
lended: 221 borrowed: 0 giants: 0
tokens: 333119 ctokens: 333119

class htb 1:3 parent 1:1 leaf 30: prio 3 quantum 7680 rate 60Kbit ceil 90Kbit burst 1675b/8 mpu 0b cburst 1714b/8 mpu 0b level 0
Sent 34228898 bytes 460930 pkts (dropped 0, overlimits 0) rate 1362bps 17pps
lended: 459074 borrowed: 1856 giants: 0
tokens: 163413 ctokens: 111717

serv:~# tc -s -d class show dev eth1

class htb 2:99 parent 2:1 leaf 299: prio 5 quantum 3840 rate 30Kbit ceil 90Kbit burst 1637b/8 mpu 0b cburst 1714b/8 mpu 0b level 0
Sent 109217144 bytes 335470 pkts (dropped 0, overlimits 0) rate 1927bps 13pps
lended: 277195 borrowed: 58275 giants: 0
tokens: 244309 ctokens: 103297

class htb 2:1 root rate 100Kbit ceil 100Kbit burst 1727b/8 mpu 0b cburst 1727b/8 mpu 0b level 7
Sent 172060944 bytes 480526 pkts (dropped 0, overlimits 0) rate 2186bps 14pps
lended: 68187 borrowed: 0 giants: 0
tokens: 96257 ctokens: 96257

Quoted 6 lines

class htb 2:2 parent 2:1 prio 1 quantum 8960 rate 70Kbit ceil 90Kbit burst 1688b/8 mpu 0b cburst 1714b/8 mpu 0b level 0
Sent 62843800 bytes 145056 pkts (dropped 18, overlimits 0) rate 259bps
lended: 135144 borrowed: 9912 giants: 0
tokens: 150034 ctokens: 118543

I'm afraid it's not so easy to get better results. You allmost have no borrowed packets so none of your classes are over limited. And tokens/ctokens is never negative so you have tokens enough to send something.

Stef

Signature · 8 lines
[email protected]
 "Using Linux as bandwidth manager"
     http://www.docum.org/
     #lartc @ irc.openprojects.net

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
#4 lore raw
In reply to Mihai Tanasescu
Quoted 6 lines · Mihai Tanasescu

Hello,

1.

I currently have a 128kbps cable link to the internet..and I'm sharing this connection with others.

<snip>

Quoted 5 lines

I have the same problem with a htb script on an adsl connection (with the htb script I get ping response times of 80-90..without it I get 200-300 ms...but these response times aren't very stable..it's
something
like I'm getting 40 ms..then 100 ms..then 50 ms..)

I am a newbie and don't yet fully understand the HTB stuff, but have experimented with others scripts/programs and thought about QOS for latency - which is what I will be aiming for when my home network is eventually finished.

With an uplink of 128000 and MTU 1500 then you would expect this behavior as a 1500 byte packet will take >90ms to get up the wire. Reducing MTU should help, also quantum/burst should be small enough to release only one packet - I notice some big quantums in your other mail. I don't know about cable, but with dsl some MTUs are more efficient than others - which are best depends on whether your dsl uses pppoa or pppoe etc.

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