[Click] Timers too fast

Eddie Kohler kohler at cs.ucla.edu
Wed Oct 6 11:40:08 EDT 2004


Bart Braem wrote:
> Hi,
> 
> I'm trying to use timers to generate a constant flow of Hello messages from a 
> node. These Hello messages should be sent at a very limited rate (1 per 
> minute) so using RatedUnQueue is undesirable, right?
> 
> For the moment my code works but the rate is way to high, I get hundreds of 
> messages in 1 second instead of 1 every 10 seconds...
> The code looks like this:

Hey Bart,

So I just typed that code into an element, and accompanied it with the obvious 
header file, and I get one packet done message every 10 seconds.  You're doing 
it right, at least here; and Click also handles this case correctly.  Are you 
sure this is equivalent to your actual example?

Eddie



> 
> AODVHelloGenerator::AODVHelloGenerator():
>  Element(0,1),
>  timer(this)
> {
>  // CONSTRUCTOR MUST MOD_INC_USE_COUNT
>  MOD_INC_USE_COUNT;
> }
> int AODVHelloGenerator::initialize(ErrorHandler *errh)
> {
>  timer.initialize(this);
>  timer.schedule_now();
>  return 0;
> }
> void AODVHelloGenerator::run_timer(){
>  printf("packet sent\n");
>  fflush(stdout);
>  timer.reschedule_after_ms(10000);
> }
> 
> Could someone explain me what I'm doing wrong here? Am I using timers the 
> wrong way?
> 
> Thanks
> Bart



More information about the click mailing list