[ns] Error model in wireless network

Xiaofei ZHANG xiaofei.zhang at etu.upmc.fr
Sat Jul 26 12:03:25 PDT 2008


but it doesn't work aussi.
 
here is my code, could you please help me to check what's wrong with it?
 
thank you very much ! 
 
#============ start of code ========================
 
# Get optionsproc getopt {argc argv} { if {$argc <= 1 } {  puts "Usage : ns wireless-cmt-simple.tcl EndTime LossRate"  exit 0 } else {  global opt  lappend optlist n  for {set i 0} {$i<$argc} {incr i} {   set opt($i) [lindex $argv $i]  } }}
getopt $argc $argv
set opt(chan) Channel/WirelessChannelset opt(prop) Propagation/TwoRayGround               ;# radio-propagation model£ºTwoRayGroundset opt(netif) Phy/WirelessPhy                         ;# network interface typeset opt(unit)       pkt                                     set opt(mac) Mac/802_11                              ;# MAC typeset opt(ifq) Queue/DropTail/PriQueue                  ;# interface queue typeset opt(ll)  LL                                       ;# link layer type set opt(ant)        Antenna/OmniAntenna                      ;# antenna modelset opt(rp)         DSDVset opt(x)  1000                                ;# X dimension of the topography set opt(y)  1000                             ;# Y dimension of the topography   set opt(ifqlen) 50                                  ;# max packet in ifqset opt(seed) 0.0                                      ;set opt(tr)  wireless-tcp-err    ;# trace file              set opt(start)      0.0set opt(stop)         $opt(0)   !
 ;#end time of simulationset opt(errrate1)   $opt(1)set opt(nn)   2
 
# Initialize the Errormodel
#Set Errorglobal defaultRNG$defaultRNG seed $opt(seed)puts [$defaultRNG seed]
 
proc UniformErrorProc {} {    global opt    set errObj [new ErrorModel]    $errObj unit $opt(unit)    $errObj set rate_ $opt(errrate1)    $errObj ranvar [new RandomVariable/Uniform]#    $errObj drop-target [new Agent/Null]    return $errObj}
 
set ns [new Simulator]
 
#$ns use-newtrace#Trace set show_sctphdr_ 1
set tracefd [open $opt(tr).tr w]$ns trace-all $tracefd
#set namtrace [open $opt(tr).nam w]#$ns namtrace-all-wireless $namtrace $opt(x) $opt(y)
 
set topo [new Topography]$topo load_flatgrid $opt(x) $opt(y)
 
create-god [expr $opt(nn)]
set chan_1_ [new $opt(chan)]
 
$ns node-config  -adhocRouting $opt(rp) \                 -llType $opt(ll) \                 -macType $opt(mac) \                 -ifqType $opt(ifq) \                 -ifqLen $opt(ifqlen) \                 -antType $opt(ant) \                 -propType $opt(prop) \                 -phyType $opt(netif) \                 -channel $chan_1_ \                 -topoInstance $topo \                 -agentTrace ON \                 -routerTrace OFF \                 -macTrace OFF \                 -movementTrace OFF \                 -IncomingErrProc UniformErrorProc -OutgoingErrProc UniformErrorProc#-errProc UniformErrorProc
 
#puts "Error model test - path 1 loss rate = $opt(errrate1)."set host0 [$ns node]set host1 [$ns node]
 
$host0 set X_ 100.0$host0 set Y_ 0.0$host0 set Z_ 0.0
$host1 set X_ 130.0$host1 set Y_ 0.0$host1 set Z_ 0.0
$ns initial_node_pos $host0 10$ns initial_node_pos $host1 10
 
set oldcwnd0 0set cwndfile0 [open "$opt(tr)-cwnd0.data" w]
 
set tcp0 [new Agent/TCP/Newreno]$ns attach-agent $host0 $tcp0$tcp0 set packetSize_ 1000$tcp0 set window_ 24$tcp0 set fid_ 0set sink0 [new Agent/TCPSink]$ns attach-agent $host1 $sink0$ns connect $tcp0 $sink0
set ftp0 [new Application/FTP]$ftp0 attach-agent $tcp0
 
$ns at 0.0 "record"$ns at $opt(start) "$ftp0 start"$ns at $opt(stop) "finish"
 
proc finish {} {        global opt ns tracefd cwndfile0 tcp0 set now [$ns now] set cwnd0 [$tcp0 set cwnd_] puts $cwndfile0 "[format "%.2f" $now] $cwnd0"        $ns flush-trace close $tracefd close $cwndfile0 puts "Done." exec xgraph "$opt(tr)-cwnd0.data" &        exit 0}
 
proc record {} { global opt ns tcp0 cwndfile0 oldcwnd0 set now [$ns now] set time 0.001 set cwnd0 [$tcp0 set cwnd_] if {$cwnd0 != $oldcwnd0} {  set oldcwnd0 $cwnd0  puts $cwndfile0 "[format "%.2f" $now] $cwnd0" } $ns at [expr $now+$time] "record"}
 
puts "Start Simulation..."
# run the simulation$ns run#============ end of code ========================



Date: Sat, 26 Jul 2008 19:15:11 +0100From: lmcbarreto at gmail.comTo: xiaofei.zhang at etu.upmc.frSubject: Re: [ns] Error model in wireless networkCC: ns-users at isi.edu
Try this------------$ns node-config -errProc UniformErr
proc UniformErr {} {    set err [new ErrorModel]
    $err unit packet    return $err
}------------it seems IncomingErrProc and -OutgoingErrProc options are no longer 
supportedLu¨ªs Barreto
On Sat, Jul 26, 2008 at 3:52 PM, ZHANG Xiaofei <xiaofei.zhang at etu.upmc.fr> wrote:
Hi ns users,I try to add some drops in wireless links following the methode of ns manual: IncomingErrProc and OutgoingErrProc.proc UniformErr {} {set err [new ErrorModel]$err unit packet$err rate_  0.01return $err}$ns node-config -IncomingErrProc UniformErr -OutgoingErrProc UniformErrbut I didn't see any packets dropped in the trace file. What am I doingwrong?How to configure the error model in wireless network?thank you very much,
_________________________________________________________________
Retouchez, classez et partagez vos photos gratuitement avec le logiciel Galerie de Photos !
http://www.windowslive.fr/galerie/


More information about the Ns-users mailing list