What are the FTP Connections?

File Transfer Protocol (FTP) uses two separate connections to facilitate communication between client and server. Understanding these connections is crucial for comprehending how FTP operates efficiently for file transfers.

Control Connection

The control connection is established first and remains active throughout the entire FTP session. This connection handles all commands and responses between the client and server.

The establishment process involves two steps:

  • The server issues a passive open on the well-known port 21 and waits for a client connection.

  • The client uses an ephemeral port and issues an active open to establish the connection.

This connection remains open during the entire FTP session, allowing continuous command exchange between client and server.

FTP Control Connection FTP Client Ephemeral Port (e.g., 1234) FTP Server Well-known Port (Port 21) Commands & Responses Control connection remains open throughout the session

Data Connection

The data connection is established separately for actual file transfers and uses port 20 on the server side. This connection is created on-demand for each file transfer operation.

The data connection establishment follows these steps:

  • The client issues a passive open using an ephemeral port for data transfer.

  • The client sends this port number to the server using the PORT command through the control connection.

  • The server receives the port number and issues an active open using the well-known port 20 and the client's ephemeral port number.

FTP Data Connection FTP Client Control: Ephemeral Data: Ephemeral (e.g., 1235) FTP Server Control: Port 21 Data: Port 20 Control Connection Data Transfer Data connection created on-demand for file transfers

Communication over Control Connection

FTP uses a similar approach to TELNET and SMTP for communication over the control connection. It employs the NVT ASCII character set and operates through command-response pairs. Each command or response consists of one short line, eliminating concerns about file format or structure during control communication.

Communication over Data Connection

For data transfer, the client must specify the file type and transmission parameters before sending data. The heterogeneity problem between different systems is resolved by defining three key attributes:

  • File Type − Defines the format of data being transferred

  • Data Structure − Specifies how the data is organized

  • Transmission Mode − Determines how data flows from FTP to TCP

File Types

File Type Description Use Case
ASCII Text files using ASCII encoding Plain text documents, configuration files
EBCDIC Text files using EBCDIC encoding Mainframe text files
Image (Binary) Files transferred without interpretation Executables, compressed files, media files

Data Structures

FTP supports two data structure types:

  • Byte-oriented structure − Data treated as a continuous stream of bytes

  • Record-oriented structure − Data organized as a sequence of records

Transmission Modes

FTP offers three transmission modes for data transfer:

  • Stream mode − Default mode where data flows as a continuous stream from FTP to TCP without any special formatting.

  • Block mode − Data is delivered in blocks, each preceded by a three-byte header containing block descriptor and size information.

  • Compressed mode − Large files are compressed before transmission, typically using Run Length Encoding (RLE) compression.

Conclusion

FTP uses two distinct connections: a persistent control connection on port 21 for commands and a separate data connection on port 20 for file transfers. This dual-connection architecture allows efficient file transfer while maintaining continuous command communication between client and server.

Updated on: 2026-03-16T23:36:12+05:30

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements