Report
Report
INDEX
Introduction
Topics
1. WHAT IS FTP ?
2. FTP MODEL
3. ELEMENTS OF FTP
4. FTP COMMANDS
10
5. FTP REPLIES
12
6. CONNECTION MANAGEMENT
13
16
8. PERFORMANCE ISSUES
17
9. COMMON PROBLEMS
18
19
20
21
13. EXAMPLES
22
14. CONCLUSION
29
15. BIBLIOGRAPHY
30
INTRODUCTION
In a networked environment it is natural to wish to copy files
between computer system. Why isnt it always easy to do this?
Computer vendors have devised hundreds of file systems .these file systems differ in
dozens of minor ways ,and quite a few drastic major ways too!
This is not just a multivendor problem. Sometimes it is difficult to copy files between
two different types of computers manufactured by the same vendor.
Among the problem that may be encountered when dealing with a multisystem
environment are:
Different conventions for naming files.
Different rules for traversing file directory system.
File access restrictions.
Different ways to represent text and numeric data within files.
3
The designers of the TCP/IP protocol suite did not try to create a very complicated
general solution to every file transfer problem .Instead ,they evolved a fairly basic but
elegant file transfer protocol(FTP) tha is serviceable and easy to use.
The file transfer protocol is designed to be operated by interactive end users or by
application programs.
It is one of the most venerable methods of transferring files from one computer to
another.
Two crucial aspects of FTP make it particularly useful1. Its capability to transfer files between computers of completely dissimilar type.
2. Its provision for public file sharing.
WHAT IS FTP?
FTP is abbreviation used for the file transfer protocol and the file transfer programs that
use the protocol.
File transfer simply means sending a copy of file (not a message) from one computer to
another.
Examples of file include spreadsheets, digitized photographs, sounds, complied program
or document files from a word processing program.
If you want to send a copy of files from your computer to another computer, you use the
FTP program in upload or put mode. More frequently people use download or get mode.
There are two methods for using FTP:
1. In one method, you sign on to remote host with your own account or ID and
transfer files.
2. In another method, you sign on as a guest or as an anonymous user and transfer
files. This method is called Anonymous FTP.
With anonymous FTP, your privileges on the host system will be severely limited for
security reasons. Thats because hosts that provide anonymous FTP do so specifically
to make certain files available to anyone who wants them.
To use it ,you connect using the login ID- anonymous or guest or ftp
and use your email address as password.
For example
If you want to connect to a machine called amber, you would enter the following
ftp amber
If your system can connect to that machine, you would see something similar to the
following
Connected to amber
220 amber ftp server (SunOS 4.1) ready.
Name (amber: kbd): ftp
331 Guest login ok
Password: <email address>
230 Guest login ok ,accesss restrictions apply
ftp>
The use of your email address helps the FTP provider track who is interested in which
materials ,and it provides a trace in case of security problems.
There are two basic kinds of FTP clients:
GUI client (graphical user interface)
Line mode client.
With a GUI client you use your mouse or arrow keys to manipulate the transaction
In line-mode client you use the commands at a system or FTP prompt.
CONNECTING TO HOST
You use FTP with an FTP client a program that manages the transmission for you.
If you are using a graphical client program, it will have pull-down menus or point-and
click buttons.
If you are using a line-mode client, you start it from the regular system prompt on
your host account.
Most line-mode FTP clients will give you a list of available commands if you type
help or ? at the FTP > prompt.
Graphical Inetrface Clients usually have a Help system.
FTP differs from the other applications because it uses two TCP connections to
transfer a file.
Control connection.
Data connection.
FTP MODEL
The local client software conducts a formal conversation with the remote server
FTP software over the control connection .
FTP commands are passed across the control connection to the remote FTP server.
Actual transfer of data takes place over the separate data connection which is created
for the purpose. There is a data Transfer Protocol that is used over the data
connection.
Figure 1:
The figure shows that the interactive user normally doesnt deal with commands and
replies that are exchanged across the control connection . Those details are left to the
two protocol interpreters.
The box labeled user interface presents whatever type of interface is desired to the
interactive user (full screen menu,selection,line-at-a time commands etc) and
converts this into FTP commands that are sent across the control connection .
Similarly the replies returned by the server across the control connection can be
converted to any format to present to the interactive user.
This figure also shows that it is the two protocol interpreters that invoke the two data
transfer functions ,when necessary.
ELEMENTS OF FTP
There are several elements that make up the file transfer protocol including
Data Representation:
Numerous choices are provided in the ftp protocol specification to govern the way
the file is transferred and stored .
A choice must be made in each of four dimensions.
1. File type:
(A) Ascii file type
(Default) The text file is transferred across the data connection in ASCII.
This requires the sender to convert the local text file into ASCII,and the
receiver to convert ASCII to local text file type.
The end of each line is transferred using ASCII representation of a
carriage return(CR) ,followed by linefeed(LF).
This means the receiver must scan every byte ,looking for cr-lf pair
(B) EBCDIC file type
An alternative way of transferring text files when both ends are EBCDIC
systems.
(C) Image file type(Also called binary)
The data is sent as a contiguous stream of bits .normally used to transfer
binary files.
(D) Local file type
A way of transferring binary file between hosts with different byte sizes.
The number of bits per byte is specified by the sender.
For systems using 8-bit bytes, a local file type with a byte size of 8 is
equivalent to the image files.
2. Format control
This choice is available only for ASCII and EBCDIC file types.
(C ) Compressed mode
A simple run-length encoding compress consecutive appearances of the
same byte. In a text file this would commonly compress strings of blanks
and in a binary file this would compress strings of a bytes.
Comman UNIX implementation of the FTP client and server restrict us to the
following choices.
File Type
: ASCII or image
Format Control
: Non Print only
Structure
: File structure only
Transmission mode : Stream mode only.
FTP Commands
What type of commands can be passed on he control connection?
There are authentication commands that enable a user to identify the userid,password
and account to be used for a set of FTP activities.
There are file transfer commands that enable a user to
Copy a single file between hosts
Copy multiple files between hosts
Append a local file to a remote file
10
Copy a file and append a number to its name so that the name is unique.
Parameters
Integer number of bytes
Filename
IP Address and port number
Marker value
Filename(s)
Filename(s)
Filename(s)
parameter
Directory name
CDUP
DELE
LIST
directory
Change the parent directory
Delete a file
List information about files
MKD
NLST
Make a directory
List the files in a directory
PWD
RMD
RNFR
RNTO
SMNT
None
Filename
Directory name,list of files
or else none to get
information about the
working directory.
Directory name
Directory name or none for
the working directory
None
Directory name
Filename
Filename
Identifier
CONTROL COMMANDS
Commands
USER
PASS
ACCT
REIN
QUIT
ABOR
FTP
Definition
Identify the user
Provide a password
Provide an account to be
charged
Reinitialize to start state
Logout
Abort the previous
command and its associated
data transfer
Parameter
Userid
Password
Accountid
None
None
None
REPLIES
The replies are 3 digit numbers in ASCII,with an optional message following the
number.
Each has a specific purpose.
Codes in 100s indicate that an action is being started.
Codes in 200s indicate successful completion of a command.
Codes in 300s indicate intermediate point has been reached successful.
Codes in 400s indicate signal transient errors.
12
13
Figure shows the state of connections while step 3 is being performed .we use the
clients ephemeral port for the control connection is 1173, and clients ephemeral port
for data connection is 1174.
The command sent by the client is the PORT command and its arguments are six
decimal numbers in ASCII,separated by commas.
The first four numbers specify the IP addresss on the client that the server should issue
the active open to (140.252.13.34 in this example)
The next two specify the 16 bit port number. Since the 16 bit port number is formed
from two numbers ,its value in this example 4*256+150=1174.
14
Figure shows the state of the connection when the server issue the active open to the
clients end of data connection . The servers end point is at port 20.
The server always does the active open of the data connection .Normally the server
also does the active close of the data connection , except when the client is sending a
file to the server in stream mode ,which requires the client to close the
connection(which gives the server the end of file notification)
15
1 brain
512
165418
95 game.zip
The first series of letters describe (cryptically) the file type and permission set for the
directory or file.
If the first character is a d, the item is a directory.
A file will have a hyphen in this position.
The next character describes the security permissions. They are in three groups of
three characters .
The first group of characters describe the permission set for the owner .
The r indicates permission to read.
The w indicates permission to write.
The x indicates permission to execute .
The second group of three characters describe the permission set for a group of login
Ids of which the owner is a part.
The third group of three characters describe s the permission sent for the world that is,
everyone who has access to this host computer.
PERFORMANCE ISSUES
The efficiency of file transfer operations depends on a number of factors.
16
17
Another problem arises because not all sites accept anonymous FTP connections.
Because a site has an FTP server does not mean that anonymous FTP service is
enabled . In fact ,most UNIX machines are shipped with functional FTP server.
However ,as shipped, the server only enables user listed in the system password file to
access their own accounts.
Finally,not all anonymous FTP sites accept ftp as the username. Although ftp is
becoming as common as anonymous for the login ,some servers will not accept it.
So make sure you try the anonymous login before flaming the administrator of a
site!
18
connect
ls
quit
connect
get Readme.ftp
Quit
connect ftp.uu.net
binary
Chdir/ index /master
Get by name.z
Quit
Simple
Easy to develop
Fast performer
implicit design criteria: Functinality across a wide range of platform.
FTP EXAMPLES
We now look at some examples using FTP: its management of the data
connection, how text files are sent .
Example 1:
Connection Management :Ephemeral Data Port
Lets first look at FTPs connection management with a simple FTP session
that just lists a file on server . We run the client on the host svr 4 with the d
19
flag (debug) . This tells it to print the commands and replies that are exchanged
across the control connection.
All the lines preceded by --- > are sent by the client to the server,and the lines
that begin with a 3-digit number are the servers replies.
The clients interactive prompt is ftp >
output by client
20
When the FTP client prompts us for a login name , it prints the default (our
login name on the client). When we type the RETURN key,this default is sent.
Asking for a directory listing of a single file causes a data connection to be
established and used.
This example follows the procedure we showed in figure.
The client asks its TCP for an ephemeral port number for its end of data
connection, and sends this port number(1174) to the server in PORT
command. We can also see that a single interactive user command(dir)
becomes two FTP commands (PORT and LIST).
Figure
is the time line for the packet exchange across the control connection
Figure is the time line for the data connection . The times in this figure are
from the same starting point as fig
.
sun % ftp bsdi
connected to bsdi
220In
bsdi
(version
ready.
theFTP
timeserver
line FTP
server5.6)
does
the active open of the data connection,from
port 20(called ftp-data),to the port number from the port command(1174).
Name
rstevens):
RETURN
Also(bsdi:
in this
example , where the server writeswetotype
the data
connection , the
331server
Password
required
for
rstevens.
does the active close of the data connection, which tells the client when
Password:
the listing is complete.
230 user rstevens logged in.
ftp> get hello.c
Example 2.
200Text
PORT
command
successful.
File
Transfer:
150 opening ASCII mode data connection for hello.c (38 bytes)
226Lets
transfer
complete.
Server
saysbyfile
contains 38 bytes
verify
that the transmission of a text file uses
ASCII
default.
This time we dont specify the d flag, so we dont see the client commands ,
but notice that the client commands ,but notice that the client still prints the
local:
hello.cresponses.
remote : hello.c
output by client
servers
42 bytes received in 0.0037 sec(11 kbytes/s)
42 bytes across data connection
ftp> quit
221 goodbye
sun % ls -1 hello.c
-rw- rw r -- 1 rstevens
sun % wc -1 hello.c
4 hello.c
21
Forty-two bytes are transferred across the data connection because the file
contains four lines.
Each UNIX newline character(\n) is converted into ascii 2-byte end of line
sequence(\r\n) by the server for transmission ,and then converted back by the
client for storage.
Newer clients attempt to determine if the server is of the same system type,and
so, transfer files in binary(image file type) instead of ASCII .This helps in
two ways:
1. The sender and receiver dont have to look at every byte (a big saving)
2. Fewer bytes are transferred if the host operatins system uses fewer
bytes for the end of line than the 2byte ASCII sequence.(a smaller
saving)
Conclusion:
Even with the advent of numerous alternate methods of moving files across the
Internet , FTP continues to be one of the most widely used protocols ,which is
a remarkable feat after 30 years of service. Probably the principal reason for
this success lies in the implicit design criteria : functionality across a wide
22
BIBILOGRAPHY
REFERENCE BOOKS:
1. TCP/IP ILLUSTRATED
THE PROTOCOL
VOL I
AUTHOR: W.RICHARD STEVENS
PUBLICATION: ADDISON WESLEY
2. MASTERING THE INTERNET
AUTHOR: GLEE HARRAH CODY
PAT McGNEGOR
23
PUBLICATION : BPB
3. HANDS ON TCP/IP
AUTHOR: PAUL SIMONEAU
PUBLICATION: McGRAW HILL
3. TCP/IP ARCHITECTURE,PROTOCOLS,AND
IMPLEMENTATION
AUTHOR: SIDNIE FEIT
PUBLICATION: : McGRAW HILL
4. INTERNET WORKING WITH TCP/IP
PRINCIPLES ,PROTOCOL AND ARCHITECTURE
SECOND EDITION
AUTHOR: DOUGLASE E.COMER
PUBLICATION: PRENTICE HALL INTERNATIONAL EDITION
24