At aodv When the node receive route request it will check if it has valid route to the destination, if it has no valid route it will rebroadcast the route request. I want to add timer before the node rebroadcast the route request.During the timer time if the node receive RREQ with the same ID (that means the node receive the RREQ twice ) then discard the RREQ otherwise rebroadcast the RREQ. I don’t know how to write the code of this part. The code of timer 1. The timer was defined in aodv.h
class RouteRequestTimer : public Handler {
public:
RouteRequestTimer(AODV* a) : agent(a) { busy_ = 0; }
void handle(Event*);
void start(double time);
void stop(void);
inline int busy(void) { return busy_; }
private:
AODV *agent;
Event intr;
int busy_;
};
The timer was declared in the routing agent aodv.h
friend class RouteRequestTimer; RouteRequestTimer rrtimer;
In aodv.cc, implement the handle function
void RouteRequestTimer::handle(Event*) { busy_ = 0; #define interval 0.5 fprintf (stderr, "This is a test for the usage of timer.\n"); Scheduler::instance().schedule(this, &intr, interval); } void RouteRequestTimer::start(double time) { Scheduler &s = Scheduler::instance(); assert(busy_ == 0); busy_ = 1; s.schedule(this, &intr, time); } void RouteRequestTimer::stop(void) { Scheduler &s = Scheduler::instance(); assert(busy_); s.cancel(&intr); busy_ = 0; }
The timer was initialized at aodv.cc
AODV::AODV(nsaddr_t id) : ..., rrtimer(this), ... { }
The timer was used at the function that receive the route request
void AODV::recvRequest(packet *p){ … … … Scheduler::instance().schedule(&rrtimer, p->copy(), inerval); … }
Then I recompile ns2 and the compilation completed with no error. When I run the tcl code for the network using aodv, this error appear
scheduler: Event UID not valid
please how to solve this error and how to check the received route request id on the timer, if a RREQ with the same id is received then discard the packet otherwise forward it.
Thanks in advance