23 December 2011

Promiscuous Mode in AODV (ns 2.34)

In a network, promiscuous mode allows a network device to intercept and read each network packet that arrives in its entirety. This mode of operation is sometimes given to a network snoop server that captures and saves all packets for analysis (for example, for monitoring network usage). Its often used to
monitor network activity

Files to be changed
1. ~ns-2.34/aodv/aodv.h
2. ~ns-2.34/aodv/aodv.cc
3. ~ns-2.34/lib/tcl/ns-mobilenode.tcl

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

   1: #include <mac.h>
   2: class AODV: public Tap, public Agent {
   3: public:
   4: void tap(const Packet *p);
   5: ......
   6: protected:
   7: Mac *mac_;
   8: ......
   9: }

2. Modify aodv/aodv.cc
Define TCL command "install-tap" and implement AODV::tap()


   1: int AODV::command(int argc, const char*const* argv) {
   2:  
   3: ......
   4:  
   5: else if(argc == 3) {
   6:  
   7: ......
   8:  
   9: else if (strcmp(argv[1], "install-tap") == 0) {
  10: mac_ = (Mac*)TclObject::lookup(argv[2]);
  11: if (mac_ == 0) return TCL_ERROR;
  12: mac_->installTap(this);
  13: return TCL_OK;
  14: }
  15:  
  16: } 
  17: return Agent::command(argc, argv);
  18:  
  19:  
  20: }
  21:  
  22: void AODV::tap(const Packet *p) {
  23: //put your code here
  24: fprintf(stdout,"Node in Promiscuous Mode");
  25: } 
  26:  


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


   1: Node/MobileNode instproc add-target { agent port } {
   2: $self instvar dmux_ imep_ toraDebug_ mac_
   3: ......
   4: # Special processing for AODV
   5: set aodvonly [string first "AODV" [$agent info class]] 
   6: if {$aodvonly != -1 } {
   7: $agent if-queue [$self set ifq_(0)] ; # ifq between LL and MAC
   8: $agent install-tap $mac_(0)
   9: ......
  10: }