|
FTP
FTP allows files to be transferred
over the Internet and is still the most
popular and quickest way to transfer
large amounts of files on the Internet.
An FTP address looks a lot like an HTTP,
or Website, address except it uses the
prefix ftp:// instead of http://. FTP is
part of the application layer of the
ISO/OSI network model and is the most
popular way web site owners / webmasters
upload their web site files to the
Internet. There is a range of FTP
programs on the market which are both
free or cost very little. Below is a
list of some of the most popular FTP
programs,
The Internet File Transfer Protocol
(FTP) is defined by RFC 959 published in
1985. It provides facilities for
transferring to and from remote computer
systems. Usually the user transferring a
file needs authority to login and access
files on the remote system.
The common facility known as
anonymous FTP actually works via a
special type of public guest account
implemented on the remote system.
An FTP session normally involves the
interaction of five software elements.
User Interface This provides a user
interface and drives the client protocol
interpreter.
Client PI This is the client protocol
interpreter. It issues commands to the
remote server protocol interpreter and
it also drives the client data transfer
process.
Server PI This is the server protocol
interpreter which responds to commands
issued by the client protocol
interpreter and drives the server data
transfer process.
Client DTP This is the client data
transfer process responsible for
communicating with the server data
transfer process and the local file
system.
Server DTP This is the server data
transfer process responsible for
communicating with the client data
transfer process and the remote file
system.
RFC 959 refers to the user rather
than the client. RFC 959 defines the
means by which the two PIs talk to each
other and by which the two DTPs talk to
each other.
The user interface and the mechanism
by which the PIs talk to the DTPs are
not part of the standard. It is common
practice for the PI and DTP
functionalities to be part of the same
program but this is not essential.
During an FTP session there will be
two separate network connections one
between the PIs and one between the
DTPs. The connection between the PIs is
known as the control connection. The
connection between the DTPs is known as
the data connection.
The control and data connections use
TCP.
In normal Internet operation the FTP
server listens on the well-known port
number 21 for control connection
requests.
The choice of port numbers for the
data connection depends on the commands
issued on the control connection.
Conventionally the client sends a
control message which indicates the port
number on which the client is prepared
to accept an incoming data connection
request.
The use of separate connections for
control and data offers the advantages
that the two connections can select
different appropriate qualities of
service e.g. minimum delay for the
control connection and maximum
throughput for the data connection, it
also avoids problems of providing escape
and transparency for commands embedded
within the data stream.
When a transfer is being set up it
always initiated by the client, however
either the client or the server may be
the sender of data. As well as
transferring user requested files, the
data transfer mechanism is also used for
transferring directory listings from
server to client.
Command Choices
When a transfer is being set up there
are normally four aspects of the
transfer that need to be specified.
These are
File type
This specifies the way the data of the
file is mapped into a form suitable for
transmission. There are four possible
choices
ASCII file type.
At the sending end the file is converted
from a local text file to NVT ASCII with
end of lines indicated by a CR/LF pair.
At the receiving this is converted into
local text file form.
This explains why text file transfers
between Unix hosts always indicate more
bytes transferred than the actual file
size. Note also that if one or both
systems do not use ASCII text encodings
it is the responsibility of the data
transfer processes to convert between
NVT ASCII and the local encodings.
EBCDIC file type
Similar to ASCII only EBCDIC character
codings are used.
Image (or binary) file type
The file is transmitted exactly as
stored at the sending end and stored
exactly as received at the receiving
end.
Local file type
Used in environments where the byte size
is not eight. The number of bits per
byte is specified by the sender.
Only ASCII and Image are likely to be
encountered in practice.
Format Control
This is associated with text files being
transferred ultimately to printing
devices. There are various ways in which
vertical format information can be
encoded within a file. This includes
indicating the way a start of page is
indicated. The choices are
No printing controls. This is the
default.
Telnet printing controls. Control
characters as specified in the telnet
protocol are included within the data
stream.
Fortran printing controls. The first
character of each line controls vertical
spacing.
These are rarely used in practice.
Structure
Files can have internal structure which
is preserved on transfer. It is the
responsibility of the data transfer
processes to map between transmitted
structures and local structures. There
are three possibilities.
File structure.
This actually means that the file is
seen as a contiguous stream of bytes
with no internal structure.
Record structure.
The file is structured as a series of
records. This only really applies to
text files.
Page structure.
This would be better called block
structure. Each page is transmitted with
a page number so that they can be
transmitted in any order.
Page structure is unlikely to be
encountered in practice. Record
structure is also comparatively uncommon
as using ASCII file type will achieve
the same effect with text files.
Transmission mode
There are three choices
Stream mode.
The file is simply transferred as a
series of bytes.
Block mode.
The file is transferred block by bock
with a header at the start of each
block.
Compressed mode.
A simple run length encoding scheme is
used to compress sequences of identical
bytes.
Only stream mode is likely to be
encountered in practice. Compression is
normally achieved using various utility
programs.
When a transfer is being set up the
client may specify one or more of the
options described above, if the server
cannot support that option there will be
an error response reflected back,
ultimately, to the user. There is no
negotiation mechanism.
There are a substantial number of
commands available for users to
establish their bona-fides on remote
systems and to navigate the remote
system's file system.
Command formats
Commands are transmitted as NVT ASCII
strings starting with three or four
upper case NVT ASCII characters followed
by optional arguments and a CR/LF pair
at the end of the command.
Replies start with 3 digit NVT ASCII
numbers with an optional message.
A long reply may be sent as several
messages with a dash after the three
digits on the first message and no dash
after the three digits on the last
message. Intermediate lines need not
have any initial digits but if they do
(and many implementations prefer this)
they should be the same three digits
followed by a dash.
Here is a list of all commands. The
ones marked with an asterisk are rare
and rarely implemented.
String Meaning
ABOR Abort transfer.
*ACCT Some systems associate both
accounts and users with file system
objects.
*ALLO Allocate space for file about to
be sent. Parameter specifies number of
bytes.
*APPE Append file to existing file.
CDUP Change to parent directory on
remote system.
CWD Change working directory on remote
system.
DELE Delete file on remote system.
HELP Elicit "helpful" information from
the server. E.g. a list of commands
supported.
LIST Send a list of file names in the
current directory on the remote system
on the data connection.
MKD Make directory.
MODE Specifies transfer mode. Parameter
is S,B or C.
NLST Send a "full" directory listing of
the current directory on the remote
system on the data connection.
NOOP Do nothing.
PASS Supplies a user password. Must
occur immediately after the USER
command.
*PASV Specifies that the server data
transfer process is to listen for a
connection request from the client data
transfer process.
PORT Specify the client port number on
which the data transfer process is
listening for a connection request.
PWD Show current directory name on
remote system.
QUIT Logout or break the connection.
*REIN Reinitialize. Logout without
breaking connection. A new USER command
for a different user would follow.
*REST Restart transfer from server
marker.
RETR Get file from remote system.
RMD Remove directory.
*RNFR Specifies old path name of file to
be renamed. Follow with RNTO command.
*RNTO Specifies new path name of file to
be renamed.
*SITE Site specific server services.
*SMNT Structure mount. Supplies the
remote system path name of a file system
structure.
*STAT Elicit status information.
STOR Store file on remote system
over-writing the file if it already
exists.
*STOU Store unique. Does not over-write
existing files.
STRU Specifies file structure. Parameter
is F,R or P.
*SYST Report operating system type on
remote system.
TYPE Specifies representation (file)
type. Parameter is one of the characters
A,E,I,L for file type followed by N,T or
C for format control or a number
specifying the local byte size. Only
TYPE A and TYPE I are common.
The control connection commands are
of the following forms
Type Description
1yz Positive preliminary reply. Expect
another reply before sending another
command.
2yz Positive completion reply. The last
command completed successfully.
3yz Positive intermediate reply. A
further command must be sent.
4yz Transient negative completion reply.
The requested action did not take place
but can be retried.
5yz Permanent negative completion reply.
The requested action did not take place
and should not be retried.
The "y" digit encodes further
information
Digit Meaning
0 Syntax error
1 Information
2 Connection status.
3 Authentication and accounting.
4 Unspecified
5 File system status
Here are some typical messages.
Number Meaning
125 Data connection open. Transfer
starting.
200 Command OK
331 User name OK, Password Required.
425 Can't open data connection
452 Error writing file
500 Syntax error - unrecognised command
There are defined responses for all
commands fully specified in RFC 959.
FTP utilities
There are very many different FTP
utility programs and FTP is often
incorporated within utilities such as
WWW browsers. On Unix systems the basic
utility is called ftp and it includes
facilities to allow users to see the
various commands.
Here is an example of it in action.
Local prompts are shown in bold. This
session took place at 08:52 on June 4th,
1996.
bash$ ftp plaza.aarnet.edu.au
Connected to plaza.aarnet.edu.au.
220 plaza.aarnet.EDU.AU FTP server
(Version wu-2.4(2) Fri Apr 15 14:04:20
EST 1994) ready.
Name (plaza.aarnet.edu.au:jphb): ftp
331 Guest login ok, send your complete
e-mail address as password.
Password:
230-
230- This is the AARNet Archive Server,
Melbourne, Australia.
230-
230-
230-The disk that failed back in
September is still not back on-line.
230-As a consequence of this, we are
only shadowing files modified in
230-the last 100 days on many of the
more popular archives. We apologise
230-for this inconvenience.
230-
230-Local time is Tue Jun 4 17:46:00
1996
230-
230-Please read the file
/info/welcome-ftpuser
230- it was last modified on Fri Apr 22
14:47:05 1994 - 774 days ago
230 Guest login ok, access restrictions
apply.
ftp> pwd
257 "/" is current directory.
ftp> ls
200 PORT command successful.
150 Opening ASCII mode data connection
for file list.
lost+found
usr
etc
java
pub
micros
wais
bin
ACS
usenet
X11
rfc
graphics
info
gnu
archie
aarnet
.cap
projects
ls-lRt.Z
.cache
talk-radio
gopher
security
NetWorkshop
Weather
lib
.symlinks
226 Transfer complete.
214 bytes received in 0.018 seconds (11
Kbytes/s)
ftp> cd rfc
250 CWD command successful.
ftp> get rfc1048.txt.gz
200 PORT command successful.
150 Opening ASCII mode data connection
for rfc1048.txt.gz (5141 bytes).
226 Transfer complete.
local: rfc1048.txt.gz remote:
rfc1048.txt.gz
5161 bytes received in 1.6 seconds (3.2
Kbytes/s)
ftp> quit
221 Goodbye.
The following replies will be noted.
The descriptions are taken from RFC 959.
220
Service ready for new user. A standard
banner message from the FTP server
program. The date probably refers to the
date the server program was compiled.
331
Use name OK, password required. ftp is a
special user name understood by many FTP
servers, any string is acceptable as a
password. anonymous may be used with
exactly the same effect.
230
User logged in, proceed. Evrything is
OK, many FTP servers use this as an
opportunity to display a welcoming
message. Note the use of continuations
(the 230- messages).
257
"PATHNAME" created is the RFC 959
interpretation of this message, here it
simply means that the CD command worked
OK as the explanatory text clearly
indicates.
200
Command okay. The command was to
indicate the port number on which the
client will be listening for the
server's data connection for the
directory listing.
150
File status okay, about to open data
connection. This is fairly
self-explanatory. The server has
established communication with the
client's listening data connection port
and is about to transfer the named file.
In this case "list" actually means a
directory listing rather than a file
called "list". The client displays the
incoming data on the standard output
device rather than copying to a local
file.
226
Closing data connection. Requested file
action successful (for example, file
transfer or file abort). In this case
the transfer has been successful.
214
This isn't actually a message at all. It
is statistics produced by the client for
user information.
250
Requested file action okay, completed.
The CWD command completed OK.
200
A PORT command for the data connection
for the file transfer was received
satisfactorily.
150
Data connection established from server
to client.
226
Transfer completed. Followed by the
client side generated statistics.
221
Service clsoing control connection.
http://www.justvb.net/it/ |