[][src]Module libp2prs_swarm::ping

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 [PingHandler] struct implements the ProtocolHandler trait. When used with a Swarm, it will respond to inbound ping requests and as necessary periodically send outbound ping requests on every established connection. If a configurable number of pings fail, the connection will be closed.

The [PingHandler] produces [PingResult]s, which will be consumed by the Swarm , e.g. to close the Connection.

Note: The ping protocol does not keep otherwise idle connections alive, it only adds an additional condition for terminating the connection, namely a certain number of failed ping requests.

Structs

PingConfig

The configuration for outbound pings.

Functions

ping