class Scriptroute::Tulip::LossTrain
Attributes
train[R]
Public Class Methods
new(destination, intra_train, type, ttl)
click to toggle source
# 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
Public Instance Methods
isLossy?()
click to toggle source
# File lib/scriptroute/tulip/loss.rb, line 13 def isLossy? return (@train.num_losses[0] > 0); end
to_s()
click to toggle source
# 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?()
click to toggle source
todo: principled treatment of pcapping
# 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