CS Atlas GATE 2027
Computer Networks course
0 / 90 complete

Computer Networks/Phase 5 · Application Layer

Lesson 5.3 · Item 80 of 90

HTTP: messages, methods, status codes, cookies, persistent connections and RTT counting

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

On this page

Recall warm-up

  1. 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).

    Read lesson 5.2

  2. 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 by D + 2).
    • Teardown states: Active closer goes FIN-WAIT-1 → FIN-WAIT-2 → TIME-WAIT (2·MSL) → CLOSED; Passive closer goes CLOSE-WAIT (half-close) → LAST-ACK → CLOSED.

    Read lesson 4.3.2

  3. 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.

    Read lesson 1.3.3

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 (HyperText Transfer Protocol) is the web's application protocol: a client sends a request, the server returns a response. It runs over TCP, port 80. A URL names an object: http://www.example.com:80/docs/page.html = protocol, host name, (port), path.
HTTPS is HTTP inside an encrypted channel (TLS) on port 443; the encryption setup adds extra round trips before the first request.
http://www.example.com/docs/page.htmlprotocolhost name → DNSpath on the server
Parts of a URL.

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)
MethodMeaning
GETfetch an object
POSTsend data (e.g. a form) in the body
HEADlike GET but headers only (no body)
PUTupload / replace an object
DELETEremove an object
Request methods.

Status codes

CodeClassExample meaning
200 OK2xx successhere is the object
301 Moved Permanently3xx redirectionobject moved; new URL in Location header
304 Not Modified3xxyour cached copy is still valid (after If-Modified-Since)
400 Bad Request4xx client errorrequest not understood
404 Not Found4xxno such object
500 Internal Server Error5xx server errorserver failed
503 Service Unavailable5xxserver overloaded
First digit = class.

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.

BrowserServerGET /cart200 OK + Set-Cookie: id=7f3aGET /checkout + Cookie: id=7f3alooks up id=7f3a → your cart
Cookies add state on top of stateless HTTP.

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, serial2·RTT·(N + 1)
Non-persistent, k parallel2·RTT + ⌈N/k⌉·2·RTT
Persistent, no pipelining2·RTT + N·RTT
Persistent, pipelining2·RTT + 1·RTT = 3·RTT
Add DNS lookup time and object transmission times when the question gives them.

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

22non-pers. serial6non-pers. 5 parallel12persistent3pipelined
Base page + 10 small objects, counted in RTTs: 22, 6, 12, 3.

Worked Examples

Easy

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.

Medium

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.

GATE

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

  1. NAT

    Base page + 6 small objects, RTT 30 ms, persistent without pipelining, transmission ignored. Total in ms?

    Write your answer before opening the key.

  2. NAT

    Base page + 6 small objects, RTT 30 ms, non-persistent serial. Total in ms?

    Write your answer before opening the key.

  3. MCQ

    Status code returned when a cached copy is still valid:

    1. 200
    2. 301
    3. 304
    4. 404
  4. MSQ

    Which are true of HTTP?

    1. It is stateless.
    2. It runs over TCP port 80.
    3. HEAD returns only headers.
    4. A 5xx code means a client error.
  5. 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

  1. The sum of the RTTs to every server contacted.
  2. One RTT (SYN → SYN-ACK); the request can go with the final ACK.
  3. 2·T_p.

Self-test answers

  1. 240 — 2 × 30 + 6 × 30 = 240.
  2. 420 — 2 × 30 × 7 = 420.
  3. C — 304 Not Modified.
    • A: Sends the object.
    • B: Moved permanently.
    • D: Not found.
  4. ABC — Stateless, TCP 80, HEAD.
    • D: 5xx = server error; 4xx = client error.
  5. 200 — 50 + 50 + ⌈12/6⌉ × 50 = 200.

Flashcards

  1. Non-persistent cost per object?
    Reveal answer2 RTT (+ transmission).
  2. Persistent with pipelining for base + N objects?
    Reveal answer3 RTT.
  3. 304 means?
    Reveal answerNot Modified — use your cached copy.
  4. How does stateless HTTP remember users?
    Reveal answerCookies.

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.

Ready for the next idea?

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