Episode 1 — Fundamentals / 1.1 — How The Internet Works

1.1 How the Internet Works — Quick Revision

Compact cheat sheet. Print-friendly.

How to use this material (instructions)

  1. Skim top-to-bottom in one pass before quizzes or interviews.
  2. If a row feels fuzzy — reopen the matching lesson in README.md1.1.a1.1.e.
  3. Drills1.1-Exercise-Questions.md.
  4. Polished phrasing1.1-Interview-Questions.md.

1.1.a History of Web

Web 1.0 vs 2.0 vs 3.0

┌──────────┬─────────────────┬──────────────────┬──────────────────────┐
│          │ Web 1.0         │ Web 2.0          │ Web 3.0              │
├──────────┼─────────────────┼──────────────────┼──────────────────────┤
│ Mode     │ Read-only       │ Read-write       │ Read-write-own       │
│ Era      │ ~1991–2004      │ ~2004–present    │ Emerging / evolving  │
│ Content  │ Static pages    │ UGC, social,     │ Decentralized,       │
│          │                 │ APIs, mashups    │ wallets, ownership   │
│ Users    │ Consumers       │ Creators         │ Owners / participants│
└──────────┴─────────────────┴──────────────────┴──────────────────────┘

Key dates (anchor timeline)

YearEvent
1969ARPANET — first packet-switched network (US research)
1983TCP/IP becomes standard on ARPANET
1989Tim Berners-Lee proposes WWW (CERN)
1991First website / HTTP/HTML in use
1993CERN puts WWW software in public domain (no patent lock-in)
1994W3C founded; Mosaic → commercial browsers

Three pillars of the Web

PillarRole
HTMLStructure & semantics of documents
HTTPHow clients request and servers respond
URLGlobal address for a resource (scheme://host/path)

1.1.b How Computers Communicate

OSI 7 layers + mnemonic

Please Do Not Throw Sausage Pizza AwayPhysical, Data link, Network, Transport, Session, Presentation, Application

#LayerTypical unit / idea
7ApplicationHTTP, DNS, SMTP — user-facing protocols
6PresentationEncoding, encryption (conceptual)
5SessionDialog management (often folded into app)
4TransportTCP/UDP segments — end-to-end reliability/ports
3NetworkIP packets — routing, logical addressing
2Data linkFrames — MAC, switches, local delivery
1PhysicalBits on wire/fiber/radio

TCP/IP 4 layers (common mapping)

┌─────────────────────────────────────┐
│  Application  (HTTP, DNS, SSH…)     │  ← OSI 5–7
├─────────────────────────────────────┤
│  Transport    (TCP, UDP)            │  ← OSI 4
├─────────────────────────────────────┤
│  Internet     (IP, ICMP, routing)  │  ← OSI 3
├─────────────────────────────────────┤
│  Link         (Ethernet, Wi‑Fi…)   │  ← OSI 1–2
└─────────────────────────────────────┘

TCP vs UDP

┌─────────────┬────────────────────────────┬────────────────────────────┐
│             │ TCP                        │ UDP                        │
├─────────────┼────────────────────────────┼────────────────────────────┤
│ Connection  │ Connection-oriented        │ Connectionless             │
│ Reliability │ Retries, ordering, acks  │ Best-effort, no ordering   │
│ Overhead    │ Higher (state, headers)    │ Lower                      │
│ Use cases   │ Web, email, file transfer  │ DNS (often), VoIP, games   │
└─────────────┴────────────────────────────┴────────────────────────────┘

TCP 3-way handshake

Client                         Server
   │── SYN (seq=x) ──────────────►│
   │◄── SYN-ACK (seq=y, ack=x+1) ─│
   │── ACK (ack=y+1) ────────────►│
   │        Connection ESTABLISHED │

Encapsulation (sending down the stack)

[App data] → Segment (TCP/UDP hdr + payload) → Packet (IP hdr + segment)
           → Frame (L2 hdr/trailer + packet) → Bits on physical medium

Each hop may re-frame at L2; IP addresses usually unchanged end-to-end (unless NAT).

Key ports (memorize these)

PortService
20/21FTP (data / control)
22SSH
25SMTP
53DNS
67/68DHCP (server / client)
80HTTP
110POP3
143IMAP
443HTTPS
993IMAPS
995POP3S

1.1.c Data Travels Worldwide

FactDetail
Submarine share~95% of intercontinental data goes via submarine cables (not satellites for bulk)
Scale694+ submarine cable systems (count varies by source/year)
Fiber / DWDMLight in fiber; DWDM = many wavelengths (colors) on one fiber → huge capacity
RepeatersUndersea repeaters/amplifiers roughly every 80–100 km to restore signal
PacketsTypical MTU ~1500 bytes on Ethernet (IP packet payload capped by path MTU)
RoutingBGP exchanges routes between autonomous systems (AS); policy + path selection
IXPInternet Exchange Point — networks peer & swap traffic locally
CDNEdge caches closer to users → lower latency, offload origin
LatencySpeed of light + hops; hard lower bound — London↔NYC ~30–40 ms RTT fiber (order of magnitude; real paths higher)

1.1.d Domain Names / IP / MAC / Routing

Three address types

Domain  → Human-meaningful names (google.com)     — resolved via DNS
IP      → Global logical routing (203.0.113.5)    — Layer 3, routable
MAC     → Local hardware identity on a segment    — Layer 2, flat, broadcast domain

IPv4 vs IPv6

IPv4IPv6
Size32-bit128-bit
NotationDotted decimalHex groups (2001:db8::1)
Addresses~4.3B (exhausted in practice)Vast space
NATVery commonDesigned to reduce need (still exists in places)

Public vs private (IPv4 examples)

Range (RFC 1918)Use
10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16Private LAN
Others (with exceptions)Public routable (ISP-assigned)

Special IPs

AddressMeaning
127.0.0.1Loopback (this host)
0.0.0.0“Any” / unspecified (context-dependent)
8.8.8.8Google public DNS (example of anycast resolver)
169.254.x.xLink-local (APIPA) when DHCP fails

Hop behavior

  • MAC changes each hop (L2 rewrites to next segment’s destination MAC).
  • IP (src/dst) usually unchanged end-to-end unless NAT or tunneling.

ARP

ARP maps IP → MAC on the same subnet (broadcast “who has this IP?”).

Subnetting quick ref

  • /24 = 256 addresses, 254 usable hosts (minus network + broadcast in classic IPv4).
  • /16, /8 — scale host bits accordingly: usable ≈ 2^(32-prefix) - 2 (classical IPv4).

1.1.e ISP and DNS

ISP tiers (simplified)

TierRole
Tier 1Global backbone; often settlement-free peering with other tier-1s
Tier 2Regional/national; buys transit + peers at IXPs
Tier 3Last-mile / access ISP; sells to homes & businesses

DNS resolution — 7-step model (conceptual chain)

  1. App asks OS stub resolver for google.com.
  2. Stub checks OS cache; miss → queries configured resolver (often ISP or 8.8.8.8).
  3. Recursive resolver checks its cache; miss → starts iterative queries.
  4. Query root (.) → referral to TLD servers (.com).
  5. Query TLD → referral to authoritative nameservers for google.com.
  6. Query authoritative → get A/AAAA (or chain via CNAME).
  7. Answer cached (with TTL) → returned to stub → to app.

Key DNS records

RecordPurpose
AIPv4 address
AAAAIPv6 address
CNAMEAlias to another name
MXMail server for domain
NSDelegates DNS to nameservers
TXTArbitrary text (SPF, DKIM, verification)

DHCP — DORA

StepMessageDirection
DDiscoverClient → broadcast
OOfferServer → client
RRequestClient → server
AAcknowledgeServer → client

Client gets IP, subnet mask, gateway, DNS servers, lease time.

DNS security & transport

TechWhat it does
DNSSECCryptographic signing — authenticity & integrity (not confidentiality)
DoHDNS over HTTPS (port 443, hides DNS in HTTPS to resolver)
DoTDNS over TLS (dedicated port 853)

Public DNS options (examples)

  • 8.8.8.8 / 8.8.4.4 (Google), 1.1.1.1 (Cloudflare), 9.9.9.9 (Quad9), ISP default.

Master workflow — visiting google.com (16 steps)

  1. User enters URL; browser parses scheme/host/path.
  2. Browser checks HSTS/preload and builds HTTPS URL if applicable.
  3. DNS: resolve google.comA/AAAA (via stub → recursive → authoritative chain).
  4. OS returns IP(s); browser may pick one (e.g. Happy Eyeballs IPv6/IPv4 race).
  5. TCP SYN to 4433-way handshake with chosen IP.
  6. TLS handshake: certs, cipher agreement, session keys.
  7. HTTP/2 or HTTP/3 connection; ALPN negotiates application protocol.
  8. Browser sends HTTP request (headers, optional body).
  9. Packets encapsulated: TCP segment → IP packet → Ethernet/Wi‑Fi frame.
  10. Default gateway receives frame; routing table sends toward ISP.
  11. NAT (typical home): private IP → public IP mapping on outbound.
  12. Many routers forward by longest-prefix match; BGP at ISP boundaries.
  13. Possibly IXP peering or tier-1 transit; submarine/long-haul as needed.
  14. Google edge (Anycast / CDN-like) receives traffic; load balancing internally.
  15. Server processes request; response encrypted over TLS, chunked/compressed.
  16. Browser renders HTML; parallel fetches (CSS/JS/images); caching for repeat visits.

One-liner definitions (20+ terms)

TermOne-liner
ProtocolAgreed rules for format and order of messages between systems.
PacketUnit of data at Layer 3 (IP header + payload), routed independently.
RouterL3 device; forwards packets between networks using IP & routing tables.
SwitchL2 device; forwards frames by MAC within a LAN (VLAN-aware in managed switches).
FirewallEnforces allow/deny rules on traffic (stateful often tracks connections).
ProxyIntermediary that forwards client requests (may cache, filter, anonymize).
VPNEncrypted tunnel over untrusted network; virtual presence on another network.
Load balancerDistributes traffic across servers for scale and availability.
LatencyTime for a signal/request to travel (RTT = round-trip).
BandwidthMax data rate capacity of a link or path (theoretical upper bound).
ThroughputActual achieved data rate under real conditions.
ISPInternet Service Provider — access and/or transit to the global Internet.
DNSHierarchical naming system resolving hostnames to IP addresses.
DHCPAuto-assigns IP configuration (address, mask, gateway, DNS) via lease.
NATMaps many private IPs to fewer public IPs at a gateway.
ARPResolves IP to MAC on the same broadcast domain.
BGPPath-vector protocol; ISPs exchange reachability for IP prefixes.
CDNGeographically distributed caches to serve content closer to users.
IXPPhysical location where networks interconnect and exchange traffic.
TLDTop-Level Domain (e.g. .com, .org) — DNS tree under root.
TTLDNS: cache lifetime for a record; IP: hop limit (decremented per router).
EncapsulationWrapping data in successive headers as it descends the stack.
HandshakeTCP’s synchronized start (SYN, SYN-ACK, ACK) before data transfer.
MTUMaximum Transmission Unit — largest frame/payload size on a link segment.

End of 1.1 quick revision.