When I ran the tcl code, the following error appeared:
wrong # args: should be "o3 self class proc file optx opty" (Simulator namtrace-all-wireless line 1) invoked from within "$ns namtrace-all-wireless $namtracefd" (file "test1.tcl" line 26)
How should I modify my tcl code to make the program run correctly.
This is code script in tcl file:
set opt(ifqlen) 50
set opt(nn) 6
set opt(rp) AODV
set opt(chan) Channel/WirelessChannel
set opt(prop) Propagation/TwoRayGround
set opt(netif) Phy/WirelessPhy
set opt(mac) Mac/S-MAC
#set opt(mac) Mac/LMAC
set opt(ifq) Queue/DropTail/PriQueue
set opt(x) 2000
set opt(y) 500
set opt(ll) LL
set opt(stop) 1000
set opt(energymodel) EnergyModel
set opt(initialenergy) 1000
set opt(receivepower) 0.3682
set opt(transmitpower) 0.3442
set opt(idlepower) 0.3442
set opt(sleeppower) 5.0e-5
set opt(transitionpower) 0.05
set opt(transitiontime) 0.0005
set ns_ [new Simulator]
set tracefd [open 1Sthreenodes.tr w]
$ns_ trace-all $tracefd
set namtracefd [open 1Sthreenodes.nam w]
$ns_ namtrace-all-wireless $namtracefd
set topo [new Topography]
$topo load_flatgrid $opt(x) $opt(y)
set channel [new Channel/WirelessChannel]
$ns_ node-config -adhocRouting $opt(rp) \
-llType $opt(ll) \
-macType $opt(mac) \
-ifqType $opt(ifq) \
-ifqLen $opt(ifqlen)
-antType $opt(ant) \
-propType $opt(prop) \
-phyTyenter code herepe $opt(netif) \
-channel $channel \
-topoInstance $topo \
-energyModel $opt(energymodel)\
-txPower $opt(transmitpower)\
-rxPower $opt(receivepower)\
-idlePower $opt(idlepower)\
-sleepPower $opt(sleeppower)\
-transitionPower $opt(transitionpower)\
-transitionTime $opt(transitiontime)\
-initialEnergy $opt(initialenergy)\
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace OFF
for {set i 0} {$i < $opt(nn)} {incr i} {
set node_($i) [$ns_ node]
$node_($i) random-motion 0;
}
for {set i 0} {$i < $opt(nn)} {
$node_($i) set X_ [expr $i*200]
$node_($i) set Y_ [expr $opt(y)/2]
$node_($i) set Z_ 0.0
}
set udp_(0) [new Agent/UDP]
$ns_ attach-agent $node_(0) $udp_(0)
set null_(0) [new Agent/Null]
$ns_ attach-agent $node_(5) $null_(0)
$ns_ connect $udp_(0) $null_(0)
set cbr_(0) [new Application/Traffic/CBR]
$cbr_(0) set packetSize_ 512
$cbr_(0) set interval_ 1.0
$cbr_(0) set random_ 1
$cbr_(0) set maxpkts_ 1000
$cbr_(0) attach-agent $udp_(0)
$ns_ at 10.0 "$cbr_(0) start“
for {set i 0} {$i < $opt(nn)} {incr i} {
$ns_ at $opt(stop).0 "$node_($i) reset";
}
$ns_ at $opt(stop).0 "stop“
$ns_ at $opt(stop).01 "puts \"NS EXITING...\"; $ns_ halt"
proc stop {} {
global ns_ tracefd
$ns_ flush-trace
close $tracefd
}
puts "starting simulation..."
$ns_ run