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
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).
|
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-12T09:31:01Z |
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
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 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).
Breaking Changes
Notes & open questions
Change checklist