.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
. if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "Net::Oping 3pm"
.TH Net::Oping 3pm "2020-11-09" "perl v5.32.0" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
Net::Oping \- ICMP latency measurement module using the oping library.
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\& use Net::Oping ();
\&
\& my $obj = Net::Oping\->new ();
\& $obj\->host_add (qw(one.example.org two.example.org));
\&
\& my $ret = $obj\->ping ();
\& print "Latency to \`one\*(Aq is " . $ret\->{\*(Aqone.example.org\*(Aq} . "\en";
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
This Perl module is a high-level interface to the
oping library . Its purpose it to send \f(CW\*(C`ICMP ECHO_REQUEST\*(C'\fR
packets (also known as \*(L"ping\*(R") to a host and measure the time that elapses
until the reception of an \f(CW\*(C`ICMP ECHO_REPLY\*(C'\fR packet (also known as \*(L"pong\*(R"). If
no such packet is received after a certain timeout the host is considered to be
unreachable.
.PP
The used \fIoping\fR library supports \*(L"ping\*(R"ing multiple hosts in parallel and
works with IPv4 and IPv6 transparently. Other advanced features that are
provided by the underlying library, such as setting the data sent, are not yet
supported by this interface.
.SH "INTERFACE"
.IX Header "INTERFACE"
The interface is kept simple and clean. First you need to create an object to
which you then add hosts. Using the \f(CW\*(C`ping\*(C'\fR method you can request a latency
measurement and get the current values returned. If necessary you can remove
hosts from the object, too.
.PP
The constructor and methods are defined as follows:
.IP "\fI\f(CI$obj\fI\fR = Net::Oping\->\fBnew\fR ();" 4
.IX Item "$obj = Net::Oping->new ();"
Creates and returns a new object.
.IP "\fI\f(CI$status\fI\fR = \fI\f(CI$obj\fI\fR\->\fBtimeout\fR (\fI\f(CI$timeout\fI\fR);" 4
.IX Item "$status = $obj->timeout ($timeout);"
Sets the timeout before a host is considered unreachable to \fI\f(CI$timeout\fI\fR
seconds, which may be a floating point number to specify fractional seconds.
.IP "\fI\f(CI$status\fI\fR = \fI\f(CI$obj\fI\fR\->\fBttl\fR (\fI\f(CI$ttl\fI\fR);" 4
.IX Item "$status = $obj->ttl ($ttl);"
Sets the \fITime to Live\fR (\s-1TTL\s0) of outgoing packets. \fI\f(CI$ttl\fI\fR must be in the
range \fB1\fR ... \fB255\fR. Returns true when successful and false
when an error occurred.
.IP "\fI\f(CI$status\fI\fR = \fI\f(CI$obj\fI\fR\->\fBbind\fR (\fI\f(CI$ip_addr\fI\fR);" 4
.IX Item "$status = $obj->bind ($ip_addr);"
Sets the source IP-address to use. \fI\f(CI$ip_addr\fI\fR must be a string containing an
IP-address, such as \*(L"192.168.0.1\*(R" or \*(L"2001:f00::1\*(R". As a side-effect this will
set the address-family (IPv4 or IPv6) to a fixed value, too, for obvious
reasons.
.IP "\fI\f(CI$status\fI\fR = \fI\f(CI$obj\fI\fR\->\fBdevice\fR (\fI\f(CI$device\fI\fR);" 4
.IX Item "$status = $obj->device ($device);"
Sets the network device used for communication. This may not be supported on
all platforms.
.Sp
\&\fIRequires liboping 1.3 or later.\fR
.IP "\fI\f(CI$status\fI\fR = \fI\f(CI$obj\fI\fR\->\fBhost_add\fR (\fI\f(CI$host\fI\fR, [\fI\f(CI$host\fI\fR, ...]);" 4
.IX Item "$status = $obj->host_add ($host, [$host, ...]);"
Adds one or more hosts to the Net::Oping\-object \fI\f(CI$obj\fI\fR. The number of
successfully added hosts is returned. If this number differs from the number of
hosts that were passed to the method you can use \fBget_error\fR (see below) to
get the error message of the last failure.
.IP "\fI\f(CI$status\fI\fR = \fI\f(CI$obj\fI\fR\->\fBhost_remove\fR (\fI\f(CI$host\fI\fR, [\fI\f(CI$host\fI\fR, ...]);" 4
.IX Item "$status = $obj->host_remove ($host, [$host, ...]);"
Same semantic as \fBhost_add\fR but removes hosts.
.IP "\fI\f(CI$latency\fI\fR = \fI\f(CI$obj\fI\fR\->\fBping\fR ()" 4
.IX Item "$latency = $obj->ping ()"
The central method of this module sends \s-1ICMP\s0 packets to the hosts and waits for
replies. The time it takes for replies to arrive is measured and returned.
.Sp
The returned scalar is a hash reference where each host associated with the
\&\fI\f(CI$obj\fI\fR object is a key and the associated value is the corresponding latency
in milliseconds. An example hash reference would be:
.Sp
.Vb 1
\& $latency = { host1 => 51.143, host2 => undef, host3 => 54.697, ... };
.Ve
.Sp
If a value is \f(CW\*(C`undef\*(C'\fR, as for \*(L"host2\*(R" in this example, the host has timed out
and considered unreachable.
.IP "\fI\f(CI$dropped\fI\fR = \fI\f(CI$obj\fI\fR\->\fBget_dropped\fR ()" 4
.IX Item "$dropped = $obj->get_dropped ()"
Returns a hash reference holding the number of \*(L"drops\*(R" (echo requests which
were not answered in time) for each host. An example return
values would be:
.Sp
.Vb 1
\& $droprate = { host1 => 0, host2 => 3, host3 => undef, ... };
.Ve
.Sp
Hosts to which no data has been sent yet will return \f(CW\*(C`undef\*(C'\fR (\*(L"host3\*(R" in this
example).
.IP "\fI\f(CI$ttl\fI\fR = \fI\f(CI$obj\fI\fR\->\fBget_recv_ttl\fR ()" 4
.IX Item "$ttl = $obj->get_recv_ttl ()"
Returns a hash reference holding the \fITime to Live\fR (\s-1TTL\s0) of the last received
packet for each host. An example return value would be:
.Sp
.Vb 1
\& $ttl = { host1 => 60, host2 => 41, host3 => 243, ... };
.Ve
.Sp
To signal an invalid or unavailable \s-1TTL,\s0 a negative number is returned.
.IP "\fI\f(CI$errmsg\fI\fR = \fI\f(CI$obj\fI\fR\->\fBget_error\fR ();" 4
.IX Item "$errmsg = $obj->get_error ();"
Returns the last error that occurred.
.SH "CAVEATS"
.IX Header "CAVEATS"
The \fIoping\fR library opens a raw socket to be able to send \s-1ICMP\s0 packets. On
most systems normal users are not allowed to do this. This is why on most
systems the \fBping\fR\|(1) utility is installed as SetUID-root. Since, when using
this module, no external process is spawned \fBthis\fR process needs the
appropriate permissions. This means that either your script has to run as
superuser or, under Linux, needs the \f(CW\*(C`CAP_NET_RAW\*(C'\fR capability.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
\&\fBliboping\fR\|(3)
.PP
The \fIliboping\fR homepage may be found at .
Information about its mailing list may be found at
.
.SH "AUTHORS"
.IX Header "AUTHORS"
First XS port by Olivier Fredj, extended \s-1XS\s0 functionality and high-level
Perl interface by Florian Forster.
.SH "COPYRIGHT AND LICENSE"
.IX Header "COPYRIGHT AND LICENSE"
Copyright (C) 2007 by Olivier Fredj
.PP
Copyright (C) 2008,2009 by Florian Forster
.PP
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.7 or,
at your option, any later version of Perl 5 you may have available.
.PP
Please note that \fIliboping\fR is licensed under the GPLv2. Derived works of
both, \fINet::Oping\fR and \fIliboping\fR, (i. e. binary packages) may
therefore be subject to stricter licensing terms than the source code of this
package.