View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide


FTP Protocol


      The FTP protocol is a TCP based protocol used to exchange files between 2 host machines over the network.

      The FTP protocol can be divided into 2 section in a connection.

1. Control connection
2. Data transmission connection

      The server will wait for a connection from a client on port number 21 (default port for FTP protocol). When the client connects to the server it recieves some of gratting message from server and the client must get a user login name from the user and send it to the FTP server followed by the user's password. Every command will be transmitted and recieved over the control connection but some commands need to send data like "ls", "get", "put". For those commands the client will send extra parameters for specifying data port for a data connection if the client wants to change the default data port but the default data connection port is port number 20.
      Every command must have one or more reply. The reply for FTP protocol will lead with 3 digit integer number and follow by a text message the client and server understand only first 3 digits number. The text message is for humans.


      Data transferring consists of setting up the data connection follow by specific ports and the parameters for transfer.
      When a client wants to get data it will send the command PASV meaning that it wants to use a passive transmission. The passive data transfer process (this may be at client data port or at server data port) will "listen" on the data port to sending a transfer request command. The server will initiate the data connection to the port. When the connection is established, the data transfer begins between both side's data port.
      Every FTP implementation must support changing the default data ports, and only the client can change to non-default ports. The data will be transmitted after the other machine sends the command "PORT" to the other side. Then after the server sends all of the data it will close the connection immediatelly.

      The server MUST close the data connection under the following conditions:


      The FTP control connection is established via TCP between the client process and the server process port 21 (default FTP control port). For data connection the client or the server will select an avilable port number for transmistion of data depending on the transmission mode.

Example for FTP connection
      This is example for connection to FTP server named "" from "" machine.

Links to this Page