file transfer protocol ftp
play

File Transfer Protocol (FTP) Chuan-Ming Liu Computer Science and - PowerPoint PPT Presentation

File Transfer Protocol (FTP) Chuan-Ming Liu Computer Science and Information Engineering National Taipei University of Technology Fall 2007 , TAIWAN 1 Contents CONNECTIONS COMMUNICATION COMMAND PROCESSING FILE TRANSFER SIMPLE FTP LAB


  1. File Transfer Protocol (FTP) Chuan-Ming Liu Computer Science and Information Engineering National Taipei University of Technology Fall 2007 , TAIWAN 1

  2. Contents CONNECTIONS COMMUNICATION COMMAND PROCESSING FILE TRANSFER SIMPLE FTP – LAB 3 2

  3. File Transfer Protocol (1) Transferring files from one computer to another Using two connections between hosts One for data transfer One for control information 3

  4. File Transfer Protocol (2) Three components for clients: user interface , client control process , and client data transfer process Two components for servers: server control process and server data transfer process 4

  5. File Transfer Protocol (3) FTP uses the services of TCP FTP uses the services of TCP The well- -known port 21 is used for the known port 21 is used for the The well control connection control connection The well- -known port 20 for the data known port 20 for the data The well connection connection 5

  6. The control connection remains connected during the entire interactive FTP session; the data connection is opened and then closed for each file transferred. 6

  7. Contents CONNECTIONS COMMUNICATION COMMAND PROCESSING FILE TRANSFER SIMPLE FTP – LAB 3 7

  8. Control Connection Created in the same ways as other applications Server issues a passive open on port 21 and waits Clients uses an ephemeral port and issues an active open Remains open during the entire process Needs minimize delay for service 8

  9. 9

  10. Data Connection Uses the port 20 usually at the server side Creation of a data connection includes Client issues a passive open using an ephemeral port Client sends this port number to the server using PORT command Server receives the port number and issues an active open using the well-known port 10

  11. 11

  12. Contents CONNECTIONS COMMUNICATION COMMAND PROCESSING FILE TRANSFER SIMPLE FTP – LAB 3 12

  13. Communication FTP client and server run on different computers using different OS, character sets, and file formats. FTP must take this heterogeneity compatible Communication over Control connection Data connection 13

  14. Communication over Control Connection Uses the NVT ASCII character set Achieves the communication by commands and responses Each command or response is a short line terminated with a two-character (CR+LF) end-of-line token 14

  15. 15 NVT

  16. 16 Using the Control Connection

  17. Communication over Data Connection Transfer files through the data connection The client must define File type Data structure Transmission mode Before sending the file through the data connection, we prepare for transmission through control connection 17

  18. File Type ASCII file default format for transferring text file EBCDIC file Image file default format for transferring binary files Mostly used to transfer binary files such as compiled programs Nonprint v.s . TELNET attribute 18

  19. Data Structure File structure (default) Continuous stream of bytes Record structure Divided into records (or structs in C) Used only with text files Page structure Divided into pages each having a page number and header Can be stored or accessed randomly or sequentially 19

  20. Transmission Mode Stream mode Default mode Data are delivered from FTP to TCP as a continuous stream of bytes Block mode Compressed Mode 20

  21. 21 Using the data connection

  22. Contents CONNECTIONS COMMUNICATION COMMAND PROCESSING FILE TRANSFER SIMPLE FTP – LAB 3 22

  23. Command Processing FTP uses the control connection to communication. Commands are sent from the client to the server and the responses are sent back from the server to the client. 23

  24. 24 Command Processing

  25. Commands In the form of ASCII uppercase May be followed by an argument Six groups: Access commands File management commands Data format commands Port defining commands File transferring commands Miscellaneous commands 25

  26. Access Commands include USER user-id PASS user-passwd ACCT account to be changed REIN QUIT ABOR 26

  27. File Management Commands includes CWD dir CDUP DELE file LIST dir NLIST dir MKD dir PWD RMD dir 27

  28. Data Formatting Commands includes TYPE A(ASCII), E(EBCDIC), I (Image), N (Nonprint), or T(TELNET) STRU F (File), R (Record), or P (page) MODE S (Stream), B (Block), or C (Compressed) 28

  29. Port Defining Commands Define the port number for the data connection on the client site Selects an port number and sends it to the server using a passive open Asks the server to choose a port number and send the port number in the response and then the client creates an active open using that port Two commands PORT ( 6-digits id ) PASV 29

  30. File Transfer Commands include RETR file(s) STOR file(s) APPE file(s) STOU file(s) ALLO file(s) REST file(s) STAT file(s) 30

  31. Miscellaneous Commands include HELP NOOP SITE SYST 31

  32. Responses Each FTP command generates at least one response Each response has two parts: 3-digit number: defines the code Text: defined needed parameters or extra explanations 32

  33. Contents CONNECTIONS COMMUNICATION COMMAND PROCESSING FILE TRANSFER SIMPLE FTP – LAB 3 33

  34. File Transfer One of the three things Retrieving a file (RETR) Storing a file (STOR) Listing directory or file names (LIST) Note that, FTP treats a list of directory or file name as a file and sends it over the data connection. 34

  35. 35 File transfer

  36. 36 Example of Retrieving a List

  37. Example of storing an image (binary) file 37

  38. Contents CONNECTIONS COMMUNICATION COMMAND PROCESSING FILE TRANSFER SIMPLE FTP – LAB 3 38

  39. LAB 3 – Simple FTP Client Implement a simple FTP client Start your ftp service on the client side by typing sftp To connect to a server, use open command open hostname (or IP) Exit the service by giving the bye command 39

  40. Commands to be Implemented Two categories for the other commands Commands on the remote machine ls, cd, get, mget, put, mput Commands on the local machine lls, lcd 40

  41. General Commands USER id PASS password PORT h1,h2,h3,h4,p1,p2 PORT 140,124,182,140,4,200 IP:140.124.182.140 Port:4*256+200=1224 TYPE mode A � ASCII I � Binary 41

  42. General Commands LIST RETR path download STOR path upload QUIT PASV Return h1,h2,h3,h4,p1,p4 42

  43. Login & Logout Scenario 43

  44. Some Details 44

  45. Basic Commands (1/5) USER <SP> <username> <CRLF> The username is required by the server for access to its file system. PASS <SP> <password> <CRLF> The argument field is a TELNET string identifying the user's password. QUIT <CRLF> This command terminates a USER and if file transfer is not in progress, the server closes the TELNET connection. 45

  46. Basic Commands (2/5) PORT <SP> <Host-port> <CRLF> The argument is a HOST-PORT specification for the data port to be used in data connection. A port command would be: PORT h1,h2,h3,h4,p1,p2 where, h1 is the high order 8 bits of the internet host address. 46

  47. Basic Commands (3/5) PASV <CRLF> This command requests the server to "listen" on a data port (which may not be its default data port) and to wait for a connection rather than initiate one upon receipt of a transfer command. Server replies a code : 227 Entering Passive Mode. h1,h2,h3,h4,p1,p2 47

  48. Basic Commands (4/5) TYPE <SP> <type code> <CRLF> The argument specifies the representation type, for example: A - ASCII I - Image RETR <SP> <pathname> <CRLF> This command causes the server to transfer a copy of the file, specified in the pathname, to the server or user at the other end of the data connection. 48

  49. Basic Commands (5/5) STOR <SP> <pathname> <CRLF> This command causes the server to accept the data transferred via the data connection and to store the data as a file at the server site. CWD <SP> <pathname> <CRLF> This command allows the user to work with a different directory or dataset for file storage or retrieval without altering his login or accounting information. LIST [<SP> <pathname>] <CRLF> This command causes a list to be sent from the server to the client. PWD <CRLF> Return the current location of direction 49

  50. The open command USER username Reply a code PASS password Server Client Reply a code 50

  51. The bye command QUIT Server Client Reply a code Reply a code 51

  52. The ls command PASV Reply a code Connect to the data connection socket LIST <pathname> Server Client Rely a code Transmit the information of direction by data connection socket Close the data connection socket Rely a code 52

  53. The cd command CWD pathname Reply a code Server Client PWD Reply a code 53

  54. The got command PASV Reply a code Connect to the data connection socket RETR filename Server Client Reply a code Transmit the file though data connection socket Close the data connection socket Reply a code 54

  55. The put command PASV Reply a code Connect to the data connection socket STOR filename Server Client Reply a code Transmit the file though data connection socket Close the data connection socket Reply a code 55

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend