CS Atlas GATE 2027
Computer Networks course
0 / 90 complete

Computer Networks/Phase 5 · Application Layer

Lesson 5.2 · Item 78 of 90

DNS: hierarchy, recursive vs iterative resolution, caching, records

Read at your own pace. Try the questions before opening the answers.

On this page

Recall warm-up

  1. Which transport suits one small question and one small answer?
  2. Range of well-known ports?
    Stuck? Peek at 4.1 Transport basics: process-to-process delivery, ports, sockets & multiplexing
    • Delivery: Network Layer = host-to-host; Transport Layer = process-to-process.
    • Port number = 16 bits (0–65,535): Well-known 0–1023, Registered 1024–49151, Ephemeral 49152–65535.
    • Demultiplexing: UDP uses 2-tuple (DstIP, DstPort); TCP uses 4-tuple (SrcIP, SrcPort, DstIP, DstPort).
    • UDP (Foundation) = 8-byte header, connectionless, best-effort; TCP = connection-oriented, reliable, flow + congestion controlled.

    Read lesson 4.1

  3. How many bits in an IPv4 address?
    Stuck? Peek at 3.1.1 IPv4 address structure, dotted decimal, net-id vs host-id
    • IPv4 address = 32 bits = 4 octets (0–255 each), total space = 2³².
    • Split: Net-ID (left n bits) + Host-ID (right h = 32 − n bits).
    • Identifies a network interface (routers have one IP per link).

    Read lesson 3.1.1

The Hook

You type www.example.com, but packets need a 32-bit IP address. A single phone book for the whole world would be too big, too busy and a single point of failure. The Domain Name System is a world-wide, distributed, cached phone book — consulted before almost every connection your laptop makes.

Predict First

Your laptop asks for the address of mail.cs.iitm.ac.in. Which server would know the final answer: a server for the whole Internet, one for .in, or one run by IIT Madras?

,

The IIT Madras (authoritative) server. The root servers only know who handles .in; the .in servers know who handles ac.in and below; the organisation's own server holds the final record. The lookup walks down this tree.

Core Concept

Names form a hierarchy

A domain name is read right to left from the root: www.cs.iitm.ac.in. → root → in → ac → iitm → cs → www. Each level is managed by different servers.
root (.)comexamplewwwinaciitmcswwworgwikipedia
The DNS name tree (a small part).

Kinds of DNS servers

ServerKnowsExample
Rootwhich servers handle each top-level domain13 named root server identities, many copies world-wide
TLD (top-level domain)which servers are authoritative for each domain under it.com, .org, .in
Authoritativethe actual records for its domainthe organisation's own name server
Local (resolver)nothing permanently; asks on the host's behalf and caches answersyour ISP's or campus resolver
Root → TLD → authoritative; the local resolver does the legwork for hosts.

Recursive vs iterative resolution

  • Iterative: the queried server answers with "I don't know, ask this other server" (a referral). The asker contacts each server in turn.
  • Recursive: the queried server takes over the job, asks onward itself, and returns the final answer.

Typically the host → local resolver query is recursive, and the local resolver → root/TLD/authoritative queries are iterative. Both styles exchange the same number of messages in a full uncached lookup (8: 4 queries + 4 replies); they differ in who does the work.

HostLocalRootTLDAuth1 query (recursive)2 query3 referral → TLD4 query5 referral → Auth6 query7 answer: address8 answer (cached)
A full lookup: recursive from the host, iterative from the local resolver. 8 messages.

Caching and TTL

Every server caches answers it has seen for a time given by the record's TTL (time to live, in seconds). Cached TLD and authoritative-server addresses let most lookups skip the root entirely; a cached final answer makes the lookup cost only the host-to-resolver round trip.

Cold cache
host → local → root → TLD → authoritative
Warm cache
host → local (answer cached)
Caching turns a multi-server walk into one short round trip.

Resource records and transport

DNS stores resource records (name, value, type, TTL):

TypeName → valueExample
Ahost name → IPv4 addresswww.example.com → 93.184.216.34
AAAAhost name → IPv6 address (brief)—
NSdomain → name of its authoritative serverexample.com → ns1.example.com
CNAMEalias → canonical (real) namewww.shop.com → shop.cdn.net
MXdomain → mail server name (with priority)iitm.ac.in → mail.iitm.ac.in
The five record types to know. DNS uses UDP port 53 for ordinary queries; TCP port 53 for zone transfers and answers too large for one UDP message.

Putting it together

  • DNS is a distributed, cached hierarchy of name servers.
  • Local resolvers walk root → TLD → authoritative (iteratively) on the host's behalf.
  • Records A, NS, CNAME, MX; UDP port 53; caching by TTL keeps it fast.

Visual

