Re: [LARTC] configuration + HTB: question

Linux Advanced Routing and Traffic Control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Thanks Stef,
>
> Can you look at this, am i doing correct?
>
> tc qdisc del dev eth0 root
>
> # Add HTB root qdisc
> tc qdisc add dev eth0 root handle 1: htb
>
> # Add main 'local' rate class
> tc class add dev eth0 parent 1: classid 1:1 htb rate
> 60Mbit
>
> #add leaf classes(20 classes, one class for one ip in
> range 192.168.1.1 - 192.168.1.20)
> tc class add dev eth0 parent 1:1 classid 1:20 htb rate
> 32kbit ceil 60Mbit
> tc class add dev eth0 parent 1:1 classid 1:21 htb rate
> 32kbit ceil 60Mbit
> tc class add dev eth0 parent 1:1 classid 1:22 htb rate
> 32kbit ceil 60Mbit
> tc class add dev eth0 parent 1:1 classid 1:23 htb rate
> 32kbit ceil 60Mbit
> ...
> tc class add dev eth0 parent 1:1 classid 1:39 htb rate
> 32kbit ceil 60Mbit
>
> # attach qdisc to leaf classes
> tc qdisc add dev eth0 parent 1:20 handle 20: sfq
> tc qdisc add dev eth0 parent 1:21 handle 21: sfq
> tc qdisc add dev eth0 parent 1:22 handle 22: sfq
> tc qdisc add dev eth0 parent 1:23 handle 23: sfq
> ...
> tc qdisc add dev eth0 parent 1:39 handle 39: sfq
>
> # filter traffic into classes by fwmark
> tc filter add dev eth0 parent 1:0 protocol ip handle 1
> fw flowid 1:20
> tc filter add dev eth0 parent 1:0 protocol ip handle 2
> fw flowid 1:21
> tc filter add dev eth0 parent 1:0 protocol ip handle 3
> fw flowid 1:22
> tc filter add dev eth0 parent 1:0 protocol ip handle 4
> fw flowid 1:23
> ...
> tc filter add dev eth0 parent 1:0 protocol ip handle 1
> fw flowid 1:39
>
> # add fwmark entries
> iptables -t mangle -A OUTPUT -d 192.168.1.1 -j MARK
> --set-mark 1
> iptables -t mangle -A OUTPUT -d 192.168.1.2 -j MARK
> --set-mark 2
> iptables -t mangle -A OUTPUT -d 192.168.1.3 -j MARK
> --set-mark 3
> iptables -t mangle -A OUTPUT -d 192.168.1.4 -j MARK
> --set-mark 4
> ...
> iptables -t mangle -A OUTPUT -d 192.168.1.20 -j MARK
> --set-mark 39
>
>
> But if i want to add one more ip, for example
> 192.168.1.21, i need:
> 1) add leaf class
> 2) attach to it qdisc with sfq
> 3) add filter by fwmark
> 4) add one entry with iptables to mark ip 192.168.1.21
Indeed.
You can reduce the number of fw filters rules if you use the mark as hash key.  
So if you add 
tc filter add dev eth0 parent 1:0 protocol ip handle 1 fw
and you have a packet with mark 39, it will placed in class 1:39.

> Maybe i'm on wrong way or is it standard way for
> fairly dividing 60Mbit between users and what if i
> need to delete/add users dynamically?
> I'm newbie to this and your help is very, very
> appreciated
I think you implemented it like it should be.  Each user a class.

Stef

-- 

stef.coene@xxxxxxxxx
 "Using Linux as bandwidth manager"
     http://www.docum.org/
     #lartc @ irc.oftc.net



[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux