Recall warm-up
- Which transport suits one small question and one small answer?
- 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, Registered1024–49151, Ephemeral49152–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.
- 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).
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
www.cs.iitm.ac.in. → root → in → ac → iitm → cs → www. Each level is managed by different servers.Kinds of DNS servers
| Server | Knows | Example |
|---|---|---|
| Root | which servers handle each top-level domain | 13 named root server identities, many copies world-wide |
| TLD (top-level domain) | which servers are authoritative for each domain under it | .com, .org, .in |
| Authoritative | the actual records for its domain | the organisation's own name server |
| Local (resolver) | nothing permanently; asks on the host's behalf and caches answers | your ISP's or campus resolver |
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.
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.
Resource records and transport
DNS stores resource records (name, value, type, TTL):
| Type | Name → value | Example |
|---|---|---|
| A | host name → IPv4 address | www.example.com → 93.184.216.34 |
| AAAA | host name → IPv6 address (brief) | — |
| NS | domain → name of its authoritative server | example.com → ns1.example.com |
| CNAME | alias → canonical (real) name | www.shop.com → shop.cdn.net |
| MX | domain → mail server name (with priority) | iitm.ac.in → mail.iitm.ac.in |
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
Worked Examples
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.
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.
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
- MCQ
Which DNS record maps a domain to its mail server?
- A
- NS
- CNAME
- MX
- 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.
- MSQ
Which are true of DNS?
- Ordinary queries use UDP port 53.
- Root servers return the final IP address.
- Answers are cached for the record's TTL.
- Zone transfers use TCP.
- MCQ
In iterative resolution, a contacted server that does not know the answer:
- forwards the query itself
- returns a referral to another server
- drops the query
- returns an error
- 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
- UDP — no handshake.
- 0–1023.
- 32.
Self-test answers
- D — MX = mail exchanger.
- A: Name → IPv4 address.
- B: Domain → name server.
- C: Alias → canonical name.
- 95 — 5 + 50 + 25 + 15 = 95.
- ACD — UDP 53, caching by TTL, TCP for zone transfers.
- B: Root servers only refer to TLD servers.
- B — Iterative = referrals.
- A: That is recursive.
- C: No.
- D: It refers.
- 4 — Only the host-to-resolver round trip.
Flashcards
- Which server holds the final record?
Reveal answer
The authoritative server. - DNS transport and port?
Reveal answer
UDP 53 (TCP 53 for zone transfers/large answers). - CNAME vs A?
Reveal answer
CNAME: alias → canonical name. A: name → IPv4 address. - Messages in a full uncached lookup?
Reveal answer
8.
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.