Stage 3 · Build
TCP/IP Fundamentals
The Network Model
OSI and TCP/IP models, how layers interact, and what engineers actually care about.
Why Layered Models Exist
Networking is too complex to solve as a single problem. A layered model breaks communication into manageable pieces, where each layer provides a well-defined service to the layer above and consumes services from the layer below. This separation means you can swap out one layer without rewriting the others — replace Wi-Fi with Ethernet at Layer 2 and TCP still works unchanged at Layer 4.
The two models you need to know are the OSI model (7 layers, the academic reference) and the TCP/IP model (4 layers, what the internet actually runs on). In practice, engineers mix terminology from both.
The OSI Model
The Open Systems Interconnection model defines seven layers. Each layer encapsulates data from the layer above with its own header. The layers go from physical signals on a wire to application-level APIs.
| Layer | Name | What It Does | Protocols/Examples |
|---|---|---|---|
| 7 | Application | User-facing protocols | HTTP, DNS, SMTP, SSH |
| 6 | Presentation | Data formatting, encryption | TLS, JPEG, ASCII |
| 5 | Session | Connection management | NetBIOS, RPC |
| 4 | Transport | End-to-end delivery | TCP, UDP, SCTP |
| 3 | Network | Routing and addressing | IP, ICMP, BGP, OSPF |
| 2 | Data Link | Frame delivery on a LAN | Ethernet, Wi-Fi, ARP |
| 1 | Physical | Bits on the wire | Cables, hubs, voltages |
A common mnemonic is Please Do Not Throw Sausage Pizza Away (Physical, Data Link, Network, Transport, Presentation, Application). In practice, layers 5, 6, and 7 are often lumped together as the application layer.
The TCP/IP Model
The TCP/IP model collapses OSI layers 5, 6, and 7 into a single Application layer, and merges OSI layers 1 and 2 into a Network Access layer. This is the model that the internet is built on.
| TCP/IP Layer | Maps to OSI | Key Protocols |
|---|---|---|
| Application | Layers 5, 6, 7 | HTTP, DNS, SMTP, SSH, TLS |
| Transport | Layer 4 | TCP, UDP |
| Internet | Layer 3 | IP (v4/v6), ICMP, ARP |
| Network Access | Layers 1, 2 | Ethernet, Wi-Fi, PPP |
Encapsulation and Headers
As data moves down the stack, each layer wraps the previous layer's data with its own header. This is encapsulation. At the receiving end, each layer strips its header and passes the payload up — decapsulation.
[Ethernet Header][IP Header][TCP Header][HTTP Payload]
L2 L3 L4 L7Each header contains addressing and control information for that layer. The Ethernet frame wraps an IP packet, which wraps a TCP segment, which wraps application data.
When you capture a packet with tcpdump, you see exactly this structure. The outermost header is Ethernet (source/destination MAC), followed by IP (source/destination IP), then TCP (source/destination port, sequence numbers), and finally the payload.
What Engineers Actually Use
Most software engineers work primarily at Layers 4 through 7. When debugging, you need to think about which layer the problem is at. Is it DNS (Layer 7)? TCP connection refused (Layer 4)? Unreachable host (Layer 3)? Bad cable (Layer 1)?
# Layer 1/2 - Is the link up?
ip link show eth0
# Layer 3 - Can we reach the host?
ping 8.8.8.8
# Layer 4 - Is the port open?
nc -zv example.com 443
# Layer 7 - Does the application respond?
curl -v https://example.comAlways start from the bottom layer and work up. If you cannot ping the IP, do not bother debugging HTTP. Fix connectivity first, then check the application.
You do not need to memorize all 7 OSI layers. You need to know that problems live at specific layers and to use the right tool for that layer. Ping tests Layer 3. nc tests Layer 4. curl tests Layer 7. Know which tool matches which layer.
Mark this lesson complete to store local progress and unlock a cleaner resume path the next time you visit.