feat(proto): Discover NAT candidates from off-path PATH_CHALLENGEs#647
Draft
Frando wants to merge 1 commit into
Draft
feat(proto): Discover NAT candidates from off-path PATH_CHALLENGEs#647Frando wants to merge 1 commit into
Frando wants to merge 1 commit into
Conversation
|
Documentation for this PR has been generated and is available at: https://n0-computer.github.io/noq/pr/647/docs/noq/ Last updated: 2026-05-13T18:37:20Z |
Performance Comparison Report
|
| Scenario | noq | upstream | Delta | CPU (avg/max) |
|---|---|---|---|---|
| large-single | 5631.1 Mbps | 7985.4 Mbps | -29.5% | 96.0% / 101.0% |
| medium-concurrent | 5504.5 Mbps | 7970.0 Mbps | -30.9% | 94.5% / 101.0% |
| medium-single | 3899.4 Mbps | 4749.5 Mbps | -17.9% | 97.4% / 151.0% |
| small-concurrent | 3804.0 Mbps | 5344.1 Mbps | -28.8% | 99.4% / 152.0% |
| small-single | 3511.1 Mbps | 4754.8 Mbps | -26.2% | 91.0% / 101.0% |
Netsim Benchmarks (network simulation)
| Condition | noq | upstream | Delta |
|---|---|---|---|
| ideal | 3067.8 Mbps | 4064.7 Mbps | -24.5% |
| lan | 782.4 Mbps | 810.3 Mbps | -3.4% |
| lossy | 69.8 Mbps | 69.9 Mbps | ~0% |
| wan | 83.8 Mbps | 83.8 Mbps | ~0% |
Summary
noq is 26.5% slower on average
1749cb88ac6fd32463056d0d0b431d4e5872954a - artifacts
Raw Benchmarks (localhost)
| Scenario | noq | upstream | Delta | CPU (avg/max) |
|---|---|---|---|---|
| large-single | 5647.9 Mbps | 7871.5 Mbps | -28.2% | 96.9% / 98.4% |
| medium-concurrent | 5479.2 Mbps | 7862.7 Mbps | -30.3% | 95.9% / 97.7% |
| medium-single | 4263.7 Mbps | 4749.9 Mbps | -10.2% | 96.6% / 98.6% |
| small-concurrent | 3841.8 Mbps | 5257.2 Mbps | -26.9% | 97.7% / 99.7% |
| small-single | 3576.9 Mbps | 4849.8 Mbps | -26.2% | 95.9% / 98.1% |
Netsim Benchmarks (network simulation)
| Condition | noq | upstream | Delta |
|---|---|---|---|
| ideal | 2985.6 Mbps | 3939.8 Mbps | -24.2% |
| lan | 782.4 Mbps | 810.3 Mbps | -3.4% |
| lossy | 69.8 Mbps | 69.8 Mbps | ~0% |
| wan | 83.8 Mbps | 83.8 Mbps | ~0% |
Summary
noq is 24.7% slower on average
When the server is behind a symmetric NAT, its ADD_ADDRESS-advertised reflexive address is mapped only against the relay and is unreachable from the client. The server's own probes do reach the client when the client's NAT is permissive, but they come from a different, NAT-rebound source address. Until now we replied with PATH_RESPONSE and forgot that source, so no path was ever opened. On the client side, treat the source of an incoming off-path PATH_CHALLENGE as a fresh probe target. The client probes back on the 4-tuple the server's NAT just opened, the response matches one of the client's own sent challenges, and the existing client-only path-opening flow opens the path. Sequence ids for discovered addresses walk down from VarInt::MAX so they cannot collide with peer-advertised ADD_ADDRESS ids (which start at 0).
75496b5 to
1749cb8
Compare
flub
reviewed
May 13, 2026
| self.paths_to_be_opened.push(network_path); | ||
| return true; | ||
| } else { | ||
| debug!("inconsistent remote addrs and seq"); |
Collaborator
There was a problem hiding this comment.
Suggested change
| debug!("inconsistent remote addrs and seq"); | |
| self.paths_to_be_opened.push(network_path); | |
| return true; |
I think the entire PR should be replaced by this, probably.
Collaborator
There was a problem hiding this comment.
logically at least, exact code can be written a bit nicer I think
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This is claude's attempt at fixing holepunching when the server is behind a hard NAT - not yet reviewed.
See n0-computer/iroh#4254 for the iroh PR using this to unignore two so-far failing patchbay NAT tests.
When the server is behind a symmetric NAT, its NAT sets a different mapping per destination 4-tuple. Say the server discovers its reflexive address by pinging a relay, let's call it S_relay, and advertises via ADD_ADDRESS. This address is unreachable from the client. When the server sends a PATH_CHALLENGE to the client directly, its NAT sets a fresh binding S_client against the client's address. The client sees an off-path PATH_CHALLENGE arriving from
S_client, a source no ADD_ADDRESS announced.
Old behavior: the client sends a PATH_RESPONSE back to S_client and forgets the source. No path is ever opened, because the server never opens paths.
New behavior: the client treats S_client as a fresh probe target and sends its own PATH_CHALLENGE there. The server's NAT recognizes return traffic on the binding it just defined and forwards it through. The PATH_RESPONSE matches one of the client's outstanding challenges, and the existing client-only path-opening flow opens the path.
Sequence ids for discovered addresses walk down from VarInt::MAX so they cannot collide with peer-advertised ADD_ADDRESS ids (which start at 0).
Breaking Changes
Notes & open questions
Change checklist