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

📄 m-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
set psize		       1500
PLevels set max_plevels_	  4
PLevels set plevels_		  4
PHY_MIB set CWMin_0		  7
PHY_MIB set CWOffset_0		  0
PHY_MIB set CWMin_1		 63
PHY_MIB set CWOffset_1		 40
PHY_MIB set CWMin_2		127
PHY_MIB set CWOffset_2		100
PHY_MIB set CWMin_3		255
PHY_MIB set CWOffset_3		200

proc create_scenario { } {
	global ns_ node_ title_
	global num_nodes
	global psize

#	SETUP
	set num_phones	[expr $num_nodes / 2]
	puts "num_phones $num_phones\n"
	set title_ "set title \"PHY(36) CW(7, 63, 127, 255) CO(0, 40, 100, 200) MTU(128/$psize)\""

	# 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])
		puts "connecting phone $i "

		set udp [new Agent/UDP]
		$udp set class_ [expr 2 + $i]
		$udp set prio_ 0
		$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]
	puts "tcp sources $num_ftp\n"

	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 prio_ [expr $i + 1]
		if {$prio_ > 3} {
			set prio_ 3
		}

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

		$src set packetSize_ $psize; # MTU

		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 + -