Re: ADSL traffic shaping to improve latency

Linux Advanced Routing and Traffic Control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Eye of the Beholder wrote:
Hello.

I have a 1024/256kbit ADSL and tried to shape outgoing traffic in order
to improve latency.

Here is my config.

UPLOAD_RATE="256"
UPRATE="$[4*$UPLOAD_RATE/5]" (a little smaller)

Depends on traffic - you may need to go smaller if there are lots of small packets, you can patch for dsl/atm overheads.

UP70="$[7*$UPRATE/10]kbit"
UP30="$[3*$UPRATE/10]kbit"
UP20="$[2*$UPRATE/10]kbit"
UPRATE="${UPRATE}kbit"

You should really make these add up to 100 not 120.


IF="eth2"
IPTABLES="iptables -t mangle -A POSTROUTING "

(Initialize)
tc qdisc del dev $IF root >& /dev/null
iptables -t mangle -F


(Root qdisc / class)
tc qdisc add dev $IF root handle 1: htb default 20

Your arp will go to default which is not nice.

tc class add dev $IF parent 1: classid 1:1 htb rate 100mbit

(class for lan traffic)
tc class add dev $IF parent 1:1 classid 1:100 htb rate 100mbit quantum 100000
(parent class for adsl traffic)
tc class add dev $IF parent 1:1 classid 1:3 htb rate $UPRATE (different classes)
tc class add dev $IF parent 1:3 classid 1:70 htb rate $UP70 ceil $UPRATE prio 1
tc class add dev $IF parent 1:3 classid 1:30 htb rate $UP30 ceil $UPRATE prio 2
quantum 1200
tc class add dev $IF parent 1:3 classid 1:20 htb rate $UP20 ceil $UPRATE prio 3
quantum 1200

(queues)
tc qdisc add dev $IF parent 1:100 handle 100: sfq perturb 10
tc qdisc add dev $IF parent 1:70 handle 70: sfq perturb 10
tc qdisc add dev $IF parent 1:30 handle 30: sfq perturb 10
tc qdisc add dev $IF parent 1:20 handle 20: sfq perturb 10

(filters)
tc filter add dev $IF parent 1:0 protocol ip handle 100 fw classid 1:100
tc filter add dev $IF parent 1:0 prio 1 protocol ip handle 7 fw classid 1:70
tc filter add dev $IF parent 1:0 prio 2 protocol ip handle 3 fw classid 1:30
tc filter add dev $IF parent 1:0 prio 3 protocol ip handle 2 fw classid 1:20

(Mark packets)

I would just -J RETURN for lan traffic here and not use htb defaut or the 100meg class/marking


(Interactive class (70%))
$IPTABLES -p icmp -j MARK --set-mark 7
$IPTABLES -p icmp -j RETURN
$IPTABLES -p tcp --dport 22 -j MARK --set-mark 7
$IPTABLES -p tcp --dport 22 -j RETURN
$IPTABLES -p tcp --dport 6667 -j MARK --set-mark 7
$IPTABLES -p tcp --dport 6667 -j RETURN
$IPTABLES -p tcp --dport 53 -j MARK --set-mark 7
$IPTABLES -p tcp --dport 53 -j RETURN
$IPTABLES -p udp --dport 53 -j MARK --set-mark 7
$IPTABLES -p udp --dport 53 -j RETURN

(30% Class)
$IPTABLES -p tcp -m multiport --dport 20,21,25,80,443,995 -j MARK
--set-mark 3 $IPTABLES -p tcp -m multiport --dport 20,21,25,80,443,995
-j RETURN

(Lan class)
$IPTABLES -d 192.168.1.0/24 -j MARK --set-mark 100
$IPTABLES -d 192.168.1.0/24 -j RETURN

(anything else)
$IPTABLES -j MARK --set-mark 2

(I changed the default "quantum" values because i got messages "HTB: quantum of class
10001 is big/small. Consider r2q change." but my tc didn't accept r2q as a parameter.)


The 100meg class should go and I would set quantum to 1514 on the remaining (1514 because a 1500 ip length packet is seen as 1514 on an eth interface)


I have tested that different packets get different marks (with iptables
-v -t mangle -L) and also that they go to the different classes (with tc -s -d class
show dev eth2) so i guess my rules are correct.

However, i put a large file to download in order to test and during the
download i get 1500-2500ms ping times.

This only shapes upload, shaping download is harder. I have written lots about this before - see archives.

Andy.
_______________________________________________
LARTC mailing list
LARTC@xxxxxxxxxxxxxxx
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc

[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux