Crate libp2p_ping
source ·Expand description
This module implements the /ipfs/ping/1.0.0
protocol.
The ping protocol can be used as a simple application-layer health check
for connections of any Transport
as well as to measure and record
round-trip times.
Usage
The Behaviour
struct implements the NetworkBehaviour
trait.
It will respond to inbound ping requests and periodically send outbound ping requests on every established connection.
It is up to the user to implement a health-check / connection management policy based on the ping protocol.
For example:
- Disconnect from peers with an RTT > 200ms
- Disconnect from peers which don’t support the ping protocol
- Disconnect from peers upon the first ping failure
Users should inspect emitted Event
s and call APIs on Swarm
:
Swarm::close_connection
to close a specific connectionSwarm::disconnect_peer_id
to close all connections to a peer
Structs
- A
NetworkBehaviour
that responds to inbound pings and periodically sends outbound pings on every established connection. - The configuration for outbound pings.
- Event generated by the
Ping
network behaviour.
Enums
- An outbound ping failure.