ns2.35,setdest, вызывается изнутри

Я хочу добавить мобильность для раковины на tclscript. раковина показана с помощью mnode(0). У меня была команда в терминале: ./setdest -v 2 -n 1 -m 15 -M 15 -t 500 -x 500 -y 500 > моб

Mobfile добавлен в каталог tcl и добавьте следующую команду в tcl:

./setdest -v 2 -n 1 -m 15 -M 15 -t 500 -x 500 -y 500 > mob

set val(cp)             "mob"               ;

# 
# Define node movement model
#
#puts "Loading connection pattern..."
#source $val(cp)

но когда я запускаю XXX.tcl, у меня появляется ошибка:

Loading connection pattern...
can't read "mnode_(0)": no such variable
    while executing
"$mnode_(0) set X_ 78.313432119133"
    (file "mob" line 7)
    invoked from within
"source.orig mob"
    ("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 $val(cp)"
    (file "AE_3.tcl" line 30)

вы не могли бы мне помочь? большое спасибо. мой код tcl:

# Generated by Topology Generator for Network Simulator (c) Elmurod Talipov
set val(chan)          Channel/WirelessChannel      ;# channel type
set val(prop)          Propagation/TwoRayGround     ;# radio-propagation model
set val(netif)         Phy/WirelessPhy     ;  # network interface type#dccp.tcl
set val(mac)           Mac/802_11                 ;     # MAC type#dccp.tcl
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)        100               ;# max packet in ifq
set val(nn)            60       ;# number of mobilenodes
set val(rp)            AE       ;# protocol tye
set val(x)             500       ;# X dimension of topography
set val(y)             500       ;# Y dimension of topography
set val(stop)          500       ;# simulation period 
set val(energymodel)   EnergyModel      ;# Energy Model
set val(initialenergy) 1000       ;# value
#set val(sc)             "./mob"       ;# me
#set val(cs)  "../mobility/scene/cbr-3-test";
#set val(sc)  "../mobility/scene/scen-3-test";


set ns          [new Simulator]
set tracefd        [open AE_3.tr w]
set namtrace       [open AE_3.nam w]

$ns trace-all $tracefd
$ns namtrace-all-wireless $namtrace $val(x) $val(y)

# 
# Define node movement model
#
#puts "Loading connection pattern..."
#source $val(sc)


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
set dist(75m) 3.41828e-08
set dist(100m) 1.42681e-08
Phy/WirelessPhy set CSThresh_ $dist(100m)
Phy/WirelessPhy set RXThresh_ $dist(75m)


# set up topography object
set topo       [new Topography]
$topo load_flatgrid $val(x) $val(y)

create-god $val(nn)
# from wireless-pkt-demo

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

# configure the nodes
$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) \
             -channel [new $val(chan)] \
             -topoInstance $topo \
             -agentTrace ON \
             -routerTrace ON \
             -macTrace  OFF \
             -movementTrace OFF \
             -energyModel $val(energymodel) \
             -initialEnergy $val(initialenergy) \
             -rxPower 35.28e-3 \
             -txPower 31.32e-3 \
      -idlePower 712e-6 \
      -sleepPower 144e-9 
                           
             #-IncomingErrProc MultistateErrorProc \
             #-OutgoingErrProc MultistateErrorProc
             
for {set i 0} {$i < $val(nn) } { incr i } {
        set mnode_($i) [$ns node]
}



for {set i 1} {$i < $val(nn) } { incr i } {
 $mnode_($i) set X_ [ expr {$val(x) * rand()} ]
 $mnode_($i) set Y_ [ expr {$val(y) * rand()} ]
 $mnode_($i) set Z_ 0
}

# Position of Sink
$mnode_(0) set X_ [ expr {$val(x)/2} ]
$mnode_(0) set Y_ [ expr {$val(y)/2} ]
$mnode_(0) set Z_ 0.0
$mnode_(0) label "Sink"

#start sending beacon message
$ns at 1.0 "[$mnode_(0) set ragent_] sink"


for {set i 0} {$i < $val(nn)} { incr i } {
 $ns initial_node_pos $mnode_($i) 3
}


#Setup a UDP connection
set udp [new Agent/UDP] 
$ns attach-agent $mnode_(10) $udp  

set sink [new Agent/Null]  
$ns attach-agent $mnode_(0) $sink  

$ns connect $udp $sink  
$udp set fid_ 2  

#Setup a CBR over UDP connection
set cbr [new Application/Traffic/CBR]  
$cbr attach-agent $udp  
$cbr set type_ CBR  
$cbr set packet_size_ 256  
$cbr set interval_ 2  
#$cbr set random_ false

$ns at 5.0 "$cbr start" 
$ns at [expr $val(stop) - 5] "$cbr stop"  

0 ответов

Другие вопросы по тегам