[ns] Fwd: ns2 wpan simulation: Bug?
Devashish
devashishsethia at gmail.com
Tue Jun 14 07:43:21 PDT 2011
I am working on ns2 and need to simulate a simple application on lines of
ping. I'm using the ns2.34 build and it comes with the wpan module. When I
tried to test the application with a ping agent. It throws the error,
"Scheduler: Event UID not valid".
here is the tcl scrip i'm using and the simple ping agent available under
apps folder.
---------------------------------------------------------------------------------------------------------------------------------------------------
# ======================================================================
# Define options
# ======================================================================
set val(chan) Channel/WirelessChannel ;# Channel Type
set val(prop) Propagation/TwoRayGround ;# radio-propagation
model
set val(netif) Phy/WirelessPhy/802_15_4
set val(mac) Mac/802_15_4
set val(ifq) Queue/DropTail ;# interface queue type
set val(ll) LL ;# link layer type
set val(ant) Antenna/OmniAntenna ;# antenna model
set val(ifqlen) 100000 ;# max packet in ifq
set val(nn) 2 ;# number of mobilenodes
set val(rp) AODV ;# routing protocol
set val(x) 50
set val(y) 50
set val(nam) 1.nam
set stopTime 50 ;# in seconds
# Initialize Global Variables
set ns_ [new Simulator]
set tracefd [open ./1.tr w]
$ns_ trace-all $tracefd
if { "$val(nam)" == "1.nam" } {
set namtrace [open ./$val(nam) w]
$ns_ namtrace-all-wireless $namtrace $val(x) $val(y)
}
$ns_ puts-nam-traceall {# nam4wpan #} ;# inform nam that this is a trace
file for wpan (special handling needed)
Mac/802_15_4 wpanCmd verbose on
Mac/802_15_4 wpanNam namStatus on ;# default = off (should be turned on
before other 'wpanNam' commands can work)
#Mac/802_15_4 wpanNam ColFlashClr gold ;# default = gold
# For model 'TwoRayGround'
set dist(5m) 7.69113e-06
set dist(9m) 2.37381e-06
set dist(10m) 1.92278e-06
set dist(11m) 1.58908e-06
set dist(12m) 1.33527e-06
set dist(13m) 1.13774e-06
set dist(14m) 9.81011e-07
set dist(15m) 8.54570e-07
set dist(16m) 7.51087e-07
set dist(20m) 4.80696e-07
set dist(25m) 3.07645e-07
set dist(30m) 2.13643e-07
set dist(35m) 1.56962e-07
set dist(40m) 1.20174e-07
Phy/WirelessPhy set CSThresh_ $dist(30m)
Phy/WirelessPhy set RXThresh_ $dist(30m)
# set up topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
# Create God
set god_ [create-god $val(nn)]
set chan_1_ [new $val(chan)]
# configure node
$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) \
-topoInstance $topo \
-agentTrace OFF \
-routerTrace OFF \
-macTrace ON \
-movementTrace OFF \
-channel $chan_1_
set node_(0) [$ns_ node]
$node_(0) random-motion 0 ;# disable random motion
$ns_ node-config -adhocRouting $val(rp) \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen 2 \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-topoInstance $topo \
-agentTrace OFF \
-routerTrace OFF \
-macTrace ON \
-movementTrace OFF \
-channel $chan_1_
set node_(1) [$ns_ node]
$node_(1) random-motion 0 ;# disable random motion
$node_(0) set X_ 25
$node_(0) set Y_ 25
$node_(0) set Z_ 0
$node_(1) set X_ 25
$node_(1) set Y_ 15
$node_(1) set Z_ 0
$ns_ at 0.0 "$node_(0) NodeLabel PAN Coor"
$ns_ at 0.0 "$node_(0) sscs startPANCoord 1 2 2" ;# startPANCoord
<txBeacon=1> <BO=3> <SO=3>
$ns_ at 15 "$node_(1) sscs startDevice 0 0"
Mac/802_15_4 wpanNam PlaybackRate 3ms
$ns_ at 25 "puts \"\nTransmitting data ...\n\""
Mac/802_15_4 wpanCmd ack4data off
# Setup traffic flow between nodes
set r [new Agent/Ping]
$ns_ attach-agent $node_(0) $r
set c [new Agent/Null]
$ns_ attach-agent $node_(1) $c
$ns_ connect $r $c
$ns_ at 28.0005 "$r send"
# defines the node size in nam
for {set i 0} {$i < $val(nn)} {incr i} {
$ns_ initial_node_pos $node_($i) 0.5
}
# Tell nodes when the simulation ends
for {set i 0} {$i < $val(nn) } {incr i} {
$ns_ at $stopTime "$node_($i) reset";
}
$ns_ at $stopTime "stop"
$ns_ at $stopTime "puts \"NS EXITING...\n\""
$ns_ at $stopTime "$ns_ halt"
proc stop {} {
global ns_ tracefd appTime1 val env
$ns_ flush-trace
close $tracefd
set hasDISPLAY 0
foreach index [array names env] {
#puts "$index: $env($index)"
if { ("$index" == "DISPLAY") && ("$env($index)" != "") } {
set hasDISPLAY 1
}
}
if { ("$val(nam)" == "1.nam") && ("$hasDISPLAY" == "1") } {
exec nam beacon_enabled_star.nam &
}
}
puts "\nStarting Simulation..."
$ns_ run
______________________________________________________________________________________________________________________________
rohit at rohit-laptop:~/ns2/ns-allinone-2.34/ns-2.34/examples$ ns 1.tcl
num_nodes is set 2
INITIALIZE THE LIST xListHead
Starting Simulation...
--- startPANCoord [0] ---
[0.000000](node 0) performing active channel scan
[0.000000](node 0) scanning channel 11
channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_ = 1.5, distCST_ = 50.8
SORTING LISTS ...DONE!
[0.080000](node 0) scanning channel 12
[0.159040](node 0) scanning channel 13
[0.239040](node 0) begin to transmit beacons
[0.239808](node 0) successfully started a new PAN (beacon enabled)
[channel:11] [PAN_ID:0]
--- startDevice [1] ---
[15.000000](node 1) performing active channel scan ...
[15.000000](node 1) scanning channel 11
[15.262400](node 1) scanning channel 12
[15.524800](node 1) scanning channel 13
[15.786880](node 1) sending association request to [channel:11] [PAN_ID:0]
[CoordAddr:0] ...
[15.788928](node 1) sending association request command ...
[15.790624](node 1) ack for association request command received
[16.282144](node 1) sending data request command ...
[16.283424](node 1) ack for data request command received
[16.285888](node 1) association response command received
[16.285888](node 1) association successful (beacon enabled) [channel:11]
[PAN_ID:0] [CoordAddr:0]
[16.285888](node 1) begin to synchronize with the coordinator
Transmitting data ...
Scheduler: Event UID not valid!
I tried searching for help on the interned but all in vain. I wanted to know
if it's a bug. if yes, is there a way to fix this? Any help in this regard
will be highly appreciated. Thanks in advance.
Regards,
Devashish Sethia
More information about the Ns-users
mailing list