Back to the 2016 paper

Module 5: Application Layer & Security

20167m

Describe the functions of the two FTP connections. What kinds of file types can FTP transfer?

Worked SolutionAI Assisted

FTP: The Two Connections and the File Types It Can Transfer

FTP is unusual in that it uses two separate TCP connections between client and server: one long-lived control connection and one short-lived data connection.

1. Control connection (well-known port 21)

  • Established when the session starts and kept open for the whole session, closed only with QUIT.
  • Carries ASCII commands and replies: USER, PASS, PWD, CWD, LIST, RETR (retrieve), STOR (store), PORT/PASV, TYPE, QUIT and the 3-digit replies (220, 200, 226, 550, ...).
  • Small, interactive, one line at a time, always in ASCII mode; it controls the session, authentication and the state of the data connection.

2. Data connection (port 20 in active mode, negotiated ephemeral port in passive mode)

  • Opened only for one transfer (a file, a directory listing) and closed as soon as it finishes - one data connection per RETR/STOR/LIST.
  • Carries the actual file bytes or directory listing, in ASCII, EBCDIC or image (binary) mode.
  • Two variants:
    • Active mode (PORT): the server initiates the connection from its port 20 to the port the client advertised.
    • Passive mode (PASV): the server opens an ephemeral port and waits; the client connects to it - preferred today because it works through client-side NAT and firewalls.
  • Bulk data flows at full window size, independent of the interactive channel.

Separating the two lets the user stay logged in and issue further commands while (or between) transfers, and lets each transfer be optimised independently.

File types FTP can transfer

TYPE mode Purpose
ASCII (A) Text files; default - end-of-line characters are converted to/from the local convention (CRLF <-> LF)
EBCDIC (E) Text transfer between EBCDIC mainframes
Image / Binary (I) Byte-for-byte copy of any file: executables, images, PDFs, archives, compressed files
Local (L n) Machine-dependent byte size between two hosts

Conclusion: because image/binary mode transfers every bit unchanged, FTP can move any kind of file; the ASCII and EBCDIC modes exist only for character-set and newline conversion between dissimilar systems.

Similar questions

Budget AppAndroid App

Pocketly on Android

Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.