Display Rout Table of AODV in ns-2.34
Let’s begin:
Step 1) Open file aodv_rtable.h . Go to class aodv_rtable and in its public scope declare a member function
void rt_display(nsaddr_t id);
Step 2) Open file aodv_rtable.cc . Go to end and type this (read copy-paste )
void
aodv_rtable::rt_display(nsaddr_t id)
{
FILE *dumpFile;
dumpFile = fopen("rtable.txt", "a+");
aodv_rt_entry *rt = rthead.lh_first;
for(; rt; rt = rt->rt_link.le_next) {
// You can add more route table entries if you want to. See aodv_rtable.h for more entries.
fprintf(dumpFile, "NODE: %d \t %f \t %d \t %d \t %d \t %d \t %.4f \t %d \n", id, CURRENT_TIME,
rt->rt_dst, rt->rt_nexthop, rt->rt_hops, rt->rt_seqno, rt->rt_expire, rt->rt_flags);
}
fclose(dumpFile);
}
Step 3) (Important One) Open file aodv.cc . Go to the function
AODV::rt_update(aodv_rt_entry *rt, .... )
At the end of inside this function call the rt_display() function as:
rtable.rt_display(index);
Step 4) Compile using make and sudo make install inside the ns-2.34 directory.
Step 5) run your tcl file (here is the file if u want to test). The rtable.txt should look like this rtable.txt ..
No comments:
Post a Comment