[Click] How to read queueLen and packetCount from code?

Eddie Kohler kohler at cs.ucla.edu
Fri Jul 8 14:21:09 EDT 2011


To find elements, we recommend using the NAMES of elements as configuration 
arguments.  For instance:

fw :: Forwarder(....., DOWNSTREAM_QUEUE q, DOWNSTREAM_COUNTER outc)
    -> q :: Queue(1000)
    -> outc::Counter() -> ToDevice(eth0);

In Forwarder::configure():

    ...
    Element *downstream_queue, *downstream_counter;
    if (Args(conf, this, errh) .....
        .read_m("DOWNSTREAM_QUEUE", downstream_queue)
        .read_m("DOWNSTREAM_COUNTER", downstream_counter)
        ....)

Then you don't need to worry about active outputs, etc., and your 
configuration is more robust to element rearrangement (like sticking debug 
elements between fw and q).

But once every 10 seconds is not very much.  Try using a HandlerCall element.

String length_as_string = HandlerCall::call_read("name_of_queue.length",this);



Eddie


On 7/7/11 2:53 AM, Tilak, Bhaskar A wrote:
> Hello Group,
>
> Seeking help in following work related to click modular router.
> I am running it in userlevel. I am trying to read the queue length
> and packet count;  I have already done this using
> script in click config file but now I want to do it from the code.
> I have following configuration.
>
> fw[2] ->  Queue(1000) ->  outc::Counter() ->  ToDevice(eth0);
>
>   66         par.queue = output(2).element();
>   67         par.h = (Handler *)router()->handler(par.queue,"length");
>   68         click_chatter("count = %u", par.count);
>   69         par.count = par.queue->output(0).element();
>   70         click_chatter("count = %u", par.count);
>   71         click_chatter("name of the element = %s", par.count->name().c_str());
>   72         if (par.count)
>   73         par.hc = (Handler *)router()->handler(par.count,"count");
>
> In the forwarder (fw = forwarder) initialise function, at line 66 I get the address of
>   queue connected to port 2 of fw&  at 67 install the handler.
> I try to use same trick on queue element to get an address of counter but it
> returns me 0 as I checked that an output port of queue is not active.
>
> I also trying forcing the initialization of forwarder late using
> CONFIGURE_PHASE_LAST but it didnt work.
>
> Is there any way I can get address of counter and install handler OR
>
> Any other way for reading queue length and packet count in the code, because
> I want to read these values every 10 second and send it to the central node.
>
> Thanks,
> - Bhaskar.


More information about the click mailing list