1. Protocols
14.1
Why protocols, and the TCP/IP stack
A protocol is an agreed set of rules for transmitting data: how data is formatted, addressed, sent, checked for errors and acknowledged. It is essential because the sender and receiver may use different hardware and software; only shared rules let them understand each other.
Protocols are implemented as a stack of layers. Each layer does one job, uses the services of the layer below and serves the layer above. Layers can be changed independently (Wi-Fi can replace Ethernet without changing the web browser), and the problem is easier to design and debug.
| Layer | Purpose and function | Examples |
|---|
| Application | provides services to applications; formats the data for the user's program and starts the communication | HTTP, HTTPS, FTP, SMTP, POP3, IMAP, BitTorrent, DNS |
| Transport | splits data into segments (packets) and numbers them; adds source and destination port numbers so data reaches the right application; with TCP, makes sure all packets arrive (acknowledgements, retransmission) and reassembles them in order; controls flow | TCP, UDP |
| Internet | adds source and destination IP addresses; routes each packet across networks, choosing the next hop | IP, routers |
| Link (network access) | moves the data across one physical link as frames; adds MAC addresses; converts to signals on the medium | Ethernet, Wi-Fi |
Worked Example
Describe what happens at each TCP/IP layer when an email is sent from a laptop to a mail server.
| Protocol | Purpose |
|---|
| HTTP / HTTPS | transfers web pages and other resources between a web server and a browser (HTTPS adds TLS encryption) |
| FTP | transfers files between a client and a server; supports login, upload, download, renaming and deleting files |
| SMTP | a push protocol: sends email from a client to a mail server and between mail servers |
| POP3 | downloads email from the server to one device; messages are usually deleted from the server afterwards |
| IMAP | email stays on the server and is synchronised, so it can be read and organised from several devices |
| BitTorrent | peer-to-peer file sharing: the file is split into pieces downloaded from many peers at once |
How BitTorrent works
torrent file
tracker
swarm
seed
leecher
2. Circuit Switching, Packet Switching