DSDV is NS2.35 is not working
by Anduamlak from LinuxQuestions.org on (#5DKSZ)
Below is my TCL script using DSDV routing protocol but it didn't show the packet exchanges from source to destination and i have got zero value of PDR.
#===================================
# Simulation parameters setup
#===================================
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) 12 ;# number of mobilenodes
set val(rp) DSDV ;# routing protocol
set val(x) 1455 ;# X dimension of topography
set val(y) 666 ;# Y dimension of topography
set val(stop) 10.0 ;# time of simulation end
#===================================
# Initialization
#===================================
#Create a ns simulator
set ns [new Simulator]
$ns use-newtrace
#Setup topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
create-god $val(nn)
#Open the NS trace file
set tracefile [open normal_dsdv.tr w]
$ns trace-all $tracefile
#Open the NAM trace file
set namfile [open normal_dsdvv.nam w]
$ns namtrace-all $namfile
$ns namtrace-all-wireless $namfile $val(x) $val(y)
set chan [new $val(chan)];#Create wireless channel
#===================================
# Mobile node parameter setup
#===================================
$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) \
-channel $chan \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF \
-movementTrace ON
#===================================
# Nodes Definition
#===================================
#Create 12 nodes
puts "Creating nodes..."
for {set i 0} {$i < $val(nn)} {incr i} {
set node_($i) [$ns node]
$node_($i) random-motion 0 ; #disable random motion
}
$node_(0) set X_ 532
$node_(0) set Y_ 438
$node_(0) set Z_ 0.0
$node_(1) set X_ 1355
$node_(1) set Y_ 317
$node_(1) set Z_ 0.0
$node_(2) set X_ 1318
$node_(2) set Y_ 527
$node_(2) set Z_ 0.0
$node_(3) set X_ 1160
$node_(3) set Y_ 405
$node_(3) set Z_ 0.0
$node_(4) set X_ 986
$node_(4) set Y_ 544
$node_(4) set Z_ 0.0
$node_(5) set X_ 646
$node_(5) set Y_ 282
$node_(5) set Z_ 0.0
$node_(6) set X_ 783
$node_(6) set Y_ 513
$node_(6) set Z_ 0.0
$node_(7) set X_ 855
$node_(7) set Y_ 366
$node_(7) set Z_ 0.0
$node_(8) set X_ 711
$node_(8) set Y_ 445
$node_(8) set Z_ 0.0
$node_(9) set X_ 628
$node_(9) set Y_ 566
$node_(9) set Z_ 0.0
$node_(10) set X_ 1123
$node_(10) set Y_ 525
$node_(10) set Z_ 0.0
$node_(11) set X_ 1002
$node_(11) set Y_ 403
$node_(11) set Z_ 0.0
for {set i 0} {$i < $val(nn) } {incr i} {
$ns initial_node_pos $node_($i) 20
}
#labeling source and destination
$ns at 0.0 "$node_(0) label "Source""
$ns at 0.0 "$node_(2) label "destination""
$ns at 0.0 "$node_(5) label "Source1""
$ns at 0.0 "$node_(1) label "destination1""
#===================================
# Generate movement
#===================================
$ns at 1 " $node_(6) setdest 1000 300 15 "
$ns at 2 " $node_(7) setdest 700 400 15 "
$ns at 1 " $node_(8) setdest 600 300 15 "
$ns at 3 " $node_(1) setdest 800 400 15 "
#===================================
# Agents Definition
#===================================
#Setup a UDP connection
set udp1 [new Agent/UDP]
$ns attach-agent $node_(0) $udp1
set null2 [new Agent/Null]
$ns attach-agent $node_(2) $null2
$ns connect $udp1 $null2
#Setup a UDP connection
set udp3 [new Agent/UDP]
$ns attach-agent $node_(5) $udp3
set null4 [new Agent/Null]
$ns attach-agent $node_(1) $null4
$ns connect $udp3 $null4
#===================================
# Applications Definition
#===================================
#Setup a CBR Application over UDP connection
set cbr0 [new Application/Traffic/CBR]
$cbr0 attach-agent $udp1
$ns at 1.0 "$cbr0 start"
$ns at 4.0 "$cbr0 stop"
#Setup a CBR Application over UDP connection
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp3
$ns at 5.0 "$cbr1 start"
$ns at 9.0 "$cbr1 stop"
#===================================
# Termination
#===================================
#Define a 'finish' procedure
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam normal_dsdvv.nam &
exit 0
}
for {set i 0} {$i < $val(nn) } { incr i } {
$ns at $val(stop) "\$node_($i) reset"
}
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "finish"
$ns at $val(stop) "puts "done" ; $ns halt"
$ns run


