##
OSI & TCP/IP Model
Two reference stacks. The OSI model has 7 layers for teaching; TCP/IP collapses them into 4 for the real world.
// encapsulation — each layer adds a header
Data
L7–5
→ Segment
+TCP · L4
→ Packet
+IP · L3
→ Frame
+Eth · L2
→ Bits
L1
Sending goes top→bottom (encapsulation); receiving reverses it (de-encapsulation).
| # | OSI Layer | PDU | Examples | TCP/IP |
| 7 | Application | Data | HTTP, DNS, SMTP, FTP | Application |
| 6 | Presentation | Data | TLS/SSL, JPEG, ASCII | Application |
| 5 | Session | Data | RPC, NetBIOS, sockets | Application |
| 4 | Transport | Segment | TCP, UDP | Transport |
| 3 | Network | Packet | IP, ICMP, OSPF, BGP | Internet |
| 2 | Data Link | Frame | Ethernet, MAC, ARP, switch | Link |
| 1 | Physical | Bit | cable, fiber, hub, RJ45 | Link |
// what each layer does & where to troubleshoot
| # | Layer | Function | Lives here | Typical fault |
|---|
| 7 | Application | User-facing services & APIs | Hosts, proxies, WAF | App bug, bad URL, auth |
| 6 | Presentation | Encoding, encryption, compression | TLS, codecs | Cert / cipher mismatch |
| 5 | Session | Open / manage / close dialogs | RPC, sockets | Session timeout / reset |
| 4 | Transport | Reliability, ports, segmentation | TCP/UDP, firewalls | Port blocked, MSS/MTU |
| 3 | Network | Logical addressing & routing | Routers, L3 switches | Bad route, wrong subnet |
| 2 | Data Link | Framing & MAC addressing | Switches, NICs, APs | VLAN, duplex, STP loop |
| 1 | Physical | Bits on the medium | Cables, fiber, hubs | Bad cable, no link light |
// TCP/IP ↔ OSI mapping
| Application | L7 · L6 · L5 | HTTP, DNS, TLS, SMTP |
| Transport | L4 | TCP, UDP |
| Internet | L3 | IP, ICMP, routing |
| Link | L2 · L1 | Ethernet, ARP, cabling |
// mnemonics
| L7 → L1 | All People Seem To Need Data Processing |
| L1 → L7 | Please Do Not Throw Sausage Pizza Away |
// encapsulation order
Data → Segment → Packet → Frame → Bits