Class: Scriptroute::Tulip::ReordTrain

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#destinationObject (readonly)

Returns the value of attribute destination.



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

def destination
  @destination
end

#intra_trainObject (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

#trainObject (readonly)

Returns the value of attribute train.



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

def train
  @train
end

#ttlObject (readonly)

Returns the value of attribute ttl.



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

def ttl
  @ttl
end

#typeObject (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

Returns:

  • (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

Returns:

  • (Boolean)


16
17
18
# File 'lib/scriptroute/tulip/reordering.rb', line 16

def isLossy? 
  return (@train.num_losses[0] > 0);
end

#isRTro?Boolean

Returns:

  • (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_sObject



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

Returns:

  • (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