From: Dale Ackerman on
Hi

I've had a request to make a utility (I want to use Ruby) that does a
MTU sweep looking for black holes in routes. So I need a library or a
way to run ping in both a OS X, Linux and Windows environment. The
utility will ping an IP and continue to increment the package / payload
size until error if any The MTU will be (max_size + 28). Can I use Ruby
to do this? I found a ping gem and the std. lib has ping as well but
very limited in options. What else is there?


Thanks
--
Posted via http://www.ruby-forum.com/.

From: Phillip Gawlowski on
On 23.01.2010 03:40, Dale Ackerman wrote:
> Hi
>
> I've had a request to make a utility (I want to use Ruby) that does a
> MTU sweep looking for black holes in routes. So I need a library or a
> way to run ping in both a OS X, Linux and Windows environment. The
> utility will ping an IP and continue to increment the package / payload
> size until error if any The MTU will be (max_size + 28). Can I use Ruby
> to do this? I found a ping gem and the std. lib has ping as well but
> very limited in options. What else is there?

You could wrap the OS ping variants (Linux and Mac OS X are probably
identical, since both use the GNU utils, so you only have to check for
Windows) in your own code, and use that.

They all should provide a means to modify packet size (Windows' ping.exe
does), so you can achieve your desired result.

--
Phillip Gawlowski

From: Dale Ackerman on

> You could wrap the OS ping variants (Linux and Mac OS X are probably
> identical, since both use the GNU utils, so you only have to check for
> Windows) in your own code, and use that.
>
> They all should provide a means to modify packet size (Windows' ping.exe
> does), so you can achieve your desired result.

How would I wrap the command line utilities from ruby? I am new to the
ruby.
--
Posted via http://www.ruby-forum.com/.

From: brabuhr on
On Fri, Jan 22, 2010 at 11:03 PM, Dale Ackerman <dale8458(a)gmail.com> wrote:
>> You could wrap the OS ping variants (Linux and Mac OS X are probably
>> identical, since both use the GNU utils, so you only have to check for
>> Windows) in your own code, and use that.
>>
>> They all should provide a means to modify packet size (Windows' ping.exe
>> does), so you can achieve your desired result.
>
> How would I wrap the command line utilities from ruby?  I am new to the
> ruby.

Simplistic example:

$ ping
usage: ping [-AaDdfnoQqRrv] [-c count] [-i wait] [-l preload] [-M mask | time]
[-m ttl] [-p pattern] [-S src_addr] [-s packetsize]
[-t timeout] [-z tos] host
ping [-AaDdfLnoQqRrv] [-c count] [-I iface] [-i wait] [-l preload]
[-M mask | time] [-m ttl] [-p pattern] [-S src_addr]
[-s packetsize] [-T ttl] [-t timeout] [-z tos] mcast-group
$ irb
irb(main):001:0> count = 3
=> 3
irb(main):002:0> packetsize = 128
=> 128
irb(main):003:0> host = '127.0.0.1'
=> "127.0.0.1"
irb(main):004:0> `ping -c #{count} -s #{packetsize} #{host}`
=> "PING 127.0.0.1 (127.0.0.1): 128 data bytes\n136 bytes from
127.0.0.1: icmp_seq=0 ttl=64 time=0.171 ms\n136 bytes from 127.0.0.1:
icmp_seq=1 ttl=64 time=0.101 ms\n136 bytes from 127.0.0.1: icmp_seq=2
ttl=64 time=0.103 ms\n\n--- 127.0.0.1 ping statistics ---\n3 packets
transmitted, 3 packets received, 0% packet loss\nround-trip
min/avg/max/stddev = 0.101/0.125/0.171/0.033 ms\n"

From: Dale Ackerman on

WOW! Thanks
are those back quotes around the ping command? I guess ruby will just
shell
out and run a command line ?? That's nice... Also how to handle
std-err I am trying to automate the MTU sweep so I want to keep
incrementing the data size and then handle (break) and display the MTU
== max-size + 28 (I think)
--
Posted via http://www.ruby-forum.com/.