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

core/: Concurrent connection attempts - aka. happy eyeball #1896

Closed
quininer opened this issue Dec 18, 2020 · 6 comments
Closed

core/: Concurrent connection attempts - aka. happy eyeball #1896

quininer opened this issue Dec 18, 2020 · 6 comments

Comments

@quininer
Copy link
Contributor

I noticed that libp2p currently only tries next address when one address fails, which causes some users to wait a long time when trying to connect to an unavailable ipv6 address.

Maybe we can try to use a fast fallback strategy like happy eyeballs v2 to quickly connect to available addresses.

I don't know if there are some special reasons that limit connection strategy of libp2p, if not, I will be happy to implement one.

@quininer
Copy link
Contributor Author

I checked the implementation of the connection pool, which may be a lot of work.

At present, we can use dial_addr to try concurrent connections.

@mxinden mxinden changed the title happy-eyeballs like strategy core/: Parallel connection attemps - aka. happy eyeball Jul 23, 2021
@mxinden
Copy link
Member

mxinden commented Jul 23, 2021

I am re-opening this issue. While complex for sure, it would greatly benefit hole punching.

When two peers coordinate a hole punch via the Direct Connection Upgrade through Relay protocol, each peer sends the remote a list of protocols to dial. Given that both sides need to simultaneously dial an address in order for a hole punch to suceed, one can not expect a high hole punch success rate when trying each address sequentially.

Given that rust-libp2p does not support parallel dialing today the rust-libp2p DCUtR implementation only attempts to dial the first address provided by the remote peer. Though it could instead emit multiple DialAddress requests at once.

@mxinden mxinden reopened this Jul 23, 2021
@mxinden mxinden changed the title core/: Parallel connection attemps - aka. happy eyeball core/: Parallel connection attempts - aka. happy eyeball Jul 23, 2021
@mxinden mxinden mentioned this issue Jul 23, 2021
14 tasks
@mxinden mxinden changed the title core/: Parallel connection attempts - aka. happy eyeball core/: Concurrent connection attempts - aka. happy eyeball Aug 31, 2021
mxinden added a commit that referenced this issue Oct 14, 2021
Concurrently dial address candidates within a single dial attempt.

Main motivation for this feature is to increase success rate on hole punching
(see #1896 (comment)
for details). Though, as a nice side effect, as one would expect, it does
improve connection establishment time.

Cleanups and fixes done along the way:

- Merge `pool.rs` and `manager.rs`.

- Instead of manually implementing state machines in `task.rs` use
  `async/await`.

- Fix bug where `NetworkBehaviour::inject_connection_closed` is called without a
  previous `NetworkBehaviour::inject_connection_established` (see
  #2242).

- Return handler to behaviour on incoming connection limit error. Missed in
  #2242.
@mxinden
Copy link
Member

mxinden commented Oct 14, 2021

Implemented in #2248.

@mxinden mxinden closed this as completed Oct 14, 2021
santos227 pushed a commit to santos227/rustlib that referenced this issue Jun 20, 2022
Concurrently dial address candidates within a single dial attempt.

Main motivation for this feature is to increase success rate on hole punching
(see libp2p/rust-libp2p#1896 (comment)
for details). Though, as a nice side effect, as one would expect, it does
improve connection establishment time.

Cleanups and fixes done along the way:

- Merge `pool.rs` and `manager.rs`.

- Instead of manually implementing state machines in `task.rs` use
  `async/await`.

- Fix bug where `NetworkBehaviour::inject_connection_closed` is called without a
  previous `NetworkBehaviour::inject_connection_established` (see
  libp2p/rust-libp2p#2242).

- Return handler to behaviour on incoming connection limit error. Missed in
  libp2p/rust-libp2p#2242.
@mxinden
Copy link
Member

mxinden commented Oct 4, 2022

Cross referencing libp2p/go-libp2p#1785 by @marten-seemann here. I think long-term rust-libp2p should adopt an advanced address prioritization like go-libp2p.

@thomaseizinger
Copy link
Contributor

Onw property that I'd like to point out is that currently, we use transports in the order they are combined in. That is nice IMO.

@mxinden
Copy link
Member

mxinden commented May 8, 2023

On the matter of smart dialing mechanism, corresponding work on the Go side: libp2p/go-libp2p#2260

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants