|Alias => $session_alias||Alias sets the components alias. It is the target of post() calls. See the synopsis. The alias defaults to pinger.|
|Socket => $raw_socket||Socket allows developers to open an existing raw socket rather than letting the component attempt opening one itself. If omitted, the component will create its own raw socket.|
|Timeout => $ping_timeout||
Timeout sets the default amount of time (in seconds) a Ping
component will wait for a single ICMP echo reply before retrying. It
is 1 by default. It is possible and meaningful to set the timeout to
a fractional number of seconds.
This default timeout is only used for ping requests that dont include their own timeouts.
|Retry => $ping_attempts||Retry sets the default number of attempts a ping will be sent before it should be considered failed. It is 1 by default.|
|OneReply => 0|1||
Set OneReply to prevent the Ping component from waiting the full
timeout period for replies. Normally the ICMP protocol allows for
multiple replies to a single request, so its proper to wait for late
responses. This option disables the wait, ending the ping transaction
at the first response. Any subsequent responses will be silently
OneReply is disabled by default, and a single successful request will generate at least two responses. The first response is a successful ICMP ECHO REPLY event. The second is an undefined response event, signifying that the timeout period has ended.
|Parallelism => $limit||
Parallelism sets POE::Component::Client::Pings maximum number of
simultaneous ICMP requests. Higher numbers speed up the processing of
large host lists, up to the point where the operating system or
network becomes oversaturated and begin to drop packets.
The difference can be dramatic. A tuned Parallelism can enable responses down to 1ms, depending on the network, although it will take longer to get through the hosts list.
Responses will take significantly longer with an untuned Parallelism, but the total run time will be quicker.
Excessively high parallelism values may saturate the OS or network, resulting in few or no responses.
By default, POE::Component::Client::Ping will guess at an optimal Parallelism value based on the raw socket receive buffer size and the operating systems nominal ICMP packet size. The latter figure is 3000 octets for Linux and 100 octets for other systems. ICMP packets are generally under 90 bytes, but operating systems may use alternative numbers when calculating buffer capacities. The component tries to mimic calculations observed in the wild.
When in doubt, experiment with different Parallelism values and use the one that works best.
|BufferSize => $bytes||
If set, then the size of the receive buffer of the raw socket will be
modified to the given value. The default size of the receive buffer is
operating system dependent. If the buffer cannot be set to the given
value, a warning will be generated but the system will continue
working. Note that if the buffer is set too small and too many ping
replies arrive at the same time, then the operating system may discard
the ping replies and mistakenly cause this component to believe the
ping to have timed out. In this case, you will typically see discards
being noted in the counters displayed by netstat -s.
Increased BufferSize values can expand the practical limit for Parallelism.
|AlwaysDecodeAddress => 0|1||If set, then any input addresses will always be looked up, even if the hostname happens to be only 4 characters in size. Ideally, you should be passing addresses in to the system to avoid slow hostname lookups, but if you must use hostnames and there is a possibility that you might have short hostnames, then you should set this.|
|Payload => $bytes||Sets the ICMP payload (data bytes). Otherwise the component generates 56 data bytes internally. Note that some firewalls will discard ICMP packets with nonstandard payload sizes.|
Requests are posted to the components ping handler. They include the name of an event to post back, an address to ping, and an optional amount of time to wait for responses. The address may be a numeric dotted quad, a packed inet_aton address, or a host name. Host names are not recommended: they must be looked up for every ping request, and DNS lookups can be very slow. The optional timeout overrides the one set when spawn is called.
Ping responses come with two array references:
my ($request, $response) = @_[ARG0, ARG1];
$request contains information about the original request:
$req_address, $req_timeout, $req_time, $req_user_args,
) = @$request;
This is the original request address. It matches the address posted
along with the original ping request.
It is useful along with $req_user_args for pairing requests with their corresponding responses.
|$req_timeout||This is the original request timeout. Its either the one passed with the ping request or the default timeout set with spawn.|
|$req_time||This is the time that the ping event was received by the Ping component. It is a real number based on the current systems time() epoch.|
This is a scalar containing arbitrary data that can be sent along with
a request. Its often used to provide continuity between requests and
their responses. $req_user_args may contain a reference to some
larger data structure.
To use it, replace the response event with an array reference in the original request. The array reference should contain two items: the actual response event and a scalar with the context data the program needs back. See the SYNOPSIS for an example.
my ($response_address, $roundtrip_time, $reply_time, $reply_ttl) =
This is the address that responded to the ICMP echo request. It may
be different than $request_address, especially if the request was
sent to a broadcast address.
$response_address will be undefined if $request_timeout seconds have elapsed. This marks the end of responses for a given request. Programs can assume that no more responses will be sent for the request address. They may use this marker to initiate another ping request.
|$roundtrip_time||This is the number of seconds that elapsed between the ICMP echo requests transmission and its corresponding responses receipt. Its a real number. This is purely the trip time and does *not* include any time spent queueing if the systems parallelism limit caused the ping transmission to be delayed.|
|$reply_time||This is the time when the ICMP echo response was received. It is a real number based on the current systems time() epoch.|
|$reply_ttl||This is the ttl for the echo response packet we received.|
REQ_ADDRESS, REQ_TIMEOUT, REQ_TIME REQ_USER_ARGS, RES_ADDRESS, RES_ROUNDTRIP, RES_TIME, RES_TTL
This components ICMP ping code was lifted from Net::Ping, which is an excellent module when you only need to ping one host at a time.
Also see the test program, t/01_ping.t, in the components distribution.
POE::Component::Client::Ping is Copyright 1999-2009 by Rocco Caputo. All rights are reserved. POE::Component::Client::Ping is free software; you may redistribute it and/or modify it under the same terms as Perl itself.
You can learn more about POE at http://poe.perl.org/
|perl v5.20.3||POE::COMPONENT::CLIENT::PING (3)||2013-11-26|