[Click] Setting a write handler from a script element

Eddie Kohler kohler at cs.ucla.edu
Wed Dec 2 13:58:35 EST 2009


Hi Walter,

Your code is correct.  The bad behavior you're seeing is a misfeature with 
RatedSource's rate handler: setting the rate effectively resets the element, 
allowing it to generate a new packet immediately.  Since you're setting the 
rate on *each packet*, the result is a single burst.

This version doesn't tickle the bad behavior:


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),
	 goto end $(eq $(src.rate) $x),
          write src.rate $x
)
src->cnt->s1->Discard;


I'll also try to fix the element.
Eddie


Walter Cerroni wrote:
> 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
> _______________________________________________
> click mailing list
> click at amsterdam.lcs.mit.edu
> https://amsterdam.lcs.mit.edu/mailman/listinfo/click


More information about the click mailing list