Hi, I wished to shape the traffic that cross my ppp0 interface so I asked around and google''d a bit and I headed in the LARTC HOWTO. As stated in the early in the text, as the title implies, that is an "Advanced" HOWTO and while by no means rocket science, some prior knowledge is assumed. Unfortunately I found myself lost very soon and I''m writing here in hope of some help. What I''d like to do, if it were possible with some iptables switch, would be something like the following. iptables --insert INPUT --in-interface ppp0 \ --protocol tcp --destination-port 80 \ --source $SOMEIPADDRESS \ --jump SHAPING --limit-to 10KBs Of course the last line is pure fiction =) but I thought it would have explained what I wished to do pretty well. Shaping the traffic according to some --source switch isn''t a priority at the moment but it would be nice to, anyhow. After some reading I found out that what I wished to do is very likely called "traffic shaping". So I searched the text for "shaping" and I found a note saying that, if all I wanted to do is simple traffic shaping, I could have skipped everything and headed to the Other possibilities chapter, and readed about CBQ.init. Unforntunately, as stated below, by all means CBQ.init is useful if the ''how and why'' don''t interest me, but they do, actually. I tried both the CBQ.init and the HTB.init scripts but they were huge, I wasn''t able to understand them and I didn''t managed to find any information about how to configure the kernel. Of course, I could check out everything in the QoS section in menuconfig during the kernel configuration but I''d like to understand which support I would actually use. At least, after having tried to read them, I realized that, if I understood well, what I wish to do should be possible only using tc, not iptables. Could you please help me to find out which commands to type and how to configure the kernel in order to accomplish my task? I''d need something in the middle between the "rocket science" of LARTC and the "how and why don''t interest you" of CBQ.init. Scuse me if some of my questions are FAQs. Thanks in advance. Best regards. -- Value your freedom, or you will lose it, teaches history. ``Don''t bother us with politics,'''' respond those who don''t want to learn. -- Richard M. Stallman http://www.gnu.org/philosophy/linux-gnu-freedom.html
Antonio Luiz
2004-Nov-25 18:46 UTC
RES: kernel configuration and tc commands for traffic shaping
You can try this (adapted from http://www.knowplace.org/shaper/examples.html): tc qdisc add dev ppp0 root handle 1: htb default 60 tc class add dev ppp0 parent 1:1 classid 1:10 htb rate 10kbit ceil $MAXSPEEDkbit prio 0 tc filter add dev ppp0 protocol ip parent 1:0 protocol ip prio 1 u32 \ match ip dport 80 0xffff \ match ip src $SOMEIPADDRESS \ police rate 10kbit flowid 1:10 Antonio Luiz> -----Mensagem original----- > De: lartc-admin@mailman.ds9a.nl > [mailto:lartc-admin@mailman.ds9a.nl] Em nome de ncrfgs > Enviada em: quinta-feira, 25 de novembro de 2004 14:17 > Para: lartc@mailman.ds9a.nl > Assunto: [LARTC] kernel configuration and tc commands for > traffic shaping > > > Hi, > > I wished to shape the traffic that cross my ppp0 interface > so I asked around and google''d a bit and I headed in the > LARTC HOWTO. > > As stated in the early in the text, as the title implies, > that is an "Advanced" HOWTO and while by no means rocket > science, some prior knowledge is assumed. > > Unfortunately I found myself lost very soon and I''m > writing here in hope of some help. > > > What I''d like to do, if it were possible with some > iptables switch, would be something like the following. > > iptables --insert INPUT --in-interface ppp0 \ > --protocol tcp --destination-port 80 \ > --source $SOMEIPADDRESS \ > --jump SHAPING --limit-to 10KBs > > Of course the last line is pure fiction =) but I thought > it would have explained what I wished to do pretty well. > > Shaping the traffic according to some --source switch > isn''t a priority at the moment but it would be nice to, > anyhow. > > > After some reading I found out that what I wished to do > is very likely called "traffic shaping". So I searched > the text for "shaping" and I found a note saying that, if > all I wanted to do is simple traffic shaping, I could have > skipped everything and headed to the Other possibilities > chapter, and readed about CBQ.init. > > Unforntunately, as stated below, by all means CBQ.init is > useful if the ''how and why'' don''t interest me, but they > do, actually. > > I tried both the CBQ.init and the HTB.init scripts but > they were huge, I wasn''t able to understand them and I > didn''t managed to find any information about how to > configure the kernel. > > Of course, I could check out everything in the QoS section > in menuconfig during the kernel configuration but I''d like > to understand which support I would actually use. > > > At least, after having tried to read them, I realized > that, if I understood well, what I wish to do should be > possible only using tc, not iptables. > > > Could you please help me to find out which commands to > type and how to configure the kernel in order to > accomplish my task? > > I''d need something in the middle between the "rocket > science" of LARTC and the "how and why don''t interest you" > of CBQ.init. > > > > Scuse me if some of my questions are FAQs. > > Thanks in advance. > > Best regards. > -- > Value your freedom, or you will lose it, teaches history. > ``Don''t bother us with politics,'''' respond those who don''t > want to learn. > > -- Richard M. Stallman > http://www.gnu.org/philosophy/linux-gnu-freedom.html >_______________________________________________ LARTC mailing list / LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
Axel aghi Hollanda
2004-Nov-25 18:54 UTC
Re: kernel configuration and tc commands for traffic shaping
Hi, First of all, you have to know what you really want. What discipline will you use, what kind of filtering you''ll implement. Such simple and not abstract questions will have the answers in the LARTC document if you read it profusely. CBQ or HTB? (I''d prefer HTB myself). u32 or FWMARK? Then you''ll know which kernel options are to be set and which tools you''ll need: iproute2 tc tool and iptables or just iptables. After that, everything will be just syntax and logics. On Thu, 25 Nov 2004 18:17:09 +0100, ncrfgs <ncrfgs@tin.it> wrote:> Hi, > > I wished to shape the traffic that cross my ppp0 interface > so I asked around and google''d a bit and I headed in the > LARTC HOWTO. > > As stated in the early in the text, as the title implies, > that is an "Advanced" HOWTO and while by no means rocket > science, some prior knowledge is assumed. > > Unfortunately I found myself lost very soon and I''m > writing here in hope of some help. > > What I''d like to do, if it were possible with some > iptables switch, would be something like the following. > > iptables --insert INPUT --in-interface ppp0 \ > --protocol tcp --destination-port 80 \ > --source $SOMEIPADDRESS \ > --jump SHAPING --limit-to 10KBs > > Of course the last line is pure fiction =) but I thought > it would have explained what I wished to do pretty well. > > Shaping the traffic according to some --source switch > isn''t a priority at the moment but it would be nice to, > anyhow. > > After some reading I found out that what I wished to do > is very likely called "traffic shaping". So I searched > the text for "shaping" and I found a note saying that, if > all I wanted to do is simple traffic shaping, I could have > skipped everything and headed to the Other possibilities > chapter, and readed about CBQ.init. > > Unforntunately, as stated below, by all means CBQ.init is > useful if the ''how and why'' don''t interest me, but they > do, actually. > > I tried both the CBQ.init and the HTB.init scripts but > they were huge, I wasn''t able to understand them and I > didn''t managed to find any information about how to > configure the kernel. > > Of course, I could check out everything in the QoS section > in menuconfig during the kernel configuration but I''d like > to understand which support I would actually use. > > At least, after having tried to read them, I realized > that, if I understood well, what I wish to do should be > possible only using tc, not iptables. > > Could you please help me to find out which commands to > type and how to configure the kernel in order to > accomplish my task? > > I''d need something in the middle between the "rocket > science" of LARTC and the "how and why don''t interest you" > of CBQ.init. > > Scuse me if some of my questions are FAQs. > > Thanks in advance. > > Best regards. > -- > Value your freedom, or you will lose it, teaches history. > ``Don''t bother us with politics,'''' respond those who don''t > want to learn. > > -- Richard M. Stallman > http://www.gnu.org/philosophy/linux-gnu-freedom.html > > >-- Aghi <ahollanda % gmail dot com> _______________________________________________ LARTC mailing list / LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
ncrfgs
2004-Nov-26 11:18 UTC
Re: RES: kernel configuration and tc commands for traffic shaping
On Thu, Nov 25, 2004 at 03:46:32PM -0300, Antonio Luiz wrote:> You can try this (adapted from > http://www.knowplace.org/shaper/examples.html): > > tc qdisc add dev ppp0 root handle 1: htb default 60 > tc class add dev ppp0 parent 1:1 classid 1:10 htb rate 10kbit ceil \ > $MAXSPEEDkbit prio 0 > tc filter add dev ppp0 protocol ip parent 1:0 protocol ip prio 1 u32 \ > match ip dport 80 0xffff \ > match ip src $SOMEIPADDRESS \ > police rate 10kbit flowid 1:10Very useful link and code. I changed it a bit, though. This is what I used. tc qdisc add dev ppp0 root handle 1: htb tc class add dev ppp0 parent 1: classid 1:1 htb rate $MAXSPEEDkbit iptables --table mangle --insert POSTROUTING \ --protocol tcp \ --source $IPADDRESS --destination-port 80 \ --jump CLASSIFY --set-class 1:1 Here are some consideration, though. - Isn''t ''default'' supposed to suggest a default subclass id? What does the 60 in your ''tc qdisc'' line refer to? - The parent you specified in ''tc class'' line'' doesn''t exist as far as I understood. If I type that command it seems to work anyhow. What am I missing? - What does the parent in your ''tc filter'' line refer to? - I assume $MAXSPEED is the speed you that traffic to be shaped like. I used ''rate $MAXSPEEDkbit'' instead of ''rate 10kbit ceil $MAXSPEEDkbit'' and it seems to work. What is the difference betweem these two versions? - Instead of the ''tc filter'' line I used a iptables rule. This way I was able to add to the kernel just the HTB support. Otherwise as far as I understood I would have had to add other filter related things. Furthermore http://www.knowplace.org/shaper/ suggests to use iptables CLASSIFY when possible. What do you think about it? What are the advantages and disadvantage of the approaches reported? 1) tc filter 2) iptables marking with tc filter 3) iptables classify Personally I love the third. It''s very human readable and, if I understood well, once you set a class with the same name on every interface, with iptables you can use just a single line to filter all the packets while with tc filter you would have to specify a filter for every single interface. - Why did you use a source-ip/destination-port combination instead of a destination-ip/source-port one? Thanks in advance. Best regards. -- Value your freedom, or you will lose it, teaches history. ``Don''t bother us with politics,'''' respond those who don''t want to learn. -- Richard M. Stallman http://www.gnu.org/philosophy/linux-gnu-freedom.html
Jason Boxman
2004-Nov-29 02:44 UTC
Re: kernel configuration and tc commands for traffic shaping
On Thursday 25 November 2004 12:17, ncrfgs wrote:> Hi, ><snip>> I''d need something in the middle between the "rocket > science" of LARTC and the "how and why don''t interest you" > of CBQ.init. >You could always check out my Linux traffic control guide[1]. [1] http://trekweb.com/~jasonb/articles/traffic_shaping/> > Scuse me if some of my questions are FAQs. > > Thanks in advance. > > Best regards.-- Jason Boxman Perl Programmer / *NIX Systems Administrator Shimberg Center for Affordable Housing | University of Florida http://edseek.com/ - Linux and FOSS stuff _______________________________________________ LARTC mailing list / LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/