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

📄 aodv.tcl

📁 Ad-hoc On-demand Distance Vector for ns2.31
💻 TCL
字号:
# An example for ad-hoc simulation with AODV# Define optionsset val(chan)		Channel/WirelessChannel		;# channel typeset val(prop)		Propagation/TwoRayGround	;# radio-propagation modelset val(netif)		Phy/WirelessPhy			;# network interface typeset val(mac)		Mac/802_11			;# MAC typeset val(ifq)		Queue/DropTail/PriQueue		;# interface queue typeset val(ll)		LL				;# link layer typeset val(ant)		Antenna/OmniAntenna		;# antenna modelset val(ifqlen)		50				;# max packet in ifqset val(nn)		9				;# number of mobilenodesset val(rp)		AODV				;# routing protocolset val(x)		2200				;# X dimension of topographyset val(y)		500				;# Y dimension of topographyset val(stop) 		150				;# time of simulation endset ns			[new Simulator]set tracefd		[open simple.tr w]set windowVsTime2	[open win.tr w]$ns trace-all $tracefd# set up topography objectset topo [new Topography]$topo load_flatgrid $val(x) $val(y)create-god $val(nn)## Create nn mobilenodes [$val(nn)] and attach them to the channel.## configure the nodes	$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) \			-channelType $val(chan) \			-topoInstance $topo \			-agentTrace ON \			-routerTrace ON \			-macTrace ON \			-movementTrace OFFfor {set i 0} {$i < $val(nn)} {incr i} {	set node_($i) [$ns node]}# Provide initial location of mobilenodesfor {set i 0} {$i < $val(nn)} {incr i} {$node_($i) set X_ [expr ($i+1)*200.0]$node_($i) set Y_ 250.0$node_($i) set Z_ 0.0}# Set a TCP connection between node_(0) and node_(8)set tcp [new Agent/TCP/Newreno]$tcp set class_ 2$tcp set window_ 2000Agent/TCPSink/DelAck set interval_ 100msset sink [new Agent/TCPSink/DelAck]$ns attach-agent $node_(0) $tcp$ns attach-agent $node_(8) $sink$ns connect $tcp $sinkset ftp [new Application/FTP]$ftp attach-agent $tcp$ns at 1.0 "$ftp start"# Printing the window sizeproc plotWindow {tcpSource file} {global nsset time 0.1set now [$ns now]set cwnd [$tcpSource set cwnd_]puts $file "$now $cwnd"$ns at [expr $now+$time] "plotWindow $tcpSource $file" }$ns at 1.1 "plotWindow $tcp $windowVsTime2"# Telling nodes when the simulation endsfor {set i 0} {$i < $val(nn)} {incr i} {	$ns at $val(stop) "$node_($i) reset";}# ending nam and the simulation$ns at $val(stop) "stop"$ns at [expr $val(stop)+0.1] "puts \"end simulation\" ; $ns halt"proc stop {} {	global ns tracefd	$ns flush-trace	close $tracefd}$ns run

⌨️ 快捷键说明

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