FTP is based on Transmission Control Protocol (TCP) and has a connection. It has no connectionless User Datagram Protocol (UDP) component. FTP requires two ports to communicate in active mode:
1. A Command Port on Port 21
2. A Data Port on Port 20
Active mode is the default FTP Communication mode and starts with the FTP Client selection of two ports: n and n+1. The FTP Client will use port n to initiate a connection with the Server on port 21. On server response, the FTP Client sends the port command, this commands instruct the server on which port to use for data communication.
It is the server that initiates the data communication from port 20 to the FTP clients data port (n+1).
Passive Mode can be used to correct problems with the active mode connections. Passive mode starts with FTP client selection of two ports n and n+1. The FTP client uses port n to initiate communications to port 21 of the server. When the Server responds, the FTP Client sends a pasv command to the server. The server selects a random port p to use for data communications and sends the port number to the client. The client then initiates communications on the data port (n+1) to the server’s data port (p)
When using passive mode, the client initiates communications on the command and data ports.