Class: Scriptroute::Tulip::LossDoctor

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

Instance Method Summary collapse

Constructor Details

#initialize(hopDetails) ⇒ LossDoctor

Returns a new instance of LossDoctor.



75
76
77
78
79
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# 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

Instance Method Details

#analyze(hopDetails) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# 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