UDP vs. TCP and Which One to Use for Video Streaming (2024)

UDP vs. TCP and Which One to Use for Video Streaming (1)

If you’re weighing the virtues of TCP vs. UDP, we’re going to assume that you’re already familiar with the seven layers of networking and the all-important transport layer. As with everything, there are advantages and disadvantages to both protocols. To make an informed decision, though, it’s important to understand the key differences between the two.

UDP vs. TCP and Which One to Use for Video Streaming (2)

Table of Contents
  • Transmission Control Protocol(TCP)
  • User Datagram Protocol (UDP)
  • Streaming Protocols
  • TCP and UDP Uses and Examples

Transmission Control Protocol(TCP)

Transmission Control Protocol (also noted as TCP/IP) is one of the earliest, most foundational networking protocols, and it’s used extensively by core internet applications such as the World Wide Web (HTTP), email (SMTP), File Transfer Protocol (FTP), and many others. It’s best suited for applications where accurate delivery is more important than timeliness.

How Does TCP Work?

TCP was designed to offer a highly reliable, end-to-end byte stream over an unreliable network. It “cares” about the quality of the data stream and prioritizes ordered and precise packet delivery. It achieves this dependability through a technique known as positive acknowledgment with retransmission.

This means that TCP requires a handshake between hosts, and it detects issues with IP packets — whether they’re due to network congestion, issues with load balancing, or other unpredictable network behaviors. If TCP determines that IP packets are lost, duplicated, or out of sequence, it’ll request retransmission of missed data, correct out-of-order data, and even minimize network congestion. Once the sequence of packets has been assembled in the appropriate order, the TCP receiver passes the data to the receiving application.

Become a Streaming Protocol Expert

Learn about codecs and protocols, the latest live streaming trends, and much more.

Subscribe

User Datagram Protocol (UDP)

User Datagram Protocol, however, is a simple connectionless protocol with minimal mechanisms. It doesn’t require recipients to let the sender know that all data packets have arrived, giving it a reputation for being unreliable (some jokingly refer to UDP as the Unreliable Datagram Protocol). Nevertheless, it has a number of attributes that make it attractive for streaming.

How Does UDP Work?

UDP leverages simple checksums instead of handshakes to validate data integrity and offers no guarantees of delivery, ordering, or duplicate protection. It’s also stateless, which makes it ideal for transmitting data to large numbers of clients.

UDP also boasts multicast support, unlocking capabilities such as service discovery and broadcasting. Its lack of retransmission delays makes it suitable for real-time applications such as Voice over IP (VoIP), online games, and live video streaming. As such, UDP is ideal to use alongside Real-Time Streaming Protocol (RTSP).

Pros and Cons of TCP and UDP

One of the biggest advantages of TCP over UDP is that it requires devices to interact with one another more frequently to check for errors. This enhanced verification means even if data packets arrive at a recipient’s IP address out of order, or if pieces are missing entirely, the protocol communicates with the sender to ensure each piece arrives where it should be.

However, prioritizing accuracy can also incur lengthy delays (several seconds’ worth) while waiting for message retransmission. These delays might be unnoticeable to human Internet users, but when it comes to UDP vs. TCP speed, UDP is a clear winner. TCP, on the other hand, is preferable for sending important files and messages that don’t need to happen in real time.

UDP is generally favored for kinds of data streaming where near immediacy is essential. The drawback is that a few data packets sent via UDP streaming might be missing or out of order, which could result in a few frames missing (for example) or a slight glitch in audio during a live stream. If the difference is minor, it hopefully won’t negatively impact your user experience too much.

TCPUDP
A connection-oriented protocol.A connectionless protocol.
Uses specifichandshake protocols(generally,SYN, SYN-ACK, ACK).No handshake.
Guarantees the delivery of data to the destination router, thus making it reliable.Doesn’t guarantee the delivery of data to the destination.
Treats communication stream as a sequence of bytes.Messages contain packets thatare considered independent of one another.
Messages make their way across the internet from one computer to another.UDP isn’t connection-based, so one program can send lots of packets to another.
Packet sequence is verified.Data is processed in order of arrival.
Slower speed of transmissiondue to reordering and retransmission.Fasterbecause integrity is checked at the arrival timeusing checksum.
Performserror checking andattemptserror recovery.Performsbasicerror checking and discards erroneous packets without attemptingerror recovery.
Offers extensive error-checking mechanisms using flow control and acknowledgment of data.Has only a single error-checking mechanism, which is used for checksums.
Acknowledgessegments.Doesn’t acknowledge specificsegments.
Header size is 20 bytes.Header size is 8 bytes.
TCP isheavy.Itneeds three packets to set up a socket connection before data can be sent.UDP is lightweight. Thereisno tracking of connections, ordering of messages, etc.
Adapted from https://www.guru99.com/tcp-vs-udp-understanding-the-difference.html.

