Updated May 30, 2023
Introduction to FTP
FTP stands for File Transfer Protocol. It is a protocol that is used for transforming a file from one location to another, i.e. from one host to another host. It is a standard mechanism that is provided by TCP/IP. Transforming files from one system to another seems very simple, but some problems need to be dealt with before transforming files.
For example, two systems may use a different file name convention; two systems may have different directory structures. Two systems may have a different way of representing data; all problems are resolved by File Transfer Protocol. Before Transforming files from one host to another, it takes care of this thing and then transfers the files.
How does it Work?
It uses TCP services. It needs two TCP connections. One is a Control connection, and another is a Data connection. For control connection, it uses well-known port 21, and for data connection, it uses well-known port 20.
1. Control Connection
A server site control connection uses a well-known port 21.
There are two steps to establish a control connection:
- The server issues a passive open on the well-known port 21 and waits for the client.
- After severing issues passive open, the client issue active open using an ephemeral port.
This control connection remains open throughout the process. Since the user and the server uses the interactive connection for communication, their service used by internet protocol minimizes the delay. For communication, the user types the command, and in return, servers give responses without any delay.
2. Data Connection
At the server-side, the data connection uses well-known port 20.
There are three steps to establish a data connection:
- Using ephemeral port client issues a passive open. This step must be done by the client, not the server because the client wants to transform the file.
- Using the PORT command client sends this port number to the server.
- When the server receives this port number from the client, it issues active open using well-known port 20.
3. Communication
Both the client and the server, which runs on two different systems, must be communicated for transforming data. For communication, it uses two approaches, i.e. communication over control connection and communication over a data connection.
- Communication over the control connection
To communicate over the control connection, FTP uses TELNET or SMTP. It uses the NVT ASCII character set. Commands and responses do communicate over the control connection. The first command is sent over the connection, and in return, a response is sent by another system. We can send a command or response at a time. There is only one-way communication.
- Communication over the data connection
To transform a file over the data connection, the client must define the type of file that needs to be transformed, transmission mode, and data structure. It solves the heterogeneity problem by defining these three attributes.
4. Command Processing
To establish communication between the client system and the server system, FTP uses a control connection. During this process, the client sends commands to the server, and in return, the server sends a response to the client.
Types of FTP Transfers
It can transfer the following file types across internet connections:
- ASCII File: This is the default format for transforming a file from one to another. Each character is encoded by NVT ASCII, i.e. Network Virtual Terminal ASCII character set. Both the sender and the receiver transform their file from its own representation into NVT ASCII.
- EBCDIC: If sender or receiver connections use the EBCDIC encoding method, then for transforming files, FTP uses EBCDIC encoding.
- Image File: For transforming the binary file, the image file is the default mode. The file is transformed over the internet connections in the form of stream bits without encoding.
Transmission Modes of FTP
For transforming files across the internet connection, it uses three transmission modes.
- Stream Mode
- Block Mode
- Compressed Mode
1. Stream Mode
This is called a default mode. In this mode, data transforms from FTP to TCP in the form of stream bytes. Here TCP is responsible for fragmenting data into small segments. If transforming data are already in the form of stream bytes, then the data connection is automatically closed. Otherwise, it is closed by the sender.
2. Block Mode
Block mode transforms data from one host to another in the form of blocks. Each block is preceded by a 3-byte header. The first byte contains all the information about the block hence know for the description block. Oher two blocks containing the size of the block in the form of bytes.
3. Compressed Mode
Compress mode is used in the case of big file size. If the file size is big, it cannot send over the internet connection because of the size limit. In Compressed mode, a large file is compressed into a small size and then sends over the internet.
4. Data Structure
For transforming a file over a data connection, it uses one of the following data structures.
- Data Structure: This is a default file structure. It contains a stream of bytes.
- Record Structure: This structure can be used only with a text file. It divides a file into records.
- Page Structure: The entire file is divided into several pages, and each page contains a page number and page header. Pages can access sequentially or randomly.
Recommended Articles
This has been a guide to What is FTP? Here we have discuss the working, types, and transmission modes of FTP with a detailed explanation. You can also go through our other suggested articles to learn more –