TCP vs UDP: The benefits of unreliability
- August 26, 2014
- No comments
- 6,017 Views
by Nate Lee, Director, Technical Operations
Following our previous post on optimizing networks for real-time media, a number of people were curious about the section on UDP vs TCP, particularly how they were related, how they differed and how they affect the way your audio and video flow on the network.
With real-time services being such a critical part of an effective Fuze session, we wanted to dig a bit deeper and provide a better understanding of how this critical traffic traverses the network. While we won’t go into the dirty details, we will touch enough that you should be able to walk away from this with enough knowledge to enjoy a fireside chat about the 4th layer of the OSI stack.
The User Datagram Protocol or UDP and Transport Control Protocol or TCP are the two main protocols that can be used to send data between applications on the internet. Both TCP and UDP ride within the Internet Protocol or IP which sends data between hosts on a network. You can think of an IP address as a locator that would be assigned to your computer, iPad or refrigerator, similar to the street address of an apartment building. It describes where on the network the destination is located so that packets can be properly delivered to the correct device. Modern devices have many different applications running at the same time. Examples would be email, web browsing, Fuze and Candy Crush. Once IP is done delivering the packets on the network to the destination host, there needs to be a way for the receiving device to understand what locally running application the information should be sent to and this is where TCP and UDP come in. Going back to the apartment building analogy, once the mail arrives at the proper building (host), there are many different people that it could be delivered to (applications running on the host). Just as an apartment number denotes who the final recipient within the building should be, TCP and UDP ports define which application running on that host should receive the data that just arrived.
Both TCP and UDP serve a similar purpose however they use slightly different approaches to achieve their goals. For the purposes of how we at Fuze stream media, we go for UDP first. This is because it is very lightweight, adds very little overhead to a stream of packets and is mainly concerned with keeping the flow of traffic moving. It is considered “unreliable” because it does not try to resend packets that may be lost due to bad wi-fi or internet congestion. Although it is counterintuitive, this is actually a desirable feature. Think of a stream of data packets as being a voice call with every packet as a syllable in a sentence. If you lose the 3rd syllable in the sentence, it doesn’t make sense to resend it as the moment where it was needed is gone, you can’t go back and play it back after the fact. It is much better to keep moving and keep sending the remaining syllables as quickly as possible.
If UDP is the unreliable member of the family, TCP is the responsible one who always calls to make sure things are going well. TCP was designed in the early eighties, a time when networks were unreliable and The Fresh Prince had not yet relocated to Bel Aire. TCP was designed to transfer data where every piece must arrive at the other side to be reassembled in the exact same order. For instance, when transferring a file, if a piece doesn’t arrive or doesn’t get put back together in its original order, the entire file ends up corrupted and won’t open at all. TCP handles this by checking to make sure that every packet is received on the other end. It will resend anything that was not acknowledged by the other side and won’t send any more data if the preceding pieces never made it. Because of the nature of real-time voice and video that we mentioned above, this makes TCP less well suited to sending streaming media, especially if there is a poor connection with lots of dropped packets. Stopping the entire flow of audio to resend a syllable that no longer matters is clearly not the best way to handle things.
Why would we ever use TCP for audio or video if UDP is clearly the better choice? This is where we’ll go back to the talk of ports. Networks with a high level of security are by nature, more restrictive. Part of this security includes blocking ports in and out of the network to prevent unauthorized traffic from passing between the internal network and the internet. Unless explicitly allowed, UDP traffic can end up blocked from entering or leaving the network. In cases like this, Fuze automatically detects the block and takes the voice and video data that would have been placed in a UDP packet and puts it in a TCP packet. We then send it to our servers in an encrypted fashion so that it looks to network security devices like any other traffic to a secured HTTPS website. This allows us to bypass the firewall rules that would otherwise block most VoIP traffic.
Ensuring that voice traffic is delivered between the participants in a meeting is of the utmost importance for online communications. At Fuze, we’ve built out our voice infrastructure such that we are able to provide high quality voice by dynamically adapting to variations in network conditions and security policies.
If you are currently using TCP because UDP is blocked, we recommend petitioning to have the ports opened. To learn more about optimizing your network for video, read on here.
We are here to help. If you have questions or want to discuss optimizing your network for video, reach out to us at Success@fuze.com.