NS2: Printing Routing Table in AODV
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);
| 1 | voidrt_print(nsaddr_t node_id); | 
 
 
 
Add following code to aodv.cc after혻void혻 AODV::rt_down(aodv_rt_entry *rt)
| 1 | voidAODV::rt_print(nsaddr_t node_id) { | 
 
| 3 |     chardumpFileName[50] = "rtable.txt"; | 
 
| 5 |     dumpFile = fopen(dumpFileName, 'a'); | 
 
| 9 |     fprintf(dumpFile, "======================================================="); | 
 
| 11 |     for(rt=rtable.head();rt; rt = rt->rt_link.le_next) { | 
 
| 13 |         fprintf(dumpFile, "NODE: %it %.4lft %it %it %it %it %it %.4lft %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).
| 1 | if(ih->daddr() == index) {  | 
 
| 7 |     rt->rt_disc_latency[(unsigned char)rt->hist_indx] = (CURRENT_TIME - rp->rp_timestamp) | 
 
| 8 |                                          / (double) rp->rp_hop_count; | 
 
| 10 |     rt->hist_indx = (rt->hist_indx + 1) % MAX_HISTORY; | 
 
 
 
No comments:
Post a Comment