Trace how devices behind NAT discover candidates, test direct paths, fall back to relays, or use brokered IoT control.
animation
nat
networking
stun
turn
ice
iot-connectivity
Learner-ready NAT traversal workbench with STUN, TURN, ICE, port mapping, cloud broker, NAT behavior controls, candidate diagnostics, relay cost, security guidance, source links, and local desktop/mobile visual verification.
Foundation networkingSTUN / TURN / ICEIoT remote access
NAT Traversal Workbench
Watch an IoT device behind a private router create an outbound mapping, learn the public address a peer sees, test direct connectivity, and then decide whether the safe design is direct, relayed, brokered, or blocked.
DiagnosisICE should try direct candidates first, then keep TURN ready.
Selected routeServer-reflexive direct
Extra latency32 ms
Current phaseGather candidates
TryChoose Home router, Technique STUN and UDP hole punching, UDP mapping timeout 60 s, and a peer with endpoint-independent filtering.
ObserveSTUN reveals public mapping 198.51.100.88:41032 and Selected route becomes direct; the keepalive recommendation stays below 60 s to preserve it.
ExplainOutbound traffic creates a private-to-public tuple mapping; direct return works only when mapping and filtering admit the peer, otherwise ICE escalates to TURN relay.
Technical boundariesRule-based NAT types omit real ICE checklist pacing, consent freshness, hairpinning, IPv6, TCP simultaneous open, port exhaustion, CGN cascades, firewall DPI, mapping jitter, and relay capacity.
NAT mappingA private address such as 192.168.1.50:51000 is rewritten to a public address and port when the device sends outbound traffic.
Inbound defaultPackets from the internet are normally dropped unless they match an existing mapping or an explicit port mapping rule.
Reflexive addressSTUN reports the public IP and port that a server observes; it does not guarantee that every peer can use that address.
Relay fallbackTURN relays media or packets when a direct path fails, trading reliability for latency and server bandwidth cost.
Scenario set
Traversal controls
Change the network conditions and compare direct, relay, broker, and router-mapping approaches.
Guided task flow
Private LANInternet servicesPeer network
IoT device192.168.1.50:51000
NAT A203.0.113.42:62014
STUNpublic mapping discovery
TURNrelay candidate
Brokeroutbound IoT control
NAT B198.51.100.88:41032
Phone or peer10.20.0.9:52000
Gather candidatesThe device contacts STUN to learn the public endpoint. ICE treats this as a server-reflexive candidate, then proves whether the peer can actually reach it.
Candidate set
ICE ranks candidates by preference, but only a successful connectivity check should be used.
NAT mapping table
Outbound traffic creates the table entries that inbound packets must match.
Diagnosis
Direct server-reflexive media is available in this home-router scenario, with TURN kept as a fallback.
Event log
Each row links the packet flow to the decision the application should make.
STUNDiscovers a server-reflexive address. It is cheap and fast, but it is not a relay and does not bypass every NAT.
TURNAllocates a relay address. It works when direct checks fail, but every packet consumes relay capacity.
ICEGathers host, server-reflexive, and relay candidates, runs checks, and nominates a working pair.
IoT defaultFor commands and telemetry, prefer outbound TLS to a broker or cloud service instead of exposing device ports.
Technical notes and primary sources
NAT type languageThe old cone/symmetric labels are convenient shorthand. The more precise model separates mapping behavior from filtering behavior.
Why STUN can misleadWith address-and-port-dependent mapping, the public endpoint observed by a STUN server may not be the endpoint used for a peer.
Security boundaryPort forwarding creates a public attack surface. Use VPN, identity-aware tunnels, brokered commands, and TLS rather than exposing embedded web consoles.