File Transfer Protocol (FTP)
- File Transfer Protocol (FTP) is an application layer protocol.
- It is used to exchange files over the internet and enables the users to upload and download the files from the internet.
- It transfers both text and binary files over the Internet. But mainly used for transferring the web page files from their creator to the computer that acts as a server for other computers on the internet.
- It transfers the data more reliably and efficiently.
- FTP uses TCP at the transport layer.
- FTP is a connection-oriented protocol.
- FTP is an out-of-band protocol as data and control information flow over different connections.
Main Benefit from the use of FTP Protocol:
- Many a time’s two systems use two different types of file conventions, two different ways to represent text & data following different directory structures.
- FTP creates two connections between the computers one connection for the commands and replies called control connection and a second connection for data transfers called data connection.
- FTP is built on a client-server model architecture using the control connection and data connection between the client and server.
- This setup of FTP helps to overcome these problems.
![FTP](https://i.imgur.com/8LIMPQI.png)
1] Control Connection in FTP:
- The control connection is the primary connection that uses very simple rules for communication.
- A Control Connection is established on Port number 21.
- FTP uses persistent TCP connections for the control connection.
- The control connection, is used to transfer a line of command or line of response at a time.
- It is used to send commands back and forth between the client and the server.
- The control connection is made between the control processes.
- It sends the control information like user identification, password, remote directory, etc., once the control connection is established.
- The control connection remains connected during the entire interactive FTP session.
2] Data Connection in FTP:
- The Data Connection uses very complex rules as data types may vary.
- Data Connection is initiated on Port number 20.
- FTP uses non-persistent connections for data connection.
- The data connection is made between data transfer processes.
- Using the established Control Connection, the client and server will create a separate Data Connection to transfer the requested data.
- The Data Connection stays open until the transfer is complete, after that the Data Connection is closed.
- Data Connections are closed by either the client or the server, depending on which party is sending the information.
Three Modes of File Transfer in FTP:
- Stream mode – In this mode FTP handles the data as a string of bytes without separating boundaries.
- Block mode − In this mode FTP decomposes the entire data into different blocks of data.
- Compressed mode − In this mode, the FTP uses the Lempel-Ziv algorithm to compress the data.
Advantages of FTP:
- Speed - Using FTP transfer of files takes place very quickly.
- Security - To access the FTP server, it is a must to log in with the username and password.
- Efficient - There is no need to complete all the operations to get the entire file.
- Back & forth movement - FTP allows us to transfer the files back and forth.
Disadvantages of FTP:
- FTP is used for transferring one file at a time in either direction between the client and the server. It also doesn't allow you to run simultaneous transfers to multiple receivers.
- Each system cannot be compatible with the FTP protocol.
- FTP requires the connection establishment between the client and server before transferring the files. Hence, both parties must have to be online at the same time. Therefore, emails are not sent using FTP.
- All FTP transmissions are not encrypted, not all the providers offer encryption.
- Passwords and file contents are sent in clear text that allows unwanted eavesdropping.