The Internet Protocol or IP suite contains two major protocols, of which the User Datagram Protocol or UDP is one. The other protocol in the suite is TCP. UDP has limited few transport functions like simple error-checking along with multiplexing and demultiplexing.
As part of the multiplexing and demultiplexing service, UDP accepts messages from the application, fills in the source and destination port numbers along with a few less-important fields and adds the section to the network layer. The segment is then encapsulated into an IP datagram by the network layer, which makes its “best effort” to send it to the recipient host. At the receiving end, the data is transported to the suitable application by UDP, which makes use of the attached port numbers, IP port and destination address. As UDP lacks the association between the sending and receiving layers it is connectionless.
DNS (Domain Name Server) is an application layer protocol making use of UDP. Upon enquiry by a host, the application creates a query and passes it to the UDP socket, after which the segment gets encapsulated and sent to the name server. The DNS application awaits a response and if there is none, which could happen if the response was lost by UDP, then it will either attempt to pass the query to a different name server or return a message that it could not get a reply.
Although TCP is considered more a more consistent data transfer service, DNS generally always runs via UDP. UDP scores over other data transfer services for many applications for many reasons, few of which are these:
1. As no establishment of a connection (which takes time) is required, an application running through UDP, like DNS, is much faster.
2. UDP has an unregulated send rate unlike TCP, the congestion control mechanism of which chokes the sender if there is heavy traffic. Thus, for applications which have a minimum send rate in spite of being able to tolerate packet loss, UDP is the better option as UDP is restricted only by the data-generation ability of the application.
3. TCP requires the tracking of parameters like sequence and acknowledgement number, congestion control parameters and receiving and sending buffers for its congestion control mechanism as it maintains a connection state. However, as UDP does not require such tracking owing to its connectionless nature, a server running over UDP can support a larger number of active clients at a time.