A small tool based of the libp2p ping example, that is using the test handshake config found in libp2p-test-handshake.
The tool will panic if any Incoming/Outgoing connection errors are encountered, otherwise, it will print out the ping events.
-
In a first terminal window, run the following command:
cargo run
This command starts a node and prints the
PeerId
and the listening addresses, such asListening on "/ip4/0.0.0.0/tcp/24915"
. -
In a second terminal window, start a new instance of the example with the following command:
cargo run -- /ip4/127.0.0.1/tcp/24915
Replace
/ip4/127.0.0.1/tcp/24915
with the listen address of the first node obtained from the first terminal window. -
The two nodes will establish a connection, negotiate the ping protocol, and begin pinging each other.