ns2 rebroadcasting packet when timer is expired -
i need rebroadcast packet when waiting timer expired, follow steps defined @ how add timer in aodv using ns2 , define agent , timer classes; cross reference; initialization of timer object in agent constructor; , expire(event*) class b_suppression. when execution reach agent->rebroadcast((packet*)p, 0);
abort following message 'invalid sdvcast packet type'. casting event packet causes problem?
class sdvcast; class b_suppression_timer : public timerhandler { friend class sdvcast; public: b_suppression_timer (sdvcast *s){agent = s;}; virtual void expire (event *p); private: sdvcast *agent; }; class sdvcast: public agent { //define object timer b_suppression_timer bstimer; } //initialized timer in constructor of sdvcast sdvcast::sdvcast(nsaddr_t id) : agent(pt_sdvcast), bstimer(this){ } // start timer void sdvcast::weightepersistence(packet *p, double delay){ bstimer.resched(delay); } // define expire of bstimer void b_suppression_timer::expire(event *p){ agent->rebroadcast((packet*)p, 0); }
add new packet type pt_sdvcast
common/packet.h
static const packet_t pt_ sdvcast = 73; // insert new packet types here static packet_t pt_ntype = 74; // must last 1 . . type == pt_sdvcast) . . name_[pt_sdvcast]= "sdvcast"
and maybe add sdvcast
tcl/lib/ns-packet.tcl
, ns-default.tcl
, ns-agent.tcl
etc.
edit : answer "segmentation fault"
"the implementation of packet data structure of ns2 not math realities. packet in ns2 simulation keeps packet headers protocols implemented in ns2. example, dsr routing packet may keep dsdv, aodv, or ping application header. reason, till today, packet used in ns2 simulation, have header size around 40~64kb. , no packet deleted release memory holds until end of simulation. typical simulation 100 nodes in ns2 around 1m packets exchanged (of course, may reuse packets being freed through packet::free(packet*). learn implementation of it, please check file common/packet{.h,.cc} ), may hold 10% of it, 100k packets, , may use memory @ least 100k*64kb -> 6.4gb, crash computer (even super server)."
etc. etc. see http://www.linuxquestions.org/questions/linux-networking-3/ns2-and-aqua-sim-4175507630/#3
http://www.linuxquestions.org/questions/tags/segmentation%20fault%20ns2/
Comments
Post a Comment