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

📄 driver.flood.tcl

📁 code that can compile NS-2.27 on Fedora Core 4
💻 TCL
字号:
# The driver for our simulations..# ======================================================================# Define options# ======================================================================set val(chan)       Channel/WirelessChannelset val(prop)       Propagation/TwoRayGroundset val(netif)      Phy/WirelessPhyset val(mac)        Mac/802_11set val(ifq)        Queue/DropTail/PriQueueset val(ll)         LLset val(ant)        Antenna/OmniAntennaset val(x)              1500   ;# X dimension of the topographyset val(y)              1500   ;# Y dimension of the topographyset val(ifqlen)         50            ;# max packet in ifqset val(adhocRouting)   FLOODset val(nn)             100             ;# how many nodes are simulatedset val(scDir)          "scenarios/" set val(stop)           910.0           ;# simulation time# minimize memory requirements by removing all irrelevant packet headersremove-packet-header PGM PGM_SPM PGM_NAK Pushback NV LDP MPLS rtProtoLS Pingremove-packet-header TFRC TFRC_ACK Diffusion RAP TORA IMEP MIPremove-packet-header IPinIP Encap HttpInval MFTP SRMEXT SRM aSRMremove-packet-header mcastCtrl CtrMcast rtProtoDV GAF Snoop TCPA TCP IVSremove-packet-header Resv UMP Src_rt# selectively allow only one of the following: AODV, SR, BCAST# FLOOD actually needs none of these...remove-packet-header AODVremove-packet-header SRremove-packet-header BCAST# =====================================================================# Main Program# ======================================================================## Check for command-line parameters#if {$argc != 4} {	error "Not enough command-line parameters"}set val(seed) [lindex $argv 3].0## Initialize Global Variables## create simulator instanceset ns_		[new Simulator]# setup topography objectset topo	[new Topography]# create trace object for nsset tracefd	[open [lindex $argv 2] w]# $ns_ use-newtrace$ns_ trace-all $tracefd# define topology$topo load_flatgrid $val(x) $val(y)## Create God#set god_ [create-god $val(nn)]## define how node should be created##global node setting$ns_ node-config -adhocRouting $val(adhocRouting) \                 -llType $val(ll) \                 -macType $val(mac) \                 -ifqType $val(ifq) \                 -ifqLen $val(ifqlen) \                 -antType $val(ant) \                 -propType $val(prop) \                 -phyType $val(netif) \                 -channelType $val(chan) \		 -topoInstance $topo \		 -agentTrace ON \                 -routerTrace OFF \                 -macTrace ON ##  Create the specified number of nodes [$val(nn)] and "attach" them#  to the channel. for {set i 0} {$i < $val(nn) } {incr i} {	set node_($i) [$ns_ node]		$node_($i) random-motion 0		;# disable random motion# create a default target for redirecting the traffic (will be at port 0)	set null_($i) [new Agent/Null]	$ns_ attach-agent $node_($i) $null_($i)}# # Define node movement model#puts "Loading connection pattern..."source [lindex $argv 0]# # Define traffic model#puts "Loading scenario file..."source $val(scDir)[lindex $argv 1]## Tell nodes when the simulation ends#for {set i 0} {$i < $val(nn) } {incr i} {    $ns_ at $val(stop).0 "$node_($i) reset";}$ns_ at  $val(stop).0002 "puts \"NS EXITING...\" ; $ns_ halt"puts $tracefd "M 0.0 nn $val(nn) x $val(x) y $val(y) rp $val(adhocRouting)"puts $tracefd "M 0.0 [lindex $argv 0]"puts $tracefd "M 0.0 sc $val(scDir)[lindex $argv 1]"puts $tracefd "M 0.0 [lindex $argv 2]"puts $tracefd "M 0.0 seed $val(seed) prop $val(prop) ant $val(ant)"puts "Starting Simulation..."$ns_ run

⌨️ 快捷键说明

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