#===================================
# Simulation parameters setup
#===================================
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) 12 ;# number of mobilenodes
set val(rp) DSDV ;# routing protocol
set val(x) 1455 ;# X dimension of topography
set val(y) 666 ;# Y dimension of topography
set val(stop) 10.0 ;# time of simulation end
#===================================
# Initialization
#===================================
#Create a ns simulator
set ns [new Simulator]
$ns use-newtrace
#Setup topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
create-god $val(nn)
#Open the NS trace file
set tracefile [open normal_dsdv.tr w]
$ns trace-all $tracefile
#Open the NAM trace file
set namfile [open normal_dsdvv.nam w]
$ns namtrace-all $namfile
$ns namtrace-all-wireless $namfile $val(x) $val(y)
set chan [new $val(chan)];#Create wireless channel
#===================================
# Mobile node parameter setup
#===================================
$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) \
-channel $chan \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF \
-movementTrace ON
#===================================
# Nodes Definition
#===================================
#Create 12 nodes
puts "Creating nodes..."
for {set i 0} {$i < $val(nn)} {incr i} {
set node_($i) [$ns node]
$node_($i) random-motion 0 ; #disable random motion
}
$node_(0) set X_ 532
$node_(0) set Y_ 438
$node_(0) set Z_ 0.0
$node_(1) set X_ 1355
$node_(1) set Y_ 317
$node_(1) set Z_ 0.0
$node_(2) set X_ 1318
$node_(2) set Y_ 527
$node_(2) set Z_ 0.0
$node_(3) set X_ 1160
$node_(3) set Y_ 405
$node_(3) set Z_ 0.0
$node_(4) set X_ 986
$node_(4) set Y_ 544
$node_(4) set Z_ 0.0
$node_(5) set X_ 646
$node_(5) set Y_ 282
$node_(5) set Z_ 0.0
$node_(6) set X_ 783
$node_(6) set Y_ 513
$node_(6) set Z_ 0.0
$node_(7) set X_ 855
$node_(7) set Y_ 366
$node_(7) set Z_ 0.0
$node_(8) set X_ 711
$node_(8) set Y_ 445
$node_(8) set Z_ 0.0
$node_(9) set X_ 628
$node_(9) set Y_ 566
$node_(9) set Z_ 0.0
$node_(10) set X_ 1123
$node_(10) set Y_ 525
$node_(10) set Z_ 0.0
$node_(11) set X_ 1002
$node_(11) set Y_ 403
$node_(11) set Z_ 0.0
for {set i 0} {$i < $val(nn) } {incr i} {
$ns initial_node_pos $node_($i) 20
}
#labeling source and destination
$ns at 0.0 "$node_(0) label "Source""
$ns at 0.0 "$node_(2) label "destination""
$ns at 0.0 "$node_(5) label "Source1""
$ns at 0.0 "$node_(1) label "destination1""
#===================================
# Generate movement
#===================================
$ns at 1 " $node_(6) setdest 1000 300 15 "
$ns at 2 " $node_(7) setdest 700 400 15 "
$ns at 1 " $node_(8) setdest 600 300 15 "
$ns at 3 " $node_(1) setdest 800 400 15 "
#===================================
# Agents Definition
#===================================
#Setup a UDP connection
set udp1 [new Agent/UDP]
$ns attach-agent $node_(0) $udp1
set null2 [new Agent/Null]
$ns attach-agent $node_(2) $null2
$ns connect $udp1 $null2
#Setup a UDP connection
set udp3 [new Agent/UDP]
$ns attach-agent $node_(5) $udp3
set null4 [new Agent/Null]
$ns attach-agent $node_(1) $null4
$ns connect $udp3 $null4
#===================================
# Applications Definition
#===================================
#Setup a CBR Application over UDP connection
set cbr0 [new Application/Traffic/CBR]
$cbr0 attach-agent $udp1
$ns at 1.0 "$cbr0 start"
$ns at 4.0 "$cbr0 stop"
#Setup a CBR Application over UDP connection
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp3
$ns at 5.0 "$cbr1 start"
$ns at 9.0 "$cbr1 stop"
#===================================
# Termination
#===================================
#Define a 'finish' procedure
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam normal_dsdvv.nam &
exit 0
}
for {set i 0} {$i < $val(nn) } { incr i } {
$ns at $val(stop) "\$node_($i) reset"
}
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "finish"
$ns at $val(stop) "puts "done" ; $ns halt"
$ns run