Computer Networks (UGC NET topics) · World Wide Web and Application Layer
Urls DNS and HTTP
Overview
This lesson covers how a web resource is named, located, resolved to an address, and finally transferred.
The three core pieces are the URL (the name/address typed by the user), DNS (the distributed system that converts a host name into an IP address), and HTTP (the request–response protocol that transfers the resource).
It sits in the application-layer chapter on the World Wide Web. Before studying it, you should know the client–server model, IP addresses, ports, and the basic difference between TCP and UDP.
Key concepts
- A URL (Uniform Resource Locator) is the address of a resource. Standard hierarchical syntax is
scheme://authority/path?query#fragment.
The scheme is the retrieval method or protocol (http,https,ftp). The authority is[userinfo@]host[:port]; the host may be a domain name or an IP literal, and the port is optional. The path identifies the resource on the server. The query starts with?and carries key–value parameters. The fragment starts with#and is handled by the client; it is not sent to the server. After the scheme and colon,//introduces the authority. - A URL needs a retrieval method/scheme, a host name, and a path name to access a document.
The port number is optional because each scheme has a default: HTTP uses 80, HTTPS uses 443. DNS is not a part of URL syntax; DNS is used later to resolve the host name. - Percent-encoding encodes reserved or non-ASCII octets, for example space as
%20. DNS names are case-insensitive; URL scheme and host are case-insensitive in practice, while path and query are generally case-sensitive. - URI (Uniform Resource Identifier) is the general identifier; a URL locates a resource; a URN names a resource without saying where it is.
- DNS (Domain Name System) is a distributed, hierarchical naming database. It maps domain names to IP addresses and stores other records.
The namespace is an inverted tree: root, then TLD (top-level domain such as genericcomor country-codein), then second-level domains, then subdomains. A FQDN is a fully qualified domain name.
DNS normally uses UDP port 53; TCP port 53 is used for zone transfers and large/truncated responses. - Important DNS resource records: A maps a name to an IPv4 address; AAAA maps to an IPv6 address; CNAME maps a canonical hostname/alias to another domain name; MX gives the mail exchanger host and preference; NS gives an authoritative name server for a zone; PTR gives reverse mapping from IP address to name; SOA identifies the start of authority for a zone; TXT carries text data.
- ICANN stands for Internet Corporation for Assigned Names and Numbers. It is the non-profit organisation, founded in 1998, that coordinates the Internet’s unique identifier systems, including DNS names and IP addresses.
- DNS resolution uses resolvers and authoritative servers. A recursive query asks the contacted server to do the full work and return the final answer or an error.
An iterative query returns the best answer the server has, often a referral to another server.
A local resolver typically receives a recursive query from the host, then performs iterative queries to root, TLD, and authoritative servers. Answers are cached for their TTL (Time To Live). - Zone transfers between DNS servers use TCP port 53, because reliability matters; ordinary lookups usually use UDP.
- HTTP (Hypertext Transfer Protocol) is a stateless application-layer request–response protocol, normally over TCP on port 80; HTTPS is HTTP over TLS on port 443. HTTP/1.0 defaults to non-persistent connections; HTTP/1.1 defaults to persistent connections and supports pipelining; HTTP/2 adds multiplexing; HTTP/3 runs over QUIC.
- Hypermedia means linked information combining hypertext with multimedia. HTTP is the file-retrieval method used by the Web to transfer hypermedia documents; HTML is a markup language, not a retrieval method.
- HTTP methods: GET retrieves a resource; HEAD returns only response headers, no body; POST submits data; PUT replaces a resource; DELETE removes a resource; OPTIONS asks about capabilities; TRACE echoes the request; CONNECT creates a tunnel.
Safe methods do not intend to change server state: GET, HEAD, OPTIONS, TRACE. Idempotent methods have the same effect when repeated as when sent once: GET, HEAD, PUT, DELETE, OPTIONS, TRACE. POST is neither safe nor idempotent.
PUT is idempotent but not safe. HEAD is safe and idempotent. - HTTP status classes: 1xx informational, 2xx success, 3xx redirection, 4xx client error, 5xx server error.
Common codes: 200 OK, 301 Moved Permanently, 302 Found, 304 Not Modified, 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 500 Internal Server Error, 503 Service Unavailable. - HTTP headers: Host identifies the virtual host and is mandatory in HTTP/1.1; User-Agent identifies client software; If-Modified-Since makes a conditional GET; Set-Cookie asks the client to store a cookie; Cookie sends stored cookies back.
Cookies add state to stateless HTTP; they are stored by the client and sent on matching requests. - DNS, FTP, TELNET, and HTTP all follow the client–server model: the client initiates communication, and the server listens on a well-known port.
How it works
- The user enters a URL. The browser parses the scheme, host, optional port, path, query, and fragment. It checks its cache; if the host name is not already resolved, it needs an IP address.
- The host’s stub resolver asks the configured local recursive resolver. If the answer is cached and its TTL has not expired, the resolver returns it immediately.
Otherwise the resolver queries a root server, gets a referral to the relevant TLD server, queries the TLD server, gets a referral to the authoritative server, and finally gets the A or AAAA answer.
The answer is cached for its TTL. - The browser opens a TCP connection to the server port. A three-way handshake occurs: SYN, SYN-ACK, ACK.
- The browser sends an HTTP request, for example
GET /path HTTP/1.1with headers such as Host, User-Agent, Accept, and Cookie. The server sends a status line, response headers, and usually a body. - The browser renders the base document and requests embedded objects such as images. With non-persistent HTTP, each object needs a new TCP connection.
With persistent HTTP, the connection is reused; with pipelining, several requests can be sent without waiting for each response.
Drawing the diagram…
Formulas
-
Let be the number of embedded objects in a page, and let one RTT be one round-trip time. Ignore DNS lookup time and TCP teardown, and assume all objects are on the same server.
-
Non-persistent HTTP without parallel connections: each of the objects needs one RTT for TCP setup and one RTT for request/response.
RTT. -
Persistent HTTP without pipelining: one TCP setup, then one request/response per object.
RTT. -
Persistent HTTP with pipelining, when all embedded objects are requested in one batch after the base file:
RTT, independent of . -
DNS cache TTL: after elapsed time , remaining TTL is . If this is positive, the cached record is used; otherwise the resolver queries again.
Worked examples
Example 1 — URL components. Lakshmi types https://college:8443/student/results?sem=4#top. The scheme is https; the authority is college:8443; the host is college; the port is 8443; the path is /student/results; the query is sem=4; the fragment is top.
If the port were omitted, HTTPS would default to 443. DNS would resolve college to an IP address, and the fragment top would not be sent to the server.
Example 2 — RTT calculation. Harish opens a page with a base HTML file and 4 JPEG images on the same server. Ignore DNS and TCP teardown. Here .
Non-persistent HTTP: RTT. Persistent without pipelining: RTT. Persistent with pipelining, with all 4 images requested in one batch after the base file: RTT.
Example 3 — DNS record matching. Match A, AAAA, CNAME, MX, NS, PTR with functions. A gives IPv4 address; AAAA gives IPv6 address; CNAME gives an alias to another domain name; MX gives the mail exchanger host; NS gives an authoritative name server; PTR gives reverse mapping from IP address to name.
Example 4 — HTTP method statements. Statement I: GET is safe and idempotent. Statement II: PUT is idempotent but not safe. Statement III: POST is idempotent. Statement IV: HEAD is safe and idempotent and returns only headers. I is true; II is true; III is false because POST is not idempotent; IV is true.
Example 5 — Conditional GET. Sunita’s browser has a cached copy of a page and sends GET with If-Modified-Since. If the server’s copy is unchanged, the server returns 304 Not Modified with no entity body.
If the copy has changed, the server returns 200 OK with the new body. This saves bandwidth while keeping the cached copy valid.
Comparison
| Feature | Recursive DNS query | Iterative DNS query |
|---|---|---|
| Work done by contacted server | Full resolution; returns final answer or error | Returns best answer or referral |
| Typical use | Host to local resolver | Local resolver to root/TLD/authoritative servers |
| Client effort | Small | Resolver must continue querying |
| Method | Safe | Idempotent | Main use |
|---|---|---|---|
| GET | Yes | Yes | Retrieve resource |
| HEAD | Yes | Yes | Retrieve headers only |
| POST | No | No | Submit data, create resource |
| PUT | No | Yes | Replace resource |
| DELETE | No | Yes | Remove resource |
| OPTIONS | Yes | Yes | Ask capabilities |
| TRACE | Yes | Yes | Echo request |
| Mode | TCP connections | RTT formula with embedded objects | Default in |
|---|---|---|---|
| Non-persistent | One per object | HTTP/1.0 | |
| Persistent, no pipelining | One reused connection | HTTP/1.1 | |
| Persistent with pipelining | One reused connection | when all objects requested in one batch | HTTP/1.1 |
Revision summary
- URL order: scheme, authority, path, query, fragment; fragment is not sent to the server.
- Retrieval method, host name, and path are needed; port is optional; DNS is not part of a URL.
- Default ports: DNS 53, HTTP 80, HTTPS 443.
- DNS names are case-insensitive; DNS normally uses UDP, zone transfers use TCP.
- ICANN = Internet Corporation for Assigned Names and Numbers.
- Safe methods: GET, HEAD, OPTIONS, TRACE. Idempotent adds PUT and DELETE.
- HEAD returns headers only; 304 Not Modified has no body.
- HTTP is stateless; cookies add state at the application level.
- HTTP/1.0 is non-persistent by default; HTTP/1.1 is persistent by default.
- A cached A record with TTL 60 used after 30 seconds still has 30 seconds left; no new query is needed.
- Client–server examples: DNS, FTP, TELNET, HTTP.
- 301 permanent redirect; 302 temporary redirect; 403 forbidden; 401 unauthorized; 503 service unavailable.
Previous-year exam insights
- Direct full-form questions are common, especially ICANN, DNS, URL, and HTTP.
- URL questions test which components are required: retrieval method/scheme, host name, path; port is optional and DNS is not a URL component.
- Sequence questions ask the order after a fresh restart: DNS query first, then TCP SYN, then HTTP GET request.
- Client–server questions often list DNS, FTP, and TELNET together; all are client–server protocols.
- Match-the-list questions pair DNS records with functions or HTTP status codes with meanings; memorise A, AAAA, CNAME, MX, NS, PTR and 301, 304, 400, 403, 503.
- Statement-based questions test safe versus idempotent methods, statelessness of HTTP, cookie behaviour, and recursive versus iterative DNS.
- Numeric questions use RTT counting for non-persistent, persistent, and pipelined HTTP; check whether parallel connections are allowed.
- Traps: treating POST as idempotent, saying 304 carries a body, saying 403 means unauthorized, confusing DNS with a URL part, and using UDP for zone transfer.
Practice at PARIKSHA
You are ready for the PARIKSHA tests of this sub-topic when you can:
- parse any URL into scheme, authority, host, port, path, query, and fragment;
- state which URL parts are mandatory and which are optional;
- list and explain the main DNS record types with their functions;
- distinguish recursive from iterative DNS resolution with an example;
- trace the packet order for a fresh browser request: DNS, TCP SYN, HTTP GET;
- classify HTTP methods as safe and/or idempotent;
- match common HTTP status codes with their meanings;
- compute RTTs for non-persistent, persistent, and pipelined HTTP;
- explain how cookies add state to stateless HTTP;
- state the role and full form of ICANN and the default ports for DNS, HTTP, and HTTPS.
Attempt the sub-topic test first, then the subject test.