Class: Scriptroute::Tulip::QueueTrain

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dst, type, ttl) ⇒ QueueTrain

Returns a new instance of QueueTrain.



8
9
10
11
12
# File 'lib/scriptroute/tulip/queuing.rb', line 8

def initialize(dst, type, ttl) 
  #(dsts, numpackets, resolution, types, ttls, shuffle=false) 
  #@train = Train.new([dst], 2, 0, [type], [ttl]);
  @train = Train.new([dst], 1, 0, [type], [ttl]);
end

Instance Attribute Details

#trainObject (readonly)

Returns the value of attribute train.



6
7
8
# File 'lib/scriptroute/tulip/queuing.rb', line 6

def train
  @train
end

Instance Method Details

#isLossy?Boolean

Returns:

  • (Boolean)


14
15
16
17
# File 'lib/scriptroute/tulip/queuing.rb', line 14

def isLossy? 
  ##losing one of the two timestamps all the time is ok.
  return (@train.num_losses[0] > 1);
end

#to_sObject

def to_s

  return @train.to_s;
end


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/scriptroute/tulip/queuing.rb', line 23

def to_s
  str = "queuetrain: #{@train.dsts} (#{@train.types})\n";
  @train.packets[0].each_index { |i| 
    (@train.dsts).each_index { |j|
	pr = @train.packets[j][i];
	stime = pr.probe.time.to_f * 1000;
	rtt = (pr.probe and pr.response) ? (pr.response.time - pr.probe.time) * 1000 : -1;
	str += "#{@train.dsts[j]} %.3fms %.3f " %[rtt, stime];
	if (@train.types[j] == "tstamp") then 
 rem_time =  (pr.response)? pr.response.packet.icmp_ttime : 0;
 str += "#{rem_time}";
	end
    }
    str += "\n";
  }
  return str;
end