A multiaddress is a self-describing network address that represents a peer’s location. It combines transport details with the peer ID needed to identify the destination. section 11.2.1 section 11.2.2
Read a multiaddress as an ordered description of how to reach a node:
- The transport portion identifies the network protocol, IP address, and listening port, such as /ip4/192.158.1.23/tcp/1234. section 11.2.2
- The peer portion identifies the destination node, such as /p2p/12D3KooWBu3fmjZgSMLkQ2p1DG35UmEayYBrhsk6WEe1xco1JFbV. section 11.2.2
- The complete address combines both parts: /ip4/192.158.1.23/tcp/1234/p2p/12D3KooWBu3fmjZgSMLkQ2p1DG35UmEayYBrhsk6WEe1xco1JFbV. section 11.2.2
Dialing a peer with libp2p
A Rust node can parse a command-line argument as a Multiaddr and pass it to swarm.dial. One node listens on /ip4/0.0.0.0/tcp/0, prints its assigned address, and a second node starts with that address as its argument. The nodes then connect and exchange ping-pong messages. section 11.3
/ip4/192.158.1.23/tcp/1234/p2p/12D3KooWBu3fmjZgSMLkQ2p1DG35UmEayYBrhsk6WEe1xco1JFbV
Inspect the complete address as a concrete composition of IPv4, TCP, and peer-ID components. section 11.2.2
