STUN vs TURN: Understanding the Differences and How They Work

3 min read
October 16, 2021

WebRTC is a fantastic technology that allows users to communicate with each other in real-time. While on the surface, it looks like participants don’t need anything more than a browser and a good internet connection to start communicating, underneath the surface, there is a complex architecture of signalling servers that developers need to instruct in order to deliver data from one peer to another.

Table of contents

  1. What are signalling servers?
  2. What is a STUN server?
  3. What is a TURN server?
  4. Taking advantage of STUN and TURN with Digital Samba
  5. Conclusion

What are signalling servers?

Even if based on a peer-to-peer protocol, WebRTC connections can't run without a server. In order for two devices to locate one another, a discovery and negotiation mechanism called signalling must take place.

Since this process is not offered by the WebRTC API itself, developers need to establish a framework that allows WebRTC to overcome the complexities of real-time communication. 

 

What is a STUN server?

As mentioned before, exchanging real-time communication (video, audio, screen sharing and other data) requires devices to connect to a mutually agreed upon server. STUN (Session Traversal Utilities for NAT) and TURN (Traversal Using Relays around NAT) servers are both used in the signalling process but for different reasons. 

Before establishing a peer-to-peer connection, it is essential for servers to identify the IP address for each participant. WebRTC applications use STUN servers most of the time. They are straightforward, quick, and most importantly, they don’t create much load.

Additionally, they are applied only during the connection setup for discovering and exchanging external host:port-pairs. Once the session has been established, media will be exchanged directly between participants. Nevertheless, STUN is sometimes restricted by firewalls. Therefore, developers need to "turn" and utilize a TURN server when STUN fails.

What is a TURN server?

Firewalls and closed corporate environments can limit access to the IP address. Without unique identifiers, it becomes unfeasible for two networks to find each other. This problem can be solved by using TURN servers as a middleman. Unlike STUN, a TURN server remains in the media path after the connection has been established. 

However, using this walk-around can add some latency to your video conference. On top of that, it can also increase the operational costs of your IT infrastructure. The more traffic you direct to your TURN server, the more complex infrastructure you will need.

Taking advantage of STUN and TURN with Digital Samba

Understanding STUN and TURN protocols is an integral part of navigating the complex networking landscape behind real-time communication. However, when it comes to implementing these protocols into your software products or websites, a reliable and robust solution is key.

Digital Samba provides a GDPR-compliant video conferencing API and SDK that simplifies this process. Our technology seamlessly integrates the use of STUN and TURN protocols to guarantee smooth, uninterrupted, and high-quality video conferencing experiences. Whether your needs involve peer-to-peer video streaming or hosting conferences with multiple global participants, our platform ensures seamless communication, even in complex environments.

One of the primary advantages of Digital Samba is our commitment to compliance and data protection. Hosted within the EU and fully adhering to GDPR guidelines, we offer end-to-end encryption for maximum data privacy and security. This focus on regulatory compliance allows you to confidently embed secure video conferencing in your product without worrying about data privacy.

Conclusion

Real-time video communication comes with a series of challenges. Even if WebRTC is designed to work peer-to-peer, it still requires building a whole signalling architecture behind it. This means that scaling up requires an additional investment in server infrastructure.

One of the key benefits of video APIs is freeing developers from the complexities of managing networking and infrastructure, including the nuances of STUN and TURN protocols. By leveraging a robust CPaaS or VCaaS platform, developers can avoid the intricate tasks involved in signalling and scaling, which allows them to focus on building better user experiences and optimising their applications.

Discover how Digital Samba can enhance your product with GDPR-compliant, encrypted video conferencing. Our API and SDK solutions are designed to streamline the integration process, enabling secure and seamless communication.

Previous story
← Samba Live 5.24
Next story
Samba Live 5.25 →

Get Email Notifications