[LARTC] Shaping multiple subnets that have same traffic types..

Linux Advanced Routing and Traffic Control

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

 



Hi All,

I have a box running as a bridge between our local network and the router
which services the connections to our two branch offices.  I want to shape
the traffic going to the two branches, so that email and web surfing no
longer hog the connection.  I'm not 100% sure about the filter matching to
use for the shaping though because both branches have the same traffic
types, but are on two different subnets..

Branch 1 has a 64kbps link, while Branch 2 has 128kbps.  The unusual figures
I've given for the ceilings below are alowing for the compression in the
routers (runs an average of about 1.3:1)

Diagram:

                                                    Local Network
(172.16.1.0)
                                                                    |
                                                                eth0
                                                    Linux Bridge/Shaper
                                                                eth1
                                                                    |
                                                               Router
                                                                |        |
                                                                /        \
                                                        64kbps    128kbps
                                                    172.16.2.0    172.16.3.0

The traffic classification I want is something like:

                                                                    |   root
(1:)
                                                                    |
                                                                    |
(1:1) 10Mbit
                                                                   /|\
                                                                  / | \
                                                                /   |   \
                                                              /(1:50)\
                                                            /              \
                                                1:10  /                  \
1:20
                                                        /\
/\
                                                      /    \               /
\
                                          2:10  /        \           /
\  3:20
                                                             |           \
                                                    2:20 |            | 3:10

And the tc setup script would be something like:

TC=/sbin/tc
$TC qdisc del dev eth1 root 2>/dev/null >/dev/null
$TC qdisc add dev eth1 root handle 1: htb default 50

$TC class add dev eth1 parent 1: classid 1:1 htb rate 10Mbit ceil 10Mbit
burst 8k

$TC class add dev eth1 parent 1:1 classid 1:10 htb rate 64k ceil 88k burst
4k prio 1
$TC class add dev eth1 parent 1:1 classid 1:20 htb rate 128k ceil 168k burst
4k prio 1
$TC class add dev eth1 parent 1:1 classid 1:50 htb rate 32k ceil 48k burst
2k prio 1

$TC class add dev eth1 parent 1:10 classid 2:10 htb rate 48k ceil 72k burst
2k prio 1
$TC class add dev eth1 parent 1:10 classid 2:20 htb rate 16k ceil 36k burst
2k prio 2

$TC class add dev eth1 parent 1:20 classid 3:10 htb rate 96k ceil 144k burst
2k prio 1
$TC class add dev eth1 parent 1:20 classid 3:20 htb rate 32k ceil 56k burst
2k prio 2

$TC filter add dev eth1 parent 1:0 protocol ip prio 1 u32 match ip dst
172.16.2.0/24 flowid 1:10
$TC filter add dev eth1 parent 1:0 protocol ip prio 1 u32 match ip dst
172.16.3.0/24 flowid 1:20

$TC filter add dev eth1 parent 1:0 protocol ip prio 1 u32 match ip dst
172.16.2.0/24 match ip sport 3389 0xffff flowid 2:10
$TC filter add dev eth1 parent 1:0 protocol ip prio 1 u32 match ip dst
172.16.2.0/24 match ip dport 515 0xffff flowid 2:10
$TC filter add dev eth1 parent 1:0 protocol ip prio 2 u32 match ip dst
172.16.2.0/24 match ip sport 80 0xffff flowid 2:20
$TC filter add dev eth1 parent 1:0 protocol ip prio 2 u32 match ip dst
172.16.2.0/24 match ip sport 110 0xffff flowid 2:20
$TC filter add dev eth1 parent 1:0 protocol ip prio 2 u32 match ip dst
172.16.2.0/24 match ip sport 3128 0xffff flowid 2:20

$TC filter add dev eth1 parent 1:0 protocol ip prio 1 u32 match ip dst
172.16.3.0/24 match ip sport 3389 0xffff flowid 3:10
$TC filter add dev eth1 parent 1:0 protocol ip prio 1 u32 match ip dst
172.16.3.0/24 match ip dport 515 0xffff flowid 3:10
$TC filter add dev eth1 parent 1:0 protocol ip prio 2 u32 match ip dst
172.16.3.0/24 match ip sport 80 0xffff flowid 3:20
$TC filter add dev eth1 parent 1:0 protocol ip prio 2 u32 match ip dst
172.16.3.0/24 match ip sport 110 0xffff flowid 3:20
$TC filter add dev eth1 parent 1:0 protocol ip prio 2 u32 match ip dst
172.16.3.0/24 match ip sport 3128 0xffff flowid 3:20

Does this look right ??  Have I got this completely wrong ??
My only question is about the filters - if I attach them all to the root,
then the first level filters are going to catch everything and I wont be
able to split the traffic types off into the different speed bands..  Is it
now possible to attach my 2nd level filters to the likes of 1:10 and 1:20
instead??  If so, then do I need to match the dst ip again or is that
unneccessary?

Apologies for the long post.

Regards,
Daniel.





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