📄 hgps.tcl
字号:
# hgps.tcl# ======================================================================# Default Script Options# ======================================================================set opt(rt_port) 255set opt(cc) "off" ;# have god check the caches for bad links?Agent/HGPSAgent set sport_ 255Agent/HGPSAgent set dport_ 255Agent/HGPSAgent set update_distance_ $opt(ud)# ======================================================================Class SRNode -superclass MobileNodeSRNode instproc init {args} { global opt ns_ tracefd RouterTrace $self instvar hgps_agent_ dmux_ entry_point_ eval $self next $args ;# parent class constructor # puts "making dsragent for node [$self id]" set hgps_agent_ [new Agent/HGPSAgent] $hgps_agent_ ip-addr [$self id] $hgps_agent_ mobile-node $self if { $RouterTrace == "ON" } { # Recv Target set rcvT [cmu-trace Recv "RTR" $self] $rcvT target $hgps_agent_ set entry_point_ $rcvT } else { # Recv Target set entry_point_ $hgps_agent_ } # # Drop Target (always on regardless of other tracing) # set drpT [cmu-trace Drop "RTR" $self] $hgps_agent_ drop-target $drpT # # Log Target # set T [new Trace/Generic] $T target [$ns_ set nullAgent_] $T attach $tracefd $T set src_ [$self id] $hgps_agent_ log-target $T $hgps_agent_ target $dmux_ # packets to the HGPS port should be dropped, since we've # already handled them in the DSRAgent at the entry. set nullAgent_ [$ns_ set nullAgent_] $dmux_ install $opt(rt_port) $nullAgent_ # SRNodes don't use the IP addr classifier. The HGPSAgent should # be the entry point $self instvar classifier_ set classifier_ "srnode made illegal use of classifier_"}SRNode instproc start-hgps {} { $self instvar hgps_agent_ global opt $hgps_agent_ start-hgps}SRNode instproc entry {} { $self instvar entry_point_ return $entry_point_}SRNode instproc add-interface {args} {# args are expected to be of the form# $chan $prop $tracefd $opt(ll) $opt(mac) global ns_ opt RouterTrace eval $self next $args $self instvar hgps_agent_ ll_ mac_ ifq_#$hgps_agent_ mac-addr [$mac_(0) id] if { $RouterTrace == "ON" } { # Send Target set sndT [cmu-trace Send "RTR" $self] $sndT target $ll_(0) $hgps_agent_ add-ll $sndT $ifq_(0) } else { # Send Target $hgps_agent_ add-ll $ll_(0) $ifq_(0) } $hgps_agent_ add-real-ll $ll_(0) }SRNode instproc wakeup {waketime} { $self instvar hgps_agent_ $hgps_agent_ wakeup $waketime}SRNode instproc test-query {dst} { $self instvar hgps_agent_ $hgps_agent_ test-query $dst}SRNode instproc reset args { $self instvar hgps_agent_ eval $self next $args $hgps_agent_ reset}# ======================================================================proc create-mobile-node { id } { global ns_ chan prop topo tracefd opt node_ global chan prop tracefd topo opt set node_($id) [new SRNode] set node $node_($id) $node random-motion 0 ;# disable random motion $node topography $topo # connect up the channel $node add-interface $chan $prop $opt(ll) $opt(mac) \ $opt(ifq) $opt(ifqlen) $opt(netif) $opt(ant) # # This Trace Target is used to log changes in direction # and velocity for the mobile node and log actions of the DSR agent # set T [new Trace/Generic] $T target [$ns_ set nullAgent_] $T attach $tracefd $T set src_ $id $node log-target $T $ns_ at 0.0 "$node start-hgps"}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -