class Scriptroute::Tulip::ReorderingDoctor

Public Class Methods

new(hopDetails) click to toggle source
# File lib/scriptroute/tulip/reordering.rb, line 80
def initialize (hopDetails) 
    
  @total = Hash.new(0);
  @fwreord = Hash.new(0);
  @rtreord = Hash.new(0);
  @ratelimited = 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 = ReordTrain.new(details[0],  $spread/1000.0, details[2], details[1]);
      puts "#{train}\n" if ($verbose>=10);
      
      next if (train.wasPcapped?);

      @total[i] += 1;
      if (train.isLossy?) then 
        @ratelimited[i] += 1;
        if ($skipRTrtrs and @ratelimited[i] >= 0.5*@total[i] and @total[i] >= 10) then
          @ejected[i] = 1;
        end
      else
        @fwreord[i] += (train.isFWro?)? 1 : 0
        @rtreord[i] += (train.isRTro?)? 1 : 0
      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/reordering.rb, line 60
  def analyze (hopDetails) 

    hopDetails.each_index { |hop| 
      next if (!hopDetails[hop]);
      details = hopDetails[hop];
      
      valid = 1.0*@total[hop] - @ratelimited[hop];
#      printf("%d. %s ", $global_tpath.path[hop].hop, details[4]);
      printf("%s ", $global_tpath.path[hop]);
#      printf("%d. %s %s ", $global_tpath.path[hop].hop, IPSocket.getname($global_tpath.path[hop].hop), details[4]);
      printf("(ejected) ") if (@ejected.has_key?(hop));
      printf("rt=%.3f (%d/%d) ", @rtreord[hop].to_f/valid, @rtreord[hop], valid);
      if (details[3]) then
        printf("fw=%.3f (%d/%d)\n", @fwreord[hop].to_f/valid, @fwreord[hop], valid) 
      else
        printf("\n")
      end
    }
  end