[ns] can't read "Node_(6)": no such element in array
Robert Chirwa
robert.m.chirwa at gmail.com
Wed Oct 15 19:07:57 PDT 2008
Dear all,
I am simulating a multi-interface mobile node using SCTP using ns-2.33. But
I am getting the error message below. I have read Jung Kee Song's thesis on
http://www.lib.ncsu.edu/theses/available/etd-05162005-094333/ but it has not
helped me. Does anyone know what I am doing wrong? I get the same error
using ns-2.30. The tcl scripts are below the error message.
Your help will be appreciated.
Robert Chirwa
-----------------------------------------------------------------------
num_nodes is set 9
INITIALIZE THE LIST xListHead
Starting Simulation...
can't read "Node_(6)": no such element in array
while executing
"return $Node_($id)"
(procedure "_o3" line 3)
(Simulator get-node-by-id line 3)
invoked from within
"$self get-node-by-id [lindex $L 0]"
(procedure "_o3" line 14)
(Simulator compute-hier-routes line 14)
invoked from within
"$self compute-hier-routes "
invoked from within
"if [Simulator hier-addr?] {
$self compute-hier-routes
} else {
$self compute-flat-routes
}"
(procedure "_o3" line 2)
(Simulator compute-routes line 2)
invoked from within
"[Simulator instance] compute-routes"
(procedure "Agent/rtProto/Static" line 2)
(Agent/rtProto/Static init-all line 2)
invoked from within
"Agent/rtProto/Static init-all"
invoked from within
"if [info exists rtprotos_] {
foreach proto [array names rtprotos_] {
eval Agent/rtProto/$proto init-all $rtprotos_($proto)
}
} else {
Agent/rtProto/St..."
(procedure "_o282" line 3)
(RouteLogic configure line 3)
invoked from within
"[$self get-routelogic] configure"
(procedure "_o3" line 5)
(Simulator run line 5)
invoked from within
"$ns_ run"
(file "wired-wireless-sctp.tcl" line 128)
-------------------------------------------------------------------------------------
### This simulation is an example of combination of wired and wireless
### topologies.
global opt
set opt(chan) Channel/WirelessChannel
set opt(prop) Propagation/TwoRayGround
set opt(netif) Phy/WirelessPhy
set opt(mac) Mac/802_11
set opt(ifq) Queue/DropTail/PriQueue
set opt(ll) LL
set opt(ant) Antenna/OmniAntenna
set opt(x) 670
set opt(y) 670
set opt(ifqlen) 50
set opt(tr) wired-wireless-sctp.tr
set opt(namtr) wired-wireless-sctp.nam
set opt(nn) 6
set opt(adhocRouting) DSDV
set opt(stop) 250
set num_wired_nodes 3
set num_bs_nodes 3
set ns_ [new Simulator]
# set up for hierarchical routing
$ns_ node-config -addressType hierarchical
AddrParams set domain_num_ 3
lappend cluster_num 2 1 1
AddrParams set cluster_num_ $cluster_num
lappend eilastlevel 1 1 4 1
AddrParams set nodes_num_ $eilastlevel
set tracefd [open $opt(tr) w]
$ns_ trace-all $tracefd
set namtracefd [open $opt(namtr) w]
$ns_ namtrace-all $namtracefd
set topo [new Topography]
$topo load_flatgrid $opt(x) $opt(y)
# god needs to know the number of all wireless interfaces
create-god [expr $opt(nn) + $num_bs_nodes]
#create wired nodes
set temp {0.0.0 0.0.1 0.0.2}
set WN [$ns_ node [lindex $temp 0]]
set WN_if0 [$ns_ node [lindex $temp 1]]
set WN_if1 [$ns_ node [lindex $temp 2]]
$ns_ multihome-add-interface $WN $WN_if0
$ns_ multihome-add-interface $WN $WN_if1
$ns_ node-config -adhocRouting $opt(adhocRouting) \
-llType $opt(ll) \
-macType $opt(mac) \
-ifqType $opt(ifq) \
-ifqLen $opt(ifqlen) \
-antType $opt(ant) \
-propInstance [new $opt(prop)] \
-phyType $opt(netif) \
-channel [new $opt(chan)] \
-topoInstance $topo \
-wiredRouting OFF
Mac/802_11 set dataRate_ 2.0Mb
Phy/WirelessPhy set Pt_ 4.5099
Phy/WirelessPhy set freq_ 2.175e+9
set temp {1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5}
set BS [$ns_ node [lindex $temp 0]]
$BS random-motion 0
$BS set X_ 1.0
$BS set Y_ 2.0
$BS set Z_ 0.0
set BS_if0 [$ns_ node [lindex $temp 1]]
set BS_if1 [$ns_ node [lindex $temp 2]]
$ns_ multihome-add-interface $BS $BS_if0
$ns_ multihome-add-interface $BS $BS_if1
#configure for mobilenodes
$ns_ node-config -wiredRouting OFF
set MN [ $ns_ node [lindex $temp 3] ]
$MN base-station [AddrParams addr2id [$BS node-addr]]
set MN_if0 [ $ns_ node [lindex $temp 4] ]
$MN_if0 base-station [AddrParams addr2id [$BS_if0 node-addr]]
set MN_if1 [ $ns_ node [lindex $temp 3] ]
$MN_if1 base-station [AddrParams addr2id [$BS_if1 node-addr]]
$ns_ multihome-add-interface $MN $MN_if0
$ns_ multihome-add-interface $MN $MN_if1
#create links between wired node and base-station interfaces
$ns_ duplex-link $WN_if0 $BS_if0 5Mb 2ms DropTail
$ns_ duplex-link $WN_if1 $BS_if1 5Mb 2ms DropTail
$ns_ duplex-link-op $WN_if0 $BS_if0 orient left-down
$ns_ duplex-link-op $WN_if1 $BS_if1 orient right-down
# setup SCTP connections
set sctp1 [new Agent/SCTP]
$sctp1 set mtu_ 1040
$sctp1 set dataChunkSize_ 1008
$ns_ multihome-attach-agent $MN $sctp1
set sctp2 [new Agent/SCTP]
$ns_ multihome-attach-agent $WN $sctp2
$ns_ connect $sctp1 $sctp2
set ftp1 [new Application/FTP]
$ftp1 attach-agent $sctp1
$sctp1 set primary-destination $MN_if0
$ns_ at 160 "$ftp1 start"
$ns_ at 180 "$sctp1 set-primary-destination $MN_if1"
$ns_ initial_node_pos $MN 20
$ns_ at $opt(stop).0000010 "$BS reset";
$ns_ at $opt(stop).1 "puts \"NS EXITING...\" ; $ns_ halt"
puts "Starting Simulation..."
$ns_ run
More information about the Ns-users
mailing list