Skip to content

feat(tests): Add a router with NAT functionality to proto tests#596

Open
flub wants to merge 13 commits intomainfrom
flub/nat-routing-table
Open

feat(tests): Add a router with NAT functionality to proto tests#596
flub wants to merge 13 commits intomainfrom
flub/nat-routing-table

Conversation

@flub
Copy link
Copy Markdown
Collaborator

@flub flub commented Apr 16, 2026

Description

This introduces a new router that simulates a very basic NAT
traversal. Both client and server are behind a NAT that needs to be
opened first.

It makes the Pair have fixed SocketAddr for the client and server
TestEndpoints. These SocketAddrs are never bound so we may as well
keep them consistent and follow an easy pattern.

It introduces a trait for the routing table, so as to not interfere
with the routing table from the proptests. I did not know how to turn
that routing table into NAT router that would be
comprehensible. Creating a new one seemed the easier solution. We can
now add more specific routers as well which could be handy.

Finally it cleans up the CLIENT_PORTS, SERVER_PORTS globals, they
really were a left over from the real socket binding functionality
removed in #537.

Breaking Changes

n/a

Notes & open questions

The newly added test currently only demonstrates this. It does not yet
do anything useful. It should probably be removed and be part of the
follow up PR I will make that builds on this. But I thought it would
be better to split off this functionality into its own PR.

Change checklist

  • Self-review.
  • Documentation updates following the style guide, if relevant.
  • Tests if relevant.

flub added 3 commits April 16, 2026 17:59
This introduces a new router that simulates a very basic NAT
traversal. Both client and server are behind a NAT that needs to be
opened first.

It makes the Pair have fixed SocketAddr for the client and server
TestEndpoints. These SocketAddrs are never bound so we may as well
keep them consistent and follow an easy pattern.

It introduces a trait for the routing table, so as to not interfere
with the routing table from the proptests. I did not know how to turn
that routing table into NAT router that would be
comprehensible. Creating a new one seemed the easier solution. We can
now add more specific routers as well which could be handy.
This was some left over from when there was a method to bind sockes
for real. Which we removed already.
@flub flub marked this pull request as draft April 16, 2026 17:26
@n0bot n0bot bot added this to iroh Apr 16, 2026
@github-project-automation github-project-automation bot moved this to 🚑 Needs Triage in iroh Apr 16, 2026
Comment thread noq-proto/src/tests/random_interaction.rs Outdated
@flub flub requested a review from matheus23 April 16, 2026 18:16
Comment thread noq-proto/src/tests/util.rs Outdated
@flub flub marked this pull request as ready for review April 17, 2026 11:19
@flub flub requested a review from matheus23 April 17, 2026 11:19
Comment thread noq-proto/src/tests/random_interaction.rs Outdated
Comment thread noq-proto/src/tests/util.rs
Comment on lines +129 to +132
/// Drive both endpoints once, optionally preventing them from receiving traffic.
///
/// Returns `false` if the connection is idle after the step.
pub(super) fn blackhole_step(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you undo moving this function? This seems like needless diff noise, no?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Hum, perhaps. I was hoping this would be fine, but I could do a separate PR if you insist. I found it really hard to have to go look somewhere seemingly random instead of where it is used. It seems like it just drifted away by accident.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's fine if you really want to leave it. But IMO it just makes git blame harder for very little benefit (I mostly navigate by IDE references though, so YMMV).

Comment thread noq-proto/src/tests/util.rs
Comment thread noq-proto/src/tests/util.rs
Comment thread noq-proto/src/tests/util.rs Outdated
@github-project-automation github-project-automation bot moved this from 🚑 Needs Triage to 🏗 In progress in iroh Apr 17, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 17, 2026

Documentation for this PR has been generated and is available at: https://n0-computer.github.io/noq/pr/596/docs/noq/

Last updated: 2026-04-17T16:04:17Z

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 17, 2026

Performance Comparison Report

57573ddf473a0c6dd74feacb34e9cc8352ce23c2 - artifacts

Raw Benchmarks (localhost)

Scenario noq upstream Delta CPU (avg/max)
large-single 5627.3 Mbps 8066.4 Mbps -30.2% 95.1% / 100.0%
medium-concurrent 5526.4 Mbps 7584.4 Mbps -27.1% 96.2% / 149.0%
medium-single 4144.5 Mbps 4631.0 Mbps -10.5% 99.6% / 150.0%
small-concurrent 3910.8 Mbps 5186.9 Mbps -24.6% 92.9% / 102.0%
small-single 3519.4 Mbps 4662.9 Mbps -24.5% 94.4% / 102.0%

Netsim Benchmarks (network simulation)

Condition noq upstream Delta
ideal 3031.3 Mbps 4063.9 Mbps -25.4%
lan 782.4 Mbps 810.3 Mbps -3.4%
lossy 69.8 Mbps 55.9 Mbps +25.1%
wan 83.8 Mbps 83.8 Mbps ~0%

Summary

noq is 24.0% slower on average

---
4e5b4085f58aa838d6fc3b95113bdfcbb98e12ce - artifacts

No results available

---
d8410f22d72fb28b7074046cbdad41edc201421c - artifacts

Raw Benchmarks (localhost)

Scenario noq upstream Delta CPU (avg/max)
large-single 5659.8 Mbps 7975.4 Mbps -29.0% 98.2% / 148.0%
medium-concurrent 5456.8 Mbps 7736.6 Mbps -29.5% 98.0% / 149.0%
medium-single 3867.1 Mbps 4611.6 Mbps -16.1% 92.0% / 100.0%
small-concurrent 3908.4 Mbps 5286.9 Mbps -26.1% 96.0% / 102.0%
small-single 3540.7 Mbps 4737.7 Mbps -25.3% 97.5% / 151.0%

Netsim Benchmarks (network simulation)

Condition noq upstream Delta
ideal 3117.8 Mbps 4064.7 Mbps -23.3%
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 25.1% slower on average

@flub flub requested a review from matheus23 April 17, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🏗 In progress

Development

Successfully merging this pull request may close these issues.

2 participants