From: Ethan Sommer <sommere@mathcs.carleton.edu>
To: lartc@vger.kernel.org
Subject: Re: [LARTC] Fw: Traffic Shaping for 80 Users on Lan
Date: Sun, 11 May 2003 19:29:39 +0000 [thread overview]
Message-ID: <marc-lartc-105268148218284@msgid-missing> (raw)
In-Reply-To: <marc-lartc-105253354606525@msgid-missing>
>
>
>> I need to shape traffic on Lan1 to 1 Meg Download,(Internet
>>
>>
>Downstream=2
>
>
>>Meg) and that everyone on that Lan
>> has the same amount of traffic bandwidth available for download, (1
>>user\x100%, 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?
>>
>>
...
>> Anyone can give me a "example script" for My Case with a bit
>>
>>
>explanation.
>
>
>>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
#QUOTA\x1000000000
#total internal bandwidth
INTRABANDWIDTH\x10mbit
#total external bandwidth
INTERBANDWIDTH=.4mbit
#the difference between intra and inter
DIFFBANDWIDTH=8mbit
#bandwidth for the unregistered ips.. probably not much...
UNREGISTEREDBW\x16kbit
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
LOCALNET\x137.22.0.0
LOCALNETNETMASK\x16
#######################################
### 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))
done
else
NUMOVERQUOTA=0
fi
_______________________________________________
LARTC mailing list / LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
prev parent reply other threads:[~2003-05-11 19:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-10 2:27 [LARTC] Fw: Traffic Shaping for 80 Users on Lan Osgaldo Suanzes
2003-05-11 19:29 ` Ethan Sommer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=marc-lartc-105268148218284@msgid-missing \
--to=sommere@mathcs.carleton.edu \
--cc=lartc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.