UDP (User Datagram Protocol)

=User Datagram Protocol (UDP)=

UDP is a no-frills, lightweight transport protocol. UDP does not utilize a handshake to initiate communication between two processes; hence it is defined as connectionless. When using UDP, there is no delivery guarantee and packets may arrive out of order. Since UDP has no congestion control mechanism it can forward data down to the network layer at any rate it pleases.



It is often used in real-time application and multimedia streaming, where speed is important and packet loss is acceptable, but since many firewalls block UDP traffic, many streaming services and real-time applications have begun using TCP instead.

UDP takes messages from the application, adds source and destination ports for multiplexing, the length of the message and a checksum before passing the segment to the network layer. Here it is encapsulated into an IP datagram and attempted delivered to the destination.

The use of UDP
DNS is an example of an application that uses UDP. UDP directly passes the DNS query to the network layer and the DNS application waits for a reply, if a reply is not received, the DNS application either tries another name server or informs the invoking application that it can’t get a reply.

Why use UDP
Better control over what is sent and when, UDP packets the data and immediately sends it through to the network layer, whilst the congestion control and redundancy of TCP will send the packets at any time and as many times as it takes for the packet to get through. Packet loss can be acceptable in certain applications (real-time, streaming, etc.)

No connection establishment means that everything can be a lot faster (this is why DNS uses UDP). For example the connection established of TCP contributes to the delay when downloading web documents.

While TCP maintains connection state (keeping track of buffers, congestion control parameters and sequence numbers), the no-frills nature of UDP allows it to have no connection state and thereby support many more active connections than TCP.

Lastly, the 8 byte header of UDP renders a small packet header overhead compared to the 20 byte header of TCP.