File Transfer Protocol (FTP) 2020bece037
File Transfer Protocol (FTP) 2020bece037
Protocol (FTP)
Introduction
File Transfer Protocol (FTP) is the standard protocol provided by TCP/IP for
copying a file from one host to another.
FTP is preferred over HTTP for transferring large files or files with different
formats.
The two connections in FTP are control connection and data connection.
The control connection remains connected during the entire interactive FTP
session. The data connection is opened and then closed for each file transfer
activity
FTP uses two well-known TCP ports: port 21 is used for the control connection, and
port 20 is used for the data connection.
Conrol Connection
This simple method is adequate for the control connection because we send one
command (or response) at a time.
Each line is terminated with a two-character (carriage return and line feed) end-
of-line token.
During this control connection, commands are sent from the client to the server
and responses are sent from the server to the client.
Commands, which are sent from the FTP client control process, are in the form of
ASCII uppercase, which may or may not be followed by an argument.
Some FTP commands
Responses
The data connection uses the well-known port 20 at the server site and for the client
side, it uses an ephemeral port.
The client issues a passive open using an ephemeral port. This must be done by the
client because it is the client that issues the commands for transferring files.
Using the PORT command the client sends this port number to the server.
The server receives the port number and issues an active open using the well-known
port 20 and the received ephemeral port number.
Communication over Data Connection
The client must define the type of file to be transferred, the structure of the data, and the
transmission mode.
Before sending the file through the data connection, we prepare for transmission through the
control connection.
File Type
FTP can transfer one of the following file types across the data connection: ASCII file, EBCDIC file,
or image file.
Data Structure
FTP can transfer a file across the data connection using one of the following interpretations of
the structure of the data: file structure, record structure, or page structure.
Transmission Mode
FTP can transfer a file across the data connection using one of the following three transmission
modes: stream mode, block mode, or compressed mode
File Transfer
File transfer occurs over the data connection under the control of the commands sent over the
control connection.
However, we should remember that file transfer in FTP means one of three things: retrieving a
file (server to client), storing a file (client to server), and directory listing (server to client).
FTP for retrieving a file
Security for FTP
The FTP protocol was designed when security was not a big issue.
The data transfer connection also transfers data in plain- text, which is insecure.
To be secure, one can add a Secure Socket Layer between the FTP application layer and
the TCP layer. In this case FTP is called SSL-FTP.