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

📄 main.tcl

📁 对IEEE 802.11e里的分布式信道接入算法EDCA进行改进
💻 TCL
字号:
############################################################################################# Main tcl code to access various wireless lan scenarios# ####################################################################################################################################################################################### Set defaults; its important to set defaults before parsing# command line arguments, so that defaults can be overriddenset mode		DCF				;# mode for this test DCF/PCFset pcf_period		0				;# CFP period for pcf modeset pcf_duration	0				;# CFP duration for pcf modeset endtime		100				;# duration of the simulationset title_		""				;# default title for the scenarioset idea_mac		0				;# default cleverness of mac							;# 	0 - normal							;# 	1 - persistent slotting							;# 	0 - PDCFset 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)		5				;# max packet in ifqset val(rp)		BSS			;# routing protocolset val(x)		500set val(y)		500##########################################1)Phy/WirelessPhy set CPThresh_	2000Phy/WirelessPhy set per_	0.0Mac/802_11 set bandwidth_	36MbMAC_MIB set RTSThreshold_	3000MAC_MIB set ShortRetryLimit_	7MAC_MIB set LongRetryLimit_	4PHY_MIB set MinimumBandwidth_	6MbPHY_MIB set SlotTime_		0.000009PHY_MIB set SIFS_		0.000016#niqiang modify for OFDM 36Mbps PHYPHY_MIB set PreambleLength_ 20     ;#20usPHY_MIB set PLCPHeaderLength_ 4    ;#4usPHY_MIB set CCATime_ 4             ;#4usPHY_MIB set RxTxTurnaroundTime_ 1  ;#1us#niqiang modify for adaptive period parameter inputMAC_MIB set adaptive_period_ [lindex $argv 2]set alpha [expr [lindex $argv 3] * 0.01 ]puts "alpha is $alpha"MAC_MIB set alpha_ $alpha############################################################################################ Usageif {$argc < 1} {	puts stderr "usage: ns $argv0 <scenario> \[list of options\]"	puts stderr "       options:"	puts stderr "             varName=varValue"	puts stderr "             vectorName=value0,value1,value2..."	puts stderr "       option example:"	puts stderr "             num_nodes=15"	exit 1;}############################################################################################ Load up the scenario; allow it to override the above defaultsset scenario [lindex $argv 0]set num_nodes [lindex $argv 1]puts "% set scenario $scenario $num_nodes"puts "Running scenario $scenario"source $scenario ############################################################################################ Parse remaining command line arguments to override any defaults#   2)########              Fin 2)# Setup other varsputs "Creating $num_nodes nodes"################################################################## cookie appended to scenario name for filenames that are createdif {[info exists cookie]} {	set outfile_ $scenario.$cookie} else {	set outfile_ $scenario}# num_bss_nodes describes the number of nodes in the BSS; the# remaining nodes are ADHOC; default: all nodes are in the BSSif {![info exists num_bss_nodes]} {	set num_bss_nodes $num_nodes}##################### Primary simulation objectsset ns_		[new Simulator]$ns_ use-newtraceset tracefd	[open $outfile_.tr w]$ns_ trace-all $tracefd# set namtrace	[open $outfile_.nam w]# $ns_ namtrace-all-wireless $namtrace $val(x) $val(y)# set up topography objectset topo       [new Topography]$topo load_flatgrid $val(x) $val(y)# Create Godcreate-god $num_nodes############################################################################################ Generic WLAN simulation objects# Create channel #1set chan_1_ [new $val(chan)]# Configure nodes to be "attached" to channel #1$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) \		 -topoInstance $topo \		 -agentTrace ON \		 -routerTrace ON \		 -macTrace ON \		 -movementTrace OFF \		 -channel $chan_1_ # Create nodes with IFQ send tracing enabled,# random motion disabledfor {set i 0} {$i < $num_nodes} {incr i} {	set node_($i) [$ns_ node]	$node_($i) add-ifq-send-trace	$node_($i) random-motion 0	# set initial position for NAM	$ns_ initial_node_pos $node_($i) 20	# Provide initial (X,Y, for now Z=0) co-ordinates	set diff [expr ($i + 1) / 2]	if {[expr $i % 2] == 0} {		set diff [expr -$diff]	}	$node_($i) set X_ [expr $num_nodes + $diff]	$node_($i) set Y_ [expr $num_nodes + $diff]	$node_($i) set Z_ 0.0}#################################################### lamia new# make node_(0) the AP for nodes in BSS#set AP_ $node_(0) ;#  lam ##set AP_MAC [$AP_ getMacAddr] ;#  lam ##for {set i 0} {$i < $num_bss_nodes} {incr i} { ;#  lam ##	$node_($i) setMac bss_id $AP_MAC ;#  lam ##} ;#  lam ############################################################################################# Scenario specific simulation objects (agents etc.)create_scenario############################################################################################ Modifications to the mac and/or other stuff dictated by the scenario!for {set i 0} {$i < $num_nodes} {incr i} {	#if {$idea_mac} {		#$node_($i) setMac IdeaMac $idea_mac		#puts "% node_($i) setMac IdeaMac $idea_mac"	#}	for {set p 0} {$p < [PLevels set plevels_]} {incr p} {		set difs_p [format "difs_%d" $p]		if {[info exists $difs_p]} {			set v [set $difs_p]			$node_($i) setMac difs $p $v			puts "% node_($i) setMac difs $p $v"		}	}	#if {$mode == "PCF"} {		#$node_($i) CFP $pcf_period $pcf_duration		#if {$i == 0} {		#	puts "% node_($i) CFP $pcf_period $pcf_duration"		#}	#}}if {$title_ != ""} {	set titlefd [open $outfile_.title w]	puts $titlefd "$title_"	close $titlefd}# to set a different CWMin for a particular node# priority level parameter is optional (0 by default)# use same method for CWMax/CWOffset/difs also# for difs: to increase/decrease by n, say +2 slots# $node_($i) setMac CWMin [priority level] 15#########################################################              ***Lamia#for {set i 0} {$i < $num_nodes} {incr i} { # for {set j 0} {$j < [PLevels set plevels_]} {incr p} {#$node_($i) setMac CWMin_j 0#$node_($i) setMac CWMax_j 2	#$node_($i) setMac CWMin [1] 0#$node_($i) setMac CWMin [2] 0#$node_($i) setMac CWMin [3] 0#$node_($i) setMac CWMax [1] 2#$node_($i) setMac CWMax [2] 2#$node_($i) setMac CWMax [3] 2					# #}##################################################################           ***Lamia# to set number of priority levels supported on a paricular node# $node_($i) setPLevels 4############################################################################################ End of simulation conditions/operationsfor {set i 0} {$i < $num_nodes } {incr i} {    $ns_ at $endtime "$node_($i) reset";}$ns_ at $endtime "do_stop"set delta 0.01set endtime [expr $endtime + $delta]$ns_ at $endtime "do_halt"proc do_stop {} {	global ns_ tracefd	$ns_ flush-trace	close $tracefd}proc do_halt {} {	global ns_	puts "NS EXITING..."	$ns_ halt}#####################################################################  **Lamia#puts " CWmin0 PHY_MIB $CWmin_0 "#puts " CWmin1 PHY_MIB $CWmin_1 "#puts " CWmin2 PHY_MIB $CWmin_2 "#puts " CWmin3 PHY_MIB $CWmin_3"#puts " CWmax0 PHY_MIB $CWmax_0"#puts " CWmax1 PHY_MIB $CWmax_1"#puts " CWmax2 PHY_MIB $CWmax_2 "#puts " CWmax3 PHY_MIB $CWmax_3"#######################################################################  **Lamia############################################################################################ Start up the simulationputs "Starting Simulation..."$ns_ run

⌨️ 快捷键说明

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