Why DNS uses UDP as the transport layer protocol?
DNS uses TCP for Zone transfer and UDP for name, and queries either regular (primary) or reverse. UDP can be used to exchange small information whereas TCP must be used to exchange information larger than 512 bytes.
UDP is used at the transport layer because it is a transport layer protocol. It provides "provides end-to-end communication services for applications" (RFC1122). Reliability services are optional for transport layer protocols.
Just like every application layer protocol, DNS uses the User Datagram Protocol (UDP) on the Transport layer of the TCP/IP model to transport data. UDP is preferred over TCP for DNS because of its speed and lightweight packets.
Since DHCP is inherently connectionless, UDP makes more sense. Second, the DHCP client does not have an IP address assigned until the DHCP process is complete.
You can read it here: https://www.geeksforgeeks.org/why-does-dns-use-udp-and-not-tcp/
UDP
is cheap. UDP
itself is not reliable, but higher level protocols — as DNS — may maintain reliability, e.g. by repeating the UDP
datagram in the case of no response.
But the last is not the case for DNS
. DNS
itself uses sometimes besides UDP
(as its primary protocol) the reliable Transmission Control Protocol (TCP
), too.
The last is used when the response data size exceeds 512
bytes, and for tasks which require the reliable delivery (e.g. zone transfers).
Moreover, there are some resolver implementations that use TCP
for all queries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With