class Scriptroute::Tulip::QueuingDoctor
Public Class Methods
new(hopDetails)
click to toggle source
# File lib/scriptroute/tulip/queuing.rb, line 192 def initialize (hopDetails) @total = Hash.new(0); @ratelimited = Hash.new(0) @stamps = Hash.new(); hopDetails.each_index { |i| @stamps[i] = Array.new() if (hopDetails[i]);} @ejected = Hash.new(); ##todo: implement the correlation thingy @pairs = Hash.new(); (0..$count-1).each { |num| startTime = Time.now; hopDetails.each_index { |i| next if (!hopDetails[i] or @ejected.has_key?(i)); details = hopDetails[i]; #(dst, types, ttl) #puts "before train = %.3f" % [Time.now.to_f*1000]; train = QueueTrain.new(details[0], details[2], details[1]); #puts "after train = %.3f" % [Time.now.to_f*1000]; puts "#{train}\n" if ($verbose>=10); @total[i] += 1; if (train.isLossy?) then @ratelimited[i] += 1; @ejected[i] = 1 if (@ratelimited[i] >= 0.5*@total[i] and @total[i] >= 10); else p = train.train.packets[0][0]; if (p and p.probe and p.response and p.probe.time and p.response.time) then @stamps[i].push([p.probe.time.to_f * 1000.0, p.response.packet.icmp_ttime, p.response.time.to_f*1000.0]); else @total[i] -= 1; end end } if ($printFrequency > 0 and (num+1) % $printFrequency == 0 and num != $count-1) then puts " ---- after #{num+1} measurements ----"; analyze(hopDetails); end sleepTime = startTime + $lag/1000.0 - Time.now; #puts "sleep = #{sleepTime} %.3f" % [Time.now.to_f*1000]; if (sleepTime > 0 and num != $count-1) then Kernel.sleep(sleepTime); end } puts " ---- after #{$count} measurements ----"; analyze(hopDetails); end
Public Instance Methods
analyze(hopDetails)
click to toggle source
# File lib/scriptroute/tulip/queuing.rb, line 166 def analyze (hopDetails) hopDetails.each_index { |hop| next if (!hopDetails[hop]); details = hopDetails[hop]; valid = @total[hop] - @ratelimited[hop]; # printf("%d. %s ", $global_tpath.path[hop].hop, details[4]); printf("%s ", $global_tpath.path[hop]); printf("(ejected) ") if (@ejected.has_key?(hop)); round = computeRTMed(@stamps[hop]); printf("rt: median=%.3f min=%.3f max=%.3f ", round[0]+round[1], round[1], round[2]); if (details[3]) then triplets = fixByteOrder(@stamps[hop]); cing = computeFWMedCing(triplets); q = (cing[1][1].to_f==0)? 1 : cing[1][0].to_f/cing[1][1].to_f; if (validOTT(cing[0][0], round[0])) then printf("fw: median=%.3f max=%s quality=%.3f (%s/%s)", cing[0][0], cing[0][1], q, cing[1][0], cing[1][1]); else printf("fw: median=-1 max=-1 quality=-1"); end end puts ""; } end
validOTT(ott, rtt)
click to toggle source
# File lib/scriptroute/tulip/queuing.rb, line 159 def validOTT (ott, rtt) return false if (ott < 0); #return false if (ott > 3 and rtt < 1); #return false if (ott > rtt/2); return true; end