P2P hole punching success: what drives it and how to verify
Any claim of a fixed success percentage deserves suspicion — the rate depends on your network, not the product.
Why no single success rate exists
Feasibility depends on how both NATs behave. Cone NATs usually punch through; symmetric NATs allocate a different port per destination, invalidating the candidates each side learned. Corporate firewalls may block outbound UDP outright.
So the same SDK may connect directly almost everywhere on home broadband while degrading frequently on some mobile networks or hardened office networks. A single cross-environment percentage is meaningless.
Four factors that decide it
- NAT type on both sides: cone versus symmetric is the dominant variable
- Egress policy: whether UDP is allowed and which destination ports are permitted
- Candidate gathering: whether a public mapping address and port are obtained
- Timing: whether both sides' punch attempts overlap in the same window
What should happen when punching fails
The correct engineering answer is an explicit fallback: degrade to a relay so the feature still works, and mark the session report as relayed so product code can warn the user or lower expectations.
The worst implementation is silent failure or a long hang. Availability may degrade; unusability must be announced.
How to measure it yourself
Do not trust marketing numbers — test on your own networks. Run one client on each of two different networks, for example home broadband and a phone hotspot, attempt a connection and record the outcome.
Repeat across times of day and network combinations. Record three things: direct or relayed, time to establish, and the share that fell back to relay. That dataset is your basis for choosing a stack.
Want to see a complete implementation?
MyWebDisk: a personal cloud built on webrpcFAQ
What is a typical success rate?
There is no single value. It depends mainly on both sides' NAT types and firewall policy, so it must be measured in your own networks.
Does it work behind symmetric NAT?
Success drops sharply and the session usually falls back to a relay for availability, with corresponding changes to speed and privacy.
What happens if punching fails?
The session report marks it as relayed so product code can inform the user or adjust expectations rather than failing silently.
Why do corporate networks often fail?
Most often outbound UDP is blocked by policy; an administrator must allow it, or you accept relay fallback.
How can I improve the rate?
Keep outbound UDP available, avoid egress paths with strict symmetric NAT, and handle the degraded path correctly in product code.