User Datagram Protocol (UDP)
Last Updated : 19 Jun, 2024
User Datagram Protocol (UDP)
This is a Transport Layer protocol. UDP is a part of the Internet
Protocol suite, referred to as UDP/IP suite. Unlike TCP, it is
an unreliable and connectionless protocol. So, there is no
need to establish a connection before data transfer. The UDP
helps to establish low-latency and loss-tolerating connections
over the network. The UDP enables process-to-process
communication.
What is User Datagram Protocol?
User Datagram Protocol (UDP) is one of the core protocols of the
Internet Protocol (IP) suite. It is a communication protocol used
across the internet for time-sensitive transmissions such as video
playback or DNS lookups. Unlike Transmission Control Protocol
(TCP), UDP is connectionless and does not guarantee delivery,
order, or error checking, making it a lightweight and efficient
option for certain types of data transmission.
UDP Header
UDP header is an 8-byte fixed and simple header, while for TCP
it may vary from 20 bytes to 60 bytes. The first 8 Bytes contain
all necessary header information and the remaining part consists
of data. UDP port number fields are each 16 bits long, therefore
the range for port numbers is defined from 0 to 65535; port
number 0 is reserved. Port numbers help to distinguish different
user requests or processes.
UDP Header
Source Port: Source Port is a 2 Byte long field used to
identify the port number of the source.
Destination Port: It is a 2 Byte long field, used to
identify the port of the destined packet.
Length: Length is the length of UDP including the
header and the data. It is a 16-bits field.
Checksum: Checksum is 2 Bytes long field. It is the 16-
bit one’s complement of the one’s complement sum of
the UDP header, the pseudo-header of information from
the IP header, and the data, padded with zero octets at
the end (if necessary) to make a multiple of two octets.
Notes – Unlike TCP, the Checksum calculation is not mandatory
in UDP. No Error control or flow control is provided by UDP. Hence
UDP depends on IP and ICMP for error reporting. Also UDP
provides port numbers so that is can differentiate between users
requests.
Applications of UDP
Used for simple request-response communication when
the size of data is less and hence there is lesser concern
about flow and error control.
It is a suitable protocol for multicasting as UDP supports
packet switching.
UDP is used for some routing update protocols
like RIP(Routing Information Protocol).
Normally used for real-time applications which can not
tolerate uneven delays between sections of a received
message.
VoIP (Voice over Internet Protocol) services, such as
Skype and WhatsApp, use UDP for real-time voice
communication. The delay in voice communication can
be noticeable if packets are delayed due to congestion
control, so UDP is used to ensure fast and efficient data
transmission.
DNS (Domain Name System) also uses UDP for its
query/response messages. DNS queries are typically
small and require a quick response time, making UDP a
suitable protocol for this application.
DHCP (Dynamic Host Configuration Protocol) uses UDP to
dynamically assign IP addresses to devices on a network.
DHCP messages are typically small, and the delay
caused by packet loss or retransmission is generally not
critical for this application.
Following implementations uses UDP as a transport layer
protocol:
o NTP (Network Time Protocol)
o DNS (Domain Name Service)
o BOOTP, DHCP.
o NNP (Network News Protocol)
o Quote of the day protocol
o TFTP, RTSP, RIP.
The application layer can do some of the tasks through
UDP-
o Trace Route
o Record Route
o Timestamp
UDP takes a datagram from Network Layer, attaches its
header, and sends it to the user. So, it works fast.
TCP vs UDP
User
Transmission Datagram
Control Protocol Protocol
Basis (TCP) (UDP)
UDP is the
Datagram-
oriented
protocol. This
is
because ther
TCP is a connection-
e is no
oriented protocol.
overhead for
Connection orientation
opening a
means that the
connection,
communicating devices
maintaining a
should establish a
connection,
connection before
or
transmitting data and
terminating a
should close the
connection.
connection after
UDP is
transmitting the data.
efficient for
broadcast
and multicast
types of
network
Type of Service transmission.
The delivery
TCP is reliable as it of data to the
guarantees the delivery destination
of data to the cannot be
destination router. guaranteed in
Reliability UDP.
TCP provides extensive UDP has only
error-checking the basic
mechanisms. It is error-
because it provides checking
Error checking flow control and mechanism
mechanism acknowledgment of using
data. checksums.
Acknowledgme nt An acknowledgment No
User
Transmission Datagram
Control Protocol Protocol
Basis (TCP) (UDP)
acknowledgm
segment is present.
ent segment.
There is no
sequencing
of data in
Sequencing of data is a
UDP. If the
feature of Transmission
order is
Control Protocol (TCP).
required, it
this means that packets
has to be
arrive in order at the
managed by
receiver.
the
application
Sequence layer.
UDP is faster,
TCP is comparatively simpler, and
slower than UDP. more efficient
Speed than TCP.
There is no
retransmissio
n of lost
Retransmission of lost
packets in
packets is possible in
the User
TCP, but not in UDP.
Datagram
Protocol
Retransmission (UDP).
UDP has an 8
TCP has a (20-60) bytes bytes fixed-
variable length header. length
Header Length header.
UDP is
TCP is heavy-weight.
Weight lightweight.
Handshaking Uses handshakes such It’s a
User
Transmission Datagram
Control Protocol Protocol
Basis (TCP) (UDP)
connectionles
s protocol i.e.
as SYN, ACK, SYN-ACK
No
Techniques handshake
TCP doesn’t support UDP supports
Broadcasting Broadcasting. Broadcasting.
UDP is used
TCP is used by HTTP, by DNS, DHC
HTTPs, FTP, SMTP and T P,
elnet. TFTP, SNMP,
Protocols RIP, and VoIP.
UDP
The TCP connection is a connection is
byte stream. a message
Stream Type stream.
Low but higher than
Very low.
Overhead UDP.
Applications This protocol is This protocol
primarily utilized in is used in
situations when a safe situations
and trustworthy where quick
communication communicati
procedure is necessary, on is
such as in email, on the necessary
web surfing, and but where
in military services. dependability
is not a
concern, such
as VoIP,
game
streaming,
video, and
music
User
Transmission Datagram
Control Protocol Protocol
Basis (TCP) (UDP)
streaming,
etc.
Advantages of UDP
Speed: UDP is faster than TCP because it does not have
the overhead of establishing a connection and ensuring
reliable data delivery.
Lower latency: Since there is no connection
establishment, there is lower latency and faster response
time.
Simplicity: UDP has a simpler protocol design than TCP,
making it easier to implement and manage.
Broadcast support: UDP supports broadcasting to
multiple recipients, making it useful for applications such
as video streaming and online gaming.
Smaller packet size: UDP uses smaller packet sizes
than TCP, which can reduce network congestion and
improve overall network performance.
User Datagram Protocol (UDP) is more efficient in terms
of both latency and bandwidth.
Disadvantages of UDP
No reliability: UDP does not guarantee delivery of
packets or order of delivery, which can lead to missing or
duplicate data.
No congestion control: UDP does not have congestion
control, which means that it can send packets at a rate
that can cause network congestion.
Vulnerable to attacks: UDP is vulnerable to denial-of-
service attacks, where an attacker can flood a network
with UDP packets, overwhelming the network and
causing it to crash.
Limited use cases: UDP is not suitable for applications
that require reliable data delivery, such as email or file
transfers, and is better suited for applications that can
tolerate some data loss, such as video streaming or
online gaming.
Conclusion
The User Datagram Protocol (UDP) is an important Transport
Layer protocol in the Internet Protocol (IP) suite, identified for its
speed and efficiency due to its connectionless and lightweight
design. While UDP lacks TCP’s stability and error-checking
features, it used in applications that need low latency and real-
time performance, such as streaming, online gaming, and DNS
lookups. Its simplicity and support for broadcast and multicast
broadcasts make it a useful tool for specialized applications,
despite its vulnerability to data loss and network congestion.