📄 aodv.tcl
字号:
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagation model
set val(netif) Phy/WirelessPhy ;# network interface type
set val(mac) Mac/802_11 ;# MAC type
set val(ifq) Queue/DropTail/PriQueue ;# interface queue type
set val(ll) LL ;# link layer type
set val(ant) Antenna/OmniAntenna ;# antenna model
set val(ifqlen) 50 ;# max packet in ifq
set val(nn) 40 ;# number of mobilenodes
set val(rp) AODV ; # routing protocol
set val(stop) 200
set val(x) 1000 ;# X dimension of the topography
set val(y) 1000 ;# Y dimension of the topography
# $val(netif) set RXThresh_ 1.42681e-08 ; #100m
set ns_ [new Simulator]
set tracefd [open aodv.tr w] ;
$ns_ trace-all $tracefd
set namtracefd [open aodv.nam w]
$ns_ namtrace-all-wireless $namtracefd $val(x) $val(y)
proc stop {} {
global ns_ tracefd
#global ns_ namtracefd
$ns_ flush-trace
close $tracefd
#close $namtracefd
#exec nam aodv.nam &
exit 0
}
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y) ;#very important
# New API to config node:
# 1. Create channel (or multiple-channels);
# 2. Specify channel in node-config (instead of channelType);
# 3. Create nodes for simulations.
set chan_1 [new Channel/WirelessChannel] ;
set god_ [create-god $val(nn)]
# two lines blew is the same to the line up
#create-god $val(nn)
#set god_ [God instance]
$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_1 \
-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
}
source "scen_40_nodes" ; # use scece created by setdest
source "cbr_40" ; # use cbr-gen creat cbr flow
for {set i 0} {$i < $val(nn) } {incr i} {
$ns_ initial_node_pos $node_($i) 2
$ns_ at $val(stop).0 "$node_($i) reset" ;
}
$ns_ at $val(stop).0 "stop"
$ns_ at $val(stop).01 "puts \" NS EXITING...\" ; $ns_ halt"
puts "Starting Simulation..."
$ns_ run
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -