File Transfer Protocol (FTP)
An Introduction
Prof. David Bernstein
James Madison University
Computer Science Department
bernstdh@jmu.edu
Introduction
Purpose:
Transfer files
Specification:
RFC 959
Channels/Connections in FTP
Control Channel:
Uses port 21
For things like: user ID, passwords, commands
Data Channel:
Uses port 20
For the actual file
Modes
Active Mode:
The local host initiates communication on the control channel
The remote host then initiates communication on the data channel
Passive Mode:
The local host initiates communication on the control channel
The remote host responds with host information to use to create the data channel
The local host then uses that information to initiate communication on the data channel
Commands
Properties:
Sent from client to server
Use the control channel
Sent in ASCII
Examples:
USER
SP
username
CRLF
PASS
SP
password
CRLF
CWD
SP
directory
CRLF
LIST [
SP
pathname
]
CRLF
RETR
SP
pathname
CRLF
STOR
SP
pathname
CRLF
Reply Codes
First Digit:
1 - Positive preliminary reply
2 - Positive completion reply
3 - Positive intermediate reply
4 - Transient negative completion reply
5 - Permanent negative completion reply
Second Digit:
0 - Syntax error
1 - Request for information
2 - Related to the connection
3 - Related to authentication/accounting
5 - File system status
Third Digit:
Details
State Information
The Concept:
A sequence of commands/responses (usually starting with USER and ending with QUIT) defines a session
The protocol allows for an infinite number of possible sequences of commands
The Implication:
The server must maintain information about the user (e.g., whether the password has been transmitted, the current working directory)
There's Always More to Learn