[ns] Cant find the bug in the code!!! --plz help

Sharath sharath at iitb.ac.in
Wed May 26 21:08:25 PDT 2004


have written a tcl to simulate n nodes connected in a circle...when i put
rts threshold high so that it doesnt send rts/cts it gives errors for most
values of the parameters i chose.. Im giving the errror output withthe gdb
backtrace..... dont know the data structures used in mac... 
please help.....

error output as follows
[root at Inferno ns-work]# gdb ns
GNU gdb Red Hat Linux (5.2.1-4)
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux"...
(gdb) break abort
Breakpoint 1 at 0x804f036: file common/tclAppInit.cc, line 193.
(gdb) run sjg.tcl -nn 5 -stoptime 50 -packetsize 1000 -rtsthreshold 3000
Starting program: /usr/local/ns-allinone-2.27/ns-2.27/ns sjg.tcl -nn 5
-stoptime 50 -packetsize 1000 -rtsthreshold 3000
==================System Parameters==============================================================
nn=5 stoptime=50  topology x=70    topology y=70
============Exponential Traffic Gen Parameters===================================================
Burst = 0s   Delay =  0.5s Packetsize = 1000 Send Rate =11e6
====================MAC Parameters===============================================================
Data Rate = 11e6  RTS Threshold = 3000
=================================================================================================
num_nodes is set 5
INITIALIZE THE LIST xListHead
Loading mobile node distribution
Starting Simulation ...
SORTING LISTS ...DONE!
channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_ = 1.5,  distCST_ = 274.9
Scheduler: Event UID not valid!


Breakpoint 1, abort () at common/tclAppInit.cc:193
193             Tcl& tcl = Tcl::instance();
(gdb) backtrace
#0  abort () at common/tclAppInit.cc:193
#1  0x082203ae in TclClass::TclClass(char const*) ()
#2  0x080552a6 in Scheduler::schedule(Handler*, Event*, double)
(this=0x85c67f0, h=0x8631bac, e=0x8631bbc,
    delay=1.0000000000000001e-05) at common/scheduler.cc:94
#3  0x08128a3c in DeferTimer::start(double) (this=0x8631bac,
time=1.0000000000000001e-05)
    at mac/mac-timers.cc:127
#4  0x0810b45d in Mac802_11::tx_resume() (this=0x86319d8) at
mac/mac-802_11.cc:774
#5  0x0810d9ea in Mac802_11::recvDATA(Packet*) (this=0x86319d8,
p=0x86b4060) at mac/mac-802_11.cc:2056
#6  0x0810d4bf in Mac802_11::recv_timer() (this=0x86319d8) at
mac/mac-802_11.cc:1869
#7  0x0810b7bf in Mac802_11::recvHandler() (this=0x86319d8) at
mac/mac-802_11.cc:902
#8  0x08128b7e in RxTimer::handle(Event*) (this=0x8631b34) at
mac/mac-timers.cc:187
#9  0x08055454 in Scheduler::dispatch(Event*, double) (this=0x85c67f0,
p=0x8631b44, t=10.501989656312565)
    at common/scheduler.cc:149
#10 0x080553b5 in Scheduler::run() (this=0x85c67f0) at common/scheduler.cc:128
#11 0x08055551 in Scheduler::command(int, char const* const*)
(this=0x85c67f0, argc=2, argv=0xbfffdf3c)
    at common/scheduler.cc:197
