My linux host has two 100M eth device, but I want to limit it''s bandwidth to 1M for experiments. Then allocate 150k to EF flow, 500k to best effort flow. The script is fllowing: ------------------------------------- #/bin/sh DEV="dev eth0" echo $DEV TC="/usr/src/redhat/SOURCES/iproute2-2.4.7src/iproute2/tc/tc" $TC qdisc add $DEV handle 1:0 root dsmark indices 64 set_tc_index $TC filter add $DEV parent 1:0 protocol ip prio 1 tcindex mask 0xfc shift 2 $TC qdisc add $DEV parent 1:0 handle 2:0 cbq bandwidth 1Mbit cell 8 avpkt 1000 mpu 64 $TC class add $DEV parent 2:0 classid 2:1 cbq bandwidth 1Mbit rate 150Kbit avpkt 500 prio 1 bounded isolated allot 1514 weight 1 max burst 10 $TC qdisc add $DEV parent 2:1 pfifo limit 5 $TC filter add $DEV parent 2:0 protocol ip prio 1 handle 0x2e tcindex classid 2:1 pass_on #BE class(2:2) $TC class add $DEV parent 2:0 classid 2:2 cbq bandwidth 1Mbit rate 500Kbit avpkt 1000 prio 7 allot 1514 weight 1 maxburst 21 borrow split 2:0 defmap 0xffff $TC qdisc add $DEV parent 2:2 red limit 10KB min 1KB max 8KB burst 4 avpkt 1000 bandwidth 1Mbit probability 0.4 $TC filter add $DEV parent 2:0 protocol ip prio 2 handle 0 tcindex mask 0 classid 2:2 pass_on -------------------------------------------------------------- But I can download file from it with 40M speed. Why the limit is invalid? Please help me. Thanks. _______________________________________________ LARTC mailing list / LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
Hi, * On Thu, Aug 07, 2003 at 04:29 PM (+0800), anzp wrote:> My linux host has two 100M eth device, but I want to limit it''s > bandwidth to 1M for experiments. Then allocate 150k to EF flow, > 500k to best effort flow. > > The script is fllowing: > ------------------------------------- > #/bin/sh > > DEV="dev eth0" > echo $DEV > TC="/usr/src/redhat/SOURCES/iproute2-2.4.7src/iproute2/tc/tc" > $TC qdisc add $DEV handle 1:0 root dsmark indices 64 set_tc_index > $TC filter add $DEV parent 1:0 protocol ip prio 1 tcindex mask 0xfc shift 2 > $TC qdisc add $DEV parent 1:0 handle 2:0 cbq bandwidth 1Mbit cell 8 avpkt 1000 mpu 64Here, you should specify the physical bandwidth of your underlaying device (eth0), i.e. 100Mbit. You can''t slow down the device at this position.> $TC class add $DEV parent 2:0 classid 2:1 cbq bandwidth 1Mbit rate 150Kbit avpkt 500 prio 1 bounded isolated allot 1514 weight 1 max > burst 10 > $TC qdisc add $DEV parent 2:1 pfifo limit 5 > $TC filter add $DEV parent 2:0 protocol ip prio 1 handle 0x2e tcindex classid 2:1 pass_on > #BE class(2:2) > $TC class add $DEV parent 2:0 classid 2:2 cbq bandwidth 1Mbit rate 500Kbit avpkt 1000 prio 7 allot 1514 weight 1 maxburst 21 borrow > split 2:0 defmap 0xffff > $TC qdisc add $DEV parent 2:2 red limit 10KB min 1KB max 8KB burst 4 avpkt 1000 bandwidth 1Mbit probability 0.4 > $TC filter add $DEV parent 2:0 protocol ip prio 2 handle 0 tcindex mask 0 classid 2:2 pass_on > -------------------------------------------------------------- > > But I can download file from it with 40M speed. Why the limit is invalid?Altough you set a maximum rate of 500Kbit for the BE class, this class borrowed additional bandwidth, of course, not from your EF class (which is isolated), but from the parent qdisc, which offers 100Mbit (because the underlaying device offers that much). But, if changing the keyword "borrow" to "bounded" within your BE class, the BE class would only be using 500Kbit, even if the EF class is empty. So, I''ve added one more class to your script - so my resulting script is: ---8<------8<------8<------8<------8<------8<------8<------8<--- # Deleting old root qdisc # $TC qdisc del $DEV root # Setting up DSMARK qdisc to copy DSCP to "skb->tc_index" # $TC qdisc add $DEV handle 1:0 root dsmark indices 64 set_tc_index # Setting up filter to mask out ECN bits and to extract DSCP # $TC filter add $DEV parent 1:0 protocol ip prio 1 tcindex mask 0xfc shift 2 # Setting up inner CBQ disc # $TC qdisc add $DEV parent 1:0 handle 2:0 cbq bandwidth 100Mbit cell 8 avpkt 1000 mpu 64 # Setting up a new class to restrict over all bandwidth to 1Mbit # $TC class add $DEV parent 2:0 classid 2:1 cbq bandwidth 100Mbit rate 1Mbit avpkt 1000 \ prio 1 bounded isolated allot 1514 weight 1 maxburst 21 # EF class (2:2) # $TC class add $DEV parent 2:1 classid 2:2 cbq bandwidth 1Mbit rate 150Kbit avpkt 500 \ prio 1 bounded isolated allot 1514 weight 1 maxburst 10 # Packets within EF class are stored in a simple classless PFIFO qdisc # $TC qdisc add $DEV parent 2:2 pfifo limit 5 # Adding filter # $TC filter add $DEV parent 2:0 protocol ip prio 1 handle 0x2e tcindex classid 2:2 pass_on # BE class (2:3) # $TC class add $DEV parent 2:1 classid 2:3 cbq bandwidth 1Mbit rate 500Kbit avpkt 1000 \ prio 7 allot 1514 weight 1 maxburst 21 borrow split 2:1 defmap 0xffff # Packets within BE class are stored in a classless RED qdisc # $TC qdisc add $DEV parent 2:3 red limit 10KB min 1KB max 8KB burst 4 avpkt 1000 \ bandwidth 1Mbit probability 0.4 # Adding filter # $TC filter add $DEV parent 2:0 protocol ip prio 2 handle 0 tcindex mask 0 classid 2:3 pass_on ---8<------8<------8<------8<------8<------8<------8<------8<--- I don''t know if this way is the smartest one. But, I think it may be able to help you with your Diffserv configuration. I hope that one of the tc gurus will correct me if I am totally wrong. Best regards, Steffen _______________________________________________ LARTC mailing list / LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
On Thursday 07 August 2003 14:42, Steffen Moser wrote:> Here, you should specify the physical bandwidth of your underlaying > device (eth0), i.e. 100Mbit. You can''t slow down the device at this > position.The bandwidth parameter is used in the internal calculations of cbq and it must be the real NIC bandwidth. It has nothing to do with the bandwidth you want to manage on your link. So bandwidth paramter is 10 or 100 mbit.> Altough you set a maximum rate of 500Kbit for the BE class, this class > borrowed additional bandwidth, of course, not from your EF class (which > is isolated), but from the parent qdisc, which offers 100Mbit (because > the underlaying device offers that much).Be warned, isolated can break the cbq setup. I did some tests with cbq classes and as long as you don''t specify the isolated parameter eveything was fine.> So, I''ve added one more class to your script - so my resulting script is:I have 1 remark : the weight parameter. Take weight = rate / 10. Stef -- stef.coene@docum.org "Using Linux as bandwidth manager" http://www.docum.org/ #lartc @ irc.oftc.net _______________________________________________ LARTC mailing list / LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
Stef Coene wrote:>On Thursday 07 August 2003 14:42, Steffen Moser wrote: > > >>Here, you should specify the physical bandwidth of your underlaying >>device (eth0), i.e. 100Mbit. You can''t slow down the device at this >>position. >> >> >The bandwidth parameter is used in the internal calculations of cbq and it >must be the real NIC bandwidth. It has nothing to do with the bandwidth you >want to manage on your link. So bandwidth paramter is 10 or 100 mbit. > >How can I get the real NIC bandwidth for a particular interface through a script or code....??> > >>Altough you set a maximum rate of 500Kbit for the BE class, this class >>borrowed additional bandwidth, of course, not from your EF class (which >>is isolated), but from the parent qdisc, which offers 100Mbit (because >>the underlaying device offers that much). >> >> >Be warned, isolated can break the cbq setup. I did some tests with cbq >classes and as long as you don''t specify the isolated parameter eveything was >fine. > > > >>So, I''ve added one more class to your script - so my resulting script is: >> >> >I have 1 remark : the weight parameter. Take weight = rate / 10. > >Stef > > >_______________________________________________ LARTC mailing list / LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
Raghuveer, : How can I get the real NIC bandwidth for a particular interface through : a script or code....?? You can use mii-tool. For a brief introduction to mii-tool, see: http://linux-ip.net/html/tools-mii-tool.html -Martin -- Martin A. Brown --- SecurePipe, Inc. --- mabrown@securepipe.com _______________________________________________ LARTC mailing list / LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
Hi, * On Thu, Aug 14, 2003 at 02:31 PM (+0530), Raghuveer wrote:> How can I get the real NIC bandwidth for a particular interface through > a script or code....??I suppose, the output of "ifconfig" does not tell the real bandwidth correctly. So if you''ve got an Ethernet device you can try to use "mii-diag", which can be found at: http://www.scyld.com/diag If you want to estimate the real bandwidth of an ADSL (e.g. PPP over Ethernet) connection it will be much difficult, because you cannot determine the real speed which is mostly limited by your ISP''s settings at their edge router. HTH, Steffen _______________________________________________ LARTC mailing list / LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
Martin A. Brown wrote:>Raghuveer, > > : How can I get the real NIC bandwidth for a particular interface through > : a script or code....?? > >You can use mii-tool. For a brief introduction to mii-tool, see: > > http://linux-ip.net/html/tools-mii-tool.html >I feel it gets the interface bandwidth. How can I get the actual/real interface bandwidth, for ex: bandwidth provided by my ISP is 512kbits. So this Iam calling it as actual/real interface bandwidth. In tc whether we have to provide interface bandwidth or real/actual bandwidth....? -Raghu>-Martin > > >_______________________________________________ LARTC mailing list / LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
Raghuveer wrote:> I feel it gets the interface bandwidth.yes, it does. you need the interface bandwidth for the cbq qdisc: http://lartc.org/howto/lartc.qdisc.classful.html#AEN935> How can I get the actual/real > interface bandwidth, for ex: bandwidth provided by my ISP is 512kbits.You can''t really. unless you''ve got a internal DSL card, or want to write a script/program to do a test downloads and uploads to try and find the max speeds.> So this Iam calling it as actual/real interface bandwidth. In tc whether > we have to provide interface bandwidth or real/actual bandwidth....?it depends where you''re using it. different qdiscs/classes use different things. -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Damion de Soto - Software Engineer email: damion@snapgear.com SnapGear --- ph: +61 7 3435 2809 | Custom Embedded Solutions fax: +61 7 3891 3630 | and Security Appliances web: http://www.snapgear.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _______________________________________________ LARTC mailing list / LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
Hi Damion, * On Tue, Aug 19, 2003 at 09:41 AM (+1000), Damion de Soto wrote:> Raghuveer wrote: > > >I feel it gets the interface bandwidth. > > yes, it does. > you need the interface bandwidth for the cbq qdisc: > http://lartc.org/howto/lartc.qdisc.classful.html#AEN935Given a 10 Mbit/s ethernet device (eth0) which is used to establish a PPP over ethernet (PPPoE) connection (ppp0) to a broadband ISP (e.g. using ADSL, SDSL and so on as an underlaying system). If I then want to shape the traffic I send to the "ppp0" interface, which bandwidth would be used for setting up a CBQ? I suppose that here the "virtual" (e.g. limited by the ISP) bandwidth of my "ppp0" connection (e.g. 128 kbit/s) is the interesting one, not the bandwidth of my "eth0" (10 Mbit/s), because the CBQ is attached to the "ppp0" device and has nothing to do with the underlaying "eth0". Is this assumption correct? TIA, Steffen _______________________________________________ LARTC mailing list / LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
Damion de Soto wrote:> Raghuveer wrote: > >> I feel it gets the interface bandwidth. > > yes, it does. > you need the interface bandwidth for the cbq qdisc: > http://lartc.org/howto/lartc.qdisc.classful.html#AEN935 > >> How can I get the actual/real interface bandwidth, for ex: bandwidth >> provided by my ISP is 512kbits. > > You can''t really. unless you''ve got a internal DSL card, or want to > write a script/program to do a test downloads and uploads to try and > find the max speeds. > >> So this Iam calling it as actual/real interface bandwidth. In tc >> whether we have to provide interface bandwidth or real/actual >> bandwidth....? > > it depends where you''re using it. > different qdiscs/classes use different things. > >Can you please tell me for HTB and CBQ what bandwidth should I use whether interface bandwidth or real/actual bandwidth....? Regards -Raghu _______________________________________________ LARTC mailing list / LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
Steffen Moser and Raghuveer wrote: SM> If I then want to shape the traffic I send to the "ppp0" interface, SM> which bandwidth would be used for setting up a CBQ? SM> SM> I suppose that here the "virtual" (e.g. limited by the ISP) bandwidth SM> of my "ppp0" connection (e.g. 128 kbit/s) is the interesting one, not SM> the bandwidth of my "eth0" (10 Mbit/s), because the CBQ is attached SM> to the "ppp0" device and has nothing to do with the underlaying "eth0". SM> SM> Is this assumption correct? no. SM> SM> TIA, SM> Steffen R> R> Can you please tell me for HTB and CBQ what bandwidth should I use whether R> interface bandwidth or real/actual bandwidth....? R> Regards R> -Raghu as it says in the HOW-TO, the cbq device uses the ethernet speed (bandwidth) for idle time calculations. so when you create a cbq qdisc, it needs to know either 10mbit or 100mbit. you then use the ''interesting'' DSL/ISP speeds for the classes. htb qdiscs don''t need to know any speeds. regards. -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Damion de Soto - Software Engineer email: damion@snapgear.com SnapGear --- ph: +61 7 3435 2809 | Custom Embedded Solutions fax: +61 7 3891 3630 | and Security Appliances web: http://www.snapgear.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _______________________________________________ LARTC mailing list / LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
Thanks Damion, I would like to re-confirm the last few days discussion. ------------------ Private --------| eth1 eth0 |-------Internet ipaddresses | | ------------------ Linux firewall 1. For shaping the incomming and outgoing traffic at eth0 I can use IMQ + HTB/CBQ with NAT(--set-mark option). 2. Another way I can shape the incomming and outgoing traffic is : incomming traffic at eth1 interface with CBQ/HTB and outgoing traffic at eth0 with CBQ/HTB with NAT(--set-mark option). 3. For CBQ I can use the interface bandwidth(using ethtool or mii-diag) and ''interesting'' DSL/ISP speeds for the classes. 4. HTB qdiscs don''t need to know any speeds. Any suggestions and help is invaluably appreciated. Regards -Raghu Damion de Soto wrote:> Steffen Moser and Raghuveer wrote: > > SM> If I then want to shape the traffic I send to the "ppp0" interface, > SM> which bandwidth would be used for setting up a CBQ? > SM> > SM> I suppose that here the "virtual" (e.g. limited by the ISP) bandwidth > SM> of my "ppp0" connection (e.g. 128 kbit/s) is the interesting one, not > SM> the bandwidth of my "eth0" (10 Mbit/s), because the CBQ is attached > SM> to the "ppp0" device and has nothing to do with the underlaying > "eth0". > SM> > SM> Is this assumption correct? > no. > SM> > SM> TIA, > SM> Steffen > R> > R> Can you please tell me for HTB and CBQ what bandwidth should I use > whether > R> interface bandwidth or real/actual bandwidth....? > R> Regards > R> -Raghu > > as it says in the HOW-TO, the cbq device uses the ethernet speed > (bandwidth) for idle time calculations. so when you create a cbq > qdisc, it needs to know either 10mbit or 100mbit. > you then use the ''interesting'' DSL/ISP speeds for the classes. > > htb qdiscs don''t need to know any speeds. > > regards. >_______________________________________________ LARTC mailing list / LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
Raghuveer, : I would like to re-confirm the last few days discussion. Good summary. : 1. For shaping the incomming and outgoing traffic at eth0 I can use : IMQ + HTB/CBQ with NAT(--set-mark option). : 2. Another way I can shape the incomming and outgoing traffic is : : incomming traffic at eth1 interface with CBQ/HTB and outgoing : traffic at eth0 with CBQ/HTB with NAT(--set-mark option). Yes and yes. : 3. For CBQ I can use the interface bandwidth(using ethtool or : mii-diag) and ''interesting'' DSL/ISP speeds for the classes. Yes, to reiterate Stef''s posting of earlier today..... CBQ "bandwidth" (parameter) must be the speed of the real device. 10Base-T card? Use 10mbit. 100Base-T card? Use 100mbit. CBQ "rate" (parameter) is the desired rate. This is the bandwidth "speed" knob. Traffic you transmit will be shaped to this rate. : 4. HTB qdiscs don''t need to know any speeds. Sort of. If you mean that HTB qdiscs need no knowledge of the real device speed, that is accurate. HTB uses tokens (replenished at rate) to determine the rate at which packets will be dequeued. It seems to me that you have accurately understood and restated the discussion. Best of luck, -Martin -- Martin A. Brown --- SecurePipe, Inc. --- mabrown@securepipe.com _______________________________________________ LARTC mailing list / LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
Martin A. Brown wrote:>Raghuveer, > > : I would like to re-confirm the last few days discussion. > >Good summary. > > : 1. For shaping the incomming and outgoing traffic at eth0 I can use > : IMQ + HTB/CBQ with NAT(--set-mark option). > : 2. Another way I can shape the incomming and outgoing traffic is : > : incomming traffic at eth1 interface with CBQ/HTB and outgoing > : traffic at eth0 with CBQ/HTB with NAT(--set-mark option). > >Yes and yes. > > : 3. For CBQ I can use the interface bandwidth(using ethtool or > : mii-diag) and ''interesting'' DSL/ISP speeds for the classes. > >Yes, to reiterate Stef''s posting of earlier today..... > > CBQ "bandwidth" (parameter) > must be the speed of the real device. > 10Base-T card? Use 10mbit. > 100Base-T card? Use 100mbit. > > CBQ "rate" (parameter) > is the desired rate. > This is the bandwidth "speed" knob. Traffic you transmit > will be shaped to this rate. > > : 4. HTB qdiscs don''t need to know any speeds. > >Sort of. If you mean that HTB qdiscs need no knowledge of the real device >speed, that is accurate. HTB uses tokens (replenished at rate) to >determine the rate at which packets will be dequeued. > >It seems to me that you have accurately understood and restated the >discussion. > >Best of luck, > >Thanks Martin.>-Martin > > >_______________________________________________ LARTC mailing list / LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/