Krzysztof Matusik
2004-Jul-30 01:08 UTC
notes&questions: filter, HTB, hfsc & tc binary,ifs tx ques
Hello
I''ve been messing with traffic controlling for some time and
encountered
singularities I''d like to talk about.
First explaining of my pow (can''t tell how much each point is relevant)
Box with Debian, Intel PII*2 old and fancy:), ADSL link with dyn IP,
some servers (f. ex. squid), loc net with dhcp, (although IP statically
given by
MAC); MASQ.
Such circumstances made me make a script which involves:
-recalculation in each ppp up/down (dynamic IP)
-filter rules/link sharing depending on list of local hosts (also used by
dhcp)
-sharing bandwidth with traffic to/generated by server box
So we''ve got imq (from http://pupa.da.ru/- simple and stable as far as
I''m
using it) for download sharing and shaping,
also ''iptables PREROUTING MARK'' and ''tc filter
fw'' for do the same for
upload (am I right that u32 can''t do it?);
else is done with HTB and u32.
Each host has its own (including the router- mentioned above) HTB parent
class where fw filter puts flow,
in that class are attached interactive prio and bulk subclasses
and filters, for example:
tcaddcls parent 1:1 htb rate $(($UPLOAD/$NUM_HOSTS)) ceil $NUM_HOSTS prio
0
tcfltadd parent 1:${parent_id} prio 2 u32 \
match ip protocol 6 0xff \
match u8 0x05 0x0f at 0 \
match u16 0x0000 0xffc0 at 2 \
match u8 0x11 0xff at 33 \
flowid 1:${CL_ID}
and it works great!!! .debs for buddys created at my repository.
So what''s mail for?:-)
Issues:
Yesterday I''ve read somewhere (don''t remeber) that HTB
can''t have filters
attached to classes except root (and leaves?). BUT IT WORKS. ???
Confused, I listed filters: all attached to 1: but with many different
handles like:
filter parent 1: protocol ip pref 1 fw handle 0x1 classid 1:11
filter parent 1: protocol ip pref 2 u32 fh 800::800 order 2048 key ht 800
bkt 0 flowid 1:11 (matches)
filter parent 1: protocol ip pref 2 u32 fh 801::802 order 2050 key ht 801
bkt 0 flowid 1:11 (matches)
Maybe provided info explains all but for me all of it works magically ;)
I''d like to know what mean above params- I understand them only
intuitively now (by means of reading HOWTO chapter about hashing).
I mean: do ''tc filter show dev'' listing (which part I
presented) can
explain how really filtering works in this situation? (a way how packets
are directed into and from the classes?)
I must decrease link throughput a bit to avoid latencies.
Problem is that sometimes link is saturated at 170kbit, sometimes at
150kbit.
That ppp link is on pppoa; max throughput is correlated with packet/s
ratio, as i noticed (using iptraf). Am I right? How to deal with it?
Using
#ifconfig $iface txqueulen $n affects latency.
What else (for e. dropping)? How to choose best value?
Furthermore, couple of days ago I wondered about HFSC. I''ve collected
infos and ''stuff'' (it''s messy; I still have
questions, not with hfsc idea
itself though; I''ve read all of trash.net and proposed places, BSD altq
man- which hfsc differs I guess and some discussions here from archives).
The same ''trick'' with filters as in HTB doesn''t
working.
Creating more hfsc qdiscs, directing packets to them with fw filter, and
directing back to classes at root with u32 doesn''t working neither.
(well, I''m not absolutely sure, I haven''t played much).
I''ve been compiling iproute-ss040702 and it haven''t done well.
Some compilation errors at atm.h, l:235 with ''void __user''.
Using kernel-headers-2.6.7-1-686-smp.
Such made tc binary print deranged ''tc show class'' but seems
working well.
It''s got problems with hfsc too- anyone can tell me does that iproute
version work well with hfsc? (supposing correct compilation) Does it have
patch from trash.net?
it would be lovely to have some help
:-)
Krzysiek, kyf@arterm.pl
_______________________________________________
LARTC mailing list / LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
hello list, i''ve got a small question related to tc and rrd. my problem is as follows. i''ve written a small c app that takes the stats of tc using libs from iproute2 package and outputs a shell script that updates rrd files (2 ds: 1 gauge for speed, 1 counter for sent). i''ve followed the manuals from tobi''s website on how to create and update the database. the dump is quite curious even after a hole day of updating (every 5 min). can anyone here share his/hers experience with these tools. any links or resources maybe even some example code are very welcome. thanks _______________________________________________ LARTC mailing list / LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
Basicaly it is easy to use rrd tool, the hardest part for me was to setup
rrd database correctly
here is example
RRDs::create("$rrd","-s",$period,
"DS:TR:GAUGE:300:0:U",
"RRA:AVERAGE:0.5:1:1440", # 0.5- uaualy leave as is
: 1-
for first entry use 1 :1440 number of points
"RRA:AVERAGE:0.5:15:3072"); #: 0.5: 15 needs 15 updates
to
create one average database entry :3072
Complete example for perl, probably will be good for you too. have
resolution of 1 min for 1 day and 15 min resolution for 1 month. uopdates
should be done each minute
$time=time;
$rrd="./data/$ip.rrd"; #$rrd is filename
if (!(-e "$rrd")) { print "creating $rrd\n";
RRDs::create("$rrd","-s",$period,
"DS:TR:GAUGE:300:0:U",
"RRA:AVERAGE:0.5:1:1440",
"RRA:AVERAGE:0.5:15:3072");
if (my $error=RRDs::error()) {print "Cannot create $rrd:
$error\n";}
}
RRDs::update("$rrd","$time:$tr"); # $tr is the data
you want to add to
database
if (my $error=RRDs::error()) {print "Cannot update $rrd: $error\n";}
}
##################
example for view script. shows load graph and total traffic per $period
$period is in seconds
$period=3600*24; #(for one day)
$start=time-$period; #starts from current time.
$rrd="./data/$ip.rrd";
RRDs::graph
("$cache/$name.png","--start=$start","--width=720",
"DEF:d=$rrd:TR:AVERAGE",
"CDEF:down=d,UN,0,d,IF,$period,*",
"LINE1:d#6600cc",
"GPRINT:down:AVERAGE:%1.1lf%sB Download",
);
if (my $error=RRDs::error()) {print "Cannot graph $rrd:
$error\n";}
print "<img src=\"$cache/$name.png\"> \n";
print "$name $ip<br>\n";
}
----- Original Message -----
From: <adi@tettas.net>
To: <lartc@mailman.ds9a.nl>
Sent: Friday, July 30, 2004 12:21 PM
Subject: [LARTC] tc & rrd question
> hello list,
> i''ve got a small question related to tc and rrd.
>
> my problem is as follows. i''ve written a small c app that takes
the stats
> of tc using libs from iproute2 package and outputs a shell script that
> updates rrd files (2 ds: 1 gauge for speed, 1 counter for sent).
i''ve
> followed the manuals from tobi''s website on how to create and
update the
> database. the dump is quite curious even after a hole day of updating
> (every 5 min).
>
> can anyone here share his/hers experience with these tools. any links or
> resources maybe even some example code are very welcome.
>
> thanks
> _______________________________________________
> LARTC mailing list / LARTC@mailman.ds9a.nl
> http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
>
_______________________________________________
LARTC mailing list / LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
that''s what i did.. rrdtool dump (or fetch) ... gives me only nan''s in the dump i see in <last ds> (?) an extended value (eg. 4.000000e+10) but for AVERAGE, MIN, MAX i get only nan. which is weird. the only diffs i see between my implementation and roys'' is that he uses perl extensions and i use shell script outputted by a c program that gathers data from tc and compares the classes with a config file to get the name of the clients. my program is an extension to htb-utils. On Sat, 2004-07-31 at 02:58, Tadas wrote:> I dont see anything wrong with your script, > but you did not show the part which displays graphs. > > For testing you can try to dump your database as xml it helps to test if > you create and update it correctly. > if all data is good, then you are incorrectly displaying it. > > > > ----- Original Message ----- > From: "Adrian Vasile" <adi@tettas.net> > To: "Roy" <roy@xxx.lt> > Sent: Saturday, July 31, 2004 2:20 AM > Subject: Re: [LARTC] tc &amp; rrd question > > > > thanks for the info. i''ll try implementing it as soon as > > possible. > > > > i''ve been using this line: for creating the db''s: > > > > $RRDTOOL create /var/rrd/eth0/upload.rrd \ > > DS:Speed:GAUGE:600:0:U \ > > DS:Bytes:COUNTER:600:0:U \ > > RRA:AVERAGE:0.5:1:288 > > RRA:MIN:0.5:1:24 \ > > RRA:MAX:0.5:1:24 > > i see some diffs i don''t set the step size (man page says default is 300 > > aka 5min) and heartbeat double. the avg is set to 24h with 12 points per > > hour.i realize it''s not too exact but for testing purposes works :) > > Do you log only last 24 points of min and max? > > if you want one point per hour you should use > 60min/5min =12 > RRA:MIN:0.5:12:24 > > > > > > and i use crontab to periodically run the update script: > > > > $RRDTOOL update /var/rrd/eth0/upload.rrd N:57:1202599 > > i use N: for now time (as per the man page) > > > > the problem appears when i fetch the data i get only ''nan''. i''m thinking > > that i may be putting the data the wrong way or something but i''ve been > > hitting a stone wall searching on this problem (docs, mailing lists). > > > > On Fri, 2004-07-30 at 16:53, Roy wrote: > > > Basicaly it is easy to use rrd tool, the hardest part for me > > was to setup > > > rrd database correctly > > > here is example > > > > > > RRDs::create(''"''$rrd''"'',''"''-s''"'',$period, > > > ''"''DS:TR:GAUGE:300:0:U''"'', > > > ''"''RRA:AVERAGE:0.5:1:1440''"'', # 0.5- > > uaualy leave as is : 1- > > > for first entry use 1 :1440 number of points > > > ''"''RRA:AVERAGE:0.5:15:3072''"''); #: 0.5: 15 > > needs 15 updates to > > > create one average database entry :3072 > > > > > > > > > Complete example for perl, probably will be good for you too. > > have > > > resolution of 1 min for 1 day and 15 min resolution for 1 > > month. uopdates > > > should be done each minute > > > $time=time; > > > $rrd=''"''./data/$ip.rrd''"''; #$rrd is filename > > > if (!(-e ''"''$rrd''"'')) { print ''"''creating > > $rrd\n''"''; > > > > > RRDs::create(''"''$rrd''"'',''"''-s''"'',$period, > > > ''"''DS:TR:GAUGE:300:0:U''"'', > > > ''"''RRA:AVERAGE:0.5:1:1440''"'', > > > ''"''RRA:AVERAGE:0.5:15:3072''"''); > > > if (my $error=RRDs::error()) {print ''"''Cannot create > > $rrd: $error\n''"'';} > > > } > > > > > > RRDs::update(''"''$rrd''"'',''"''$time:$tr''"''); # > > $tr is the data you want to add to > > > database > > > > > > if (my $error=RRDs::error()) {print ''"''Cannot update $rrd: > > $error\n''"'';} > > > > > > } > > > ################## > > > example for view script. shows load graph and total traffic per > > $period > > > $period is in seconds > > > > > > $period=3600*24; #(for one day) > > > > > > $start=time-$period; #starts from current time. > > > $rrd=''"''./data/$ip.rrd''"''; > > > RRDs::graph > > (''"''$cache/$name.png''"'',''"''--start=$start''"'',''"''--width=720''"'', > > > ''"''DEF:d=$rrd:TR:AVERAGE''"'', > > > ''"''CDEF:down=d,UN,0,d,IF,$period,*''"'', > > > ''"''LINE1:d#6600cc''"'', > > > ''"''GPRINT:down:AVERAGE:%1.1lf%sB Download''"'', > > > ); > > > > > > if (my $error=RRDs::error()) {print ''"''Cannot graph > > $rrd: $error\n''"'';} > > > > > > print ''"''<img src=\''"''$cache/$name.png\''"''> > > \n''"''; > > > print ''"''$name $ip<br>\n''"''; > > > } > > > > > > > > > > > > > > > > > > > > > > > > > > > ----- Original Message ----- > > > From: http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: > http://lartc.org/ > > > > > > > > > > _______________________________________________ > > > LARTC mailing list / LARTC@mailman.ds9a.nl > > > http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/ > > > > > > > > >_______________________________________________ LARTC mailing list / LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/