• Blog
  • What is UDP and how UDP works?

What is UDP and how UDP works?

Oct 19, 2023

What is the UDP protocol?

UDP (User Datagram Protocol) is a long-term protocol used with the IP protocol to send data where transmission speed and efficiency are more important than security and reliability. UDP uses a simple, connectionless communication model with minimal protocol mechanisms. UDP uses checksums to ensure data integrity and port numbers to distinguish between different applications in the sender and receiver of the data.

What are the pros and cons of UDP protocol?

Pros

Fast transfer speed

UDP does not have TCP’s handshake, acknowledgment, retransmission, congestion control, and other mechanisms. Instead, UDP is a stateless transmission protocol faster in transmitting data.

The header is shorter

The TCP header is 20 bytes, and the UDP header is 8 bytes.

tcp

UDP has no congestion control

The application layer can better control the sending data. The sending time and congestion control in the network will not affect the sending rate of the host. Some real-time applications require sending at a stable speed, which can tolerate data loss but cannot allow a significant delay (such as real-time video, live broadcast, etc.).

UDP is message-oriented

The message-oriented transmission mode determines that UDP data is sent piecemeal. If the application layer sends UDP message of the same length, UDP sends the message at a time. Therefore, the application needs to select the message size.

UDP is used to transmit fewer data at the same time

UDP is often used in multimedia applications (such as IP telephony, real-time video conferencing, streaming media, etc.), but reliable data transmission is not essential to them. TCP’s congestion control will make them to have a considerable delay, and UDP will use a one-time transfer of fewer network data.

UDP supports a variety of communication modes

It supports unicast one-to-one, broadcast one-to-all, and multicast one-to-several interactive communications.

Cons

UDP is a connectionless protocol

The sender and receiver do not establish a connection before transmitting data, which is different from the process of TCP’s three-way handshake to establish a relationship. Instead, when it transmits data, it only needs to grab the data from the application and send it out of order to the other party that receives it.

UDP is an unreliable protocol

Because the connection doesn’t establish before the information is transmitted, UDP often loses packets during transmission, which becomes an unreliable protocol. If a message is lost, another new message will replace after a few seconds.

udp

Data lost

Don’t use UDP as the transport protocol for untrusted networks. UDP is not a connection-type protocol. Therefore, if you do not need to establish a connection, you can directly send messages, causing severe packet loss.

However, it consumes fewer resources, has a faster processing speed, and is more suitable for audio, video, and general data transmission. Therefore, even if one or two packets are lost, there will be no severe consequences for the received results.

When to use the UDP protocol?

UDP packets are poor reliability cause they don’t have a reliability guarantee, sequence guarantee, or flow control fields. However, because the UDP protocol has fewer control options, the delay in data transmission is slight, and the data transmission efficiency is high. Therefore, it is suitable for applications that do not require high reliability or can guarantee reliability, such as DNS, TFTP, and SNMP.