Module 8 — APIs
Networking Basics
TCP, UDP, HTTP, DNS—the foundation of all networked systems.
1The Postal System Analogy
💡 Simple Analogy
IP Address: Your street address
Port: Apartment number at that address
DNS: Phone book that converts "John's House" → "123 Main St"
TCP: Registered mail—guaranteed delivery, in order
UDP: Postcards—fast, no guarantees
Port: Apartment number at that address
DNS: Phone book that converts "John's House" → "123 Main St"
TCP: Registered mail—guaranteed delivery, in order
UDP: Postcards—fast, no guarantees
2OSI Model (Simplified)
7
Application
HTTP, FTP, SMTP
User-facing protocols
4
Transport
TCP, UDP
Reliable vs fast delivery
3
Network
IP
Routing between networks
2
Data Link
Ethernet, WiFi
Local network communication
1
Physical
Cables, Radio
Physical transmission
3TCP vs UDP
TCP
Connection-oriented, reliable, ordered.
- ✓ Guaranteed delivery
- ✓ In-order packets
- ✓ Error checking
- ✗ Higher latency
Use: HTTP, email, file transfer
UDP
Connectionless, fast, no guarantees.
- ✓ Low latency
- ✓ No connection setup
- ✗ No delivery guarantee
- ✗ Packets can arrive out of order
Use: Video streaming, gaming, DNS
4DNS Resolution
1
Browser: Do I have google.com cached? No.2
OS: Check /etc/hosts, then OS cache. No.3
Recursive Resolver: Check cache, ask root if not.4
Root DNS: I don't know google.com, try .com servers.5
.com TLD: google.com is at these nameservers.6
Google's NS: google.com → 142.250.190.787
Browser: Cache it, connect to that IP.5HTTP Overview
HTTP/1.1
One request per connection (or keep-alive). Text-based.
HTTP/2
Multiplexing (multiple requests on one connection). Binary, header compression.
HTTP/3 (QUIC)
Based on UDP. Faster connection setup, better mobile performance.
6Key Takeaways
1DNS converts domain names to IP addresses.
2TCP: reliable, ordered. UDP: fast, no guarantees.
3HTTP is application layer protocol built on TCP.
4HTTP/2 multiplexes requests; HTTP/3 uses UDP (QUIC).
5Know the OSI layers—helps debug network issues.
6In interviews: understand TCP handshake, DNS resolution, HTTP versions.