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

📄 ns-mobilenode.tcl

📁 Low Rate Wireless Personal Area Networks (LR-WPANs)in C
💻 TCL
📖 第 1 页 / 共 2 页
字号:
	set fec $fec_($t)	#	# Initialize ARP table only once.	#	if { $arptable_ == "" } {		set arptable_ [new ARPTable $self $mac]		# FOR backward compatibility sake, hack only		if {$imepflag != ""} {			set drpT [$self mobility-trace Drop "IFQ"]		} else {			set drpT [cmu-trace Drop "IFQ" $self]		}		$arptable_ drop-target $drpT		if { $namfp != "" } {			$drpT namattach $namfp		}        }	#	# Link Layer	#	$ll arptable $arptable_	$ll mac $mac	$ll down-target $ifq	if {$imepflag == "ON" } {		$imep recvtarget [$self entry]		$imep sendtarget $ll		$ll up-target $imep        } else {		$ll up-target [$self entry]	}	#	# Interface Queue	#	$ifq target $mac	$ifq set limit_ $qlen	if {$imepflag != ""} {		set drpT [$self mobility-trace Drop "IFQ"]	} else {		set drpT [cmu-trace Drop "IFQ" $self]        }	$ifq drop-target $drpT	if { $namfp != "" } {		$drpT namattach $namfp	}	#	# Mac Layer	#	$mac netif $netif	$mac up-target $ll	if {$outerr == "" && $fec == ""} {		$mac down-target $netif	} elseif {$outerr != "" && $fec == ""} {		$mac down-target $outerr		$outerr target $netif	} elseif {$outerr == "" && $fec != ""} {		$mac down-target $fec		$fec down-target $netif	} else {		$mac down-target $fec		$fec down-target $outerr		$err target $netif	}	set god_ [God instance]        if {$mactype == "Mac/802_11"} {		$mac nodes [$god_ num_nodes]	}	#	# Network Interface	#	#if {$fec == ""} {        #		$netif up-target $mac	#} else {        #		$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	# ============================================================	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_]	}	# ============================================================	$self addif $netif}# 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}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 + -