How to use tc to limit bandwidth of a special IP in LAN
hi,
I want to limit bandwidth of a special IP in LAN, when it upload or download from Internet through Linux server. How to use tc to do?
Thanks.
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://ds9a.nl/2.4Routing/
Quoted 2 lines · Chuanbo Xu
I want to limit bandwidth of a special IP in LAN, when it upload or download from Internet through Linux server. How to use tc to do?
The HOWTO covers this quite well:
<http://www.linuxdoc.org/HOWTO/Adv-Routing-HOWTO.html>
but there were two hiccups I encountered:
1. with "tc class" the priority must be no more than 8
2. with "tc filter" the priority must be no more than 99
Here is my setup (shortened), modify to suit:
## ROOT Class
tc qdisc add dev eth2 root handle 12: cbq bandwidth 10Mbit avpkt 1400
tc class add dev eth2 parent 12: classid 12:1 cbq bandwidth 10Mbit \
rate 10Mbit allot 1514 weight 1Mbit prio 2 maxburst 20 avpkt 1400
## FLOWs
# 192.168.2.12 (unbounded)
tc class add dev eth2 parent 12:1 classid 12:212 cbq bandwidth 10Mbit \
rate 256Kbit allot 1514 weight 25Kbit prio 5 maxburst 20 avpkt 1400
# 192.168.2.13 (bounded)
tc class add dev eth2 parent 12:1 classid 12:213 cbq bandwidth 10Mbit \
rate 64Kbit allot 1514 weight 6Kbit prio 5 maxburst 20 avpkt 1400 bounded
# unbounded class for local traffic tc class add dev eth2 parent 12:1 classid 12:300 cbq bandwidth 10Mbit \ rate 3Mbit allot 1514 weight 300Kbit prio 3 maxburst 20 avpkt 1400
## QDISCs
tc qdisc add dev eth2 parent 12:212 sfq quantum 1514b perturb 15 tc qdisc add dev eth2 parent 12:213 sfq quantum 1514b perturb 15 tc qdisc add dev eth2 parent 12:300 sfq quantum 1514b perturb 15
## FILTERs
# unbounded class (local) tc filter add dev eth2 parent 12:0 protocol ip prio 10 u32 \ match ip src 192.168.2.0/24 flowid 12:300
# bounded classes (Internet) tc filter add dev eth2 parent 12:0 protocol ip prio 20 u32 \ match ip dst 192.168.2.12 flowid 12:212 tc filter add dev eth2 parent 12:0 protocol ip prio 20 u32 \ match ip dst 192.168.2.13 flowid 12:213
I have only limited downloads. To cover uploads as well you need to do the same thing for that direction.
Signature · 8 lines
Manfred ---------------------------------------------------------------- NetfilterLogAnalyzer, NetCalc, whois at: <http://logi.cc/linux/> _______________________________________________ LARTC mailing list / [email protected] http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://ds9a.nl/2.4Routing/
Quoted 3 lines
I have spent days trying to do the most basic things with these new tools that I accomplished in hours with 2.2.x, and have made some progress but it does not have to be so difficult.
HOW DO YOU DO THIS IN 2.2.x??? I've been trying to find this info. So far, no responses from anyone here. Thanks!
Bob
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://ds9a.nl/2.4Routing/
Quoted 4 lines
tc class add dev eth1 parent 1:1 classid 1:2 cbq bandwidth 10Mbit rate 1Mbit \
allot 1514 cell 8 weight 100Kbit prio 3 maxburst 20 avpkt 1000 split 1:0 \
defmap c0
- tc : command
- class : 'owns' a part of the traffic that flows through his parent
- add : add a new class
- dev eth0 : we are working onf device eth0
- parent 1:1 : parent of this class (see also option class) number : first part is the major number (equal for all classes and
parent who belongs to each other)
second part is the minor number : uniq number
- classid 1:2 : number of the class (first number = first number of parent)
- cbq : type of class
- bandwidth 10Mbit : bandwidth of parent (should be the same for all elements with same major number)
- rate 1Mbit : bandwidth of this class
- allot 1514 cell 8 maxburst 10 avpkt 1000 : forget these options for now, just set them
- weight 100Kbit : Used to divide the traffic in the class. When you takes it 10 time less then bandwidth, everything will be fine
- split 1:0 defmap c0 : ? ? ? ? Maybe to split the traffic? I never needed this options, so I don't know what this mean. Just forget this option for now.
Quoted 2 lines
A small note on all these options would have saved me a lot of guess-work.
Better? ;-)
Quoted 3 lines
But anyway, don't take me wrong. I think that iproute2 is one of the coolest networking tools I've ever seen.
Me to, you can do great things with CBQ but it really sucks and is not accurate enough.
Quoted 9 lines
Ramin
Quoted 2 lines
-jwb
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://ds9a.nl/2.4Routing/
Signature · 7 lines
Stef More QOS info : http://users.belgacom.net/staf/ _______________________________________________ LARTC mailing list / [email protected] http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://ds9a.nl/2.4Routing/
Quoted 4 lines
tc class add dev eth1 parent 1:1 classid 1:2 cbq bandwidth 10Mbit rate 1Mbit \
allot 1514 cell 8 weight 100Kbit prio 3 maxburst 20 avpkt 1000 split 1:0 \
defmap c0
- tc : command
- class : 'owns' a part of the traffic that flows through his parent
- add : add a new class
- dev eth0 : we are working onf device eth0
- parent 1:1 : parent of this class (see also option class) number : first part is the major number (equal for all classes and
parent who belongs to each other)
second part is the minor number : uniq number
- classid 1:2 : number of the class (first number = first number of parent)
- cbq : type of class
- bandwidth 10Mbit : bandwidth of parent (should be the same for all elements with same major number)
- rate 1Mbit : bandwidth of this class
- allot 1514 cell 8 maxburst 10 avpkt 1000 : forget these options for now, just set them
- weight 100Kbit : Used to divide the traffic in the class. When you takes it 10 time less then bandwidth, everything will be fine
- split 1:0 defmap c0 : ? ? ? ? Maybe to split the traffic? I never needed this options, so I don't know what this mean. Just forget this option for now.
Quoted 2 lines
A small note on all these options would have saved me a lot of guess-work.
Better? ;-)
Quoted 3 lines
But anyway, don't take me wrong. I think that iproute2 is one of the coolest networking tools I've ever seen.
Me to, you can do great things with CBQ but it really sucks and is not accurate enough.
Quoted 9 lines
Ramin
Quoted 2 lines
-jwb
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://ds9a.nl/2.4Routing/
Signature · 8 lines
Stef More QOS info : http://users.belgacom.net/staf/ _______________________________________________ LARTC mailing list / [email protected] http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://ds9a.nl/2.4Routing/
Thanks Stef :-)
Quoted 2 lines · Stef Coene
- allot 1514 cell 8 maxburst 10 avpkt 1000 : forget these options for now, just set them
That's exactly what I meant.
Quoted 3 lines
- split 1:0 defmap c0 : ? ? ? ? Maybe to split the traffic? I never needed this options, so I don't know what this mean. Just forget this option for now.
You will never need something when you don't know of its existance ;-)
Quoted 2 lines
Quoted 1 line
A small note on all these options would have saved me a lot of guess-work.
Better? ;-)
Yes. Much better :-)
Quoted 4 lines
Quoted 2 lines
But anyway, don't take me wrong. I think that iproute2 is one of the coolest networking tools I've ever seen.
Me to, you can do great things with CBQ but it really sucks and is not accurate enough.
Why do you need accuracy when you're doing "Traffic Engineering" ;-)
Ramin
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://ds9a.nl/2.4Routing/
Quoted 19 lines · Ramin Alidousti
Thanks Stef :-)
Quoted 2 lines · Stef Coene
- allot 1514 cell 8 maxburst 10 avpkt 1000 : forget these options for now, just set them
That's exactly what I meant.
Quoted 3 lines
- split 1:0 defmap c0 : ? ? ? ? Maybe to split the traffic? I never needed this options, so I don't know what this mean. Just forget this option for now.
You will never need something when you don't know of its existance ;-)
Quoted 2 lines
Quoted 1 line
A small note on all these options would have saved me a lot of guess-work.
Better? ;-)
Quoted 8 lines
Yes. Much better :-)
Quoted 4 lines
Quoted 2 lines
But anyway, don't take me wrong. I think that iproute2 is one of the coolest networking tools I've ever seen.
Me to, you can do great things with CBQ but it really sucks and is not accurate enough.
Why do you need accuracy when you're doing "Traffic Engineering" ;-)
I did some tests : I tried to give 2 hosts a bandwidth og 128kbit/s. Host A needs 75% of this bandwidth and host B 25%. They share the same 128kbit/s so they may borrow unused bandwidth. The only way to do this is to create a qdisc on a bounded class of 128kbit/s (I tried all other things and this was the only way to get it working). On this qdisc you can attach 2 classes for the two hosts with appropriate optiones and it works perfect. Host A gets 75% of the bandwidth and they can borrow bandwidth.
BUT, the problem is the bounded class and qdisc. I did some tests and CBQ is very bad when it has to bound a class, but the problem is that you need a bounded class with his rate equal to the link-bandwidth. You can find some nice pictures on my website and they are very clear
(http://users.belgacom.net/staf/qos/tests/cbq/bounded/bounded-accuracy.html):
CBQ is not accurate when bounding a class. So it's working but not accurate enough. There are some other problems, but this the most inportant.
So if anyone out there has other results or find a solution, plz let us know. I did a lot of testing and I'm surre I didn't made a mistake. I made all the possible combinations of options, and each time it was not working like I wanted to.
Signature · 7 lines
Stef More QOS info : http://users.belgacom.net/staf/ _______________________________________________ LARTC mailing list / [email protected] http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://ds9a.nl/2.4Routing/
Quoted 19 lines · Ramin Alidousti
Thanks Stef :-)
Quoted 2 lines · Stef Coene
- allot 1514 cell 8 maxburst 10 avpkt 1000 : forget these options for now, just set them
That's exactly what I meant.
Quoted 3 lines
- split 1:0 defmap c0 : ? ? ? ? Maybe to split the traffic? I never needed this options, so I don't know what this mean. Just forget this option for now.
You will never need something when you don't know of its existance ;-)
Quoted 2 lines
Quoted 1 line
A small note on all these options would have saved me a lot of guess-work.
Better? ;-)
Quoted 8 lines
Yes. Much better :-)
Quoted 4 lines
Quoted 2 lines
But anyway, don't take me wrong. I think that iproute2 is one of the coolest networking tools I've ever seen.
Me to, you can do great things with CBQ but it really sucks and is not accurate enough.
Why do you need accuracy when you're doing "Traffic Engineering" ;-)
I did some tests : I tried to give 2 hosts a bandwidth og 128kbit/s. Host A needs 75% of this bandwidth and host B 25%. They share the same 128kbit/s so they may borrow unused bandwidth. The only way to do this is to create a qdisc on a bounded class of 128kbit/s (I tried all other things and this was the only way to get it working). On this qdisc you can attach 2 classes for the two hosts with appropriate optiones and it works perfect. Host A gets 75% of the bandwidth and they can borrow bandwidth.
BUT, the problem is the bounded class and qdisc. I did some tests and CBQ is very bad when it has to bound a class, but the problem is that you need a bounded class with his rate equal to the link-bandwidth. You can find some nice pictures on my website and they are very clear
(http://users.belgacom.net/staf/qos/tests/cbq/bounded/bounded-accuracy.html):
CBQ is not accurate when bounding a class. So it's working but not accurate enough. There are some other problems, but this the most inportant.
So if anyone out there has other results or find a solution, plz let us know. I did a lot of testing and I'm surre I didn't made a mistake. I made all the possible combinations of options, and each time it was not working like I wanted to.
Signature · 8 lines
Stef More QOS info : http://users.belgacom.net/staf/ _______________________________________________ LARTC mailing list / [email protected] http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://ds9a.nl/2.4Routing/