510 likes | 695 Views
FPT. File Transfer Protocol and RFC 959. Objectives of FTP. Promote the sharing of files To encourage indirect or implicit use of remote computers To shield users from variations in file storage systems To transfer data reliably and efficiently. History.
E N D
FPT File Transfer Protocol and RFC 959
Objectives of FTP • Promote the sharing of files • To encourage indirect or implicit use of remote computers • To shield users from variations in file storage systems • To transfer data reliably and efficiently
History • First proposed file transfer mechanisms in 1971 in RFC 114 and RFC 141 • RFC 354 (1972) defined FTP between hosts on ARPANET • Several RFCs came shortly thereafter • RFC 686 (1975) entitled “Leaving Well Enough Alone” • RFC 959 defines additional commands: • CDUP, SMNT, STOU, RMD, MKD, PWD, SYST
FTP • FTP begins at port 21 • Initially, client and server communicate in plain text • Server will send ‘reply codes’ along with text • client doesn’t need to interpret text • Client will send upper-case commands
How FTP Works Primary Command Thread Server
Enter the Client Primary Command Thread Primary Command Thread Socket (21) Client Server
Server Greeting 220 Welcome! Primary Command Thread Primary Command Thread Socket (21) Client Server
USER Identification USER chastine Primary Command Thread Primary Command Thread Socket (21) Client Server
User Verified 331 User OK… Primary Command Thread Primary Command Thread Socket (21) Client Server
PASSword Sent PASS jeffrox Primary Command Thread Primary Command Thread Socket (21) Client Server
User Now Verified 230 User logged in Primary Command Thread Primary Command Thread Socket (21) Client Server
What we have so far… • Client/server connected by a socket • The user identified
LISTing of Files Primary Command Thread Primary Command Thread Socket (21) Client Server
Set TYPE to ASCII TYPE A Primary Command Thread Primary Command Thread Socket (21) Client Server
Server Responds 200 Type set to A Primary Command Thread Primary Command Thread Socket (21) Client Server
Now the Tricky Part PASV Primary Command Thread Primary Command Thread Socket (21) Client Server • PASV • Requests server to prepare a new socket • Server listens for client on that new port
Server Sets up New Socket Returns IP and port number 227 Entering Passive Mode (168,28,245,183,28,45) Primary Command Thread Primary Command Thread Socket (21) Secondary Data Thread On port 2845 Client Server
Establish the Data Socket Primary Command Thread Primary Command Thread Socket (21) Secondary Data Thread On port 2845 Secondary Data Thread Client Socket (2845) Server
Request the LISTing LIST Primary Command Thread Primary Command Thread Socket (21) Secondary Data Thread On port 2845 Secondary Data Thread Client Socket (2845) Server
Secondary Thread Is Waiting 150 Opening ASCII mode data… Primary Command Thread Primary Command Thread Socket (21) Secondary Data Thread On port 2845 Secondary Data Thread Client Socket (2845) Server
Establish the Data Socket Primary Command Thread Primary Command Thread Socket (21) Secondary Data Thread On port 2845 Secondary Data Thread Client Socket (2845) Server <Data is transferred>
Secondary Socket Closes Primary Command Thread Primary Command Thread Socket (21) Secondary Data Thread On port 2845 Secondary Data Thread Client Socket (2845) Server
Transfer Complete 226 Transfer Complete Primary Command Thread Primary Command Thread Socket (21) Client Server
What We’ve Done Now • Sent a directory listing by: • Sending the request • Establishing a new socket on a new port • Sent/Read the data • Closed the connection • Return back to the original socket • How about for files?
Transfering Files(Client - Receiving) Primary Command Thread Primary Command Thread Socket (21) Client Server
Set TYPE to Image (binary) TYPE I Primary Command Thread Primary Command Thread Socket (21) Client Server
Server Responds 200 Type set to I Primary Command Thread Primary Command Thread Socket (21) Client Server
Tricky Part PASV Primary Command Thread Primary Command Thread Socket (21) Client Server
Server Sets up New Socket Returns IP and port number 227 Entering Passive Mode (168,28,245,183,28,46) Primary Command Thread Primary Command Thread Socket (21) Secondary Data Thread On port 2846 Client Server
Establish the Data Socket Primary Command Thread Primary Command Thread Socket (21) Secondary Data Thread On port 2846 Secondary Data Thread Client Socket (2846) Server
RETRieve the File RETR Bob.txt Primary Command Thread Primary Command Thread Socket (21) Secondary Data Thread On port 2846 Secondary Data Thread Client Socket (2846) Server
Secondary Thread Is Waiting 150 Opening BINARY mode data… Primary Command Thread Primary Command Thread Socket (21) Secondary Data Thread On port 2846 Secondary Data Thread Client Socket (2846) Server
Establish the Data Socket Primary Command Thread Primary Command Thread Socket (21) Secondary Data Thread On port 2846 Secondary Data Thread Client Socket (2846) Server <Data is transferred>
Secondary Socket Closes Primary Command Thread Primary Command Thread Socket (21) Secondary Data Thread On port 2846 Secondary Data Thread Client Socket (2846) Server
Transfer Complete 226 Transfer Complete Primary Command Thread Primary Command Thread Socket (21) Client Server
Question • Why can’t this be done with telnet alone?
Transfering Files(Client - Sending) Primary Command Thread Primary Command Thread Socket (21) Client Server
Set TYPE to Image (binary) TYPE I Primary Command Thread Primary Command Thread Socket (21) Client Server
Server Responds 200 Type set to I Primary Command Thread Primary Command Thread Socket (21) Client Server
Tricky Part PASV Primary Command Thread Primary Command Thread Socket (21) Client Server
Server Sets up New Socket Returns IP and port number 227 Entering Passive Mode (168,28,245,183,28,47) Primary Command Thread Primary Command Thread Socket (21) Secondary Data Thread On port 2847 Client Server
Establish the Data Socket Primary Command Thread Primary Command Thread Socket (21) Secondary Data Thread On port 2847 Secondary Data Thread Client Socket (2847) Server
RETRieve the File STOR Bob.txt Primary Command Thread Primary Command Thread Socket (21) Secondary Data Thread On port 2847 Secondary Data Thread Client Socket (2847) Server
Secondary Thread Is Waiting 150 Opening BINARY mode data… Primary Command Thread Primary Command Thread Socket (21) Secondary Data Thread On port 2847 Secondary Data Thread Client Socket (2847) Server
Establish the Data Socket Primary Command Thread Primary Command Thread Socket (21) Secondary Data Thread On port 2847 Secondary Data Thread Client Socket (2847) Server <Data is transferred>
Secondary Socket Closes Primary Command Thread Primary Command Thread Socket (21) Secondary Data Thread On port 2847 Secondary Data Thread Client Socket (2847) Server
Transfer Complete 226 Transfer Complete Primary Command Thread Primary Command Thread Socket (21) Client Server
Other Commands(no additional socket needed) • PWD – print (or present) working directory • CDUP – Change Dir UP • CWD <dir> - Change Working Directory • RMD <dir> - Remove Directory • MKD <dir> - Make Directory • REIN – reinitialize • QUIT – logout • MODE – Stream*, Block, Compressed *Default