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

📄 ns-mobilenode.tcl

📁 OPNET 中的Wimax模块, 主要用于wimax 无线网络仿真,以及普通无线网络仿真.
💻 TCL
📖 第 1 页 / 共 2 页
字号:
        #		$netif up-target $fec	#	$fec up-target $mac	#}	$netif channel $channel	if {$inerr == "" && $fec == ""} {		$netif up-target $mac	} elseif {$inerr != "" && $fec == ""} {		$netif up-target $inerr		$inerr target $mac	} elseif {$err == "" && $fec != ""} {		$netif up-target $fec		$fec up-target $mac	} else {		$netif up-target $inerr		$inerr target $fec		$fec up-target $mac	}	$netif propagation $pmodel	;# Propagation Model	$netif node $self		;# Bind node <---> interface	$netif antenna $ant_($t)	#	# Physical Channel	#	$channel addif $netif	        # List-based improvement	# For nodes talking to multiple channels this should	# be called multiple times for each channel	$channel add-node $self			# let topo keep handle of channel	$topo channel $channel	# ============================================================	if { [Simulator set MacTrace_] == "ON" } {		#		# Trace RTS/CTS/ACK Packets		#		if {$imepflag != ""} {			set rcvT [$self mobility-trace Recv "MAC"]		} else {			set rcvT [cmu-trace Recv "MAC" $self]		}		$mac log-target $rcvT		if { $namfp != "" } {			$rcvT namattach $namfp		}		#		# Trace Sent Packets		#		if {$imepflag != ""} {			set sndT [$self mobility-trace Send "MAC"]		} else {			set sndT [cmu-trace Send "MAC" $self]		}		$sndT target [$mac down-target]		$mac down-target $sndT		if { $namfp != "" } {			$sndT namattach $namfp		}		#		# Trace Received Packets		#		if {$imepflag != ""} {			set rcvT [$self mobility-trace Recv "MAC"]		} else {			set rcvT [cmu-trace Recv "MAC" $self]		}		$rcvT target [$mac up-target]		$mac up-target $rcvT		if { $namfp != "" } {			$rcvT namattach $namfp		}		#		# Trace Dropped Packets		#		if {$imepflag != ""} {			set drpT [$self mobility-trace Drop "MAC"]		} else {			set drpT [cmu-trace Drop "MAC" $self]		}		$mac drop-target $drpT		if { $namfp != "" } {			$drpT namattach $namfp		}	} else {		$mac log-target [$ns set nullAgent_]		$mac drop-target [$ns set nullAgent_]	}# change wrt Mike's code       if { [Simulator set EotTrace_] == "ON" } {               #               # Also trace end of transmission time for packets               #               if {$imepflag != ""} {                       set eotT [$self mobility-trace EOT "MAC"]               } else {                       set eoT [cmu-trace EOT "MAC" $self]               }               $mac eot-target $eotT       }	# ============================================================	$self addif $netif}#developed by Juliana Freitag (juliana@ic.unicamp.br)#Modification to support 802_16 over wirelessNode/MobileNode instproc startsim {} {	$self instvar mac_        $mac_(0) cmd "start" }Node/MobileNode instproc configure-channel { updatarate_ ticks_ maxburst_ upoverhead_ downdatarate_ doverhead_} {	$self instvar mac_        set propdelay_ 0.000002        $mac_(0) "configure-upstream" $updatarate_ $ticks_ $maxburst_ $upoverhead_ $propdelay_        $mac_(0) "configure-downstream" $downdatarate_ $doverhead_ $propdelay_}Node/MobileNode instproc configure-upflows {node flows} {        $self instvar maclist_ tmp_ nodelist_ 	$self instvar default_ schtype_ cldst_ clpkt_ phs_	$self instvar frag_ conc_ conc_thr_ piggy_ gsize_ gint_	$self instvar tmpsrc_ tmpdst_ qsize_ debugon_        $self instvar USratecntrlon_ USrate_ latency_ minBW_ aggreqinterval_		set tmp_ [$node id]	set tmpsrc_ $tmp_        set default_ [lindex $flows 0]	set schtype_ [lindex $flows 1]	set cldst_ [lindex $flows 2]	set tmpdst_ [$cldst_ id]	set clpkt_ [lindex $flows 3]	set phs_ [lindex $flows 4]	set frag_ [lindex $flows 5]	set conc_ [lindex $flows 6]	set conc_thr_ [lindex $flows 7]	set piggy_ [lindex $flows 8]	set gsize_ [lindex $flows 9]	set gint_ [lindex $flows 10]	set qsize_ [lindex $flows 11]        set latency_ [lindex $flows 12]        set minBW_ [lindex $flows 13]	set aggreqinterval_ [lindex $flows 14]	set debugon_ [lindex $flows 15]	set USratecntrlon_ [lindex $flows 16]	set USrate_ [lindex $flows 17]	$self instvar mac_	$mac_(0) "insert-upflow" $schtype_ $tmp_ $tmpdst_ $clpkt_ $phs_ $frag_ $conc_ $conc_thr_ $piggy_ $gsize_ $gint_ $latency_ $minBW_ $aggreqinterval_ $default_ $qsize_ $debugon_ $USratecntrlon_ $USrate_ }Node/MobileNode instproc configure-downflows {node flows} {        $self instvar dst_ schtype_ default_ tmp_	$self instvar src_ pkttype_ phs_ dsrate_ tkqlen_ bucket_	$self instvar tmpsrc_ ratecntrlon_ gsize_ gint_ qsize_ latency_ minBW_		set dst_ [$node id]        set default_ [lindex $flows 0] 	set schtype_ [lindex $flows 1]	set tmp_ [lindex $flows 2]	set src_ [$tmp_ id]	set pkttype_ [lindex $flows 3]	set phs_ [lindex $flows 4]        set gsize_ [lindex $flows 5]	set gint_ [lindex $flows 6]        set qsize_ [lindex $flows 7]        set latency_ [lindex $flows 8]        set minBW_ [lindex $flows 9]#	set ratecntrlon_ [lindex $flows 3]#	set dsrate_ [lindex $flows 4]#	set tkqlen_ [lindex $flows 5]#	set bucket_ [lindex $flows 6]	$self instvar mac_#	$mac_(0) cmd "insert-downflow" $tmpsrc_ $tmp_ $clpkt_ $phs_ 0 $ratecntrlon_ $dsrate_ $tkqlen_ $bucket_	$mac_(0) "insert-downflow" $default_ $schtype_ $src_ $dst_ $pkttype_ $phs_ $gsize_ $gint_ $latency_ $minBW_ $qsize_ 0 0 0 0}Node/MobileNode instproc configure-mapparams { time_covered map_interval contslots_permap mgmtslots_permap bkoff_start bkoff_end proportion map_lookahead } {	$self instvar mac_		$mac_(0) cmd "configure-mapparam"  $time_covered $map_interval $contslots_permap $mgmtslots_permap $bkoff_start $bkoff_end $proportion $map_lookahead }Node/MobileNode instproc configure-mgmtparams {sync_msg_interval rng_msg_interval ucd_msg_interval} {        $self instvar maclist_ tmp_ nodelist_ 	        $self instvar mac_        $mac_(0) cmd "configure-mgmtparams"  $sync_msg_interval $rng_msg_interval $ucd_msg_interval 100}Node/MobileNode instproc configure-ss {priority rng_msg_interval cm_id debug} {	$self instvar mac_		$mac_(0) cmd "configure-ss" $priority $rng_msg_interval $cm_id $debug}#dump ss BW#StatisticsNode/MobileNode instproc dump-final-ss-stats { node outputFile } {        $self instvar tmp_ 	set tmp_ [$node id] 	$self instvar mac_	$mac_(0) cmd "dump-final-ss-stats"  $outputFile }	#dump bs BW#Statistics#####################################################################################function : dump-final-bs-stats##  explanation:  Calls 802_16 BS method to print stats.  Can be called periodically#                during a simulation.  But typically will be called once at the end#                of the simulation run.#                It is invoked as follows:#			$ns at $printtime "dump-final-bs-stats  $p $ns $n1 log.out"#                Eventually this calls the BS objects dumpFinalBSStats method.# Output:# 	The following lines are produced with each invocation:##	dumpFinalBSStats(10.100000) Total drops in DS: 0;  loss rate: 0.000000 percent#                       Total Packets sent downstream: 4495, Total Packets received upstream: 3464#                       Total Bytes sent downstream: 255768, Total Bytes received upstream: 3527338#                       downstream Util: 0.668 percent, upstream Util: 54.569 percent## #####################################################################################Node/MobileNode instproc dump-final-bs-stats { outputFile DSBW USBW } {	$self instvar mac_        $mac_(0) cmd "dump-final-bs-stats"  $outputFile $DSBW $USBW}#End of modification# set transmission powerNode/MobileNode instproc setPt { val } {	$self instvar netif_	$netif_(0) setTxPower $val}# set receiving powerNode/MobileNode instproc setPr { val } {	$self instvar netif_	$netif_(0) setRxPower $val}# set idle power -- ChalermekNode/MobileNode instproc setPidle { val } {	$self instvar netif_	$netif_(0) setIdlePower $val}# change wrt Mike's code Node/MobileNode instproc getMac {param0} {       $self instvar mac_       return $mac_($param0) } Node/MobileNode instproc CFP { beacon_period cfp_duration } {       if {$mactype == "Mac/802_11"} {               $self instvar mac_               set ns_ [Simulator instance]               set beacon_period [$ns_ delay_parse $beacon_period]               set cfp_duration [$ns_ delay_parse $cfp_duration]               $mac_(0) cfp $beacon_period $cfp_duration       } }Node/MobileNode instproc mobility-trace { ttype atype } {	set ns [Simulator instance]        set tracefd [$ns get-ns-traceall]        if { $tracefd == "" } {	        puts "Warning: You have not defined you tracefile yet!"	        puts "Please use trace-all command to define it."		return ""	}	set T [new CMUTrace/$ttype $atype]	$T newtrace [Simulator set WirelessNewTrace_]	$T tagged [Simulator set TaggedTrace_]	$T target [$ns nullagent]	$T attach $tracefd        $T set src_ [$self id]        $T node $self	return $T}Node/MobileNode instproc nodetrace { tracefd } {	#	# This Trace Target is used to log changes in direction	# and velocity for the mobile node.	#	set T [new Trace/Generic]	$T target [[Simulator instance] set nullAgent_]	$T attach $tracefd	$T set src_ [$self id]	$self log-target $T    }Node/MobileNode instproc agenttrace {tracefd} {	set ns [Simulator instance]	set ragent [$self set ragent_]	#	# Drop Target (always on regardless of other tracing)	#	set drpT [$self mobility-trace Drop "RTR"]	set namfp [$ns get-nam-traceall]	if { $namfp != ""} {		$drpT namattach $namfp	}	$ragent drop-target $drpT	#	# Log Target	#	set T [new Trace/Generic]	$T target [$ns set nullAgent_]	$T attach $tracefd	$T set src_ [$self id]	$ragent tracetarget $T	#	# XXX: let the IMEP agent use the same log target.	#	set imepflag [$ns imep-support]	if {$imepflag == "ON"} {		[$self set imep_(0)] log-target $T	}}Node/MobileNode instproc mip-call {ragent} {	$self instvar regagent_	if [info exists regagent_] {		$regagent_ ragent $ragent	}}Node/MobileNode instproc attach-gafpartner {} {        $self instvar gafpartner_ address_ ll_         set gafpartner_ [new GAFPartner]	$gafpartner_ set mask_ [AddrParams NodeMask 1]	$gafpartner_ set shift_ [AddrParams NodeShift 1]	set nodeaddr [AddrParams addr2id [$self node-addr]]		#$gafpartner_ set addr_ [expr ( ~([AddrParams NodeMask 1] << \	#		[AddrParams NodeShift 1]) & $nodeaddr )]		$gafpartner_ set addr_ $nodeaddr	$gafpartner_ set port_ 254	#puts [$gafpartner_ set addr_]        $gafpartner_ target [$self entry]	$ll_(0) up-target $gafpartner_}Node/MobileNode instproc unset-gafpartner {} {	$self instvar gafpartner_		$gafpartner_ set-gafagent 0}# <zheng: add>Node/MobileNode instproc sscs args {	$self instvar mac_	eval $mac_(0) sscs $args}Node/MobileNode instproc NodeClr {arg1} {	$self instvar mac_	$mac_(0) NodeClr $arg1}Node/MobileNode instproc NodeLabel args {	$self instvar mac_	eval $mac_(0) NodeLabel $args}Node/MobileNode instproc node-down {} {	$self instvar mac_	$mac_(0) node-down}Node/MobileNode instproc node-up {} {	$self instvar mac_	$mac_(0) node-up}Node/MobileNode instproc RNType args {	$self instvar ragent_	eval $ragent_ RNType $args}# </zheng: add>Class SRNodeNew -superclass Node/MobileNodeSRNodeNew instproc init args {	$self instvar dsr_agent_ dmux_ entry_point_ address_        set ns [Simulator instance]	eval $self next $args	;# parent class constructor	if {$dmux_ == "" } {		# Use the default mash and shift		set dmux_ [new Classifier/Port]	}	set dsr_agent_ [new Agent/DSRAgent]	# setup address (supports hier-address) for dsragent	$dsr_agent_ addr $address_	$dsr_agent_ node $self	if [Simulator set mobile_ip_] {		$dsr_agent_ port-dmux [$self set dmux_]	}	# set up IP address	$self addr $address_		if { [Simulator set RouterTrace_] == "ON" } {		# Recv Target		set rcvT [$self mobility-trace Recv "RTR"]		set namfp [$ns get-nam-traceall]		if {  $namfp != "" } {			$rcvT namattach $namfp		}		$rcvT target $dsr_agent_		set entry_point_ $rcvT		} else {		# Recv Target		set entry_point_ $dsr_agent_	}	$self set ragent_ $dsr_agent_	$dsr_agent_ target $dmux_	# packets to the DSR port should be dropped, since we've	# already handled them in the DSRAgent at the entry.	set nullAgent_ [$ns set nullAgent_]	$dmux_ install [Node set rtagent_port_] $nullAgent_	# SRNodes don't use the IP addr classifier.  The DSRAgent should	# be the entry point	$self instvar classifier_	set classifier_ "srnode made illegal use of classifier_"	return $self}SRNodeNew instproc start-dsr {} {	$self instvar dsr_agent_	$dsr_agent_ startdsr}SRNodeNew instproc entry {} {        $self instvar entry_point_        return $entry_point_}SRNodeNew instproc add-interface args {	eval $self next $args	$self instvar dsr_agent_ ll_ mac_ ifq_	set ns [Simulator instance]	$dsr_agent_ mac-addr [$mac_(0) id]	if { [Simulator set RouterTrace_] == "ON" } {		# Send Target		set sndT [$self mobility-trace Send "RTR"]		set namfp [$ns get-nam-traceall]		if {$namfp != "" } {			$sndT namattach $namfp		}		$sndT target $ll_(0)		$dsr_agent_ add-ll $sndT $ifq_(0)	} else {		# Send Target		$dsr_agent_ add-ll $ll_(0) $ifq_(0)	}	# setup promiscuous tap into mac layer	$dsr_agent_ install-tap $mac_(0)}SRNodeNew instproc reset args {	$self instvar dsr_agent_	eval $self next $args	$dsr_agent_ reset}

⌨️ 快捷键说明

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