Complete Communications Engineering

VOCAL’s software library supports Classic STUN (Simple Traversal of UDP Through NAT).

What is STUN?

Classic STUN Protocol is a client-server protocol that was created to solve some of the issues traversing a Network Address Translator (NAT) for VoIP implementations. Classic STUN works by discovering the presence of a NAT, the type of NAT, and the IP address/port mappings assigned by the NAT. Contact us to discuss your network application requirements.

Consider this example using the SIP protocol. A SIP device with user Bob sits behind a NAT and wants to register its location with a SIP registrar located on the public Internet. The SIP device has a non-routable Private IP address The SIP device registers its location with the registrar as sip:[email protected]:5060. This tells the registrar that Bob can be reached at the IP address at port 5060 (the default SIP port). This private IP address is meaningless to a device on the public Internet and the registrar would not know how to reach Bob.

A second example involves problems in sending RTP media. Alice calls Bob and Alice’s invite contains SDP with her local IP address and media port 1234. Bob accepts Alice’s invite with his SDP containing his local IP address and media port 1234. Both of these IP addresses are meaningless outside the scope of each individual’s private local network and neither party will receive the other’s RTP packets.

A SIP device can use STUN to discover the external IP address of the NAT as well as the port that the NAT has assigned to it. In the first example, before Bob registers with the SIP registrar, his SIP device would send a STUN request from its local IP address and SIP port ( to a STUN server located on the public Internet. The NAT is a Full Cone NAT and has a public IP address of The NAT translates this packet and binds it to an external port 50000. The STUN server sees this packet as having been sent by and inserts this information into its response. When Bob’s SIP device receives this response it now knows that its externally mapped address is Bob can now register his location sip:[email protected]:50000 with the registrar and the registrar will know how to reach Bob in future requests.

In the second example, both Alice and Bob would perform a similar STUN transaction to learn their external NAT address and port mapping and then use that address and port combination in their respective SDPs. Both Alice and Bob would then be able to communicate with each other.

More Information