What is FTP?
FTP or File Transfer Protocol is used for transferring computer files. It is frequently used as a mechanism for transferring the new web pages on the Internet. FTP transfers the web page files to the computer server such that other users can gain access to these files. FTP is also used for downloading files and programs from the Internet to a local user’s system. Whenever a user downloads these files, the files get transferred across other servers using FTP.
It’s not only the transfer between the Internet and user system, but FTP also allows users to transfer files across two systems, provided they have an active Internet connection. Folders containing data can also be shared across the computers.
Working of FTP
FTP is an application layer protocol that is responsible for the movement of files taking place between the local and remote systems. It runs on TCP, similar to HTTP. For transferring a file, 2 active TCP connections are required by FTP, namely- control connection and data connection.
- Control Connection
FTP uses control connection for a number of purposes. Some of these could include- sending control information such as user ids, passwords, commands related to the remote directory, commands for retrieving and storing files.
The control connection takes place on port 21.
- Data Connection
FTP deploys the use of data connection for sending the actual file. Using data connection, FTP sends the control information out-of-band since a separate control connection is used.
The data connection takes place on port 20.
FTP Reply Codes
An anonymous FTP is an FTP type that allows users to access their files and other data without any ID or password. This type of FTP method is a common way of gaining access to any server such that files are viewed or downloaded and made publicly available.
Active and Passive FTP
The basic underlying difference between active and passive FTP connection lies with the fact that who has initiated the data connection.
- Active FTP
In the case of an active FTP, the server is responsible for initiating the data connection with the client once the client has an established connection.
- The client connects to an FTP server by setting up an FTP control connection on port 21 at the server
- When the client demands data over the control connection, the server starts data transfer connections back to the client. The source port of the data transfer connection needs to be always on port 20 of the server. However, the destination port has to be a higher port at the client end.
Active FTP can fail whenever the client is behind a firewall and protected from many to one NAT or Network Address Translation. This is because the firewall is not aware of the servers who’re going to receive the return connection. Active FTP mode is more secured when it comes to servers. It doesn’t need to have any unsecured ports to remain open at the server end, as it is the server that has initiated the data connection.
- Passive FTP
In the case of a passive FTP, it is the client that initiates the data connection with the server once there is an established connection.
- The client needs to connect to the FTP server by making an FTP control connection to port 21 at the server.
- Whenever the client demands data over the control connection, the client begins the transfer of the data connections back to the server. The source port of the data transfer connections needs to be higher on the client end along with a destination port that is higher on the server.
Passive mode needs to be viewed as if the client has initiated the required connections. However, passive mode tends to work in better for the clients as they are protected by the means of a firewall.
Advantages of FTP
The advantages/benefits of FTP include-
- It is a connection-oriented protocol that deploys the use of robust control commands
- It sends data by a separate TCP connection from the control commands. This helps in enabling a faster transfer of data
- Its implementation is easy
- Due to standardization in place, it becomes a universal application, thus, it is widely used
- Users of all kind of OS can connect their server using FTP or secured FTP without any issue hindrance
Disadvantages of FTP
The disadvantages/drawbacks of using FTP include-
- It needs more memory with a high effort level of programming
- Various TCP/IP connections are deployed and firewall can hinder the use of these connections
- It has high latency as it is connection-oriented by nature
- It supports no integrity check on the receiver end.