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

📄 demo-scenario.tcl

📁 对IEEE 802.11e里的分布式信道接入算法EDCA进行改进
💻 TCL
字号:
#
# A wireless lan scenario with 1 ftp stream and 2 phone
# traffic streams as the default case; passing in the
# num of nodes as an argument sets up half the nodes as
# phones into the AP, and the other half as ftp streams
# in pairs
#
#

# defaults
set num_nodes 5

proc create_scenario { } {
	global ns_ node_
	global num_nodes

	set num_phones	[expr $num_nodes / 2]

	# Setup phones on first set of nodes, sending to the node 0
	# Flow ids 2 onwards - cbr over UDP
	for {set i 0} {$i < $num_phones} {incr i} {
		set phone $node_([expr $i + 1])

		set udp [new Agent/UDP]
		$udp set class_ [expr 2 + $i]
		$ns_ attach-agent $phone $udp

		set udp_base [new Agent/UDP]
		$ns_ attach-agent $node_(0) $udp_base

		$ns_ connect $udp $udp_base

		set audio [new Application/Traffic/CBR]
		$audio attach-agent $udp
		$audio set packetSize_ 120
		$audio set interval_ 10ms

		if {$num_phones == 2} {		;# special default case
			$audio set random_ 0
			$ns_ at [expr 3.0 + 3.005 * $i] "$audio start" 
		} else {
			$audio set random_ 1
			$ns_ at [expr 3.0 + $i] "$audio start" 
		}
	}

	# Setup ftp over TCP between remaining pairs of nodes
	set num_ftp [expr ($num_nodes - $num_phones - 1) / 2]
	for {set i 0} {$i < $num_ftp} {incr i} {
		set n [expr $num_phones + (2 * $i) + 1]
		set client $node_($n)
		set server $node_([expr $n + 1])

		set src [new Agent/TCP]
		$src set class_ [expr 2 + $num_phones + $i]
#		$src set packetSize_ 128
		$src set syn_ 1
		$ns_ attach-agent $client $src

		set sink [new Agent/TCPSink/DelAck]
		$ns_ attach-agent $server $sink

		$ns_ connect $src $sink

		set ftp [new Application/FTP]
		$ftp attach-agent $src

		if {$num_ftp == 1} {		;# special default case
			$ns_ at 9.0025 "$ftp start"
		} else {
			$ns_ at [expr 3.0 + $num_phones + $i] "$ftp start"
		}
	}

}

⌨️ 快捷键说明

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