Skip to contentSkip to conversation

Qos wiht HTB for ADSL/Home

LARTC ddaas 2 participants 3 messages Jul 30, 2005

lore
Share & tools
lore

ddaas

author
#0 lore raw

Hi,
My home setup is as following:
- 1024/128 kbit ADSL
- FC3

I set up HTB to prioritize traffic. I am not very pleased with the obtained results.

The scope of my setup is to have some ssh sessions with remote servers while browsing websites and running aMule Nothing complicated (I think... ;).

The very high priority traffic (ssh), gets stuck when I start aMule and make an FTP download. Although there is an improvement.
High priority (WEB) traffic has some delay when I have a lot of bulk traffic (aMule, FTP). It waits a few seconds for DNS lookup, and other synchronizations and then in a blink of the eye the whole page appears. I think that this means that the queue is still to long.

So, I have some questions:

1) Do I need to use ppp0 or eth0 for shaping traffic?
2) Are the default values for quantum, burst, cburst acceptable or should I tune these values?
3) I've seen in some tutorials that decreasing the queue (as I know it is 100 in Linux as the default) with #ip link set dev eth0 qlen, they have been obtained better results. Should I try to decrease the queue? To what value?
3) The same with mtu. A less value (ex 1000) should be better?
4) If your are in my situation (ADSL – for home), what is your htb configuration?
5)Does it worth configuring policing for inbound traffic (with imq)? 6)So, am I on the right way with my script or should I change it fundamental?

In my setup I have 3 categories of traffic:

1)very high priority traffic: ssh, DNS, ACK, SYN+ACK, RST, FIN+ACK (40kbit > CEIL)
2) high priority traffic: web, online radio, online tv (72kbit->CEIL) 3)low priority traffic - default class: aMule, P2P, other type of traffic(8Kbit->CEIl)

THANKS,
ddaas

My htb script is:

#!/bin/bash

YAHOOMSG="216.155.193.0/24"
RADIO="xxx.xxx.xxx.xxx"
TRI="xxx.dnsalias.net"
TV="xxx.xxx.xxx.xxx"
DNSSERVER="217.237.150.225"

IF="ppp0"
CEIL="120"

#flush everything
tc qdisc del dev $IF root
iptables -F OUTPUT -t mangle

#root qdisc
tc qdisc add dev $IF root handle 1: htb default 12

#class 1:1 attached to root qdisc
tc class add dev $IF parent 1: classid 1:1 htb rate ${CEIL}kbit ceil ${CEIL}kbit

#class 1:10 -> 40kbit-CEIL for ACK,SSH
tc class add dev $IF parent 1:1 classid 1:10 htb rate 40kbit ceil ${CEIL}kbit prio 1

#class 1:11 (web,radio,tv)
tc class add dev $IF parent 1:1 classid 1:11 htb rate 72kbit ceil ${CEIL}kbit prio 2

#default class 1:12 for bulk traffic (aMule, ftp)
tc class add dev $IF parent 1:1 classid 1:12 htb rate 8kbit ceil ${CEIL}kbit prio 5

#mark ack,syn ack,rst,fin, ssh packets and add them to class 1:10 (high prioroty)
iptables -A OUTPUT -t mangle -o $IF -p tcp --sport 22 -j MARK --set-mark 1 iptables -A OUTPUT -t mangle -o $IF -p tcp --sport 22 -j RETURN

iptables -A OUTPUT -t mangle -o $IF -p tcp --dport 22 -j MARK --set-mark 1 iptables -A OUTPUT -t mangle -o $IF -p tcp --dport 22 -j RETURN

iptables -A OUTPUT -t mangle -o $IF -p tcp --tcp-flags SYN,RST,ACK SYN,FIN -j MARK --set-mark 1
iptables -A OUTPUT -t mangle -o $IF -p tcp --tcp-flags SYN,RST,ACK SYN,FIN -j RETURN

#mark dns packets
iptables -A OUTPUT -t mangle -o $IF -d $DNSSERVER -j MARK --set-mark 1 iptables -A OUTPUT -t mangle -o $IF -d $DNSSERVER -j RETURN

tc filter add dev $IF parent 1: protocol ip handle 1 fw classid 1:10

