[Click] Trying to install new element

Fran franciscojgc at eresmas.com
Sat Apr 3 17:54:29 EST 2004


The MMARPWaitRandom element is part of an implementation of the MMARP 
multicast routing protocol for Ad Hoc network which I have implemented. If 
you only want to use the element, you don't need the rest of the 
implementation. You have to modify the file and erase that line because the 
mmarp.hh is not needed.

         Fran.


At 17:28 31/03/2004 -0600, you wrote:
>I'm trying to install the new element mmarpwaitrandom. I placed it in
>the elements directory, and recompiled the click router, and it seems to
>pick it up, but it says I'm missing the header information for
>'elements/mmarp/mmarp.hh'. Does anyone know which file this is since I
>looked all over the distribution but did not find the file. I am trying
>to compile click1.4pre1.
>
>Any help would GREATLY be appreciated,
>
>Thanks,
>
>Anthony G Persaud
>ironstar at iastate.edu
>
>Date: Sat, 20 Mar 2004 11:03:49 +0100
>From: Fran <franciscojgc at eresmas.com>
>Subject: Re: [Click] Using Click while adding random packet delay
>To: ironstar at iastate.edu
>Cc: click at amsterdam.lcs.mit.edu
>Message-ID: <5.1.0.14.2.20040320105646.00bbd728 at pop.eresmas.com>
>Content-Type: text/plain; charset="us-ascii"
>
>I have created a new element that add a random packet delay to each
>packet
>before send it to the interface.
>
>This is the code. I hope this could help you!!!
>
>          Fran.
>
>.hh file
>--------------------------
>#ifndef CLICK_MMARPWAITRANDOM_HH
>#define CLICK_MMARPWAITRANDOM_HH
>#include <click/element.hh>
>#include <elements/mmarp/mmarp.hh>
>#include <click/timer.hh>
>
>CLICK_DECLS
>
>class MMARPWaitRandom : public Element { public:
>
>    MMARPWaitRandom();
>    ~MMARPWaitRandom();
>
>
>    const char *class_name() const        { return "MMARPWaitRandom"; }
>    const char *processing() const        { return AGNOSTIC; }
>    MMARPWaitRandom *clone() const        { return new MMARPWaitRandom; }
>    int configure(Vector<String> &, ErrorHandler *);
>    int initialize(ErrorHandler *);
>
>    Packet *simple_action(Packet *);
>
>private:
>
>    struct PacketTimerPair {
>        MMARPWaitRandom *obj;
>        Packet *p;
>
>        PacketTimerPair(MMARPWaitRandom *o) : obj(o) { }
>
>      private:
>        PacketTimerPair() { }
>    };
>
>    static void static_expire_packet(Timer *, void *v)
>    { ((PacketTimerPair *) v)->obj->expire_packet(*((PacketTimerPair *)
>v)->p); }
>    void expire_packet(Packet &);
>
>    Timer *t;
>    PacketTimerPair *ptp;
>
>    unsigned long _wait;
>};
>
>CLICK_ENDDECLS
>#endif
>---------------------------------------------
>.cc file
>---------------------------------------------
>/*
>   * mmarpwaitrandom.{cc,hh} --
>   *
>   */
>
>#include <click/config.h>
>#include "mmarpwaitrandom.hh"
>#include <click/timer.hh>
>#include <time.h>
>#include <click/confparse.hh>
>
>CLICK_DECLS
>
>MMARPWaitRandom::MMARPWaitRandom()
>    : Element(1, 1)
>{
>    MOD_INC_USE_COUNT;
>}
>
>MMARPWaitRandom::~MMARPWaitRandom()
>{
>    MOD_DEC_USE_COUNT;
>}
>
>int
>MMARPWaitRandom::initialize(ErrorHandler *)
>{
>      srand(time(NULL));
>
>      return 0;
>}
>int
>MMARPWaitRandom::configure(Vector<String> &conf, ErrorHandler *errh) {
>          return cp_va_parse(conf, this, errh,
>                          cpUnsigned, "limit ms to wait", &_wait,
>                          0);
>}
>
>void
>MMARPWaitRandom::expire_packet(Packet &p){
>    t->unschedule();
>    output(0).push(&p);
>}
>
>Packet *
>MMARPWaitRandom::simple_action(Packet *p)
>{
>    ptp = new PacketTimerPair(this);
>    ptp->p = p;
>    t = new Timer(static_expire_packet, (void *) ptp);
>    t->initialize(this);
>
>    uint32_t micros = _wait * 1000;
>    uint32_t num = (uint32_t)((double)micros * rand()/(RAND_MAX+1.0));
>    double d = (double)num / 1000.0;
>    t->schedule_after_ms(d);
>
>    return 0;
>}
>
>CLICK_ENDDECLS
>EXPORT_ELEMENT(MMARPWaitRandom)
>ELEMENT_MT_SAFE(MMARPWaitRandom)
>
>----------------------------------------------
>
>At 14:18 19/03/2004 -0600, you wrote:
>
> >I am wondering how I could use your software router to add a random
> >packet delay to each packet that the router sends. (Maybe do some code
> >modifications? But where?). Any information to do this would greatly be
>
> >appreciated.
> >
> >Thanks,
> >
> >Anthony G Persaud
> >ironstar at iastate.edu
> >
>
>
>_______________________________________________
>click mailing list
>click at amsterdam.lcs.mit.edu
>https://amsterdam.lcs.mit.edu/mailman/listinfo/click




More information about the click mailing list