Teaching / Network protocols
Interactive lesson
Network Protocols
Computers are physically linked by cables, radio or light, yet applications behave as if they talk to each other directly. Protocols make that possible. Send a message down the stack, race packets across a network that breaks, and follow a web request from URL to page.
This page supports British University Vietnam students in the module Introduction to Computing Science (2024–2027 and onwards). It accompanies the Week 8 “Networks” lecture and continues from Networks and the Internet.
1 · Where do protocols fit in?
The protocol stack: a virtual link on top of a physical one
Only the bottom layer is physically connected. Every layer above talks to its partner layer on the other computer (the dashed “virtual links”) by handing its message to the layer below, which wraps it in a header. The Internet’s base protocol set is IP at the bottom with TCP on top. Higher-level protocols (HTTP, FTP, SMTP) sit on top of TCP.
Ready
The packet right now
IP: just deliver it
The Internet Protocol is only tasked with sending packets from one node to another. It does not handle lost, damaged or out-of-order packets.
TCP: make it reliable
The Transmission Control Protocol cares about data integrity. It splits the data into packets, adds a header with the order of reassembly and an error-checking value, and rebuilds the data at the destination. The TCP segment travels as the payload of an IP packet.
2 · How does data cross the network?
Packet switching vs circuit switching
Circuit switching reserves one dedicated path from end to end before any data moves (the old telephone network). Packet switching, invented to replace it, chops the message into packets that each find their own way. Send the same message both ways, then cut links and add loss.
Tip: click any link while it runs to cut it (click again to repair). Numbers in grey are link delays in ticks.
At the receiver
The application sees: —
What happened
Results
Packet switching: advantages
Much more efficient use of physical links (nobody owns a line while it is idle). More robust: more lines of communication, a lost connection only loses some of the data, and it is easier and faster to fix.
Packet switching: disadvantages
Lost packets (tiny fluctuations in power, conflicting Wi-Fi signals) and wrong order (packets on different routes arrive in different orders). The right protocol, TCP, fixes both.
3 · How do we name a machine?
IP addresses: IPv4 vs IPv6
An IPv4 packet header carries a 4-byte source address and a 4-byte destination address, giving 232 (about 4 billion) addresses for roughly 7.8 billion people. IPv6 uses 16-byte addresses.
IPv4 (4 bytes = 32 bits)
IPv6 (16 bytes = 128 bits)
How many addresses?
4 · What do we use it for?
HTTP: the protocol of the web
The World Wide Web is based on the Hypertext Transfer Protocol: a simple client–server protocol. The client is your browser; the server is the web server. Every document is addressed by a Uniform Resource Locator (URL).
A request and its response
Ready
What the browser shows
The full HTTP specification runs to well over a hundred pages. Status codes tell the client what happened: 404 Not Found, 403 Forbidden, 408 Request Timeout… and, most important (not really), 418 “I’m a teapot”.
Web portals: using HTTP to do more
A server can act as a portal to other systems: databases, resources, payment services. All e-commerce sites are portals. The server controls the client database, payment and stock database, and generates web pages dynamically. Try a purchase:
Ready
Page the browser gets
Things to try
- Count the overhead. Send a 3-letter message down the stack. How many bytes of headers surround it? Why is it worth it?
- Break the checksum. Tick Corrupt one bit and run the stack. Which layer notices, and what happens to the message?
- Circuit vs packet. Send the message both ways. Which method starts delivering sooner? Which uses more of the network’s links?
- Out of order. In packet mode with no TCP, send the message and look at what the application sees. Why do packets overtake each other?
- Turn on TCP and add 20% loss. Watch the retransmissions. How does the receiver restore the original order?
- Cut a link mid-way. Do it in packet mode, then in circuit mode. Which survives? Why?
- Crowd the network. Raise Other users in each mode. What does a circuit say? What do packets do?
- Change the answer. Make the server reply 404, 403 or 418. What does the browser show? Which part of the URL decided where the request went?