#mark www,radio,tv,tri,yahoomsg
iptables -A OUTPUT -t mangle -o $IF -p tcp -m multiport --dports 80,443 -j MARK --set-mark 2
iptables -A OUTPUT -t mangle -o $IF -d $RADIO -p tcp --dport 8000 -j MARK --set-mark 2
iptables -A OUTPUT -t mangle -o $IF -d $YAHOOMSG -p tcp --dport 5050 -j MARK --set-mark 2
iptables -A OUTPUT -t mangle -o $IF -d $TV -p tcp -m multiport --dports 554,6970 -j MARK --set-mark 2
iptables -A OUTPUT -t mangle -o $IF -d $TRI -j MARK --set-mark 2 tc filter add dev $IF parent 1: protocol ip handle 2 fw classid 1:11

#other type of traffic in default class 1:12

tc qdisc add dev $IF parent 1:10 handle 100: sfq perturb 10 tc qdisc add dev $IF parent 1:11 handle 110: sfq perturb 10 tc qdisc add dev $IF parent 1:12 handle 120: sfq perturb 10

##INGRESS - drop everithing over 1000kbit
tc qdisc del dev $IF ingress

tc qdisc add dev $IF handle ffff: ingress
tc filter add dev $IF parent ffff: protocol ip prio 10 u32 match \
ip src 0.0.0.0/0 police rate 1000kbit burst 80kbit drop flowid :1
_______________________________________________
LARTC mailing list
[email protected]
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc

author
#1 lore raw

I've forgotten something. After a period of all type of traffic (very high priority, high priority, low priority) the redistribution of the traffic doesn't look ok.
The 1:11 class (high priority) didn't borrow a byte but the low priority class (1:12) borrowed a lot.

I get with tc -s class show dev ppp0:

class htb 1:11 parent 1:1 leaf 110: prio 2 rate 72Kbit ceil 100Kbit burst 1608b cburst 1611b
Sent 659962 bytes 12307 pkts (dropped 0, overlimits 0 requeues 0) rate 1703bit 32pps
lended: 12307 borrowed: 0 giants: 0
tokens: 177607 ctokens: 128123

class htb 1:1 root rate 100Kbit ceil 100Kbit burst 1611b cburst 1611b
Sent 6398190 bytes 29624 pkts (dropped 0, overlimits 0 requeues 0) rate 11456bit 68pps
lended: 15414 borrowed: 0 giants: 0
tokens: -151656 ctokens: -151656

class htb 1:10 parent 1:1 leaf 100: prio 1 rate 40Kbit ceil 100Kbit burst 1604b cburst 1611b
Sent 1477 bytes 23 pkts (dropped 0, overlimits 0 requeues 0)
lended: 23 borrowed: 0 giants: 0
tokens: 317236 ctokens: 127468

class htb 1:12 parent 1:1 leaf 120: prio 5 rate 8Kbit ceil 100Kbit burst 1600b cburst 1611b
Sent 5737669 bytes 17311 pkts (dropped 0, overlimits 0 requeues 0) rate 10165bit 34pps backlog 17p
lended: 1880 borrowed: 15414 giants: 0
tokens: -1945424 ctokens: -105185

_______________________________________________
LARTC mailing list
[email protected]
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc

#2 lore raw
In reply to ddaas
Quoted 2 lines · ddaas

4) If your are in my situation (ADSL – for home), what is your htb configuration?

http://www.metamorpher.de/fairnat/

It's for a Linux gateway/router and more than one user though. HTB is used to divide bandwidth between users, and PRIO for prioritization of different traffic types per user. There's also another setup that uses HTB only (Wondershaper style), but I never really used that one myself.

I've tried my best to make the script easy to understand, with documentation for each function and such. Quite a few people who didn't use this script directly still found it useful as an example.

There are still a lot of things that need improvements, naturally. Unfortunately, I'll move out of the flat I was living in soon, due to switching Universities. And my new home won't have a shared DSL line anymore, so I will no longer have the means to further develop and test the script.

Quoted 1 line

5)Does it worth configuring policing for inbound traffic (with imq)?

In my case, yes, it was. Not only worth it, but absolutely necessary.

HTH
Andreas
_______________________________________________
LARTC mailing list
[email protected]
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc