📄 aodv3.tcl
字号:
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagation model
set val(ant) Antenna/OmniAntenna ;# network interface type
set val(ll) LL ;# link layer type
set val(ifq) Queue/DropTail/PriQueue;
set val(ifqlen) 50 ;# max packet in ifq
set val(netif) Phy/WirelessPhy ;# network interface type
set val(mac) Mac/802_11;
set val(rp) AODV;
set val(nn) 50;
set val(cp) "scen-50n";
set val(sc) "cbr-50n-30c";
set val(x) 1000;
set val(y) 1000;
#Create a ns simulator
set ns_ [new Simulator]
set tracefd [open aodv3.tr w]
$ns_ trace-all $tracefd
set namtracefd [open aodv3.nam w]
$ns_ namtrace-all-wireless $namtracefd $val(x) $val(y)
#Setup topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
set chan [new $val(chan)];#Create wireless channel
#===================================
# Mobile node parameter setup
#===================================
$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) \
-channel $chan \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF \
-movement OFF
set god_ [create-god $val(nn)]
for {set i 0} {$i < $val(nn) } {incr i} {
set node_($i) [$ns_ node] ;
$node_($i) random-motion 0;
}
source scen-50n
source cbr-50n-30c
for {set i 0} {$i <$val(nn) } {incr i} {
$ns_ at 200.0 "$node_($i) reset";
}
$ns_ at 200.0 "finish"
proc finish {} {
global ns tracefd namtracefd
close $tracefd
close $namtracefd
exec nam aodv3.nam &
exit 0
}
$ns_ run
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -