Tuesday, May 30, 2006

Why Ping is not an Acceptable Ping

Ruby has a ping in the Standard Library, but it's not a very good one. I really think it should be replaced, and there are a couple of options. Let me tell you what's wrong with the current ping. Then I'll lay out a plan for replacing it.

First, it's in the wrong place. Instead of being nestled in with net/http, net/smtp, and the rest of the net friends, ping is off in its own little world. This could be fixed if it weren't for a bigger problem.

Second, ping isn't even an implementation of the real (ICMP) ping. It only does TCP pings (by default on the echo port). And it's not called in a standard way. The documents recommend the following:


rb(main):001:0> require 'ping'
=> true
irb(main):002:0> Ping.pingecho("localhost")
=> true
irb(main):003:0>

There are timeout and service parameter, but no number of ping attempts and you only get back a boolean value.

We can do better than that. In fact, we already have. There are at least three implementations of ping floating around that could be merged to provide a sensible interface; the full range of TCP, UDP, and ICMP pings; and could live happily in net/ping. Is that too much to ask?


UPDATE: I wrote this on Friday, intending to post it this morning. In the meantime, Peter Szinek posted a message to ruby-talk asking if there were any way to get ping stats from Ruby. This is exactly the kind of functionality that we need to include in netping. I guess I was being more timely than I thought.

3 comments:

Anonymous said...

Pat,

Did anyone ever do something about it? Just curious.

Thanks
Vish
donnoit@yahoo.com

gnupate said...

Slowly. I've merged Daniel Berger's implementation and mine. I need to add a bunch more documentation, then I think it will be in shape to submit a patch to the ruby-core mailing list.

I've got a bunch of other stuff on my plate, but I hope to do it this year (before 1.8.6 is more than a twinkle in matz's eye.)

Robert J. Berger said...

So did anything happen with this? Is your code anywhere available? Did you add the ability to do a continuous ping and get the stats of the roundtrip times for each itteration (that is what I'm looking for)

Thanks!
Rob