UDP(User Datagram Protocol)

UDP is a transport layer protocol provides an unreliable, connectionless and fast services .

It is a very simple protocol and has very less overhead.


Despite being unreliable why it is used??

Let's say we have to send a very small message and we are not very much concerning about reliability so we can use UDP.


UDP is used in the following applications:

  • DNS
  • SNMP
  • NTP etc.

UDP packets are called user datagram and have the fixed-sized header of 8 Bytes.


1.Source port number: This is the port number used by the process running on the source host. It is 16 bits long, which means that the port number can range from 0 to65,535.


2.Destination port number: This is the port number used by the process running on the destination host. It is also 16 bits long. 

If in some case destination is some server then that must be a well-known port number.

3. Total length: It is  16 bit long and 

total length= UDP datagram length + header 

Actually, the length field is not necessary for UDP datagram because UDP datagram is carried in IP datagram and if we subtract IP header from total IP length we will get UDP length.

UDP length = IP length - IP header's length



UDP checksum has three sections fields:

  • Pseudo-header
  • The UDP header
  • The data coming from the application layer
  1. The Pseudo header is the part of the IP header in which UDP datagram is going to encapsulate and entries in this are all 0's.
  2. If the checksum does not include Pseudo header it means user datagram may arrive safe and unaffected.
  3. There is also a protocol field that tells that packets belong to UDP and the value of the protocol field for UDP is 17.


Some operations of UDP:-

1. Connectionless:

Connectionless in UDP means:-

  1. No reservation of resources.
  2. datagram from the same source can take a different path even they are going to the same destination.
  3. There is no relation between datagrams of the same source and they are not numbered.
  4. It does not chop large data into small data so data size should be such that it can fit into one UDP datagram.

 2. NO flow and Error control:-

Since there is no flow control, it may happen that the receiver is overflow with incoming messages.

NO error control means: sender doesn't know whether the packet is lost or reached. if the receiver gets the wrong packest it silently discards.


To send a message from one process to another, the UDP protocol encapsulates and decapsulates messages in an IP datagram.


Some important applications of UDP:-

  1. It is useful in applications that require simple little request-response communication.
  2. Multicasting is the capability of UDP not TCP.
  3. All routing algorithms use UDP.
  4. TFTP uses UDP.
  5. RIP(Route Information Protocol) uses UDP.



Transport Layer - OSI Model

Transport Layer

The main aim of transport layer is to be delivered the entire message from source to destination. Transport layer ensures whole message arrives intact and in order, ensuring both error control and flow control at the source to destination level. It decides if data transmission should be on parallel path or single path

Transport layer breaks the message (data) into small units so that they are handled more efficiently by the network layer and ensures that message arrives in order by checking error and flow control.


Transport Layer in ISO-OSI Model


  1. Service Point Addressing : Transport Layer header includes service point address which is port address. This layer gets the message to the correct process on the computer unlike Network Layer, which gets each packet to the correct computer.
  2. Segmentation and Reassembling : A message is divided into segments; each segment contains sequence number, which enables this layer in reassembling the message. Message is reassembled correctly upon arrival at the destination and replaces packets which were lost in transmission.
  3. Connection Control : It includes 2 types :
    • Connectionless Transport Layer : Each segment is considered as an independent packet and delivered to the transport layer at the destination machine.
    • Connection Oriented Transport Layer : Before delivering packets, connection is made with transport layer at the destination machine.
  4. Flow Control : In this layer, flow control is performed end to end.
  5. Error Control : Error Control is performed end to end in this layer to ensure that the complete message arrives at the receiving transport layer without any error. Error Correction is done through retransmission.