Recall warm-up
- DNS lookup time with cold caches = ?
Stuck? Peek at 5.2 DNS: hierarchy, recursive vs iterative resolution, caching, records
- 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).
- How long before a TCP client can send its first data?
Stuck? Peek at 4.3.2 TCP 3-way handshake, connection termination & state machine
- 3-way handshake:
SYN(seq=x) → SYN+ACK(seq=y, ack=x+1) → ACK(seq=x+1, ack=y+1). - Seq consumption:
SYN = +1,FIN = +1,Pure ACK = 0,Data(L) = +L(full connection advances byD + 2). - Teardown states: Active closer goes
FIN-WAIT-1 → FIN-WAIT-2 → TIME-WAIT (2·MSL) → CLOSED; Passive closer goesCLOSE-WAIT (half-close) → LAST-ACK → CLOSED.
- 3-way handshake:
- RTT for a tiny message on one link?
Stuck? Peek at 1.3.3 RTT, bandwidth-delay product, utilisation and a = Tp/Tt
- RTT = 2·Tp for tiny signals (add Tt / queuing if stated).
- BDP = B × Tp bits in flight; B × RTT before any reply.
- a = Tp / Tt.
- Send-and-wait: U = Tt/(Tt + 2Tp) = 1/(1 + 2a); throughput = U·B.
- To keep the link busy: about 1 + 2a units in flight.
The Hook
The browser now knows the server's address. It opens a TCP connection and sends a few lines of plain text: "GET /index.html". Back comes the page — which turns out to need 10 images, each another request. Whether the browser reuses one connection or opens a new one for each image can make a page several times slower. GATE turns that into an RTT-counting question.
Predict First
A page has a base file and 4 small images on the same server; RTT = 20 ms, transmission times negligible. If every object needs its own new TCP connection, one after another, how long does the page take?
,200 ms: each object costs 2 RTT (1 for the TCP handshake, 1 for request + response), and there are 5 objects: 5 × 2 × 20 ms.
Core Concept
URLs and HTTP
http://www.example.com:80/docs/page.html = protocol, host name, (port), path.Request and response messages
GET /docs/page.html HTTP/1.1 ← request line: method, path, version
Host: www.example.com ← header lines
Connection: keep-alive
← blank line, then (optional) body
HTTP/1.1 200 OK ← status line: version, code, phrase
Content-Type: text/html
Content-Length: 5120
Set-Cookie: id=7f3a; Path=/
← blank line
<html>… ← body (the object)| Method | Meaning |
|---|---|
| GET | fetch an object |
| POST | send data (e.g. a form) in the body |
| HEAD | like GET but headers only (no body) |
| PUT | upload / replace an object |
| DELETE | remove an object |
Status codes
| Code | Class | Example meaning |
|---|---|---|
| 200 OK | 2xx success | here is the object |
| 301 Moved Permanently | 3xx redirection | object moved; new URL in Location header |
| 304 Not Modified | 3xx | your cached copy is still valid (after If-Modified-Since) |
| 400 Bad Request | 4xx client error | request not understood |
| 404 Not Found | 4xx | no such object |
| 500 Internal Server Error | 5xx server error | server failed |
| 503 Service Unavailable | 5xx | server overloaded |
Stateless, so cookies
HTTP is stateless: the server keeps no memory of earlier requests. To recognise a returning user, the server sends a cookie (Set-Cookie header); the browser stores it and includes it (Cookie header) in later requests to that site; the server looks the value up in its own database.
Non-persistent vs persistent, pipelining
- Non-persistent (HTTP/1.0 style): one object per TCP connection. Each object costs 2 RTT (handshake + request/response) + its transmission time.
- Persistent (HTTP/1.1 default): the connection stays open. After the first 2 RTT for the base file, each further object costs 1 RTT without pipelining.
- Pipelining: the client sends all requests back to back without waiting; all referenced objects arrive in about 1 RTT total.
- Parallel connections: a browser may open k non-persistent connections at once.
| Scheme (base + N small objects) | Total time |
|---|---|
| Non-persistent, serial | 2·RTT·(N + 1) |
| Non-persistent, k parallel | 2·RTT + ⌈N/k⌉·2·RTT |
| Persistent, no pipelining | 2·RTT + N·RTT |
| Persistent, pipelining | 2·RTT + 1·RTT = 3·RTT |
Putting it together
- HTTP is a stateless request/response protocol over TCP port 80; cookies add state.
- Methods and status codes are exam vocabulary: GET/POST/HEAD, 200/301/304/404/500.
- Persistent connections and pipelining cut page load from 2(N+1) RTT to 3 RTT.
Visual
Worked Examples
Base page + 4 small objects, RTT = 20 ms, transmission negligible. Total time for: non-persistent serial, persistent without pipelining, persistent with pipelining.
Show the full solution
Non-persistent: 2 × 20 × 5 = 200 ms. Persistent: 2 × 20 + 4 × 20 = 120 ms. Pipelined: 2 × 20 + 20 = 60 ms.
Base page + 10 objects, RTT = 50 ms, non-persistent with up to 5 parallel connections. Total?
Show the full solution
Base: 2 RTT = 100 ms. Then ⌈10/5⌉ = 2 rounds of 2 RTT = 200 ms. Total 300 ms.
DNS resolution visits servers with RTTs 10, 20 and 30 ms (60 ms in total; the cache is empty). The web server's RTT is 40 ms. The page has a base file and 8 small objects on the same server. Find the total time with (a) non-persistent serial, (b) non-persistent with 4 parallel connections, (c) persistent with pipelining.
Show the full solution
DNS: 60 ms in every case.
(a) 60 + 2 × 40 × 9 = 60 + 720 = 780 ms.
(b) 60 + 80 (base) + ⌈8/4⌉ × 80 = 60 + 80 + 160 = 300 ms.
(c) 60 + 80 + 40 = 180 ms.
GATE Traps
- Non-persistent costs 2 RTT per object including the base file — count N + 1 objects.
- Persistent without pipelining still waits 1 RTT per object; only pipelining sends them together.
- DNS time is added once, before the first TCP handshake (unless the question says otherwise).
- HTTP is stateless; cookies are the add-on that keeps state.
- 304 Not Modified has no body — the client uses its cached copy.
Memory Hook
"New connection: knock (1 RTT) and ask (1 RTT). Keep the door open: just ask. Ask everything at once: one RTT for all."
Connect the Dots
We have every piece now: DNS gives the address, TCP opens a connection, HTTP fetches the page. Next (5.4): put the entire course together — what happens, layer by layer and hop by hop, when you type a URL and press Enter?
Self-Test
- NAT
Base page + 6 small objects, RTT 30 ms, persistent without pipelining, transmission ignored. Total in ms?
Write your answer before opening the key.
- NAT
Base page + 6 small objects, RTT 30 ms, non-persistent serial. Total in ms?
Write your answer before opening the key.
- MCQ
Status code returned when a cached copy is still valid:
- 200
- 301
- 304
- 404
- MSQ
Which are true of HTTP?
- It is stateless.
- It runs over TCP port 80.
- HEAD returns only headers.
- A 5xx code means a client error.
- NAT
DNS 50 ms, RTT 25 ms, base + 12 small objects, non-persistent with 6 parallel connections. Total in ms?
Write your answer before opening the key.
Rule Card
- HTTP: request (method, path, version, headers, body) / response (status, headers, body); TCP 80; URL = protocol + host + path.
- Methods GET, POST, HEAD, PUT, DELETE; codes 2xx ok, 3xx redirect (301, 304), 4xx client (404), 5xx server.
- Stateless; cookies via Set-Cookie / Cookie.
- RTTs (base + N small): non-persistent 2(N+1); k-parallel 2 + 2⌈N/k⌉; persistent 2 + N; pipelined 3. Add DNS first.
Concept Ledger
- HTTP, port 80
- URL
- request line, status line, header lines
- methods GET / POST / HEAD / PUT / DELETE
- status codes (2xx–5xx; 200, 301, 304, 404, 500)
- stateless, cookies
- non-persistent vs persistent connections
- pipelining, parallel connections
- HTTPS port 443 (Foundation)
Answer Vault
Try the questions first. Open when you are ready to check.
Warm-up answers
- The sum of the RTTs to every server contacted.
- One RTT (SYN → SYN-ACK); the request can go with the final ACK.
- 2·T_p.
Self-test answers
- 240 — 2 × 30 + 6 × 30 = 240.
- 420 — 2 × 30 × 7 = 420.
- C — 304 Not Modified.
- A: Sends the object.
- B: Moved permanently.
- D: Not found.
- ABC — Stateless, TCP 80, HEAD.
- D: 5xx = server error; 4xx = client error.
- 200 — 50 + 50 + ⌈12/6⌉ × 50 = 200.
Flashcards
- Non-persistent cost per object?
Reveal answer
2 RTT (+ transmission). - Persistent with pipelining for base + N objects?
Reveal answer
3 RTT. - 304 means?
Reveal answer
Not Modified — use your cached copy. - How does stateless HTTP remember users?
Reveal answer
Cookies.
Exam shortcuts
- Count RTTs: new TCP connection = 1 RTT; each request/response = 1 RTT; pipelined requests share 1 RTT. — small objects (transmission time ignored) and one server; add DNS RTTs before the first connection.
- Non-persistent with k parallel: 2 + 2·⌈N/k⌉ RTTs. — the base file is fetched first, then up to k objects at a time.