host ↔ local
2 ms
local ↔ root
RTT 40 ms
local ↔ TLD
RTT 30 ms
local ↔ authoritative
RTT 20 ms
0102030405060708090
time (ms)
Cold-cache lookup time is the sum of the round trips: 2 + 40 + 30 + 20 = 92 ms.

Worked Examples

Easy

Cold caches. RTT host↔local resolver 2 ms; local↔root 40 ms; local↔TLD 30 ms; local↔authoritative 20 ms. Iterative resolution by the local resolver. Lookup time?

Show the full solution

Each step is one round trip, one after another: 2 + 40 + 30 + 20 = 92 ms.

Medium

Same, but the local resolver already caches the address of the authoritative server for that domain. Lookup time?

Show the full solution

Skip root and TLD: 2 + 20 = 22 ms.

GATE

For a full uncached lookup (host → local → root → TLD → authoritative), how many DNS messages are exchanged in total, and how many are sent by the local resolver, when the local resolver works iteratively? (Count every query and every reply.)

Show the full solution

Host↔local 2, local↔root 2, local↔TLD 2, local↔authoritative 2 → 8 messages. The local resolver sends 3 queries + 1 reply to the host = 4.

GATE Traps

  • DNS uses UDP port 53 for normal queries; TCP port 53 for zone transfers and long answers.
  • The root does not know the final address — it only refers you to TLD servers.
  • CNAME maps an alias to the canonical name, not to an address; MX names a mail server.
  • Recursive vs iterative is about who chases the referrals, not about the number of messages in a full lookup.

Memory Hook

"Root points to the shelf, TLD to the book, the authoritative server reads you the line."

Connect the Dots

With the address in hand, the browser can open a TCP connection to port 80. Next (5.3): what exactly does it send to ask for a page, what comes back, and how many round trips does a page with many images cost?

Self-Test

  1. MCQ

    Which DNS record maps a domain to its mail server?

    1. A
    2. NS
    3. CNAME
    4. MX
  2. NAT

    Cold cache, iterative: RTTs host↔local 5 ms, local↔root 50 ms, local↔TLD 25 ms, local↔authoritative 15 ms. Lookup time in ms?

    Write your answer before opening the key.

  3. MSQ

    Which are true of DNS?

    1. Ordinary queries use UDP port 53.
    2. Root servers return the final IP address.
    3. Answers are cached for the record's TTL.
    4. Zone transfers use TCP.
  4. MCQ

    In iterative resolution, a contacted server that does not know the answer:

    1. forwards the query itself
    2. returns a referral to another server
    3. drops the query
    4. returns an error
  5. NAT

    Warm cache: the local resolver already has the final A record. RTT host↔local = 4 ms. Lookup time in ms?

    Write your answer before opening the key.

Rule Card

  • Hierarchy: root → TLD → authoritative; local resolver works for hosts and caches.
  • Recursive (server chases) vs iterative (referrals); full lookup = 8 messages.
  • Lookup time = Σ RTT of servers actually contacted.
  • Records: A, AAAA, NS, CNAME, MX; TTL for caching.
  • Transport: UDP 53 (normal), TCP 53 (zone transfer / large).

Concept Ledger

  • DNS (Domain Name System)
  • domain name hierarchy
  • root, TLD, authoritative, local resolver
  • recursive vs iterative resolution
  • caching and TTL (DNS)
  • records A, AAAA, NS, CNAME, MX
  • UDP port 53 (TCP 53 for zone transfers)

Answer Vault

Try the questions first. Open when you are ready to check.

Warm-up answers

  1. UDP — no handshake.
  2. 0–1023.
  3. 32.

Self-test answers

  1. D — MX = mail exchanger.
    • A: Name → IPv4 address.
    • B: Domain → name server.
    • C: Alias → canonical name.
  2. 95 — 5 + 50 + 25 + 15 = 95.
  3. ACD — UDP 53, caching by TTL, TCP for zone transfers.
    • B: Root servers only refer to TLD servers.
  4. B — Iterative = referrals.
    • A: That is recursive.
    • C: No.
    • D: It refers.
  5. 4 — Only the host-to-resolver round trip.

Flashcards

  1. Which server holds the final record?
    Reveal answerThe authoritative server.
  2. DNS transport and port?
    Reveal answerUDP 53 (TCP 53 for zone transfers/large answers).
  3. CNAME vs A?
    Reveal answerCNAME: alias → canonical name. A: name → IPv4 address.
  4. Messages in a full uncached lookup?
    Reveal answer8.

Exam shortcuts

  • Lookup time = sum of the RTTs of every server actually contacted (cached steps skipped). — queries made one after another; no retransmissions.
  • Message count for a full lookup through 3 servers = 8 (4 queries + 4 replies). — one root, one TLD, one authoritative server; same count recursive or iterative.

Ready for the next idea?

Mark this item complete when you’ve finished reading and working through it.