I was using nam to simulate a simple scenario the topology is as follow:

            (1)

(0)                      (3)
 
            (2)           

Node 0 sends traffic to Node 3 through node 2 and is supposed to have Node 1 as 
a backup path.  After 2 seconds, node 2 moves out of range and Node 0 is 
supposed to instantly switch to an alternate path.  However it takes 8 seconds 
and an addition Route discovery in order for node 0 to find a path to node 3.  
Is AOMDV working???  I am using NS 2.34. and borrowing the code that is listed 
on one of the popular ns sites.  The code is below:

# A 3-node example for ad-hoc simulation with AODV

# Define options
set val(chan)           Channel/WirelessChannel    ;# channel type
set val(prop)           Propagation/TwoRayGround   ;# radio-propagation model
set val(netif)          Phy/WirelessPhy            ;# network interface type

set val(mac)            Mac/802_11                 ;# MAC type
set val(ifq)            Queue/DropTail/PriQueue    ;# interface queue type
set val(ll)             LL                         ;# link layer type
set val(ant)            Antenna/OmniAntenna        ;# antenna model
set val(ifqlen)         50                         ;# max packet in ifq
set val(nn)            4                          ;# number of mobilenodes
set val(rp)             AOMDV                       ;# routing protocol
set val(x)              1000                  ;# X dimension of topography
set val(y)              700                  ;# Y dimension of topography
set val(stop)        150               ;# time of simulation end

set ns          [new Simulator]
set tracefd       [open simple.tr w]
set windowVsTime2 [open win.tr w]
set namtrace      [open simwrls.nam w]

$ns trace-all $tracefd
$ns namtrace-all-wireless $namtrace $val(x) $val(y)

# set up topography object
set topo       [new Topography]

$topo load_flatgrid $val(x) $val(y)

create-god $val(nn)

#
#  Create nn mobilenodes [$val(nn)] and attach them to the channel.
#

# configure the 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 OFF \
             -movementTrace ON

    for {set i 0} {$i < $val(nn) } { incr i } {
        set node_($i) [$ns node]
    }

# Provide initial location of mobilenodes
    $node_(0) set X_ 150
    $node_(0) set Y_ 350
    $node_(0) set Z_ 0.0
    $node_(1) set X_ 300
    $node_(1) set Y_ 500
    $node_(1) set Z_ 0.0
    $node_(2) set X_ 300
    $node_(2) set Y_ 200
    $node_(2) set Z_ 0.0
    $node_(3) set X_ 450
    $node_(3) set Y_ 350
    $node_(3) set Z_ 0.0
    

# Generation of movements
#$ns at 10.0 "$node_(0) setdest 250.0 250.0 3.0"
$ns at 12.0 "$node_(2) setdest 500 50 100.0"
#$ns at 15.0 "$node_(9) setdest 700.0 400.0 5.0"
#$ns at 12.5 "$node_(17) setdest 30.0 300.0 50.0"

# Set a TCP connection between node_(0) and node_(1)
set tcp [new Agent/TCP/Newreno]
$tcp set class_ 2
set sink [new Agent/TCPSink]
$ns attach-agent $node_(0) $tcp
$ns attach-agent $node_(3) $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at 10.0 "$ftp start"

# Printing the window size
proc plotWindow {tcpSource file} {
global ns
set time 0.01
set now [$ns now]
set cwnd [$tcpSource set cwnd_]
puts $file "$now $cwnd"
$ns at [expr $now+$time] "plotWindow $tcpSource $file" }
$ns at 10.1 "plotWindow $tcp $windowVsTime2"

# Define node initial position in nam
for {set i 0} {$i < $val(nn)} { incr i } {
# 30 defines the node size for nam
$ns initial_node_pos $node_($i) 30
}

# Telling nodes when the simulation ends
for {set i 0} {$i < $val(nn) } { incr i } {
    $ns at $val(stop) "$node_($i) reset";
}

# ending nam and the simulation
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "stop"
$ns at 150.01 "puts \"end simulation\" ; $ns halt"
proc stop {} {
    global ns tracefd namtrace
    $ns flush-trace
    close $tracefd
    close $namtrace
}

$ns run

                                          
_________________________________________________________________
Hotmail: Trusted email with powerful SPAM protection.
http://clk.atdmt.com/GBL/go/201469227/direct/01/

Reply via email to