Hello,
I use this script for aodv, when i want to calcualte the PDF (Packet Delivery
Fraction) =number of recived packets/those sent by CBR source.
But i get the anomalous result that are not important. (pdf=0 , for 2
nodes!!!!!!!!!)
and for 10 nodes , i get the anomalous result .
Please help me.
the script:
# 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) 2 ;# number of mobilenodes
set val(rp) AODV ;# routing protocol
#set val(x) [expr $val(nn)*110]
#set val(y) [expr $val(nn)*110]
set val(x) 500
set val(y) 500
set ns [new Simulator]
#ns-random 0
set f [open 1_out.tr w]
$ns trace-all $f
set namtrace [open 1_out.nam w]
$ns namtrace-all-wireless $namtrace $val(x) $val(y)
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
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 # \
#-channel $chan_2 \
#-channel $chan_3 \
#-channel $chan_4 \
#-channel $chan_5 \
#-channel $chan_6
proc finish {} {
global ns f namtrace
#f0 f1 f2 f3
$ns flush-trace
close $namtrace
exec nam -r 5m 1_out.nam &
exit 0
}
proc record {} {
global sink f0 f1 f2 f3
#Get An Instance Of The Simulator
set ns [Simulator instance]
#Set The Time After Which The Procedure Should Be Called Again
set time 0.05
#Get The Current Time
set now [$ns now]
#Re-Schedule The Procedure
$ns at [expr $now+$time] "record"
}
for {set i 1} {$i <= $val(nn)} {incr i} {
set n($i) [$ns node]
$ns at 0.0 "$n($i) setdest [expr $i*90.0 ] [expr $i*90.0 ] 100.0"
}
$ns at 2.0 "$n($val(nn)) setdest 100.0 400.0 100.0"
set sink [new Agent/LossMonitor]
$ns attach-agent $n($val(nn)) $sink
set tcp [new Agent/TCP]
$ns attach-agent $n(1) $tcp
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 cbr [attach-CBR-traffic $n(1) $sink 1000 .015]
$ns at 0.0 "record"
$ns at 1.0 "$cbr start"
$ns at 10.0 "finish"
puts "Start of simulation.."
$ns run