Department of Computer Science
Southern Illinois University Edwardsville
Spring, 2008
Dr. Hiroshi Fujinoki
E-mail: hfujino@siue.edu
FTP Protocol Programming (Part I)
Application_Level_Protocol (1)/000
CS 447 Network and Data Communication, Project Phase 2
App_Protocol_1/001
1. What is “application level protocols”?  Why we need them?
Presentation Agenda
2. Major application level protocols:
HTTP,
FTP,
POP,
Telnet
SMTP,
3. Protocol details for HTTP, FTP, POP, SMTP
CS 447 Network and Data Communication, Project Phase 2
CS 447 Network and Data Communication, Project Phase 2
What are the application level protocols?
Protocols that are implemented in the top three layers in the OSI model
App_Protocol_1/002
CS 447 Network and Data Communication, Project Phase 2
Application Layer
NFS
(Network File Server)
Presentation Layer
Session Layer
XDR
(External Data Rep.)
RPC
(Remote Proc. Call)
Transport Layer
Physical Layer
Datalink Layer
Network Layer
Network Hardware
TCP
UDP
IP
ARP
RARP
Telnet, FTP, SMTP, rlogin,
DNS, HTTP, rcp, finger, etc.
Application-
layer protocol
Transport-
layer protocol
Network-
layer protocol
App_Protocol_1/003
CS 447 Network and Data Communication, Project Phase 2
FTP
Fundamental operations in FTP:
Get and Send files from/to a remote host
FTP Server
(FTP Daemon)
FTP Client
FTP GET
FTP SEND
FTP Server
(FTP Daemon)
FTP Client
GET Command
SEND Command
Download File
Local
Disk
Remote
Disk
Upload File
App_Protocol_1/004
CS 447 Network and Data Communication, Project Phase 2
FTP Server
(FTP Daemon)
FTP Client
FTP Architecture
 PI = Protocol Interpreter
 DTP = Data Transfer Process
Client PI
GUI
Client DTP
FTP Client
Disk
Server PI
Server DTP
Disk
FTP Server
Port #21
Commands
Files
Port #20
App_Protocol_1/005
CS 447 Network and Data Communication, Project Phase 2
FTP Commands
Commands
Semantics
USER
Transmit a login name of a user to the FTP server
Transmit the password of a user to the FTP server
PASS
RETR
Download a file from the FTP server
STOR
Upload a file to the FTP server
TYPE
Set ASCII/Binary transmission mode
SYST
Display FTP server information
LIST
List (display) the directory contents
PWD
List the current directory path
DELE
Delete a remote file
QUIT
Close the current FTP session
(Most essential FTP commands)
App_Protocol_1/006
CS 447 Network and Data Communication, Project Phase 2
FTP Return Codes
Code #
Meaning
200
Previous command successfully completed
220
FTP server ready
230
User login in progress (not login completed)
331
User login name identified but password required
500
FTP command syntax error
550
Requested file/directory doe not exist
503
Login not successful (session not established)
(Major return codes)
221
Current FTP session is now closed
226
File Transfer Completed
150
Transmission change acknowledgement
App_Protocol_1/007
CS 447 Network and Data Communication, Project Phase 2
FTP Procedures
 USER ABC
 PASS ***
230 Login in progress 
CLIENT
SERVER
Time
 Connection to port #21
220 (Server Ready) 
331 (Password Required) 
215 Login completed 
Phase 1: FTP login
App_Protocol_1/008
Welcome Message
CS 447 Network and Data Communication, Project Phase 2
FTP Procedures
CLIENT
SERVER
Time
 RETR command
226 (Transmission Complete) 
Phase 2-(1): FTP file transfers (GET)
FTP file transfer (port #20) 
App_Protocol_1/009
CS 447 Network and Data Communication, Project Phase 2
FTP Procedures
CLIENT
SERVER
Time
 RETR command
550 (No such file or directory) 
Phase 2-(1): FTP file transfers (GET)
If the requested file does not exist in the remote FTP server
App_Protocol_1/010
CS 447 Network and Data Communication, Project Phase 2
FTP Procedures
CLIENT
SERVER
Time
 STOR command
226 (Transmission Complete) 
Phase 2-(2): FTP file transfers (SEND)
 FTP file transfer (port #20)
App_Protocol_1/011
CS 447 Network and Data Communication, Project Phase 2
FTP Procedures
CLIENT
SERVER
Time
(11) QUIT Command
221 (FTP Session Closed) (12)
Phase 3: Closing Session
If you need more details about FTP protocols, what can you do?
App_Protocol_1/012
CS 447 Network and Data Communication, Project Phase 2
App_Protocol_1/013
1. RFC for FTP
2. Other FTP related RFCs
  RFC 959: The core RFC for FTP
  RFC 607: Passive and active FTP transmission modes
  RFC 614: Auxiliary information for RFC 607
  RFC 624: Auxiliary information for RFC 607
Documentations for FTP
CS 447 Network and Data Communication, Project Phase 2