FTP – How Many TCP Connections are Required to Download a File?

tcp

Regardless of which mode is used (active or passive mode), the initial connection is done on port 21 (command port). Then a second channel starts (data port) for exchanging the files/data.

Each of the above implies a separate TCP connection and a separate 3-way handshake for each one? Meaning that there are two different TCP connections?

Best Regards

Best Answer

FTP uses a control connection and for each transfer, a data connection in parallel - so the answer is: two. Both are TCP connections.

If you browse a directory first, each mdir requires an additional TCP connection - data connections are only used for a single transfer.

The difference between active and passive mode is the direction of the data connection: with traditional "active" it's connected from the server to the client and with the more common "passive" it's from client to server.

Edit: As jonathanjo has noted, FTP's FXP mode can use two control connections to different servers to make the servers open the data connection between them and transfer the data without it passing through the client (for a total of three connections). FXP has several potential security issues and isn't very common.

Related Topic