FTP can operate in active or passive mode, the choice of which depends on the connection method. In active mode, the client creates a TCP- control connection to the server, and the server sends your IP address and an arbitrary number of client port.
If the client is behind a firewall and can not accept incoming TCP connection, the passive mode can be used. In this mode, the client uses flow control to send a command to the server PASV, and then it receives from the server IP address and port number.
This is then used by the client to open a data stream with arbitrary client port to the resulting address and port. Both modes were updated in September 1998 to support IPv6. At this time, further changes were made to the passive mode to upgrade to the extended passive mode.
The protocol is defined in RFC 959. The server responds on the control flow three-digit ASCII-status codes with optional text message. For example, “200” (or “200 OK”) means that the last command was successful.
Figures represent the response code and the text – or request clarification. Current transmission on the data flow can be interrupted by using the interrupt message sent by the control flow.
When transferring data over the network four reporting methods can be used:
ASCII – used for text. Data, if necessary, converted from the symbolic representation of the host sender in “eight-bit ASCII”, and (again, if necessary) in the symbolic representation of the receiving host. As a consequence, this mode is not suitable for files that contain not only the plain text.
Image mode (commonly referred to as a binary) – the sending device sends each file byte by byte, and the receiver stores the byte stream upon receipt. Support for this mode has been recommended for all implementations of FTP.
EBCDIC – used for transmission of plain text between hosts encoded EBCDIC. Otherwise, this mode is similar to ASCII mode.
Local mode – allows two computers with identical settings to send the data in its native format without conversion to ASCII.
For text files, a variety of formats and settings control record structure are provided. These features were designed to work with files containing Telnet or ASA formatting.
Data transmission may be implemented in any of three modes:
Stream mode – Data is sent in a continuous stream by performing FTP, releasing whatever was the treatment. Instead, all processing is TCP. End of file indicator is not needed, except for the separation of the recording data.
Block mode – FTP divides the data into several blocks (block header, the number of bytes, a data field), and then transmits them to TCP.
Compression mode – data is compressed into single algorithm (usually, run-length encoding).
FTP authentication uses regular username / password for access.
If the provided information is received by the client server, the server sends the invitation and client session begins. Users can, if the server supports this feature, log in without providing credentials, but the server can provide only limited access to such sessions.
Host provides FTP service, and can provide anonymous access to FTP. People usually come in as anonymous (may be case-sensitive on some FTP servers) as the user name.
Although it usually ask users to send their e-mail address instead of a password, no verification is actually performed. Many FTP hosts with software updates, support anonymous access.
NAT-PT (rfc2766), allows broadcast incoming connections from the server to the client through the NAT.
In the process of such a compound, NAT replaces the data being transmitted from the client to indicate the true server address and port, which can connect to the server, and then transmits the connection from the server to the client.
Despite all the measures and innovations adopted to support FTP protocol, in practice NAT-PT typically disables all routers to provide additional security against virus threats.
NAT and firewall traversal
FTP normally transfers data when the server is connected to the client after the client sends the command PORT. This creates a problem for NAT, and for firewalls that do not allow connections from the Internet to the internal hosts.
There are two approaches to this problem. The first is that the FTP client and FTP server use the command PASV, which establishes the data connection from the client to the server. The second approach – changes values for NAT PORT commands through the gateway at the application level.
Support for web browsers
Most of the conventional web browsers can retrieve files on FTP servers, although they may not support the expansion protocols like FTPS. Fully functional FTP client can be run as an extension to Firefox FireFTP.
FTP URL syntax is described in RFC1738, in the form : ftp:// [< user > [: < password > ] @ ] < host > [: < port > ] / < path > (parameters in square brackets are optional.) For example:
ftp://user001:secretpassword @ private.ftp-servers.example.com/mydirectory/myfile.txt
More details on specifying a user name and password is written in the documentation browser. By default, most web browsers use passive (PASV) mode, which bypasses firewalls.