Monday 23 February 2015

awk scripts for analysis of trace files in ns2

awk scripts for analysis of trace files in ns2


Packet delivery ratio

awk script

BEGIN {
        sendLine = 0;
        recvLine = 0;
        fowardLine = 0;
}
 
$0 ~/^s.* AGT/ {
        sendLine ++ ;
}
 
$0 ~/^r.* AGT/ {
        recvLine ++ ;
}
 
$0 ~/^f.* RTR/ {
        fowardLine ++ ;
}
 
END {
        printf "s:%d r:%d, r/s Ratio:%.4f, f:%d \n", sendLine, recvLine, (recvLine/sendLine),fowardLine;
}


End to end delay
awk script 

BEGIN {

    seqno = -1;    


    count = 0;

}

{

    if($4 == "AGT" && $1 == "s" && seqno < $6) {

          seqno = $6;

    } 

    #end-to-end delay

    if($4 == "AGT" && $1 == "s") {

          start_time[$6] = $2;

    } else if(($7 == "tcp"||$7=="cbr") && ($1 == "r")) {

        end_time[$6] = $2;

    } else if($1 == "D" && ($7 == "tcp"$7=="cbr") {

          end_time[$6] = -1;

    } 

}

 
END {        
  
    for(i=0; i<=seqno; i++) {

          if(end_time[i] > 0) {

              delay[i] = end_time[i] - start_time[i];

                  count++;

        }

            else

            {

                  delay[i] = -1;

            }

    }

    for(i=0; i<=seqno; i++) {

          if(delay[i] > 0) {

              n_to_n_delay = n_to_n_delay + delay[i];

        }         

    }

   n_to_n_delay = n_to_n_delay/count;

 

    print "\n";

    print "Average End-to-End Delay    = " n_to_n_delay * 1000 " ms";

    print "\n";

}

Control Overhead(Normalized routing overhead)
Note: Add control packets in the (routing packet)conditions as per your protocol 
awk script
BEGIN{
recvd = 0;#################### to calculate total number of data packets received
rt_pkts = 0;################## to calculate total number of routing packets received
}

{
##### Check if it is a data packet
if (( $1 == "r") && ( $7 == "cbr" || $7 =="tcp" ) && ( $4=="AGT" )) recvd++;

##### Check if it is a routing packet
if (($1 == "s" || $1 == "f") && $4 == "RTR" && ($7 =="udp" || $7 == "AODV" || $7 =="message" || $7 =="AOMDV" || $7 =="OLSR")) rt_pkts++;

}


END{
printf("##################################################################################\n");
printf("\n");
printf("total no of data packets\t%d\n",recvd);
printf("\ntotal no of routing packets\t%d\n",rt_pkts);
printf("                       Normalized Routing Load = %.3f\n", rt_pkts/recvd);
printf("\n");
printf("##################################################################################\n");
}

Throughput
Note: Change packet size as per mentioned in your tcl script 
awk script

BEGIN {
       recvdSize = 0
       startTime = 400
       stopTime = 0
  }
   
  {
             event = $1
             time = $2
             node_id = $3
             pkt_size = $8
             level = $4
   
  # Store start time
  if (level == "AGT" && event == "s" && pkt_size >= 512) {
    if (time < startTime) {
             startTime = time
             }
       }
   
  # Update total received packets' size and store packets arrival time
  if (level == "AGT" && event == "r" && pkt_size >= 512) {
       if (time > stopTime) {
             stopTime = time
             }
            recvdSize += pkt_size
       }
  }
   
  END {
       printf("Average Throughput[kbps] = %.2f\t\t StartTime=%.2f\tStopTime=%.2f\n",(recvdSize/(stopTime-startTime))*(8/1000),startTime,stopTime)
  }

How to apply awk?
awk -f pdr.awk out.tr

Friday 20 February 2015

Step by step installation of ns-2.34 on ubuntu 14.04

Step by step installation of ns2.34 on ubuntu 14.04

step 1: step1: Download ns-allinone-2.34.tar.gz

Download link:
http://sourceforge.net/projects/nsnam/files/allinone/ns-allinone-2.34/

step 2:Copy it to home folder(not compulsory, you can change as per your choice )

step 3:Open Terminal (Altr+ctrl+t)

step 3:Install the basic packages required to install the ns2




        $sudo apt-get update

        $sudo apt-get install build-essential autoconf automake libxmu-dev


step 4: Extract tar file to home. In terminal default directory is home.
            Run follwing command to extract tar file to home directory

          $tar -zxvf ns-allinone-2.34.tar.gz

step 5: Edit line 137 of ns-allinone-2.35/ns-2.35/linkstate/ls.h file as

    
        void eraseAll() { this->erase(baseMap::begin(), baseMap::end()); }

              after change save and close this file.

step 6: Modify the specified files in ns-allinone-2.34 folder as specified below:

         i. In ns-allinone-2.34/otcl-1.13/configure 
            

         change SHLIB_LD="ld -shared" to SHLIB_LD="gcc -shared"

        ii. ns-allinone-2.34/ns-2.34/tools/ranvar.cc  line:219 change

           return GammaRandomVariable::GammaRandomVariable(1.0 + alpha_, beta_).value() * pow (u, 1.0 / alpha_);
                      to
            return GammaRandomVariable(1.0 + alpha_, beta_).value() * pow (u, 1.0 / alpha_); 


    
         iii.Change the lines 183 and 185 in file ns-allinone-2.34/ns-2.34/mobile/nakagami.cc to
              resultPower = ErlangRandomVariable(Pr/m, int_m).value();
                      and
              resultPower = GammaRandomVariable(m, Pr/m).value();

        iv.Next add a bellow line after line 64 in ns-allinone-2.34/ns-2.34/mac/mac-802_11Ext.h
              #include <stddef.h> 



step 7:To install ns2  go to ns-allinone-2.34 directory and run ./install

           $ cd ns-allinone-2.34/
      
           $./install

            it will take 20- 30 min or may be more time to install

step 8: After this go to base directory and following command

         $cd ns-allinone-2.34/ns-2.34

           $sudo make install 

step 10: Run ns

            $ns

             It will show % sign
             type exit to exit

            Run nam command

            $nam

             it will show nam window



if nam shows you error like segmentation fault(core dumped)

go to nam-1.15 and run

$cd ns-allinone-2.34/nam-1.14

$sudo cp nam /usr/local/bin


now run nam

$nam

Enjoy!
 

Thursday 19 February 2015

Adding a malicious node in NS2 in AODV Protocol

Adding a malicious node is ns2 using aodv protocol. The node which is declared as malicious will simply drop the router packet (DROP_RTR_ROUTE_LOOP).

Two files have to be modified.
1. aodv.h
2. aodv.cc

aodv.h file changes

Declare a boolean variable malicious as shown below in the protected scope in the class AODV

bool malicious;

aodv.cc file changes

1. Initialize the malicious varible with a value "false". Declare it inside the constructor as shown below
AODV::AODV(nsaddr_t id):Agent(PT_AODV)...
{
.......
malicious = false;
}

2. Add the following statement to the aodv.cc file in the "if(argc==2)" statment.

if(strcmp(argv[1], "malicious") == 0) {
    malicious = true;
   return TCL_OK;
}


3. Implement the behavior of the malicious node by setting the following code in the rt_resolve(Packet *p) function. The malicious node will simply drop the packet as indicated below.

if(malicious==true)
{
drop(p,DROP_RTR_ROUTE_LOOP);
}

Once done, recompile ns2 as given below
Open Terminal -> Go to ~ns-2.35/ directory and type the command make to compile
$ cd /home/pradeep/ns-allinone-2.35/ns-2.35/
$ make clean
$ make                                              # it will take time to compile
$ sudo make install

Once the compilation is done, Check the malicious behavior using the Tcl Script by setting any one node as malicious node. The command to set the malicious node is

$ns at 0.0 "[$n(1) set ragent_] malicious" 

The variable referred for node2 is n1 (set n(1) [$ns node])

you  can disable the packet dropping by adding # before above line

#$ns at 0.0 "[$n(1) set ragent_] malicious"


aodv.tcl file









#======================================================================
# Define options
#======================================================================
 set val(chan)         Channel/WirelessChannel  ;# channel type
 set val(prop)         Propagation/TwoRayGround ;# radio-propagation model
 set val(ant)          Antenna/OmniAntenna      ;# Antenna type
 set val(ll)           LL                       ;# Link layer type
 set val(ifq)          Queue/DropTail/PriQueue  ;# Interface queue type
 set val(ifqlen)       50                       ;# max packet in ifq
 set val(netif)        Phy/WirelessPhy          ;# network interface type
 set val(mac)          Mac/802_11               ;# MAC type
 set val(nn)           6                        ;# number of mobilenodes
 set val(rp)           AODV                     ;# routing protocol
 set val(x)            800
 set val(y)            800



set ns [new Simulator]
#ns-random 0

set f [open out.tr w]
$ns trace-all $f
set namtrace [open out.nam w]
$ns namtrace-all-wireless $namtrace $val(x) $val(y)
set topo [new Topography]
$topo load_flatgrid 800 800

create-god $val(nn)

set chan_1 [new $val(chan)]
set chan_2 [new $val(chan)]
set chan_3 [new $val(chan)]
set chan_4 [new $val(chan)]
set chan_5 [new $val(chan)]
set chan_6 [new $val(chan)]

# CONFIGURE AND CREATE NODES

$ns node-config  -adhocRouting $val(rp) \
          -llType $val(ll) \
                 -macType $val(mac) \
                 -ifqType $val(ifq) \
                 -ifqLen $val(ifqlen) \
                 -antType $val(ant) \
                 -propType $val(prop) \
                 -phyType $val(netif) \
                 #-channelType $val(chan) \
                 -topoInstance $topo \
                 -agentTrace ON \
                 -routerTrace ON \
                 -macTrace ON \
                 -movementTrace OFF \
                 -channel $chan_1

proc finish {} {
    global ns namtrace
    $ns flush-trace
        close $namtrace 
        exec nam -r 5m out.nam &
    exit 0
}

# define color index
$ns color 0 blue
$ns color 1 red
$ns color 2 chocolate
$ns color 3 red
$ns color 4 brown
$ns color 5 tan
$ns color 6 gold
$ns color 7 black
                      
set n(0) [$ns node]
$ns at 0.0 "$n(0) color blue"
$n(0) color "0"
$n(0) shape "circle"
set n(1) [$ns node]
$ns at 0.0 "$n(1) color red"
$n(1) color "blue"
$n(1) shape "circle"
set n(2) [$ns node]
$n(2) color "tan"
$n(2) shape "circle"
set n(3) [$ns node]
$n(3) color "red"
$n(3) shape "circle"
set n(4) [$ns node]
$n(4) color "tan"
$n(4) shape "circle"
set n(5) [$ns node]
$ns at 0.0 "$n(5) color blue"
$n(5) color "red"
$n(5) shape "circle"


for {set i 0} {$i < $val(nn)} {incr i} {
    $ns initial_node_pos $n($i) 30+i*100
}
#$ns at 0.0 "[$n(1) set ragent_] malicious"  
        
$ns at 0.0 "$n(0) setdest 100.0 100.0 3000.0"
$ns at 0.0 "$n(1) setdest 200.0 200.0 3000.0"
$ns at 0.0 "$n(2) setdest 300.0 200.0 3000.0"
$ns at 0.0 "$n(3) setdest 400.0 300.0 3000.0"
$ns at 0.0 "$n(4) setdest 500.0 300.0 3000.0"
$ns at 0.0 "$n(5) setdest 600.0 400.0 3000.0"

# CONFIGURE AND SET UP A FLOW

set sink0 [new Agent/LossMonitor]
set sink1 [new Agent/LossMonitor]
set sink2 [new Agent/LossMonitor]
set sink3 [new Agent/LossMonitor]
set sink4 [new Agent/LossMonitor]
set sink5 [new Agent/LossMonitor]
$ns attach-agent $n(0) $sink0
$ns attach-agent $n(1) $sink1
$ns attach-agent $n(2) $sink2
$ns attach-agent $n(3) $sink3
$ns attach-agent $n(4) $sink4
$ns attach-agent $n(5) $sink5

#$ns attach-agent $sink2 $sink3
set tcp0 [new Agent/TCP]
$ns attach-agent $n(0) $tcp0
set tcp1 [new Agent/TCP]
$ns attach-agent $n(1) $tcp1
set tcp2 [new Agent/TCP]
$ns attach-agent $n(2) $tcp2
set tcp3 [new Agent/TCP]
$ns attach-agent $n(3) $tcp3
set tcp4 [new Agent/TCP]
$ns attach-agent $n(4) $tcp4
set tcp5 [new Agent/TCP]
$ns attach-agent $n(5) $tcp5


proc attach-CBR-traffic { node sink size interval } {
   #Get an instance of the simulator
   set ns [Simulator instance]
   #Create a CBR  agent and attach it to the node
   set cbr [new Agent/CBR]
   $ns attach-agent $node $cbr
   $cbr set packetSize_ $size
   $cbr set interval_ $interval

   #Attach CBR source to sink;
   $ns connect $cbr $sink
   return $cbr
  }

set cbr0 [attach-CBR-traffic $n(0) $sink5 1000 .030]
$ns at 0.5 "$cbr0 start"
$ns at 5.5 "finish"
puts "Start of simulation.."
$ns run

For video tutorial
https://www.youtube.com/watch?v=ca-yFicgDZs

thank you!

Wednesday 11 February 2015

how to clone protocol in ns2

How to clone a protocol in ns2.35(AODV)

Step 1: Copy the file of aodv in the different folder name as taodv.

Step 2: Rename all the file names and inside document.

step 3: Replace aodv to taodv and AODV to TAODV.


Step 4: Go to #ns-allinone-2.35\ns-2.35\common\packet.h

typedef unsigned int packet_t;

static const packet_t PT_TCP = 0;
static const packet_t PT_UDP = 1;
static const packet_t PT_CBR = 2;
......
......
......
......
        // insert new packet types here
static const packet_t PT_TAODV = 73;  //newly added packet
static packet_t       PT_NTYPE = 74; // This MUST be the LAST one





class p_info {
public:
    p_info()
    {
        initName();
    }
    const char* name(packet_t p) const {
        if ( p <= p_info::nPkt_ ) return name_[p];
        return 0;
    }
........
........
........

static packetClass classify(packet_t type) {       
        if (type == PT_DSR ||
            type == PT_MESSAGE ||
            type == PT_TORA ||
            type == PT_PUMA ||
            type == PT_AODV ||
            type == PT_TAODV ||
            type == PT_MDART)
            return ROUTING;   
...........
..........
........
........

name_[PT_DCCP]="DCCP";
        name_[PT_DCCP_REQ]="DCCP_Request";
        name_[PT_DCCP_RESP]="DCCP_Response";
        name_[PT_DCCP_ACK]="DCCP_Ack";
        name_[PT_DCCP_DATA]="DCCP_Data";
        name_[PT_DCCP_DATAACK]="DCCP_DataAck";
        name_[PT_DCCP_CLOSE]="DCCP_Close";
        name_[PT_DCCP_CLOSEREQ]="DCCP_CloseReq";
        name_[PT_DCCP_RESET]="DCCP_Reset";
        name_[PT_TAODV]= "TAODV";
        name_[PT_NTYPE]= "undefined";


}

Step 5: #ns-allinone-2.35\ns-2.35\trace\cmu-trace.h

class CMUTrace : public Trace {
public:
    CMUTrace(const char *s, char t);
    void    recv(Packet *p, Handler *h);
    void    recv(Packet *p, const char* why);

    static void addPacketTracer(PacketTracer *pt);

..........
.........
..........
..........

void    format_imep(Packet *p, int offset);
        void    format_aodv(Packet *p, int offset);
        void    format_taodv(Packet *p, int offset);
    void    format_aomdv(Packet *p, int offset);
    void    format_mdart(Packet *p, int offset);
}


Step 6: #ns-allinone-2.35\ns-2.35\trace\cmu-trace.cc
#include <taodv/taodv_packet.h>

//Newly added
void
CMUTrace::format_taodv(Packet *p, int offset)
    {
      struct hdr_taodv *ah = HDR_TAODV(p);
      struct hdr_taodv_request *rq = HDR_TAODV_REQUEST(p);
      struct hdr_taodv_reply *rp = HDR_TAODV_REPLY(p);


      switch(ah->ah_type) {
      case TAODVTYPE_RREQ:

                if (pt_->tagged()) {
                    sprintf(pt_->buffer() + offset,
                            "- taodv:t %x - taodv:h %d - taodv:b %d -taodv:d %d "
                            "- taodv:ds %d - taodv:s %d - taodv:ss %d "
                            "- taodv:c REQUEST ",rq->rq_type,
                             rq->rq_hop_count,
                             rq->rq_bcast_id,
                  rq->rq_dst,
                  rq->rq_dst_seqno,
                  rq->rq_src,
                  rq->rq_src_seqno);
            } else if (newtrace_) {
              sprintf(pt_->buffer() + offset,"-P  taodv -Pt 0x%x -Ph %d -Pb %d -Pd %d -Pds %d -Ps %d -Pss %d -Pc REQUEST ",
              rq->rq_type,
              rq->rq_hop_count,
              rq->rq_bcast_id,
              rq->rq_dst,
              rq->rq_dst_seqno,
              rq->rq_src,
              rq->rq_src_seqno);


                } else {

                    sprintf(pt_->buffer() + offset,
                        "[0x%x %d %d [%d %d] [%d %d]] (RREQ)",
              rq->rq_type,
              rq->rq_hop_count,
              rq->rq_bcast_id,
              rq->rq_dst,
              rq->rq_dst_seqno,
              rq->rq_src,
              rq->rq_src_seqno);
                }
                 break;

        case TAODVTYPE_RREP:
        case TAODVTYPE_HELLO:
        case TAODVTYPE_RERR:

                if (pt_->tagged()) {
                    sprintf(pt_->buffer() + offset,
                            "- taodv:t %x - taodv:h %d - taodv:d %d -tadov:ds %d "
                            "- taodv:l %f - taodv:c %s ",
                            rp->rp_type,
                            rp->rp_hop_count,
                            rp->rp_dst,
                            rp->rp_dst_seqno,
                            rp->rp_lifetime,
                            rp->rp_type == TAODVTYPE_RREP ? "REPLY" :
                            (rp->rp_type == TAODVTYPE_RERR ? "ERROR" :
                             "HELLO"));
                } else if (newtrace_) {

                        sprintf(pt_->buffer() + offset,
                           "-P  taodv -Pt 0x%x -Ph %d -Pd %d -Pds %d -Pl %f -Pc %s ",
                                 rp->rp_type,
                                 rp->rp_hop_count,
                               rp->rp_dst,
                                 rp->rp_dst_seqno,
                  rp->rp_lifetime,
                  rp->rp_type == TAODVTYPE_RREP ?"REPLY" :
                                 (rp->rp_type == TAODVTYPE_RERR ?"ERROR" :
                                 "HELLO"));
                                } else {

                        sprintf(pt_->buffer() + offset,"[0x%x %d [%d %d] %f] (%s)",
                  rp->rp_type,
                  rp->rp_hop_count,
                  rp->rp_dst,
                  rp->rp_dst_seqno,
                  rp->rp_lifetime,
                  rp->rp_type == TAODVTYPE_RREP ? "RREP":
                                (rp->rp_type == TAODVTYPE_RERR ?"ERROR" :
                                  "HELLO"));
                }
                break;

        default:
          #ifdef WIN32
          fprintf(stderr,"CMUTrace::format_ taodv: invalid TAODV packet type\n");
          #else
              fprintf(stderr,"%s: invalid TAODV packet type\n",__FUNCTION__);
        #endif
                abort();
        }
 }
 
...... ......
 //Newly added
 void CMUTrace::format(Packet* p, const char *why)
  {
         ......
        ......
        default:
        ......
        ......
                case PT_AODV:
            format_aodv(p, offset);
                        break;
                case PT_TAODV:                //Newly added
                        format_taodv(p, offset);

                        break;
             break;
        ......
        ......
 }

Step 7: #ns-allinone-2.35\ns-2.35\tcl\lib\ns-packet.tcl



set protolist {
# Common:
    Common
    Flags
    IP     # IP
.......
.......
.......
# Mobility, Ad-Hoc Networks, Sensor Nets:
    AODV     # routing protocol for ad-hoc networks
    TAODV     # routing protocol for ad-hoc networks
.........
........
.........

}

Step 8: #ns-allinone-2.35\ns-2.35\tcl\lib\ns-lib.tcl
Simulator instproc create-wireless-node args {
         ......
        ......
        switch -exact $routingAgent_ {
            ......
            ......
            AODV {
                    set ragent [$self create-aodv-agent $node]
            }
           TAODV {
           set ragent [$self create-taodv-agent $node]            

        }
                
......
                 ......
             }
             ......
             ......
      }
      ......
      ......
      # Newly added
      Simulator instproc create-taodv-agent { node } {
             #  Create TAODV routing agent
             set ragent [new Agent/TAODV [$node node-addr]]
             $self at 0.0 "$ragent start"    ;# start BEACON/HELLO messages
             $node set ragent_ $ragent
             return $ragent
      }


Step 9: #ns-allinone-2.35\ns-2.35\queue\priqueue.cc

//Newly added
      void
      PriQueue::recv(Packet *p, Handler *h)
      {
                     ......
                     ......
                     case PT_AODV:
                     case PT_TAODV:                //Newly added
                     ......
                     ......
      }

Step 10: #ns-allinone-2.35\ns-2.35\Makefile

OBJ_CC = \
             ......
             ......
             aodv/aodv_logs.o aodv/aodv.o \
             aodv/aodv_rtable.o aodv/aodv_rqueue.o \
             taodv/taodv_logs.o taodv/taodv.o \
             taodv/taodv_rtable.o taodv/taodv_rqueue.o \

             ......
             ......
             $(OBJ_STL)
    
    
   *** Make sure you are making the same changes in makefile.vc and Makefile.in otherwise after ./configure
    it will not take into account and object file will not generate.


Step 11: #ns-allinone-2.35\ns-2.35\tcl\lib\ns-agent.tcl
      Agent/AODV instproc init args {
    
              $self next $args
      }
    
      Agent/AODV set sport_   0
      Agent/AODV set dport_   0
    
      # Newly added
      Agent/TAODV instproc init args {
    
              $self next $args
      }
    
      Agent/TAODV set sport_   0
      Agent/TAODV set dport_   0


Step 12: #ns-allinone-2.35\ns-2.35\tcl\lib\ns-mobilenode.tcl
      Node/MobileNode instproc add-target { agent port } {
             ......
             ......
             # 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
             }
             # Newly added
             # Special processing for TAODV
             set taodvonly [string first "TAODV" [$agent info class]]
             if {$taodvonly != -1 } {
        $agent if-queue [$self set ifq_(0)]   ;# ifq between LL and MAC
             }
            
......
             ......
      }

Step 13: #ns-allinone-2.35\ns-2.35\queue\rtqueue.cc
 
      Do not make any changes just go through the Packet Queue used by AODV.

Step 14: #ns-allinone-2.35\ns-2.35\routing\rtable.h

    class Neighbor {
        friend class AODV;
    friend class TAODV;    //Newly added
        friend class rt_entry;
        ......
        ......
        }
       
        class rt_entry {
        friend class rttable;
        friend class AODV;
    friend class TAODV;    //Newly added
    friend class TAODVLocalRepairTimer; //modified
    .....
    .....
    .....
    }
 Step 15: #ns-allinone-2.35\ns-2.35\wpan\p802_15_4nam.cc

    packet_t nam_pktName2Type(const char *name)
    {
        //not all types included

        return (strcmp(packet_info.name(PT_TCP),name) == 0)?PT_TCP:
        ......
        ......
        ......
        (strcmp(packet_info.name(PT_AODV),name) == 0)?PT_AODV:
       (strcmp(packet_info.name(PT_TAODV),name) == 0)?PT_TAODV:
       
      }

Step 16: #ns-allinone-2.35\dei80211mr-1.1.4\src\InitTCL.cc

PacketHeaderManager set tab_(PacketHeader/SR) 1\n\
PacketHeaderManager set tab_(PacketHeader/AODV) 1\n\
PacketHeaderManager set tab_(PacketHeader/TAODV) 1\n\  

Step 17: Rename every aodv file with taodv name inside taodv folder

Step 18: Open each and every file and rename aodv to taodv and AODV to TAODV
Step 19: Rename every timer class in taodv.h and taodv.cc

 E.g. In taodv.h

class TAODVBroadcastTimer : public Handler {
public:
    TAODVBroadcastTimer(TAODV* a) : agent(a) {}
        void    handle(Event*);
private:
        TAODV    *agent;
        Event   intr;
};

.......
......
.....





....
.....
.....
class TAODV: public Tap,public Agent {


....
.....
friend class TAODVBroadcastTimer;
......
......

TAODVBroadcastTimer  btimer;
.....
......




}


 *note rename every timer otherwise it will give an error

E.G.
In taodv.cc


void TAODVHelloTimer::handle(Event* p) {


    agent->sendHello();
    double interval = MinHelloInterval +
    ((MaxHelloInterval - MinHelloInterval) * Random::uniform());
    assert(interval >= 0);
    Scheduler::instance().schedule(this, &intr, interval);


}
*note rename every timer otherwise it will give an error

Step 20: Edit taodv_rtable.h

class taodv_rt_entry {
        friend class taodv_rtable;
        friend class TAODV;
        friend class LocalRepairTimer;
        friend class TAODVLocalRepairTimer; 

 ......
 ......
......


}
 

Step 21: Recompilation:
Step 1: We should recompiled ``packet.cc`` as the ``packet.h'' is modified.
        this can be done by  : ``touch common/packet.cc''
Step 2: ./configure (if this fails go to step 22)
Step 3: make clean
Step 4: make
Step 5: make install

Step 22: If ./configure fails then run ./install

 $cd ns-allinone-2.35
 $./install
 $cd ns-allinone-2.35/ns-2.35
 $sudo make install

You are now done with complete cloning of aodv routing protocol!

Tuesday 10 February 2015

How to install multiple ns2 versions on same machine and run in parallel.

I will show you how to run ns2.35 and ns2.34 side by side

Step 1: Install extract ns-allinone-2.35

              $cd ns-allinone-2.35/

              do required changes.

Step 2: Run following command to install ns2.35

                ./install

Step 3: After successful installation run

               $cd ns-2.35/
             
               $sudo make install

               $cp ns ns-2.35
       
               $sudo mv ns-2.35 /usr/local/bin

Step 4: Repeat step1 to step 3 procedure for ns-2.34

Step 5: Now you can use both ns2 versions

           $ns-2.34 example.tcl
           $ns-2.35 example.tcl  


 Thank you!