Learn › Part 1 ยท Networking foundations
Application layer: HTTP, DNS, e-mail and FTP
HTTP methods and persistence, DNS hierarchy and resolution, SMTP/POP/IMAP with MIME, and FTP's two connections.
HTTP
HTTP runs over TCP (port 80; HTTPS on 443). It is stateless: each request stands alone, and cookies or tokens carry state such as logins. It is in-band: commands and content share one connection.
| Method | Purpose | Note |
|---|---|---|
| GET | Fetch a resource | Safe, idempotent; parameters in the URL |
| HEAD | Headers only | Check size or freshness without the body |
| PUT | Store or replace at a URI | Idempotent |
| POST | Submit data for processing | Not idempotent: a retry may duplicate |
| DELETE | Remove a resource | Idempotent |
| TRACE | Echo the request | Often disabled (cross-site tracing) |
| CONNECT | Open a tunnel via a proxy | Used for HTTPS through proxies |
| OPTIONS | List allowed methods | Used in CORS pre-flight |
Persistent versus non-persistent connections
Non-persistent (HTTP/1.0): about 2 RTT per object (handshake + request). Persistent (HTTP/1.1 keep-alive, no pipelining): 1 RTT for the handshake, then 1 RTT per object.
Worked example
Page = 1 HTML + 5 images = 6 objects. Non-persistent serial: 6 × 2 = 12 RTT and 6 TCP connections. Persistent: 1 + 6 = 7 RTT on one connection.
DNS
DNS maps names to addresses (and back). Ordinary queries use UDP 53; zone transfers and large answers use TCP 53. The namespace is an inverted tree: root (13 logical root server addresses, A–M, served by anycast), top-level domains (generic such as .com, .org; country such as .in) and authoritative servers for each zone. Reverse lookups use PTR records.
| Mode | Who does the walking | Typical use |
|---|---|---|
| Recursive | Each server asks the next on the requester's behalf and passes the answer back | Client → local resolver |
| Iterative | The local resolver receives referrals (root → TLD → authoritative) and queries each itself | Resolver → hierarchy |
The resolver caches answers for the record's TTL, so repeat lookups skip the walk (the cost of the full walk is the “DNS overhead”).
E-mail: SMTP, POP3/IMAP and MIME
- SMTP (TCP 25) is a push protocol: client to its server, then server to server (mail transfer agents). Store-and-forward means the recipient need not be online.
- POP3 / IMAP are pull protocols used by the recipient's mail access agent.
- MIME lets 7-bit ASCII SMTP carry binary and non-Latin content: headers
MIME-Version,Content-Type(e.g.application/pdf) andContent-Transfer-Encoding(e.g.base64). Base64 turns every 3 bytes into 4 characters, so 3,000 bytes become 4,000 characters. - Webmail: the browser speaks HTTP(S) to a web front end; SMTP still moves mail between providers behind it.
FTP
FTP is out-of-band: a persistent control connection on TCP 21 carries commands and replies, and a separate data connection (port 20 in active mode, or a negotiated port) carries each listing or file. A firewall that allows only port 21 lets you log in but not transfer.
Common pitfalls
- Persistent connections are not a session mechanism; cookies are.
- In iterative resolution the root never contacts the TLD itself; it refers the resolver there.
- MIME encodes; it does not encrypt.