Skip to content
GATEiit

GATE CSE · Computer Networks

DNS and HTTP

How DNS maps names to addresses (hierarchy, recursive and iterative resolution, caching, record types) and how HTTP works (methods, status codes, cookies, persistent and non-persistent connections), with page-load time calculations.

Before you start

Concept notes

1. DNS: a distributed, hierarchical name database

The Domain Name System maps host names such as www.example.in to IP addresses (and does more: mail servers, aliases, reverse lookups). It is a distributed database run by a hierarchy of name servers; no single server holds all names.

Server Knows
Root Addresses of TLD servers (13 named root server identities, many physical copies via anycast)
TLD (.com, .org, .in, …) Authoritative servers of each domain under it
Authoritative The actual records for its zone (a company's hosts)
Local (default resolver) Not part of the hierarchy; the ISP or campus server that resolves on the host's behalf and caches results

The name space is a tree; a zone is a part of the tree managed by one authority, served by a primary and secondary (replica) servers. Replication and caching make DNS reliable and fast.

Transport: DNS queries and replies normally use UDP port 53 (one small request, one reply; no handshake cost). TCP port 53 is used for zone transfers between primary and secondary servers and when a reply is too large and comes back truncated.

Query and reply messages share one format: a header with a 16-bit identification field (to match replies to queries) and flags, then question, answer, authority and additional sections.

2. Resolution: recursive, iterative and caching

  • Recursive query: "get me the answer". The queried server takes over the job and returns the final answer. The host's query to its local server is normally recursive.
  • Iterative query: "tell me what you know". The queried server answers or returns a referral to the next server to ask. The local server's queries to root, TLD and authoritative servers are normally iterative.

In the usual mix (figure), a cold lookup is: host → local (1), local → root → referral (2, 3), local → TLD → referral (4, 5), local → authoritative → answer (6, 7), local → host (8). Total delay is the sum of the RTTs of the pairs used.

If every server asked the next one recursively, the same name would still cost 8 messages, but the load would sit on the root and TLD servers, which is why they answer iteratively.

Caching: every server caches what it learns for the record's TTL (time to live). A cached TLD or authoritative NS record lets the local server skip the root (and TLD) on later lookups. An answer from a cache is non-authoritative; only the zone's own servers give authoritative answers. Hosts and browsers keep their own caches too.

Iterative DNS resolutionHostLocal DNS serverRoot serverTLD server (.in)Authoritative server182345671 and 8: recursive query and answer; 2 to 7: iterative queries from the local server
Cold-cache lookup: the host asks recursively, the local server walks the hierarchy iteratively.

3. DNS resource records

Each record is a tuple (Name, Value, Type, TTL).

Type Name Value
A Host name IPv4 address
AAAA Host name IPv6 address
NS Domain Host name of an authoritative name server for it
CNAME Alias Canonical (real) host name
MX Domain Mail server host name (with a preference value)
PTR Reversed address under in-addr.arpa Host name (reverse lookup)
SOA Zone Start of authority: primary server, admin, serial, timers

How they work together:

  • A TLD server returns an NS record for the domain plus a glue A record for that server, so the resolver can contact it without another lookup.
  • A company can use the same alias for its web and mail server: example.in has an MX record pointing to the mail host and an A record for the web host (a CNAME cannot sit at the domain name itself alongside the MX record, but www.example.in can be a CNAME).
  • Load distribution: one name can have several A records; the server rotates their order.

A small TTL means changes spread fast but caching helps less; a large TTL means the opposite.

4. HTTP messages, methods and status codes

HTTP is a request–response protocol over TCP, port 80 (HTTPS: TLS over TCP, port 443). It is stateless: the server keeps no memory of past requests. State is layered on with cookies: the server sends Set-Cookie, the browser returns it in a Cookie header on later requests.

A request has a request line (GET /index.html HTTP/1.1), header lines (Host: is mandatory in HTTP/1.1, User-Agent:, If-Modified-Since: …), a blank line and an optional body.

Method Does
GET Fetch a resource; parameters in the URL
POST Send data in the body (forms)
HEAD Like GET but the response has headers only
PUT / DELETE Upload / remove a resource

GET, HEAD, PUT and DELETE are idempotent; POST is not.

Class Meaning Examples
1xx Informational 100 Continue
2xx Success 200 OK
3xx Redirection 301 Moved Permanently, 304 Not Modified
4xx Client error 400 Bad Request, 403 Forbidden, 404 Not Found
5xx Server error 500 Internal Server Error, 503 Service Unavailable

Conditional GET: a cache sends If-Modified-Since: <date>; if the object is unchanged the server replies 304 Not Modified with no body, saving bandwidth.

5. Persistent and non-persistent connections: timing

A web page is a base HTML file plus N referenced objects (images, scripts). Ignoring transmission times, each new TCP connection costs 1 RTT for the handshake and each request–response costs 1 RTT.

Mode Time for base + N objects
Non-persistent, serial 2 RTT (N+1)
Non-persistent, k parallel connections 2 RTT+⌈N/k⌉⋅2 RTT
Persistent, no pipelining 2 RTT+N⋅RTT
Persistent, with pipelining 2 RTT+RTT=3 RTT
  • Non-persistent (HTTP/1.0 default): one object per TCP connection; the server closes after sending.
  • Persistent (HTTP/1.1 default): the connection stays open for further requests.
  • Pipelining: the client sends all N requests back to back without waiting for each reply.
  • HTTP/2 multiplexes many requests as interleaved frames over one connection, avoiding head-of-line blocking at the HTTP level.

Add the DNS lookup time first if the name is not cached, and add transmission time =size/rate for each object if the question gives sizes. Read whether parallel connections are allowed and how many.

Formulas to remember

Non-persistent, serial
T=2 RTT (N+1)
Non-persistent, k parallel
T=2 RTT+⌈Nk⌉2 RTT
Persistent, no pipelining
T=2 RTT+N RTT
Persistent, pipeliningN objects requested back to back; transmission times ignored
T=3 RTT
Cold DNS lookup (iterative from local server)
TDNS=RTThost,local+RTTroot+RTTTLD+RTTauth

Common mistakes

  • Forgetting the TCP handshake RTT for each new non-persistent connection; every object then costs 2 RTT, not 1.
  • Adding DNS time again for objects on the same host; the name is resolved once and cached.
  • Saying DNS runs only over TCP or only over UDP; lookups use UDP, zone transfers use TCP.
  • Confusing recursive and iterative queries: in an iterative query the server returns a referral, not the final answer.
  • Placing 404 among server errors; 4xx are client errors and 5xx are server errors.
  • Counting the base HTML file inside the pipelined batch; it must arrive before the browser knows which objects to request.

Worked examples

Try each step yourself, then reveal the working.

Example 1: Page load time in four modes

numerical

A page has a base HTML file and 8 small embedded objects on the same server. RTT = 20 ms; ignore transmission times and DNS. Find the time to get everything with (a) non-persistent serial HTTP, (b) non-persistent with up to 4 parallel connections, (c) persistent without pipelining, (d) persistent with pipelining.

  1. Step 1: (a) Each of the 9 files needs a handshake and a request.

    Try it on paper first.

Example 2: DNS lookup time with caching

numerical

RTTs: host to local DNS server 2 ms, local server to root 20 ms, to the .in TLD server 30 ms, to the authoritative server of example.in 40 ms. Caches start empty. Find the lookup time for (a) www.example.in, (b) then mail.example.in, (c) then www.example.in again.

  1. Step 1: (a) Cold cache: walk the whole hierarchy.

    Try it on paper first.

Example 3: Reading a conditional GET

conceptual

A proxy cache holds a copy of /logo.png saved on 1 Nov. It forwards a request with the header If-Modified-Since set to that date. The server's copy has not changed. What does the server send, and what does the client receive?

  1. Step 1: Which status code means unchanged?

    Try it on paper first.

Example 4: Recursive vs iterative resolution

conceptual

In a cold lookup, compare the usual scheme (host asks recursively, local server asks iteratively) with a fully recursive chain (each server asks the next). Count the messages and say where the load falls.

  1. Step 1: Count messages in the usual scheme.

    Try it on paper first.

Previous year questions

5 official GATE CSE questions on this topic, newest first.

Practise these 5 PYQs →

Topic test

10 questions: up to 4 official PYQs and original practice questions, with GATE marking (MCQ wrong answers lose marks). Score 60% or more to pass. A new set is drawn each time.

Mark as mastered

Loading your progress…

My revision notes

Notes written by the GATEiit team against the official GATE CSE syllabus; being checked by a reviewer. Updated 2026-11-21. Spotted a mistake? Use Report an issue on any question, or contact us.