Actually you can find all this information in trace file which NS2 made, however using following code simplifies getting required informaiton during running time. The code stores
Add following code to aodv.h after void rt_down(aodv_rt_entry *rt);
void rt_print(nsaddr_t node_id); |
Add following code to aodv.cc after void AODV::rt_down(aodv_rt_entry *rt)
void AODV::rt_print(nsaddr_t node_id) { |
char dumpFileName[50] = "rtable.txt" ; |
dumpFile = fopen (dumpFileName, 'a' ); |
fprintf (dumpFile, "=======================================================" ); |
for (rt=rtable.head();rt; rt = rt->rt_link.le_next) { |
fprintf (dumpFile, "NODE: %i\t %.4lf\t %i\t %i\t %i\t %i\t %i\t %.4lf\t %d \n" , node_id, CURRENT_TIME, rt->rt_dst, rt->rt_nexthop, rt->rt_hops, rt->rt_seqno, rt->rt_expire, rt->rt_flags) |
The function (rt_print) can be used anywhere in AODV. For example, I am using the function, when route request generated node receives route reply message (RREP).
if (ih->daddr() == index) { |
rt->rt_disc_latency[(unsigned char )rt->hist_indx] = (CURRENT_TIME - rp->rp_timestamp) |
/ ( double ) rp->rp_hop_count; |
rt->hist_indx = (rt->hist_indx + 1) % MAX_HISTORY; |
No comments:
Post a Comment