FTP. The file Transfer Protocol FTP file transfer FTP user client server interface er at host ocal file aremote file ystem system Transfer file tolfrom remote host Client/server model > Client: side that initiates transfer (either to/from remote) 》 Server; remote host ftp: RFC 959 ftp server: port 21
11 FTP: The File Transfer Protocol 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 file transfer FTP server FTP user interface FTP client local file system remote file system user at host
Ftp: Separate Control, Data Connections Ftp client contacts ftp server at port 21, specifying TCP as transport protocol Two parallel TCP connections TCP control connection opened: port 21 > Control: exchange commands responses between client, server. <out of band control) TCP data connection FTP port 20 FTP > Data: file data tolfrom server client server Ftp server maintains"state" current directory, earlier authentication 12
12 Ftp: Separate Control, Data Connections Ftp client contacts ftp server at port 21, specifying TCP as transport protocol Two parallel TCP connections opened: » Control: exchange commands, responses between client, server. “out of band control” » Data: file data to/from server Ftp server maintains “state”: current directory, earlier authentication FTP client FTP server TCP control connection port 21 TCP data connection port 20
Ftp Commands, responses Sample Commands: Sample Return Codes sent as ascll text over status code and phrase control channel 331 Username OK, UsER username password required PAsS password 125 data connection already openi transfer LISt return list of files in starting current directory 425 Can't open data reTR filename retrieves connection (gets)file 452 Error writing file STOR filename stores(puts) file onto rem ote host 13
13 Ftp Commands, Responses Sample Commands: sent as ASCII text over control channel USER username PASS password LIST return list of files in current directory RETR filename retrieves (gets) file STOR filename stores (puts) file onto remote host Sample Return Codes status code and phrase 331 Username OK, password required 125 data connection already open; transfer starting 425 Can’t open data connection 452 Error writing file
Http Basics Http layered over bidirectional byte stream 》 Almost always TCP Interaction >) Client sends request to server, followed by response from server to client >)Requests/responses are encoded in text Stateless ) Server maintains no information about past client requests 14
14 HTTP Basics HTTP layered over bidirectional byte stream » Almost always TCP Interaction » Client sends request to server, followed by response from server to client » Requests/responses are encoded in text Stateless » Server maintains no information about past client requests
How to Mark End of Message? Size of message >Content-Length > Must know size of transfer in advance Delimiter MIME style Content-Type 》 Server must“ escape” delimiter in content Close connection >)Only server can do this 15
15 How to Mark End of Message? Size of message → Content-Length » Must know size of transfer in advance Delimiter → MIME style Content-Type »Server must “escape” delimiter in content Close connection »Only server can do this