Re: how to speedup downloads

Linux Advanced Routing and Traffic Control

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

 



Sorry for the mime encoding. This attachment should work.

Thomas
#!/bin/sh
UP=192
DOWN=2048
UNIT=kbit
TC=/sbin/tc
IPT=/sbin/iptables
MARK="$IPT -t mangle -A POSTROUTING -o ppp0"
C_ADD="$TC class add dev ppp0"

if [ ! "$1" ]; then
	PROC=50;
else
	PROC=$1;
fi


$TC qdisc del dev ppp0 root 2> /dev/null > /dev/null
$TC qdisc del dev ppp0 ingress 2>/dev/null > /dev/null
$IPT -t mangle -F

$MARK -p tcp    --tcp-flags ALL SYN  -m multiport      --dports 25,80     -j MARK  --set-mark 111
$MARK -p tcp    --tcp-flags ALL ACK,PSH  -m multiport  --dports 25,80     -j MARK  --set-mark 111
$MARK -p tcp    --tcp-flags ALL ACK,FIN  -m multiport  --dports 25,80     -j MARK  --set-mark 111
$MARK -p tcp 	-m state --state ESTABLISHED,RELATED -m multiport --dports 25,80 -j MARK --set-mark 121


$MARK -p tcp    --tcp-flags ALL SYN      -m tos --tos 0x00 --dport 22     -j MARK  --set-mark 111
$MARK -p tcp    --tcp-flags ALL ACK,PSH  -m tos --tos 0x00 --dport 22     -j MARK  --set-mark 111
$MARK -p tcp    --tcp-flags ALL ACK,FIN  -m tos --tos 0x00 --dport 22     -j MARK  --set-mark 111
$MARK -p tcp    --tcp-flags ALL SYN      -m tos --tos 0x00 --dport 22     -j MARK  --set-mark 111
$MARK -p tcp    --tcp-flags ALL ACK,PSH  -m tos --tos 0x00 --dport 22     -j MARK  --set-mark 111
$MARK -p tcp    --tcp-flags ALL ACK,FIN  -m tos --tos 0x00 --dport 22     -j MARK  --set-mark 111
$MARK -p tcp 	-m state --state ESTABLISHED,RELATED -m tos --tos 0x10 	--dport 22 -j MARK --set-mark 122
$MARK -p tcp 	-m state --state ESTABLISHED,RELATED -m tos --tos 0x08 	--dport 22 -j MARK --set-mark 122


$MARK -p tcp    --dport 53                      -j MARK                 --set-mark 112 #dns
$MARK -p udp    --dport 53                      -j MARK                 --set-mark 112 #dns


$MARK -p icmp 	--icmp-type echo-request	-j MARK 		--set-mark 113 #Ping
$MARK -p icmp 	--icmp-type echo-reply		-j MARK  		--set-mark 113 #Pong

$MARK -p tcp	-m tcp -m multiport --dports 20,21,993,9160,6667,8360,8363,8390 	-j MARK	--set-mark 131 # low prio ports

$MARK -m mark --mark=0x00/0xff -j MARK --set-mark 141 # everything else

$TC qdisc add dev ppp0 root handle 1: htb default 141 

$C_ADD parent 1:   classid 1:1   htb quantum 1490 rate ${UP}$UNIT 

$C_ADD parent 1:1  classid 1:11  htb quantum 1490 rate $[${UP}*20/100]$UNIT ceil $[${UP}*99/100]$UNIT prio 1
$C_ADD parent 1:11 classid 1:111 htb quantum 1490 rate 18$UNIT ceil ${UP}$UNIT prio 1
$C_ADD parent 1:11 classid 1:112 htb quantum 1490 rate 18$UNIT ceil ${UP}$UNIT prio 2
$C_ADD parent 1:11 classid 1:113 htb quantum 1490 rate 2$UNIT ceil $[${UP}*10/100]$UNIT prio 3

$C_ADD parent 1:1  classid 1:12  htb quantum 1490 rate $[${UP}*55/100]$UNIT ceil $[${UP}*99/100]$UNIT prio 2
$C_ADD parent 1:12 classid 1:121 htb quantum 1490 rate 52$UNIT ceil ${UP}$UNIT prio 1
$C_ADD parent 1:12 classid 1:122 htb quantum 1490 rate 52$UNIT ceil ${UP}$UNIT prio 2

$C_ADD parent 1:1  classid 1:13  htb quantum 1490 rate $[${UP}*20/100]$UNIT ceil $[${UP}*99/100]$UNIT prio 3
$C_ADD parent 1:13 classid 1:131 htb quantum 1490 rate 38$UNIT ceil $[${UP}*99/100]$UNIT prio 1

$C_ADD parent 1:1 classid 1:14 htb quantum 1490 rate $[${UP}*5/100]$UNIT ceil $[${UP}*$PROC/100]$UNIT prio 5
$C_ADD parent 1:14 classid 1:141 htb quantum 1490 rate 9$UNIT ceil $[${UP}*$PROC/100]$UNIT prio 1

#Die tc filter suchen nach den markierungen die iptables in den packets hinterlassen hat und 
#leitet den Traffic in verschiedene Klassen
$TC filter add dev ppp0 parent 1:0 prio 1 protocol ip handle 111 fw flowid 1:111
$TC filter add dev ppp0 parent 1:0 prio 1 protocol ip handle 112 fw flowid 1:112
$TC filter add dev ppp0 parent 1:0 prio 1 protocol ip handle 113 fw flowid 1:113

$TC filter add dev ppp0 parent 1:0 prio 2 protocol ip handle 121 fw flowid 1:121
$TC filter add dev ppp0 parent 1:0 prio 2 protocol ip handle 122 fw flowid 1:122

$TC filter add dev ppp0 parent 1:0 prio 3 protocol ip handle 131 fw flowid 1:131

$TC filter add dev ppp0 parent 1:0 prio 4 protocol ip handle 141 fw flowid 1:141

#SFQ fuer Bulktraffic 
$TC qdisc add dev ppp0 parent 1:141 handle 141: sfq perturb 1

#TBF fuer bursty Leaf-Klassen (Bursts fuellen die Modem-queue und zerstoeren die interaktivitaet)

$TC qdisc add dev ppp0 parent 1:111  handle 111: tbf rate $[${UP}*99/100]$UNIT burst 7k latency 1ms
$TC qdisc add dev ppp0 parent 1:112  handle 112: tbf rate $[${UP}*99/100]$UNIT burst 1492 latency 1ms
$TC qdisc add dev ppp0 parent 1:121  handle 121: tbf rate $[${UP}*95/100]$UNIT burst 4k latency 20ms

#Ingress:
$TC qdisc add dev ppp0 handle ffff: ingress

$TC filter add dev ppp0 parent ffff: protocol ip prio 1 u32 \
match ip src 0.0.0.0/0 police rate $[${DOWN}*96/100]$UNIT burst 7k drop flowid :1

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