Day 44 – DNS and UDP

DNS is a great example of an application layer service that uses UDP for the transport layer instead of TCP, this can be broken down into a few simple reasons

  • the biggest difference between TCP and UDP is that UDP is connectionless this means there’s no set up or tear down of a connection.
  • A single DNS request and its response can usually fit inside of a single UDP datagram, making it an ideal candidate for a connectionless protocol
  • DNS can generate a lot of traffic.
  • It’s true that caches of DNS entries are stored both on local machines and cashing name servers, but it’s also true that if the full resolution needs to be processed, we’re talking about a lot more traffic.

TCP

UDP

A DNS server never needs to care about doing anything but responding to incoming lookups and a DNS resolver simply needs to perform lookups and repeat them if they don’t succeed.

As the web has gotten more complex, it’s no longer the case that all DNS lookup responses can fit in a single UDP datagram. In these situations, a DNS name server would respond with a packet explaining that the response is too large. The DNS client would then establish a TCP connection in order to perform the lookup.

Leave a Reply