Tulis code berikut pada aodv.h setelah fungsi void AODV::rt_down(aodv_rt_entry *rt);
void rt_print(nsaddr_t node_id);
Tambahkan code dibawah ini pada file aodv.cc setelah void rt_down(aodv_rt_entry *rt);
void AODV::rt_print(nsaddr_t node_id) { FILE * dumpFile; char dumpFileName[50] = "rtable.txt"; dumpFile = fopen(dumpFileName, 'a'); aodv_rt_entry *rt; fprintf(dumpFile, "======================================================="); for (rt=rtable.head();rt; rt = rt->rt_link.le_next) { 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) } fclose(dumpFile); }
Fungsi (rt_print) dapat digunakan dan dipanggil di manapun dilingkungan AODV, misalnya fungsi ini akan dipanggil saat sebuah node menerima route reply message (RREP). maka tiru penulisan code pada file aodv.cc di bawah ini.
if (ih->daddr() == index) { // If I am the original source // Update the route discovery latency statistics // rp->rp_timestamp is the time of request origination rt_print(index); // print this nodes whole routing table rt->rt_disc_latency[(unsigned char)rt->hist_indx] = (CURRENT_TIME - rp->rp_timestamp) / (double) rp->rp_hop_count; // increment indx for next time rt->hist_indx = (rt->hist_indx + 1) % MAX_HISTORY; }
No comments:
Post a Comment