Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transport hole punching #873

Merged
merged 51 commits into from
Apr 6, 2023
Merged

Transport hole punching #873

merged 51 commits into from
Apr 6, 2023

Conversation

diegomrsantos
Copy link
Collaborator

@diegomrsantos diegomrsantos commented Mar 7, 2023

Previously, when dialing a peer using the TcpTransport, the OS randomly chose the socket local port. It means that when an internal peer dials a remote one, the latter will always observe a random port. But to do TCP hole punching, we need a stable and predictable public port that will be advertised to the peers we want to create a TCP simultaneous open. This is known as the NAT port prediction problem.

To solve this problem, we add the possibility of binding to the TCP listening port before dialing remote peers in this PR. The TCP transport will always bind when the peer's network reachability is "not reachable" and not bind otherwise. We assume the NAT uses the port preservation scheme, i.e. it maps the source port of the internal peer to the same public port.

More info:

Base automatically changed from observed-addr-manager to unstable March 24, 2023 15:42
# Conflicts:
#	.pinned
#	libp2p/observedaddrmanager.nim
#	libp2p/peerstore.nim
#	libp2p/protocols/connectivity/autonat/service.nim
#	libp2p/protocols/identify.nim
#	tests/testautonatservice.nim
#	tests/testobservedaddrmanager.nim
@diegomrsantos diegomrsantos marked this pull request as ready for review March 27, 2023 13:40
.pinned Outdated Show resolved Hide resolved
@diegomrsantos diegomrsantos dismissed a stale review via f579c12 April 5, 2023 14:35
@diegomrsantos diegomrsantos merged commit 0041ed4 into unstable Apr 6, 2023
@diegomrsantos diegomrsantos deleted the transport-hole-punching branch April 6, 2023 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants