NS2 Notebook: How to Use Promiscuous Mode in AODV (ns-2.27)

Back to NS2 Menu


1. Modify aodv/aodv.h

Make AODV agent a child class of Tap (you should have a member function tap), and define the Mac variable

#include <mac.h>

class AODV: public Tap, public Agent {

public:

void tap(const Packet *p);

......

protected:

Mac *mac_;

......

}

 

2. Modify aodv/aodv.cc

Define TCL command "install-tap" and implement AODV::tap()

int
AODV::command(int argc, const char*const* argv) {

......

else if(argc == 3) {

......

else if (strcmp(argv[1], "install-tap") == 0) {
mac_ = (Mac*)TclObject::lookup(argv[2]);
if (mac_ == 0) return TCL_ERROR;
mac_->installTap(this);
return TCL_OK;
}

}
return Agent::command(argc, argv);


}

void
AODV::tap(const Packet *p) {

// put your code here

}

 

3. Modify tcl/lib/ns-mobilenode.tcl

Node/MobileNode instproc add-target { agent port } {

$self instvar dmux_ imep_ toraDebug_ mac_

......

# Special processing for AODV
set aodvonly [string first "AODV" [$agent info class]]
if {$aodvonly != -1 } {
$agent if-queue [$self set ifq_(0)] ;
# ifq between LL and MAC

$agent install-tap $mac_(0)

......

}

 

© Copyright 2008. All rights reserved. Powered by Free Site Templates