[Click] Trying to install new element

Eddie Kohler kohler at CS.UCLA.EDU
Sun Apr 4 18:16:05 EDT 2004


Hey Fran,

Thanks for sending in MMARPWaitRandom!  It's cool.

I have some suggestions though.  Eventually would
you like to include it in the Click distribution?

1. Call it RandomDelay, which is a better description of its function.

2. The element is not AGNOSTIC since you call output(0).push() in the
    timer.  It is PUSH.  Don't provide a simple_action -- provide a 
push()
    method.

3. Provide a SEED keyword argument like AnonymizeIPAddr, and use the 
same
    algorithm for setting the random seed.  
(elements/analysis/anonipaddr.*)

4. Probably people would like to have a minimum and a maximum delay.

5. You can't use "double"s in Click elements that might go in the 
kernel.
    Use integer arithmetic instead.

6. You need to delete both the Timer and the PacketTimerPair in 
expire_packet.

7. You also need to delete any leftover Timers and PacketTimerPairs when
    the router is deleted.  (i.e. in cleanup().)

Eddie

On Apr 3, 2004, at 7:54 AM, Fran wrote:

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



More information about the click mailing list