PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : QoS -> packet loss



Taktloss
12.04.04, 18:34
Hi @ all
Ich habe mich mal mit QoS via HTB auseinander gesetzt.
Dabei ist dann folgendes Script entstanden:



#!/bin/sh

################################################## ############################
#+++++ Firewall Script für herms.lan (172.16.0.0) +++++#
#+++++ (c) 2004 by Oliver Herms, excluded.org +++++#
#+++++ www.excluded.org, www.fresh-hosting.com +++++#
#+++++ oliver.herms@herms.mine.nu +++++#
################################################## ############################

####################
### MASQUERADING ###
####################

iptables -t nat -A POSTROUTING -s 172.16.0.0/24 -d 0/0 -o ppp0 -j MASQUERADE


#######################
### Port FORWARDING ###
#######################

iptables -A FORWARD -i ppp0 -m state --state NEW -p tcp --dport 4662 -j ACCEPT
iptables -A PREROUTING -t nat -p tcp -i ppp0 --dport 4662 -j DNAT --to 172.16.0.2
iptables -A FORWARD -i ppp0 -m state --state NEW -p tcp --dport 4663 -j ACCEPT
iptables -A PREROUTING -t nat -p tcp -i ppp0 --dport 4663 -j DNAT --to 172.16.0.3



##############################
### Einrichten der Klassen ###
##############################

#wenn tc schon geconft, loeschen
if [ -n "`tc qdisc show dev ppp0`" ]
then
tc qdisc del dev ppp0 root
fi

#traffic mangling
tc qdisc add dev ppp0 root handle 1:0 htb default 13 r2q 2

#Hauptklasse
tc class add dev ppp0 parent 1:0 classid 1:1 htb rate 125kbit ceil 125kbit

#Half-life
tc class add dev ppp0 parent 1:1 classid 1:10 htb rate 22kbit ceil 46kbit prio 0

#ACK class Packete
tc class add dev ppp0 parent 1:1 classid 1:11 htb rate 9kbit ceil 80kbit prio 1

#SSH class
tc class add dev ppp0 parent 1:1 classid 1:12 htb rate 16kbit ceil 125kbit prio 2

#Normal Traffic
tc class add dev ppp0 parent 1:1 classid 1:13 htb rate 59kbit ceil 125kbit prio 3

#smtp
tc class add dev ppp0 parent 1:1 classid 1:14 htb rate 5kbit ceil 80kbit prio 4

#ftp
tc class add dev ppp0 parent 1:1 classid 1:15 htb rate 4kbit ceil 80kbit prio 5

#sandra, esel
tc class add dev ppp0 parent 1:1 classid 1:16 htb rate 10kbit ceil 50kbit prio 6


###################################
### markieren der pakete für tc ###
###################################

#CS
iptables -A POSTROUTING -t mangle -o ppp0 -p udp --dport 27015:27024 -j MARK --set-mark 10

#ACKs
iptables -A POSTROUTING -t mangle -o ppp0 -p tcp -m length --length :64 -j MARK --set-mark 11

#SSH(outgoing ssh)
iptables -A POSTROUTING -t mangle -o ppp0 -p tcp --dport 22 -j MARK --set-mark 12

#SSH Server(local)
iptables -A OUTPUT -t mangle -o ppp0 -p tcp --sport 22 -j MARK --set-mark 12

#SMTP(outgoing smtp)
iptables -A POSTROUTING -t mangle -o ppp0 -p tcp --dport 25 -j MARK --set-mark 14

#SMTP Server(local)
iptables -A OUTPUT -t mangle -o ppp0 -p tcp --sport 25 --j MARK --set-mark 14

#ftp(outgoing ftp)
iptables -A POSTROUTING -t mangle -o ppp0 -p tcp --dport 21 -j MARK --set-mark 15

#ftp Server (local)
iptables -A OUTPUT -t mangle -o ppp0 -p tcp --sport 21 -j MARK --set-mark 15

#xMule (P2P)
iptables -t mangle -A FORWARD -o ppp0 -p tcp --dport 4662 -j MARK --set-mark 16
iptables -t mangle -A FORWARD -o ppp0 -p tcp --sport 4662 -j MARK --set-mark 16


#sandras pakete
iptables -A FORWARD -t mangle -s 172.16.0.3 -j MARK --set-mark 16



##########################################
### Einordnen der pakete in die filter ###
##########################################

