aodv1.tcl

来自「adhoc路由协议aodv仿真与end-to-en-delay分析」· TCL 代码 · 共 75 行

TCL
75
字号
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)  10;
set val(cp)  "scen-10n"; 
set val(sc)  "cbr-10n-4c";
set val(x)  250;
set val(y)  250;

#Create a ns simulator
set ns_ [new Simulator]

set tracefd [open aodv1.tr w]
$ns_ trace-all $tracefd
set namtracefd [open aodv1.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-10n
source cbr-10n-4c

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 aodv1.nam &
    exit 0
}

$ns_ run

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?