Fiveable

📡Systems Approach to Computer Networks Unit 7 Review

QR code for Systems Approach to Computer Networks practice questions

7.1 File Transfer and FTP

7.1 File Transfer and FTP

Written by the Fiveable Content Team • Last updated August 2025
Written by the Fiveable Content Team • Last updated August 2025
📡Systems Approach to Computer Networks
Unit & Topic Study Guides

File Transfer Protocol (FTP)

FTP is the standard protocol for transferring files between computers over a network. It follows a client-server model where a user connects to a remote server to upload, download, and manage files. What makes FTP distinct from other protocols is its use of two separate connections: one for commands and one for actual data transfer.

Purpose of FTP

FTP solves a straightforward problem: moving files between machines that may be running different operating systems or file systems. The protocol handles the translation details so you don't have to.

A few key characteristics define how FTP works:

  • It uses a client-server model where the client initiates a connection, sends commands, and the server responds and performs the requested actions.
  • It establishes two separate TCP connections: a control connection (port 21) for sending commands and receiving responses, and a data connection (port 20 in active mode) for the actual file transfers and directory listings.
  • It provides reliable transfer by running over TCP, which guarantees delivery and correct ordering of data.

Common FTP client software includes FileZilla, WinSCP, and command-line FTP tools built into most operating systems.

Purpose of FTP, File:Client-server-model.svg - Wikipedia

Client-Server Architecture in FTP

The FTP client is the program you run on your local machine. It connects to the server, authenticates with a username and password, and then sends commands to browse directories, list files, and initiate transfers.

The FTP server listens for incoming connections on port 21. Once a client connects, the server authenticates the user, checks permissions, and then executes whatever commands the client sends. Server software examples include vsftpd, ProFTPD, and Microsoft IIS FTP server.

The separation of control and data connections is worth understanding clearly. The control connection stays open for the entire session, carrying your commands (RETR, STOR, etc.) and the server's reply codes. The data connection opens and closes as needed, each time a file transfer or directory listing occurs. This two-connection design is one of the things that makes FTP behave differently from HTTP, which multiplexes everything over a single connection.

Purpose of FTP, Client Server Network Architecture ~ I Answer 4 U

Active vs. Passive FTP Modes

FTP has two modes for establishing the data connection, and the difference comes down to who initiates that second connection.

Active mode works like this:

  1. The client opens a random high-numbered port and sends that port number to the server using the PORT command.
  2. The server then initiates the data connection from its port 20 to the client's specified port.
  3. The problem: firewalls and NAT devices on the client side often block this incoming connection from the server, since it looks like an unsolicited inbound request.

Passive mode flips the direction:

  1. The client sends a PASV command to the server.
  2. The server opens a random high-numbered port and replies with its IP address and that port number.
  3. The client then initiates the data connection to the server's specified port.
  4. Since the client initiates both the control and data connections, firewalls and NAT on the client side don't cause problems.

Passive mode is far more commonly used today because most clients sit behind firewalls or NAT routers that would block active mode's inbound data connection.

Common FTP Commands

FTP commands are sent as plain text over the control connection. Here are the ones you need to know:

CommandFunction
USERSends the username to the server for authentication
PASSSends the password (sent after USER)
PWDPrints the current working directory on the server
CWDChanges the current directory on the server
LISTRetrieves a list of files and directories in the current directory (sent over the data connection)
RETRDownloads a file from the server to the local machine
STORUploads a file from the local machine to the server
DELEDeletes a file on the server
MKDCreates a new directory on the server
RMDRemoves a directory on the server
QUITTerminates the session and closes the control connection

Notice that LIST and RETR/STOR all require a data connection to be established first. The command itself travels over the control connection, but the actual file content or listing travels over the data connection. Commands like PWD, CWD, and QUIT only use the control connection since they don't transfer file data.

The server responds to each command with a three-digit reply code (for example, 200 for success, 530 for authentication failure). These codes follow a pattern: 2xx means success, 3xx means the server needs more information, 4xx and 5xx indicate errors.