Class: Scriptroute::Tulip::ReorderingDoctor

Inherits:
Object
  • Object
show all
Defined in:
lib/scriptroute/tulip/reordering.rb

Instance Method Summary collapse

Constructor Details

#initialize(hopDetails) ⇒ ReorderingDoctor

Returns a new instance of ReorderingDoctor.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# 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

Instance Method Details

#analyze(hopDetails) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# 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