Files
piik/prototype
T
AAA a66d49e1eb fix(native): probe distinct ports in the random UDP search
The searching side of a random-port preparation sent 512 requests but
cycled twice over the same 256 ports. Coverage, not the number of requests,
sets the chance that a probe reaches one of the peer's 256 mappings: with M
mappings and N distinct targets in a pool of R ports the idealized hit
probability is 1 - exp(-M*N/R), as docs/research/nat-traversal.md records.
For M = 256 and R = 64,512 that is 63% at N = 256 and 87% at N = 512, for
the same packets, pacing and deadline.

A second pass over one set only protects against a lost request, and it
loses to distinct targets at any loss rate: at 30% loss the repeated set
covers about 233 ports and the distinct set about 358. The peer signals
Ready after its mappings exist, so a first probe is not early.

The request budget stays 520 and the pool side is unchanged. Lab evidence
in nat-traversal.md was taken with 256 targets and is not re-measured here.

Reference: https://tailscale.com/blog/how-nat-traversal-works (birthday
search against a hard NAT).
a66d49e1eb · 2026-11-24 23:12:07 +08:00
History
..