📄 ns-queue.tcl
字号:
QueueMonitor instproc reset {} { $self instvar size_ pkts_ $self instvar parrivals_ barrivals_ $self instvar pdepartures_ bdepartures_ $self instvar pdrops_ bdrops_ # don't reset size_ and pkts_ here # because they are not cumulative measurements # the way the following values are set parrivals_ 0 set barrivals_ 0 set pdepartures_ 0 set bdepartures_ 0 set pdrops_ 0 set bdrops_ 0 set bint [$self get-bytes-integrator] if { $bint != "" } { $bint reset } set pint [$self get-pkts-integrator] if { $pint != "" } { $pint reset } set samp [$self get-delay-samples] if { $samp != "" } { $samp reset }}QueueMonitor/ED instproc reset {} { $self next $self instvar epdrops_ ebdrops_ mon_epdrops_ mon_ebdrops_ set epdrops_ 0 set ebdrops_ 0 set mon_epdrops_ 0 set mon_ebdrops_ 0}Class AckReconsClass -superclass AgentAckReconsControllerClass instproc demux { src dst } { $self instvar reconslist_ queue_ set addr $src:$dst if { ![info exists reconslist_($addr)] } { set recons [new Agent/AckReconsClass $src $dst] $recons target $queue_ set reconslist_($addr) $recons } # return an ack reconstructor object return $reconslist_($addr)}# Calculate number and spacing of acks to be sent# deltaAckThresh_ = threshold after which reconstructor kicks in# ackInterArr_ = estimate of arrival rate of acks ("counting process")# ackSpacing_ = duration in time between acks sent by reconstructor# delack_ = generate an ack at least every delack_ acks at reconstructorAgent/AckReconsClass instproc spacing { ack } { $self instvar ackInterArr_ ackSpacing_ delack_ \ lastAck_ lastRealAck_ lastRealTime_ adaptive_ size_ global ns set deltaTime [expr [$ns now] - $lastRealTime_] set deltaAck [expr $ack - $lastAck_] if {$adaptive_} { set bw [expr $deltaAck*$size_/$deltaTime] set ackSpacing_ $ackInterArr_ if { $deltaAck > 0 } {# set ackSpacing_ [expr $ackInterArr_*$delack_/$deltaAck] } } else { set deltaT [expr $deltaTime / ($deltaAck/$delack_ +1)] set ackSpacing_ $deltaT }}# Estimate rate at which acks are arrivingAgent/AckReconsClass instproc ackbw {ack time} { $self instvar ackInterArr_ lastRealTime_ lastRealAck_ alpha_ set sample [expr $time - $lastRealTime_] # EWMA set ackInterArr_ [expr $alpha_*$sample + (1-$alpha_)*$ackInterArr_]}Class Classifier/Hash/Fid/FQ -superclass Classifier/Hash/FidClassifier/Hash/Fid/FQ instproc unknown-flow { src dst fid } { $self instvar fq_ $fq_ new-flow $src $dst $fid}Class FQLink -superclass SimpleLinkFQLink instproc init { src dst bw delay q } { $self next $src $dst $bw $delay $q $self instvar link_ queue_ head_ toNode_ ttl_ classifier_ \ nactive_ $self instvar drophead_ ;# idea stolen from CBQ and Kevin set nactive_ 0 set classifier_ [new Classifier/Hash/Fid/FQ 33] $classifier_ set fq_ $self #$self add-to-head $classifier_ $head_ target $classifier_ # XXX # put the ttl checker after the delay # so we don't have to worry about accounting # for ttl-drops within the trace and/or monitor # fabric # $queue_ set secsPerByte_ [expr 8.0 / [$link_ set bandwidth_]]}FQLink instproc new-flow { src dst fid } { $self instvar classifier_ nactive_ queue_ link_ drpT_ incr nactive_ set type [$class set queueManagement_] set q [new Queue/$type] #XXX yuck if { $type == "RED" } { set bw [$link_ set bandwidth_] $q set ptc_ [expr $bw / (8. * [$q set mean_pktsize_])] } $q drop-target $drpT_ set slot [$classifier_ installNext $q] $classifier_ set-hash auto $src $dst $fid $slot $q target $queue_ $queue_ install $fid $q}#XXX ask Kannan why this isn't in otcl base class.FQLink instproc up? { } { return up}##Added by ratul for RedPDQueue#Queue/RED/PD instproc makeflowmon { link {cltype "SrcDestFid"} {cslots 29}} { set flowmon [new QueueMonitor/ED/Flowmon] set cl [new Classifier/Hash/$cltype $cslots] $cl proc unknown-flow { src dst fid } { set nflow [new QueueMonitor/ED/Flow/RedPD] set slot [$self installNext $nflow] # puts "New Flow : $nflow at slot $slot" $self set-hash auto $src $dst $fid $slot # puts "Installed It\n"; } $cl proc no-slot slotnum { puts stderr "classifier $self, no-slot for slotnum $slotnum" } $flowmon classifier $cl $self attach-flowmon $flowmon set isnoop [new SnoopQueue/In] set osnoop [new SnoopQueue/Out] set dsnoop [new SnoopQueue/Drop] set edsnoop [new SnoopQueue/EDrop] $link attach-monitors $isnoop $osnoop $dsnoop $flowmon $edsnoop set-monitor $flowmon $self early-drop-target $edsnoop set ns [Simulator instance] $edsnoop target [$ns set nullAgent_] # $edsnoop target [$dsnoop target] # $edsnoop drop-target [$dsnoop drop-target] $self drop-target $dsnoop return $flowmon} ############################################################## Stuff below has been added to enable queue specific tracing##Blame me if anything is broken below - ratul############################################################ attach-nam-traces: Only conventional trace objects are understood by nam currently. # do not attach fancy trace objects here. nam will crash in this case.#Queue instproc attach-nam-traces {src dst file} { #valid only if the default trace type in attach-traces is Drop, Enque, Deque. #see comment above. #this function should be different for different queue when needed. $self attach-traces $src $dst $file "nam"}## Dummy function for all the queues that don't implement attach-traces#Queue instproc attach-traces {src dst file {op ""}} { #Do nothing here}## Added to be able to trace the edrop events #Queue/RED instproc attach-traces {src dst file {op ""}} { set ns [Simulator instance] set type [$self trace-type] #nam does not understand anything else yet. if {$op == "nam"} { set type "Drop" } #puts "In attach-trace: $type" set newtrace [$ns create-trace $type $file $src $dst $op] set oldTrace [$self edrop-trace] # puts "oldTrace - $oldTrace" if {$oldTrace!=0} { # puts "exists" $newtrace target $oldTrace } else { # puts "Does not exist" $newtrace target [$ns set nullAgent_] } $self edrop-trace $newtrace}## Added to be able to trace the mon_edrop and edrop events#Queue/RED/PD instproc attach-traces {src dst file {op ""}} { $self next $src $dst $file $op set ns [Simulator instance] set type [$self mon-trace-type] #nam does not understand anything else yet if {$op == "nam"} { set type "Drop" } set medtrace [$ns create-trace $type $file $src $dst $op] set oldTrace [$self mon-edrop-trace] if {$oldTrace!=0} { puts "exists" $medtrace target $oldTrace } else { # puts "Does not exist" $medtrace target [$ns set nullAgent_] } $self mon-edrop-trace $medtrace }Delayer instproc init {} { $self next}Simulator instproc insert-delayer {src dst delayer} { set link [$self link $src $dst] $link insert-delayer $delayer}SimpleLink instproc insert-delayer args { $self instvar delayer_ queue_ if {[info exists delayer_]} { puts stderr "Delayer already inserted" } else { set delayer_ [lindex $args 0] $delayer_ target [$queue_ target] $queue_ target $delayer_ }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -