FTP
What is FTP
FTP
means File Transfer Protocol
which is a standard network protocol
used for transferring files between a client and server.
For secure transmission, FTP with SSL/TLS(FTPS) or SSH File Transfer Protocol (SFTP) is used.
FTP Port
FTP is a TCP based service.
There are two ports : data port
and command(control) port
. That is,
there are two channels : data channel and command channel.
For ftp server, the command port
is 21
, while the command port
is 20
or others which depends on ftp mode.
For ftp client, the port number is random and unprivileged(>1023) port, the data port is command port + 1, e.g. command port is 1023, then data port is 1024.
FTP Mode
There are two modes : active mode and passive mode.
FTP mode is for server.
In linux, ftp server default is passive mode.
Active Mode
Passive Mode
If client is behind a firewall and unable to accept incoming TCP connections, passive mode may be used.
Data mode
-
ASCII mode. Used for text. Data is converted, if needed, from the sending host’s character representation to “8-bit ASCII” before transmission, and (again, if necessary) to the receiving host’s character representation. As a consequence, this mode is inappropriate for files that contain data other than plain text.
-
Image mode (commonly called Binary mode). The sending machine sends each file byte by byte, and the recipient stores the bytestream as it receives it. (It has been recommended for all implementations of FTP).
-
EBCDIC mode. Used for plain text between hosts using the EBCDIC character set.
-
Local mode. Allows two computers with identical setups to send data in a proprietary format without the need to convert it to ASCII.
Data Transfer Mode
-
Stream mode. Data is sent as a continuous stream, relieving FTP from doing any processing. Rather, all processing is left up to TCP. No End-of-file indicator is needed, unless the data is divided into records.
-
Block mode. FTP breaks the data into several blocks (block header, byte count, and data field) and then passes it on to TCP.
-
Compressed mode