[Click] Setting a write handler from a script element
Walter Cerroni
walter.cerroni at unibo.it
Wed Dec 2 13:36:32 EST 2009
Hi All,
I am trying to understand how to set, from within a PACKET script element, another element's handler and to test this I have written the following simple example:
src::RatedSource(PACKETDATA, 1, 200);
cnt::Counter;
s1::Script(
TYPE PACKET,
set npack $(cnt.count),
print $npack - $(src.rate),
set x $(if $(ge $npack 10) 10 1),
write src.rate $x
)
src->cnt->s1->Discard;
I am working in userlevel mode, so the expected result should be a series of 10 lines printed to stdout one per second, followed by 190 lines printed 10 per second. What I actually see is that all the 200 lines are printed immediately, as if the source was set to a very high rate. This happens even though the variables are printed correctly (the second number on each line shows the source rate):
1 - 1
2 - 1
3 - 1
4 - 1
5 - 1
6 - 1
7 - 1
8 - 1
9 - 1
10 - 1
11 - 10
12 - 10
[...]
Am I doing something wrong? I couldn't find any clue or example in the click documentation. I am using click v. 1.7.0rc1.
Any suggestion would be highly appreciated. Thank you.
Walter
More information about the click
mailing list