A Level · Topic 14.1
A-Level Computer Science 9618 / Topic 14 / A2

Rules in layers.

Two computers made by different companies, running different operating systems, on opposite sides of the world, can still exchange a web page in a fraction of a second. That only works because both follow the same protocols. This lesson explains why protocols are essential and how TCP/IP organises them as a four-layer stack.

The key idea

A protocol is a set of rules that governs communication between devices: the format of the data, how it is addressed, how errors are detected and what happens when they are. Without agreed protocols, devices from different manufacturers could not understand each other. TCP/IP is a protocol suite arranged as a stack of four layers: Application, Transport, Internet and Link. Each layer has its own job, uses the services of the layer below and provides a service to the layer above. On the way down the stack each layer adds a header (encapsulation); on the way up the receiver's layers remove them.

the TCP/IP stack: each layer adds its own header Application Transport Internet Link data (HTTP) TCP data IP TCP data frame IP TCP data sending: wrap the receiver works back up the stack, removing each header in turn
Fig. 1: going down the TCP/IP stack, each layer wraps the data from the layer above in its own header
Section 01

Why protocols?

A protocol is to computers what a shared language plus a set of manners is to people: both sides must agree on it before any communication can happen.

Examiner trap

"A protocol lets computers communicate" is too vague for the mark. Say it is a set of rules and say why rules are needed: so that devices from different manufacturers or platforms interpret the data in the same way.

Section 02

A four-layer stack.

In the lab, step through a web page request: watch each layer on the sender add its header and each layer on the receiver remove it.

LayerPurpose and functionExamples
Applicationprovides network services to applications; defines the format of the data the user's program sends and receivesHTTP, FTP, SMTP, POP3, IMAP, BitTorrent, DNS
Transportcontrols the host-to-host connection: splits data into segments and adds source and destination port numbers (which application) and sequence numbers; at the receiver, reorders the segments, sends acknowledgements and asks for lost segments again; flow controlTCP (reliable, connection-based); UDP (faster, no guarantee of delivery)
Internet (network)adds the source and destination IP addresses to form packets; routes each packet across networks, hop by hop through routersIP (IPv4, IPv6)
Link (data link / network access)moves the data across one physical link: adds the MAC addresses of the next device to form a frame, adds an error check, and turns the bits into signals on the mediumEthernet, WiFi
Examiner trap

Do not mix up the addresses. Port numbers belong to the Transport layer, IP addresses to the Internet layer and MAC addresses to the Link layer.

Stage 1 · Learn

Check what the sim just showed you

Four quick checks. Each correct answer earns XP and records this skill on your profile.

Quick check+10 XP

Why is a protocol essential for communication between computers?

Quick check+10 XP

In the lab, which layer adds the source and destination IP addresses?

Quick check+10 XP

Which is a function of the Transport layer?

Quick check+10 XP

What is one benefit of implementing protocols as a stack of layers?

Section 03

From one host to another.

The syllabus asks you to apply the stack to a message sent from one host to another across the internet. Describe it layer by layer, down on the sender and back up on the receiver.

Worked example How many segments?
A browser sends 4500 bytes of data. The Transport layer can put at most 1460 bytes of data in each segment. How many segments are sent, and how many bytes does the last one carry?
  1. Divide: 4500 / 1460 = 3.08..., so 3 full segments are not enough.
  2. 3 full segments carry 3 x 1460 = 4380 bytes.
  3. Remaining: 4500 - 4380 = 120 bytes go in a 4th segment.
  4. Each segment gets a sequence number so the receiver can rebuild the data in the right order.
Answer: 4 segments; the last one carries 120 bytes
Your turn
A router receives a packet. Up to which layer of the TCP/IP stack does it process the packet, and what does it read there?
Examiner trap

Sequence numbers are added by the Transport layer, not by IP, and it is TCP at the receiver that reorders the data and requests lost segments.

Stage 2 · Exam

Exam-style questions

Unlocks once the four checks above are done. Worth more XP, written to A Level Paper 3 and Paper 4 standard.

Finish the four checks above to unlock the exam questions
Exam style+20 XP

Which TCP/IP layer is responsible for adding MAC addresses and transmitting frames across a physical link?

Exam style+20 XP

Segments arrive at a host out of order. Which layer puts them back in the correct order?

Exam style+20 XP

Which protocol is used at the Internet layer?

Exam style+20 XP

What is meant by encapsulation in the TCP/IP stack?

Skill unlocked

The TCP/IP stack, mastered.

This skill is now recorded on your profile. Keep the chain going.

-Rank -Level -Score -Topics
Go deeper · practice
Six original Cambridge-style questions
Why protocols are essential, protocols as a stack, the four TCP/IP layers and how a message passes down and up the stack between two hosts.