⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dsdv.tcl

📁 Ubuntu dsdv无线网络中的NS2模拟源代码
💻 TCL
字号:
# a simple wireless simulation running with DSDV
# mobile node:20
# time of simulation: 300s
# speed of mobile node: 20 m/s, 1 packets/second
# pausetime: 30s
# max connection: 20
# topology: 800*600
#======================================================================
# Define options
#======================================================================
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) 64 ;# max packet in interface queue
set val(nn) 20 ;# number of mobilenodes
set val(rp) DSDV ;# routing protocol
set opt(cp) "../mobility/cbr-n20-mc10" ;# cbr stream between nodes
set opt(sc) "../mobility/scen-n20-m10-p0" ;# node movement file.
#======================================================================
# Main Program
#======================================================================
puts "\n"
puts " Simulation of a simple wireless topology running with DSDV\n"
puts " Starting Simulation...\n"
# Initialize Global Variables
set ns_ [new Simulator]
# set the output directory of trace file
set tracefd [open wireless-dsdv00.tr w]
# use revised trace file edition
$ns_ use-newtrace
$ns_ trace-all $tracefd

# set up topography object
set topo [new Topography]
$topo load_flatgrid 800 600
# Create God
set god_ [new God]
create-god $val(nn)
set chan [new $val(chan)]
# Create the specified number of mobilenodes [$val(nn)] and "attach" them to the channel.
# Here fifty nodes are created : node(1) - node(20)
# configure 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 OFF
        for {set i 0} {$i < $val(nn) } {incr i} {

                set node_($i) [$ns_ node]

                $node_($i) random-motion 0            ;# disable random motion

        }
#
# load file of traffic flow
puts " Loading connection pattern file\n"
source $opt(cp)
puts " Load complete...\n"
# load file of simulation scenario
puts " Loading scenario file...\n"
source $opt(sc)
puts " Load complete...\n"
puts " Simulation may take a lot of minutes.............\n"
puts " a script writed by YangBin"
# Tell nodes when the simulation ends
for {set i 0} {$i < $val(nn) } {incr i} {
$ns_ at 300.0 "$node_($i) reset";
}
$ns_ at 300.0 "stop"
$ns_ at 300.1 "puts \" Simulation runs sucessfully and NS EXITING...\" ; $ns_ halt"
proc stop {} {
global ns_ tracefd
$ns_ flush-trace
close $tracefd
}
# some useful headers for tracefile
puts $tracefd "Here is a trace for simple wireless simulation\n"
puts $tracefd "The nodes movement file is $opt(cp)\n"
puts $tracefd "The traffic flow between nodes is $opt(sc)\n"
$ns_ run
# END
 

⌨️ 快捷键说明

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