Go back

TCP vs UDP – What’s The Difference?

January 13, 2022
Alina Krukova

Alina Krukova

Categories: Reviews

TCP vs UDP. Basic theory

To get to the comparison, we need to know some basic theory.

What do we know about IP networks? The data stream you send is divided into packets which are delivered to the client. The client gathers packets and receives your data stream. This part of the process is well-known and there’s no need to think about what’s going on at the lower network levels.TCP vs UDP - What’s The Difference? 1

On this diagram you can view the TCP/IP and UDP/IP stack. At the bottom there are Ethernet packets and IP packets; at the operating system level there are TCP and UDP. TCP and UDP in this stack are not very different from each other. As they are encapsulated into IP packets, they can be used by applications. To see the differences, you need to look inside the TCP and UDP packets.

TCP and UDP stack

Both protocols have ports. However, UDP only has a checksum — the packet length, this protocol is the simplest. In TCP there is a lot of data that explicitly indicates a window, acknowledgement, sequence, packets, and so on.

Packet Formats

What is TCP?

TCP (Transmission Control Protocol) is a protocol that provides reliable delivery of data packets and allows connections between two hosts by “handshaking”, after which the data can be exchanged.

To make sure that a recipient exists and is ready to accept data, a session with the recipient is established before the start of packet transmission over a TCP connection. When the transmission is complete, the session closes, the recipient is notified that there will be no more data, and the sender is notified that the recipient is informed.

Each packet has its own sequence number when exchanged. TCP automatically arranges packets using a sequence number and passes them on to the application layer after they have been concatenated. After sending several packets, an acknowledgement and the sequence number of the next packet is expected. If the acknowledgement is not received, the sending is repeated; if the attempts are unsuccessful, the session is terminated. The number of data packets for which an acknowledgement will be requested depends on the network reliability. If data is lost, acknowledgement is automatically requested more frequently. This is called the sliding window mechanism, which allows TCP to work with the networks regardless of their level of reliability.

applications using TCP

The use of TCP is appropriate where data loss is unacceptable, for example, during authorization, as well as when transmitting encrypted information.

What is UDP?

UDP is a protocol that allows the transmission of data (datagrams) without creating a connection between hosts. When sending datagrams, it is unknown if the recipient exists and is ready for the exchange. The UDP network protocol also does not provide sequencing of datagrams when received. The UDP is used by applications for which delivery time is crucial, for example in real time systems when it is not possible to wait for delayed packets or to retrieve lost packets. Datagrams can be duplicated, not delivered or delivered in the wrong order, which is why the UDP protocol is called “unreliable datagram protocol”.

applications using UDP

Applications using the UDP protocol are not sensitive to data loss, disrupted datagram order and duplication. However, they can use application-level reliability mechanisms.

What is the Difference Between TCP and UDP?

Despite the fact that the UDP and TCP protocols are focused on data transmission, between them there are several fundamental differences.

The connection setup process. UDP does not require a connection setup process, while TCP needs the obligatory three-step process to start a session.
Guaranteed traffic exchange. TCP sends a request for data integrity. If the reply is a request for lost packets, they will be re-sent. This provides an absolute guarantee of a complete transmission. In turn, the use of UDP can lead to the loss of a number of packets.

Flow management and control. Unlike UDP, TCP provides comprehensive control and management of the flow of information.

Delivery order. TCP sends all packets in a strict queue format. UDP, on the other hand, delivers messages as unordered datagrams.

Overload notification. If overloads occur as a part of the data transmission, TCP will send the appropriate notification. The UDP protocol does not provide any overload protection.

Saving the transmitted messages boundaries. The TCP protocol cannot preserve the boundaries of transmitted messages; however it provides a guarantee of their integrity. The UDP protocol usage involves saving the boundaries of each sent datagram.

Packets reassembly and segmentation. This function is only supported by the TCP protocol.

Reachability checking. This is a mandatory procedure only for the TCP protocol, while the UDP does not support it on a physical network layer.

Interaction with semi-open type compounds. The TCP protocol never resynchronizes, while the UDP protocol establishes a connection by resending the request to the end user.

TCP vs UDP Comparison Chart

TCP UDP
Full name Transmission Control Protocol User Datagram Protocol
Protocol Connection-oriented Not connection-oriented
Packet format Segments User datagrams
Header  8 bytes 20-60 bytes
Acknowledgement As TCP is a connection-oriented service, it sends an acknowledgment when all the data has been delivered As no connection is established, UDP does not send any acknowledgement when data delivery takes place
Error control  +
Communication processing Port numbers Combination of port numbers and IP addresses
Transfer rate Low packet transfer rate High packet transfer rate
Services Communication processing, stream delivery service, reliability, flow control, error control, overload control, full-duplex communication, multiplexing, demultiplexing, acknowledgement number, system number, sequence number, and byte number Communication processing, encapsulation, decapsulation, multiplexing and demultiplexing
Reliability More reliable Less reliable
Window mechanism Sliding window  
Optimal usage HTTPS, HTTP, SMTP, POP, FTP, etc.  Video conferencing, streaming, DNS, VoIP, etc. 

Which is Better for Video Conferencing?

In video conferencing software solutions, TCP is most often used because it provides packet sequencing, retransmission and prevents packet loss. This protocol is best suited for video conferencing buffering and sending images, spreadsheets, documents, graphs, and crystal clear HD video and audio, which is more important than speed. TCP protocol packets have a built-in feedback system to make sure that all data was received and sent exactly as intended.

The use of UDP significantly reduces the load on the server, because audio and video streams are transmitted within the UDP Multicast domain, which can be used in the local network or VPN (e.g. TrueConf UTM Multicast mode). Simply put, it allows users to exchange data directly with each other during a group conference bypassing the server. By default, UDP Multicast data transmission is available only within your corporate closed network, which eliminates the risk of losing sensitive data. You can learn more about UDP Multicast in our article.

Conclusion

TCP flow control, while reliable, cannot recover missing data fast enough to be used in real-time video communications. And while data integrity is important, it must be balanced with speed so that the rate of data exchange remains seamless.

The use of the UDP is important in broadcasting data, because it provides a high speed of sending data packets, but without a guarantee of their delivery. That’s why it is very popular in live streaming as well as in the gaming industry and real-time collaboration. TrueConf uses TCP protocol by default, but it is possible to switch to UDP Multicast at any time.


Sign up for newsletter