What would I have to do in order to be able to send an ARP Ping or a
regular ICMP_ECHO_REQUEST in Ruby? Is it possible?
Ruby R. wrote:
What would I have to do in order to be able to send an ARP Ping or a
regular ICMP_ECHO_REQUEST in Ruby? Is it possible?
require ‘ping’
Ping.pingecho(‘example.com’)
or
system(‘ping -c1 www.example.com’)
regular ICMP_ECHO_REQUEST in Ruby? Is it possible?
Posted via http://www.ruby-forum.com/.
pingecho() uses a TCP echo (not an ICMP echo) to determine if the
remote host is reachable. This is usually adequate to tell that a
remote
host is available to rsh(1), ftp(1), or telnet(1) to.
So the standard library may be sufficient, but not necessarily so.
In addition to the above, you can also try the net/ping from rubyforge,
or
possibly even rubyforger to craft your own ARP or ICMP packets.
HTH,
Felix
On Friday 10 August 2007 03:20:19 pm Klodus K. wrote:
Ruby R. wrote:
What would I have to do in order to be able to send an ARP Ping or a
regular ICMP_ECHO_REQUEST in Ruby? Is it possible?require ‘ping’
Ping.pingecho(‘example.com’)
Unfortunately, this isn’t a ‘ICMP_ECHO_REQUEST’, it’s an attempt to
connect
to the remote machine on the ‘echo’ port. If the connection is refused
or
allowed, pingecho() returns true. If it times out, or otherwise errors,
it returns false. Either way, it’s not ICMP if you need ICMP.
or
system(‘ping -c1 www.example.com’)
Shelling out to a ping command is probably a bad idea for portability
reasons.
If a TCP connection test works for you then go with the stdlib Ping
library.
If it doesn’t, you might look into RubyInline or writing a simple C
extension for basic ICMP requests.
Cheers!
On Aug 10, 8:42 am, Ruby R. [email protected] wrote:
What would I have to do in order to be able to send an ARP Ping or a
regular ICMP_ECHO_REQUEST in Ruby? Is it possible?
require ‘net/ping’
include Net
icmp = Ping::ICMP.new(‘foo.com’)
if icmp.ping?
Successful
else
Failed
end
gem install net-ping
Regards,
Dan
On Aug 10, 6:02 pm, Konrad M. [email protected] wrote:
On Friday 10 August 2007 03:20:19 pm Klodus K. wrote:
Ruby R. wrote:
What would I have to do in order to be able to send an ARP Ping or a
regular ICMP_ECHO_REQUEST in Ruby? Is it possible?
http://raa.ruby-lang.org/project/icmpping/
hope it helps
Gordon