Tải bản đầy đủ (.pdf) (5 trang)

Practical TCP/IP and Ethernet Networking- P31 ppt

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (61.77 KB, 5 trang )

132 Practical TCP/IP and Ethernet Networking
Checksum: 16 bits
This is the 16-bit one’s complement of the one’s complement sum of a pseudo header
of information from the IP header, the UDP header, and the data, padded with ‘0’ bytes at
the end (if necessary) to make a multiple of two bytes.
The pseudo header, conceptually prefixed to the UDP header, contains the source
address, the destination address, the protocol, and the UDP length. As in the case of TCP,
this header is used for computational purposes only, and is NOT transmitted. This
information gives protection against misrouted datagrams. This checksum procedure is
the same as is used in TCP.


Figure 7.8
UDP pseudo header format
If the computed checksum is zero, it is transmitted as all ones (the equivalent in one’s
complements arithmetic). An all zero transmitted checksum value means that the
transmitter generated no checksum (for debugging or for higher level protocols that don’t
care).
UDP is numbered protocol 17 (21 octal) when used with the Internet protocol.














8
Application layer protocols
Objectives
When you have completed study of this chapter you should have a basic understanding of
the application and operation of the following application layer protocols:
• FTP
• TFTP
• TELNET
• RLOGIN
• NFS
• DNS
• WINS
• SNMP
• SMTP
• POP3
• HTTP
• BOOTP
• DHCP
8.1 Introduction
This chapter examines the process/application layer of the TCP/IP model. Protocols at
this layer act as intermediaries between some user application (external to the TCP/IP
communication stack) and the lower-level protocols such as TCP or UDP. An example is
SMTP, which acts as an interface between an e-mail client or server and TCP.
Note that the list of protocols supplied here is by no means complete, as new protocols
are developed all the time. Using a developer’s toolkit such as WinSock, software
developers can interface their own application protocols at this level to the TCP/IP
protocol stack.
134 Practical TCP/IP and Ethernet Networking
8.2 File transfer protocol (FTP)

File transfer requires a reliable transport mechanism, and therefore TCP connections are
used. The FTP process running on the host that is making the file transfer request is called
the FTP client, while the FTP process running on the host that is receiving the request is
called the FTP server.
The process involved in requesting a file is as follows:
• The FTP client opens a control connection to port 21 of the server
• The FTP client forwards user name and password to the FTP server for
authentication. The server indicates whether authentication was successful
• The FTP client sends commands indicating file name, data type, file type,
transmission mode and direction of data flow (i.e. to or from the server) to
the server. The server indicates whether the transfer options are acceptable
• The server establishes another connection for data flow, using port 20 on the
server
• Data packages are now transferred utilizing the standard TCP flow control,
error checking, and retransmission procedures. Data is transferred using the
basic NVT format as defined by the TELNET network virtual terminal
protocol (no option negotiation is provided for)
• When the file has been transferred, the sending FTP process closes the data
connection, but retains the control connection

The control connection can now be used for another data transfer, or it can be closed

8.2.1 Internal FTP commands
These commands are exchanged between the FTP client and FTP server. Each internal
protocol command comprises a four-character ASCII sequence terminated by a new-line
(<CRLF>) character. Some commands also require parameters. The use of ASCII
character sequences for commands allows the user to observe and understand the
command flow, and aids the debugging process. The user can communicate directly with
the server program by using these codes, but in general this is not advisable.
FTP commands can be divided into three categories, namely service commands,

