---------- Forwarded message ---------- From: davesh som <java.davesh...@gmail.com> Date: Tue, Sep 11, 2012 at 10:14 AM Subject: problem regarding random waypoint model implementation To: ns-users@isi.edu
hello ns-2 users my name is davesh som and i am having problem with my aodv ns-2 implementation.My code works fine if i am using 2rayground model but i want to perform the simulation using RANDOM WAYPOINT MODEL.I am new to the ns-2 so please can anyone guide me that how should i do that with the same code i mention in this mail.I attach my code here please go through it. Thanks in advance. *aodv10.tcl* 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) 250 ;# max packet in ifq set val(nn) 10 ;# number of mobilenodes set val(rp) AODV ;# routing protocol set val(x) 1000 ;# X dimension of topography set val(y) 1000 ;# Y dimension of topography #CMUTrace set newtrace_ 1 #set RouterTrace ON #set MacTrace ON Phy/WirelessPhy set CPThresh_ 10.0 Phy/WirelessPhy set CSThresh_ 1.559e-11 Phy/WirelessPhy set RXThresh_ 3.652e-10 Phy/WirelessPhy set bandwidth_ 2e6 Phy/WirelessPhy set Pt_ 0.2818 Phy/WirelessPhy set freq_ 914e+6 Phy/WirelessPhy set L_ 1.0 set ns [new Simulator] set f [open output.tr w] $ns trace-all $f set namtrace [open AODV10.nam w] $ns namtrace-all-wireless $namtrace $val(x) $val(y) $ns use-newtrace set f0 [open throughput1.tr w] set f1 [open throughput2.tr w] set f2 [open throughput3.tr w] set f3 [open packetdrop1.tr w] set f4 [open packetdrop2.tr w] set f5 [open packetdrop3.tr w] set f6 [open delay1.tr w] set f7 [open delay2.tr w] set f8 [open delay3.tr w] set topo [new Topography] $topo load_flatgrid 1000 1000 create-god $val(nn) $ns node-config -adhocRouting AODV \ -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 \ proc finish {} { global ns f f0 f1 f2 f3 f4 f5 f6 f7 f8 namtrace $ns flush-trace close $namtrace close $f0 close $f1 close $f2 close $f3 close $f4 close $f5 close $f6 close $f7 close $f8 exec ./xgraph throughput1.tr throughput2.tr throughput3.tr -geometry 800x400 -t "AODV Throughput" -x "Time" -y "No.of Packets" -bg white & exec ./xgraph packetdrop1.tr packetdrop2.tr packetdrop3.tr -geometry 800x400 -t "AODV Packet Drop" -x "Time" -y "No.of Packets" -bg white & exec ./xgraph delay1.tr delay2.tr delay3.tr -geometry 800x400 -t "AODV Delay Level" -x "Time" -y "No.of Packets" -bg white & exec ./nam AODV10.nam & exit 0 } set n(0) [$ns node] $n(0) set X_ 0.0 $n(0) set Y_ 0.0 $n(0) set Z_ 0.0 set n(1) [$ns node] $n(1) set X_ 0.0 $n(1) set Y_ 0.0 $n(1) set Z_ 0.0 set n(2) [$ns node] $n(2) set X_ 0.0 $n(2) set Y_ 0.0 $n(2) set Z_ 0.0 set n(3) [$ns node] $n(3) set X_ 0.0 $n(3) set Y_ 0.0 $n(3) set Z_ 0.0 set n(4) [$ns node] $n(4) set X_ 0.0 $n(4) set Y_ 0.0 $n(4) set Z_ 0.0 set n(5) [$ns node] $n(5) set X_ 0.0 $n(5) set Y_ 0.0 $n(5) set Z_ 0.0 set n(6) [$ns node] $n(6) set X_ 0.0 $n(6) set Y_ 0.0 $n(6) set Z_ 0.0 set n(7) [$ns node] $n(7) set X_ 0.0 $n(7) set Y_ 0.0 $n(7) set Z_ 0.0 set n(8) [$ns node] $n(8) set X_ 0.0 $n(8) set Y_ 0.0 $n(8) set Z_ 0.0 set n(9) [$ns node] $n(9) set X_ 0.0 $n(9) set Y_ 0.0 $n(9) set Z_ 0.0 for {set i 0} {$i < $val(nn)} {incr i} { $ns initial_node_pos $n($i) 30+i*100 } $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" $ns at 0.0 "$n(6) setdest 550.0 30.0 3000.0" $ns at 0.0 "$n(7) setdest 15.0 350.0 3000.0" $ns at 0.0 "$n(8) setdest 600.0 340.0 3000.0" $ns at 0.0 "$n(9) setdest 180.0 240.0 3000.0" $ns at 1.5 "$n(3) setdest 134.868 84.518 15.0" $ns at 2.0 "$n(5) setdest 170.566.0 106.349 15.0" $ns at 5.1 "$n(8) setdest 160.0 740.0 15.0" $ns at 5.2 "$n(9) setdest 350.0 200.0 15.0" $ns at 6.9 "$n(9) setdest 330.0 400.0 15.0" $n(0) color blue $ns at 1.0 "$n(0) color blue" $n(7) color blue $ns at 1.0 "$n(7) color blue" $ns at 1.0 "$n(0) label Source1" $ns at 1.0 "$n(7) label Destination1" $n(2) color brown $ns at 1.0 "$n(2) color brown" $ns at 1.0 "$n(2) label source2" $n(5) color brown $ns at 1.0 "$n(5) color brown" $ns at 1.0 "$n(5) label Destination2" $n(3) color darkgreen $ns at 1.0 "$n(3) color darkgreen" $ns at 1.0 "$n(3) label source3" $n(8) color darkgreen $ns at 1.o "$n(8) color darkgreen" $ns at 1.0 "$n(8) label Destination3" # CONFIGURE AND SET UP A FLOW proc record {} { global sink7 sink5 sink8 f0 f1 f2 f3 f4 f5 f6 f7 f8 set ns [Simulator instance] set time 0.9 set bw0 [$sink7 set bytes_] set bw1 [$sink5 set bytes_] set bw2 [$sink8 set bytes_] set bw3 [$sink7 set nlost_] set bw4 [$sink5 set nlost_] set bw5 [$sink8 set nlost_] set bw6 [$sink7 set lastPktTime_] set bw7 [$sink7 set npkts_] set bw8 [$sink5 set lastPktTime_] set bw9 [$sink5 set npkts_] set bw10 [$sink8 set lastPktTime_] set bw11 [$sink8 set npkts_] set now [$ns now] # Record Bit Rate in Trace Files puts $f0 "$now [expr (($bw0)*8)/(2*$time*1000000)]" puts $f1 "$now [expr (($bw1)*8)/(2*$time*1000000)]" puts $f2 "$now [expr (($bw2)*8)/(2*$time*1000000)]" # Record Packet Loss Rate in File puts $f3 "$now [expr $bw3/$time]" puts $f4 "$now [expr $bw4/$time]" puts $f5 "$now [expr $bw5/$time]" #record the packet delay in file if { $bw7 > 0} { puts $f6 "$now [expr ($bw6)/($bw7)]" } else { puts $f6 "$now [expr ($bw7)]" } if { $bw9 > 0 } { puts $f7 "$now [expr ($bw8)/($bw9)]" } else { puts $f7 "$now [expr ($bw9)]" } if { $bw11 > 0 } { puts $f8 "$now [expr ($bw10)/($bw11)]" } else { puts $f8 "$now [expr ($bw11)]" } $ns at [expr $now+$time] "record" ;# Schedule Record after $time } proc PerHopTime {} { puts"time delay $now [expr ($n(0)+$time)]" } 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] set sink6 [new Agent/LossMonitor] set sink7 [new Agent/LossMonitor] set sink8 [new Agent/LossMonitor] set sink9 [new Agent/LossMonitor] set sink10 [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 $n(6) $sink6 $ns attach-agent $n(7) $sink7 $ns attach-agent $n(8) $sink8 $ns attach-agent $n(9) $sink9 set tcp0 [new Agent/TCP] $tcp0 set prio_ 1 $ns attach-agent $n(0) $tcp0 set tcp1 [new Agent/TCP] $tcp1 set prio_ 2 $ns attach-agent $n(1) $tcp1 set tcp2 [new Agent/TCP] $tcp2 set prio_ 3 $ns attach-agent $n(2) $tcp2 set tcp3 [new Agent/TCP] $tcp3 set prio_ 4 $ns attach-agent $n(3) $tcp3 set tcp4 [new Agent/TCP] $tcp4 set prio_ 5 $ns attach-agent $n(4) $tcp4 set tcp5 [new Agent/TCP] $tcp5 set prio_ 6 $ns attach-agent $n(5) $tcp5 set tcp6 [new Agent/TCP] $tcp6 set prio_ 7 $ns attach-agent $n(6) $tcp6 set tcp7 [new Agent/TCP] $tcp7 set prio_ 8 $ns attach-agent $n(7) $tcp7 set tcp8 [new Agent/TCP] $tcp8 set prio_ 9 $ns attach-agent $n(8) $tcp8 set tcp9 [new Agent/TCP] $tcp9 set prio_ 10 $ns attach-agent $n(9) $tcp9 proc attach-CBR-traffic { node sink size interval } { #Get an instance of the simulator set ns [Simulator instance] #Create a CBR sink14 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) $sink7 512 .042] set cbr1 [attach-CBR-traffic $n(2) $sink5 512 .041] set cbr2 [attach-CBR-traffic $n(3) $sink8 512 .041] $ns at 0.0 "record" $ns at 1.0 "$cbr0 start" $ns at 2.0 "$cbr1 start" $ns at 3.0 "$cbr2 start" $ns at 10.0 "finish" puts "Start of simulation.." $ns run