180 likes | 326 Views
FTP. Introduction. File Transfer Protocol RFC 959 Transfer file to / from remote host Client / Server architecture Separate control, data connection FTP server control connection : port 21. Model for FTP (1/2). User Interface. User. FTP Command. Server PI. User PI. FTP Replies.
E N D
Introduction • File Transfer Protocol • RFC 959 • Transfer file to / from remote host • Client / Server architecture • Separate control, data connection • FTP server control connection : port 21
Model for FTP (1/2) User Interface User FTP Command Server PI User PI FTP Replies Data File System Server DTP User DTP File System Connection Server-FTP USER-FTP
Model for FTP (2/2) • PI : The protocol interpreter • DTP : The data transfer process establishes and manages the data connection • The Data connection may be used in either direction • The data connection need not exist all of the time
FTP Command (1/3) • USER • Syntax : USER username • Used to send the user identification to the server • Response : 331 (username okay, need password) • PASS • Syntax : PASS password • Used to send password to the server • Response : 230 (user logged in) • PWD • Syntax : PWD • Used to get the current working directory • Response : 257 (current directory)
FTP Command (2/3) • PASV • Syntax : PASV • Used to request the server to listen on a data port • Response : 227 (entering passive mode) • The response includes the host and port address this server is listening on • Ex : 163.112.28.104.19.196 • IP : 163.112.28.104 • Port : 19x256+196 = 5060 • LIST • Syntax : LIST • Used to ask the server to send back a list of all the files in the current remote directory
FTP Command (3/3) • CWD • Syntax : CWD pathname • Used to change working directory • Response : 250 (Request file action okay) • TYPE • Syntax : TYPE type • Response : 200 • RETR • Syntax : RETR filename • Used to get a file from the current directory of the remote host
NOTE • We must append “\r\n” to the end of FTP command
Login Client Server Control Port Control Port(21) TCP connection 220 ready USER username 331 password require PASS password 230 user username logged in
Print Working Directory Client Server Control Port Control Port(21) PWD 257 “/” is current direction
List Files in Current Directory Client Server Data Port Control Port Control Port(21) Data Port PASV 227 Entering Passive Mode (163.112.28.104.19.196) LIST TCP connection Port: 5060 150 Data Connection FTP-DA Close TCP connection 226 Transfer ok
Change Working Directory Client Server Control Port Control Port(21) CWD pathname 250 CWD command successful
Download File (1/2) Client Server Data Port Control Port Control Port(21) Data Port Type I 200 Type set to I PASV 227 Entering Passive Mode RETR filename TCP connection 150 Data Connection FTP-DA (傳檔案)
Download File (2/2) Client Server Data Port Control Port Control Port(21) Data Port Close TCP connection 226 file send ok
Resource • RFC 959, http://www.ietf.org • Ethereal, http://www.ethereal.com
評分標準 • 基本功能 (共85%) • 顯示所有傳送出和接收到的訊息 (5%) • 使用帳號和密碼登入FTP Server (15%) • 顯示目前所在工作目錄 (10%) • 列出目前工作目錄內容 (15%) • 切換工作目錄 (10%) • 下載FTP Server端的檔案至本機端磁碟中 (25%) • 結束與FTP Server的連線 (5%) • 書面報告 (共10%) • 程式架構與寫法介紹 (5%) • 程式功能與操作方法 (5%) • 程式註解 (5%) • 其他功能 (Bonus) • 上傳檔案至FTP Server (10%) • 可同時下載多個檔案 (10%)
繳交日期 • 94年5月9日 24:00前 • 於截止時間前將Source Code寄至 network2006@csie.ntu.edu.tw • Demo地點 : R219 • Demo時段 • 5/10 (三) • 5/11 (四) • 請於Demo前一週至R442門口填表預約時段
注意事項 • 可以使用任何程式語言 • 不可使用和FTP相關的API • Demo時當場以截止繳交日期前寄出的source code編譯執行檔 • 執行環境以R219電腦中可提供的為主,如使用特殊的Compiler,請自行準備執行環境 • 作業驗收標準以可在 R219 之電腦執行為準,若Demo時程式無法於 R219 之電腦執行,則視同作業未完成 (可自備執行環境,工作站上亦可) • 作業驗收時,只要能通過指定的FTP Server之測試即可 • 作業請勿抄襲 • Demo 時請攜帶書面報告紙本,並於封面註明姓名與學號