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

📄 ns-mobilenode.tcl

📁 一个很好的LINUX底下的GPRS协议栈
💻 TCL
📖 第 1 页 / 共 2 页
字号:
		} else {			$classifier_ defaulttarget $agent			$dmux_ install $port $agent		}	}}## The following setups up link layer, mac layer, network interface# and physical layer structures for the mobile node.#Node/MobileNode instproc add-interface { channel pmodel lltype rlctype mactype \		qtype qlen iftype anttype} {	$self instvar arptable_ nifs_ netif_ mac_ ifq_ ll_ rlc_ imep_ 		set ns [Simulator instance]	set imepflag [$ns imep-support]	set t $nifs_	incr nifs_	set netif_($t)	[new $iftype]		;# interface	set mac_($t)	[new $mactype]		;# mac layer	set ifq_($t)	[new $qtype]		;# interface queue	set ll_($t)	[new $lltype]		;# link layer	set rlc_($t)   [new $rlctype]		;# sandy's rlc	        set ant_($t)    [new $anttype]	set namfp [$ns get-nam-traceall]        if {$imepflag == "ON" } {              		# IMEP layer		set imep_($t) [new Agent/IMEP [$self id]]		set imep $imep_($t)		set drpT [$self mobility-trace Drop "RTR"]		if { $namfp != "" } {			$drpT namattach $namfp		}		$imep drop-target $drpT		$ns at 0.[$self id] "$imep_($t) start"   ;# start beacon timer        }	#	# Local Variables	#	set nullAgent_ [$ns set nullAgent_]	set netif $netif_($t)	set mac $mac_($t)	set ifq $ifq_($t)	set ll $ll_($t)	set rlc $rlc_($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 ifq $ifq ; #rj 	$ll mac $mac#	$ll down-target $ifq	$ll down-target $rlc	# sandy's rlc	$rlc up-target $ll    ;#?? doubtful	$rlc mac $mac	$rlc down-target $ifq#rlc acked if 1 ...non-acked mode if 0#	$rlc acked_ 1		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	$mac up-target $rlc 		 ;#sandy's rlc	$mac down-target $netif	set god_ [God instance]        if {$mactype == "Mac/802_11"} {		$mac nodes [$god_ num_nodes]	}	#	# Network Interface	#	$netif channel $channel	$netif 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 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	}}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_ rlc_ 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 + -