?? ns-lib.tcl
字號(hào):
return [list $s_agent $d_agent]} # Creates connection. First creates a source agent of type s_type and binds# it to source. Next creates a destination agent of type d_type and binds# it to dest. Finally creates bindings for the source and destination agents,# connects them, and returns the source agent. # The destination agent is set to listen, for full-tcp.Simulator instproc create-connection-listen {s_type source d_type dest pktClass} { set s_agent [new Agent/$s_type] set d_agent [new Agent/$d_type] $s_agent set fid_ $pktClass $d_agent set fid_ $pktClass $self attach-agent $source $s_agent $self attach-agent $dest $d_agent $self connect $s_agent $d_agent $d_agent listen return $s_agent } # This seems to be an obsolete procedure.Simulator instproc create-tcp-connection {s_type source d_type dest pktClass} { set s_agent [new Agent/$s_type] set d_agent [new Agent/$d_type] $s_agent set fid_ $pktClass $d_agent set fid_ $pktClass $self attach-agent $source $s_agent $self attach-agent $dest $d_agent return "$s_agent $d_agent"}## Other classifier methods overload the instproc-likes to track # and return the installed objects.#Classifier instproc install {slot val} { $self set slots_($slot) $val $self cmd install $slot $val}Classifier instproc installNext val { set slot [$self cmd installNext $val] $self set slots_($slot) $val set slot}Classifier instproc adjacents {} { $self array get slots_}Classifier instproc in-slot? slot { $self instvar slots_ set ret "" if {[info exists slots_($slot)]} { set ret $slots_($slot) } set ret}# For debuggingClassifier instproc dump {} { $self instvar slots_ offset_ shift_ mask_ puts "classifier $self" puts "\t$offset_ offset" puts "\t$shift_ shift" puts "\t$mask_ mask" puts "\t[array size slots_] slots" foreach i [lsort -integer [array names slots_]] { set iv $slots_($i) puts "\t\tslot $i: $iv ([$iv info class])" }}Classifier instproc no-slot slot { puts stderr "--- Classfier::no-slot{} default handler (tcl/lib/ns-lib.tcl) ---" puts stderr "\t$self: no target for slot $slot" puts stderr "\t$self type: [$self info class]" puts stderr "content dump:" $self dump puts stderr "---------- Finished standard no-slot{} default handler ----------" # Clear output before we bail out [Simulator instance] flush-trace exit 1}Classifier/Hash instproc dump args { eval $self next $args $self instvar default_ puts "\t$default_ default"}Classifier/Hash instproc init nbuck { # We need to make sure that port shift/mask values are there # so we set them after they get their default values $self next $nbuck $self instvar shift_ mask_ set shift_ [AddrParams NodeShift 1] set mask_ [AddrParams NodeMask 1]}Classifier/Port/Reserve instproc init args { eval $self next $self reserve-port 2}Simulator instproc makeflowmon { cltype { clslots 29 } } { set flowmon [new QueueMonitor/ED/Flowmon] set cl [new Classifier/Hash/$cltype $clslots] $cl proc unknown-flow { src dst fid } { set fdesc [new QueueMonitor/ED/Flow] set dsamp [new Samples] $fdesc set-delay-samples $dsamp set slot [$self installNext $fdesc] $self set-hash auto $src $dst $fid $slot } $cl proc no-slot slotnum { # # note: we can wind up here when a packet passes # through either an Out or a Drop Snoop Queue for # a queue that the flow doesn't belong to anymore. # Since there is no longer hash state in the # hash classifier, we get a -1 return value for the # hash classifier's classify() function, and there # is no node at slot_[-1]. What to do about this? # Well, we are talking about flows that have already # been moved and so should rightly have their stats # zero'd anyhow, so for now just ignore this case.. # puts "classifier $self, no-slot for slotnum $slotnum" } $flowmon classifier $cl return $flowmon}# attach a flow monitor to a link# 3rd argument dictates whether early drop support is to be usedSimulator instproc attach-fmon {lnk fm { edrop 0 } } { set isnoop [new SnoopQueue/In] set osnoop [new SnoopQueue/Out] set dsnoop [new SnoopQueue/Drop] $lnk attach-monitors $isnoop $osnoop $dsnoop $fm if { $edrop != 0 } { set edsnoop [new SnoopQueue/EDrop] $edsnoop set-monitor $fm [$lnk queue] early-drop-target $edsnoop $edsnoop target [$self set nullAgent_] } [$lnk queue] drop-target $dsnoop}# Added by Yun WangSimulator instproc maketbtagger { cltype { clslots 29 } } { set tagger [new QueueMonitor/ED/Tagger] set cl [new Classifier/Hash/$cltype $clslots] $cl proc unknown-flow { src dst fid } { set fdesc [new QueueMonitor/ED/Flow/TB] set dsamp [new Samples] $fdesc set-delay-samples $dsamp set slot [$self installNext $fdesc] $self set-hash auto $src $dst $fid $slot } $cl proc set-rate { src dst fid hashbucket rate depth init} { set fdesc [new QueueMonitor/ED/Flow/TB] set dsamp [new Samples] $fdesc set-delay-samples $dsamp $fdesc set target_rate_ $rate $fdesc set bucket_depth_ $depth # Initialize the bucket as full $fdesc set tbucket_ $init set slot [$self installNext $fdesc] $self set-hash $hashbucket $src $dst $fid $slot } $cl proc no-slot slotnum { # # note: we can wind up here when a packet passes # through either an Out or a Drop Snoop Queue for # a queue that the flow doesn't belong to anymore. # Since there is no longer hash state in the # hash classifier, we get a -1 return value for the # hash classifier's classify() function, and there # is no node at slot_[-1]. What to do about this? # Well, we are talking about flows that have already # been moved and so should rightly have their stats # zero'd anyhow, so for now just ignore this case.. # puts "classifier $self, no-slot for slotnum $slotnum" } $tagger classifier $cl return $tagger}# Added by Yun WangSimulator instproc maketswtagger { cltype { clslots 29 } } { set tagger [new QueueMonitor/ED/Tagger] set cl [new Classifier/Hash/$cltype $clslots] $cl proc unknown-flow { src dst fid hashbucket } { set fdesc [new QueueMonitor/ED/Flow/TSW] set dsamp [new Samples] $fdesc set-delay-samples $dsamp set slot [$self installNext $fdesc] $self set-hash $hashbucket $src $dst $fid $slot } $cl proc no-slot slotnum { # # note: we can wind up here when a packet passes # through either an Out or a Drop Snoop Queue for # a queue that the flow doesn't belong to anymore. # Since there is no longer hash state in the # hash classifier, we get a -1 return value for the # hash classifier's classify() function, and there # is no node at slot_[-1]. What to do about this? # Well, we are talking about flows that have already # been moved and so should rightly have their stats # zero'd anyhow, so for now just ignore this case.. # puts "classifier $self, no-slot for slotnum $slotnum" } $tagger classifier $cl return $tagger}# attach a Tagger to a link# Added by Yun WangSimulator instproc attach-tagger {lnk fm} { set isnoop [new SnoopQueue/Tagger] $lnk attach-taggers $isnoop $fm}# Imported from session.tcl. It is deleted there.### to insert loss module to regular links in detailed SimulatorSimulator instproc lossmodel {lossobj from to} { set link [$self link $from $to] $link errormodule $lossobj}# This function generates losses that can be visualized by nam.Simulator instproc link-lossmodel {lossobj from to} { set link [$self link $from $to] $link insert-linkloss $lossobj}#### Polly Huang: Simulator class instproc to support abstract tcp simulationsSimulator instproc rtt { src dst } { $self instvar routingTable_ delay_ set srcid [[$src set node_] id] set dstid [[$dst set node_] id] set delay 0 set tmpid $srcid while {$tmpid != $dstid} { set nextid [$routingTable_ lookup $tmpid $dstid] set tmpnode [$self get-node-by-id $tmpid] set nextnode [$self get-node-by-id $nextid] set tmplink [[$self link $tmpnode $nextnode] link] set delay [expr $delay + [expr 2 * [$tmplink set delay_]]] set delay [expr $delay + [expr 8320 / [$tmplink set bandwidth_]]] set tmpid $nextid } $src rtt $delay return $delay}Simulator instproc abstract-tcp {} { $self instvar TahoeAckfsm_ RenoAckfsm_ TahoeDelAckfsm_ RenoDelAckfsm_ dropper_ $self set TahoeAckfsm_ [new FSM/TahoeAck] $self set RenoAckfsm_ [new FSM/RenoAck] $self set TahoeDelAckfsm_ [new FSM/TahoeDelAck] $self set RenoDelAckfsm_ [new FSM/RenoDelAck] $self set nullAgent_ [new DropTargetAgent]}# Chalermek: For Diffusion, Flooding, and Omnicient Multicast Simulator instproc create-diffusion-rate-agent {node} { global opt set diff [new Agent/Diffusion/RateGradient] $node set diffagent_ $diff $node set ragent_ $diff $diff on-node $node if [info exist opt(enablePos)] { if {$opt(enablePos) == "true"} { $diff enable-pos } else { $diff disable-pos } } if [info exist opt(enableNeg)] { if {$opt(enableNeg) == "true"} { $diff enable-neg } else { $diff disable-neg } } if [info exist opt(suppression)] { if {$opt(suppression) == "true"} { $diff enable-suppression } else { $diff disable-suppression } } if [info exist opt(subTxType)] { $diff set-sub-tx-type $opt(subTxType) } if [info exist opt(orgTxType)] { $diff set-org-tx-type $opt(orgTxType) } if [info exist opt(posType)] { $diff set-pos-type $opt(posType) } if [info exist opt(posNodeType)] { $diff set-pos-node-type $opt(posNodeType) } if [info exist opt(negWinType)] { $diff set-neg-win-type $opt(negWinType) } if [info exist opt(negThrType)] { $diff set-neg-thr-type $opt(negThrType) } if [info exist opt(negMaxType)] { $diff set-neg-max-type $opt(negMaxType) } $self put-in-list $diff $self at 0.0 "$diff start" return $diff}Simulator instproc create-diffusion-probability-agent {node} { global opt set diff [new Agent/Diffusion/ProbGradient] $node set diffagent_ $diff $node set ragent_ $diff $diff on-node $node if [info exist opt(enablePos)] { if {$opt(enablePos) == "true"} { $diff enable-pos } else { $diff disable-pos } } if [info exist opt(enableNeg)] { if {$opt(enableNeg) == "true"} { $diff enable-neg } else { $diff disable-neg } } $self put-in-list $diff $self at 0.0 "$diff start" return $diff}# Diffusioncore agent (in diffusion) maps to the wireless routing agent# in nsSimulator instproc create-core-diffusion-rtg-agent {node} { $self instvar stopTime_ diffFilter_ Node instvar ragent_ dmux_ set ragent [new Agent/DiffusionRouting [$node id]] $node set ragent_ $ragent # at stop-time core-diffusion dumps stats data # see diffusion.cc for details if { [info exists stopTime_] } { $ragent stop-time $stopTime_ } if { ![info exists diffFilter_] } { puts stderr "Error: No filter defined for diffusion!\n" exit 1 } $node create-diffusionApp-agent $diffFilter_ return $ragent}Simulator instproc create-flooding-agent {node} { set flood [new Agent/Flooding] $node set ragent_ $flood $flood on-node $node $self put-in-list $flood $self at 0.0 "$flood start" return $flood}Simulator instproc create-omnimcast-agent {node} { set omni [new Agent/OmniMcast] $node set ragent_ $omni $omni on-node $node $self put-in-list $omni $self at 0.0 "$omni start" return $omni}# XXX These are very simulation-specific methods, why should they belong here?Simulator instproc put-in-list {agent} { $self instvar lagent lappend lagent $agent}Simulator instproc terminate-all-agents {} { $self instvar lagent foreach i $lagent { $i terminate }}Simulator instproc prepare-to-stop {} { $self instvar lagent foreach i $lagent { $i stop }}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -