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.

MethodPurposeNote
GETFetch a resourceSafe, idempotent; parameters in the URL
HEADHeaders onlyCheck size or freshness without the body
PUTStore or replace at a URIIdempotent
POSTSubmit data for processingNot idempotent: a retry may duplicate
DELETERemove a resourceIdempotent
TRACEEcho the requestOften disabled (cross-site tracing)
CONNECTOpen a tunnel via a proxyUsed for HTTPS through proxies
OPTIONSList allowed methodsUsed 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.

ModeWho does the walkingTypical use
RecursiveEach server asks the next on the requester's behalf and passes the answer backClient → local resolver
IterativeThe local resolver receives referrals (root → TLD → authoritative) and queries each itselfResolver → 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) and Content-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.