File Transfer Protocol (FTP) is a standard network protocol used for transferring files from one computer to another. It is the preferred method of exchanging files because it’s faster than other protocols like HTTP.
FTP operates on the application layer of the OSI model, and is used to transfer files using TCP/IP. For the data transfer, FTP server needs to be waiting for incoming requests. The client computer is then able to communicate with the server on port no. 21. Actually, there are two types of connection i.e. Control connection & Data Connection.
First, the control connection is used for session administration (i.e., commands, identification, passwords) exchanged between the client and server by port no 21. Then, the server responds on the control connection with three digit status codes in ASCII with an optional text message, for example “200″ (or “200 OK.”) means that the last command was successful. The numbers represent the code number and the optional text represent explanations (e.g. <OK>). At last,that the data connection is established by port no. 20.
FTP can be run in two modes i.e. active or passive mode. In active mode, the client sends the server the IP address and port number on which the client will listen, and the server initiates the TCP connection. In situations where the client is behind a firewall and unable to accept incoming TCP connections, passive mode may be used. In this mode the client sends a PASV command to the server and receives an IP address and port number in return. The client uses these to open the data connection to the server.