icmp v0.1.0 Icmp View Source
An OTP-supervised ping (ICMP Echo) server written in pure elixir.
Prerequisites
Currently, this only supports ICMP socket opened in
:raw
mode. In
linux, to use this feature, you must have your
beam.smp
executable
set with raw capabilities:
sudo setcap cap_net_raw=+ep /path/to/beam.smp
Note that this path may depend on if you installed elixir globally, via
a manager such as
asdf
, or if you are running off of a release artifact.
Usage
The Icmp library starts a global ICMP Echo server named
Icmp
in the
VM supervision tree; To use this library, call
Icmp.ping/1
Other options
The Echo server is designed to emit
:pong
on success and
:pang
on failure, to be consistent with the symbols emitted by the
Node
module and erlang distribution. However, these symbols can be
difficult to distinguish in a code setting, leading to errors. If you
would like to change the nature of these values, you may set them
in config:
config :icmp, pong: <your symbol>,
pang: <your symbol>
Link to this section Summary
Functions
Issues an ICMP Echo request to
host
.
Issues an ICMP Echo request to
host
, with a sequence number.
like
start_link/1
, but without linking to the calling process.
starts a standalone ICMP Echo server.
Link to this section Types
state() View Source
Link to this section Functions
ping(addr, timeout \\ 5000, srv \\ __MODULE__)
View Source
ping(
host :: IP.addr() | String.t(),
timeout :: timeout(),
srv :: GenServer.server()
) :: :pong | :pang | {:error, any()}
ping( host :: IP.addr() | String.t(), timeout :: timeout(), srv :: GenServer.server() ) :: :pong | :pang | {:error, any()}
Issues an ICMP Echo request to
host
.
Responds with
:pong
on success, and
:pang
on
failure to recieve a reply within the specified
timeout
.
ping_seq(addr, seq, timeout \\ 5000, srv \\ __MODULE__)
View Source
ping_seq(
host :: IP.addr() | String.t(),
seq :: non_neg_integer(),
timeout :: timeout(),
srv :: GenServer.server()
) :: {:pong, non_neg_integer()} | {:pang, non_neg_integer()} | {:error, any()}
ping_seq( host :: IP.addr() | String.t(), seq :: non_neg_integer(), timeout :: timeout(), srv :: GenServer.server() ) :: {:pong, non_neg_integer()} | {:pang, non_neg_integer()} | {:error, any()}
Issues an ICMP Echo request to
host
, with a sequence number.
Responds with
{:pong, seq}
on success, and
{:pang, seq}
on
failure to recieve a reply within the specified
timeout
.
start(opts \\ []) View Source
like
start_link/1
, but without linking to the calling process.
start_link(opts \\ []) View Source
starts a standalone ICMP Echo server.
Options
-
:name
assigns a name to the server.