Page 1 of 1
					
				Trafficshaping
				Posted: 2003-05-06 16:33
				by dopefish
				vielleicht für euch auch interessant, ich habe ein kleines script zusammengeschnipselt der trafficshaping lokal auf kiste macht um dafür zu sorgen dass pakete nicht nach FIFO abgearbeitet werden sondern dass gewisse priotirisierung stattfindet. das script ist zusammengeschnipselt aus diverse dokus und relativ schlicht, fall einer bessere ideen hat kann er es gerne modifizieren und hier wieder posten damit alle was davon haben.
ich freue mich natürlich auch wenn ihr einen fehler entdeckt und mir sagt.  beim neuen hlds server ist die zeile für counterstrike überflüssig da man hlds sinnigerweise mit -tos aufrufen kann.
DEV ist das interface, STREAM eure lokale Anbindung, sollten beides so korrekt sein.
Code: Select all
#!/bin/bash
DEV=eth0
STREAM=100mbit
if [ "$1" = "status" ]
then
        tc -s qdisc ls dev $DEV
        tc -s class ls dev $DEV
        exit
fi
tc qdisc del dev $DEV root >/dev/null 2>&1
if [ "$1" = "stop" ]
then
        exit
fi
#tc qdisc add dev $DEV root handle 1: prio
# ok, lets start this thing off by instaling the root
tc qdisc add dev $DEV root handle 1: cbq avpkt 1000 bandwidth $STREAM
# goofing around with our upstream got to set some main things straight
tc class add dev $DEV parent 1: classid 1:1 cbq rate $STREAM allot 1500 prio 5 bounded isolated
# okidookie let's whack some priority into these two queues
# high priority queue
tc class add dev $DEV parent 1:1 classid 1:10 cbq rate $STREAM allot 1600 prio 1 avpkt 1000
# low priority queue
tc class add dev $DEV parent 1:1 classid 1:20 cbq rate $STREAM allot 1600 prio 2 avpkt 1000
# now lets give 'm a little Stochastic Fairness
tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10
tc qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10
# what would traffisshaping be without respect for the tos flag ;)
tc filter add dev $DEV parent 1:0 protocol ip prio 10 u32 match ip tos 0x10 0xff  flowid 1:10
# this one here is for counterstrike, the main reason i whipped this together
tc filter add dev $DEV parent 1:0 protocol ip prio 10 u32 match ip sport 27015 0xffff flowid 1:10
# ACK Packets also get a nice priority, no need to slow them down.
tc filter add dev $DEV parent 1: protocol ip prio 13 u32 
   match ip protocol 6 0xff 
   match u8 0x05 0x0f at 0 
   match u16 0x0000 0xffc0 at 2 
   match u8 0x10 0xff at 33 
   flowid 1:10
# put the rest in the 2.d queue
tc filter add dev $DEV parent 1: protocol ip prio 14 u32 match ip dst 0.0.0.0/0 flowid 1:20
 
			
					
				Re: Trafficshaping
				Posted: 2003-05-06 19:29
				by captaincrunch
				Ein Fall für's Datentransfer und Backup
			 
			
					
				Re: Trafficshaping
				Posted: 2003-05-12 18:42
				by bmp
				DopeFish wrote:
Code: Select all
# this one here is for counterstrike, the main reason i whipped this together
tc filter add dev $DEV parent 1:0 protocol ip prio 10 u32 match ip sport 27015 0xffff flowid 1:10
 
Sehe ich das richtig, das hier alle Pakete mit Port 27015 bevorzugt werden ?
Kann man (du;-) das umschreiben das die Ports 80 und 21 benachteiligt werden ?
mfg
Marcus
 
			
					
				Re: Trafficshaping
				Posted: 2003-05-12 23:51
				by dopefish
				geht relativ einfach, setz einfach ein filter für die ports in die 2. queue und alles andere in die erste queue
			 
			
					
				Re: Trafficshaping
				Posted: 2003-05-13 00:15
				by bmp
				DopeFish wrote:geht relativ einfach, setz einfach ein filter für die ports in die 2. queue und alles andere in die erste queue
Ã?hhmmm Ja  :oops:  wenn du das so sagt  :roll: .....
Du hast nicht zufällig ein Beispiel parat bei dem Port 21 und 80 als unterstes behandelt werden  :D
 
			
					
				Re: Trafficshaping
				Posted: 2003-05-13 10:52
				by dopefish
				versuchs mal mit folgenden, habs aber net getestet:
Code: Select all
#!/bin/bash
DEV=eth0
STREAM=100mbit
if [ "$1" = "status" ]
then
        tc -s qdisc ls dev $DEV
        tc -s class ls dev $DEV
        exit
