Back to the 2023 paper

Module 5: Application Layer & Security

20237m

Write short notes on FTP.

Worked SolutionAI Assisted

Short Notes on FTP (File Transfer Protocol)

Definition. FTP is an application-layer protocol of the TCP/IP model (Layer 5 of the TCP/IP stack, Layer 7 of the OSI model), standardised in RFC 959, for copying files between a client and a server over an IP network. It supports login/authentication, directory listing, upload, download, rename and delete, and can transfer files in ASCII (text) mode or image/binary mode (also EBCDIC), with file structures of file, record or page.

Two connections. FTP is unusual in using two separate TCP connections:

  • Control connection — port 21 (well-known). Carries commands and replies as 7-bit ASCII lines (USER, PASS, RETR, STOR, LIST, CWD, DELE, TYPE, PORT, PASV, QUIT) and remains open for the whole session.
  • Data connection — carries the actual file bytes; opened only for each transfer and closed afterwards.

Active vs passive mode.

  • Active mode: the server opens the data connection from its port 20 to an ephemeral port chosen by the client.
  • Passive mode (PASV): the client opens the data connection to an ephemeral port announced by the server. Passive mode is what works through NAT/firewalls, which normally refuse inbound connection attempts.

Features. User authentication with USER/PASS (anonymous FTP uses the username anonymous and any e-mail address as password), ASCII/binary translation so that text files are converted between operating-system line endings, remote directory navigation, and resumption of interrupted transfers. Reliability comes from TCP, so FTP needs no error correction of its own.

Security — the main limitation. Classic FTP transmits the password and file data in clear text; anyone sniffing the path can capture them. Secure alternatives are:

  • SFTP — SSH File Transfer Protocol, running over SSH on port 22; a completely different protocol, not FTP with security added.
  • FTPS — FTP secured with TLS/SSL: implicit TLS on port 990, or explicit AUTH TLS negotiated on port 21.

Other issue. The PORT command embeds the client's private IP address inside the payload, which breaks behind NAT; RFC 2428 added the EPRT/EPSV extensions and IPv6 support to solve this. Because FTP keeps control and data on different ports, it is also awkward for packet-filtering firewalls, which must be told to open both.

Similar questions

Free AppAndroid App

Coursify Android App

Generate AI courses, take quick quizzes between classes, and master complex engineering concepts on the go.