[LARTC] how to setup massive traffic shaping? (2 class B nets)

Alexandru Dragoi alex at zoomnet.ro
Wed Sep 20 09:57:30 CEST 2006


????? ????? wrote:
> Hello
> I have 2 class-B networks (172.22.0.0/16 and 172.23.0.0/16, over 130k
> of ip's) and need to setup
> traffic tbf shapers with 64kb/s for each ip from 172.22.0.0/16 and
> 128kb/s for each ip from 172.23.0.0/16
> just read lartc and don't understand how to use u32 for decreasing
> number of rules and hashing
> _______________________________________________
> LARTC mailing list
> LARTC at mailman.ds9a.nl
> http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc
First you need imq. This because you can't have more than 65536 classes. 
Having 8 imqs you will be able to use 4 for download and 4 for upload. 
However You will tell us if the machine will support everything :). So 
you will divide the big class /15 into 4 classes /17

iptables -t mangle -A POSTROUTING -o $clients_eth -d 172.22.0.0/17 -j 
IMQ --todev 0

and:

tc qdisc add dev imq0 root handle 1: htb #Or whatever you use
tc class add dev imq0 parent 1: classid 1:f000 htb rate 620mbit #or 
whatever ...


tc filter add dev imq0 parent 1: protocol ip prio 5 handle 0: u32 
divisor 128
tc filter add dev imq0 parent 1: prio 5 u32 ht 800:: match ip dst 
172.22.0.0/17 hashkey mask 0x00007f00 at 16 link 0:

for i in seq `0 127` ; do
div=`printf "%x" $i`
let j=$i+1
tc filter add dev imq0 parent 1: prio 5 u32 ht 0:$div: match ip dst 
172.22.$i.0/24 hashkey mask 0x000000ff at 16 link $j:
for q in seq `0 255`; do
d=`printf "%x" $q`
clsid=$[$i*256+$q]
tc class add dev imq0 parent 1: classid 1:$clsid htb rate 128kbit
tc filter add dev imq0 parent 1: prio 5 u32 ht $j:$d match ip dst 
172.22.$i.$q flowid 1:$clsid
done
done

I hope i'm not missing something. For 172.22.128.0/17, instead of 
172.22.$i you will have 172.22.$[$i+128]
On other imq of course. For upload you just change dst with src, and "at 
16" into "at 12"


I'm really curious how it will work :D and how much it will take to run it.




More information about the LARTC mailing list