Forum: Ruby Measuring Network Latency

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Brian Mac (Guest)
on 2009-01-30 23:41
(Received via mailing list)
i'm looking for ideas of measuring network latency with ruby.  i can't
reliably use net::ping because rdp (remote desktop protocol) traffic
is being prioritized.  i thought i could use Net::PingTCP and get the
duration but users in a remote office are complaining of network
latency when i'm just not seeing it from the code below (even when
using a high count).

here is the the code that i'm working with.  any help or suggestions
would be much appreciated.

$endpoints = {"Office Name" => ''}

def self.latency_summary(ping_count=50)
  $endpoints.sort.each do |k,v|
    sum = 0
    results =
    ping_count.times {
      p =, 3389)
      results << p.duration

    results.each do |num|
      sum += num

    puts "Avg/Max/Min response time to #{k} for #{ping_count.to_s} TCP
pings: #{(sum/results.length)}.sec / #{results.max}sec / #{results.min}
This topic is locked and can not be replied to.