§2.4.1DNS — The Internet's Directory Service

Application layer Kurose & Ross pp. 122–124 · ~13 min read

  • domain name system
  • hostname
  • host aliasing
  • canonical hostname
  • alias hostname
  • load distribution

Where you are

  • Application layer you are here
  • Transport layer
  • Network layer
  • Link layer
  • Physical layer

DNS turns names people can remember into addresses routers can process. It does that job for almost every other application, and neither they nor you ever talk to it directly.

Words you will meet

  • DNS — Domain Name System: the Internet’s directory service.
  • Hostname — the readable name of a host, such as www.example.edu.
  • Host aliasing — giving one machine a short easy name as well as its long official one.
  • Canonical hostname — a machine’s one real, official name.
  • Alias hostname — a short nickname that stands for it.
  • Load distribution — spreading visitors over several identical servers.

Why this matters

Everything in section 2.2 assumed the browser already knew the server’s address. It did not. Something had to find it first, and that something runs before the clock on every measurement in that section started.

DNS (Domain Name System) is also the best example in this chapter of a distributed database, and section 2.4.2 is worth the effort for that reason alone. Almost nothing else you will study is designed to be run by hundreds of thousands of separate organisations that do not trust each other.

Two ways to name the same host

People can be identified in many ways: the name on a birth certificate, a national identity number, a driver’s licence number. Each works, but within a given context one is more appropriate than another. Tax computers prefer fixed-length numbers. Ordinary people prefer names.

Everyday picture

Imagine introducing yourself by your identity number: “Hi. My name is 132-67-9875. Please meet my husband, 178-87-1146.”

The number is perfectly good for a computer that has to sort a million records. It is useless for a human being who has to remember one.

Where the picture breaks: your identity number does not tell anyone where you live. An IP (Internet Protocol) address does say roughly where a host sits in the Internet, and that is the whole reason routers can work with it. So the two identifiers differ in more than readability.

Internet hosts are the same. One identifier is the hostname www.facebook.com, www.google.com, gaia.cs.umass.edu. These are mnemonic and therefore appreciated by humans.

But hostnames have two problems for machines:

  1. They provide little information about location. A hostname ending .fr suggests France, but says nothing more.
  2. They consist of variable-length alphanumeric characters, which would be difficult for routers to process.

For these reasons hosts are also identified by IP (Internet Protocol) addresses.

One host, two identifiers — and they run in opposite directionshostnamegaia . cs . umass . edumore general as you read right →one machine → a department → a university → a whole top-level domainIP address121 . 7 . 106 . 83more specific as you read right →four bytes, each 0–255 · a fixed length a router can read at speedLike a postal addressread from the bottom up:country → city → street → number

An IP address consists of four bytes and has a rigid hierarchical structure. It looks like 121.7.106.83, where each period separates one byte written in decimal from 0 to 255. It is hierarchical because scanning it from left to right gives more and more specific information about where the host sits: within which network, in the network of networks. Chapter 4 covers this in detail.

What DNS provides

People prefer the mnemonic name. Routers prefer the fixed-length, hierarchically structured address. To reconcile the two we need a directory service that translates one into the other.

DNS is two things at once

The domain name system is:

  1. a distributed database implemented in a hierarchy of DNS servers, and
  2. an application-layer protocol that allows hosts to query that database.

DNS servers are often UNIX machines running the Berkeley Internet Name Domain software ( BIND (Berkeley Internet Name Domain) ). The DNS protocol runs over UDP (User Datagram Protocol) and uses port 53.

Why UDP, and not TCP (Transmission Control Protocol) ?

Section 2.1.4 said TCP costs a handshake before any data moves. A DNS exchange is usually one small query and one small reply. Paying a full connection setup for two messages would more than double the cost.

Chapter 3 returns to this trade-off properly. For now, notice that the protocol almost every other application depends on chose the one with no guarantees.

A lookup, step by step

DNS is commonly employed by other application-layer protocols — including HTTP (HyperText Transfer Protocol) and SMTP (Simple Mail Transfer Protocol) — to translate user-supplied hostnames to IP addresses. Here is what happens when a browser requests www.someschool.edu/index.html.

What has to happen before a single byte of the page can be requested
1 — The same machine runs a DNS clientstep 1 of 5
Lin types http://www.example.edu/index.htmlLin’s laptopa DNS serverwww.example.eduDNS clientpart of the operating system

There is no separate program to install and no service to subscribe to. The client side of the DNS application runs on the very machine that needs the answer, alongside the browser.

Five steps, and the browser cannot skip any of them. Step forward and watch what the browser knows at each point.

Read all steps as text
  1. 1 — The same machine runs a DNS clientThere is no separate program to install and no service to subscribe to. The client side of the DNS application runs on the very machine that needs the answer, alongside the browser.
  2. 2 — The browser extracts the hostnameFrom the URL http://www.example.edu/index.html the browser takes just the hostname part, www.example.edu, and passes it to the DNS client. The path name /index.html is not DNS’s business.
  3. 3 — The DNS client sends a queryA query containing the hostname goes to a DNS server. All DNS query and reply messages travel inside UDP datagrams, to port 53.
  4. 4 — A reply comes back with the IP addressAfter a delay ranging from milliseconds to seconds, the reply arrives. From the browser’s point of view DNS is a black box that turned a name into an address. Section 2.4.2 opens that box, and it is far from simple inside.
  5. 5 — Only now can TCP beginWith the IP address in hand, the browser initiates a TCP connection to the HTTP server process at port 80 at that address. Everything §2.2.2 measured starts here — the DNS lookup happened before the clock in that section started.
