liveBook · Manning

Multiaddress

As explained in Rust Servers, Services, and Apps

A multiaddress is a self-describing network address format that can encode the protocols and endpoint information needed to reach a network node.

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

How Rust Servers, Services, and Apps covers it

How deep it goes
Explains address components and demonstrates parsing and dialing, stopping short of detailed protocol implementation.
Examples
Uses IPv4/TCP address strings, peer-ID suffixes, command-line dialing, and a two-node ping-pong exchange.
What it assumes
Assumes understanding of peer IDs and introduces their combination with transport addresses.
What you can do after
Build and test a Rust libp2p node that listens on, parses, and dials multiaddresses.
How it connects
Connects peer IDs, transport protocols, libp2p, Swarm, and asynchronous Rust networking.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Rust Servers, Services, and Apps. The section links point to the parts of the book it draws on.