Blog Post View

What is User Datagram Protocol (UDP)?

The User Datagram Protocol (UDP) is one of the core protocols of the Internet Protocol (IP) Suite in the transport layer. The protocol’s primary purpose is for the use of sending messages (datagrams) between two endpoints across the Internet without the need for a pre-existing data path from prior communication between the endpoints. This is what is referred to as connectionless communication and is ideal in situations where error-checking and error-correction are not needed between two endpoints. In these scenarios, the datagrams can be sent between the two endpoints faster than using the Transmission Control Protocol (TCP) and Stream Control Transmission Protocol (SCTP) as the overhead generated from error-checking and error-correction is no longer a factor. This makes UDP very popular and a very optimal solution in these types of situations as it would be more preferred than its counterparts.

Structure and Function

Because UDP forgoes error-checking and error-correction, it is not usable in every situation and relies on these things being done in the application using it beforehand. This is because the protocol has no handshaking functionality which exposes it to unreliability. Because of this, the protocol can guarantee no protection against lost datagrams, inaccurate ordering of datagrams, or redundant datagrams. As a matter of fact, UDP supplies the bare minimum functionality for its tasks; which are checksums for data integrity and port numbers for addressing functions between the two endpoints of the datagram. This means that UDP will always prefer to drop packets that are flawed as opposed to going through error-checking and/or error-checking and resending those packets.

It should also be noted that the protocol’s minimalistic nature gives it some features that make it actually more desirable to TCP and SCTP. For instance, the protocol is connectionless which makes it perfect for streaming media as it would be faster and more desirable. Its transaction-oriented nature also makes it optimal for query-response systems such as the Domain Name System (DNS) while its simplicity makes it great for bootstrapping and useful when used alongside other protocols without a full stack such as the Dynamic Hosting Control Protocol (DHCP). So while it may not save any record of the data it sends and be unreliable in that regard, it also offers a variety of functionality and features that are definitely applicable and usable on the Internet.

The packets sent through the protocol are structured in a very minimalistic way as well by having it attach a UDP header to the top of each packet with relevant information and a checksum. A checksum is simply a digit representing the sum of all the correct digits in the data being transmitted. It is used in comparisons to validate that the data is correct and is used on a smaller scale of error-checking. The actual packet itself consists of four smaller fields, 2 bytes each (16 bits), one of which is the checksum. The source port number identifies the port of origin the packet was sent from and is assumed to be the port to reply to if needed. If the port is unused, its value is zero as the field is optional in IPv4 and IPv6. The destination port number is another field in the packet and is required in both IPv4 and IPv6. Similar to the source port number, it stores the destination port number to which the packet is to be sent. Finally, the last field is the length field which states the length of the header and the data attached in bytes. The minimum length of the header is 8 bytes while the maximum data length is 65,507 bytes for IPv4 and even greater than 65,535 bytes in IPv6.

Transmission Control Protocol vs User Datagram Protocol

When it comes down to comparing TCP to UDP, they each have their pros and cons which makes it integral to know the differences between them and when to use one over the other. Firstly, TCP is reliable as it manages message acknowledgment, resending data, and timing out to pause data transfers. This allows it to recognize if data is sent or not and then request for it to be sent again across the connection. Furthermore, this reliability is encapsulated further by the protocol sending each piece of data multiple times to ensure it is all received. On the other hand, UDP has no reliability as it has no means to acknowledge when a message is received. As such, is incapable of requesting data to be resent or timed out as well.

TCP is an ordered-protocol; meaning, that if two messages are transferred over the connection in sequence, the first message will reach the application first. In the event that the packets are sent out of order, the protocol will delay the out-of-order data until the packets are intended to be received before it arrives. UDP is unordered which means that there is no way to determine in which order two messages may arrive across a connection.

Because TCP is connection-oriented, it is a heavy protocol. This means that it uses 3 packets to first create a socket connection to send the data. This is what allows the protocol to be reliable and handle congestion across the connection. This feature also allows data to be sent in a stream across the connection which means there is no way to identify segments of data through the stream. As UDP is connectionless, it is very lightweight and also offers no congestion control or reliability. This is why these issues must be handled by the application utilizing the protocol; although, this does also mean that the protocol is capable of broadcasting a message to all devices on a subnet and the data has to be broken down into packets when being sent. These packets are then checked for integrity via checksums once they arrive at their destination.


As mentioned before, UDP is indeed useful but it’s not going to be a viable alternative to TCP or SCTP in every situation. One scenario in which it has definitely been applied already is in the case of the DNS as the system prioritizes fast responses to the queries it receives. Applications that also rely on voice and video media also utilize the protocol as they require the data to be sent as close to real-time as possible. As such, these applications often make use of specific voice and video protocols to handle data loss which may be experienced during use. This means applications such as Skype and Discord will utilize the protocol and even websites that focus on video media like YouTube and Twitch will also utilize it. Although it is rare, there are even some Virtual Private Networks (VPNs), such as OpenVPN, which will use the protocol while implementing their own solutions for error-checking and reliability at the application layer.

Over time, it is very likely that there can be even more uses for the protocol as a limitation within the space of technology is only determined by a developer's imagination. It’s also possible that applications may choose to employ their own solutions for reliability and error-checking and choose to use UDP instead of TCP in favor of faster speeds as well. At the moment, however, the amount of applications which does this is small but only time will tell.

Share this post

Comments (0)

    No comment

Leave a comment

All comments are moderated. Spammy and bot submitted comments are deleted. Please submit the comments that are helpful to others, and we'll approve your comments. A comment that includes outbound link will only be approved if the content is relevant to the topic, and has some value to our readers.

Login To Post Comment