📄 exercise3.tcl
字号:
set val(chan) Channel/WirelessChannel
set val(prop) Propagation/TwoRayGround
set val(netif) Phy/WirelessPhy
set val(mac) Mac/802_11
set val(ifq) Queue/DropTail/PriQueue
set val(ll) LL
set val(ant) Antenna/OmniAntenna
set val(ifqlen) 10
set val(nn) 6
set val(rp) AODV
set val(x) 500
set val(y) 500
set ns_ [new Simulator]
set tracefd [open exercise3.tr w]
$ns_ trace-all $tracefd
set namtracefd [open exercise3.nam w]
$ns_ namtrace-all-wireless $namtracefd $val(x) $val(y)
proc finish {} {
global ns_ tracefd namtracefd
$ns_ flush-trace
close $tracefd
close $namtracefd
exec nam exercise3.nam &
exit 0
}
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
set god_ [create-god $val(nn)]
$ns_ node-config -addressType def
$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 1
}
source scen-5n-0p-50t-5s-200-200
source cbr-5n-8mc-512
for {set i 0} {$i<$val(nn)} {incr i} {
$ns_ at 50.0 "$node_($i) reset";
}
$ns_ at 50.0 "finish"
$ns_ run
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -