2 releases

0.27.1 Nov 6, 2024
0.27.0 Nov 3, 2024

#1933 in Network programming

Download history 214/week @ 2024-11-01 79/week @ 2024-11-08 33/week @ 2024-11-15 24/week @ 2024-11-22 38/week @ 2024-11-29 54/week @ 2024-12-06 17/week @ 2024-12-13

143 downloads per month
Used in 14 crates (via mwc-libp2p)

MIT license

680KB
12K SLoC

Central repository for work on libp2p

dependency status

This repository is the central place for Rust development of the libp2p spec.

Warning: While we are trying our best to be compatible with other libp2p implementations, we cannot guarantee that this is the case considering the lack of a precise libp2p specifications.

Documentation

How to use the library?

Where to ask questions?

  • In the Rust section of https://discuss.libp2p.io.
  • In the #libp2p IRC channel on freenode.
  • By opening an issue in this repository.

Repository Structure

The main components of this repository are structured as follows:

  • core/: The implementation of mwc-libp2p-core with its Network, Transport and StreamMuxer API on which almost all other crates depend.

  • transports/: Implementations of transport protocols (e.g. TCP) and protocol upgrades (e.g. for authenticated encryption, compression, ...) based on the mwc-libp2p-core Transport API .

  • muxers/: Implementations of the StreamMuxer interface of mwc-libp2p-core, e.g. (sub)stream multiplexing protocols on top of (typically TCP) connections. Multiplexing protocols are (mandatory) Transport upgrades.

  • swarm/: The implementation of mwc-libp2p-swarm building on mwc-libp2p-core with the central interfaces NetworkBehaviour and ProtocolsHandler used to implement application protocols (see protocols/).

  • protocols/: Implementations of application protocols based on the mwc-libp2p-swarm APIs.

  • misc/: Utility libraries.

  • examples/: Worked examples of built-in application protocols (see protocols/) with common Transport configurations.

Notable users

(open a pull request if you want your project to be added here)


lib.rs:

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 Ping struct implements the NetworkBehaviour 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 consecutive pings fail, the connection will be closed.

The Ping network behaviour produces PingEvents, which may be consumed from the Swarm by an application, e.g. to collect statistics.

Note: The ping protocol does not keep otherwise idle connections alive by default, see PingConfig::with_keep_alive for changing this behaviour.

Dependencies

~11–16MB
~284K SLoC