【发布时间】:2014-09-01 10:05:35
【问题描述】:
你好,我试图在终端中调用这个 tcl,但它给了我这个错误
num_nodes is set 0
warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl
can't read "node_(0)": no such variable
while executing
"$node_(0) set X_ 133.516460138239"
(file "/tmp/mob.tcl" line 4)
invoked from within
"source.orig /tmp/mob.tcl"
("uplevel" body line 1)
invoked from within
"uplevel source.orig [list $fileName]"
invoked from within
"if [$instance_ is_http_url $fileName] {
set buffer [$instance_ read_url $fileName]
uplevel eval $buffer
} else {
uplevel source.orig [list $fileName]
..."
(procedure "source" line 8)
invoked from within
"source "/tmp/mob.tcl" "
(file "mobilita_source.tcl" line 125)
而tcl文件是
#定义离子
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 RTSThreshold_ 500 ;
Mac/802_11 set dataRate_ 24Mb ;
Mac/802_11 set basicRate_ 6Mb ;
Mac/802_11 set CWMin_ 31 ;
Mac/802_11 set CWMAX_ 1023 ;
Mac/802_11 set SlotTime_ 0.000009 ;
Mac/802_11 set SIFS_ 0.000016 ;
Mac/802_11 set ShortRetryLImit_ 7 ;
Mac/802_11 set LOngRetryLimit_ 7 ;
set val(ifq) Queue/DropTail/PriQueue ;# interface queue type
set val(ifqlen) 50 ;# max packet in ifq
set val(ll) LL ;# link layer type
set val(ant) Antenna/OmniAntenna ;# antenna model
set val(adhocRouting) AODV ;# routing protocol
set val(x) 250 ;# X dimension of the topography
set val(y) 250 ;# Y dimension of the topography
set val(tr) esercizio1.tr ;# trace file
set val(rate) [lindex $argv 0] ;
set val(nn) [lindex $argv 1] ;# how many nodes are simulated
set val(stop) [lindex $argv 3] ;# simulation time
set val(seed) 0.0
# 主程序
# Initialize Global Variables
# create simulator instance
set ns_ [new Simulator]
# define topology
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
# create trace object for ns and nam
set tracefd [open $val(tr) w]
$ns_ trace-all $tracefd
$ns_ use-newtrace
# Create God
set god_ [create-god $val(nn)]
# define how node should be created
#global node setting
$ns_ node-config -adhocRouting $val(adhocRouting) \
-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 ON
# Create the specified number of nodes [$val(nn)] and "attach" them to the channel
for {set i 0} {$i < $val(nn) } {incr i} {
set node_($i) [$ns_ node]
}
# Define node positions
source "/tmp/mob.tcl"
# Define traffic flows
source "traffic"
for {set i 0} {$i < 4 } {incr i} {
$cbr_($i) set interval_ [ expr 1 /$rate ]
}
# Tell nodes when the simulation ends
for {set i 0} {$i < $val(nn) } {incr i} {
$ns_ at $val(stop).000000001 "$node_($i) reset";
}
$ns_ at $val(stop).000000001 "puts \"NS EXITING...\" ; $ns_ halt"
puts "Starting Simulation..."
$ns_ run
我从终端调用了 ns mobilita_source,但它描述了我,所以我认为它可能是 mobilita_souce.tcl 文件中的路径 /tmp。在 tmp 我注意到该文件存在。
【问题讨论】: