2. file transfer
FTP
server
FTP
user
interface
FTP
client
local file
system
remote file
system
user
at host
transfer file to/from remote host
client/server model
client: side that initiates transfer (either to/from remote)
server: remote host
ftp: RFC 959
ftp server: port 21
FTP client (FileZila, CuteFtp etc)
Separate connection for commands and data
3. 2 connections
21 for commands (persistent)
20 for data (non-persistent)
Out of band
Data connection can be initiated by
server (PORT command) or by client (PASV
command)
Remember connection status history
(authentication, cur dir)
21
20
MSG MSG
101010101101…
4. Control Connection
Server Port 21
NVT ASCII format
Each command or
response is one line
Terminated by CR LF
Data Connection
Server port 20
File type, data
structure, transmission
mode defined by client
File type
NVT ASCII
EBCDIC
Image
Data structure
File structure
(stream) default
Record structure
Page Structure
Transmission mode
Stream mode
EOF is when connection close
Block mode
Data in the form of block
3 byte header (1 byte descriptor, 2
byte block length)
Compress mode
TYPE
command
STRU
command
MODE
command
5. Let the user to access remote system
Command Argument Description
USER User id User name to login
PASS Password Login password
ACCT Account to be changed Account information
REIN Reinitialize
QUIT Logout from system
ABOR Abort previous command
6. Access/navigate the file system, manipulate files
Command Argument Description
CWD Directory name Change directory
CDUP Change to parent dir
DELE File name Delete a file
LIST Directory name List subdirectory or files
NLIST Directory name List subdirectory or file without attributes
MKWD Directory name Create directory
PWD Name of current directory
RMD Directory name Delete a directory
RNFR File name (old) File to be renamed
RNTO File name (new) Rename the file
SMNT File system name Mount a file system
7. Sent the data connection options
Command Argument Description
TYPE A (NVT ASCII), E (EBCDIC), I
(Image), N (Nonprint), T (Telnet)
Define file type
STRU F (File), R (Record), P (Page) Define organization of data
MODE S (Stream), B (Block), C
(Compressed)
Define transmission mode
8. Define port number for data connection
Command Argument Description
PORT 6 digit identifier Client choose a port
PASV Server chooses a port
PORT a1,a2,a3,a4,p1,p2
This is interpreted as IP address a1.a2.a3.a4, port p1*256+p2
Does port command always work/used? Brain storm on weekend
9. 3 digit number followed by text in action of any command
First digit can be 1-5
1yz Positive preliminary reply
2yz Positive completion reply
3yz Positive intermediate reply
4yz Transient negative completion reply
5yz Permanent negative completion reply
Second digit can be 0-5
x0z Syntax
x1z information
x2z connection
x3z authentication
x4z unspecified
x5z file system
Third digit provide additional information
See table 21.7 from forouzan
10. Control connection b/w client
server
220 Service Ready
USER ali12
331 User Ok password?
PWD XYZXYZ
230 user login OK
PORT 8888
150 Data connection opens shortly
LIST usr/backup/reports
125 Data connection OK
Data connection b/w client
server
List of file or dirs
Connection closed
Data Transfer
QUIT
221 Service closing
226 Closing data connection
11. Control connection b/w client
server
220 Service Ready
USER ali12
331 User Ok password?
PWD XYZXYZ
230 user login OK
PORT 1900
150 Data connection opens shortly
TYPE I
200 OK
Data connection b/w client
server
Send file
Connection closed
QUIT
221 Service closing
226 Closing data connection
STRU F
200 OK
STOR usr/backup/y5.jpg
250 OK connection open
Data transfer
12. Some FTP server maintain public account for some public
files
User is Ananymous
PWD is guest
Restricted access
FTP is not secure as sending password as plain
Trivial File Transfer Protocol (TFTP)
Less features of FTP, light weight
Uses UDP on port 69
But UDP is non-reliable
Uses ACKs to confirm data
Demo
13. Ross book 2.3
Forouzan book Chapter 21 (Leave details of TFTP)
List of FTP commands
http://www.nsftools.com/tips/RawFTP.htm