Download our low-latency deep dive

Find out what’s required to delivery interactive video experiences.

Get the PDF

Streaming Protocols

Because HTTP communication typically takes place over TCP connections, we tend to see HTTP-based streaming protocols layered over TCP connections. However, newer technologies leverage UDP’s simplicity and speed. You can see which streaming protocols pair with TCP or UDP best in the chart below:

TCPUDP
RTMP (Real-Time Messaging Protocol)SRT (Secure Reliable Transport)
RTSP (Real-Time Streaming Protocol)WebRTC (Web Real-Time Communications)
Apple HLS(includesLow-Latency HLS)RTSP (Real-Time Streaming Protocol)
MPEG-DASH(includesCMAF)RTP (Real-Time Transport Protocol)

You’ll notice that RTSP is on both sides of the chart because it often relies on TCP’s reliable transmission for control and UDP’s best-efforts delivery to display audio and video on client-side applications before the complete file has arrived. So, if you’re using RTSP, UDP or TCP isn’t the question — you need each of them for an optimal experience. RTP is also capable of using both, but RTMP is strictly a TCP-based protocol.

MPEG-DASH is made to work with TCP but is incompatible with Apple devices. If you know a portion of your audience uses iOS devices or Safari, don’t worry; Apple HLS is also designed to function with TCP to ensure reliability and maintain its powerful adaptive bitrate. Unfortunately, this also results in high latency (as much as 30-45 seconds), but Low-Latency HLS is created to operate with TCP as well and ensure speedy delivery.

The WebRTC protocol can leverage either TCP or UDP, but we recommend using it with the latter. SRT is also best used with UDP because it’s built with its own latency and “jitter” control from packet loss on low networks, which can compensate for UDP’s reduced accuracy, making them an ideal combination for data transmission.

UDP vs. TCP and Which One to Use for Video Streaming (3)

TCP and UDP Uses and Examples

What are some applications for both TCP and UDP in real life? Knowing that TCP is primarily for functions where accuracy is prioritized over timeliness, this protocol is common for Internet essentials like sending emails, sharing files, text messaging and accessing web pages. Some specific TCP examples include:

  • iMessage
  • Instagram
  • WhatsApp
  • FileZilla Client
  • HTTP (the Internet as we know it)
  • Gmail
  • Outlook
  • Yahoo

UDP applications include functions like video conferencing, voice over IP, online games, and domain name systems. All of these require transferring data as fast as possible, even if it results in a glitch or two. For instance, the slightest delay while video conferencing ruins the illusion that the conversation is happening in real-time, and gamers can’t tolerate lags when playing together. Some specific UDP examples include:

  • Zoom
  • Google Meet
  • FaceTime
  • WhatsApp’s voice calling feature
  • Viber
  • Halo
  • Team Fortress

Of course, there are exceptions, such as when an application needs a feature of another protocol it doesn’t benefit from its typical partner, like security. World of Warcraft, for example, leverages TCP instead of UDP like other video games.

Conclusion

If you’re debating whether to use UDP or TCP for streaming, keep in mind how fast you want your transmission to send and what your margin for error is before it impacts your user experience. It’s crucial to architect a workflow that uses the best streaming protocols for your specific requirement, which is why we built Wowza’s technology to be flexible.

Wowza’s platform supports all the protocols discussed in this article and can be customized to your needs.Simplycontact us todayto talk to an expert about the best way to architect your streaming workflow.

Try Wowza Video
Free for 30 Days

Test both UDP and TCP protocols and much more. No card necessary.

UDP vs. TCP and Which One to Use for Video Streaming (2024)
Top Articles
Latest Posts
Article information

Author: Allyn Kozey

Last Updated:

Views: 5826

Rating: 4.2 / 5 (43 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Allyn Kozey

Birthday: 1993-12-21

Address: Suite 454 40343 Larson Union, Port Melia, TX 16164

Phone: +2456904400762

Job: Investor Administrator

Hobby: Sketching, Puzzles, Pet, Mountaineering, Skydiving, Dowsing, Sports

Introduction: My name is Allyn Kozey, I am a outstanding, colorful, adventurous, encouraging, zealous, tender, helpful person who loves writing and wants to share my knowledge and understanding with you.