#12 0x08220612 in TclClass::dispatch_cmd(void*, Tcl_Interp*, int, char
const**) ()
#13 0x0822410a in OTclDispatch (cd=0x85c66c8, in=0x840e7f8, argc=3,
argv=0xbfffdf90) at otcl.c:432
#14 0x0822898b in TclInvokeStringCommand ()
#15 0x08229917 in TclEvalObjvInternal ()
#16 0x08249df9 in TclExecuteByteCode ()
#17 0x082494b8 in TclCompEvalObj ()
#18 0x08249ee5 in TclExecuteByteCode ()
#19 0x082494b8 in TclCompEvalObj ()
#20 0x0827346e in TclObjInterpProc ()
#21 0x08272fda in TclProcInterpProc ()
#22 0x082242a6 in OTclDispatch (cd=0x85c66c8, in=0x840e7f8, argc=2,
argv=0xbfffe930) at otcl.c:475
#23 0x0822898b in TclInvokeStringCommand ()
#24 0x08229917 in TclEvalObjvInternal ()
#25 0x08249df9 in TclExecuteByteCode ()
#26 0x082494b8 in TclCompEvalObj ()
---Type <return> to continue, or q <return> to quit---q
Quit
(gdb) frame 2
#2  0x080552a6 in Scheduler::schedule(Handler*, Event*, double)
(this=0x85c67f0, h=0x8631bac, e=0x8631bbc,
    delay=1.0000000000000001e-05) at common/scheduler.cc:94
94                      abort();
(gdb) print e->uid_
$1 = 29393




my tcl file is as follows
# ======================================================================
# Define options
# ======================================================================
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)            CMUPriQueue                ;# 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)             DumbAgent                  ;# routing protocol
set val(x)                              70                                 
               ;# x max of grid
set val(y)                              70                                 
               ;# y max of grid
set val(stoptime)               10                                         
       ;# Stop time
set val(rtsthreshold)   3000                                       ;# RTS
Threshold
# ======================================================================

# ============================Exponential Data parameters ==============
set val(datarate)           11e6                                          
;# Data rate for transmit
set val(sendrate)       11e6                       ;# Data rate of traffic
generated
set val(packetsize)     1000                       ;# Packet size defaulted
to opt pac size for mac
set val(expdelay)       0.5s                       ;# Exponential delay
set val(expburst)       0s                         ;# Exponential Traffic
burst
set val(explambda)      2                          ;# Value of Lambda
# ======================================================================


# ======================================================================
# Main Program
# ======================================================================

# =======================Initialize Global Variables====================

set  ns_                        [new Simulator]


# =======================Get Arguments as parameters from shell=========

proc getval {argc argv} {
        global val
        lappend vallist nn stoptime
        for {set i 0} {$i < $argc} {incr i} {
                set arg [lindex $argv $i]
                if {[string range $arg 0 0] != "-"} continue
                set name [string range $arg 1 end]
                set val($name) [lindex $argv [expr $i+1]]
        }
}

getval $argc $argv

# ====================================================================================================


puts "==================System Parameters=============================================================="
puts "nn=$val(nn) stoptime=$val(stoptime)  topology x=$val(x)    topology
y=$val(y)"
puts "============Exponential Traffic Gen Parameters==================================================="
puts "Burst = $val(expburst)   Delay =  $val(expdelay) Packetsize =
$val(packetsize) Send Rate =$val(sendrate)"puts "====================MAC
Parameters==============================================================="
puts "Data Rate = $val(datarate)  RTS Threshold = $val(rtsthreshold)"
puts "================================================================================================="


set stoptime_ $val(stoptime)

$ns_ use-newtrace
#$ns_ use-smalltrace


set tracefd [open sjg.tr w]
$ns_ trace-all $tracefd


#set namtrace [open sjg.nm w]
#$ns_ namtrace-all-wireless $namtrace $val(x) $val(y)



#Set -66 dBm of both RX and CS Threshold
Phy/WirelessPhy set CSThresh_ 2.5e-10
Phy/WirelessPhy set RXThresh_ 2.5e-10



# =======================Set datarate=============================

Mac/802_11 set dataRate_                $val(datarate)
Mac/802_11 set RTSThreshold_    $val(rtsthreshold)
#MAC_MIB set MAC_RTSThreshold   $val(rtsthreshold)
# ================================================================

# ====================Set up topography object====================

set topo [new Topography]
$topo load_flatgrid             $val(x) $val(y)

# ================================================================

# =========================Create God=============================

set god_ [create-god $val(nn)]

# ================================================================




#VARPTable set size_ 3000


# ======================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 [new $val(chan)]


for {set i 0} {$i < $val(nn) } {incr i} {
        set node_($i) [$ns_ node]
        $node_($i) random-motion 0      ;# disable random motion
}

# =================================================================

