Networking / The TCP/IP model

The TCP/IP model

Follow one web request down the four layers of the internet, watch each layer wrap it in its own header, and see how the stack lines up with OSI.

Beginner7 steps~6 min
Application — what programs say: HTTP, DNS
Transport — program to program: TCP, UDP, ports
Internet — machine to machine: IP addresses
Link — one hop: Ethernet, Wi-Fi, MAC addresses
// THE SHORT VERSION

In 30 seconds

The internet splits the job of moving data into four layers: application, transport, internet and link. Each one solves a single problem and relies on the layer below.

On the way out, every layer wraps the data in its own header: TCP adds ports, IP adds addresses, Ethernet or Wi-Fi adds the next hop. This is encapsulation. The receiver unwraps in reverse.

The seven-layer OSI model describes the same work in finer slices, but TCP/IP is the set of protocols that was actually built and deployed.

The TCP/IP model, step by step

STEPS01 / 07

Header sizes are the minimums for IPv4, TCP and Ethernet; options make them longer. Where OSI layers 5 and 6 land is a convention: real protocols such as TLS do not fit either model neatly.

STEP 01 / 07 One job, four layers
THE MATH
application transport internet link
  1. Step 1: One job, four layers. Sending data between two programs is split into four smaller jobs, stacked. Each layer answers one question, hands its result to the layer below, and does not care how that layer does its work. That separation is why Wi-Fi can replace a cable without the web noticing.
  2. Step 2: Application: the message. A browser wants a page, so it writes an HTTP request: 100 bytes of text starting with GET /index.html. The application layer is where programs agree on what the bytes mean. It says nothing about how they travel.
  3. Step 3: Transport: which program. TCP puts a 20-byte header in front of the message. It carries port numbers, here 80 for the web server program, plus the sequence numbers TCP uses to detect loss and reorder. Wrapping data in a header like this is called encapsulation. The result is a segment.
  4. Step 4: Internet: which machine. IP adds its own 20-byte header with the source and destination IP addresses. Routers use only this header to pass the packet from network to network. IP makes no promise of delivery; repairing loss is left to TCP above.
  5. Step 5: Link: the next hop. The link layer gets the packet across one physical hop. Ethernet adds a 14-byte header holding the hardware (MAC) address of the next device, usually your router, and a 4-byte checksum at the end. The frame is what actually goes out as signals.
  6. Step 6: Across a router and back up. A router unwraps only as far as the IP header, picks the next hop and builds a fresh frame. The packet inside is carried end to end. At the server each layer strips its own header and passes the rest up, until the web server reads the same 100 bytes.
  7. Step 7: TCP/IP next to OSI. The OSI model splits the same work into seven layers. It is a reference model whose own protocols never caught on, while the TCP/IP protocols were already running and spread. So the internet is described by the four layers, and OSI survives as vocabulary: a “layer 2 switch”, a “layer 7 load balancer”.
VALUES SO FAR
layers4rule
message····HTTP
port····TCP
segment····TCP
to····IP
packet····IP
frame····Ethernet
OSI····model
// BEFORE

Learn this first

Nothing. This concept starts from scratch.

Spotted a mistake on this page?