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.
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.
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.
Definition: a protocol is a set of rules for the transmission of data between two devices.
What the rules cover: the format and structure of the data and headers; how devices are addressed; the order in which messages are exchanged (e.g. a handshake to start a connection); the timing of transmission; how errors are detected and corrected; what happens when data is lost.
Why essential: the sender and receiver must interpret the bits in exactly the same way. Protocols let devices made by different manufacturers, running different operating systems and software, communicate with each other.
Why standard: protocols are published standards, so anyone can build hardware or software that works on the internet.
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.
Layer
Purpose and function
Examples
Application
provides network services to applications; defines the format of the data the user's program sends and receives
HTTP, FTP, SMTP, POP3, IMAP, BitTorrent, DNS
Transport
controls 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 control
TCP (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 routers
IP (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 medium
Ethernet, WiFi
Why a stack? Each layer only deals with the layers directly above and below it, through a defined interface. A layer can be changed (e.g. WiFi replacing Ethernet at the Link layer) without changing the others.
This makes the system easier to design, develop, test and fault-find, and lets different manufacturers build different layers that still work together.
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.
Sender, Application: the browser creates an HTTP request for a web page and passes it down to the Transport layer.
Sender, Transport: TCP sets up a connection with the server (a handshake), splits the data into segments, and adds a header to each with the port numbers and a sequence number.
Sender, Internet: IP adds a header with the source and destination IP addresses, forming packets.
Sender, Link: each packet is put in a frame with the MAC address of the next device (usually the router) and sent as signals.
On the way: each router works only up to the Internet layer: it reads the destination IP address, chooses the next hop from its routing table and puts the packet in a new frame for the next link.
Receiver: the Link layer checks the frame and passes the packet up; IP checks the address and passes the segment up; TCP uses the sequence numbers to put the segments back in order, acknowledges them and requests any that are missing; the application (the web server) receives the complete request.
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?
Divide: 4500 / 1460 = 3.08..., so 3 full segments are not enough.
3 full segments carry 3 x 1460 = 4380 bytes.
Remaining: 4500 - 4380 = 120 bytes go in a 4th segment.
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?
Up to the Internet layer. It reads the destination IP address and uses its routing table to forward the packet to the next hop; it does not need the TCP or application data.
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.