transfer parameter commands and access control commands. There is also a series of
reply codes. Here follows a brief summary of the commands and reply codes.
Service commands
These commands define the operation required by the requester. The format of the
pathname depends on the specific FTP server being used.
RETR<SP><pathname><CRLF> Retrieve a copy of the file from the server
STOR<SP><pathname><CRLF> Store data at the server
STOU<CRLF> Store unique
APPE<SP><pathname><CRLF> Append
ALLO<SP><decimal integer> Allocate storage
[<SP>R<SP><decimal integer>]<CRLF>
REST<SP><marker><SP> Restart transfer at checkpoint
RNFR<SP><pathname><CRLF> Rename from
RNTO<SP><pathname><CRLF> Rename to
ABOR<CRLF> Abort previous service command
DELE<SP><pathname><CRLF> Delete file at server
Application layer protocols 135
RMD<SP><pathname><CRLF> Remove directory
MKD<SP><pathname><CRLF> Make directory
PWD<CRLF> Print working directory
LIST<SP><pathname><CRLF> List files or text
NLST<SP><pathname><CRLF> Name list
SITE<SP><string><CRLF> Site parameters
SYST<CRLF> Determine operating system
STAT<SP><pathname><CRLF> Status
HELP[<SP><string>]CRLF Help information
NOOP<CRLF> No operation
Transfer parameter commands
These commands are used to alter the default parameters used to transfer data on an FTP
connection.

PORT<SP><host-port><CRLF> Specifies the data port to be used.
PASV<CRLF> Request server DTP to listen on a data port
TYPE<SP><type code><CRLF> Representation type: ASCII, EBCDIC,
image, or local.
STRU<SP><structure code><CRLF> File structure: file, record or page.
MODE<SP><mode code><CRLF> Transmission mode: stream, block or
compressed
Access control commands
These commands are invoked by the server and determine which users may access a
particular file.
USER<SP><username> <CRLF> User name
PASS<SP><password><CRLF> User password
ACCT<SP><acc. information><CRLF> User account
CWD<SP><pathname><CRLF> Change working directory
CDUP<CRLF> Change to parent directory
SMNT<SP><pathname><CRLF> Structure mount
REIN<CRLF> Terminate user and re-initialize
QUIT<CRLF> Logout
<SP> Space character
<CRLF> Carriage return, line feed characters
Reply codes
FTP uses a three-digit return code ‘xyz’ followed by a space to indicate transfer
conditions. The first digit (value 1–5) indicates whether a response is good, bad or
incomplete. The second and third digits are encoded to provide additional information
about the reply. The values for the first digit are:
Value Description
1yz Action initiated. Expect another reply before sending a new
command.
2yz Action completed. Can send a new command.
3yz Command accepted but on hold due to lack of information.

4yz Command not accepted or completed. Temporary error condition
exists. Command can be reissued.
5yz Command not accepted or completed.
Don’t reissue – reissuing the command will result in the same error.

136 Practical TCP/IP and Ethernet Networking
The second digit provides more detail about the condition indicated by the first digit:
Value Description
X0z Syntax error or illegal command
X1z Reply to request for information
X2z Reply that refers to connection management
X3z Reply for authentication command
X5z Reply for status of server
The third digit of the reply code also provides further information about the condition,
but the meanings vary between implementations.
8.2.2 FTP user commands
Although designed for use by applications, FTP software usually also provides interactive
access to the user, with a range of commands that can be used to control the FTP session.
There are several dozen commands available to the user, but for normal file transfer
purposes very few of them ever need to be used.
Command Description
ASCII Switch to ASCII transfer mode
Binary Switch to binary transfer mode
Cd Change directory on the server
Cdup Change remote working directory to parent directory
Close Terminate the data connection
Del Delete a file on the server
Dir Display the server directory
Get Get a file from the server
Help Display help

Ls List contents of remote directory
Lcd Change directory on the client
Mget Get several files from the server
Mput Send several files to the server
Open Connect to a server
Put Send a file to the server
Pwd Display the current server directory
Quote Supply a file transfer protocol (FTP) command directly
Quit Terminate the file transfer protocol (FTP) session
Trace Display protocol codes
Verbose Display all information
To execute a command, the user types the commands at the ftp prompt, e.g.
ftp>close
A list of available user commands can be viewed by typing help at the ftp prompt, e.g.
ftp> help close
After logging into another machine using FTP, the user is still logically connected to
the (local) client machine. This is different to TELNET, where the user is logically
connected to the (remote) server machine. References to directories and movements of
files are relative to the client machine. For example, getting a file involves moving it
from the server to the client; putting a file involves moving it from the client to the server.
It may be wise to create a special directory on the client computer just for the transfer of
files into and out of the client’s system. This helps guard against accidental file deletion,
and allows easier screening of incoming files for viruses.

×