Protocols

Standards, and TCP, UDP, IP, HTTP, HTTPS, FTP, SMTP, POP and IMAP.

F10.7NetworksGCSE15 min

Covers OCR J277 1.3.2 Wired and wireless networks, protocols and layers · AQA 8525 3.5 Fundamentals of computer networks · Edexcel 1CP2 4.1.6 Protocols

Do this lesson in the simulator

Two devices can only communicate if they agree on the rules: what a message looks like, what order things happen in, and what to do when something goes wrong. Those rules are a protocol. You met the idea in module 9, where robots agreed on messages like forward 30. The internet runs on a set of protocols that every device in the world follows.

Standards

A standard is a set of rules agreed across an industry, so that equipment from different makers works together. A phone made by one company can join a Wi-Fi network built by another, and load a web page from a server built by a third, because all of them follow the same standards.

The protocols on the exam

Protocol What it is for
TCP (Transmission Control Protocol) splits data into packets, numbers them, checks they all arrive, puts them back in order and asks for missing ones again
UDP (User Datagram Protocol) sends packets without checking they arrive. Faster, used for live video and games where a late packet is useless anyway
IP (Internet Protocol) addresses packets and routes them between networks
HTTP (Hypertext Transfer Protocol) how a browser requests web pages from a web server, and how the server replies
HTTPS (HTTP Secure) HTTP with the data encrypted, so it cannot be read if intercepted. Used for logins and payments
FTP (File Transfer Protocol) sends files between computers
SMTP (Simple Mail Transfer Protocol) sends email to a mail server, and between mail servers
POP (Post Office Protocol) downloads email from the server to one device, usually removing it from the server
IMAP (Internet Message Access Protocol) reads email kept on the server, so it stays in sync on every device
Ethernet how devices send data over a wired LAN
Wi-Fi how devices send data over a wireless LAN

TCP and IP work together, so they are often called TCP/IP.

An email goes by SMTP from the sender's email program to their mail server, by SMTP again to the recipient's mail server, and is fetched from there by POP or IMAPsender'semail programsender'smail serverrecipient'smail serverrecipient'semail programSMTPSMTPPOP or IMAPsending: SMTP, program to server and server to serverfetching:POP or IMAP
SMTP only ever sends, so it carries the email all the way to the recipient's server. The email waits there until the recipient's program fetches it with POP or IMAP.

Requests and responses

An HTTP request names a method and a path: GET /index.html asks for a page. The server replies with a status code and the content. 200 means OK; 404 means Not Found. The Hub robot on this mat speaks a tiny version of HTTP:

# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()

send("GET /battery")
for tick in range(10):
    wait(0.1)
    for sender, text in messages():
        status, _, body = text.partition(" ")
        print("status:", status, "| the rest:", body)

Run this in the simulator

A timeline between a browser and a web server: the browser sends GET /index.html, and the server replies 200 OK with the page, or 404 Not Found if there is no such pagebrowser(the client)web serverGET/index.htmlmethodpathrequest200 OK+ the pagestatus coderesponseor 404 Not Found, if there is no such page
Every exchange follows the same rules: the client asks with a method and a path, and the server answers with a status code first, then the content if there is any.

Task: a tiny web client

Write request(path), which sends GET <path>, waits up to a second for the reply, and returns the status code as a number and the rest of the reply as text. Request /battery, /camera and /lights. For a status of 200, print <name>: <rest> (for example battery: 87, without the OK); otherwise print <name>: error <status>. Turn the LED green if the battery is above 50, and red if not.

# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()

Challenges

  1. Add a timeout: if no reply comes, print <name>: no reply.
  2. What status code would mean "you are not allowed"? Look up 403.
  3. For each of these, say which protocol is used: uploading a website to a server; reading email on a phone and a laptop; a live video call.