- Home Page of ProjectGuideline.com ›
- Forums ›
- Get Help to do your B.E., and M.E., M.Tech., & M.S., Project in Ns2 ›
- Error when simulating the generated files from “cbrgen.
Hi,
I am using the programs, “cbrgen.tcl” and “setdest” provided in NS2 to
generate wireless scenarios. However, when I run the “tcl” file using “ns
xxxxx.tcl”, it gave the following error messages. Anyone knows what is
wrong with my program?
Thanks in advance.
Rdgs,
Rachel.
=====================================================================================
[Phoenix@Victory NS2_programs]$ ns wireless-20.tcl
num_nodes is set 20
warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl
can’t read “topoInstance_”: no such variable
while executing
“$node add-interface $chan $propInstance_ $llType_ $macType_ $ifqType_
$ifqlen_ $phyType_ $antType_ $topoInstance_ $inerrProc_ $outerrProc_
$FECProc_”
(procedure “_o3” line 70)
(Simulator create-wireless-node line 70)
invoked from within
“_o3 create-wireless-node”
(“eval” body line 1)
invoked from within
“eval $self create-wireless-node $args”
(procedure “_o3” line 23)
(Simulator node line 23)
invoked from within
“$ns_ node”
(“for” body line 2)
invoked from within
“for {set i 0} {$i < $val(nn) } {incr i} {
set node_($i) [$ns_ node]
$node_($i) random-motion 0 ;# disable random
motion
}”
(file “wireless-20.tcl” line 60)
[Phoenix@Victory NS2_programs]$
Below is the tcl code.
==================================================
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) 20 ;# number of mobilenodes
set val(rp) DSDV ;# routing protocol
set ns_ [new Simulator]
set tracefd [open simple.tr w]
set chan_1_ [new $val(chan)]
$ns_ trace-all $tracefd
set topo [new Topography]
$topo load_flatgrid 500 500
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)
# -channelType $chan_1_
-topoInstance $topo
-agentTrace ON
-routerTrace ON
-macTrace OFF
-movementTrace OFF
for {set i 0} {$i < $val(nn) } {incr i} {
set node_($i) [$ns_ node]
$node_($i) random-motion 0 ;# disable random motion
}
$node_(0) set X_ 134.797774264109
$node_(0) set Y_ 103.697771455426
$node_(0) set Z_ 0.000000000000
$node_(1) set X_ 2.425825457222
$node_(1) set Y_ 468.466310282469
$node_(1) set Z_ 0.000000000000
$node_(2) set X_ 154.517970895334
$node_(2) set Y_ 354.166289713836
$node_(2) set Z_ 0.000000000000
$node_(3) set X_ 195.887741224060
$node_(3) set Y_ 107.444866408718
$node_(3) set Z_ 0.000000000000
$node_(4) set X_ 36.061014398162
$node_(4) set Y_ 6.635082392045
$node_(4) set Z_ 0.000000000000
$node_(5) set X_ 308.167652250005
$node_(5) set Y_ 218.213698102266
$node_(5) set Z_ 0.000000000000
$node_(6) set X_ 414.413568959111
$node_(6) set Y_ 146.286278247728
$node_(6) set Z_ 0.000000000000
$node_(7) set X_ 109.238236379240
$node_(7) set Y_ 25.818090855648
$node_(7) set Z_ 0.000000000000
$node_(8) set X_ 450.116510415504
$node_(8) set Y_ 347.518249946599
$node_(8) set Z_ 0.000000000000
$node_(9) set X_ 1.420670257765
$node_(9) set Y_ 355.958140813581
$node_(9) set Z_ 0.000000000000
$node_(10) set X_ 270.366322536998
$node_(10) set Y_ 10.042953791314
$node_(10) set Z_ 0.000000000000
$node_(11) set X_ 91.726927337982
$node_(11) set Y_ 334.900999828104
$node_(11) set Z_ 0.000000000000
$node_(12) set X_ 137.106941667908
$node_(12) set Y_ 408.057931316097
$node_(12) set Z_ 0.000000000000
$node_(13) set X_ 101.923311757867
$node_(13) set Y_ 209.943009113927
$node_(13) set Z_ 0.000000000000
$node_(14) set X_ 231.024910591818
$node_(14) set Y_ 36.122093096700
$node_(14) set Z_ 0.000000000000
$node_(15) set X_ 369.398276748797
$node_(15) set Y_ 15.610310772188
$node_(15) set Z_ 0.000000000000
$node_(16) set X_ 477.955544464000
$node_(16) set Y_ 97.839343676014
$node_(16) set Z_ 0.000000000000
$node_(17) set X_ 498.951244117194
$node_(17) set Y_ 61.225939480354
$node_(17) set Z_ 0.000000000000
$node_(18) set X_ 439.020291044428
$node_(18) set Y_ 268.278422020821
$node_(18) set Z_ 0.000000000000
$node_(19) set X_ 106.880836824704
$node_(19) set Y_ 348.913065291456
$node_(19) set Z_ 0.000000000000
$god_ set-dist 0 1 2
$god_ set-dist 0 2 2
$god_ set-dist 0 3 1
$god_ set-dist 0 4 1
$god_ set-dist 0 5 1
$god_ set-dist 0 6 2
$god_ set-dist 0 7 1
$god_ set-dist 0 8 2
$god_ set-dist 0 9 2
$god_ set-dist 0 10 1
$god_ set-dist 0 11 1
$god_ set-dist 0 12 2
$god_ set-dist 0 13 1
$god_ set-dist 0 14 1
$god_ set-dist 0 15 2
$god_ set-dist 0 16 2
$god_ set-dist 0 17 2
$god_ set-dist 0 18 2
$god_ set-dist 0 19 1
$god_ set-dist 1 2 1
$god_ set-dist 1 3 3
$god_ set-dist 1 4 3
$god_ set-dist 1 5 2
$god_ set-dist 1 6 3
$god_ set-dist 1 7 3
$god_ set-dist 1 8 3
$god_ set-dist 1 9 1
$god_ set-dist 1 10 3
$god_ set-dist 1 11 1
$god_ set-dist 1 12 1
$god_ set-dist 1 13 2
$god_ set-dist 1 14 3
$god_ set-dist 1 15 3
$god_ set-dist 1 16 3
$god_ set-dist 1 17 3
$god_ set-dist 1 18 3
$god_ set-dist 1 19 1
$god_ set-dist 2 3 2
$god_ set-dist 2 4 2
$god_ set-dist 2 5 1
$god_ set-dist 2 6 2
$god_ set-dist 2 7 2
$god_ set-dist 2 8 2
$god_ set-dist 2 9 1
$god_ set-dist 2 10 2
$god_ set-dist 2 11 1
$god_ set-dist 2 12 1
$god_ set-dist 2 13 1
$god_ set-dist 2 14 2
$god_ set-dist 2 15 2
$god_ set-dist 2 16 2
$god_ set-dist 2 17 2
$god_ set-dist 2 18 2
$god_ set-dist 2 19 1
$god_ set-dist 3 4 1
$god_ set-dist 3 5 1
$god_ set-dist 3 6 1
$god_ set-dist 3 7 1
$god_ set-dist 3 8 2
$god_ set-dist 3 9 2
$god_ set-dist 3 10 1
$god_ set-dist 3 11 2
$god_ set-dist 3 12 2
$god_ set-dist 3 13 1
$god_ set-dist 3 14 1
$god_ set-dist 3 15 1
$god_ set-dist 3 16 2
$god_ set-dist 3 17 2
$god_ set-dist 3 18 2
$god_ set-dist 3 19 2
$god_ set-dist 4 5 2
$god_ set-dist 4 6 2
$god_ set-dist 4 7 1
$god_ set-dist 4 8 3
$god_ set-dist 4 9 2
$god_ set-dist 4 10 1
$god_ set-dist 4 11 2
$god_ set-dist 4 12 2
$god_ set-dist 4 13 1
$god_ set-dist 4 14 1
$god_ set-dist 4 15 2
$god_ set-dist 4 16 2
$god_ set-dist 4 17 2
$god_ set-dist 4 18 3
$god_ set-dist 4 19 2
$god_ set-dist 5 6 1
$god_ set-dist 5 7 2
$god_ set-dist 5 8 1
$god_ set-dist 5 9 2
$god_ set-dist 5 10 1
$god_ set-dist 5 11 1
$god_ set-dist 5 12 2
$god_ set-dist 5 13 1
$god_ set-dist 5 14 1
$god_ set-dist 5 15 1
$god_ set-dist 5 16 1
$god_ set-dist 5 17 1
$god_ set-dist 5 18 1
$god_ set-dist 5 19 1
$god_ set-dist 6 7 2
$god_ set-dist 6 8 1
$god_ set-dist 6 9 3
$god_ set-dist 6 10 1
$god_ set-dist 6 11 2
$god_ set-dist 6 12 3
$god_ set-dist 6 13 2
$god_ set-dist 6 14 1
$god_ set-dist 6 15 1
$god_ set-dist 6 16 1
$god_ set-dist 6 17 1
$god_ set-dist 6 18 1
$god_ set-dist 6 19 2
$god_ set-dist 7 8 3
$god_ set-dist 7 9 2
$god_ set-dist 7 10 1
$god_ set-dist 7 11 2
$god_ set-dist 7 12 2
$god_ set-dist 7 13 1
$god_ set-dist 7 14 1
$god_ set-dist 7 15 2
$god_ set-dist 7 16 2
$god_ set-dist 7 17 2
$god_ set-dist 7 18 3
$god_ set-dist 7 19 2
$god_ set-dist 8 9 3
$god_ set-dist 8 10 2
$god_ set-dist 8 11 2
$god_ set-dist 8 12 3
$god_ set-dist 8 13 2
$god_ set-dist 8 14 2
$god_ set-dist 8 15 2
$god_ set-dist 8 16 2
$god_ set-dist 8 17 2
$god_ set-dist 8 18 1
$god_ set-dist 8 19 2
$god_ set-dist 9 10 3
$god_ set-dist 9 11 1
$god_ set-dist 9 12 1
$god_ set-dist 9 13 1
$god_ set-dist 9 14 2
$god_ set-dist 9 15 3
$god_ set-dist 9 16 3
$god_ set-dist 9 17 3
$god_ set-dist 9 18 3
$god_ set-dist 9 19 1
$god_ set-dist 10 11 2
$god_ set-dist 10 12 3
$god_ set-dist 10 13 2
$god_ set-dist 10 14 1
$god_ set-dist 10 15 1
$god_ set-dist 10 16 1
$god_ set-dist 10 17 1
$god_ set-dist 10 18 2
$god_ set-dist 10 19 2
$god_ set-dist 11 12 1
$god_ set-dist 11 13 1
$god_ set-dist 11 14 2
$god_ set-dist 11 15 2
$god_ set-dist 11 16 2
$god_ set-dist 11 17 2
$god_ set-dist 11 18 2
$god_ set-dist 11 19 1
$god_ set-dist 12 13 1
$god_ set-dist 12 14 2
$god_ set-dist 12 15 3
$god_ set-dist 12 16 3
$god_ set-dist 12 17 3
$god_ set-dist 12 18 3
$god_ set-dist 12 19 1
$god_ set-dist 13 14 1
$god_ set-dist 13 15 2
$god_ set-dist 13 16 2
$god_ set-dist 13 17 2
$god_ set-dist 13 18 2
$god_ set-dist 13 19 1
$god_ set-dist 14 15 1
$god_ set-dist 14 16 2
$god_ set-dist 14 17 2
$god_ set-dist 14 18 2
$god_ set-dist 14 19 2
$god_ set-dist 15 16 1
$god_ set-dist 15 17 1
$god_ set-dist 15 18 2
$god_ set-dist 15 19 2
$god_ set-dist 16 17 1
$god_ set-dist 16 18 1
$god_ set-dist 16 19 2
$god_ set-dist 17 18 1
$god_ set-dist 17 19 2
$god_ set-dist 18 19 2
$ns_ at 2.000000000000 “$node_(0) setdest 435.685042320399 232.692274823783 0.000000000000”
$ns_ at 2.000000000000 “$node_(1) setdest 2.916927707084 66.812723152583 0.000000000000”
$ns_ at 2.000000000000 “$node_(2) setdest 321.069989884868 275.999518089904 0.000000000000”
$ns_ at 2.000000000000 “$node_(3) setdest 142.604522444713 353.334748533933 0.000000000000”
$ns_ at 2.000000000000 “$node_(4) setdest 148.347370875127 204.368767563417 0.000000000000”
$ns_ at 2.000000000000 “$node_(5) setdest 50.649413381489 447.505424516538 0.000000000000”
$ns_ at 2.000000000000 “$node_(6) setdest 306.629137666631 78.683298864897 0.000000000000”
$ns_ at 2.000000000000 “$node_(7) setdest 25.478645064765 412.782426192133 0.000000000000”
$ns_ at 2.000000000000 “$node_(8) setdest 335.135580205405 440.278350626560 0.000000000000”
$ns_ at 2.000000000000 “$node_(9) setdest 404.023537653707 59.355616417240 0.000000000000”
$ns_ at 2.000000000000 “$node_(10) setdest 96.106203852708 499.503773147423 0.000000000000”
$ns_ at 2.000000000000 “$node_(11) setdest 90.975145092893 241.289639889320 0.000000000000”
$ns_ at 2.000000000000 “$node_(12) setdest 70.561100187876 347.120521986175 0.000000000000”
$ns_ at 2.000000000000 “$node_(13) setdest 136.395104781301 496.051983949452 0.000000000000”
$ns_ at 2.000000000000 “$node_(14) setdest 235.840673571187 139.000435455723 0.000000000000”
$ns_ at 2.000000000000 “$node_(15) setdest 155.888388614353 181.096916126124 0.000000000000”
$ns_ at 2.000000000000 “$node_(16) setdest 418.516713672196 190.667217517919 0.000000000000”
$ns_ at 2.000000000000 “$node_(17) setdest 231.583375406764 453.048835446629 0.000000000000”
$ns_ at 2.000000000000 “$node_(18) setdest 313.163024754708 297.434493635403 0.000000000000”
$ns_ at 2.000000000000 “$node_(19) setdest 66.658849563692 224.195612625379 0.000000000000”
set tcp_(0) [$ns_ create-connection TCP $node_(0) TCPSink $node_(1) 0]
$tcp_(0) set window_ 32
$tcp_(0) set packetSize_ 512
set ftp_(0) [$tcp_(0) attach-source FTP]
$ns_ at 63.547990686981002 “$ftp_(0) start”
set tcp_(1) [$ns_ create-connection TCP $node_(1) TCPSink $node_(2) 0]
$tcp_(1) set window_ 32
$tcp_(1) set packetSize_ 512
set ftp_(1) [$tcp_(1) attach-source FTP]
$ns_ at 31.131527242777651 “$ftp_(1) start”
set tcp_(2) [$ns_ create-connection TCP $node_(2) TCPSink $node_(3) 0]
$tcp_(2) set window_ 32
$tcp_(2) set packetSize_ 512
set ftp_(2) [$tcp_(2) attach-source FTP]
$ns_ at 99.279540590606416 “$ftp_(2) start”
set tcp_(3) [$ns_ create-connection TCP $node_(2) TCPSink $node_(4) 0]
$tcp_(3) set window_ 32
$tcp_(3) set packetSize_ 512
set ftp_(3) [$tcp_(3) attach-source FTP]
$ns_ at 75.299373089940929 “$ftp_(3) start”
set tcp_(4) [$ns_ create-connection TCP $node_(4) TCPSink $node_(5) 0]
$tcp_(4) set window_ 32
$tcp_(4) set packetSize_ 512
set ftp_(4) [$tcp_(4) attach-source FTP]
$ns_ at 137.85855275479076 “$ftp_(4) start”
set tcp_(5) [$ns_ create-connection TCP $node_(7) TCPSink $node_(8) 0]
$tcp_(5) set window_ 32
$tcp_(5) set packetSize_ 512
set ftp_(5) [$tcp_(5) attach-source FTP]
$ns_ at 87.716911690177824 “$ftp_(5) start”
set tcp_(6) [$ns_ create-connection TCP $node_(7) TCPSink $node_(9) 0]
$tcp_(6) set window_ 32
$tcp_(6) set packetSize_ 512
set ftp_(6) [$tcp_(6) attach-source FTP]
$ns_ at 4.6058981235166536 “$ftp_(6) start”
set tcp_(7) [$ns_ create-connection TCP $node_(9) TCPSink $node_(10) 0]
$tcp_(7) set window_ 32
$tcp_(7) set packetSize_ 512
set ftp_(7) [$tcp_(7) attach-source FTP]
$ns_ at 85.313742349536042 “$ftp_(7) start”
for {set i 0} {$i < $val(nn) } {incr i} {
$ns_ at 200.0 “$node_($i) reset”;
}
$ns_ at 200.0 “stop”
$ns_ at 200.01 “puts “NS EXITING…” ; $ns_ halt”
proc stop {} {
global ns_ tracefd
$ns_ flush-trace
close $tracefd
}
Justt cut the following code segment and past it on your previous code. It will work. I have corrected and tested it on ns2.31.
Can you guess what is the error? I will tell you latter.
set god_ [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 -movementTrace OFF