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

📄 bst.tcl

📁 跑leach需要的
💻 TCL
📖 第 1 页 / 共 2 页
字号:
		set rpfoif ""	}	if { $oiflist_($group) == $rpfoif && ![$node_ check-local $group] } {		# propagate		$node_ add-mark m2 red circle		$self send-ctrl "graft" $RP_($group) $group	}	if { [lsearch $oiflist_($group) $oif] < 0 } {		lappend oiflist_($group) $oif		if { [$node_ lookup-iface "x" $group] != $iface } {			set rep [$node_ getReps "x" $group]			if { $rep != "" } {				$rep insert $oif			}		}	}}## send a graft/prune for src/group up the RPF tree towards dst#BST instproc send-ctrl { which dst group } {        $self instvar mctrl_ ns_ node_		if {$node_ != $dst} {		set nbr [$node_ rpf-nbr $dst]		if [$nbr is-lan?] {			# we're requested to send via a lan			$nbr instvar receivers_			# send graft/prune only if there's no other receiver.			if { [info exists receivers_($group)] && \				 $receivers_($group) > 0 } return			set nbr [$nbr rpf-nbr $dst]#  			$self dbg "BST::send-ctrl The first hop router to LAN is node [$nbr id]"		}#  		$self dbg "BST::send-ctrl $ns_ simplex-connect \[\[\[$nbr getArbiter\] getType \[$self info class\]\] set mctrl_\]"		$ns_ simplex-connect $mctrl_ \				[[[$nbr getArbiter] getType [$self info class]] set mctrl_]		if { $which == "prune" } {			$mctrl_ set fid_ 2		} else {			$mctrl_ set fid_ 3		}# 		$self dbg "BST::send-ctrl $mctrl_ ([$mctrl_ info class]) send $which [$node_ id] $dst $group"		$mctrl_ send $which [$node_ id] $dst $group	}}################ HelpersBST instproc dbg arg {	$self instvar ns_ node_	puts [format "At %.4f : node [$node_ id] $arg" [$ns_ now]]}					# designate-ump-router# Designates a router on a LAN in order to avoid transmission of# duplicate and redundant messages.  The node with the highest ID is# chosen as the designated router.LanNode instproc designate-ump-router {group dst} {	$self instvar nodelist_	$self instvar up_	set nbr [$self rpf-nbr $dst]	set up_($group) $nbr	return}# Returns the next hop router to a nodeBST instproc next-hop-router {node group} {	BST instvar RP_	set nbr [$node rpf-nbr $RP_($group)]	if [$nbr is-lan?] {		set nbr [$nbr rpf-nbr $RP_($group)]	}	return $nbr}# Checks if an mcast group is BST BST instproc is-group-bidir? {group} {	BST instvar RP_	foreach grp [array names RP_] {		if {$grp == $group} {			return 1		}	}	return 0}# Finds out which Connector or Vlink corresponds to (link)BST instproc match-oif {group link} {	$self instvar oiflist_ 	set oiflist $oiflist_($group)  	if {$oiflist != ""} {		foreach oif $oiflist {			set oiflink [$oif set link_]			if {$oiflink == $link} {				return $oiflink			}		}  	}	return}# Finds the outgoing link to the next node (dst)BST instproc find-oif {dst group} {	$self instvar node_ ns_	if {$node_ != $dst} {		set ns [$self set ns_]		$ns instvar link_		set link [$ns set link_([$node_ id]:[$dst id])]		# Now find which Connector or VLink corresponds to this link		return [$self match-oif $group $link]	} else {		return ""	}}# Finds if the interface (iface) is toward the LAN represented by (neighbor) # or not.BST instproc link2lan? {neighbor iface} {	$self instvar node_ ns_	set link1 [[[$node_ iif2oif $iface] set link_] set iif_]	set link2 [[$ns_ link $node_ $neighbor] set iif_]    	if {$link1 == $link2} {		return 1	} else {		return 0	}}####################Class Classifier/Multicast/Replicator/BST -superclass Classifier/Multicast/BST## This method called when a new multicast group/source pair# is seen by the underlying classifier/mcast object.# We install a hash for the pair mapping it to a slot# number in the classifier table and point the slot# at a replicator object that sends each packet along# the RPF tree.#Classifier/Multicast/BST instproc new-group { src group iface code} {	$self instvar node_	$node_ new-group $src $group $iface $code}Classifier/Multicast/BST instproc no-slot slot {	# NOTHING}Classifier/Multicast/Replicator/BST instproc init args {	$self next	$self instvar nrep_	set nrep_ 0}Classifier/Multicast/Replicator/BST instproc add-rep { rep src group iif } {	$self instvar nrep_	$self set-hash $src $group $nrep_ $iif	$self install $nrep_ $rep	incr nrep_}##################### match-BST-iif# Performs the RPF Classifier/Multicast/Replicator/BST instproc match-BST-iif {iface group} {	$self instvar node_	list retval_	set agents [$node_ set agents_]	for {set i 0} {$i < [llength $agents]} {incr i} {		# Check if you can find a BST agent		set agent [lindex $agents $i]		$agent instvar proto_		if [info exists proto_] {			set protocol [$agent set proto_]			if {[$protocol info class] == "BST"} {				# See if the group is a BST group				BST instvar RP_				$protocol instvar oiflist_				set bidir [$protocol is-group-bidir? $group]				if {$bidir == 1} {					if {$node_ == $RP_($group)} {						return 1					}					# Find the incoming interface					# from RP.					set iif [$node_ from-node-iface \						     $RP_($group)]					if {$iif == $iface} {						return 1					} else {						return 0					}				}			}		}	}	return -1}# Classifier/Multicast/Replicator upstream-link# Finds the link from the next hop upstream router to the current# node.  This function is called from C++ to provide the classifier# with appropriate information to set the UMP option.Classifier/Multicast/Replicator/BST instproc upstream-link {group} {	$self instvar node_	list retval_	set agents [$node_ set agents_]	for {set i 0} {$i < [llength $agents]} {incr i} {		# Check if you can find a BST agent		set agent [lindex $agents $i]		$agent instvar proto_		if [info exists proto_] {			set protocol [$agent set proto_]			if {[$protocol info class] == "BST"} {				# See if the group is a BST group				BST instvar RP_				$protocol instvar oiflist_				set bidir [$protocol is-group-bidir? $group]				if {$bidir == 1} {					# Get the next node, REAL or VIRTUAL!					set nbr [$node_ rpf-nbr $RP_($group)]					# Find the outgoing link to the next					# node 					set oif [$protocol find-oif $nbr \						     $group]					if {$oif == ""} {						set oif "self"					} 					lappend retval_ $oif					# Now attach the next node's ID					# If the neighbor is a virtual					# name, we need to find the					# designated router on the					# LAN. Currently, the					# designated router is the one					# which is the closest to the RP.					if [$nbr is-lan?] {					    set nbr [$nbr rpf-nbr $RP_($group)]					}					lappend retval_ [$nbr id]					return $retval_				}			}		}	}# 	$self dbg "There is no agent for this node!"	return {}}# check-rpf-link # Finds out the RPF link for a nodeClassifier/Multicast/Replicator/BST instproc check-rpf-link {node group} {	$self instvar node_	set agents [$node_ set agents_]	for {set i 0} {$i < [llength $agents]} {incr i} {		# Check if you can find a BST agent		set agent [lindex $agents $i]		$agent instvar proto_		if [info exists proto_] {			set protocol [$agent set proto_]			set classInfo [$protocol info class]			if {$classInfo == "BST"} {				# See if the group is a BST group				BST instvar RP_				set rpfiif [$node_ from-node-iface \						$RP_($group)]				return $rpfiif			}		}	}	return -1}

⌨️ 快捷键说明

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