Why was the FTP protocol designed to use more than one port?
772
The question is in the title. The reason I wonder this is because I'm coding an tcp service and would like to explore some of the reasons as they may shed some light on my work.
I expect that the use of a different port simplifies the handling of the separate expected data connection, which will be in a format different from the control connection. I believe this would allow the receiver to simply start processing the data without having to check if it was a connection initiation as would need to be done if it used port 21.
This would allow the last bullet's example of a linefeed printer start receiving text to print. However, I'm not sure how this was actually used back then (a program on the terminal would forward port 20 to their linefeed printer because there might be a FTP daemon already listening on 21?)
As for the why another connection, there's three primary reasons:
Efficiency of transfer is an important
factor affecting the usefulness of
FTP. File transfer may be very
expensive (in terms of CPU time)
and slow (in real-time) if an
inappropriate transfer strategy is
used (e.g., inappropriate byte size).
Every attempt should be made to
optimize transfer of data. A good
strategy may be to allow transfer
of files over a separate connection or
close and reopen connections (using
perhaps a different byte size).
[4] We considered using two
full-duplex links, one for control
information, the other for data. The
use of a separate control link
between the cooperating processes
would simplify aborts, error
recoveries and synchronization.
It would be desirable to modify FTP to
allow sending data to a specified
socket in a specified mode and type.
TIP users would then find it
convenient to obtain listing of their
files on a high-speed line printer,
input their files from a card reader,
and keep back-up on cards or magnetic
tapes.
One (not often used) advantage of the split control/data connections is that it is possible for the client to start a transfer between two servers without the data needing to pass through the client.
Over-engineering is not the case.
It was designed this way, so that different modes of operation are allowed.
Active FTP is nowadays rarely used, because in this mode the server connects back to the client. But back then - in the 80s - it was working quite well.
Passive FTP is very useful behind firewalls nowadays, in this mode the client connects to ports opened by the Server; the clients are usually not reachable directly anymore because they have a firewall/NAT/appliance in front of them. So this mode also makes sense.
I expect that the use of a different port simplifies the handling of the separate expected data connection, which will be in a format different from the control connection. I believe this would allow the receiver to simply start processing the data without having to check if it was a connection initiation as would need to be done if it used port 21.
This would allow the last bullet's example of a linefeed printer start receiving text to print. However, I'm not sure how this was actually used back then (a program on the terminal would forward port 20 to their linefeed printer because there might be a FTP daemon already listening on 21?)
As for the why another connection, there's three primary reasons:
Over-engineering might be the main reason.
One (not often used) advantage of the split control/data connections is that it is possible for the client to start a transfer between two servers without the data needing to pass through the client.
Over-engineering is not the case. It was designed this way, so that different modes of operation are allowed. Active FTP is nowadays rarely used, because in this mode the server connects back to the client. But back then - in the 80s - it was working quite well. Passive FTP is very useful behind firewalls nowadays, in this mode the client connects to ports opened by the Server; the clients are usually not reachable directly anymore because they have a firewall/NAT/appliance in front of them. So this mode also makes sense.
The wikipedia article has nice, detailed info: http://en.wikipedia.org/wiki/FTP
FTP uses one port for data transmission (20) and other to send the commands (21), GET, DIR, PUT, etc...
A more thorough explanation can be found here: http://slacksite.com/other/ftp.html
HTH!