Hi all,

I am trying to simulation a lossy link in a wireless environment using the ErrorModel. However the code I inserted to simulate a uniform packet loss has no effect on my results (see below). Can anyone tell me what I am doing wrong. I am using version 2.29.


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
           Mac/802_11 set dataRate_ 54Mb        ;# Data Rate
           Mac/802_11 set basicRate_ 6Mb        ;# Data Rate
           Mac/802_11 set RTSThreshold_ 3000    ;# Turn off RTS / CTS
           Mac/802_11 set CWMin_ 15
           Mac/802_11 set CWMax_ 1023
           Mac/802_11 set SlotTime_ 0.000009
           Mac/802_11 set sifs_ 0.000016
           Mac/802_11 set PreambleLenght_ 16
           Mac/802_11 set PLCPHeaderLength_ 24
           Mac/802_11 set PLCPDataRate_ 6Mb
           Mac/802_11 set ShortRetryLimit_ 7
           Mac/802_11 set LongRetryLimit_ 4
           Mac/802_11 set CCAtime_ 0.000004

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)             2                          ;# number of mobilenodes
set val(rp)             DSDV                       ;# routing protocol DSDV

set ns [new Simulator]

$ns color 0 blue
$ns color 1 red

# set up topography object
set topo [new Topography]
$topo load_flatgrid 400 200

#Open the trace file
set tf [open gAnalysis.tr w]
$ns trace-all $tf

#Open the nam trace file
set nf [open gAnalysis.nam w]
$ns namtrace-all-wireless $nf 400 200

# Create God
create-god $val(nn)

Agent/DSDV set perup_       15000000   ;# ~ infinite periodic update

       $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 OFF \
           -macTrace ON \
           -movementTrace OFF \
           -inerrProc uniformErr - outerrProc uniformErr

set nodeBase [$ns node] $nodeBase random-motion 0
$nodeBase set X_ 100.0
$nodeBase set Y_ 100.0
$nodeBase set Z_ 0.0

set nodeA [$ns node] $nodeA random-motion 0
$nodeA set X_ 300.0
$nodeA set Y_ 100.0
$nodeA set Z_ 0.0

$ns at 0.0 "$nodeBase setdest 100.0 100.0 0.0"
$ns at 0.0 "$nodeA setdest 300.0 100.0 0.0"

set udpBaseA [new Agent/UDP]
$ns attach-agent $nodeBase $udpBaseA
$udpBaseA set packetSize_ 2068
#$udpBaseA set dst_addr_ -1
#$udpBaseA set dst_port_ 0

set cbrBaseA [new Application/Traffic/CBR]
$cbrBaseA attach-agent $udpBaseA
$cbrBaseA set type_ CBR
$cbrBaseA set packetSize_ 2048
$cbrBaseA set interval_ 0.005
#$cbrBaseA set rate_ 40Mb
$cbrBaseA set random_ false

set sinkA [new Agent/LossMonitor]
$ns attach-agent $nodeA $sinkA
$ns connect $udpBaseA $sinkA

# Start Simulation

$ns at 1.0 "$cbrBaseA start"
$ns at 4.0 "$cbrBaseA stop"
$ns at 5.0000001 "stop"
$ns at 5.0000002 "puts \"NS EXITING...\" ; $ns halt"

proc uniformErr {} {

   set err [new ErrorModel]
   $err unit packet
   $err set rate_ 0.25
   $err ranvar [new RandomVariable/Uniform]
   $err drop-target [new Agent/Null]
   return $err

proc stop {} {
   global ns tf nf
   $ns flush-trace
   close $nf
   close $tf
   exec nam gAnalysis.nam &
   exit 0

puts "Starting Simulation..."
$ns run

Reply via email to