Nowe posty

Autor Wątek: Podział łacza- okropne pingi  (Przeczytany 1872 razy)

lpm11

  • Gość
Podział łacza- okropne pingi
« dnia: 2009-01-31, 13:22:04 »
Witam. Mam pewien problem. Posiadam stary komputer stacjonarny, na którym postawiłem router. Zainstalowałem Ubuntu 7.10 server, do tego skompilowałem jądro 2.6.25.20 z IMQ, ipp2p, użyłem pom itd.   teoretycznie wszystko działa, a praktycznie jest do niczego. Używam skryptu do klasyfikacji pakietów. Poniżej zamieszczam jego treść. Łącze tpsa DSL 1024/512. Przy pobieraniu ze speedtesta pingi rosną do 500 ms. a szybkość sięga do 800 kb/s, strasznie skacząc. Wiem że wina jest serwera, bo jak podłacze laptopa bezpośrednio pod modem adsl, to jest 1050 kb/s(łącze jest ok). co ciekawe przy uploadzie na speedteście (szybkość wyszła 460 kb/s) wszystko wydaje się być ok. pingi nie przekraczają 100 ms.
wszystkie pingi robiłem do wp. Na odciążonym łaczu wynik waha się koło 20 ms.
statystyki tc -s qdisc dev imq0(i imq1) show  pokazują że pakiety są poprawnie klasyfikowane.

oto mój plik firewall(uruchamiany przy starcie)

iptables -t filter -F
iptables -t mangle -F
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
RULE="PREROUTING"

modprobe ip_conntrack_ftp
modprobe ip_nat_ftp
modprobe imq numdevs=2
ifconfig imq0 up txqueuelen 12
ifconfig imq1 up txqueuelen 12


DL="imq0"
UL="imq1"

echo " -czyszczenie"
tc qdisc del dev $DL root 2>/dev/null
tc qdisc del dev $UL root 2>/dev/null
tc qdisc add dev $DL root handle 1: htb default 13
tc qdisc add dev $UL root handle 2: htb default 13

echo " -kolejki: download: htb"
tc class add dev $DL parent 1 classid 1:3 htb rate 960kbit ceil 960kbit
tc class add dev $DL parent 1:3 classid 1:11 htb rate 256kbit ceil 256kbit prio 1 quantum 1500
tc class add dev $DL parent 1:3 classid 1:12 htb rate 256kbit ceil 512kbit prio 2 quantum 1500
tc class add dev $DL parent 1:3 classid 1:13 htb rate 128kbit ceil 960kbit prio 4 quantum 1500
tc class add dev $DL parent 1:3 classid 1:14 htb rate 128kbit ceil 768kbit prio 5 quantum 1500
tc class add dev $DL parent 1:3 classid 1:15 htb rate 32kbit ceil 768kbit prio 6 quantum 1500
tc qdisc add dev $DL parent 1:11 handle 11: sfq perturb 10
tc qdisc add dev $DL parent 1:12 handle 12: sfq perturb 10
tc qdisc add dev $DL parent 1:13 handle 13: sfq perturb 10
tc qdisc add dev $DL parent 1:14 handle 14: sfq perturb 10
tc qdisc add dev $DL parent 1:15 handle 15: sfq perturb 10

echo " -kolejki: upload: htb"
tc class add dev $UL parent 2 classid 2:3 htb rate 480kbit ceil 480kbit
tc class add dev $UL parent 2:3 classid 2:11 htb rate 128kbit ceil 128kbit prio 1 quantum 1500
tc class add dev $UL parent 2:3 classid 2:12 htb rate 128kbit ceil 256kbit prio 2 quantum 1500
tc class add dev $UL parent 2:3 classid 2:13 htb rate 64kbit ceil 480kbit prio 4 quantum 1500
tc class add dev $UL parent 2:3 classid 2:14 htb rate 64kbit ceil 384kbit prio 5 quantum 1500
tc class add dev $UL parent 2:3 classid 2:15 htb rate 16kbit ceil 384kbit prio 6 quantum 1500
tc qdisc add dev $UL parent 2:11 handle 21: sfq perturb 10
tc qdisc add dev $UL parent 2:12 handle 22: sfq perturb 10
tc qdisc add dev $UL parent 2:13 handle 23: sfq perturb 10
tc qdisc add dev $UL parent 2:14 handle 24: sfq perturb 10
tc qdisc add dev $UL parent 2:15 handle 25: sfq perturb 10

echo " -przydzielanie: download"
tc filter add dev $DL parent 1: protocol ip prio 1 handle 1 fw flowid 1:11
tc filter add dev $DL parent 1: protocol ip prio 1 handle 2 fw flowid 1:12
tc filter add dev $DL parent 1: protocol ip prio 1 handle 3 fw flowid 1:13
tc filter add dev $DL parent 1: protocol ip prio 1 handle 4 fw flowid 1:14
tc filter add dev $DL parent 1: protocol ip prio 1 handle 5 fw flowid 1:15

echo " -przydzielanie: upload"
tc filter add dev $UL parent 2: protocol ip prio 1 handle 1 fw flowid 2:11
tc filter add dev $UL parent 2: protocol ip prio 1 handle 2 fw flowid 2:12
tc filter add dev $UL parent 2: protocol ip prio 1 handle 3 fw flowid 2:13
tc filter add dev $UL parent 2: protocol ip prio 1 handle 4 fw flowid 2:14
tc filter add dev $UL parent 2: protocol ip prio 1 handle 5 fw flowid 2:15



iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state INVALID -j DROP
iptables -A OUTPUT -m state --state INVALID -j DROP
iptables -A FORWARD -m state --state INVALID -j DROP
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth1 -j MASQUERADE

iptables -A INPUT -p tcp --dport 22 -m state --state NEW -j LOG --log-prefix "[SSH] "
iptables -A INPUT -p tcp --dport 21:22 -j ACCEPT
iptables -A INPUT -p tcp --dport 25 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
iptables -A INPUT -p tcp --dport 143 -j ACCEPT
iptables -A INPUT -p tcp --dport 993 -j ACCEPT
iptables -A INPUT -p tcp --dport 995 -j ACCEPT
iptables -A INPUT -p udp --dport 53 -j ACCEPT
iptables -A INPUT -p udp --dport 123 -j ACCEPT

iptables -A INPUT -i eth0 -p tcp --dport 110 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --dport 143 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --dport 149 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --dport 445 -j ACCEPT
iptables -A INPUT -i eth0 -p udp --dport 137:138 -j ACCEPT
iptables -A INPUT -p tcp -j REJECT --reject-with tcp-reset
iptables -A INPUT -p udp -j REJECT --reject-with icmp-port-unreachable

iptables -t mangle -A $RULE -m mark ! --mark 5 -j MARK --set-mark 4
iptables -t mangle -A $RULE -m layer7 --l7proto h323 -j MARK --set-mark 2
iptables -t mangle -A $RULE -m layer7 --l7proto sip -j MARK --set-mark 2
iptables -t mangle -A $RULE -m layer7 --l7proto skypetoskype -j MARK --set-mark 2
#iptables -t mangle -A $RULE -m layer7 --l7proto skypeout -j MARK --set-mark 2
iptables -t mangle -A $RULE -m layer7 --l7proto teamspeak -j MARK --set-mark 2
iptables -t mangle -A $RULE -m layer7 --l7proto ventrilo -j MARK --set-mark 2
iptables -t mangle -A $RULE -m layer7 --l7proto ssh -j MARK --set-mark 2
iptables -t mangle -A $RULE -m layer7 --l7proto telnet -j MARK --set-mark 1
iptables -t mangle -A $RULE -m layer7 --l7proto dns -j MARK --set-mark 1
iptables -t mangle -A $RULE -p icmp -j MARK --set-mark 1
iptables -t mangle -A $RULE -m tcp -p tcp --dport 1024:65535 -i eth0 -j MARK --set-mark 4
iptables -t mangle -A $RULE -m tcp -p tcp --sport 1024:65535 -i eth1 -j MARK --set-mark 4

iptables -t mangle -A $RULE -p tcp -m tcp --tcp-flags SYN,ACK,RST ACK -j MARK --set-mark 2
iptables -t mangle -A $RULE -p tcp -m tcp --tcp-flags SYN,ACK,RST SYN -j MARK --set-mark 2
iptables -t mangle -A $RULE -p tcp -m tcp --tcp-flags SYN,ACK,RST SYN,ACK -j MARK --set-mark 2
iptables -t mangle -A $RULE -p tcp -m tcp --tcp-flags SYN,ACK,RST RST,ACK -j MARK --set-mark 2
iptables -t mangle -A $RULE -p tcp -m tcp --tcp-flags SYN,ACK,RST FIN,ACK -j MARK --set-mark 2

iptables -t mangle -A $RULE -p tcp -m layer7 --l7proto http -j MARK --set-mark 3
iptables -t mangle -A $RULE -p tcp -m layer7 --l7proto ssl -j MARK --set-mark 3
iptables -t mangle -A $RULE -p tcp -m layer7 --l7proto pop3 -j MARK --set-mark 4
iptables -t mangle -A $RULE -p tcp -m layer7 --l7proto smtp -j MARK --set-mark 4
iptables -t mangle -A $RULE -p tcp -m layer7 --l7proto ftp -j MARK --set-mark 4

iptables -t mangle -A $RULE -m ipp2p --ipp2p -j MARK --set-mark 5
iptables -t mangle -A $RULE -m layer7 --l7proto ares -j MARK --set-mark 5
iptables -t mangle -A $RULE -m layer7 --l7proto gnutella -j MARK --set-mark 5
iptables -t mangle -A $RULE -m layer7 --l7proto fasttrack -j MARK --set-mark 5
iptables -t mangle -A $RULE -m layer7 --l7proto bittorrent -j MARK --set-mark 5
iptables -t mangle -A $RULE -m layer7 --l7proto edonkey -j MARK --set-mark 5
iptables -t mangle -A $RULE -m layer7 --l7proto directconnect -j MARK --set-mark 5

iptables -t mangle -A PREROUTING -i eth1 -j IMQ --todev 0
iptables -t mangle -A POSTROUTING -o eth1 -j IMQ --todev 1


eth0- to sieć wewnętrzna
eth1- modem ADSL
imq0- tu skierowałem download z internetu
a do imq1 upload

poświęciłem ogromnie dużo czasu, kombinując na różne sposoby. Dokładnie przeczytałem dokumentację htb, oraz kilka poradników z neta. Zmieniałem maksymalne szybkości, algorytm kolejkowania(na esfq), oraz z filtrami layer7.
na modemie ADSL pingi nie przekraczają 2 ms.

Bardzo was proszę o pomoc, cokolwiek zauważycie co mogłoby być nie tak.
będę bardzo wdzieczny.