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:
- 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:
- The UDP header
- The data coming from the application layer
- 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.
- If the checksum does not include Pseudo header it means user datagram may arrive safe and unaffected.
- 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:-
Connectionless in UDP means:-
- No reservation of resources.
- datagram from the same source can take a different path even they are going to the same destination.
- There is no relation between datagrams of the same source and they are not numbered.
- 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:-
- It is useful in applications that require simple little request-response communication.
- Multicasting is the capability of UDP not TCP.
- All routing algorithms use UDP.
- TFTP uses UDP.
- RIP(Route Information Protocol) uses UDP.