File Transfer Protocol (FTP) Guide

File Transfer Protocol (FTP) Guide

What is A File Transfer Protocol (FPT)?

The File Transfer Protocol (protocol file transfer), or FTP, is a communications protocol for the exchange of computer files over a TCP / IP. It allows for a computer, copy files to another computer network to power a website, or delete or modify files on that computer. The variant of FTP protected by SSL or TLS (SSL is the predecessor of TLS) is called FTPS.

FTP follows a client-server model, that is to say that the two parties, the client sends requests to which the other responds, called a server. In practice, the server is a computer running software itself called FTP, which releases a file structure similar to a Unix file system. To access an FTP server, use an FTP client (with a GUI or command line).

The protocol, which belongs to the session layer of the OSI model and the application layer model ARPA, uses a TCP connection. It can be used in two ways:

1. Active mode: the FTP client determines the connection port to use to enable data transfer. Thus, for data exchange can take place, the FTP server is initializing the connection of its data port (port 20) to the port specified by the customer. The customer will then configure the firewall to allow new incoming connections so that data exchange takes place.

Moreover, it can be problematic for users trying to access FTP servers when behind a NAT gateway. Given how does the NAT, the FTP server starts the data connection by connecting to the external address the NAT gateway on the chosen port. Some NAT gateways with no match for the packet received in the state table, the packet will be ignored and will not be issued to the customer.

2. Passive mode: The FTP server itself determines the connection port to use for the transfer of data (data connection) and communicates to the client. If the presence of a firewall to the server, it must be configured to allow the data connection. The advantage of this method is that the FTP server is able to initialize any connection. This mode works without problems with a NAT gateway. In the new implementations, the client initializes and communicates directly through the port 21 of the server that simplifies the configuration of the firewall server.

Two ports are standardized (well known ports) connections to FTP port 21 for commands and port 20 for data.

This protocol can work with IPv4 and IPv6.

To access an FTP server using an FTP client, command line or with GUI.

Users of GNU / Linux or Unix can consult documentation (mostly installed by default) by typing “man ftp”

Anonymous FTP

Many Internet sites offer software and other files available free from an FTP server. In this case, it is not necessary to have a user name and password, simply enter anonymous as username and email address as your password. However as no validity check is usually done on email, a fictitious address or even any string or empty can be used. This is the access mode used by the default browser when a user is not specified on the command line.

FTP Software

There are many customers in the command line, like ftp, wget, curl wput download or to upload files.

Most programs now have a graphical interface to set up an FTP server or to connect it to copy data (FTP client). Some software such as CuteFTP (Windows) are paid, others, such as FileZilla (Cross-platform), KamzyFTP (Windows), Cyberduck (MacOSX) or gftp (Linux) are free and open. Another example FTP Explorer (Freeware for Windows), as convenient to use the file browser, or FireFTP, an extension for Firefox. For more advanced uses (special orders etc.). Software such as FlashFXP (fee) may be helpful.

The Protocol

The protocol uses two types of TCP connections:

* A control connection initiated by the client to the server (usually port 21) to send commands file (transfer, delete files, rename, list of files …).

* A data connection initiated by the client or server to transfer the required data (file contents, list of files).

Control connection

This connection uses the Telnet protocol. The client sends a command in the form of a text line terminated by a newline (CR followed by LF or \ r \ n, 0d0a or hexadecimal).

For example, the following command requests the download of the file “file.txt”
RETR file.txt

N.B.: Commands such as GET or PUT are not recognized in the FTP protocol, but often used by the FTP client software.

After sending the order, the customer receives one or more responses from the server. Each answer is preceded by a decimal code for FTP client to handle the response may include one or more lines of text.

For the previous example, if the server finds the requested file, it sends the client:

150 File status okay, about to open data connection.

Depending on what the client and server have agreed a two listens on TCP port agreed, and the other connects to it to establish a data connection. Then the server sends the client the requested file, closes the data connection, and sends the following response on the control connection:

226 Closing data connection.

Data Connection

The data connection is established for the duration of data (contents of files, or lists of files). In general, it is established for transferring data from a single command, unless another mode of transmission is selected and supported by the server.

The PASV command tells the server to wait passively for a connection by listening TCP port (usually port 20). In the opposite case where the client waits for a connection on TCP port, it shows the same form the port listened by sending the PORT command.

Transfer Mode

When the file transfer on the data connection, 2 modes can be used:

* The binary mode: In this mode, the file is sent as is.
* The ASCII mode: The ASCII mode is only intended for text files. The file is reviewed and changes made to maintain a correct format. For example, the end line is represented by the character <LF> on a UNIX system, and the pair <CR> <LF> Windows. A Windows machine receiving a text file via FTP then recovers to end a file with <CR> <LF> in ASCII mode and binary mode <LF>. This method has its advantages, but can cause corruption of files (not text) for the transfer when using a former client / command line, unable to adapt to the type of file. It must then switch mode (usually using the command BIN) before transfer to keep intact.

Transfer between two servers

The specification of FTP (RFC 959) states that it is possible to transfer files directly between FTP servers. This feature is not known, because not available in the FTP client software.

For this, the client establishes a connection control server. In setting the data connection, the client asks a server to wait for the connection (PASV command), and captures the IP address and TCP port listening. These two parameters are sent to another server using the PORT command. From there, the data connection is established between two servers.

The customer is informed of the transfer completed by receiving a positive response from each server. It is also commonly known that the FXP protocol.

If you need a more powerful web hosting solution to cope with increasing demand, visit our homepage.

Sharing