?? rp.tcl
字號:
#simulation script for DSDV,DSR and AODV routing protocols#by fang chen#2008-08-12#check the parametersif {$argc != 5} { puts "Invalid options" puts "Usage: " puts "ns rp.tcl routing_protocols node_num max_velocity max_connection sending_rate" exit}#getset rp [lindex $argv 0]set nn [lindex $argv 1]set ve [lindex $argv 2]set co [lindex $argv 3]set ra [lindex $argv 4]#options for the mobile-nodes#================================================================set val(chan) Channel/WirelessChannelset val(prop) Propagation/TwoRayGround ;#Propagation/Shadowingset val(netif) Phy/WirelessPhyset val(mac) Mac/802_11if {$rp=="DSR"} { set val(ifq) CMUPriQueue ;#for DSR routing protocol} else { set val(ifq) Queue/DropTail/PriQueue ;#for DSDV and AODV}set val(ll) LLset val(ant) Antenna/OmniAntennaset val(x) 500 ;#the simulation scenario is 200x200set val(y) 500set val(cp) "./cbr/cbr-$nn-$co-$ra"set val(sc) "./scene/scene-$nn-$ve"set val(ifqlen) 50set val(nn) $nn ;#num of mobile nodes#set val(seed) 1.0 ;#the seed of random numset val(stop) 200 ;#the end timeset val(tr) "./tr/$rp-$nn-$ve-$co-$ra.tr" ;#trace fileset val(nam) "./nam/$rp-$nn-$ve-$co-$ra.nam" ;#nam trace fileset val(rp) $rp ;#routing protocol#set val(lm) "off" ;#log movement#set val(agent) #===============================================================#configure the netif#=====================================================================================#set the threshold power of receiving corresponding to the 50m-range mobile node#Phy/WirelessPhy set CPThresh_ 10.0 ;#forPhy/WirelessPhy set CSThresh_ 1.4268e-08 ;#the threshold for carrier sensingPhy/WirelessPhy set RXThresh_ 7.691113e-08 ;#5.46688e-08 ;#the receiveing range is 50mPhy/WirelessPhy set bandwidth_ 10e6 ;#10Mb#Phy/WirelessPhy set freq_ 914.0e6#configure the prop#the propagation is in-door environment with line-of-sight, like factory and gymnasium.#Propagation/Shadowing set pathlossExp_ 1.7 ;#the pass loss exponent#Propagation/Shadowing set std_db_ 4.0 ;#the shadowing deviation#Propagation/Shadowing set dist0_ 1.0#Propagation/Shadowing set seed_ 1.0#======================================================================================#Main Programset ns_ [new Simulator]#$ns_ use-newtraceset tracefd [open $val(tr) w]$ns_ trace-all $tracefdset namtracefd [open $val(nam) w]$ns_ namtrace-all-wireless $namtracefd $val(x) $val(y)set topo [new Topography]$topo load_flatgrid $val(x) $val(y)set god_ [create-god $val(nn)]set chan [new $val(chan)]#configure the mobile node$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 \ -movementTrace OFFfor {set i 0} {$i < $val(nn) } {incr i} { set node_($i) [$ns_ node] $node_($i) random-motion 0}puts "loading traffic file: $val(cp)"source $val(cp)puts "loading scene file: $val(sc)"source $val(sc)for {set i 0} {$i < $val(nn)} {incr i} { $ns_ initial_node_pos $node_($i) 10}for {set i 0} {$i < $val(nn)} {incr i} { $ns_ at $val(stop).000000001 "$node_($i) reset"}$ns_ at $val(stop).000000001 "finish"proc finish {} { global ns_ tracefd namtracefd $ns_ flush-trace close $tracefd close $namtracefd exit 0}$ns_ run
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -