错误的#args:应该是“_o3 self class proc file optx opty”
wrong # args: should be "_o3 self class proc file optx opty"
当我运行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
wrong # args: should be ... 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-示例-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
当我运行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
wrong # args: should be ... 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-示例-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