Glossary

addr Message (Address Relay)

An addr message shares IP addresses of known Bitcoin nodes to help peers discover and connect to the network.

Key Takeaways

  • The addr message is Bitcoin's primary mechanism for peer discovery: nodes gossip the IP addresses of other known nodes so that new and existing peers can find each other without relying on centralized directories.
  • BIP-155 introduced the addrv2 upgrade, replacing the fixed 128-bit address field with a variable-length format that supports Tor v3, I2P, and CJDNS addresses alongside IPv4 and IPv6.
  • Bitcoin Core's address manager uses bucketed tables with keyed hashing and feeler connections to resist eclipse attacks that attempt to isolate a node by flooding it with attacker-controlled addresses.

What Is an addr Message?

An addr message is a peer-to-peer network message in the Bitcoin protocol that carries a list of IP addresses (and ports) of known nodes. When one node sends an addr message to another, it is sharing information about where additional peers can be found on the network. This decentralized address relay system allows Bitcoin to operate without any central server that tracks all participants.

Every Bitcoin node maintains a database of peer addresses. When a node first joins the network, it typically bootstraps from DNS seeds or hardcoded bootstrap nodes. After establishing initial connections, the node uses addr messages to learn about more peers, gradually building a diverse view of the network. On subsequent startups, the node can reconnect directly to peers it has previously verified, skipping the DNS seed step entirely.

How It Works

Address relay in Bitcoin operates through two complementary mechanisms: nodes actively announce their own presence and passively forward addresses they receive from others. Together, these mechanisms ensure that reachable nodes become known across the network within hours.

Message Format

The original addr message (defined in the Bitcoin protocol since its earliest versions) carries up to 1,000 address entries. Each entry contains four fields:

  • Timestamp: a 4-byte Unix timestamp indicating when the address was last known to be active
  • Services: a bitfield describing which services the node offers (such as full block serving, bloom filtering, or witness data)
  • IP address: a 16-byte field that holds either a native IPv6 address or an IPv4 address mapped into the IPv6 space (using the ::ffff:0:0/96 prefix)
  • Port: a 2-byte network port number (default 8333 for mainnet)
// Legacy addr message entry layout (30 bytes per entry)
+------------+----------+------------------+------+
| timestamp  | services | address (IPv6)   | port |
| 4 bytes    | 8 bytes  | 16 bytes         | 2 B  |
+------------+----------+------------------+------+

// Example: an IPv4 node at 192.168.1.1:8333
timestamp:  0x67890ABC   (Unix epoch seconds)
services:   0x0000000000000001  (NODE_NETWORK)
address:    00000000 00000000 0000FFFF C0A80101
port:       0x208D   (8333)

Nodes must reject any addr message containing more than 1,000 entries to prevent memory exhaustion. A single message typically carries far fewer: unsolicited announcements usually contain 1 to 10 addresses.

Self-Announcement and Relay

Every listening node periodically announces its own address to its connected peers. In Bitcoin Core, these self-announcements follow a randomized schedule with a mean interval of approximately 24 hours per peer, using an exponential distribution to avoid creating predictable traffic patterns.

When a node receives an addr message, it decides whether to forward those addresses to its other peers based on several criteria:

  1. The message must contain at most 10 address entries (larger messages are treated as responses to a getaddr request and are not relayed)
  2. Each address must have a timestamp no more than 10 minutes in the future
  3. The address must be routable (not a private or reserved IP range)
  4. A per-neighbor filter prevents the same address from being forwarded to the same peer more than once

These rules prevent amplification attacks where a malicious node floods the network with junk addresses. Incoming addr processing is further governed by a token-bucket rate limiter that averages approximately 0.1 addresses per second per connection, with bursts up to 1,000 for handling getaddr responses.

The getaddr Request

A node can explicitly request addresses from a peer by sending a getaddr message. The peer responds with an addr message containing up to 1,000 addresses sampled from its database, capped at 23% of its total known addresses. This cap prevents any single peer from learning a node's entire address table, which would make mapping the network easier for adversaries.

The Address Manager

Bitcoin Core stores received addresses in a structure called AddrMan, which is specifically designed to resist manipulation. AddrMan maintains two tables:

  • New table: holds addresses the node has heard about through gossip but has never connected to
  • Tried table: holds addresses the node has successfully connected to in the past

Both tables are divided into buckets, and each address is assigned to a bucket using a keyed hash function. The key is a randomly generated 256-bit secret unique to each node. This means an attacker cannot predict which bucket an address will land in, making it difficult to systematically fill every bucket with malicious entries.

To verify addresses in the new table, Bitcoin Core periodically initiates feeler connections: short-lived outgoing connections (approximately every two minutes) to randomly selected new-table addresses. If a feeler connection succeeds, the address moves to the tried table. This mechanism ensures the tried table contains only addresses that have been independently verified as reachable.

The addrv2 Upgrade (BIP-155)

The original addr message encodes all addresses in a fixed 16-byte IPv6 field. IPv4 addresses fit by using IPv4-mapped IPv6 encoding, and Tor v2 addresses were squeezed in using the OnionCat prefix. But when Tor v3 moved to 256-bit addresses and I2P adopted 256-bit hashes, these no longer fit in 16 bytes.

