# Measuring Network Latency

**URL:** <https://www.ruby-forum.com/t/measuring-network-latency/159057>\
**Category:** Ruby\
**Created:** [January 30, 2009, 10:41pm UTC](https://www.ruby-forum.com/t/measuring-network-latency/159057 "2009-01-30T22:41:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian\_Mac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a88e4f/32.png) [@Brian\_Mac](https://www.ruby-forum.com/u/Brian_Mac)\
**Post date:** [January 30, 2009, 10:41pm UTC](https://www.ruby-forum.com/t/measuring-network-latency/159057/1 "2009-01-30T22:41:00Z")

</div>

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” =\> ‘some.ip.address.here’}

def self.latency\_summary(ping\_count=50)  
$endpoints.sort.each do |k,v|  
sum = 0  
results = Array.new  
ping\_count.times {  
p = Net::PingTCP.new(v, 3389)  
p.ping  
results \<\< p.duration  
}

```
results.each do |num|
  sum += num
end

puts "Avg/Max/Min response time to #{k} for #{ping_count.to_s} TCP

```

pings: #{(sum/results.length)}.sec / #{results.max}sec / #{results.min}  
sec"  
end  
end
