Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
1Activity
0 of .
Results for:
No results containing your search query
P. 1
File Transfer Protocol, Active Ftp, Passive Ftp

File Transfer Protocol, Active Ftp, Passive Ftp

Ratings: (0)|Views: 30|Likes:
Published by kzelda
File Transfer Protocol, Active Ftp, Passive Ftp
File Transfer Protocol, Active Ftp, Passive Ftp

More info:

Published by: kzelda on Apr 28, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

04/28/2011

pdf

text

original

 
File Transfer Protocol (FTP)
The model of how FTP operates can be illustrated thus:
PI
stands for 
Protocol Interpreter 
and
DTP
stands for 
Data Transfer Process
.
Control Connection
The
User-PI
intitiates the Control connection (Port
21
) and FTP commands are generated by the User-PI and sent across theControl connection to the
Server-PI
. The Server-PI replies to the User-PI over the Control connection.Within the FTP commands, parameters are specified for the data connection e.g. Data Port, Transfer Mode, Representation Type,Structure. Also, the nature of the file system operation such as store, retrieve, append, delete, etc. is communicated.The specified data port is then listened to by the User DTP and the server is the one that initiates the data connection and datatransfer. The control connection remains open whilst the data transfer takes place and when the transfer has finished, the User requests that the control connection be closed, the server reponds by closing the connection. A small part of the Telnet protocolis used for the control connection, this makes sense since Telnet and FTP often exist on the same box so they can share code.The Representation Type can be ASCII, EBCDIC, an Image Type or other types such as Local. FTP uses ASCII by default.FTP allows the structure of a file to be specified. Three file structures are defined in FTP:
file-structure
- where there is no internal structure and the file is considered to be a continuous sequence of data bytes.This is the default.
record-structure
- where the file is made up of sequential records.
page-structure
- where the file is made up of independent indexed pages.
SFTP Components for Java
Add FTP/S & SFTP to Your Java Apps Download Now - 30 Day Trial - No CC
www.JSCAPE.com/SecureFTPforJava
Physical LayerData Link LayerNetwork LayerUpper LayersMiscellaneous
 
Physical LayerData Link LayerNetwork LayerUpper LayersMiscellaneous
 
Data Connection
Once the Control Connection has been established, the next step is to set up the Data Connection and communicate theparameters. The Control connection has to remain up all the while the Data connection is up.The User-DTP uses port
21
by default to 'listen' for data (the same as the Control Connection), whereas the Server-DTP uses port
20
. The User-PI then sends an FTP Transfer Request, the Server-PI receives this request and initiates a Data Connection to theport
21
and sends a Confirmation Reply back to the User-PI along the Control Connection.The User-PI has the ability to change from the default data port on the User side, by way of the
PORT
command (
Active Mode
).The User-PI can also change the default port used on the Server side for data by way of the
PASV
command (
Passive Mode
).The Server is responsible for opening, maintaining and closing the Data connections. To close a Data connection, the server responds to EOF, ABORT, error conditions, a User port change or the connection is closed normally.In
Active Mode FTP
:The User-PI initiates the control connection from a random port
n>1024
to the Server-PI on port
21
.The User-PI issues a
PORT
command which tells the Server to connect back to the User on the specified User data port
n+1
.The User then listens on port
n+1
which has become the User data port.The Server then sends data from its own data port
20
to the User data port
n+1
.This is called Active because as far as the data connection is concerned, the Server is the one being active, it is the one that isinitiating the data connection, even though the User is initiating the Control Connection. The User uses unpriviledged ports for boththe control and data connections whilst the Server uses ports
21
and
20
respectively.In
Passive Mode FTP
:The User opens two random port connections (>1024),
x
for the Control connection and
x+1
for the data connection.The User-PI issues a
PASV
command which tells the Server to open its own random data port
y
.The Server-PI then sends a PORT command back to the User informing the User of the Server's data port
y
.The User initiates a Data connection from its own data port
x+1
to the Server's data port
y
.This called
Passive
because the Server has an entirely passive role, and the User initiates both the Control connection and theData connection. The User again uses unpriviledged ports for both the control and data connections whilst the Server uses anunpriviledged port for the Data connection and port
21
for the Control connection.
Transmission Modes
Data is transferred in one of three modes:
Stream Mode
This is where all the data is transferred as a stram of 'transfer bytes'. For a file tht is structured in a
Record Structure
format, atwo byte field is used to indicate the
End of Record (EOR)
and
End of File (EOF)
. The first byte is
11111111
(the Escapecharacter), and the second byte is
00000001
for EOR,
00000010
for EOF and
00000011
for both EOR and EOF. For a file that isstructured in a
File Structure
the EOF is indicated in the sender closing the connection rather than bytes in the data stream.
Block Mode
In this mode, data is transferred in blocks, each block having the following header:
 
The following Descriptor codes are used:
128
- End of data block is EOR
64
- End of data block is EOF
32
- Suspected errors in the block
16
- Block is a Restart Marker The above numbering is used so that if more than one descriptor applies to a particular data block then the appropriate bits can beset (i.e. 10000000
2
= 128, 01000000
2
= 64 so a block which has both EOF and EOR will have a descriptor 11000000
2
= 192).The
Byte Count
field indicates the number of bytes in the data block.
Compressed Mode
This is useful for making more efficient use of bandwidth available without impacting too much on CPU usage. There are threesorts of information sent:
1. Regular Data
sent in a byte string:The first byte of the byte string has a
0
as the first bit with the following 7 bits used to define the number 
n
. The value
n
representsthe number of data bytes being sent, the maximum number is
127
.
2. Compressed Data
can consist of 
Replications
:where a repeated byte
d
is repeated
n
times. Replicated Bytes are indicated by the first two bits being
1 0
.Compressed Data can also consist of 
Filler bytes
:

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->