what happens at each layer of OSI?
The 7 Layers of the OSI Model
| # | Layer | Function | Common Protocols / Tools |
|---|---|---|---|
| 7 | Application | Where users and software interact | HTTP, HTTPS, DNS, SSH, SMTP, FTP, SNMP, etc. |
| 6 | Presentation | Translates, encrypts, and formats data | SSL/TLS, MIME, JSON, ASCII, JPEG |
| 5 | Session | Starts, manages, and ends sessions | TCP session, NetBIOS, RPC |
| 4 | Transport | Ensures data delivery (error checking, retransmission) | TCP, UDP, SCTP |
| 3 | Network | Handles routing and addressing between networks | IP, ICMP, ARP, BGP, OSPF |
| 2 | Data Link | Transfers frames between devices on same network | Ethernet, Wi-Fi (802.11), PPP, MAC addresses |
| 1 | Physical | Physical transmission of bits | Cables, fiber, voltage, NIC, switches |
Quick Mental Model
Let’s take curl https://ashwiniag.com . what happens at each layer?
| Layer | What’s happening |
|---|---|
| 7 - Application | Browser sends HTTP GET request |
| 6 - Presentation | TLS encrypts request (HTTPS) |
| 5 - Session | Session established via TCP handshake |
| 4 - Transport | TCP breaks data into segments, tracks ACKs |
| 3 - Network | IP routes packets to destination (public IP of server) |
| 2 - Data Link | Ethernet/Wi-Fi frames sent to next hop router |
| 1 - Physical | Bits flow through fiber/electric signals |
When debugging:
- Layer 1-2: cable unplugged, NIC down, bad Wi-Fi, ARP issue.
→ Tools: I don't know yet... - Layer 3: can’t reach IP → routing issue.
→ Tools:ping,traceroute,ip route - Layer 4: packets reach, but port closed.
→ Tools:nc,ss,telnet - Layer 7: DNS, HTTP issues.
→ Tools:curl,dig, logs.
Mnemonic to Remember
All People Seem To Need Data Processing
→ Application, Presentation, Session, Transport, Network, Data Link, Physical.
random notes
- Ports only exist in the Transport Layer (Layer 4),
- TCP: 80 (HTTP), 443 (HTTPS), 22 (SSH)
- UDP: 53 (DNS), ? (DHCP)
- ICMP lives in the Network Layer (Layer 3). operates directly on top of IP, not TCP or UDP