UDP versus TCP for VoIP
In VoIP, audio samples are placed into data packets for transmission over the IP network. Typically, a single packet will contain anywhere from 10-30 milliseconds of audio. TCP and UDP are two of the most commonly used connection protocols used for data traversal across the Internet.
Transmission Control Protocol or TCP is connection oriented, which means that a formal connection between two end points must be established before any data is transmitted. TCP guarantees the delivery of data, and it also guarantees that data packets will be delivered in the same order in which they were sent. The process goes something like this:
Endpoint A sends packet 1 to Endpoint B
Endpoint B receives packet 1 without error and sends acknowledgement packet back to Endpoint A
Endpoint A receives the acknowledgement packet and proceeds to send packet 2 Endpoint B
If no acknowledgement packet is received after a certain amount of time, the original packet will be retransmitted. This guarantees that all data sent will be without error and in the correct order. TCP prioritizes accuracy over speed and efficiency. Websites such as the one you are viewing now, email delivery, etc use TCP.
User Datagram Protocol or UDP is quite different. Unlike TCP, UDP is connectionless, which means that data packets can be sent without warning, preparation, or negotiation. There’s no handshake or setup, just packets of data. UDP also lacks any kind of error control. Not only can packets be delivered in an incorrect order, but they can also get completely left out. UDP is meant for applications where you are more concerned with keeping the stream of information going than making sure you receive every single packet. This makes UDP ideal for real-time services such as Voice over IP.
Why is UDP ideal for real-time services and not TCP? Believe it or not it’s actually the ‘reliable’ nature of the protocol that hurts the end user experience. With TCP, delays happen every time there is an error like packet loss. These delays, which are caused by retransmitting broken packets and any following packets that may have already been sent, translate into an unacceptable level of jitter for the end user.
Luckily, real time communications services such as VoIP do not require a completely reliable transport layer protocol. This allows UDP to shine. Errors like packet loss usually only have minor impacts on the audio output. It is much better to drop a packet and have a few milliseconds of silence than to have seconds of lag.
Try out our Free SIP Services.Easy signup, no CC required
Let us help you find the right phone service for your business.
We'll get back to you shortly.