User datagram protocol (UDP) provides connectionless and unreliable process-to-process communication. It is a transport layer protocol. UDP has less overhead and provides faster delivery of the packets. UDP packets are referred to as user datagrams.
Content: User Datagram Protocol (UDP)
Introduction
Like TCP, UDP is also a transport layer protocol that provides process-to-process communication. Well, it is quite different than TCP protocol. Let us discuss how?
TCP is a connection-oriented protocol and it provides reliable communication. TCP protocol also manages flow and error control during the communication. But these services of TCP come with additional costs such as overheads and latency.
Sometimes the communicating processes exchange small messages which does not require much reliability then we can use the UDP protocol. Though UDP is a connectionless and unreliable protocol it provides faster delivery of packets as compared to TCP using the minimum overhead.
User Datagram
The user datagram protocol encapsulates the data received from the application layer into a packet and attaches a UDP header to it and this we refer to as user datagram. The UDP header has a fixed size i.e. 8 bytes. In these 8 bytes, it stores source port number and destination port number, the total length of the user datagram, and checksum.
The source port number is a process identifier. It identified the communicating process running on the source host. The destination port number identifies the destined process running on the destination host to which the datagram has to be delivered. We have discussed the types of port numbers in our previous content transport layer services.
The total length field in the UDP header describes the length of the entire user datagram i.e., ‘UDP header’ plus ‘data’. The checksum field helps in detecting errors in the user datagram.
User Datagram Protocol Services
1. Process-to-Process Communication
Being a transport layer protocol UDP provides process-to-process communication. In general, we say that two hosts (source host and destination host) in a network communicate with each other and we refer to it as host-to-host communication.
It is the responsibility of the network layer to deliver the messages from the source host to the destination host. But the story doesn’t end here and the message has to be delivered to a specific process on the destination host.
There may be several processes running on the source host and several processes running on the destination host. The UDP protocol identifies which process on the source host is communicating with which process on the destination host. UDP protocol uses port numbers to identify the processes on the source and destination host.
2. Connectionless Service
As UDP is a connectionless protocol it treats each user datagram as an independent entity, even if they belong to the same source host or if they are traveling towards the same destination host. Unlike TCP packets, the user datagrams are not numbered and each user datagram can take a different path to reach the destination even if they all are going to the same destination.
UDP protocol cannot be used to propagate the stream data instead it is used to send short messages.
3. Flow & Error Control
UDP does not provide any mechanism for flow control hence it is unable to manage the rate of data transmission. As the rate of transmission cannot be controlled the receiving host may overflow with the incoming messages.
The UDP protocol even does not have any mechanism for error control. But UDP has a checksum mechanism using which the receiver can detect if there is any error in the received packet. If the receiver detects any error in the packet it silently drops the packet.
4. Congestion Control
The UDP packets or user datagram are small and are assumed to be sporadic which means they are not sent frequently. So UDP packets are not suspected to create congestion. And even UDP is a connectionless protocol so the user datagram from the same source host may travel different paths to reach the same destination host. Thus it does not have any congestion control mechanism.
5. Encapsulation & Decapsulation
Whenever a sender sends a message to the receiver the message is encapsulated a couple of times at the sender side and it is then decapsulated at the receiver side.
Encapsulation
When a process at the application layer in the source is ready to send a message it passes that message to the transport layer along with the pair of socket addresses (source process id + source host Id & receiver process id + receiver host id) and data length. At the transport layer, the UDP header is added to the data and the user datagram is forwarded to the network layer.
At the network layer, an IP header is added to the datagram. In the IP header, the value of the protocol field is ’17’ which indicates usage of UDP protocol. Further, the IP datagram is forwarded to the datalink layer which attaches a frame header to the IP datagram and forwards it to the physical layer. The physical layer converts the bit information into an electric or optical signal and passes it on to the network.
Decapsulation
When the message arrives at the receiver host, the physical layer converts the electrical signal into bits and passes the information to the data link layer. At the datalink layer, the frame header is used to check if the received data has some error. If no error is detected the frame header and trailer are removed and the data is passed to the network layer.
At the network layer, IP protocol even performs the check for any error and if no error is detected the IP header and trailer are dropped and the datagram is forward to the transport layer where UPD performs checksum to detect the error if any. When no error is found the UDP header is dropped and the data is passed to the corresponding process in the application layer with the sender socket address (in case the receiver has to respond).
6. Multiplexing and Demultiplexing
When several processes running on the host wants to use UDP service then UDP has to perform multiplexing and demultiplexing.
Multiplexing
At the sender host if there are multiple processes that want to send user datagram then the UDP at the transport layer accepts messages from all the processes and is able to distinguish between those messages using the port number assigned to those messages. After adding the UDP header to these messages UDP passes them to IP at the network layer.
Demultiplexing
Receiving host may receive messages for different processes running on it. UDP accepts all these messages and after performing checksum if no error is found it delivers the message to the corresponding process based on the port number.
User Datagram Protocol Working
UDP protocol is used as a transport layer protocol which is in between the application layer and network layer. Whenever a process in the application layer wants to send data, it delivers it to UDP along with pair of socket addresses ( IP address of sender and port address of sender process plus IP address of receiver and port address of receiver process).
UDP accepts the data encapsulate it by adding a UDP header to the data. UDP then delivers this user datagram to IP at the network layer. IP attaches IP header and delivers the IP datagram to datalink layer. The data link layer encapsulates the IP datagram into the frame header and passes it to the physical layer which converts the bit information into an electrical or optical signal.
When data arrives at the receiver host the physical layer converts the electrical or optical signals into a bitstream and delivers it to the receiver data link layer. At the data link layer using frame header, the received data is check for error. If no error is found frame header and trailer is dropped and the IP datagram is delivered to the network layer.
At the network layer, IP also performs an error check, and when no error is detected IP header and trailer are dropped and the datagram is delivered to UDP. UDP performs checksum and if there is any error the datagram is silently dropped. Else the removing UDP header the data is delivered to the process in the application layer along with the sender’s socket address in case the receiver process wants to respond.
UDP Applications
Though UDP doesn’t have features of TCP still some applications are benefited from its services.
- UDP does not have its own flow and control mechanism but it can be used by the process that has internal flow and error control mechanism such as TFTP (Trivial File Transfer Protocol).
- UDP can be used by the processes that communicate by exchanging simple requests and responses and is less concerned with flow and error control.
- UDP is a preferable transport layer protocol for multicasting as it is able to perform multiplexing and demultiplexing.
- UDP can be used with the process that is used for management such as simple network management protocol SNMP.
- UDP can be used by route updating protocol Such as RIP (Routing Information Protocol).
- UDP is also used by real-time multimedia applications such as audio and video calling.
Advantages and Disadvantages
Advantages
- UDP provides faster delivery of messages from sender to receiver.
- UDP is suitable for broadcasting.
- UDP produces minimum overheads.
Disadvantages
- UDP is an Unreliable protocol, it does not guarantee the delivery of packets.
- UDP cannot manage flow and error control.
- UDP does not have any congestion control mechanism.
So this is all about user datagram protocol. We have seen how it accepts data from the process running on the sender host and delivers it to the corresponding process on the receiver host.
Leave a Reply