fi
tc qdisc del dev $DEV root >/dev/null 2>&1
if [ "$1" = "stop" ]
then
        exit
fi
#tc qdisc add dev $DEV root handle 1: prio
# ok, lets start this thing off by instaling the root
tc qdisc add dev $DEV root handle 1: cbq avpkt 1000 bandwidth $STREAM
# goofing around with our upstream got to set some main things straight
tc class add dev $DEV parent 1: classid 1:1 cbq rate $STREAM allot 1500 prio 5 bounded isolated
# okidookie let's whack some priority into these two queues
# high priority queue
tc class add dev $DEV parent 1:1 classid 1:10 cbq rate $STREAM allot 1600 prio 1 avpkt 1000
# low priority queue
tc class add dev $DEV parent 1:1 classid 1:20 cbq rate $STREAM allot 1600 prio 2 avpkt 1000
# now lets give 'm a little Stochastic Fairness
tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10
tc qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10
# this one here is for http
tc filter add dev $DEV parent 1:0 protocol ip prio 10 u32 match ip sport 80 0xffff flowid 1:20
# this one here is for ftp data channel
tc filter add dev $DEV parent 1:0 protocol ip prio 10 u32 match ip sport 20 0xffff flowid 1:20
# this one here is for ftp command channel
tc filter add dev $DEV parent 1:0 protocol ip prio 10 u32 match ip sport 21 0xffff flowid 1:20
# put the rest in the 1st queue
tc filter add dev $DEV parent 1: protocol ip prio 14 u32 match ip dst 0.0.0.0/0 flowid 1:10
ich glaube aber kaum dass du damit glücklich werden willst weil FTP ein bescheuertes protokoll ist (firewalltechnisch, besonders PASSIVE mode), da bist du wahrscheins besser dran die pakete von ftp mittels iptables zu markieren und die TOS zu setzen und anhand dessen das trafficshaping zu machen weil iptables connection tracking für ftp sessions (mehr oder minder je nach modus) beherrscht.  siehe 
http://www.sns.ias.edu/~jns/security/ip ... k.html#FTP 
			
					
				Re: Trafficshaping
				Posted: 2003-05-13 11:03
				by bmp
				DopeFish wrote:versuchs mal mit folgenden, habs aber net getestet:
ich glaube aber kaum dass du damit glücklich werden willst weil FTP ein bescheuertes protokoll ist (firewalltechnisch, besonders PASSIVE mode), da bist du wahrscheins besser dran die pakete von ftp mittels iptables zu markieren und die TOS zu setzen und anhand dessen das trafficshaping zu machen weil iptables connection tracking für ftp sessions (mehr oder minder je nach modus) beherrscht.  siehe 
http://www.sns.ias.edu/~jns/security/ip ... k.html#FTP 
Ich Danke dir.  :P 
Werde es gleich mal testen. 
FTP ist eigendlich nebensächlich. Hauptsache ist, das die Downloads per HTTP ein wenig gebremst werden.
Also nochmals vielen Dank...
mfg
Marcus
 
			
					
				Re: Trafficshaping
				Posted: 2003-05-13 11:24
				by bmp
				BMP wrote:Werde es gleich mal testen. 
So gerade versucht zu testen.
Code: Select all
SHELL:~ # /etc/init.d/HTTP-FTP-Begrenzung start
/etc/init.d/HTTP-FTP-Begrenzung: Dadurch: command not found
RTNETLINK answers: Invalid argument
RTNETLINK answers: Invalid argument
RTNETLINK answers: Invalid argument
RTNETLINK answers: Invalid argument
RTNETLINK answers: Invalid argument
RTNETLINK answers: Invalid argument
RTNETLINK answers: Invalid argument
RTNETLINK answers: Invalid argument
RTNETLINK answers: Invalid argument
RTNETLINK answers: Invalid argument
Weiß da einer rat ??
 
			
					
				Re: Trafficshaping
				Posted: 2003-05-13 11:31
				by dopefish
				ändere mal die erste zeile in #!/bin/bash -x damit man sieht was schiefläuft.
es sieht aber eher dannach aus als ob die module für traffic shaping fehlen, solltest du mal im kernel auswählen (networking options -> QOS ) und dananch ein make modules && make modules_install machen (oder fest einkompilieren und rebooten)
			 
			
					
				Re: Trafficshaping
				Posted: 2003-05-13 12:00
				by bmp
				DopeFish wrote:ändere mal die erste zeile in #!/bin/bash -x damit man sieht was schiefläuft.