DNS is pure added delay, in front of everything else
message 6 of 6
0 ms93 ms185 ms278 ms370 msLin’s laptop192.168.1.24TimeLocal DNS server41.72.0.53Timewww.example.edu198.51.100.7Timeaddress known — only now can TCP startDNS query: www.example.edu5 msDNS reply: 198.51.100.75 msSYN90 msSYN, ACK90 msACK + GET /index.html90 msindex.html, then the rest of the page90 ms

Click any arrow to see what that message says and why it is sent.

The same page load as §2.2.2, with the lookup that has to happen first. Click the last arrow for the arithmetic.

Read this diagram as text
  1. Lin’s laptop sends DNS query: www.example.edu to Local DNS server (5 ms). The local DNS server sits inside Lin’s access ISP, a few kilometres away, so this hop is short. It is carried in a UDP datagram — no connection is established first, which matters when the whole exchange is two messages.
  2. Local DNS server sends DNS reply: 198.51.100.7 to Lin’s laptop (5 ms). This assumes the answer was already cached at the local DNS server, which §2.4.2 shows is the common case. If it was not, this server must walk the hierarchy first, and the reply takes far longer.
  3. Lin’s laptop sends SYN to www.example.edu (90 ms).
  4. www.example.edu sends SYN, ACK to Lin’s laptop (90 ms).
  5. Lin’s laptop sends ACK + GET /index.html to www.example.edu (90 ms).
  6. www.example.edu sends index.html, then the rest of the page to Lin’s laptop (90 ms). Section 2.2.2 measured this page at 569.8 ms — 3 RTT plus 29.76 ms of transmission. The cached DNS lookup adds about 10 ms on top, so the real total is roughly 580 ms. An uncached lookup can add far more, which is why §2.4.2 spends so long on caching.

Lifelines, left to right: Lin’s laptop (host), Local DNS server (server), www.example.edu (server).

DNS adds delay to everything

From the invoking application’s point of view, DNS is a black box providing a simple translation service. But the box costs time, and that time is added to every application that uses it.

In the ladder above the lookup takes about 10 ms, because the answer was already cached at the local DNS server. That is the common case, and section 2.4.2 explains why. When it is not cached, the delay can be far larger — the book says it ranges from milliseconds to seconds.

Notice where this leaves the arithmetic of section 2.2.2. Lin’s page took 569.8 ms there. With a cached lookup the honest figure is about 580 ms, and the extra was never mentioned because the clock in that section started after the address was already known.

The other three services

Translating hostnames is DNS’s main task, but not its only one. It provides three more, and each is worth naming.

Host aliasing lets a host with a complicated name also answer to simpler ones. The complicated one is its canonical hostname .

Each simpler name is an alias hostname , and aliases are typically more mnemonic. Mail server aliasing does the same for e-mail, which is why nobody has to type a mail server’s real name.

And load distribution spreads visitors across a set of replicated servers.

What else DNS does, besides turning names into addresses
What it lets you doHow
The MX record lets a company’s mail server and web server have the same aliased name — enterprise.com for both. A client asks for MX to reach the mail server, and CNAME to reach the other. The record type is part of the question.

Cells marked ⓘ have an explanation — click to read it. Sortable columns have a ↕ in the heading.

Three more services. Click a ⓘ for the example the book gives.

In plain words

All three extra services are the same trick: let one name stand for something else, and let the questioner say which kind of answer it wants.

That single idea buys a great deal. A company can publish one short name for both its website and its mail. A site can be replicated across a dozen machines without anyone noticing. And section 2.6.3 will show content distribution companies such as Akamai using it to steer you to a nearby server. They do that without changing a single link on the page you clicked.

Principles in practice — a core function, built at the edge

Like HTTP, FTP (File Transfer Protocol) and SMTP, DNS is an application-layer protocol. It runs between communicating end systems using the client-server paradigm, and it relies on an underlying transport protocol to carry its messages.

But its role is different from the Web, file transfer and e-mail. DNS is not an application a user interacts with. It provides a core Internet function — the translation of hostnames to addresses — for user applications and other software.

Section 1.2 noted that much of the complexity in the Internet architecture is located at the edges of the network. DNS, which implements this critical translation using clients and servers at the edge, is another example of that design philosophy.

DNS is specified in RFC (Request For Comments) 1034 and RFC 1035, updated by several further RFCs. It is a complex system, and this chapter touches only the key aspects of its operation.

Check yourself

Check yourself

0 of 6 answered
  1. 1.Hosts have two kinds of identifier. Why keep both instead of settling on one?

  2. 2.What are the two things DNS actually is?

  3. 3.predictLin's browser is told to load http://www.example.edu/index.html. In the ladder above, what has to finish before the very first TCP segment can be sent?

  4. 4.A company's web server and mail server are both reachable as `enterprise.com`. How can one name mean two different machines?

  5. 5.A busy site is replicated over several servers with different IP addresses. How does DNS spread visitors across them?

  6. 6.The Principles in Practice box calls DNS an example of a design philosophy from chapter 1. Which one, and why does DNS illustrate it?

What to remember

  • A host has two identifiers: a hostname for people and an IP address for routers. Names are variable-length and say little about location; addresses are four bytes and hierarchical.
  • DNS is two things: a distributed database in a hierarchy of servers, and an application-layer protocol for querying it.
  • A browser must complete the lookup before it can open a TCP connection. DNS delay is added to every application that uses it.