Assuming host A B both behind NAT on the internet.
STUN: Session Traversal Utilities for NAT
A B talk to STUN server to know each other’s external IP and port state for hole punching.
The goal is to let A B directly talk to each other on UCP and sometimes TCP, if NAT is not symmetric.
This public IP is also needed in RTSP SDP when RTP over UDP.
STUN server itself communicates over UDP by default.
TURN: Traversal Using Relays around NAT
A first asks TURN server a permission, and then A sends all data to TURN, which is relayed to B.
Used for some NAT TCP, when hole punching doesn’t work.
ICE: Interactive Connectivity Establishment
Just a combination of STUN and TURN, and automatically switches between the two.