0% found this document useful (0 votes)
36 views24 pages

Report

This document provides an overview of the File Transfer Protocol (FTP). It discusses what FTP is, the FTP model involving control and data connections, elements of FTP like data representation and commands, and various FTP topics like commands, replies, connections, file listings, performance issues, and examples. The document is intended as training material for a seminar on FTP.

Uploaded by

Jennifer Griffin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views24 pages

Report

This document provides an overview of the File Transfer Protocol (FTP). It discusses what FTP is, the FTP model involving control and data connections, elements of FTP like data representation and commands, and various FTP topics like commands, replies, connections, file listings, performance issues, and examples. The document is intended as training material for a seminar on FTP.

Uploaded by

Jennifer Griffin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 24

SEMINAR ON

FILE TRANSFER PROTOCOL

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

7. WHAT A UNIX FILE/DIRECTORY


LISTING TELLS YOU

16

8. PERFORMANCE ISSUES

17

9. COMMON PROBLEMS

18

10. RELATIONSHIP OF FTP TO OSI

19

11. FTP VIA MAIL

20

12. REASONS FOR SUCCESS OF FTP

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.

Control connection is established in the normal client-server fashion.The server does


a passive open on the user known port for FTP (21) and waits for a client connection.
The client does an active open to TCP port 21 to establish the control connection .
The control connection stays up for the entire time that the client communicates with
the server.
This connection is used for commands from the client to the server anf for the
servers replies.
The IP type-of-service for the control connection should be minimize delay
since the commands are normally typed by human user.
Data connection is created each time a file is transferred between the client and
server.
The IP type of-service for data connection should be maximize throughput since
this connection is for file transfer.

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

The format of data to be transferred (DATA REPRESENTATION)


The command words and related parameters sent on the control connection
(FTP COMMANDS)
The numeric code returned in response to the commands (FTP REPLIES).

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.

(A) Non print


(Default) the filr contains no vertical format information.
(B) Telnet format control
The file contains Telnet vertical format controls for a printer to interpret.
(C ) Fortran carriage control
The first character of each line is the fortran format control character.
3. Structure
(A) File Structure
(default) the file is considered as a contiguous stream of bytes . There is no
internal file structure
(B) Record structure
this structure is only used with text files (ASCII or EBCDIC)
(C ) Page structure
Each page is transmitted with a page number to let the receiver store the
pages in random order.
4. Transmission mode
This specifies how the file is transferred across the data connection
(A) Stream mode
(Default) The file is transferred as a stream of bytes . For a file
structure ,the end of file is indicated by the sender closing the data
connection . For
a record structure ,a special two byte sequence indicates the end of
record (EOR) and end of file (EOF).
(B) Block mode
The file is transferred as a series of blocks,each preceded by one or more
header bytes.

