ping-0.1.0.2: icmp echo requests

Safe HaskellNone
LanguageHaskell2010

Network.Icmp.Ping

Contents

Synopsis

Functions

host Source #

Arguments

:: Int

Microseconds to wait for response

-> IPv4

Host

-> IO (Either IcmpException (Maybe Word64))

Elapsed nanoseconds

Ping an IPv4 address. Blocks until a response is received.

hosts Source #

Arguments

:: Int

Microseconds to wait for response

-> Set IPv4

Hosts

-> IO (Either IcmpException (Map IPv4 Word64))

Elapsed nanoseconds for responding hosts

Ping a set of hosts simultaneously. Performs one ping for each host and reports the elapsed nanoseconds for the response. If a key is missing from the resulting map, it indicates that a response was not received from that host.

range Source #

Arguments

:: Int

Microseconds to wait for response

-> IPv4Range

Range

-> IO (Either IcmpException (Map IPv4 Word64))

Elapsed nanoseconds for responding hosts

Ping a range of hosts simultaneously.

multihosts Source #

Arguments

:: Int

Microseconds to wait for response

-> Int

Microsecond delay between pings to same host

-> Int

Number of pings per host

-> Int

Nonresponsive cutoff

-> Set IPv4

Hosts

-> IO (Either IcmpException (Map IPv4 (PrimArray Word64))) 

Ping a group of hosts simultaneously. Performs a configurable number of pings for each host and reports the elapsed nanoseconds for each response. If the array of durations is smaller than the total number of pings, it indicates that some ICMP requests for that host were lost or corrupted.

The function also accepts an cutoff for unresponsive hosts. If a host does not respond to the initial number of pings equal to the cutoff, this function does not attempt further pings to the host. Consider the case in which this function performs 20 pings per host with a 5e6 microsecond timeout. Without the unresponsive cutoff, a single nonresponsive host would cause this function to always run for 100 seconds. However, with the cutoff set to 3, this function would stop trying pinging the host after there was no response to any of the first 3 pings. However if there were a response to any of the first 3 pings, then all 20 pings would continue to be sent. This does not necessarily guarantee that this function would run for less than 100 seconds. A host might respond to the initial ping and then go offline. Or a host might take just under 5 seconds to respond to each ping. However, both of these situations are uncommon. What is much more common is that someone includes a bad IP address in the list of hosts, and a low cutoff can considerably reduce the amount of time wasted on such pings. To prevent the cutoff behavior, set it to the number of pings per host.

multirange Source #

Arguments

:: Int

Microseconds to wait for response

-> Int

Microsecond delay between pings to same host

-> Int

Number of pings per host

-> Int

Nonresponsive cutoff

-> IPv4Range

Range

-> IO (Either IcmpException (Map IPv4 (PrimArray Word64)))

Elapsed nanoseconds for responsive hosts

Send multiple pings to each host in a range of hosts simultaneously.

Exceptions

data IcmpException Source #

Constructors

IcmpExceptionSocket !CInt

Could not create the socket

IcmpExceptionSend !CInt

Unable to send when the event manager indicated that the socket was ready for writes.

IcmpExceptionSendBytes !CSize

Unable to send the entirity on an ICMP request. The field is the number of bytes actually sent.

IcmpExceptionReceive !CInt

Unable to receive when the event manager indicated that the socket was ready for reads.

IcmpExceptionClose !CInt

Could not close the socket.