求教:最近在学习NS-2的应用,新手上路,正在看《NS与网络模拟》徐雷鸣等著的这本书,在第2.5节中的example2.tcl敲到记事本中后无法运行,其中出现的问题提示如下:
num_nodes is set 2
warning:Plesase use -channel as shown in tcl/ex/wireless-mitf.tcl
extra characters after close-brace
while exexuting
"for {set i 0} {$i<$val(nn)} {incr i}{
set node_($i) [$ns node]
$node_($i) random-motion 0
}
$node_(0) set X_ 5.0
$node_(0) set Y) 2.0
$node_..."
书上的脚本文件为:
proc finish {} {
global ns tracefd namtracefd
$ns flush-trace
close $tracefd
close $namtracefd
exec nam example2.nam &
exit 0
}
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
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
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_ 5.0
$node_(0) set Y_ 2.0
$node_(0) set Z_ 0.0
$node_(1) set X_ 390.0
$node_(1) set Y_ 385.0
$node_(1) set Z_ 0.0
$ns at 50.0 "$node_(1) setdest 25.0 20.0 15.0"
$ns at 10.0 "$node_(0) setdest 20.0 18.0 1.0"
$ns at 100.0 "$node_(1) setdest 490.0 480.0 15.0"
set tcp [new Agent/TCP]
$tcp set class_ 2
set sink [new Agent/TCPSink]
$ns attach-agent $node_(0) $tcp
$ns attach-agent $node_(1) $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at 10.0 "$ftp start"
for{set i 0}{$i<$val(nn)}{incr i}{
$ns at 150.0 "$node_($i) reset";
}
$ns at 150.0 "finish"
$ns run
num_nodes is set 2
warning:Plesase use -channel as shown in tcl/ex/wireless-mitf.tcl
extra characters after close-brace
while exexuting
"for {set i 0} {$i<$val(nn)} {incr i}{
set node_($i) [$ns node]
$node_($i) random-motion 0
}
$node_(0) set X_ 5.0
$node_(0) set Y) 2.0
$node_..."
书上的脚本文件为:
proc finish {} {
global ns tracefd namtracefd
$ns flush-trace
close $tracefd
close $namtracefd
exec nam example2.nam &
exit 0
}
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
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
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_ 5.0
$node_(0) set Y_ 2.0
$node_(0) set Z_ 0.0
$node_(1) set X_ 390.0
$node_(1) set Y_ 385.0
$node_(1) set Z_ 0.0
$ns at 50.0 "$node_(1) setdest 25.0 20.0 15.0"
$ns at 10.0 "$node_(0) setdest 20.0 18.0 1.0"
$ns at 100.0 "$node_(1) setdest 490.0 480.0 15.0"
set tcp [new Agent/TCP]
$tcp set class_ 2
set sink [new Agent/TCPSink]
$ns attach-agent $node_(0) $tcp
$ns attach-agent $node_(1) $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at 10.0 "$ftp start"
for{set i 0}{$i<$val(nn)}{incr i}{
$ns at 150.0 "$node_($i) reset";
}
$ns at 150.0 "finish"
$ns run
set node_($i) [$ns node]
$node_($i) random-motion 0 ;#disable random motion
}"} {"之间一个空格
$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) \ #这一句改为“-channel $chan”,然后在这一大段之前加上“set chan [new $val(chan)]” -topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF \
-movementTrace OFF