(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.

There are file management commands that enable user to


List the files in a directory
Identify the current directory and change directories
Create and remove directories
Rename or delete files.
There are control commands that enable user to
Identify whether ASCII text , EBCDIC text ,or binary data is to be transferred.
Establish whether the file is structured as a series of bytes or as a sequence of
records.
Describe how the file will be transferred as a stream of octects, a sequence of
blocks ,or in a compressed format.

FILE TRANSFER COMMANDS


Command
Definition
ALLO
Allocate (reserve) enough
storage for data that follows
APPE
Append a local file to a
remote file .
PASV
Identify a network address
and port to be used for a
data connection to be
initiated by the client
PORT
Identify a network address
and port to be used for a
data connection to be
initiated by the server
REST
Identify a restart marker (to
be followed by the transfer
command to be restarted)
RETR
Retrieve or get file
STOR
Store or put a file
STOU
Store unique create a
version of a file with a
unique name

FILE MANAGEMENT COMMANDS


Command
Definition
CWD
Change to another server
11

Parameters
Integer number of bytes
Filename
IP Address and port number

IP Address and port

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

Print the name of working


directory
Remove a directory
Identify a file to be renamed
Rename the file
Mount a different file
system

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

Codes in 500s indicate bad news and announce a permanent error.


Connection Management
There are 3 uses for the data connection
1. Sending a file from the client to the server.
2. Sending a file from the server to the client.
3. Sending a listing of files or directories from server to the client.
The FTP server sends file listings back across the data connections,rather than as
multiline replies across the control connection.
This avoids any line limits that restrict the size of directory listing and makes it easier for
the client to save the output of a directory listing into a file ,instead of printing the listing
to the terminal.
Weve said that the control connection stays up for the duration of the client server
connection ,but the data connection can come and go as required.
How are the port numbers chosen for the data connection,and who does the active open
and passive open?
First , we said earlier that the common transmission mode is the stream mode and that the
end-of-file is denoted by closing the data connection.this implies that a brand new data
connection is required for every file transfer or directory listing.
The normal procedure is as follows :
1. The creation of the data connection is under control of the client , because its
the client that issues the command that requires the data connection(get a file,
put a file ,or list a directory)
2. The client normally chooses an ephemeral port number on the client host for
its end of the data connection . The client issues a passive open from this port.
3. The client sends this port number to the sever across the control connection
using the port command.
4. The server receives the port number on the client host .The servers end of the
data connection always uses port 20.

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

What a UNIX File/Directory listing tells you


Here is a sample directory listing from a file archive hosted on a remote computer
using the Unix operating system.
Many of the archive sites are hosted on Unix machines ,so this may help you
understand what the directory listings says:

drwxr- xr- r 2 glee


-r r xr -

1 brain

512
165418

jan 8 22:95 foom


may 3

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.

Host file system access efficiency.


Processing required to reformat data
Underlying TCP service

16

It is very important that an implementation include some internal checking of the


status of FTP connections. Systems and communication connections do fail. An FTP
process may be orphaned and left hanging for a long time ting up a lot of resources , if
the service does not check itself to terminate idle connections.
Note that a brief throughput report usually is printed at the end of a file transfer.
226 Transfer complete.
Local:rfc1261 remote rfc 1261
4488 bytes sent in 0.037 sec
A bulk transfer can be initiated in order to obtain a rough measure of TCP and FTP
performance.
COMMON PROBLEMS
Probably the most common problem when trying to FTP a site is captured in the error
message.
Unknown host
Often enough ,the reason for this error is the mistyping of host address .
Check the spelling of the hostname and try again . If you still get an error message
and you have access to the ping command, you can verify the existence and
accessibility of host by typing
Ping s (hostname) 1 1
This command sends the named host 1 byte in one packet. The purpose here is two
fold: the command determines if your host is a valid hostname, and the procedure
demonstrates whether the site is reachable from your host . If so , you will have a
numeric address to try:
amber - > ping -s cerf.net 1 1
PING cerf.net : 1 data bytes
9 bytes from nic .cerf.net(192.102.249.3): icmp_seq=0.
----nic.cerf.net PING Statistics---1 packets transmitted ,1 packets received ,0% packet loss.
The important thing to note is that the numeric address is given(192.102.249 .3),which
can be used in place of full site name(nic.cerf.net). If your FTP client doesnot have
access to name server ,using the numeric address is often necessary.

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!

RELATIONSHIP OF FTP TO OSI


The OSI File Transfer Access And Management (FTAM) standard defines a far higher
level of functionality than FTP .
Differences in file systems are overcome by defining a generic virtual filestore.
The attributes of files are defined in a system-invariant manner.
Some of the FTAM enhancements include:

FTAM supports the transfer of individual units of data.


for example selected records can be read, updated, added or deleted.
Complex file structure such as hierarchical files or file accessed via keys can
be defined and used.
There are commands that enable a user to navigate the file in order to reach
specific data to be read or written.
Rich data structures can be defined , embracing virtually any data type. A unit
of data might be a record , a table , or a subtree of information.
There are mechanism that support sensitive access control.
For example, some users may be able to read only a files attributes,others may
have read access , while others may be able to read and write. Restrictions on
concurrent access can be imposed.
The price is that FTAM is
Complex and difficult to develop.
There is a great deal of overhead involved in using FTAM.
Its high level of resource utilization is likely to make it a slow
performer .

18

FTP via MAIL


If you do not have direct access to the Internet, but can send e-mail, you can still make
use of FTP .There are several services available that provide an e-mail interface to
FTP.
One such service , BITftp, is for users of Bitnet only (others will be rejected).
Examples of FTPmail requests.
Desired function

Body of Mail Message

Connect to default server


And obtain a root directory
Lising

connect
ls
quit

Connect to default server and obtain


Readme.ftp file

connect
get Readme.ftp
Quit

Connect to ftp.uu.net and obtain a


Root directory listing

connect ftp.uu.net
binary
Chdir/ index /master
Get by name.z
Quit

Reasons for the success of FTP


1.
2.
3.
4.

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 >

svr 4 % ftp d bsdi


connected to bsdi
220 bsdi FTP server (version 5.6) ready
Name (bsdi:rstevens):
----> USER rstevens
330 Password required for rstevens
Password :
-- -- > PASS xxxxxx
230 User rstevens logged in.

-d option for debug output


client does active open of control
connection
server responds it is ready
client prompts us for a login name
we type RETURN ,so client sends default

client sends it as a clear text

ftp> dir hello.c


---- > PORT 140,252,13,34,4,150
200 PORT command successful.

ask for directory listing of a single file

----- > LIST hello.c


150 opening ASCII mode data connection for /bin/ls.
-rw-rr

1 rstevens staff 38 jul 25 12:47 hello.c

226 Transfer complete.


Remote : hello.c

output by client

56 bytes received in 0.03 sec(1.0 kbytes/s)


ftp> quit
----- >quit
221 Goodbye

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

38 jul 25 08:48 hello.c

sun % wc -1 hello.c
4 hello.c
21

but file contains 38


bytes
count the lines

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

range of platforms .FTP lives up to that philosophy ,and in so doing continues


to provide one of the most useful utilities of the Internet.

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

You might also like