Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / man / man3 / Net::Ping.3
CommitLineData
920dae64
AT
1.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
2.\"
3.\" Standard preamble:
4.\" ========================================================================
5.de Sh \" Subsection heading
6.br
7.if t .Sp
8.ne 5
9.PP
10\fB\\$1\fR
11.PP
12..
13.de Sp \" Vertical space (when we can't use .PP)
14.if t .sp .5v
15.if n .sp
16..
17.de Vb \" Begin verbatim text
18.ft CW
19.nf
20.ne \\$1
21..
22.de Ve \" End verbatim text
23.ft R
24.fi
25..
26.\" Set up some character translations and predefined strings. \*(-- will
27.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28.\" double quote, and \*(R" will give a right double quote. | will give a
29.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
30.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
31.\" expand to `' in nroff, nothing in troff, for use with C<>.
32.tr \(*W-|\(bv\*(Tr
33.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34.ie n \{\
35. ds -- \(*W-
36. ds PI pi
37. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
39. ds L" ""
40. ds R" ""
41. ds C` ""
42. ds C' ""
43'br\}
44.el\{\
45. ds -- \|\(em\|
46. ds PI \(*p
47. ds L" ``
48. ds R" ''
49'br\}
50.\"
51.\" If the F register is turned on, we'll generate index entries on stderr for
52.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53.\" entries marked with X<> in POD. Of course, you'll have to process the
54.\" output yourself in some meaningful fashion.
55.if \nF \{\
56. de IX
57. tm Index:\\$1\t\\n%\t"\\$2"
58..
59. nr % 0
60. rr F
61.\}
62.\"
63.\" For nroff, turn off justification. Always turn off hyphenation; it makes
64.\" way too many mistakes in technical documents.
65.hy 0
66.if n .na
67.\"
68.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69.\" Fear. Run. Save yourself. No user-serviceable parts.
70. \" fudge factors for nroff and troff
71.if n \{\
72. ds #H 0
73. ds #V .8m
74. ds #F .3m
75. ds #[ \f1
76. ds #] \fP
77.\}
78.if t \{\
79. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80. ds #V .6m
81. ds #F 0
82. ds #[ \&
83. ds #] \&
84.\}
85. \" simple accents for nroff and troff
86.if n \{\
87. ds ' \&
88. ds ` \&
89. ds ^ \&
90. ds , \&
91. ds ~ ~
92. ds /
93.\}
94.if t \{\
95. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101.\}
102. \" troff and (daisy-wheel) nroff accents
103.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110.ds ae a\h'-(\w'a'u*4/10)'e
111.ds Ae A\h'-(\w'A'u*4/10)'E
112. \" corrections for vroff
113.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115. \" for low resolution devices (crt and lpr)
116.if \n(.H>23 .if \n(.V>19 \
117\{\
118. ds : e
119. ds 8 ss
120. ds o a
121. ds d- d\h'-1'\(ga
122. ds D- D\h'-1'\(hy
123. ds th \o'bp'
124. ds Th \o'LP'
125. ds ae ae
126. ds Ae AE
127.\}
128.rm #[ #] #H #V #F C
129.\" ========================================================================
130.\"
131.IX Title "Net::Ping 3"
132.TH Net::Ping 3 "2001-09-21" "perl v5.8.8" "Perl Programmers Reference Guide"
133.SH "NAME"
134Net::Ping \- check a remote host for reachability
135.SH "SYNOPSIS"
136.IX Header "SYNOPSIS"
137.Vb 1
138\& use Net::Ping;
139.Ve
140.PP
141.Vb 3
142\& $p = Net::Ping->new();
143\& print "$host is alive.\en" if $p->ping($host);
144\& $p->close();
145.Ve
146.PP
147.Vb 10
148\& $p = Net::Ping->new("icmp");
149\& $p->bind($my_addr); # Specify source interface of pings
150\& foreach $host (@host_array)
151\& {
152\& print "$host is ";
153\& print "NOT " unless $p->ping($host, 2);
154\& print "reachable.\en";
155\& sleep(1);
156\& }
157\& $p->close();
158.Ve
159.PP
160.Vb 10
161\& $p = Net::Ping->new("tcp", 2);
162\& # Try connecting to the www port instead of the echo port
163\& $p->{port_num} = getservbyname("http", "tcp");
164\& while ($stop_time > time())
165\& {
166\& print "$host not reachable ", scalar(localtime()), "\en"
167\& unless $p->ping($host);
168\& sleep(300);
169\& }
170\& undef($p);
171.Ve
172.PP
173.Vb 9
174\& # Like tcp protocol, but with many hosts
175\& $p = Net::Ping->new("syn");
176\& $p->{port_num} = getservbyname("http", "tcp");
177\& foreach $host (@host_array) {
178\& $p->ping($host);
179\& }
180\& while (($host,$rtt,$ip) = $p->ack) {
181\& print "HOST: $host [$ip] ACKed in $rtt seconds.\en";
182\& }
183.Ve
184.PP
185.Vb 7
186\& # High precision syntax (requires Time::HiRes)
187\& $p = Net::Ping->new();
188\& $p->hires();
189\& ($ret, $duration, $ip) = $p->ping($host, 5.5);
190\& printf("$host [ip: $ip] is alive (packet return time: %.2f ms)\en", 1000 * $duration)
191\& if $ret;
192\& $p->close();
193.Ve
194.PP
195.Vb 2
196\& # For backward compatibility
197\& print "$host is alive.\en" if pingecho($host);
198.Ve
199.SH "DESCRIPTION"
200.IX Header "DESCRIPTION"
201This module contains methods to test the reachability of remote
202hosts on a network. A ping object is first created with optional
203parameters, a variable number of hosts may be pinged multiple
204times and then the connection is closed.
205.PP
206You may choose one of six different protocols to use for the
207ping. The \*(L"tcp\*(R" protocol is the default. Note that a live remote host
208may still fail to be pingable by one or more of these protocols. For
209example, www.microsoft.com is generally alive but not \*(L"icmp\*(R" pingable.
210.PP
211With the \*(L"tcp\*(R" protocol the \fIping()\fR method attempts to establish a
212connection to the remote host's echo port. If the connection is
213successfully established, the remote host is considered reachable. No
214data is actually echoed. This protocol does not require any special
215privileges but has higher overhead than the \*(L"udp\*(R" and \*(L"icmp\*(R" protocols.
216.PP
217Specifying the \*(L"udp\*(R" protocol causes the \fIping()\fR method to send a udp
218packet to the remote host's echo port. If the echoed packet is
219received from the remote host and the received packet contains the
220same data as the packet that was sent, the remote host is considered
221reachable. This protocol does not require any special privileges.
222It should be borne in mind that, for a udp ping, a host
223will be reported as unreachable if it is not running the
224appropriate echo service. For Unix-like systems see \fIinetd\fR\|(8)
225for more information.
226.PP
227If the \*(L"icmp\*(R" protocol is specified, the \fIping()\fR method sends an icmp
228echo message to the remote host, which is what the \s-1UNIX\s0 ping program
229does. If the echoed message is received from the remote host and
230the echoed information is correct, the remote host is considered
231reachable. Specifying the \*(L"icmp\*(R" protocol requires that the program
232be run as root or that the program be setuid to root.
233.PP
234If the \*(L"external\*(R" protocol is specified, the \fIping()\fR method attempts to
235use the \f(CW\*(C`Net::Ping::External\*(C'\fR module to ping the remote host.
236\&\f(CW\*(C`Net::Ping::External\*(C'\fR interfaces with your system's default \f(CW\*(C`ping\*(C'\fR
237utility to perform the ping, and generally produces relatively
238accurate results. If \f(CW\*(C`Net::Ping::External\*(C'\fR if not installed on your
239system, specifying the \*(L"external\*(R" protocol will result in an error.
240.PP
241If the \*(L"syn\*(R" protocol is specified, the \fIping()\fR method will only
242send a \s-1TCP\s0 \s-1SYN\s0 packet to the remote host then immediately return.
243If the syn packet was sent successfully, it will return a true value,
244otherwise it will return false. \s-1NOTE:\s0 Unlike the other protocols,
245the return value does \s-1NOT\s0 determine if the remote host is alive or
246not since the full \s-1TCP\s0 three-way handshake may not have completed
247yet. The remote host is only considered reachable if it receives
248a \s-1TCP\s0 \s-1ACK\s0 within the timeout specifed. To begin waiting for the
249\&\s-1ACK\s0 packets, use the \fIack()\fR method as explained below. Use the
250\&\*(L"syn\*(R" protocol instead the \*(L"tcp\*(R" protocol to determine reachability
251of multiple destinations simultaneously by sending parallel \s-1TCP\s0
252\&\s-1SYN\s0 packets. It will not block while testing each remote host.
253demo/fping is provided in this distribution to demonstrate the
254\&\*(L"syn\*(R" protocol as an example.
255This protocol does not require any special privileges.
256.Sh "Functions"
257.IX Subsection "Functions"
258.ie n .IP "Net::Ping\->new([$proto [, $def_timeout\fR [, \f(CW$bytes\fR [, \f(CW$device\fR [, \f(CW$tos ]]]]]);" 4
259.el .IP "Net::Ping\->new([$proto [, \f(CW$def_timeout\fR [, \f(CW$bytes\fR [, \f(CW$device\fR [, \f(CW$tos\fR ]]]]]);" 4
260.IX Item "Net::Ping->new([$proto [, $def_timeout [, $bytes [, $device [, $tos ]]]]]);"
261Create a new ping object. All of the parameters are optional. \f(CW$proto\fR
262specifies the protocol to use when doing a ping. The current choices
263are \*(L"tcp\*(R", \*(L"udp\*(R", \*(L"icmp\*(R", \*(L"stream\*(R", \*(L"syn\*(R", or \*(L"external\*(R".
264The default is \*(L"tcp\*(R".
265.Sp
266If a default timeout ($def_timeout) in seconds is provided, it is used
267when a timeout is not given to the \fIping()\fR method (below). The timeout
268must be greater than 0 and the default, if not specified, is 5 seconds.
269.Sp
270If the number of data bytes ($bytes) is given, that many data bytes
271are included in the ping packet sent to the remote host. The number of
272data bytes is ignored if the protocol is \*(L"tcp\*(R". The minimum (and
273default) number of data bytes is 1 if the protocol is \*(L"udp\*(R" and 0
274otherwise. The maximum number of data bytes that can be specified is
2751024.
276.Sp
277If \f(CW$device\fR is given, this device is used to bind the source endpoint
278before sending the ping packet. I beleive this only works with
279superuser privileges and with udp and icmp protocols at this time.
280.Sp
281If \f(CW$tos\fR is given, this ToS is configured into the soscket.
282.ie n .IP "$p\->ping($host [, $timeout]);" 4
283.el .IP "$p\->ping($host [, \f(CW$timeout\fR]);" 4
284.IX Item "$p->ping($host [, $timeout]);"
285Ping the remote host and wait for a response. \f(CW$host\fR can be either the
286hostname or the \s-1IP\s0 number of the remote host. The optional timeout
287must be greater than 0 seconds and defaults to whatever was specified
288when the ping object was created. Returns a success flag. If the
289hostname cannot be found or there is a problem with the \s-1IP\s0 number, the
290success flag returned will be undef. Otherwise, the success flag will
291be 1 if the host is reachable and 0 if it is not. For most practical
292purposes, undef and 0 and can be treated as the same case. In array
293context, the elapsed time as well as the string form of the ip the
294host resolved to are also returned. The elapsed time value will
295be a float, as retuned by the \fITime::HiRes::time()\fR function, if \fIhires()\fR
296has been previously called, otherwise it is returned as an integer.
297.IP "$p\->source_verify( { 0 | 1 } );" 4
298.IX Item "$p->source_verify( { 0 | 1 } );"
299Allows source endpoint verification to be enabled or disabled.
300This is useful for those remote destinations with multiples
301interfaces where the response may not originate from the same
302endpoint that the original destination endpoint was sent to.
303This only affects udp and icmp protocol pings.
304.Sp
305This is enabled by default.
306.IP "$p\->service_check( { 0 | 1 } );" 4
307.IX Item "$p->service_check( { 0 | 1 } );"
308Set whether or not the connect behavior should enforce
309remote service availability as well as reachability. Normally,
310if the remote server reported \s-1ECONNREFUSED\s0, it must have been
311reachable because of the status packet that it reported.
312With this option enabled, the full three-way tcp handshake
313must have been established successfully before it will
314claim it is reachable. \s-1NOTE:\s0 It still does nothing more
315than connect and disconnect. It does not speak any protocol
316(i.e., \s-1HTTP\s0 or \s-1FTP\s0) to ensure the remote server is sane in
317any way. The remote server \s-1CPU\s0 could be grinding to a halt
318and unresponsive to any clients connecting, but if the kernel
319throws the \s-1ACK\s0 packet, it is considered alive anyway. To
320really determine if the server is responding well would be
321application specific and is beyond the scope of Net::Ping.
322For udp protocol, enabling this option demands that the
323remote server replies with the same udp data that it was sent
324as defined by the udp echo service.
325.Sp
326This affects the \*(L"udp\*(R", \*(L"tcp\*(R", and \*(L"syn\*(R" protocols.
327.Sp
328This is disabled by default.
329.IP "$p\->tcp_service_check( { 0 | 1 } );" 4
330.IX Item "$p->tcp_service_check( { 0 | 1 } );"
331Depricated method, but does the same as \fIservice_check()\fR method.
332.IP "$p\->hires( { 0 | 1 } );" 4
333.IX Item "$p->hires( { 0 | 1 } );"
334Causes this module to use Time::HiRes module, allowing milliseconds
335to be returned by subsequent calls to \fIping()\fR.
336.Sp
337This is disabled by default.
338.IP "$p\->bind($local_addr);" 4
339.IX Item "$p->bind($local_addr);"
340Sets the source address from which pings will be sent. This must be
341the address of one of the interfaces on the local host. \f(CW$local_addr\fR
342may be specified as a hostname or as a text \s-1IP\s0 address such as
343\&\*(L"192.168.1.1\*(R".
344.Sp
345If the protocol is set to \*(L"tcp\*(R", this method may be called any
346number of times, and each call to the \fIping()\fR method (below) will use
347the most recent \f(CW$local_addr\fR. If the protocol is \*(L"icmp\*(R" or \*(L"udp\*(R",
348then \fIbind()\fR must be called at most once per object, and (if it is
349called at all) must be called before the first call to \fIping()\fR for that
350object.
351.IP "$p\->open($host);" 4
352.IX Item "$p->open($host);"
353When you are using the \*(L"stream\*(R" protocol, this call pre-opens the
354tcp socket. It's only necessary to do this if you want to
355provide a different timeout when creating the connection, or
356remove the overhead of establishing the connection from the
357first ping. If you don't call \f(CW\*(C`open()\*(C'\fR, the connection is
358automatically opened the first time \f(CW\*(C`ping()\*(C'\fR is called.
359This call simply does nothing if you are using any protocol other
360than stream.
361.ie n .IP "$p\->ack( [ $host ] );" 4
362.el .IP "$p\->ack( [ \f(CW$host\fR ] );" 4
363.IX Item "$p->ack( [ $host ] );"
364When using the \*(L"syn\*(R" protocol, use this method to determine
365the reachability of the remote host. This method is meant
366to be called up to as many times as \fIping()\fR was called. Each
367call returns the host (as passed to \fIping()\fR) that came back
368with the \s-1TCP\s0 \s-1ACK\s0. The order in which the hosts are returned
369may not necessarily be the same order in which they were
370\&\s-1SYN\s0 queued using the \fIping()\fR method. If the timeout is
371reached before the \s-1TCP\s0 \s-1ACK\s0 is received, or if the remote
372host is not listening on the port attempted, then the \s-1TCP\s0
373connection will not be established and \fIack()\fR will return
374undef. In list context, the host, the ack time, and the
375dotted ip string will be returned instead of just the host.
376If the optional \f(CW$host\fR argument is specified, the return
377value will be partaining to that host only.
378This call simply does nothing if you are using any protocol
379other than syn.
380.ie n .IP "$p\->nack( $failed_ack_host );" 4
381.el .IP "$p\->nack( \f(CW$failed_ack_host\fR );" 4
382.IX Item "$p->nack( $failed_ack_host );"
383The reason that host \f(CW$failed_ack_host\fR did not receive a
384valid \s-1ACK\s0. Useful to find out why when ack( \f(CW$fail_ack_host\fR )
385returns a false value.
386.IP "$p\->\fIclose()\fR;" 4
387.IX Item "$p->close();"
388Close the network connection for this ping object. The network
389connection is also closed by \*(L"undef \f(CW$p\fR\*(R". The network connection is
390automatically closed if the ping object goes out of scope (e.g. \f(CW$p\fR is
391local to a subroutine and you leave the subroutine).
392.ie n .IP "pingecho($host [, $timeout]);" 4
393.el .IP "pingecho($host [, \f(CW$timeout\fR]);" 4
394.IX Item "pingecho($host [, $timeout]);"
395To provide backward compatibility with the previous version of
396Net::Ping, a \fIpingecho()\fR subroutine is available with the same
397functionality as before. \fIpingecho()\fR uses the tcp protocol. The
398return values and parameters are the same as described for the \fIping()\fR
399method. This subroutine is obsolete and may be removed in a future
400version of Net::Ping.
401.SH "NOTES"
402.IX Header "NOTES"
403There will be less network overhead (and some efficiency in your
404program) if you specify either the udp or the icmp protocol. The tcp
405protocol will generate 2.5 times or more traffic for each ping than
406either udp or icmp. If many hosts are pinged frequently, you may wish
407to implement a small wait (e.g. 25ms or more) between each ping to
408avoid flooding your network with packets.
409.PP
410The icmp protocol requires that the program be run as root or that it
411be setuid to root. The other protocols do not require special
412privileges, but not all network devices implement tcp or udp echo.
413.PP
414Local hosts should normally respond to pings within milliseconds.
415However, on a very congested network it may take up to 3 seconds or
416longer to receive an echo packet from the remote host. If the timeout
417is set too low under these conditions, it will appear that the remote
418host is not reachable (which is almost the truth).
419.PP
420Reachability doesn't necessarily mean that the remote host is actually
421functioning beyond its ability to echo packets. tcp is slightly better
422at indicating the health of a system than icmp because it uses more
423of the networking stack to respond.
424.PP
425Because of a lack of anything better, this module uses its own
426routines to pack and unpack \s-1ICMP\s0 packets. It would be better for a
427separate module to be written which understands all of the different
428kinds of \s-1ICMP\s0 packets.
429.SH "INSTALL"
430.IX Header "INSTALL"
431The latest source tree is available via cvs:
432.PP
433.Vb 2
434\& cvs -z3 -q -d :pserver:anonymous@cvs.roobik.com.:/usr/local/cvsroot/freeware checkout Net-Ping
435\& cd Net-Ping
436.Ve
437.PP
438The tarball can be created as follows:
439.PP
440.Vb 1
441\& perl Makefile.PL ; make ; make dist
442.Ve
443.PP
444The latest Net::Ping release can be found at \s-1CPAN:\s0
445.PP
446.Vb 1
447\& $CPAN/modules/by-module/Net/
448.Ve
449.PP
4501) Extract the tarball
451.PP
452.Vb 2
453\& gtar -zxvf Net-Ping-xxxx.tar.gz
454\& cd Net-Ping-xxxx
455.Ve
456.PP
4572) Build:
458.PP
459.Vb 4
460\& make realclean
461\& perl Makefile.PL
462\& make
463\& make test
464.Ve
465.PP
4663) Install
467.PP
468.Vb 1
469\& make install
470.Ve
471.PP
472Or install it \s-1RPM\s0 Style:
473.PP
474.Vb 1
475\& rpm -ta SOURCES/Net-Ping-xxxx.tar.gz
476.Ve
477.PP
478.Vb 1
479\& rpm -ih RPMS/noarch/perl-Net-Ping-xxxx.rpm
480.Ve
481.SH "BUGS"
482.IX Header "BUGS"
483For a list of known issues, visit:
484.PP
485https://rt.cpan.org/NoAuth/Bugs.html?Dist=Net\-Ping
486.PP
487To report a new bug, visit:
488.PP
489https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net\-Ping
490.SH "AUTHORS"
491.IX Header "AUTHORS"
492.Vb 2
493\& Current maintainer:
494\& bbb@cpan.org (Rob Brown)
495.Ve
496.PP
497.Vb 2
498\& External protocol:
499\& colinm@cpan.org (Colin McMillen)
500.Ve
501.PP
502.Vb 2
503\& Stream protocol:
504\& bronson@trestle.com (Scott Bronson)
505.Ve
506.PP
507.Vb 3
508\& Original pingecho():
509\& karrer@bernina.ethz.ch (Andreas Karrer)
510\& pmarquess@bfsec.bt.co.uk (Paul Marquess)
511.Ve
512.PP
513.Vb 2
514\& Original Net::Ping author:
515\& mose@ns.ccsn.edu (Russell Mosemann)
516.Ve
517.SH "COPYRIGHT"
518.IX Header "COPYRIGHT"
519Copyright (c) 2002\-2003, Rob Brown. All rights reserved.
520.PP
521Copyright (c) 2001, Colin McMillen. All rights reserved.
522.PP
523This program is free software; you may redistribute it and/or
524modify it under the same terms as Perl itself.
525.PP
526$Id: Ping.pm,v 1.86 2003/06/27 21:31:07 rob Exp $