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

📄 ns-mobilenode.tcl

📁 NS-2.28的802.11e协议扩展源代码
💻 TCL
📖 第 1 页 / 共 2 页
字号:
Node/MobileNode instproc getMacAddr {} {	$self instvar mac_	return [$mac_(0) id]}Node/MobileNode instproc setMac { param0 param1 args } {	$self instvar mac_	if { $args != "" } {		$mac_(0) $param0 $param1 $args	} else {		$mac_(0) $param0 $param1	}}Node/MobileNode instproc setPLevels { value } {	$self instvar mac_ ifq_	$ifq_(0) plevels $value	$mac_(0) plevels $value}Node/MobileNode instproc CFP { beacon_period cfp_duration } {	$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 add-ifq-send-trace { } {	$self instvar namtraceFile_	$self instvar ifq_	set ifq $ifq_(0)	set sndT [[Simulator instance] mobility-trace Send "IFQ" $self]	if [info exists namtraceFile_] {		$sndT namattach $namtraceFile_	}	$sndT target [$ifq target]	$ifq target $sndT}##  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 mactype qtype qlen iftype anttype} {	$self instvar arptable_ nifs_	$self instvar netif_ mac_ ifq_ ll_	$self instvar imep_	$self instvar namtraceFile_		#global ns_ opt	#set MacTrace [Simulator set MacTrace_]	set ns_ [Simulator instance]	set imepflag [$ns_ imep-support]	set t $nifs_	incr nifs_	create_mibs	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 ant_($t)    [new $anttype]        if {$imepflag == "ON" } {              ;# IMEP layer            set imep_($t) [new Agent/IMEP [$self id]]            set imep $imep_($t)            set drpT [$ns_ mobility-trace Drop "RTR" $self]            if [info exists namtraceFile_] {                $drpT namattach $namtraceFile_            }            $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)	#	# Initialize ARP table only once.	#	if { $arptable_ == "" } {            set arptable_ [new ARPTable $self $mac]            # FOR backward compatibility sake, hack only	    	    if {$imepflag != ""} {                set drpT [$ns_ mobility-trace Drop "IFQ" $self]	    } else {		set drpT [cmu-trace Drop "IFQ" $self]	    }	    	    $arptable_ drop-target $drpT            if [info exists namtraceFile_] {	       $drpT namattach $namtraceFile_	    }        }	#	# Link Layer	#	$ll arptable $arptable_	$ll mac $mac#	$ll up-target [$self entry]	$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 qlim_ $qlen	if {$imepflag != ""} {	    set drpT [$ns_ mobility-trace Drop "IFQ" $self]	} else {	    set drpT [cmu-trace Drop "IFQ" $self]        }	$ifq drop-target $drpT        if  [info exists namtraceFile_]  {           $drpT namattach $namtraceFile_	} 	#	# Mac Layer	#	$mac netif $netif	$mac ll $ll	$mac up-target $ll	$mac down-target $netif	#$mac nodes $opt(nn)	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	    # Trace end of transmission time for packets	    #	    if {$imepflag != ""} {	        set logT [$ns_ mobility-trace Recv "MAC" $self]		set eotT [$ns_ mobility-trace EOT "MAC" $self]	    } else {		set logT [cmu-trace Recv "MAC" $self]		set eotT [cmu-trace EOT "MAC" $self]	    }	    $mac log-target $logT	    $mac eot-target $eotT            if [info exists namtraceFile_] {                $logT namattach $namtraceFile_            }	    #	    # Trace Sent Packets	    #	    if {$imepflag != ""} {	        set sndT [$ns_ mobility-trace Send "MAC" $self]	    } else {		set sndT [cmu-trace Send "MAC" $self]	    }	    $sndT target [$mac down-target]	    $mac down-target $sndT            if [info exists namtraceFile_] {                $sndT namattach $namtraceFile_            }	    #	    # Trace Received Packets	    #	    if {$imepflag != ""} {		set rcvT [$ns_ mobility-trace Recv "MAC" $self]	        	    } else {	        set rcvT [cmu-trace Recv "MAC" $self]	    }	    $rcvT target [$mac up-target]	    $mac up-target $rcvT            if [info exists namtraceFile_] {                $rcvT namattach $namtraceFile_            }	    #	    # Trace Dropped Packets	    #	    if {$imepflag != ""} {	        set drpT [$ns_ mobility-trace Drop "MAC" $self]	    } else {		set drpT [cmu-trace Drop "MAC" $self]`	    }	    $mac drop-target $drpT            if [info exists namtraceFile_] {                $drpT namattach $namtraceFile_            }	} else {	    $mac log-target [$ns_ set nullAgent_]	    $mac drop-target [$ns_ set nullAgent_]	}	# ============================================================	$self addif $netif}Node/MobileNode instproc nodetrace { tracefd } {    set ns_ [Simulator instance]    #    # This Trace Target is used to log changes in direction    # and velocity for the mobile node.    #    set T [new Trace/Generic]    $T target [$ns_ set nullAgent_]    $T attach $tracefd    $T set src_ [$self id]    $self log-target $T    }Node/MobileNode instproc agenttrace {tracefd} {    $self instvar namtraceFile_     set ns_ [Simulator instance]        set ragent [$self set ragent_]        #    # Drop Target (always on regardless of other tracing)    #    set drpT [$ns_ mobility-trace Drop "RTR" $self]    if [info exists namtraceFile_] {       $drpT namattach $namtraceFile_    }    $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 log-target $T    $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    }}## method to remove an entry from the hier classifiersNode/MobileNode instproc clear-hroute args {    $self instvar classifiers_    set a [split $args]    set l [llength $a]    $classifiers_($l) clear [lindex $a [expr $l-1]] }Node/MobileNode instproc mip-call {ragent} {    $self instvar regagent_    if [info exists regagent_] {        $regagent_ ragent $ragent    }}Node instproc mip-call {ragent} {}#-----------------------------------------------------------------Agent/DSRAgent set sport_ 255Agent/DSRAgent set dport_ 255Agent/DSRAgent set rt_port 255Class SRNodeNew -superclass Node/MobileNodeSRNodeNew instproc init {args} {	#global ns ns_ opt tracefd RouterTrace	$self instvar dsr_agent_ dmux_ entry_point_ address_        set ns_ [Simulator instance]	eval $self next $args	;# parent class constructor	if {$dmux_ == "" } {		set dmux_ [new Classifier/Port]		$dmux_ set mask_ [AddrParams set PortMask_]		$dmux_ set shift_ [AddrParams set PortShift_]		#		# point the node's routing entry to itself		# at the port demuxer (if there is one)		#		#if [Simulator set EnableHierRt_] {		    #$self add-hroute $address_ $dmux_		#} else {		    #$self add-route $address_ $dmux_		#}	}	# puts "making dsragent for node [$self id]"	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 [$ns_ mobility-trace Recv "RTR" $self]        set namtraceFile_ [$ns_ set namtraceAllFile_]        if {  $namtraceFile_ != "" } {            $rcvT namattach $namtraceFile_        }	$rcvT target $dsr_agent_	set entry_point_ $rcvT	    } else {	# Recv Target	set entry_point_ $dsr_agent_    }    #    # Drop Target (always on regardless of other tracing)    #    #set drpT [$ns_ mobility-trace Drop "RTR" $self]    #$dsr_agent_ drop-target $drpT    #    # Log Target    #    #set tracefd [$ns_ get-ns-traceall]    #if {$tracefd != "" } {    #     set T [new Trace/Generic]    #     $T target [$ns_ set nullAgent_]    #     $T attach $tracefd    #     $T set src_ [$self id]    #     $dsr_agent_ log-target $T    #}    $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 [Agent/DSRAgent set rt_port] $nullAgent_    # SRNodeNews 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_"        #$ns_ at 0.0 "$node start-dsr"    return $self}SRNodeNew instproc start-dsr {} {    $self instvar dsr_agent_    #global opt;    $dsr_agent_ startdsr    #if {$opt(cc) == "on"} {checkcache $dsr_agent_}}SRNodeNew instproc entry {} {        $self instvar entry_point_        return $entry_point_}SRNodeNew instproc add-interface {args} {    set ns_ [Simulator instance]    eval $self next $args    $self instvar dsr_agent_ ll_ mac_ ifq_    $dsr_agent_ mac-addr [$mac_(0) id]    if { [Simulator set RouterTrace_] == "ON" } {	# Send Target	set sndT [$ns_ mobility-trace Send "RTR" $self]        set namtraceFile_ [$ns_ set namtraceAllFile_]        if {$namtraceFile_ != "" } {            $sndT namattach $namtraceFile_        }	$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}#new base station nodeClass BaseNode -superclass {HierNode Node/MobileNode}BaseNode instproc init {args} {    $self instvar address_    $self next $args    set address_ $args}BaseNode instproc install-defaulttarget {rcvT} {    $self instvar classifiers_    set level [AddrParams set hlevel_]    for {set i 1} {$i <= $level} {incr i} {		$classifiers_($i) defaulttarget $rcvT#		$classifiers_($i) bcast-receiver $rcvT    }}## Global Defaults - avoids those annoying warnings generated by bind()#Node/MobileNode set X_				0Node/MobileNode set Y_				0Node/MobileNode set Z_				0Node/MobileNode set speed_			0Node/MobileNode set position_update_interval_	0

⌨️ 快捷键说明

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