What are TCP and UDP?
First, we need to build some vocabulary. TCP and UDP are connection protocols in use today for data traversing the Internet. Data travels across the Internet in packets. Think of them like letters. Like letters, they have an envelope with a to/from address on them. TCP and UDP are just two types of envelopes. The IP addresses are the to/from addresses. They both carry data and both use IP addresses, but just the outside envelope is different. Think US mail vs. FedEx. The address on the envelope is the IP address for where the packet came from (source address) and where it’s going (destination address). TCP is so prevalent on the Internet that it’s typically combined with IP, and written as TCP/IP.
TCP would be the ‘FedEX’ part of the analogy from above. Whenever two servers ‘speak’ TCP, they set up a formal connection. Every time a packet is sent from one side, the other side sends a packet back acknowledging the packet’s arrival. If no acknowledgment packet arrives after a certain amount of time, or if the acknowledgment states that there was a problem, then the packet is re-sent. It can sometimes take a few seconds for a packet to be fully successfully transmitted. TCP is optimized for accurate delivery, not timeliness, and is the protocol for WWW sites and e-mail among others.
UDP is the opposite. It is a protocol optimized for getting packets there in a timely fashion with little overhead, but with just as little accountability. It’s more like throwing a bottle in the ocean. Ok, a very rapidly moving ocean, but you get the point. With UDP, you just address the envelope and drop it on the network. There’s no handshake, and no setup. Just the data packets. UDP is meant for real-time conversations where you are more interested in keeping the stream going then making sure that you have every single packet.
Why is UDP better for VoIP traffic?
Right this very moment, Junction Networks has over 3,500 devices attempting to connect with Junction Networks. These devices are everything from individual SIP phones, to SIP devices, to other PBXs. Most of the connection attempts are simple SIP registrations. A SIP registration is when a SIP device tells the server, in this case Junction Networks, that it’s available for calls and what its IP address is. This communication happens anywhere from every minute to every hour, for EVERY device. That’s a LOT of packets.
If these were TCP packets, each time a phone wanted to tell us that it’s available, it would have to go through the whole TCP connection setup. That would be a HUGE amount of overhead for a VoIP carrier. In a LAN environment, it would be manageable, but for thousands of individual devices and hundreds of them attempting to register EVERY SECOND, a TCP connection would grind servers to a halt.
Next, once the phones are registered and a call is set up, it’s really UDP’s time to shine. A phone conversation is a stream of packets meant to be created, sent and received in real time. With TCP, a lag – any lag – would mean a degradation in the quality of the phone call. Imagine hearing something on the call one to two seconds after the person on the other end says it. You’re replying to what they’re saying, but they’ve already moved on. It would be totally disconcerting. And, since it’s real-time, there’s no catching up. Better to drop a packet and have a millisecond of silence than seconds of lag.
In short, VoIP traffic is best left as UDP traffic for both server load and call quality reasons.