The TCP/IP protocol suite provides a number of protocols for the manipulation of files. In general, there are two different mechanisms for accessing remote files.The most simple mechanism is by transferring the particular file to the local machine. In this case, multiple copies of the same file are likely to exist.
FileTransfer Protocol (FTP), Trivial File Transfer Protocol (TFTP),Secure Copy(SCP), and SSH FTP(SFTP)employ this mechanism of file sharing.
An alternate approach to accessing files is through the use of a file system. In this case, the operating machine on the local host provides the necessary functionality to access the file on the remote machine. The user and application on the local machine are not aware that the file actually resides on the remote machine; they just read and write the file through the file system as though it were on the local machine. In this case, only one copy of the file exists, and the file system is responsible for coordinating updates. The Network File System (NFS),Andrew File System(AFS),and the Common Internet File System (CIFS,previously called Server message Block, or SMB) provide this type of functionality.
In this Tutorial we will try to cover the mose generic and popular protocol FTP.For other protocols please go through my profile and find other related blogs.
An overview of FTP
FTP uses TCP as a transport protocol to provide reliable end-to-end connections and implements two types of connections in managing data transfers. The FTP client initiates the first connection, referred to as the control connection, to well-known port 21 (the client’s port is typically ephemeral). It is on this port that an FTP server listens for and accepts new connections. The control connection is used for all of the control commands a client user uses to log on to the server,manipulate files, and terminate a session. This is also the connection across which the FTP server will send messages to the client in response to these control commands.
The second connection used by FTP is referred to as the data connection.Typically, the data connection is established on server port 20. However,depending on how the data connection is established, both the client and server might use ephemeral ports. It is across this connection that FTP transfers the data. FTP only opens a data connection when a client issues a command requiring a data transfer, such as a request to retrieve a file, or to view a list of the files available. Therefore, it is possible for an entire FTP session to open and close without a data connection ever having been opened. Unlike the control connection, in which commands and replies can flow both from the client to the server and from the server to the client, the data connection is unidirectional.
FTP can transfer data only from the client to the server,or from the server to the client,but not both.Also,unlike the control connection, the data connection can be initiated from either the client or the server. Data connections initiated by the server are active,while those initiated by the client are passive.
Note: Communication between the client and the server follow the Telnet
protocol defined in RFC 854.
The client FTP application is built with a protocol interpreter (PI),a data transfer process(DTP),and a user interface.The server FTP application typically only consists of a PI and DTP.
The FTP client’s user interface communicates with the protocol interpreter,which manages the control connection.This protocol interpreter translates any application-specific commands to the RFC architected FTP commands,and then communicates these control commands to the FTP server.
The FTP server’s PI receives these commands, and then initiates the appropriate processes to service the client’s requests. If the requests require the transfer of data, data management is performed by the DTPS on both the client and server applications. Following the completion of the data transfer, the data connection is closed, and control is returned to the PIs of the client and server applications.
Note: Only one data transfer can occur for each data connection. If multiple data transfers are required for a single FTP session, one distinct control connection will be opened for each transfer.
When using FTP, the user performs some or all of the following operations:
Connect to a remote host.
Navigate and manipulate the directory structure.
List files available for transfer.
Define the transfer mode, transfer type, and data structure.
Transfer data to or from the remote host.
Disconnect from the remote host.
Connecting to a remote host
To execute a file transfer, the user begins by logging in to the remote host. This
is only the primary method of implementing security within the FTP model.Additional security can be provided using SSL and TLS.
There are four commands that are used:
open Selects the remote host and initiates the login session.
user Identifies the remote user ID.
pass Authenticates the user.
site Sends information to the foreign host that is used to provide
services specific to that host.
Navigating the directory structure
After a user has been authenticated and logged on to the server, that user can navigate through the directory structure of the remote host in order to locate the
file desired for retrieval, or locate the directory into which a local file will be
transferred. The user can also navigate the directory structure of the client’s host.
After the correct local and remote directories have been accessed, users can display the contents of the remote directory. The subcommands that perform these functions are as follows:
cd Changes the directory on the remote host: A path name can be
specified, but must conform to the directory structure of the remote host. In most implementations, cd .. will move one directory up within the directory structure.
lcd Changes the directory on the local host. Similar to the cd
command, a path name can be specified but must conform to the directory structure of the local host.
ls Lists the contents of the remote directory. The list generated by
this command is treated as data, and therefore, this command requires the use of a data connection. This command is intended to create output readable by human users.
dir Lists the contents of the remote directory. Similar to the ls
command, the list generated by dir is treated as data and requires the use of a data connection. This command is intended to create output readable by programs.
Controlling how the data is transferred
Transferring data between dissimilar systems often requires transformations of the data as part of the transfer process. The user has to decide on three aspects of the data handling:
The way the bits will be moved from one place to another
The different representations of data on the system's architecture
The file structure in which the data is to be stored
Each of these is controlled by a subcommand:
mode Specifies whether the file is treated as having a record structure in a byte stream format:
B This specifies block mode is to be used. This indicates
that the logical record boundaries of the file are preserved.
S This specifies that stream mode is to be used, meaning
that the file is treated as a byte stream. This is the default and provides more efficient transfer but might not produce the desired results when working with a
record-based file system.
type Specifies the character sets used in translating and representing the data:
A Indicates that both hosts are ASCII-based, or that if one
is ASCII-based and the other is EBCDIC-based, that ASCII-EBCDIC translation must be performed. On many implementations, this can be invoked by issuing the
ASCII command, which the PI translates into the type a command.
E Indicates that both hosts use an EBCDIC data representation. On many implementations, this can be invoked by issuing the EBCDIC command, which the PI
translates into the type E command.
I Indicates that no translation is to be done on the data.
On many implementations, this can be invoked by using the BINARY command, which the PI translates into the type I command.
structure Specifies the structure of the file to be transferred:
file Indicates that the file has no internal structure, and is
considered to be a continuous sequence of data bytes.
record Indicates that the file is made up of sequential records.
page Indicates that the file is made up of independent indexed
pages.
Because these subcommands do not cover all possible differences between
systems, the site subcommand is available to issue implementation-dependent
and platform-specific commands. The syntax of this command will vary by
implementation.
Transferring files
The following commands can be used to copy files between FTP clients and
servers:
get Copies a file from the remote host to the local host. The PI
translates get into a RETR command.
mget Copies multiple files from the remote to the local host. The PI
translates mget into a series of RETR commands.
put Copies a file from the local host to the remote host. The PI translates put into a STOR command.
mput Copies multiple files from the local host to the remote host. The PI translates mput into a series of STOR commands.
Terminating the FTP session
The following commands are used to end an FTP session:
quit Disconnects from the remote host and terminates FTP. Some
implementations use the BYE subcommand.
close Disconnects from the remote host but leaves the FTP client
running. An open command can be issued to establish a new control connection.
The active data transfer
When issuing the subcommands get, put, mget, mput, ls, or dir, FTP opens a data connection across which the data will be transferred. Most FTP implementations default to an active data transfer unless a passive transfer has been specifically requested. In an active transfer, the FTP client sends a PORT command to the FTP server, indicating the IP address and port number on which the client will listen for a connection. Upon accepting the PORT command, the FTP server initiates a connection back to the client on the indicated IP address
and port. After this connection has been established, data will begin flowing,
either from the client to the server (for put and mput commands) or from the
server to the client (for get, mget, ls, and dir commands).
The passive data transfer
Contrary to the use of an active data connection, the passive data transfer reverses the direction of establishment of the data connection. Instead of issuing a PORT command, the client issues a PASV command, which uses no parameters. Upon accepting this command, the FTP server sends back a reply containing an IP address and port number. The client initiates a connection back to the server on the indicated IP address and port.
Anonymous FTP
Many TCP/IP sites implement what is known as anonymous FTP, which means that these sites allow public access to some file directories. The remote user only needs to use the login name anonymous and password guest or some other common password conventions (for example, the user's Internet e-mail ID). The password convention used on a system is explained to the user during the login process. Because this method of logon is available to anyone with Internet access to the system, most hosts restrict the folders accessible to anonymous users.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment