Networking Basics
How data travels from browser to server and back-the foundation of everything.
1The Postal System Analogy
Networking is the set of protocols and systems that enable computers to communicate. Understanding these fundamentals helps you debug issues and design better systems.
2The OSI Model (Simplified)
Data flows through layers. Each layer has a specific job:
For system design, focus on layers 4 (TCP/UDP) and 7 (HTTP/WebSocket). These are where most decisions happen.
3TCP vs UDP
TCP
Transmission Control Protocol
Pros
- ✓ Reliable delivery
- ✓ Ordered packets
- ✓ Error checking
- ✓ Flow control
Cons
- ✗ Higher latency
- ✗ Connection overhead
- ✗ Head-of-line blocking
UDP
User Datagram Protocol
Pros
- ✓ Low latency
- ✓ No connection setup
- ✓ No head-of-line blocking
- ✓ Broadcast support
Cons
- ✗ No delivery guarantee
- ✗ No ordering
- ✗ No congestion control
4HTTP Request Lifecycle
5Key Concepts
IP Address
Unique identifier for a device. IPv4 (192.168.1.1) or IPv6.
Port
Endpoint for specific service. HTTP=80, HTTPS=443, MySQL=3306.
DNS
Translates domain names to IP addresses. Like a phone book.
Latency
Time for data to travel. Measured in milliseconds (ms).
Bandwidth
Maximum data transfer rate. Measured in Mbps/Gbps.
Throughput
Actual data transferred. Limited by bandwidth and latency.
6Common Latency Numbers
| Operation | Latency |
|---|---|
| L1 cache reference | 0.5 ns |
| RAM access | 100 ns |
| SSD read | 150 µs |
| Same datacenter round trip | 0.5 ms |
| Same continent round trip | 50-100 ms |
| Cross-continent round trip | 150-300 ms |
7Key Takeaways
?Quiz
1. Video call uses which protocol primarily?
2. What adds ~150ms latency to a request?