es sieht aber eher dannach aus als ob die module für traffic shaping fehlen, solltest du mal im kernel auswählen (networking options -> QOS ) und dananch ein make modules && make modules_install machen (oder fest einkompilieren und rebooten)
Hmmm,
Code: Select all
essen112:~ # /etc/init.d/HTTP-FTP-Begrenzung start
+ Dadurch werden alle Anfragen die auf anderen Ports laufen bevorzugt behandelt.
/etc/init.d/HTTP-FTP-Begrenzung: Dadurch: command not found
+ DEV=eth0
+ STREAM=100mbit
+ '[' start = status ']'
+ tc qdisc del dev eth0 root
+ '[' start = stop ']'
+ tc qdisc add dev eth0 root handle 1: cbq avpkt 1000 bandwidth 100mbit
RTNETLINK answers: Invalid argument
+ tc class add dev eth0 parent 1: classid 1:1 cbq rate 100mbit allot 1500 prio 5 bounded isolated
RTNETLINK answers: Invalid argument
+ tc class add dev eth0 parent 1:1 classid 1:10 cbq rate 100mbit allot 1600 prio 1 avpkt 1000
RTNETLINK answers: Invalid argument
+ tc class add dev eth0 parent 1:1 classid 1:20 cbq rate 100mbit allot 1600 prio 2 avpkt 1000
RTNETLINK answers: Invalid argument
+ tc qdisc add dev eth0 parent 1:10 handle 10: sfq perturb 10
RTNETLINK answers: Invalid argument
+ tc qdisc add dev eth0 parent 1:20 handle 20: sfq perturb 10
RTNETLINK answers: Invalid argument
+ tc filter add dev eth0 parent 1:0 protocol ip prio 10 u32 match ip sport 80 0xffff flowid 1:20
RTNETLINK answers: Invalid argument
+ tc filter add dev eth0 parent 1:0 protocol ip prio 10 u32 match ip sport 20 0xffff flowid 1:20
RTNETLINK answers: Invalid argument
+ tc filter add dev eth0 parent 1:0 protocol ip prio 10 u32 match ip sport 21 0xffff flowid 1:20
RTNETLINK answers: Invalid argument
+ tc filter add dev eth0 parent 1: protocol ip prio 14 u32 match ip dst 0.0.0.0/0 flowid 1:10
RTNETLINK answers: Invalid argument
+ exit 0
Habe auch schon QOS eingebaut und dann make modules && make modules_install +Reeboot. 
Kann man feststellen ob QOS Aktiv ist ?
 
			
					
				Re: Trafficshaping
				Posted: 2003-05-13 12:06
				by captaincrunch
				Habe auch schon QOS eingebaut und dann make modules && make modules_install +Reeboot.
Kann man feststellen ob QOS Aktiv ist ?
Wie wär's denn, wenn du die nötigen Module einfach mal händisch per 
modprobe lädst ? ;)
 
			
					
				Re: Trafficshaping
				Posted: 2003-05-13 18:58
				by bmp
				CaptainCrunch wrote:Wie wär's denn, wenn du die nötigen Module einfach mal händisch per modprobe lädst ? ;)
Ich bin zu blöd dafür.
Ich habe folgendes gemacht :
1. cd /usr/src/linux
2. make menuconfig
3. QOS Ausgewählt und alle Module als M markiert.
4. make depend
5. make modules && make modules_install
6. modprobe sch_qdisc
aber bei kommt als Ausgabe = modprobe: Can't locate module sch_qdisc
 :(  :(  :(
 
			
					
				Re: Trafficshaping
				Posted: 2003-05-13 20:19
				by captaincrunch
				Mach mal ein find /lib/modules/KERNELVERSION/ -name NAMEDERMODULE. Wahrscheinlich heißen die nur anders. Sorry, mit QOS habe ich mich noch nie befasst.
			 
			
					
				Re: Trafficshaping
				Posted: 2003-05-15 14:30
				by moomurray
				Ich finde das echt lustig, denn was hier ganz schnell weiterhilft, ist das von mir mal in irgendeinem Beitrag angesprochene PHP-Script, welches einfach Dateien irgendwo auf dem Server liest und und zum Beispiel in 50kb-Blöcken pro Sekunde verfüttert an den Browser. Ich denke, genau diese Lösung wird hier gesucht.
Dennoch finde ich die ganze Diskussion recht interessant :)
Das Script hab ich auf php.net gefunden, aber frag nicht wo, habs jetzt auch gerade nicht zur Hand...
			 
			
					
				Re: Trafficshaping
				Posted: 2003-05-15 23:29
				by dopefish
				das nenn ich mal ne überflüssige belastung vom server das so zu lösen :p