Computer ScienceCore24 min read

The Network Stack & Protocols

Why the internet is built in layers, and the protocols that run on each

This topic appears in:

Practise the full question bank:

01

Why layers at all

The internet is not one program — it is a stack of layers, each doing one job and trusting the layer below to do its own. This separation is the reason the internet works at all: Wi-Fi can change to fibre, or HTTP to a video protocol, without anything else needing to know. Each layer talks only to the layers directly above and below it.

The engineering idea is encapsulation: as your data travels down the stack to be sent, each layer wraps it in its own header (like putting a letter in an envelope, then a mailbag, then a truck); on the way up at the other end, each layer unwraps its own part.

Follow a message down the sending stack and back up the receiving one. Watch each layer add its header on the way down and strip it on the way up — that is encapsulation.

02

The layers, in the model you will be asked about

Two models are taught. The TCP/IP model (4 layers) is what the internet actually runs; the OSI model (7 layers) is the fuller teaching reference. Mapped to what each does:

Layer (TCP/IP)JobExample
Applicationthe software the user seesHTTP, HTTPS, DNS, SMTP
Transportend-to-end delivery between programsTCP, UDP
Internetrouting packets across networks by addressIP
Linkmoving bits over the physical mediumEthernet, Wi-Fi
03

TCP vs UDP: reliable or fast

The transport layer offers two very different services, and choosing between them is a classic question. TCP is reliable: it sets up a connection, numbers every segment, resends anything lost, and delivers everything in order — at the cost of speed and overhead. UDP is a fire-and-forget datagram: no connection, no resending, no ordering — but fast and lightweight.

So downloads, web pages and email use TCP (you need every byte, correct and in order); live video, voice calls and online games use UDP (a lost frame is better dropped than delivered late).

The one-line test

Does every byte have to arrive, correctly and in order? Use TCP. Does it matter more that it arrives now, and a little loss is acceptable? Use UDP. Streaming and gaming pick UDP for exactly that reason.

04

Ports, and the protocols on top

One computer runs many network programs at once, so the transport layer uses port numbers to say which program a message is for — like flat numbers within a building whose street address is the IP. Web servers listen on port 80 (HTTP) and 443 (HTTPS); DNS on 53.

HTTP is the application protocol of the web — a request for a page, a response with it. HTTPS is the same wrapped in TLS encryption, so nobody between you and the site can read or tamper with the traffic. It is why the padlock matters.

05

A worked example

Worked example

You are (a) loading a bank web page and (b) on a live video call. Which transport protocol suits each, and why?

  1. (a) The web page uses TCP (via HTTPS on port 443).Every byte of the page — and your login — must arrive correctly and in order; TCP guarantees that and TLS encrypts it.
  2. (b) The video call uses UDP.Arriving on time matters more than perfection; resending a lost frame would make the call lag, so a dropped frame is preferred.
  3. Both ride on IP at the internet layer, which routes their packets by address regardless of the transport choice.The layers are independent: the transport decision does not change how IP delivers packets.

Bank page → TCP (reliable, ordered, encrypted); video call → UDP (fast, tolerant of small loss). The layered design lets each choose freely.