Class: Scriptroute::Tulip::QueuingDoctor

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

Instance Method Summary collapse

Constructor Details

#initialize(hopDetails) ⇒ QueuingDoctor

Returns a new instance of QueuingDoctor.



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# 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

Instance Method Details

#analyze(hopDetails) ⇒ Object



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# 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) ⇒ Object



159
160
161
162
163
164
# 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