~/netref / OSI & TCP/IP
##

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 LayerPDUExamplesTCP/IP
7ApplicationDataHTTP, DNS, SMTP, FTPApplication
6PresentationDataTLS/SSL, JPEG, ASCIIApplication
5SessionDataRPC, NetBIOS, socketsApplication
4TransportSegmentTCP, UDPTransport
3NetworkPacketIP, ICMP, OSPF, BGPInternet
2Data LinkFrameEthernet, MAC, ARP, switchLink
1PhysicalBitcable, fiber, hub, RJ45Link
// what each layer does & where to troubleshoot
#LayerFunctionLives hereTypical fault
7ApplicationUser-facing services & APIsHosts, proxies, WAFApp bug, bad URL, auth
6PresentationEncoding, encryption, compressionTLS, codecsCert / cipher mismatch
5SessionOpen / manage / close dialogsRPC, socketsSession timeout / reset
4TransportReliability, ports, segmentationTCP/UDP, firewallsPort blocked, MSS/MTU
3NetworkLogical addressing & routingRouters, L3 switchesBad route, wrong subnet
2Data LinkFraming & MAC addressingSwitches, NICs, APsVLAN, duplex, STP loop
1PhysicalBits on the mediumCables, fiber, hubsBad cable, no link light
// TCP/IP ↔ OSI mapping
ApplicationL7 · L6 · L5HTTP, DNS, TLS, SMTP
TransportL4TCP, UDP
InternetL3IP, ICMP, routing
LinkL2 · L1Ethernet, ARP, cabling
// mnemonics
L7 → L1All People Seem To Need Data Processing
L1 → L7Please Do Not Throw Sausage Pizza Away

// encapsulation order

Data → Segment → Packet → Frame → Bits