Class: Scriptroute::Tulip::ReordTrain
- Inherits:
-
Object
- Object
- Scriptroute::Tulip::ReordTrain
- Defined in:
- lib/scriptroute/tulip/reordering.rb
Instance Attribute Summary collapse
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#intra_train ⇒ Object
readonly
Returns the value of attribute intra_train.
-
#train ⇒ Object
readonly
Returns the value of attribute train.
-
#ttl ⇒ Object
readonly
Returns the value of attribute ttl.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(destination, intra_train, type, ttl) ⇒ ReordTrain
constructor
A new instance of ReordTrain.
- #isFWro? ⇒ Boolean
- #isLossy? ⇒ Boolean
- #isRTro? ⇒ Boolean
- #to_s ⇒ Object
- #wasPcapped? ⇒ Boolean
Constructor Details
#initialize(destination, intra_train, type, ttl) ⇒ ReordTrain
Returns a new instance of ReordTrain.
8 9 10 11 12 13 14 |
# File 'lib/scriptroute/tulip/reordering.rb', line 8 def initialize(destination, intra_train, type, ttl) @destination, @intra_train, @type, @ttl = destination, intra_train, type, ttl; #(dsts, numpackets, resolution, types, ttls, shuffle=false) @train = Train.new([@destination], 2, @intra_train, [@type], [@ttl]); end |
Instance Attribute Details
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
6 7 8 |
# File 'lib/scriptroute/tulip/reordering.rb', line 6 def destination @destination end |
#intra_train ⇒ Object (readonly)
Returns the value of attribute intra_train.
6 7 8 |
# File 'lib/scriptroute/tulip/reordering.rb', line 6 def intra_train @intra_train end |
#train ⇒ Object (readonly)
Returns the value of attribute train.
6 7 8 |
# File 'lib/scriptroute/tulip/reordering.rb', line 6 def train @train end |
#ttl ⇒ Object (readonly)
Returns the value of attribute ttl.
6 7 8 |
# File 'lib/scriptroute/tulip/reordering.rb', line 6 def ttl @ttl end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/scriptroute/tulip/reordering.rb', line 6 def type @type end |
Instance Method Details
#isFWro? ⇒ Boolean
26 27 28 29 30 |
# File 'lib/scriptroute/tulip/reordering.rb', line 26 def isFWro? return false if (isLossy?); id1, id2 = [0,1].map { |v| @train.packets[0][v].response.packet.ip_id; } (id1 > id2)? true : false; end |
#isLossy? ⇒ Boolean
16 17 18 |
# File 'lib/scriptroute/tulip/reordering.rb', line 16 def isLossy? return (@train.num_losses[0] > 0); end |
#isRTro? ⇒ Boolean
20 21 22 23 24 |
# File 'lib/scriptroute/tulip/reordering.rb', line 20 def isRTro? return false if (isLossy?); rt1, rt2 = [0,1].map { |v| @train.packets[0][v].response.time; } (rt1 > rt2)? true : false; end |
#to_s ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/scriptroute/tulip/reordering.rb', line 40 def to_s str = ""; str += "reordtrain %s %s %s %s\n" % [@destination, @ttl, @type, @intra_train]; @train.packets[0].each_index { |k| pr = @train.packets[0][k]; stime, sid = pr.probe.time.to_f * 1000, pr.probe.packet.ip_id; rtime = (pr.response) ? pr.response.time.to_f * 1000 : -1; sid = pr.probe.packet.ip_id; rid = (pr.response) ? pr.response.packet.ip_id : -1; src = (pr.response)? pr.response.packet.ip_src : -1; str += "#{src} %.3f +%.3fms %d %d" %[stime, rtime-stime, rid, sid]; str += "\n"; } return str; end |
#wasPcapped? ⇒ Boolean
32 33 34 35 36 37 38 |
# File 'lib/scriptroute/tulip/reordering.rb', line 32 def wasPcapped? @train.packets[0].each_index { |k| pr = @train.packets[0][k]; return true if (!pr or !pr.probe or !pr.probe.time) } return false; end |