Traffic Shaping for 80 Users on Lan
Quoted 9 lines
Hi ,
I dont know if this has been asked before (sorry)
I need to shape traffic on Lan1 to 1 Meg Download,(Internet
Downstream=2
Quoted 7 lines
Meg) and that everyone on that Lan
has the same amount of traffic bandwidth available for download, (1
user0%, 2 userP% each 3 users3,3%....etc)
I read about sfq, and esfq but it seems that I have to write a line for
every user (in my case about 80 users) .
So that it creates for each flow(user/port?) a new Band, right? This could be a solution, but I still have no clue how this script has
to
Quoted 5 lines
look like, but it has to be a "Huge" script since
I have a lot of users(total 190), different places, more users, more
Unknown Ip Adresses to figure out..... :)Anyone can give me a "example script" for My Case with a bit
explanation.
Quoted 9 lines
so I can work with it?
Ok this sound weird but... Is there a way to do a "2 Line script"
instead?? (and let TC do the Fair Queing) like:
* Create qdisc on eth1 with maximum bandwith 1 Meg....and no need to
specify any ip addresses of the users????Could someone please send me something to start with, Im
desperate!
Quoted 6 lines
regards Osgaldo.
(sorry for the bad english)
PD: The How to is quite good for understand a bit about Traffic Shaping,
But
Quoted 12 lines
I think It lacks of Real Scenario examples.
The HTB page is quiet good, good examples but in this case I think
HTB is not the one I need for my Scenario, right?
Couldnt find neither on Stef Coene page some example scripts on my
Subject.
(Sorry Stef didnt mean to anger you,I believe you have done a great
job with your site)
But I think it would be great if everyone could send to the How To
Maintainer their Scenario scripts to include for Future
reference for everyone in the How To, what do you think?
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
Quoted 16 lines
Quoted 5 lines
I need to shape traffic on Lan1 to 1 Meg Download,(Internet
Downstream=2
Quoted 8 lines
Meg) and that everyone on that Lan
has the same amount of traffic bandwidth available for download, (1
user0%, 2 userP% each 3 users3,3%....etc)
I read about sfq, and esfq but it seems that I have to write a line for
every user (in my case about 80 users) .
So that it creates for each flow(user/port?) a new Band, right?
...
Quoted 10 lines
Quoted 3 lines
Anyone can give me a "example script" for My Case with a bit
explanation.
Quoted 4 lines
so I can work with it?
I have a script which does something similar. Assuming you have a /etc/hosts file with all the hosts: (it is somewhat more complicated because it lives between our resnet and the rest of campus and I don't want to shape down traffic going to campus much (if at all))
#/bin/bash
###########################################
### ALL CONFIGURATION SHOULD BE UP HERE ###
###########################################
### bandwidth settings
#daily quota in bytes
#QUOTA00000000
#total internal bandwidth
INTRABANDWIDTHmbit
#total external bandwidth
INTERBANDWIDTH=.4mbit
#the difference between intra and inter
DIFFBANDWIDTH=8mbit
#bandwidth for the unregistered ips.. probably not much... UNREGISTEREDBWkbit
BASEBANDWIDTH=1kbit
#bandwidth for jail
#JAILBANDWIDTH=.1mbit
#rest of bandwidth (inter-jail)
#RESTBANDWIDTH=1mbit
### interfaces and ips
#interface to shape (should probably be one facing world) SHAPEINTERFACE=eth0
#interface to watch (usually the same as SHAPEINTERFACE) WATCHINTERFACE=eth0
LOCALNET7.22.0.0
LOCALNETNETMASK
#######################################
### BEGIN NON-CONFIGURATION SECTION ###
#######################################
initqos() {
#remove the old qos rules
echo tc qdisc del root dev $SHAPEINTERFACE
tc qdisc del root dev $SHAPEINTERFACE
#create the root queue
echo tc qdisc add dev $SHAPEINTERFACE root handle 1: htb default 20 tc qdisc add dev $SHAPEINTERFACE root handle 1: htb default 20
#create the root class
echo tc class add dev $SHAPEINTERFACE parent 1: classid 1:1 htb rate
$INTRABANDWIDTH burst 15k
tc class add dev $SHAPEINTERFACE parent 1: classid 1:1 htb rate
$INTRABANDWIDTH burst 15k
#create the class for the intranet
echo tc class add dev $SHAPEINTERFACE parent 1:1 classid 1:10 htb
rate $DIFFBANDWIDTH ceil $INTRABANDWIDTH burst 15k
tc class add dev $SHAPEINTERFACE parent 1:1 classid 1:10 htb rate
$DIFFBANDWIDTH ceil $INTRABANDWIDTH burst 15k
#create the "default" class which will include everything else
(probably the internet)
echo tc class add dev $SHAPEINTERFACE parent 1:1 classid 1:20 htb
rate $INTERBANDWIDTH burst 15k
tc class add dev $SHAPEINTERFACE parent 1:1 classid 1:20 htb rate
$INTERBANDWIDTH burst 15k
#add a queue to handle all the local net requests
echo tc qdisc add dev $SHAPEINTERFACE parent 1:10 handle 10: sfq
perturb 10
tc qdisc add dev $SHAPEINTERFACE parent 1:10 handle 10: sfq perturb 10
#create the filter to pick out the intranet from all the packets echo tc filter add dev $SHAPEINTERFACE protocol ip parent 1:0 prio 1
u32 \
match ip src $LOCALNET/$LOCALNETNETMASK flowid 1:10
tc filter add dev $SHAPEINTERFACE protocol ip parent 1:0 prio 1 u32 \
match ip src $LOCALNET/$LOCALNETNETMASK flowid 1:10
#add the htb queue to make the good go fast to the internet and the
bad go slowly.
echo tc qdisc add dev $SHAPEINTERFACE parent 1:20 htb default 21 tc qdisc add dev $SHAPEINTERFACE parent 1:20 htb default 21
#create the class for the users who have not registered. bad users! echo tc class add dev $SHAPEINTERFACE parent 1:10 classid 1:21 htb
rate $UNREGISTEREDBW ceil $UNREGISTEREDBW burst 15k
tc class add dev $SHAPEINTERFACE parent 1:10 classid 1:21 htb rate
$UNREGISTEREDBW ceil $UNREGISTEREDBW burst 15k
#add a queue to handle all the unregistered users
echo tc qdisc add dev $SHAPEINTERFACE parent 1:21 handle 21: sfq
perturb 10
tc qdisc add dev $SHAPEINTERFACE parent 1:21 handle 21: sfq perturb 10
#filters for each user will be added farther down...
}
addclass() {
IP=$1
CLASS=$2
#create the class for each user
echo tc class add dev $SHAPEINTERFACE parent 1:10 classid 1:$CLASS htb rate $BASEBANDWIDTH ceil $INTERBANDWIDTH burst 15k
tc class add dev $SHAPEINTERFACE parent 1:10 classid 1:$CLASS htb rate $BASEBANDWIDTH ceil $INTERBANDWIDTH burst 15k
#add a queue for each user
echo tc qdisc add dev $SHAPEINTERFACE parent 1:$CLASS handle $CLASS: sfq perturb 10
tc qdisc add dev $SHAPEINTERFACE parent 1:$CLASS handle $CLASS: sfq perturb 10
#add a filter for each user
echo tc filter add dev $SHAPEINTERFACE protocol ip parent 1:0 prio 1 u32 \
match ip dst $IP flowid 1:$CLASS
tc filter add dev $SHAPEINTERFACE protocol ip parent 1:0 prio 1 u32 \
match ip dst $IP flowid 1:$CLASS
echo tc filter add dev $SHAPEINTERFACE protocol ip parent 1:0 prio 1 u32 \
match ip src $IP flowid 1:$CLASS
tc filter add dev $SHAPEINTERFACE protocol ip parent 1:0 prio 1 u32 \
match ip src $IP flowid 1:$CLASS
}
OVERQUOTAIPS=()
NUMOVERQUOTA=0
initqos
FILE=/etc/hosts
echo $FILE
LINES=cat $FILE | grep -v \# |grep -v 127.0.0.1 | wc -l
#copy the ipfm file to the web dir
#echo The quota is currently $QUOTA -- compare to the third column of numbers > /var/www/html/curbandwidth.txt
echo The current test does not involve a quota. I may post bandwidth usage soon anyway. > /var/www/html/curbandwidth.txt
#cat $FILE >>/var/www/html/curbandwidth.txt
echo ips registered: $LINES
#loop through the ip addresses that have been observed so far if [ $LINES -ne 0 ]; then
for x in seq 1 $LINES; do
HOSTNAME=`cat $FILE | grep -v \# | grep -v 127.0.0.1 | head -$x
| tail -1 | cut -f 1 -d" "`
addclass $HOSTNAME $(($x+21))
doneelse
NUMOVERQUOTA=0
fi
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/