📄 ns-uenode.tcl
字号:
$self addif $netif}#----------------------------------------------------------------------# XXX Following are the last remnant of nodetype_. Need to be completely# removed, however, we need a better mechanism to distinguish vanilla# mobile node from MIP base station, and MIP mobile host.Node/MobileNode/UE instproc makemip-NewMobile {} {}Node/MobileNode/UE instproc makemip-NewBase {} {}Node/MobileNode/UE instproc makemip-NewNodeB {} {}Node/MobileNode/UE instproc makemip-NewUE {} {}Node/MobileNode/UE instproc makemip-New {} {}Node/MobileNode/UE instproc makemip-NewMIPBS {} { $self instvar regagent_ encap_ decap_ agents_ id_ set dmux [new Classifier/Port/Reserve] $dmux set mask_ 0x7fffffff $dmux set shift_ 0 $self install-demux $dmux set regagent_ [new Agent/MIPBS $self] $self attach $regagent_ [Node/MobileNode set REGAGENT_PORT] $self attach-encap $self attach-decap}Node/MobileNode/UE instproc attach-encap {} { $self instvar encap_ set encap_ [new MIPEncapsulator] $encap_ set mask_ [AddrParams NodeMask 1] $encap_ set shift_ [AddrParams NodeShift 1] #set mask 0x7fffffff #set shift 0 set nodeaddr [AddrParams addr2id [$self node-addr]] $encap_ set addr_ [expr ( ~([AddrParams NodeMask 1] << \ [AddrParams NodeShift 1]) & $nodeaddr )] $encap_ set port_ 1 $encap_ target [$self entry] $encap_ set node_ $self}Node/MobileNode/UE instproc attach-decap {} { $self instvar decap_ dmux_ agents_ set decap_ [new Classifier/Addr/MIPDecapsulator] lappend agents_ $decap_ $decap_ set mask_ [AddrParams NodeMask 1] $decap_ set shift_ [AddrParams NodeShift 1] $dmux_ install [Node/MobileNode set DECAP_PORT] $decap_}Node/MobileNode/UE instproc makemip-NewMIPMH {} { $self instvar regagent_ set dmux [new Classifier/Port/Reserve] $dmux set mask_ 0x7fffffff $dmux set shift_ 0 $self install-demux $dmux set regagent_ [new Agent/MIPMH $self] $self attach $regagent_ [Node/MobileNode set REGAGENT_PORT] $regagent_ set mask_ [AddrParams NodeMask 1] $regagent_ set shift_ [AddrParams NodeShift 1] $regagent_ set dst_addr_ [expr (~0) << [AddrParams NodeShift 1]] $regagent_ set dst_port_ 0 $regagent_ node $self}#----------------------------------------------------------------------## Attach an agent to a node. Pick a port and# bind the agent to the port number.# if portnumber is 255, default target is set to the routing agent#Node/MobileNode/UE instproc add-target { agent port } { $self instvar dmux_ imep_ toraDebug_ set ns [Simulator instance] set newapi [$ns imep-support] $agent set sport_ $port # special processing for TORA/IMEP node set toraonly [string first "TORA" [$agent info class]] if {$toraonly != -1 } { $agent if-queue [$self set ifq_(0)] ;# ifq between LL and MAC # # XXX: The routing protocol and the IMEP agents needs handles # to each other. # $agent imep-agent [$self set imep_(0)] [$self set imep_(0)] rtagent $agent } # Special processing for AODV set aodvonly [string first "AODV" [$agent info class]] if {$aodvonly != -1 } { $agent if-queue [$self set ifq_(0)] ;# ifq between LL and MAC } if { $port == [Node set rtagent_port_] } { # Ad hoc routing agent setup needs special handling $self add-target-rtagent $agent $port return } # Attaching a normal agent set namfp [$ns get-nam-traceall] if { [Simulator set AgentTrace_] == "ON" } { # # Send Target # if {$newapi != ""} { set sndT [$self mobility-trace Send "AGT"] } else { set sndT [cmu-trace Send AGT $self] } if { $namfp != "" } { $sndT namattach $namfp } $sndT target [$self entry] $agent target $sndT # # Recv Target # if {$newapi != ""} { set rcvT [$self mobility-trace Recv "AGT"] } else { set rcvT [cmu-trace Recv AGT $self] } if { $namfp != "" } { $rcvT namattach $namfp } $rcvT target $agent $dmux_ install $port $rcvT } else { # # Send Target # $agent target [$self entry] # # Recv Target # $dmux_ install $port $agent }}Node/MobileNode/UE instproc add-target-rtagent { agent port } { $self instvar imep_ toraDebug_ set ns [Simulator instance] set newapi [$ns imep-support] set namfp [$ns get-nam-traceall] set dmux_ [$self demux] set classifier_ [$self entry] if { [Simulator set RouterTrace_] == "ON" } { # # Send Target # if {$newapi != ""} { set sndT [$self mobility-trace Send "RTR"] } else { set sndT [cmu-trace Send "RTR" $self] } if { $namfp != "" } { $sndT namattach $namfp } if { $newapi == "ON" } { $agent target $imep_(0) $imep_(0) sendtarget $sndT # second tracer to see the actual # types of tora packets before imep packs them if { [info exists toraDebug_] && $toraDebug_ == "ON"} { set sndT2 [$self mobility-trace Send "TRP"] $sndT2 target $imep_(0) $agent target $sndT2 } } else { ;# no IMEP $agent target $sndT } $sndT target [$self set ll_(0)] # # Recv Target # if {$newapi != ""} { set rcvT [$self mobility-trace Recv "RTR"] } else { set rcvT [cmu-trace Recv "RTR" $self] } if { $namfp != "" } { $rcvT namattach $namfp } if {$newapi == "ON" } { [$self set ll_(0)] up-target $imep_(0) $classifier_ defaulttarget $agent # need a second tracer to see the actual # types of tora packets after imep unpacks them # no need to support any hier node if {[info exists toraDebug_] && $toraDebug_ == "ON" } { set rcvT2 [$self mobility-trace Recv "TRP"] $rcvT2 target $agent $classifier_ defaulttarget $rcvT2 } } else { $rcvT target $agent $classifier_ defaulttarget $rcvT $dmux_ install $port $rcvT } } else { # # Send Target # # if tora is used if { $newapi == "ON" } { $agent target $imep_(0) # second tracer to see the actual # types of tora packets before imep packs them if { [info exists toraDebug_] && $toraDebug_ == "ON"} { set sndT2 [$self mobility-trace Send "TRP"] $sndT2 target $imep_(0) $agent target $sndT2 } $imep_(0) sendtarget [$self set ll_(0)] } else { ;# no IMEP $agent target [$self set ll_(0)] } # # Recv Target # if {$newapi == "ON" } { [$self set ll_(0)] up-target $imep_(0) $classifier_ defaulttarget $agent # need a second tracer to see the actual # types of tora packets after imep unpacks them # no need to support any hier node if {[info exists toraDebug_] && $toraDebug_ == "ON" } { set rcvT2 [$self mobility-trace Recv "TRP"] $rcvT2 target $agent [$self set classifier_] defaulttarget $rcvT2 } } else { $classifier_ defaulttarget $agent $dmux_ install $port $agent } }}# set transmission powerNode/MobileNode/UE instproc setPt { val } { $self instvar netif_ $netif_(0) setTxPower $val}# set receiving powerNode/MobileNode/UE instproc setPr { val } { $self instvar netif_ $netif_(0) setRxPower $val}# set idle power -- ChalermekNode/MobileNode/UE instproc setPidle { val } { $self instvar netif_ $netif_(0) setIdlePower $val}Node/MobileNode/UE 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/UE 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/UE 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/UE instproc mip-call {ragent} { $self instvar regagent_ if [info exists regagent_] { $regagent_ ragent $ragent }}Node/MobileNode/UE 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/UE instproc unset-gafpartner {} { $self instvar gafpartner_ $gafpartner_ set-gafagent 0}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -