User Datagram Protocol(UDP) – Transport Layer

User Datagram Protocol

Now lets start with the 1st protocol of Transport Layer  i.e. User Datagram Protocol(UDP). UDP is one of the most important protocol in the Transport Layer providing services to the Internet. The UDP was first ever developed by David P. Reed in 1980. UDP is used by Transport Layer to pass the messages from Application Layer to the underlying Network Layer.


UDP is a Connection-Less protocol. This means that there is no handshaking between the two hosts before transmission of packets. UDP provides no guarantee for the delivery of packets. As transport layer works over Network Layer. Thus, UDP working over IP , that is also an unreliable data delivery. Therefore in case of UDP , you cannot be sure about the delivery of message. UDP just provides simple multiplexing and demultiplexing at hosts and a checksum for data integrity at both the hosts.

 Multiplexing/De-multiplexing is performed by the Transport Layer Protocols in order to send the data between the Network Layer and the correct-Application Layer process.

Checksum is a procedure or you can say that it is a mathematical calculation, that is done at both the sending and the receiving host, in order to check that, whether the data has arrived in its original form or not. It checks the correctness of the received data.


**** Now a question must be arising in your mind. That, if UDP doesn’t provides any guarantee of transfer of packets, it doesn’t provide any flow control, then why should a developer use UDP for his Application?? 


Let me tell you some uses of UDP and why should a Application Developer uses UDP for his Application.

checksum and error detection 

There are various uses of UDP. These are as follows:

 1. Stateless Protocol :

 It doesn’t maintain any state of the clients. Thus is very useful in Application where there are millions of clients and maintaining information of all the clients would be difficult task such as Streaming Media, etc.

2. No Re-transmission Delay :

 As UDP doesn’t provide any reliable delivery of data, so there are no re-transmission for the lost packets. Therefore, this is good for real Time Application such as Voice over IP etc.

3. Suitable for DNS:

It is a Transaction Oriented protocol, thus plays a vital role in query-response protocols, such as Domain Name Systems (DNS).

4. Small Header : 

The header that UDP encapsulate with Application Layer message, is only of 8 bytes whereas TCP header is of 20 bytes. We will discuss about headers later in the post.

Working of User Datagram Protocol(UDP):

 As we have discussed above that UDP do multiplexing/demultiplexing and some error checking.  It just adds a UDP header containing the Source port Number and a Destination port Number and pass the data to the underlying Network Layer. Then the network Layer adds it own header to Transport Layer packet and sends it to the destination.

UDP is really helpful in real time Applications such as, Video Conferencing , Online Gaming etc. Because in such Applications, losing packets is preferable than getting Delayed.


Port Numbers:

Ports are identified by a port number. A Port Number is a 16 bit number i.e a port number can be assigned from 0 to 65535 to an Application. Port Number from 0 to 1023 are registered for the IANA registered services such as HTTP, FTP, TCP etc. and port Numbers from 1024 to 65535 are dynamic, that means, a newly developed application can be assigned port number among these.

UDP Packet Structure:

user datagram protocol(UDP) Packet


The UDP Header has 4 fields . Each field is of 16 bit or 2 bytes. Thus UDP header length is 8 bytes or 32 bits.


                         ******** 1 byte= 8 bits  *********


1.Source and Destination Port Number

The source and destination port number allows the application to pass the message to the correct process running on the end systems or the hosts. They are of length 16 bit each.

2. Length 

It tells you the complete length of the UDP Packet i.e Length = UDP header + Application Message length. Thus for different UDP segments, length will be different, depending upon the size of the Application Message.

 Minimum Length will be 8 bytes i.e. the size of the header.

 3. Checksum

 Checksum is used on the receiving side in order to check, whether the data has arrived in its original form or not. Or to check any error in the data, during transmission.

 Checksum Calculation: 

Checksum is used for Error Detection.

 Let us suppose that we have

Source Port Number (S) = 0001101110010101

 Destination Port Number (P) = 1010100101110011

Length (L) = 0011011110010001

 We will add all these and put it in the Checksum field.

                                  i) S+P=T



                 +   1100010100001000   = T         

                                   ii) T+L= A



                  + 1111110010011001     = A


Now we will take the 1’s complement of A, i.e converting all 1’s to 0 and all 0’s to 1.

 Thus 1’s complement of 1111110010011001 is 0000001101100110. And this is our checksum.
 We will put this checksum in the header and send the packet. On the receiving side, the receiver will add all the 4 fields of the header i.e. Source+Destination+Length+Checksum.

If the data has arrived him correctly, then the sum will be equal to 1111111111111111. That is , he will get all 1’s after adding the 4 fields. And if he gets 0 at some bit , that will show him the error.

  •  You can see that UDP provides error checking, but it doesn’t provide anything to recover from that error. Some UDP applications will discard the packet with an error, and some will pass the packet to the Application with a given warning.

Thank You for reading the article . We hope you enjoyed it.

This was all from us on User Datagram Protocol(UDP). Do you have any information to share with our readers ?

Mandeep Kaur Bajaj

Mandeep Kaur Bajaj

Mandeep passion for blogging encouraged her to write at FitnyTech. She is a tech blogger and writes about Technology , Gadgets , various programming languages. In Blogging world , she is known as "Mandy". Mandeep is very good at cooking also , you can ask her for any cooking advice also.

More Posts

Leave a Reply

Your email address will not be published. Required fields are marked *