class Scriptroute::Tulip::LossDoctor
Public Class Methods
new(hopDetails)
click to toggle source
# File lib/scriptroute/tulip/loss.rb, line 75 def initialize (hopDetails) @total = Hash.new(0); @noLosses = Hash.new(0); @undesiredLosses = Hash.new(0); @forwardLosses = Hash.new(0); @reorderedResponses = Hash.new(0); @consecutiveIPIDs = Hash.new(0); @ejected = Hash.new(0); (0..$count-1).each { |num| startTime = Time.now; hopDetails.each_index { |i| next if (!hopDetails[i] or @ejected.has_key?(i)); details = hopDetails[i]; #(destination, intra_train, type, ttl) train = LossTrain.new(details[0], $spread/1000.0, details[2], details[1]); puts "#{train}\n" if ($verbose>=10); @total[i] += 1; pkts = train.train.packets[0]; next if (train.wasPcapped?); if (!train.isLossy?) then @noLosses[i] += 1; if (details[3]) then ids = pkts.map { |p| p.response.packet.ip_id }; if (ids[1] < ids[0] or ids[2] < ids[1]) then @reorderedResponses[i] += 1 if (ids[1] != 0); #don't count routers that return 0 for big probes end if (ids[0] + 1 == ids[1] and ids[1] + 1 == ids[2]) then @consecutiveIPIDs[i] += 1; end end else if (!pkts[0].response or !pkts[2].response) then @undesiredLosses[i] += 1; else id0 = pkts[0].response.packet.ip_id; id2 = pkts[2].response.packet.ip_id; if (id0 == id2 - 1) then @forwardLosses[i] += 1; end end if (@noLosses[i] <= 0.25*@total[i] and @total[i] >= 10) then @ejected[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; if (sleepTime > 0) 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/loss.rb, line 52 def analyze (hopDetails) hopDetails.each_index { |hop| next if (!hopDetails[hop]); details = hopDetails[hop]; valid = @total[hop] - @undesiredLosses[hop]; # printf("%d. %s ", $global_tpath.path[hop].hop, details[4]); printf("%s ", $global_tpath.path[hop]); printf("(ejected) ") if (@ejected.has_key?(hop)); rt = @total[hop] - @undesiredLosses[hop] - @noLosses[hop]; printf("rt=%.3f (%d/%d) ",(valid==0)? 0 : rt.to_f/valid, rt, valid); if (details[3]) then printf("fw=%.3f (%d/%d) ", @forwardLosses[hop].to_f/valid, @forwardLosses[hop], valid); consec = @noLosses[hop] - @reorderedResponses[hop]; consecR = (consec==0)? 0 : @consecutiveIPIDs[hop].to_f/consec; printf("co=%.3f (%d/%d) ", consecR, @consecutiveIPIDs[hop], consec); printf("ro=%.3f (%d/%d)", @reorderedResponses[hop].to_f/@noLosses[hop], @reorderedResponses[hop], @noLosses[hop]); end puts ""; } end