When someone called you on phone, have you experienced any voice breaks? This happens very often. Well, this can be related to our topic. UDP or User Datagram protocol is also a transport layer protocol that works less dominant compared to TCP (Transmission Control Protocol). It is used less but has its own importance. Let’s look into the details.
If you remember, there is a three-way handshake in TCP to transmit data over a network. A connection has to be established before the actual transmission happens, which makes it connection-oriented. And also TCP is reliable, it notifies the sender that the data has been delivered. If not, a retransmission is requested. Now, this is the opposite of UDP.
In UDP, a prior connection is not required to transmit the data which makes it connectionless. Also, the sender doesn’t know if the data has been delivered or not, which makes it unreliable. UDP also avoids error checking and retransmission which is present in TCP. So, UDP is suitable for real-time and high-performance applications where error-detection and correction are required. Further verification will be performed at the application layer if needed.
UDP is a stateless protocol. The receiver doesn’t provide acknowledgments to the sender that the sent packets are received. It sends acknowledgment only if requested by the sender. UDP is almost a null protocol i.e. the only services it provides at the IP level is checksumming and multiplexing by port number. Hence, the application running over the UDP must deal directly with the end-to-end communication issues such as reliability, retransmission, packetization, flow control, etc. which were actually performed by the connection-oriented protocols.
From our above discussion the properties of UDP are as follows:
- It is an unreliable and connection-less protocol.
- It is a stateless protocol.
- UDP is almost a null protocol.
- It is a fast protocol comparatively as there are no acknowledgments, prior connection establishments, error checking or other overhead operations to be performed.
- It provides a minimal transport service. It means that it doesn’t guarantee the successful delivery of the information to the destination. It offers only minimal transport services- host-to-host delivery and error checking. Error checking is not a strict service in UDP.
- It is suitable if the transmission is one way. Ex. While streaming video, it is one-way traffic and hence UDP is suitable here.
UDP header:

The total header length is 8 bytes and contains the following fields.
Source port:
It is 2 bytes or 16-bits field that identifies the port number of the source or the sending application.
Destination port:
It is 2 bytes or 16-bits field that identifies the port number of the destination or the receiving application.
Length:
It is the combined length of the header and encapsulated data or payload and is expressed in bytes.
Total length = Length of UDP header + Encapsulated Data
The minimum value of this field is 8 bytes (if no data). The data carried by a UDP datagram will be decided by the underlying IP protocols.
Checksum:
The checksum is the 16-bit ‘one’s complement of the one’s complement sum of a pseudo-header of information from the IP header, the UDP header, and the data, padded with zero octets at the end (if necessary) to make a multiple of two octets’. The checksum is the same as used in TCP. The checksum is not mandatory incase of UDP.
The pseudo-header conceptually prefixed to the UDP header contains the source address, the destination address, the protocol, and the UDP length. This information gives protection against misrouted datagrams. This is how a UDP datagram is delivered to a destination.
Applications:
- It can be used for data transmissions that aren’t concerned about flow control or error detection.
- UDP is an ideal protocol for network applications in which perceived latency is critical, such as in gaming and voice and video communications, which can suffer some data loss without adversely affecting perceived quality. In some cases, forward error correction techniques are used to improve audio and video quality, despite some loss.
- Applications that require one response for one request use UDP. Ex. DNS (Domain Name System)
- Streaming applications like multimedia, video conferencing, etc use UDP since they require speed over reliability.
TCP Vs UDP
| Transmission Control Protocol (TCP) | User Datagram Protocol (UDP) |
| It is a connection-oriented protocol. | It is a connectionless protocol. |
| TCP is reliable. | UDP is unreliable. |
| TCP provides flow control, error checking, and acknowledgment of data. | UDP offers minimal transport service i.e. provides only delivery from host-host and basic error-checking using checksums. |
| Packets arrive in order at the receiver end. This is possible through the sequencing of packets. | No sequencing and the application layer should manage the incoming packets. |
| Variable header length (20-60 bytes). | Fixed header length (8 bytes). |
| Retransmission of packets is possible in TCP. | UDP doesn’t support retransmission of packets and suffers a loss if packets are lost. |
| TCP is comparatively slower than UDP. | UDP is a faster protocol as it doesn’t have any overhead. |