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

📄 monitoring.tcl

📁 跑leach需要的
💻 TCL
📖 第 1 页 / 共 2 页
字号:
			} else {			    $self vprint 2 "$flow $pre_drop_rate $oldDropP"  			    if { $pre_drop_rate > $oldDropP } {				set newDropP [expr {3*$oldDropP}]			    } else {				set newDropP [expr {$oldDropP + 2*$pre_drop_rate}]			    }			    			    set newTarget [expr {1 - $newDropP}]			    			    if {$newTarget < 0} {				set newTarget [expr {$oldTarget/3.0}]			    }			    			    $flow set targetBW_ $newTarget			    $self vprint 2 "Monitor: Strangling unresponsive $flow $fid $oldTarget -> $newTarget"			}			#memory			unset oldTarget newTarget newDropP oldDropP		    } else {			if { $pre_drop_rate > 2*$usableDropRate } {			    set newDropP [expr {2*$usableDropRate}]			} else {			    set newDropP $pre_drop_rate			}			set newTarget [expr {1 - $newDropP}]						if { $newTarget < 0.5 } {			    set newTarget 0.5			}						$self vprint 2 "Monitor: Monitoring $flow $fid $newTarget"			$redpdq_ monitor-flow $flow $newTarget 1 						#memory			unset newTarget newDropP		    }		    		    set mon_flow_hist_($fid,lastChange) [$ns_ now]		    set new_hist [list [expr [$flow set barrivals_].0/$elapsed] \				      [expr [$flow set bdrops_].0/[$flow set barrivals_].0]] 		    lappend mon_flow_hist_($fid,hist) $new_hist		    		    if { [llength $mon_flow_hist_($fid,hist)] > $Hist_Max_ } {			$self vprint 2 "Curtailing the history for $flow $fid"			set mon_flow_hist_($fid,hist) [lrange $mon_flow_hist_($fid,hist) 1 end]		    }		    		    $self vprint-nonewline 2 "History of $flow $fid "		    $self printListOfLists 2 $mon_flow_hist_($fid,hist)		    		    #memory		    unset pre_drop_rate new_hist		}	    }	    	    #memory	    unset flow drop_count fid lastChange	}    }        #memory    unset regular_list            $self sched-detect-reward [$self calculateB $avgDropRate]        foreach f [$redpdflowmon_ flows] {	$f reset    }    $redpdflowmon_ reset    $self vprint 3 "do_detect complete..."}## to calculate B, the list compilation interval#REDPDSim instproc calculateB { p } {    $self instvar TargetRTT_    $self instvar Mintime_ Maxtime_    $self instvar MaxHighDRFlowHist_ XinRegular_    $self instvar BList_ Bindex_    $self instvar P_testTFRp_    if {$P_testTFRp_ != -1} {	set p $P_testTFRp_    }    if {$p == 0 } {	return $Maxtime_    }        set sqrt1_5p [expr {sqrt(1.5*$p)}]      set x_by_yR [expr {[$self frac $XinRegular_ $MaxHighDRFlowHist_]*$TargetRTT_}]        #deterministic model computation    set time1 [expr {$x_by_yR / $sqrt1_5p}]        set plusTerm [expr {1 + 9*$p*(1+32*$p*$p)}]        #the newer model    #set time2 [expr {$time1 * $plusTerm}]    #set ns [Simulator instance]    #puts "[$ns now] timeAfter: $p $time1 $time2"        set timeAfter $time1    #    set timeAfter $time2    if { $timeAfter > $Maxtime_ } {	set timeAfter $Maxtime_    }    if { $timeAfter < $Mintime_ } {	set timeAfter $Mintime_    }        set BList_($Bindex_) $timeAfter    incr Bindex_    set Bindex_ [expr {$Bindex_ % $MaxHighDRFlowHist_}]    return $timeAfter}## Gives the total time for last noB intervals.#REDPDSim instproc minLastChange { noB } {    $self instvar BList_ Bindex_    $self instvar minBtoConsider_ minTimetoConsider_    set index [expr {$Bindex_ - 1}]     set sum 0    for {set i 0} {$i < $noB} {incr i} {	if {$index == -1} {	    set index 4	}	set sum [expr {$sum + $BList_($index)}]	incr index -1    }    if {$sum < $minTimetoConsider_} {	return $minTimetoConsider_    } else {	return $sum    }}	REDPDSim instproc do_reward {} {    $self instvar ns_    $self instvar last_reward_ reward_pending_    $self instvar Mintime_    $self instvar redpdflowmon_ redpdq_    $self instvar mon_flow_hist_    $self instvar maxPReduction_ maxPReductionUnresp_        #	$redpdflowmon_ dump    set reward_pending_ false    set now [$ns_ now]    $self vprint 3 "DO_REWARD starting at $now, last: $last_reward_"    set elapsed [expr $now - $last_reward_]    set last_reward_ $now#    if { $elapsed < $Mintime_ } {#	puts "ERROR: do_reward: elapsed: $elapsed, min: $Mintime_"#	exit 1#    }            foreach flow [$self check-irregular] {	set fid [$flow set flowid_]	set lastChange $mon_flow_hist_($fid,lastChange)		set oldTarget [$flow set targetBW_]		if { [$flow set unresponsive_] != 1 && \		 ([$ns_ now] - $lastChange) >= [$self minLastChange 3] } {	    if { $oldTarget >= 0.995 } {		$self vprint 2 "Monitor: Unmonitoring $flow $fid "		$redpdq_ unmonitor-flow $flow		unset mon_flow_hist_($fid,hist)	    } else {		set dropP [expr  {1 - $oldTarget}]		if { $dropP >  2*$maxPReduction_ } {		    set newTarget [expr {1 - ($dropP - $maxPReduction_)}]		} else {		    set newTarget [expr {1 - ($dropP/2.0)}]		} 		$flow set targetBW_ $newTarget		$self vprint 2 "Monitor: Loosening $flow $fid $oldTarget -> $newTarget "	    }	    set mon_flow_hist_($fid,lastChange) [$ns_ now]	 	} elseif  { [$flow set unresponsive_] == 1 && \			([$ns_ now] - $lastChange) >= [$self minLastChange 5] } {	    if { $oldTarget >= 0.9975 } {		$self vprint 2 "Monitor: Unmonitoring unresponsive flow $flow $fid "		$redpdq_ unmonitor-flow $flow		unset mon_flow_hist_($fid,hist)	    } else {		set dropP [expr  {1 - $oldTarget}]	# 		set target1 [expr {1 - ($dropP/1.2)}]# 		set target2 [expr {1.2*$oldTarget}]# 		if { $target1 <= $target2 } {# 		    set newTarget $target1# 		} else {# 		    set newTarget $target2# 		}		if { $dropP > 1.5*$maxPReductionUnresp_ } {		    set newTarget [expr {1 - ($dropP - $maxPReductionUnresp_)}]		} else {		    set newTarget [expr {1 - ($dropP/1.5)}]		}		$flow set targetBW_ $newTarget		$self vprint 2 "Monitor: Loosening unresponsive $flow $fid $oldTarget -> $newTarget"	    }	    set mon_flow_hist_($fid,lastChange) [$ns_ now]	}    }	    $self vprint 3 "do_reward complete..."}REDPDSim instproc check-unresponsive {flow} {	$self instvar mon_flow_hist_ unresponsiveTestOn_	#see if unresponsive test is ON	if { $unresponsiveTestOn_ == 0} {	    return 0	}		set target [$flow set targetBW_] 		# goal is to catch just high-bw unresponsive flows. # 	if { $target > 0.79 } {# 		return 0# 	}		set fid [$flow set flowid_]	set flow_hist [lsort -real -index 1 $mon_flow_hist_($fid,hist)]	$self vprint-nonewline 2 "checking unresponsiveness $flow $fid "	$self printListOfLists 2 $flow_hist	set good 0	set bad 0	foreach histItem1 $flow_hist {		foreach histItem2 $flow_hist {			set bw1 [lindex $histItem1 0] 			set p1  [lindex $histItem1 1]			set bw2 [lindex $histItem2 0]			set p2  [lindex $histItem2 1]			if { $p1 < $p2 && $p1/$p2 > 0.1 } { 				set x [expr {$p1/$p2}]				set y [expr {$bw2/$bw1}]			} else {				# we don't care about too small differences				# and the reverse case will be taken care of anyway				continue			}			set rootx [expr {sqrt($x)}]			# y = rootx ideally.			$self vprint 2 "unresp $histItem1 $histItem2 $x $y $rootx"			if { $y > $rootx } {				incr bad			} elseif  { $y <= $rootx } {				incr good			}		}	}	#memory	unset flow_hist		$self vprint 2 "unresponsive check $flow [$flow set flowid_] $bad $good"	if { ($good == 0 && $bad >= 3) || ($good == 1 && $bad>=4) || ($good >= 2 && $bad >= 4*$good) } {		return 1	}		return 0}REDPDSim instproc testIdent {barrivals bdrops avgDropRate regular_list} {    $self instvar barrT bdrT    $self instvar MaxHighDRFlowHist_    $self instvar counter_    $self instvar redpdflowmon_        set j [expr $counter_ % $MaxHighDRFlowHist_]    foreach f [$redpdflowmon_ flows] {	set fid [$f set flowid_]	set i [expr $fid*$MaxHighDRFlowHist_ + $j]	set barrT($i) [$f set barrivals_];	set bdrT($i) [$f set bdrops_];    }    set barrT($j) $barrivals    set bdrT($j) $bdrops    incr counter_        lappend temp_flow_list    unset temp_flow_list    lappend temp_flow_list    if { $counter_ %  $MaxHighDRFlowHist_ == 0 } {	set count [llength $regular_list]	foreach flow_drop_list $regular_list {	    set flow [lindex $flow_drop_list 0]	    set fid [$flow set flowid_]	    	    set flow_arr 0	    set flow_dr 0	    set cum_arr 0	    set cum_dr 0	    for {set j 0} {$j < $MaxHighDRFlowHist_} {incr j} {		set i [expr $fid*$MaxHighDRFlowHist_ + $j]		incr flow_arr $barrT($i)		incr flow_dr  $bdrT($i)		incr cum_arr $barrT($j)		incr cum_dr $bdrT($j)	    }	    if { $MaxHighDRFlowHist_ != 1 || $flow_dr>=3000 } {		puts "3:5-identified $counter_ $fid $flow_arr $cum_arr $flow_dr $cum_dr"		lappend temp_flow_list $flow		puts "1:1-3-identified $counter_ $fid $flow_arr $cum_arr $flow_dr $cum_dr"			    }	    if { $flow_dr >= 4000 } {		puts "1:1-4-identified $counter_ $fid $flow_arr $cum_arr $flow_dr $cum_dr"	    } else {		puts "1:1-4-nodentified $counter_ $fid $flow_arr $cum_arr $flow_dr $cum_dr"	    }	}	foreach flow [$redpdflowmon_ flows] {	    if { [lsearch $temp_flow_list $flow] == -1} {		set fid [$flow set flowid_] 		set flow_arr 0		set flow_dr 0		set cum_arr 0		set cum_dr 0		for {set j 0} {$j < $MaxHighDRFlowHist_} {incr j} {		    set i [expr $fid*$MaxHighDRFlowHist_ + $j]		    incr flow_arr $barrT($i)		    incr flow_dr  $bdrT($i)		    incr cum_arr $barrT($j)		    incr cum_dr $bdrT($j)		}		puts "3:5-nodentified $counter_ $fid $flow_arr $cum_arr $flow_dr $cum_dr"		if { $flow_dr >= 3000 } {		    puts "1:1-3-identified $counter_ $fid $flow_arr $cum_arr $flow_dr $cum_dr"		} else {		    puts "1:1-3-nodentified $counter_ $fid $flow_arr $cum_arr $flow_dr $cum_dr"		}		if { $flow_dr >= 4000 } {		    puts "1:1-4-identified $counter_ $fid $flow_arr $cum_arr $flow_dr $cum_dr"		} else {		    puts "1:1-4-nodentified $counter_ $fid $flow_arr $cum_arr $flow_dr $cum_dr"		}	    }	}    }    if { $MaxHighDRFlowHist_ == 1 } {		$self sched-detect-reward [expr 5*[$self calculateB $avgDropRate]]    } else {    	$self sched-detect-reward [$self calculateB $avgDropRate]    }#    $self sched-detect 0.200    foreach f [$redpdflowmon_ flows] {	$f reset    }    $redpdflowmon_ reset        return}

⌨️ 快捷键说明

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