BIP-155, authored by Wladimir J. van der Laan, introduced the addrv2 message to solve this problem. Shipped in Bitcoin Core 0.21 (January 2021), addrv2 replaces the fixed address field with a network ID byte followed by a variable-length address. This allows the protocol to support any address format without further message changes.

Supported Network Types

Network IDNameAddress LengthDescription
0x01IPv44 bytesStandard IPv4 address
0x02IPv616 bytesStandard IPv6 address
0x03Tor v210 bytesObsolete (Tor v2 is no longer operational)
0x04Tor v332 bytesEd25519 public key for .onion v3 services
0x05I2P32 bytesSHA-256 hash of the I2P destination
0x06CJDNS16 bytesIPv6 address in the fc00::/8 range

Two peers negotiate addrv2 support during the version handshake by exchanging a sendaddrv2 message. If both sides signal support, all subsequent address relay uses addrv2. Otherwise, nodes fall back to the legacy addr format. Clients must ignore unknown network IDs and reject entries whose address length does not match the expected size for a known network ID.

// addrv2 entry layout (variable length)
+------------+----------+--------+---------+------+
| timestamp  | services | net_id | address | port |
| 4 bytes    | compact  | 1 byte | varies  | 2 B  |
+------------+----------+--------+---------+------+

// services uses CompactSize encoding (1-8 bytes)
// address length is determined by network ID:
//   IPv4=4, IPv6=16, TorV3=32, I2P=32, CJDNS=16

Why It Matters

Address relay is foundational to Bitcoin's decentralization. If nodes cannot discover each other organically, the network becomes dependent on a small number of hardcoded entry points, creating censorship vectors and single points of failure. The addr and addrv2 messages ensure that peer knowledge spreads across the network naturally, keeping the topology resilient even as nodes join and leave.

The addrv2 upgrade is particularly important for privacy and censorship resistance. By supporting Tor v3, I2P, and CJDNS natively, Bitcoin nodes can operate over multiple anonymous transport layers and discover peers on those networks through the same gossip mechanism used for clearnet nodes. This multi-network diversity strengthens the network's resistance to both eclipse attacks and state-level surveillance, as described in the eclipse attack mitigation research. Combined with encrypted transport from BIP-324, modern Bitcoin P2P connections are both private and resilient.

For layer-2 protocols built on Bitcoin, robust peer discovery at the base layer is a prerequisite. Nodes running Spark or Lightning rely on a healthy, well-connected Bitcoin P2P network to broadcast and receive transactions. If a node is eclipsed due to poisoned address tables, it cannot reliably verify on-chain state, which undermines the security guarantees of any protocol built on top.

Use Cases

  • Network bootstrapping: new nodes use addr messages received from DNS seeds and initial peers to build their first address database, enabling them to find diverse peers across the network
  • Ongoing peer maintenance: long-running nodes continuously receive addr messages to refresh stale entries and discover newly joined peers, maintaining connection diversity
  • Privacy-preserving connectivity: addrv2 enables nodes to discover and connect to peers on Tor, I2P, and CJDNS networks, allowing operators to run nodes without revealing their IP address
  • Network monitoring: researchers and monitoring tools use addr messages (via getaddr requests) to map the P2P network topology and estimate the number of reachable nodes
  • Eclipse attack defense: the address manager's bucket system, fed by addr messages, ensures that outbound connections are drawn from a diverse pool of addresses rather than a set controlled by a single adversary

Risks and Considerations

Eclipse Attacks via Address Poisoning

An attacker who controls many IP addresses can flood a victim node with addr messages containing only attacker-controlled addresses. If the attacker successfully fills enough of the victim's new and tried buckets, every outbound connection the victim makes will reach an attacker node. This eclipse attack can be used to censor transactions, feed false blockchain data, or facilitate double spends against the isolated node.

Bitcoin Core mitigates this with keyed bucket hashing, feeler connections, anchor peers (persisted outbound connections that survive restarts), block-relay-only connections (which do not participate in address relay), and ASN-aware peer selection that limits connections to any single autonomous system. For a detailed analysis, see the research on P2P network topology resilience.

Address Spam and Resource Exhaustion

Without rate limiting, a malicious peer could send millions of addr entries, consuming memory and CPU. The 1,000-entry cap per message and token-bucket rate limiter (averaging 0.1 addresses per second per connection) prevent this. Nodes that exceed the rate limit have their excess addresses silently dropped.

Deanonymization via Address Observation

Because nodes announce their own address through addr messages, observers can correlate self-announcements with transaction timing to identify which node originated a transaction. This is one reason Bitcoin adopted the Dandelion approach for transaction relay (separating transaction propagation from address announcement) and why BIP-324 encrypted transport makes passive observation harder.

Stale Address Accumulation

Nodes go offline frequently, and addresses in the database can become stale. Bitcoin Core's feeler connections help by periodically testing entries, but the tried table may still contain many unreachable addresses. Stale addresses waste connection attempts and slow down peer discovery after a fresh startup.

This glossary entry is for informational purposes only and does not constitute financial or investment advice. Always do your own research before using any protocol or technology.