libp2p / libp2p/go-libp2p

swarm: inconsistent listening address reporting

Open
#2,067 13 comments 0 reactions 0 assignees View on GitHub
P3
Dominant language
Go
Stars
6.9k
Forks
1.3k
Avg merge
13d 21h
Merged PRs (30d)
1

Description

During our [`punchr`](https://github.com/libp2p/punchr) measurement campaign, we observed that the listening addresses returned by `host.Addrs()` didn't match the ones that were used during a hole punch.

After a `punchr` client has requested a peer to hole punch, it immediately makes a note of all the addresses it is listening on ([here](https://github.com/libp2p/punchr/blob/4d2343ff01f2250a7b88314dde0fa2e6ca9a1775/pkg/client/host.go#L302)). In our database, we find plenty of cases where the client reported a set of listening addresses that didn't contain any public address but still a successful hole punch.

I saw that go-libp2p calls `OwnObservedAddrs` on the ID service [here](https://github.com/libp2p/go-libp2p/blob/313b080ea4e27f47dbfb9f872133b9fba4a9d183/p2p/protocol/holepunch/svc.go#L173). This is also used if no port mappings are in use [here](https://github.com/libp2p/go-libp2p/blob/313b080ea4e27f47dbfb9f872133b9fba4a9d183/p2p/host/basic/basic_host.go#L944). `punchr` clients also reported if they've had active port mappings in place. If we only consider the ones with no port mapping, we still end up with plenty of successful hole punches.

The only explanation that comes to my mind is that from extracting the listening addresses before the hole punch until we are transmitting all addresses to the remote peer, the set of listening addresses has changed.

Could this have something to do with #2046 ?

I have documented the distribution of hole punch outcomes for peers that reported to listen on a public address [here in Notion](https://www.notion.so/pl-strflt/Final-Report-NAT-Hole-Punching-Measurement-Campaign-94366124f4e34b29bf55fb860a3d8c72#dd8f6e54043b4190bdefcf362cfc74f2).

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the hole-punch address handling in p2p/protocol/holepunch/svc.go and the listening-address logic in p2p/host/basic/basic_host.go, then compare them with punchr/pkg/client/host.go. Investigate whether the address set can change between reporting and transmission, and review #2046 for related behavior. Done means identifying and reproducing the cause of the inconsistent addresses.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.