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

swarm: use happy eyeballs ranking for TCP dials #2573

Merged
merged 9 commits into from
Oct 19, 2023

Conversation

sukunrt
Copy link
Member

@sukunrt sukunrt commented Sep 15, 2023

The required change is much simpler than my previous tries. Closing other open PRs in favour of this.

Copy link
Contributor

@marten-seemann marten-seemann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we also need to use this for WebTransport? WebTransport also has a two-step handshake: The QUIC handshake finishes first, then we do the WebTransport session setup.

core/transport/transport.go Outdated Show resolved Hide resolved
p2p/net/swarm/dial_worker.go Outdated Show resolved Hide resolved
p2p/transport/tcp/tcp.go Outdated Show resolved Hide resolved
p2p/net/swarm/dial_ranker.go Show resolved Hide resolved
p2p/net/swarm/dial_ranker.go Outdated Show resolved Hide resolved
p2p/net/swarm/dial_ranker.go Show resolved Hide resolved
@marten-seemann marten-seemann linked an issue Oct 17, 2023 that may be closed by this pull request
@sukunrt sukunrt force-pushed the sukun/happy-eyeballs-tcp-4 branch 3 times, most recently from 0bea85f to a92d4e7 Compare October 18, 2023 14:06
@sukunrt
Copy link
Member Author

sukunrt commented Oct 18, 2023

@marten-seemann Addressed review comments. I'll take webtransport up in a later PR.

copy(addrs[2:], addrs[1:i])
for j := 1; j < len(addrs); j++ {
if isQUICAddr(addrs[j]) && isProtocolAddr(addrs[j], ma.P_IP4) {
// The first IPv4 address is at position i
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't i always 0 here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad. This should be j.

// If the first address is (QUIC, IPv6), make the second address (QUIC, IPv4).
happyEyeballs := false
if len(addrs) > 0 {
// addrs is now sorted by (Transport, IPVersion). Reorder addrs for happy eyeballs dialing.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this sorting logic be part of score?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if that'd be more readable. For this ranking we need to look at other addresses, so an IPv4 address gets higher score than other IPv6 addresses only if there are some IPv6 addresses present. I think the present implementation makes the logic explicit.

p2p/net/swarm/dial_ranker.go Outdated Show resolved Hide resolved
@sukunrt sukunrt merged commit f4b7369 into master Oct 19, 2023
11 checks passed
@sukunrt sukunrt deleted the sukun/happy-eyeballs-tcp-4 branch October 19, 2023 10:20
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.

Implement Happy Eyeballs for TCP
2 participants