Computer Networks — OSI Model
OSI Model (7 Layers)
Open Systems Interconnection — reference model for network communication
``
Layer 7 — APPLICATION → HTTP, FTP, SMTP, DNS
Layer 6 — PRESENTATION → Encryption, Compression, Translation
Layer 5 — SESSION → Session management, Authentication
Layer 4 — TRANSPORT → TCP, UDP — End to end delivery
Layer 3 — NETWORK → IP, Routing — Logical addressing
Layer 2 — DATA LINK → MAC, Ethernet, Framing
Layer 1 — PHYSICAL → Cables, Bits, Signals
``
Mnemonic: "All People Seem To Need Data Processing"
Layer Details
Layer 7 — Application
• Interfaces with user applications
• Protocols: HTTP (web), FTP (file transfer), SMTP (email), DNS (name resolution)
• Data unit: Message
Layer 4 — Transport
• TCP (Transmission Control Protocol)
- Connection-oriented (3-way handshake: SYN → SYN-ACK → ACK)
- Reliable, ordered delivery
- Flow control, error control
- Used for: web browsing, email, file transfer
• UDP (User Datagram Protocol)
- Connectionless
- No reliability guarantee
- Faster, less overhead
- Used for: video streaming, gaming, DNS queries
Layer 3 — Network
• IP addressing and routing
• IPv4: 32-bit address (e.g., 192.168.1.1)
• IPv6: 128-bit address
• Protocols: IP, ICMP, ARP, RIP, OSPF
Layer 2 — Data Link
• MAC address (48-bit hardware address)
• Framing, error detection (CRC)
• Protocols: Ethernet, WiFi, PPP
• Devices: Switch, Bridge
Layer 1 — Physical
• Actual transmission of bits
• Media: copper wire, fiber optic, wireless
• Devices: Hub, Repeater, Modem
TCP vs UDP Comparison
| Feature | TCP | UDP |
|---------|-----|-----|
| Connection | Connection-oriented | Connectionless |
| Reliability | Reliable | Unreliable |
| Speed | Slower | Faster |
| Ordering | Ordered | No ordering |
| Use case | HTTP, FTP, Email | DNS, Streaming, Gaming |
IP Addressing
Classes:
• Class A: 1.0.0.0 – 126.0.0.0 (Large networks)
• Class B: 128.0.0.0 – 191.255.0.0 (Medium)
• Class C: 192.0.0.0 – 223.255.255.0 (Small — home/office)
Private IP ranges:
• 10.0.0.0/8
• 172.16.0.0/12
• 192.168.0.0/16
PYQ
Q: Explain OSI model with functions of each layer.
Q: Difference between TCP and UDP with examples.
Q: What is subnetting? Calculate subnet mask for given hosts.