# =Provide initial (X,Y, for now Z=0) co-ordinates for mobilenodes=

puts "Loading mobile node distribution"
set val(sc)                     "scenarios/scen-$val(nn)-test"
source $val(sc)

# =================================================================


# ==============Setup traffic flow between nodes==================
proc attach-expoo-traffic { node sink size burst idle rate } {
        #Get an instance of the simulator
        set ns [Simulator instance]

        #Create a UDP agent and attach it to the node
        set source [new Agent/UDP]
        $ns attach-agent $node $source

        #Create an Expoo traffic agent and set its configuration parameters
        set traffic [new Application/Traffic/Exponential]
        $traffic set packet-size $size
        $traffic set burst-time $burst
        $traffic set idle-time $idle
        $traffic set rate $rate

        # Attach traffic source to the traffic generator
        $traffic attach-agent $source
        #Connect the source and the sink
        $ns connect $source $sink
        return $traffic

}

# ===========Attach sinks to each of the nodes==============

for {set i 0} {$i < $val(nn) } {incr i} {
        set sink_($i) [new Agent/Null]
        $ns_ attach-agent $node_($i) $sink_($i)
}

# =======Connect sources to sinks in a circular fashion=====

for {set i 0} {$i < [expr $val(nn) - 1] } {incr i} {
        set source_($i) [attach-expoo-traffic $node_($i) $sink_([expr $i +
1]) $val(packetsize) $val(expburst)
$val(expdelay) $val(sendrate)]
}
set source_([expr $val(nn) - 1]) [attach-expoo-traffic $node_([expr
$val(nn) - 1 ]) $sink_(0) $val(packetsize)
$val(expburst) $val(expdelay) $val(sendrate)]


# ============ Start Sending data at 0.5 seconds =============
for {set i 0} {$i < $val(nn) } {incr i} {
        $ns_ at 0.5 "$source_($i) start"
}


# ==============================================================

$ns_ at $stoptime_ "stop"

proc stop {} {
    global ns_ tracefd
    $ns_ flush-trace
    close $tracefd
    exit 0
}
puts "Starting Simulation ..."
$ns_ run


my scenario file for 5 nodes was generated by set dest.. the bug can be
checked with the foll file 
scenarios/scen-5-test   relative to the path of the tcl file....
file is as follows
$node_(0) set X_ 39.921588293205
$node_(0) set Y_ 52.113054832331
$node_(0) set Z_ 0.000000000000
$node_(1) set X_ 60.541677871409
$node_(1) set Y_ 53.586663423578
$node_(1) set Z_ 0.000000000000
$node_(2) set X_ 68.215098958169
$node_(2) set Y_ 40.167816003064
$node_(2) set Z_ 0.000000000000
$node_(3) set X_ 37.458311075188
$node_(3) set Y_ 64.862060372557
$node_(3) set Z_ 0.000000000000
$node_(4) set X_ 37.355298220623
$node_(4) set Y_ 44.490444926548
$node_(4) set Z_ 0.000000000000
$ns_ at 0.000000000000 "$node_(0) setdest 63.283520928345 12.754967369380
0.060875579613"
$ns_ at 0.000000000000 "$node_(1) setdest 31.231945689359 2.866034471927
0.026348574292"
$ns_ at 0.000000000000 "$node_(2) setdest 10.242748074348 24.669398709954
0.021166211204"
$ns_ at 0.000000000000 "$node_(3) setdest 7.173092212063 29.893336824098
0.056113479815"
$ns_ at 0.000000000000 "$node_(4) setdest 17.265273924260 53.952297070547
0.097243158456"
$god_ set-dist 0 1 1
$god_ set-dist 0 2 1
$god_ set-dist 0 3 1
$god_ set-dist 0 4 1
$god_ set-dist 1 2 1
$god_ set-dist 1 3 1
$god_ set-dist 1 4 1
$god_ set-dist 2 3 1
$god_ set-dist 2 4 1
$god_ set-dist 3 4 1

    hve been stuck with this ubg for quite some time now... any help will
be appreciated..
thanx in advance...
regards,
sharath




More information about the Ns-users mailing list