Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
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.
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
PORTcommand 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.
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.
