AQA 7517, section 4.9.4.2
Application layer protocols are the rules used by programs, such as a browser or an email program, to talk to servers. Each protocol uses a well-known port on the server (see 4.9.4.1).
The protocols
| Protocol | Full name | Port | Purpose |
|---|---|---|---|
| FTP | File Transfer Protocol | 21 | Transferring files between a client and a server |
| HTTP | Hypertext Transfer Protocol | 80 | Requesting and sending web pages |
| HTTPS | HTTP Secure | 443 | HTTP encrypted (using TLS) |
| SMTP | Simple Mail Transfer Protocol | 25 | Sending email (and passing it between mail servers) |
| POP3 | Post Office Protocol (v3) | 110 | Retrieving email from a server to a client |
| SSH | Secure Shell | 22 | Secure remote login and command execution |
FTP
FTP is used to upload and download files, for example to put a website's files on a web server. A person uses FTP client software to connect to an FTP server.
Anonymous and non-anonymous access
- Anonymous FTP: the user logs in with the name
anonymous(and often an email address as a password). No account is needed. It is used for public downloads, usually read-only, such as software or documents anyone may have. - Non-anonymous FTP: the user has an account with a username and password, which controls what they can see and change. It is used for private files and for uploading.
FTP sends the username, password and files unencrypted, so it is not secure on its own (secure alternatives exist).
HTTP and HTTPS
HTTP is the protocol of the World Wide Web. A client sends a request and the server sends a response.
GET /index.html HTTP/1.1
Host: www.example.com
GET asks for a resource. The server replies with a status code (such as 200 for success, or 404 for not found) and the content.
HTTPS is the same, but the connection is encrypted with TLS, so that others can't read or change the data in transit. It also lets the browser check the server's identity using a digital certificate. It is used for logins, payments and, today, most sites.
SMTP and POP3: email
- SMTP is used to send email: from your email program to your mail server, and between mail servers on its way to the recipient.
- POP3 is used to retrieve email: your email program connects to its mail server and downloads the messages, usually removing them from the server.
The role of an email server
An email server:
- receives email sent to its users, using SMTP, and stores it in each user's mailbox;
- sends outgoing email, and forwards it to the recipient's mail server;
- lets users retrieve their stored messages (using POP3, for example);
- checks the user's login details.
SSH
SSH (Secure Shell) lets you log in securely to a remote computer and run commands on it, over an encrypted connection. It uses port 22. It is mainly used for remote management, such as an administrator looking after a server that is far away.
$ ssh admin@192.168.1.50
admin@192.168.1.50's password: ********
admin@server:~$ ls
admin@server:~$ shutdown -h now
Everything, including the password and the commands, is encrypted, unlike older tools such as Telnet.
Using an SSH client to connect to a remote port
An SSH client can open a TCP connection to a remote port and send that port the commands of an application-level protocol directly, for example:
- a
GETrequest to port 80, to fetch a web page using HTTP; - SMTP commands (such as
HELO,MAIL FROMandRCPT TO) to port 25, to send an email; - POP3 commands (such as
USER,PASSandRETR) to port 110, to retrieve email.
This is useful because SSH can tunnel through a firewall that blocks those other ports. Only port 22 needs to be open, and the commands travel encrypted inside the SSH connection.
The web server and the web browser
Web server
A web server is a program (on a computer) that stores web pages and serves them to clients. When it gets an HTTP request, it finds the page and sends it back as text (HTML), together with a status code. It may also send other files, such as images and stylesheets.
Web browser
A web browser (such as Chrome or Firefox) is the client program that:
- Sends the request for a page (using HTTP or HTTPS), after finding the IP address with DNS.
- Retrieves the HTML, then requests the other resources the page needs (images, CSS stylesheets, JavaScript files).
- Renders the page: it reads the HTML and CSS and draws the page on screen as intended, and runs any JavaScript.
Worked example
Task: explain what happens when Amy sends an email to Ben, who reads it later.
- Amy's email program sends the message to her mail server using SMTP.
- Her mail server forwards it, again using SMTP, to Ben's mail server, which stores it in his mailbox.
- Later, Ben's email program connects to his mail server and retrieves the message using POP3.
Exam tip: don't mix these up: SMTP sends, POP3 retrieves. HTTPS is HTTP plus encryption. FTP transfers files. SSH gives secure remote access. Learn the port numbers, since they link to the well-known ports.
Check yourself
Which protocol is used to send email, and which to retrieve it?
SMTP is used to send email, and POP3 is used to retrieve it.
What is the difference between HTTP and HTTPS?
HTTPS is HTTP with the connection encrypted (using TLS), so the data can't be read or altered in transit and the server's identity can be checked.
What is the difference between anonymous and non-anonymous FTP?
Anonymous FTP needs no account, and is used for public, usually read-only, files. Non-anonymous FTP needs a username and password, which control what the user can access.
What is SSH used for?
Logging in securely to a remote computer and running commands on it, over an encrypted connection.
What does a web browser do with the HTML it receives?
It retrieves the other resources the page needs, then renders the page (draws it on screen), and runs any scripts.