<<

ftp: the protocol ftp: separate control, data connections

❒ ftp client contacts ftp FTP file transfer FTP FTP at port 21, specifying TCP as user client server transport protocol interface TCP control connection user ❒ two parallel TCP connections port 21 remote file at host local file opened: system system ❍ control: exchange TCP data connection commands, responses FTP ❒ transfer file to/from remote host port 20 FTP between client, server. client server ❒ client/server model “out of band control” ❍ client: side that initiates transfer (either to/from ❍ data: file data to/from remote) server ❍ server: remote host ❒ ftp server maintains “state”: ❒ ftp: RFC 959 current directory, earlier ❒ ftp server: port 21 authentication

2: 27 2: Application Layer 28

outgoing ftp commands, responses Electronic Mail message queue user mailbox user Sample commands: Sample return codes Three major components: agent ❒ sent as ASCII text over ❒ status code and phrase (as ❒ user agents mail user server control channel in http) ❒ mail servers agent ❒ ❒ USER username 331 Username OK, ❒ simple mail transfer SMTP mail ❒ PASS password password required protocol: smtp server user ❒ 125 data connection ❒ LIST return list of file in SMTP agent already open; User Agent current directory transfer starting ❒ a.k.a. “mail reader” SMTP ❒ RETR filename retrieves user ❒ 425 Can’t open data ❒ composing, editing, reading mail (gets) agent connection mail messages ❒ STOR filename ❒ stores 452 Error writing ❒ e.g., Eudora, Outlook, elm, user (puts) file onto remote file Messenger agent host ❒ user outgoing, incoming messages agent stored on server 2: Application Layer 29 2: Application Layer 30 Electronic Mail: mail servers Electronic Mail: smtp [RFC 821]

user ❒ uses tcp to reliably transfer msg from client to Mail Servers agent ❒ server, port 25 mailbox contains incoming mail user ❒ messages (yet to be read) server direct transfer: sending server to receiving server agent for user ❒ three phases of transfer SMTP ❒ message queue of outgoing mail ❍ handshaking (greeting) server (to be sent) mail messages user ❍ transfer of messages SMTP agent ❒ smtp protocol between mail ❍ closure servers to send email SMTP ❒ command/response interaction messages user mail ❍ commands: ASCII text ❍ client: sending mail server agent ❍ server response: status code and phrase user ❍ ❒ messages must be in 7-bit ASCII “server”: receiving mail agent server user agent

2: Application Layer 31 2: Application Layer 32

try smtp interaction for yourself: Sample smtp interaction S: 220 hamburger.edu C: HELO crepes.fr ❒ servername 25 S: 250 Hello crepes.fr, pleased to meet you C: MAIL FROM: ❒ see 220 reply from server S: 250 [email protected]... Sender ok ❒ enter HELO, MAIL FROM, RCPT TO, DATA, QUIT C: RCPT TO: S: 250 [email protected] ... Recipient ok commands C: DATA above lets you send email without using email client S: 354 Enter mail, end with "." on a line by itself (reader) C: Do you like ketchup? C: How about pickles? C: . S: 250 Message accepted for delivery C: QUIT S: 221 hamburger.edu closing connection

2: Application Layer 33 2: Application Layer 34 smtp: final words Mail message format

❒ smtp uses persistent Comparison with http smtp: protocol for exchanging connections email msgs header ❒ http: pull blank ❒ smtp requires that RFC 822: standard for text ❒ line message (header & body) email: push message format: be in 7-bit ❒ both have ASCII ❒ header lines, e.g., ❒ certain character strings command/response ❍ To: body are not permitted in interaction, status codes ❍ From: message (e.g., CRLF.CRLF). ❍ Subject: ❒ http: each object is Thus message has to be different encoded (usually into either encapsulated in its own ! base-64 or quoted response message commandsfrom smtp ❒ body printable) ❒ smtp: multiple objects of ❍ the “message”, ASCII ❒ smtp server uses message sent in a multipart characters only CRLF.CRLF to determine message end of message 2: Application Layer 35 2: Application Layer 36

MIME types Message format: multimedia extensions Content-Type: type/subtype; parameters

❒ MIME: multimedia mail extension, RFC 2045, 2056 ❒ additional lines in msg header declare MIME content Text Video type ❒ example subtypes: plain, ❒ example subtypes: mpeg, html quicktime

From: [email protected] MIME version To: [email protected] Image Subject: Picture of yummy crepe. Application ❒ jpeg, method used MIME-Version: 1.0 example subtypes: ❒ other data that must be to encode data Content-Transfer-Encoding: base64 gif processed by reader Content-Type: image/jpeg before “viewable” multimedia data ❒ type, subtype, Audio example subtypes: base64 encoded data ..... msword, octet-stream parameter declaration ...... ❒ exampe subtypes: basic ...... base64 encoded data (8-bit mu-law encoded), encoded data 32kadpcm (32 kbps coding)

2: Application Layer 37 2: Application Layer 38 Multipart Type From: [email protected] To: [email protected] Mail access protocols Subject: Picture of yummy crepe. MIME-Version: 1.0 SMTP SMTP Content-Type: multipart/mixed; boundary=98766789 POP3 or user user IMAP agent --98766789 agent Content-Transfer-Encoding: quoted-printable Content-Type: text/plain sender’s mail receiver’s mail server server Dear Bob, Please find a picture of a crepe. ❒ SMTP: delivery/storage to receiver’s server --98766789 ❒ Mail access protocol: retrieval from server Content-Transfer-Encoding: base64 Content-Type: image/jpeg ❍ POP: [RFC 1939] • authorization (agent <-->server) and download base64 encoded data ...... ❍ IMAP: Mail Access Protocol [RFC 1730] ...... base64 encoded data • more features (more complex) --98766789-- • manipulation of stored msgs on server ❍ HTTP: Hotmail , Yahoo! Mail, etc.

2: Application Layer 39 2: Application Layer 40

POP3 protocol S: +OK POP3 server ready C: user alice S: +OK authorization phase C: pass hungry ❒ client commands: S: +OK user successfully logged on ❍ user: declare username C: list ❍ pass: password S: 1 498 ❒ server responses S: 2 912 S: . ❍ +OK C: retr 1 ❍ -ERR S: S: . client: transaction phase, C: dele 1 ❒ list: list message numbers C: retr 2 ❒ retr: retrieve message by S: number S: . C: dele 2 ❒ dele: delete C: quit ❒ quit S: +OK POP3 server signing off

2: Application Layer 41