FTP
FTP (File Transfer Protocol) is a protocol for transferring a file
from one host to another host.
ftp |
- Allows a user to copy files to/from remote hosts
- Client program connects to FTP server
- Provides a login id and password
- Allows the user to explore the directories and download and
upload files with the server
HTTP and FTP are both file transfer protocols and have many common characteristics.
Example:
Both run on top of TCP, the Internet's connection-oriented, transport-layer,
reliable data transfer protocol.
But FTP uses two parallel TCP connections to transfer a file, a control connection
and a data connection.
The control connection is used for sending control information between the two hosts.
information such as user identification, password, commands to change remote
directory, and commands to "put" and "get" files.
The data connection is used to actually send a file.
As FTP uses a separate control connection, FTP is said to send its control
information out-of-band which avoids requiring the user to log in again ! Why?
TCP control connection |
When a user starts an FTP session with a remote host, FTP first sets up
a control TCP connection on server port number 21.
The client side of FTP sends the user identification and password over
this control connection.
The client side of FTP also sends, over the control connection,
commands to change the remote directory.
When the user requests a file transfer (either to, or from, the remote
host), FTP opens a TCP data connection on server port number 20.
FTP sends exactly one file over the data connection and then closes
the data connection.
If, during the same session, the user wants to transfer another file, FTP opens
another data TCP connection.
Thus, with FTP, the control connection remains open throughout the duration
of the user session, but a new data connection is created for each file
transferred within a session.
- FTP maintains state and therefor is stateful.
FTP Commands
The commands, from client to server, and replies, from server to client,
are sent across the control TCP connection in 7-bit ASCII format.
Common cmds:
Authentication
– USER: specify the user name to log in as
– PASS: specify the user’s password
Exploring the files
– LIST: list the files for the given file specification
– CWD: change to the given directory
Downloading and uploading files
– TYPE: set type to ASCII (A) or binary image (I)
– RETR: retrieve the given file
– STOR: upload the given file
Closing the connection
– QUIT: close the FTP connection
FTP Respond
There is typically a one-to-one correspondence between the command that the user
issues and the FTP command sent across the control connection.
Each command is followed by a reply, sent from server to client. The replies are threedigit
numbers, with an optional message following the number.
Eg:
331 Username OK, password required
125 Data connection already open; transfer starting
425 Can't open data connection
Server Response Codes
1xx: positive preliminary reply
– The action is being started, but expect another reply before sending the next
command.
2xx: positive completion reply
– The action succeeded and a new command can be sent.
3xx: positive intermediate reply
– The command was accepted but another command is now required.
4xx: transient negative completion reply
– The command failed and should be retried later.
5xx: permanent negative completion reply
– The command failed and should not be retried.
No comments:
Post a Comment