Class: Scriptroute::Tulip::LossTrain
- Inherits:
-
Object
- Object
- Scriptroute::Tulip::LossTrain
- Defined in:
- lib/scriptroute/tulip/loss.rb
Instance Attribute Summary collapse
-
#train ⇒ Object
readonly
Returns the value of attribute train.
Instance Method Summary collapse
-
#initialize(destination, intra_train, type, ttl) ⇒ LossTrain
constructor
A new instance of LossTrain.
- #isLossy? ⇒ Boolean
- #to_s ⇒ Object
-
#wasPcapped? ⇒ Boolean
todo: principled treatment of pcapping.
Constructor Details
#initialize(destination, intra_train, type, ttl) ⇒ LossTrain
Returns a new instance of LossTrain.
7 8 9 10 11 |
# File 'lib/scriptroute/tulip/loss.rb', line 7 def initialize(destination, intra_train, type, ttl) @destination, @intra_train, @type, @ttl = destination, intra_train, type, ttl; #(dsts, numpackets, intratrain, types, ttls, psizes, numtrains, intertrain) @train = Train2.new([destination], 3, @intra_train, [type], [ttl], [-1, 1000, -1], 1, 0); end |
Instance Attribute Details
#train ⇒ Object (readonly)
Returns the value of attribute train.
5 6 7 |
# File 'lib/scriptroute/tulip/loss.rb', line 5 def train @train end |
Instance Method Details
#isLossy? ⇒ Boolean
13 14 15 |
# File 'lib/scriptroute/tulip/loss.rb', line 13 def isLossy? return (@train.num_losses[0] > 0); end |
#to_s ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/scriptroute/tulip/loss.rb', line 28 def to_s str = ""; str += "losstrain #{@destination} #{@intra_train} #{@type} #{@ttl}\n"; @train.packets.each_index { |j| @train.packets[0].each_index { |k| pr = @train.packets[j][k]; if (pr and pr.probe and pr.probe.time) then stime, sid = pr.probe.time.to_f * 1000, pr.probe.packet.ip_id; rtime = (pr.response) ? pr.response.time.to_f * 1000 : -1; rid = (pr.response) ? pr.response.packet.ip_id : -1; src = (pr.response)? pr.response.packet.ip_src : -1; str += "#{src} %.3f +%.3fms %d %d\n" %[stime, rtime-stime, rid, sid]; else str += "pcap overload\n"; end } } return str; end |
#wasPcapped? ⇒ Boolean
todo: principled treatment of pcapping
18 19 20 21 22 23 24 25 26 |
# File 'lib/scriptroute/tulip/loss.rb', line 18 def wasPcapped? @train.packets.each_index { |j| @train.packets[0].each_index { |k| pr = @train.packets[j][k]; return true if (!pr or !pr.probe or !pr.probe.time); } } return false; end |