Spring 2006 CPE : Application Layer_ 1 Special Topics in Computer Engineering Application layer: Some of these Slides are Based on Slides by Kurose and Ross Prepared for Section 2.4 of the Book Computer Networking: A Top Down Approach Featuring the Internet
Spring 2006 CPE : Application Layer_ 2 Electronic Mail Three major components: r user agents r mail servers r simple mail transfer protocol: SMTP User Agent r a.k.a. “mail reader” r read, reply to, forward, save, and compose messages r Example GUI user agents: Eudora, Outlook, elm, Netscape Messenger r Example text-based user agents: elm, pine, mail r outgoing, incoming messages stored on server
Spring 2006 CPE : Application Layer_ 3 Scenario: Alice sends message to Bob 1) Alice uses UA to compose message “to” 2) Alice’s UA sends message to her mail server; message placed in outgoing message queue 3) Client side of SMTP running on Alice’s mail server opens TCP connection with Bob’s mail server 4) SMTP client sends Alice’s message over the TCP connection 5) Bob’s mail server places the message in Bob’s mailbox 6) Bob invokes his user agent to read message user agent mail server mail server user agent
Spring 2006 CPE : Application Layer_ 4 Electronic Mail: mail servers Mail Servers r mailbox contains incoming messages for user r message queue of outgoing (to be sent) mail messages r SMTP protocol between mail servers to send messages client side: sending mail “server” side: receiving mail mail server user agent user agent user agent mail server user agent user agent mail server user agent SMTP
Spring 2006 CPE : Application Layer_ 5 Electronic Mail: SMTP [RFC 2821]SMTP r uses TCP to reliably transfer message from client to server, port 25 r direct transfer: sending server to receiving server r three phases of transfer handshaking (greeting) transfer of messages closure r command/response interaction commands: ASCII text response: status code and ( optional ) phrase r messages must be in 7-bit ASCII
Spring 2006 CPE : Application Layer_ 6 Example Transcript of Messages Exchanged between SMTP Client & Server (TCP Connection Established) S: 220 hamburger.edu C: HELO crepes.fr S: 250 Hello crepes.fr, pleased to meet you C: MAIL FROM: S: 250 Sender ok C: RCPT TO: S: 250 Recipient ok C: DATA S: 354 Enter mail, end with "." on a line by itself C: Do you like ketchup? C: How about pickles? C:. S: 250 Message accepted for delivery C: QUIT S: 221 hamburger.edu closing connection server host name client host name
Spring 2006 CPE : Application Layer_ 7 Try SMTP interaction for yourself: telnet servername 25 r see 220 reply from server r enter HELO, MAIL FROM, RCPT TO, DATA, QUIT commands above lets you send without using client (reader)
Spring 2006 CPE : Application Layer_ 8 SMTP: final words r SMTP uses persistent connections r SMTP requires message (header & body) to be in 7- bit ASCII SMTP server uses CRLF.CRLF to determine end of message Comparison with HTTP: r HTTP: a pull protocol user initiates TCP connection ; use HTTP to pull the information off the server r SMTP: a push protocol sending mail server pushes the file to the receiving mail server ( initiates TCP connection ) r both have ASCII command/response interaction, status codes r HTTP: each object encapsulated in its own response msg r SMTP: multiple objects sent in one multipart msg
Spring 2006 CPE : Application Layer_ 9 Mail message format SMTP: protocol for exchanging msgs RFC 822: standard for text message format: r header lines, e.g., To: From: Subject: different from SMTP commands which were part of the SMTP handshaking protocol r body the “message”, ASCII characters only header body blank line
Spring 2006 CPE : Application Layer_ 10 Message format: multimedia extensions r Multipurpose Internet Mail Extensions, MIME : extra header lines defined in RFC 2045, 2056 to send content other than ASCII text From: To: Subject: Picture of yummy crepe. MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Type: image/jpeg base64 encoded data base64 encoded data multimedia data type, subtype, parameter declaration method used to encode data MIME version encoded data User agent first uses value of the Content-Transfer-Encoding header to convert message body to its original non-ASCII form, and then uses Content-Type header to determine what actions to take on the message body
Spring 2006 CPE : Application Layer_ 11 Mail access protocols r SMTP: delivery/storage to receiver’s server r Mail access protocol: retrieval from server POP: Post Office Protocol [RFC 1939] authorization (agent server) and download IMAP: Internet Mail Access Protocol [RFC 1730] IMAP more features (more complex) manipulation of stored msgs on server HTTP: Hotmail, Yahoo! Mail, etc. user agent sender’s mail server user agent SMTP access protocol receiver’s mail server
Spring 2006 CPE : Application Layer_ 12 POP3 protocol authorization phase r client commands: user: declare username pass: password r server responses +OK -ERR transaction phase, client: list: list message numbers retr: retrieve message by number dele: delete r quit C: list S: S: S:. C: retr 1 S: S:. C: dele 1 C: retr 2 S: S:. C: dele 2 C: quit S: +OK POP3 server signing off S: +OK POP3 server ready C: user bob S: +OK C: pass hungry S: +OK user successfully logged on
Spring 2006 CPE : Application Layer_ 13 POP3 (more) and IMAP More about POP3 r Previous example uses “download and delete” mode. r Bob cannot re-read e- mail if he changes client r “Download-and-keep” mode: copies of messages on different clients r POP3 is stateless across sessions IMAP r Keep all messages in one place: the server r Allows user to organize messages in folders r IMAP keeps user state across sessions: names of folders and mappings between message IDs and folder name