错误 # args: 应该是“_o3 self class proc file optx opty”
Posted
技术标签:
【中文标题】错误 # args: 应该是“_o3 self class proc file optx opty”【英文标题】:wrong # args: should be "_o3 self class proc file optx opty" 【发布时间】:2021-10-04 09:12:48 【问题描述】:我在运行tcl代码时,出现如下错误:
错误的#args:应该是“o3 self class proc file optx opty” (模拟器 namtrace-all-wireless line 1) 从内部调用 "$ns namtrace-all-wireless $namtracefd" (文件“test1.tcl”第 26 行)
我应该如何修改我的 tcl 代码以使程序正确运行。
这是tcl文件中的代码脚本:
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
【问题讨论】:
【参考方案1】:错误的#args:应该是... optx opty
几个错别字之一:原来的第26行应该是$ns_ namtrace-all-wireless $namtracefd $opt(x) $opt(y)
片段,示例编辑
-set opt(mac) Mac/S-MAC
+set opt(mac) Mac/SMAC ;# edit to the ns2 default SMAC
+set opt(ant) Antenna/OmniAntenna ;# antenna model missing
+set opt(x) 2000 ;# area added
+set opt(y) 500
+# create God
+create-god [expr $opt(nn)] ;# missing god
$ns_ node-config -adhocRouting $opt(rp) \
-llType $opt(ll) \
-macType $opt(mac) \
-ifqType $opt(ifq) \
- -ifqLen $opt(ifqlen) (missing \)
+ -ifqLen $opt(ifqlen) \
-antType $opt(ant) \
-propType $opt(prop) \
- -phyTyenter code herepe $opt(netif) \ (!!)
- -channel $channel \ (surplus ?)
+ -phyType $opt(netif) \
+ -channelType $opt(chan) \ (missing line)
+# Define initial node position in nam (missing definition)
+for set i 0 $i < $opt(nn) incr i
+$ns_ initial_node_pos $node_($i) 40
-$ns_ at 10.0 "$cbr_(0) start“
+$ns_ at 10.0 "$cbr_(0) start" ;# forbidden character “ edited
-$ns_ at $opt(stop).0 "stop“
+$ns_ at $opt(stop).0 "stop" ;# forbidden character “ edited
编辑文件示例在这里https://drive.google.com/file/d/1OP49HAAhxHumWacE_qsSq1gFBZkLi0ak/view?usp=sharing
NAM 抱怨“未定义节点 6”。建议:将 nn 编辑为 7 个节点。
第二个示例 = 2-zhang-test1.tcl
,节点位置为 https://drive.google.com/drive/folders/1aTFX1vJs2k0IchPCqq6cpj_UKeTHch31?usp=sharing:包含特殊 SMAC 示例 Energy_wireless-4x4-grid+4__flows.tcl
。
SMAC-examples-4.tar.gz https://drive.google.com/file/d/1nO4aZWwL7wkmAlVOGGZI40-kjl4bqeb0/view?usp=sharing
ns2 能量模型示例https://drive.google.com/file/d/1g8WnlHHHnNXBLc0rwJY4i1z9uieKtl9s/view?usp=sharing
全部 ~2500 ex https://drive.google.com/drive/folders/0B7S255p3kFXNSmRYb2lGcDRUdWs?usp=sharing
【讨论】:
以上是关于错误 # args: 应该是“_o3 self class proc file optx opty”的主要内容,如果未能解决你的问题,请参考以下文章
如何在 PrimeFaces oncomplete 中触发 args.validationFailed