tc filter add dev ppp0 parent 1:0 prio 0 protocol ip handle 10 fw flowid 1:10
tc filter add dev ppp0 parent 1:0 prio 0 protocol ip handle 11 fw flowid 1:11
tc filter add dev ppp0 parent 1:0 prio 0 protocol ip handle 13 fw flowid 1:13
tc filter add dev ppp0 parent 1:0 prio 0 protocol ip handle 14 fw flowid 1:14
tc filter add dev ppp0 parent 1:0 prio 0 protocol ip handle 15 fw flowid 1:15
tc filter add dev ppp0 parent 1:0 prio 0 protocol ip handle 16 fw flowid 1:16


Fehlermeldungen bekomme ich beim ausführen keine. Jedoch kommt es unter Last zu packet loss. Das bestätigt sich zum einen durch pings und zum anderen durch
tc -s class show dev ppp0|grep dropped
dabei bekomme ich dann folgende Ausgabe:


server:/home/taktloss# tc -s class show dev ppp0|grep dropped
Sent 2749362 bytes 55241 pkts (dropped 5680, overlimits 0)
Sent 22750779 bytes 88525 pkts (dropped 0, overlimits 0)
Sent 0 bytes 0 pkts (dropped 0, overlimits 0)
Sent 5980084 bytes 8982 pkts (dropped 85, overlimits 0)
Sent 0 bytes 0 pkts (dropped 0, overlimits 0)
Sent 10918 bytes 161 pkts (dropped 0, overlimits 0)
Sent 0 bytes 0 pkts (dropped 0, overlimits 0)
Sent 14010415 bytes 24141 pkts (dropped 5897, overlimits 0)

Das zeigt, dass insbesondere die Pakete meines Esels gedroppt werden.
Wie bekomme ich die packet losses nun weg?


Die Ausgabe von tc -s class show dev ppp0 sie wie folgt aus:


server:/home/taktloss# tc -s class show dev ppp0
class htb 1:11 parent 1:1 prio 1 rate 9Kbit ceil 80Kbit burst 1610b cburst 1701b

Sent 2592104 bytes 54755 pkts (dropped 6302, overlimits 0)
rate 2698bps 56pps
lended: 27518 borrowed: 27237 giants: 0
tokens: -697953 ctokens: 132320

class htb 1:1 root rate 125Kbit ceil 125Kbit burst 1759b cburst 1759b
Sent 13843459 bytes 76743 pkts (dropped 0, overlimits 0)
rate 9148bps 74pps
lended: 38917 borrowed: 0 giants: 0
tokens: 38096 ctokens: 38096

class htb 1:10 parent 1:1 prio 0 rate 22Kbit ceil 46Kbit burst 1627b cburst 1657
b
Sent 0 bytes 0 pkts (dropped 0, overlimits 0)
lended: 0 borrowed: 0 giants: 0
tokens: 473600 ctokens: 230677

class htb 1:13 parent 1:1 prio 3 rate 59Kbit ceil 125Kbit burst 1674b cburst 175
9b
Sent 6081607 bytes 7474 pkts (dropped 91, overlimits 0)
rate 261bps 3pps
lended: 6246 borrowed: 1228 giants: 0
tokens: 168678 ctokens: 83968

class htb 1:12 parent 1:1 prio 2 rate 16Kbit ceil 125Kbit burst 1619b cburst 175
9b
Sent 0 bytes 0 pkts (dropped 0, overlimits 0)
lended: 0 borrowed: 0 giants: 0
tokens: 647999 ctokens: 90112

class htb 1:15 parent 1:1 prio 5 rate 4Kbit ceil 80Kbit burst 1604b cburst 1701b
Sent 4549 bytes 69 pkts (dropped 0, overlimits 0)
lended: 69 borrowed: 0 giants: 0
tokens: 2491199 ctokens: 132320

class htb 1:14 parent 1:1 prio 4 rate 5Kbit ceil 80Kbit burst 1605b cburst 1701b
Sent 0 bytes 0 pkts (dropped 0, overlimits 0)
lended: 0 borrowed: 0 giants: 0
tokens: 2055680 ctokens: 136159

class htb 1:16 parent 1:1 prio 6 rate 10Kbit ceil 50Kbit burst 1611b cburst 1663 b
Sent 5165199 bytes 14445 pkts (dropped 4138, overlimits 0)
rate 6198bps 14pps
lended: 3993 borrowed: 10452 giants: 0
tokens: -40448 ctokens: -186348

Hat jemand ne Idee warum er die Pakete verwirft und wie ich dieses Phänomen beseitigen kann?
MfG. Takt