ftp protocol details
DESCRIPTION
FTP Protocol Details. Tips for the assignment. Socket Programming using TCP. controlled by application developer. controlled by application developer. process. process. socket. socket. TCP with buffers, variables. controlled by operating system. TCP with buffers, variables. - PowerPoint PPT PresentationTRANSCRIPT
1
Tips for the assignmentTips for the assignment
2
Socket: a door between application process and end-end-transport protocol (UDP or TCP)
TCP service: reliable transfer of bytes from one process to another
process
TCP withbuffers,
variables
socket
controlled byapplicationdeveloper
controlled byoperating
system
host orserver
process
TCP withbuffers,
variables
socket
controlled byapplicationdeveloper
controlled byoperatingsystem
host orserver
Internet
Socket Programming using TCPSocket Programming using TCP
3
4
client
Client socket
server
Welcome socket
Connection socket
time
Client socket
bytes
Client Sockets & Server SocketsClient Sockets & Server Sockets
5
Client/server socket interaction: Client/server socket interaction: TCPTCP
wait for incomingconnection requestconnectionSocket =accept()
create socket,port=x, forincoming request:welcomeSocket =
Socket()
create socket,connect to hostid, port=xclientSocket =
Socket()
closeconnectionSocket
read reply fromclientSocket
closeclientSocket
ServerServer (running on hostid) ClientClient
send request usingclientSocketread request from
connectionSocket
write reply toconnectionSocket
TCP connection setup
Application 2-5
6
socket
bind
listen
loop "forever"
{
accept /* by creating new socket */
/* process the client’s request */
loop until done
{
receive/send
}
closesocket(newsocket)
}
Simple Server Pseudo-CodeSimple Server Pseudo-Code
7
socket
connect
/* process the client’s request */
loop until done
{
send/receive
}
closesocket(socket)
Simple Client Pseudo-CodeSimple Client Pseudo-Code
8
socket
bind
listen
loop "forever"
{
accept /* by creating new socket */
/* process the clients request */
loop until done
{
receive/send
}
closesocket(newsocket)
}
Proper Ordering of Proper Ordering of SendSend and and RecvRecv
socket
connect
/* process the clients request */
loop until done
{
send/receive
}
closesocket(socket)
9
Test the Test the TCPTCP Client-Server Client-Server CodesCodes
Run ServerWindows.cServerWindows.c Compile ClientWindows.cClientWindows.c, look for the
executable. Run ClientWindows.cClientWindows.c from the command
prompt to connect to the server: ClientWindows localhost ClientWindows localhost 12341234 Alternatively, use IpConfig to find out what your IP
address is: (e.g. 130.123.123.111), then connect to the server using:• ClientWindows ClientWindows 130.123.123.111130.123.123.111 12341234
Let’s see how to use the compiler’s Let’s see how to use the compiler’s debug debug mode mode to trace the exchange of messages.to trace the exchange of messages.
10
11
FTP (Multiple Clients)FTP (Multiple Clients)
In TCP, the Server should be running already prior to a Client connecting to it
SSServerServer
TCP Control SocketTCP Control Socket
CCTCP Control SocketTCP Control Socket
Listening Listening SocketSocket
DIRDIR
TCP Active Data SocketTCP Active Data Socket
Port 127,0,0,1,Port 127,0,0,1,6,116,11
QuitQuit
After file transferAfter file transfer
12
13
FTP OperationFTP Operation
Source: Computer Networking and the Internet (5/e) by Fred Halsall
CLIENTCLIENT
SERVERSERVER
Control connection
Data connection
Note that Ports 1216 & 1217 are ephemeral ports. Any port [1024, 65535] will work.
14
FTP CommandsFTP Commands
COMMAND DESCRIPTION
USER username User name on the FTP server
PASS password User’s password on the FTP server
SYST Type of operating system requested
TYPE type File type to be transferred: A (ASCII), I (Image/Binary)
PORT n1,n2,n3,n4,n5,n6 Client IP address (n1-n4) and port number (n5, n6)
RETR filename.type Retrieve (get) a file
STOR filename.type Store (put) a file
LIST filelist List files or directories
QUIT Log off from server
Source: Computer Networking and the Internet (5/e) by Fred Halsall
15
FTP Reply CodesFTP Reply Codes
REPLY DESCRIPTION
11yz Positive reply, wait for another reply before sending a new command
22yz Positive reply, a new command can be sent
33yz Positive reply, another command is awaited
44yz Negative reply, try again
55yz Negative reply, do not retry
x00z Syntax
x11z Information
x22z Control or data connection
x33z Authentication
x44z Unspecified
x55z File status
Source: Computer Networking and the Internet (5/e) by Fred Halsall
16
ActiveActive FTP (or Standard ) FTP (or Standard )
Standard (or PORT or Active)The Standard mode FTP client sends PORT commands to the FTP server. These commands are sent over the FTP command channel when establishing the FTP session.
OperationOperationStandard mode FTP clients first establish a connection to TCP port 21 on the FTP server. This connection establishes the FTP command channel. The client sends a PORT command over the FTP command channel when the FTP client needs to send or receive data, such as a folder list or file. The PORT command contains information about which port the FTP client receives the data connection on. In Standard mode, the FTP server always starts the data connection from TCP port 20. The FTP server must open a new connection to the client when it sends or receives data, and the FTP client requests this by using the PORT command again.
17
PassivePassive FTP (or PASV) FTP (or PASV)
Passive (or PASV)The Passive mode client sends PASV commands to the FTP Server.
OperationPassive mode FTP clients also start by establishing a connection to TCP port 21 on the FTP server to create the control channel. When the client sends a PASV command over the command channel, the FTP server opens an ephemeral port (between 1024 and 5000) and informs the FTP client to connect to that port before requesting data transfer. As in Standard mode, the FTP client must send a new PASV command prior to each new transfer, and the FTP server will await a connection at a new port for each transfer.
18
p. 50p. 50, RFC 959, RFC 959
19Source: Computer Networking and the Internet (5/e) by Fred Halsall
ACTIVEACTIVE FTP Operation FTP Operation
CLIENTCLIENTSERVERSERVER
PortPort2020
PortPort2121
Data connection control connection
timetime time time
Passive open
PortPort11201120
PortPort11211121
Data connectioncontrol connection
20Source: Computer Networking and the Internet (5/e) by Fred Halsall
ACTIVEACTIVE FTP Operation FTP Operation
CLIENTCLIENTSERVERSERVER
PortPort2020
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
PortPort11201120
PortPort11211121
Data connectioncontrol connection
21Source: Computer Networking and the Internet (5/e) by Fred Halsall
ACTIVEACTIVE FTP Operation FTP Operation
CLIENTCLIENTSERVERSERVER
PortPort2020
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
TCP control connection to Port 21 established
PortPort11201120
PortPort11211121
Data connectioncontrol connection
22Source: Computer Networking and the Internet (5/e) by Fred Halsall
ACTIVEACTIVE FTP Operation FTP Operation
CLIENTCLIENTSERVERSERVER
PortPort2020
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
PortPort11201120
PortPort11211121
Data connectioncontrol connection
23Source: Computer Networking and the Internet (5/e) by Fred Halsall
ACTIVEACTIVE FTP Operation FTP Operation
CLIENTCLIENTSERVERSERVER
PortPort2020
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
PortPort11201120
PortPort11211121
Data connectioncontrol connection
24Source: Computer Networking and the Internet (5/e) by Fred Halsall
ACTIVEACTIVE FTP Operation FTP Operation
CLIENTCLIENTSERVERSERVER
PortPort2020
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PortPort11201120
PortPort11211121
Data connectioncontrol connection
25Source: Computer Networking and the Internet (5/e) by Fred Halsall
ACTIVEACTIVE FTP Operation FTP Operation
CLIENTCLIENTSERVERSERVER
PortPort2020
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
PortPort11201120
PortPort11211121
Data connectioncontrol connection
26Source: Computer Networking and the Internet (5/e) by Fred Halsall
ACTIVEACTIVE FTP Operation FTP Operation
CLIENTCLIENTSERVERSERVER
PortPort2020
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
220 user <username> logged in
PortPort11201120
PortPort11211121
Data connectioncontrol connection
27Source: Computer Networking and the Internet (5/e) by Fred Halsall
ACTIVEACTIVE FTP Operation FTP Operation
CLIENTCLIENTSERVERSERVER
PortPort2020
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
220 user <username> logged in
SYST
PortPort11201120
PortPort11211121
Data connectioncontrol connection
28Source: Computer Networking and the Internet (5/e) by Fred Halsall
ACTIVEACTIVE FTP Operation FTP Operation
CLIENTCLIENTSERVERSERVER
PortPort2020
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
220 user <username> logged in
SYST215 UNIX Type:X Version:Y
PortPort11201120
PortPort11211121
Data connectioncontrol connection
29Source: Computer Networking and the Internet (5/e) by Fred Halsall
ACTIVEACTIVE FTP Operation FTP Operation
CLIENTCLIENTSERVERSERVER
PortPort2020
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
220 user <username> logged in
get <filename.type>
PortPort11201120
PortPort11211121
Data connectioncontrol connection
30Source: Computer Networking and the Internet (5/e) by Fred Halsall
ACTIVEACTIVE FTP Operation FTP Operation
CLIENTCLIENTSERVERSERVER
PortPort2020
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
220 user <username> logged in
PORT n1-n6 get <filename.type>
PortPort11201120
PortPort11211121
Data connectioncontrol connection
31Source: Computer Networking and the Internet (5/e) by Fred Halsall
ACTIVEACTIVE FTP Operation FTP Operation
CLIENTCLIENTSERVERSERVER
PortPort2020
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
220 user <username> logged in
PORT n1-n6200 PORT command successful
get <filename.type>
PortPort11201120
PortPort11211121
Data connectioncontrol connection
32Source: Computer Networking and the Internet (5/e) by Fred Halsall
ACTIVEACTIVE FTP Operation FTP Operation
CLIENTCLIENTSERVERSERVER
PortPort2020
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
220 user <username> logged in
PORT n1-n6200 PORT command successful
get <filename.type>
RETR <filename.type>
PortPort11201120
PortPort11211121
Data connectioncontrol connection
33Source: Computer Networking and the Internet (5/e) by Fred Halsall
ACTIVEACTIVE FTP Operation FTP Operation
CLIENTCLIENTSERVERSERVER
PortPort2020
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
220 user <username> logged in
PORT n1-n6200 PORT command successful
get <filename.type>
RETR <filename.type>
150 opening ASCII mode data connection
PortPort11201120
PortPort11211121
Data connectioncontrol connection
34Source: Computer Networking and the Internet (5/e) by Fred Halsall
ACTIVEACTIVE FTP Operation FTP Operation
CLIENTCLIENTSERVERSERVER
PortPort2020
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
220 user <username> logged in
PORT n1-n6200 PORT command successful
get <filename.type>
RETR <filename.type>
150 opening ASCII mode data connection
Server does an active open to Port n5, n6
PortPort11201120
PortPort11211121
Data connectioncontrol connection
35Source: Computer Networking and the Internet (5/e) by Fred Halsall
ACTIVEACTIVE FTP Operation FTP Operation
CLIENTCLIENTSERVERSERVER
PortPort2020
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
220 user <username> logged in
PORT n1-n6200 PORT command successful
get <filename.type>
RETR <filename.type>
150 opening ASCII mode data connectionSend file through data connection
Server does an active open to Port n5, n6
PortPort11201120
PortPort11211121
Data connectioncontrol connection
36Source: Computer Networking and the Internet (5/e) by Fred Halsall
ACTIVEACTIVE FTP Operation FTP Operation
CLIENTCLIENTSERVERSERVER
PortPort2020
PortPort2121
Data connection control connection
timetime time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
220 user <username> logged in
PORT n1-n6200 PORT command successful
get <filename.type>
RETR <filename.type>
150 opening ASCII mode data connectionSend file through data connection
Server does an active open to Port n5, n6
226 File transfer complete
User prompted for a conmand
PortPort11201120
PortPort11211121
Data connectioncontrol connection
37Source: Computer Networking and the Internet (5/e) by Fred Halsall
ACTIVEACTIVE FTP Operation FTP Operation
CLIENTCLIENTSERVERSERVER
PortPort2020
PortPort2121
Data connection control connection
time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
220 user <username> logged in
PORT n1-n6200 PORT command successful
get <filename.type>
RETR <filename.type>
150 opening ASCII mode data connectionSend file through data connection
Server does an active open to Port n5, n6
226 File transfer complete
User prompted for a conmand
QUIT
PortPort11201120
PortPort11211121
Data connectioncontrol connection
38Source: Computer Networking and the Internet (5/e) by Fred Halsall
ACTIVEACTIVE FTP Operation FTP Operation
CLIENTCLIENTSERVERSERVER
PortPort2020
PortPort2121
Data connection control connection
time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
220 user <username> logged in
PORT n1-n6200 PORT command successful
get <filename.type>
RETR <filename.type>
150 opening ASCII mode data connectionSend file through data connection
Server does an active open to Port n5, n6
226 File transfer complete,
User prompted for a conmand
QUIT221 Goodbye
PortPort11201120
PortPort11211121
Data connectioncontrol connection
39Source: Computer Networking and the Internet (5/e) by Fred Halsall
ACTIVEACTIVE FTP Operation FTP Operation
CLIENTCLIENTSERVERSERVER
PortPort2020
PortPort2121
Data connection control connection
PortPort11201120
PortPort11211121
Data connectioncontrol connection
time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
220 user <username> logged in
PORT n1-n6200 PORT command successful
get <filename.type>
RETR <filename.type>
150 opening ASCII mode data connectionSend file through data connection
Server does an active open to Port n5, n6
226 File transfer complete,
User prompted for a conmand
QUIT221 GoodbyeServer closes data connection
first , then control connection
40
41Source: Computer Networking and the Internet (5/e) by Fred Halsall
PASSIVEPASSIVE FTP OperationFTP Operation
CLIENTCLIENTSERVERSERVER
PortPort20242024
PortPort2121
Data connection control connection
timetime time time
Passive open
PortPort11201120
PortPort11211121
Data connectioncontrol connection
42Source: Computer Networking and the Internet (5/e) by Fred Halsall
PASSIVEPASSIVE FTP OperationFTP Operation
CLIENTCLIENTSERVERSERVER
PortPort20242024
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
PortPort11201120
PortPort11211121
Data connectioncontrol connection
43Source: Computer Networking and the Internet (5/e) by Fred Halsall
PASSIVE PASSIVE FTP OperationFTP Operation
CLIENTCLIENTSERVERSERVER
PortPort20242024
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
TCP control connection to Port 21 established
PortPort11201120
PortPort11211121
Data connectioncontrol connection
44Source: Computer Networking and the Internet (5/e) by Fred Halsall
PASSIVE PASSIVE FTP OperationFTP Operation
CLIENTCLIENTSERVERSERVER
PortPort20242024
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
PortPort11201120
PortPort11211121
Data connectioncontrol connection
45Source: Computer Networking and the Internet (5/e) by Fred Halsall
PASSIVE PASSIVE FTP OperationFTP Operation
CLIENTCLIENTSERVERSERVER
PortPort20242024
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
PortPort11201120
PortPort11211121
Data connectioncontrol connection
46Source: Computer Networking and the Internet (5/e) by Fred Halsall
PASSIVE PASSIVE FTP OperationFTP Operation
CLIENTCLIENTSERVERSERVER
PortPort20242024
PortPort2121
Data connection control connection Data connection
timetime time time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PortPort11201120
PortPort11211121
Data connectioncontrol connection
47Source: Computer Networking and the Internet (5/e) by Fred Halsall
PASSIVE PASSIVE FTP OperationFTP Operation
CLIENTCLIENTSERVERSERVER
PortPort20242024
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
PortPort11201120
PortPort11211121
Data connectioncontrol connection
48Source: Computer Networking and the Internet (5/e) by Fred Halsall
PASSIVE PASSIVE FTP OperationFTP Operation
CLIENTCLIENTSERVERSERVER
PortPort20242024
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
220 user <username> logged in
PortPort11201120
PortPort11211121
Data connectioncontrol connection
49Source: Computer Networking and the Internet (5/e) by Fred Halsall
PASSIVE PASSIVE FTP OperationFTP Operation
CLIENTCLIENTSERVERSERVER
PortPort20242024
PortPort2121
Data connection control connection
PortPort11201120
PortPort11211121
timetime time time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
220 user <username> logged in
SYST
Data connectioncontrol connection
50Source: Computer Networking and the Internet (5/e) by Fred Halsall
PASSIVE PASSIVE FTP OperationFTP Operation
CLIENTCLIENTSERVERSERVER
PortPort20242024
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
220 user <username> logged in
SYST215 UNIX Type:X Version:Y
PortPort11201120
PortPort11211121
Data connectioncontrol connection
51Source: Computer Networking and the Internet (5/e) by Fred Halsall
PASSIVE PASSIVE FTP OperationFTP Operation
CLIENTCLIENTSERVERSERVER
PortPort20242024
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
220 user <username> logged in
PASV
PortPort11201120
PortPort11211121
Data connectioncontrol connection
52Source: Computer Networking and the Internet (5/e) by Fred Halsall
PASSIVE PASSIVE FTP OperationFTP Operation
CLIENTCLIENTSERVERSERVER
PortPort20242024
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
220 user <username> logged in
PASV
227 Entering PASV mode (192,168,150,90,195,149)
Port2024
PortPort11201120
PortPort11211121
Data connectioncontrol connection
53Source: Computer Networking and the Internet (5/e) by Fred Halsall
PASSIVE PASSIVE FTP OperationFTP Operation
CLIENTCLIENTSERVERSERVER
PortPort20242024
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
220 user <username> logged in
PASV
227 Entering PASV mode (192,168,150,90,195,149)
Port2024
dir
PortPort11201120
PortPort11211121
Data connectioncontrol connection
54Source: Computer Networking and the Internet (5/e) by Fred Halsall
PASSIVE PASSIVE FTP OperationFTP Operation
CLIENTCLIENTSERVERSERVER
PortPort20242024
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
220 user <username> logged in
PASV
227 Entering PASV mode (192,168,150,90,195,149)
Port2024
LIST dir
PortPort11201120
PortPort11211121
Data connectioncontrol connection
55Source: Computer Networking and the Internet (5/e) by Fred Halsall
PASSIVE PASSIVE FTP OperationFTP Operation
CLIENTCLIENTSERVERSERVER
PortPort20242024
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
220 user <username> logged in
PASV
227 Entering PASV mode (192,168,150,90,195,149)
Port2024
LIST dir150 Opening ASCII mode data connection for file list
PortPort11201120
PortPort11211121
Data connectioncontrol connection
56Source: Computer Networking and the Internet (5/e) by Fred Halsall
PASSIVE PASSIVE FTP OperationFTP Operation
CLIENTCLIENTSERVERSERVER
PortPort20242024
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
220 user <username> logged in
PASV
227 Entering PASV mode (192,168,150,90,195,149)
Port n5, n6(or Port 2024 in this
example)
LIST dir150 Opening ASCII mode data connection for file list
Client does an active open to Port n5,n6
PortPort11201120
PortPort11211121
Data connectioncontrol connection
57Source: Computer Networking and the Internet (5/e) by Fred Halsall
PASSIVE PASSIVE FTP OperationFTP Operation
CLIENTCLIENTSERVERSERVER
PortPort20242024
PortPort2121
Data connection control connection
timetime time time
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
220 user <username> logged in
PASV
227 Entering PASV mode (192,168,150,90,195,149)
Port n5, n6(or Port 2024 in this
example)
LIST dir150 Opening ASCII mode data connection for file list
Client does an active open to Port n5,n6
Send file through data connection
PortPort11201120
PortPort11211121
Data connectioncontrol connection
58Source: Computer Networking and the Internet (5/e) by Fred Halsall
PASSIVE PASSIVE FTP OperationFTP Operation
CLIENTCLIENTSERVERSERVER
PortPort20242024
PortPort2121
Data connection control connection
timetime
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
220 user <username> logged in
PASV
227 Entering PASV mode (192,168,150,90,195,149)
Port n5, n6(or Port 2024 in this
example)
LIST dir150 Opening ASCII mode data connection for file list
Client does an active open to Port n5,n6
Send file through data connection226 File transfer complete
User is prompted for a command
PortPort11201120
PortPort11211121
Data connectioncontrol connection
59Source: Computer Networking and the Internet (5/e) by Fred Halsall
PASSIVE PASSIVE FTP OperationFTP Operation
CLIENTCLIENTSERVERSERVER
PortPort20242024
PortPort2121
Data connection control connection
timetime
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
220 user <username> logged in
PASV
227 Entering PASV mode (192,168,150,90,195,149)
Port n5, n6(or Port 2024 in this
example)
LIST dir150 Opening ASCII mode data connection for file list
Client does an active open to Port n5,n6
Send file through data connection226 File transfer complete
User is prompted for a commandQUIT
PortPort11201120
PortPort11211121
Data connectioncontrol connection
60Source: Computer Networking and the Internet (5/e) by Fred Halsall
PASSIVE PASSIVE FTP OperationFTP Operation
CLIENTCLIENTSERVERSERVER
PortPort20242024
PortPort2121
Data connection control connection
timetime
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
220 user <username> logged in
PASV
227 Entering PASV mode (192,168,150,90,195,149)
Port n5, n6(or Port 2024 in this
example)
LIST dir150 Opening ASCII mode data connection for file list
Client does an active open to Port n5,n6
Send file through data connection226 File transfer complete
User is prompted for a commandQUIT
221 Goodbye
PortPort11201120
PortPort11211121
Data connectioncontrol connection
61Source: Computer Networking and the Internet (5/e) by Fred Halsall
PASSIVE PASSIVE FTP OperationFTP Operation
CLIENTCLIENTSERVERSERVER
PortPort20242024
PortPort2121
Data connection control connection
timetime
Passive openActive open
TCP control connection to Port 21 established
220 FTP server ready
USER <username>
331 password required
PASS <password>
220 user <username> logged in
PASV
227 Entering PASV mode (192,168,150,90,195,149)
Port n5, n6(or Port 2024 in this
example)
LIST dir150 Opening ASCII mode data connection for file list
Client does an active open to Port n5,n6
Send file through data connection226 File transfer complete
User is prompted for a commandQUIT
221 GoodbyeServer closes data connection first , then control connection
PortPort11201120
PortPort11211121
Data connectioncontrol connection
63
Security IssuesSecurity Issues
Firewall administrators may not want to use Passive Passive mode FTP servers mode FTP servers because the FTP server can open any ephemeral port number.
Many FTP servers are configured with an ephemeral ephemeral port rangeport range of 10241024 through 6553565535.
Firewall configurations that allow full access to all ephemeral ports for unsolicited connections may be considered unsecuredunsecured.
http://support.microsoft.com/kb/323446
66
How to change the Internet Explorer How to change the Internet Explorer FTP Client modeFTP Client mode
Start Internet Explorer. On the Tools menu, click Internet Options. Click the Advanced tab. Under Browsing, click to clear the Enable folder
view for FTP sites check box. Click to select the Use Passive FTP Passive FTP (for firewall
and DSL modem compatibility) check box. Internet Explorer behaves as a Standard mode FTP client if you select
the Enable folder view for FTP sites check box, even if you also select the Use Passive FTP check box. If you clear the Enable folder view for FTP sites check box and then select the Use Passive FTP check box, Internet Explorer behaves as a Passive mode FTP client.
67
The EndThe End