I am new in ns2 simulation, if this question is easy I am sorry for that.This is my tcl code and I created my scenario file with this code:
./setdest -n 250 -p 0.0 -M 10.0 -t 10 -x 1500 -y 1500 > S250
and also
ns cbrgen.tcl -type tcp -nn 250 -seed 1.0 -mc 100 > T250
but when i tried run simulation i shown this error.
can't read "ns_": no such variable
while executing
"global $ns_"
(file "wireless.tcl" line 24)
Can you help me about this topic? It would be much appreciated.
# ======================================================================
# 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) 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) 250 ;# number of mobilenodes
set val(rp) AODV ;# routing protocol
set val(cp) T250
set val(sc) S250
# ==================================================== =================
# Main Program
# ======================================================================
set ns [new Simulator]
set tracefd [open out.tr w]
set winfile [open winFile w]
global $ns_
$ns trace-all $tracefd
set namtrace [open out.nam w]
$ns namtrace-all-wireless $namtrace 1500 1500
set topo [new Topography]
$topo load_flatgrid 1500 1500
create-god $val(nn)
$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 OFF \
-mvementTrace ON \
for {set i 0} {$i < $val(nn) } {incr i} {
set node_($i) [$ns_ node]
}
puts "Loading scenario file..."
source $val(sc)
puts "Loading connection pattern..."
source $val(cp)
# Tell nodes when the simulation ends
for {set i 0} {$i < $val(nn) } {incr i} {
$ns_ at 10.0 "$node_($i) reset";
}
$ns_ at 10.0 "stop"
$ns_ at 10.01 "puts \"NS EXITING...\" ; $ns_ halt"
proc stop {} {
global ns_ tracefd
$ns_ flush-trace
close $tracefd
exec nam out.nam &
exit 0
}
puts "Starting Simulation..."
$ns_ run
Try
instead of
ns_
is the name of the varible.$ns_
is the variable's value. You declare it by its name.