COMP 431 Application-Layer Protocols Internet Services & Protocols Outline application application Applications & transport ◆ Example client/server systems and network their application-level protocols: link Application-Layer Protocols: » The World-Wide Web (HTTP) physical » Reliable file transfer (FTP) FTP and Email (SMTP & POP) » E-mail (SMTP & POP) » Internet Domain Name System (DNS) regional ISP Jasleen Kaur ◆ Example p2p applications systems: » BitTorrent ◆ Other protocols and systems: February 4, 2020 » Streaming media — DASH » Content delivery networks (CDNs) Institutional network 1 2
Application-Layer Protocols FTP Protocol Design FTP: The Internet file transfer protocol (RFC 959) Control and data sockets TCP control connection (port 21) FTP FTP client server File Transfer FTP TCP data connection User FTP FTP user (port 20) at host client server interface Remote file Local file ◆ FTP client contacts FTP server on port 21, using TCP as the system system transport protocol ◆ FTP is used to transfer a file to/from remote host ◆ Two parallel TCP connections opened: » A control connection for exchanging commands, responses ( “ out of ◆ FTP uses a client/server model band control ” ) » Client : side that initiates transfer (either to/from remote) » n data connections for transferring file data to/from server » Server : remote host ◆ FTP server listens for connections on port 21 ◆ FTP server maintains “ state ” » Remembers current directory, earlier authentication 3 4
FTP Protocol Design Application-Layer Protocols FTP commands, responses Electronic mail ◆ Major components: ◆ Sample commands: ◆ Sample return codes user » User agents » Sent as ASCII text on agent » Status code and phrase (as POP control socket in HTTP) » Mail servers mail SMTP server » Mailboxes user agent USER < username> 331 Username OK, password required SMTP ◆ Protocols: mail SMTP PASS < password> 125 data connection already open; server transfer starting » Simple Mail Transfer LIST SMTP 425 Can ’ t open data connection Protocol (SMTP) delivers Return list of file in current 452 Error writing file mail to servers directory SMTP SMTP user RETR <filename> ❖ From clients to local mail mail agent server server Retrieves (gets) file POP ❖ Inter-mail server delivery STOR <filename> Stores (puts) file onto » Post Office Protocol (POP) SMTP remote host user for user access to delivered agent email ❖ (Also IMAP! More later…) 5 6
Electronic Mail Electronic Mail Protocol flow Email flow Mail servers The email delivery process outgoing ◆ Servers maintain: message queue mail mail » A message queue of outgoing user user server server user mailbox SMTP SMTP POP POP agent agent email messages IMAP » A mailbox containing incoming user agent messages for each user Mail Local Remote Mail Sender Mail Server Mail Server Recipient mail SMTP server ◆ SMTP protocol is run between mail agents and servers to send email messages SMTP ◆ User’s mail agent contacts its local mail server SMTP user » Client — the sending mail mail agent ◆ Local mail server contacts the destination mail server(s) server server or agent POP » Server — the receiving mail ◆ Destination mail server places the mail into the server appropriate user’s mailbox SMTP user agent ◆ User retrieves mail via a mail access protocol 7 8
Electronic Mail The Email Delivery Process Protocol flow Email flow The “webmail” delivery process SMTP [RFC 821] ◆ SMTP uses a TCP socket on port 25 to transfer email reliably mail mail from client to server web web server server HTTP SMTP SMTP POP? HTTP browser browser ◆ Email is temporarily stored on the local server and eventually IMAP? transferred directly to receiving server » Intermediate relay is a special case User Web Local Remote Web Mail ◆ Three phases of the protocol: Sender Server Mail Server Mail Server Server Recipient » Handshaking ( “ greeting ” ) » Transfer of messages » Closure ◆ User’s browser sends components of email message via HTTP to a ◆ Client/server interaction follows a command/response paradigm “webmail” server » commands: ASCII text <CRLF> ◆ Web server is either also an SMTP server or it contacts its local » response: status code and phrase <CRLF> mail server » Command and response lines terminated with CRLF ◆ To read mail, the mail access protocol is ultimately HTTP ◆ messages must be in 7-bit ASCII 9 10
The Email Delivery Process Electronic Mail Sample SMTP interaction Mail message format (RFC 822) ◆ SMTP client establishes TCP connection to server hamburger.edu at port 25 ◆ Header lines, e.g., » (SMTP is non-standard in that the server “ talks first ” ) header » From: blank » To: line Server: 220 hamburger.edu Client: HELO crepes.fr » Subject: S: 250 Hello crepes.fr, pleased to meet you these are different from C: MAIL FROM: <alice@crepes.fr> body SMTP commands ! S: 250 alice@crepes.fr... Sender ok C: RCPT TO: <bob@hamburger.edu> S: 250 bob@hamburger.edu ... Recipient ok C: DATA ◆ Body S: 354 Enter mail, end with "." on a line by itself » The “ message ” , ASCII C: Do you like ketchup? Line with single ‘ . ’ is C: How about pickles? characters only the message delimiter C: . S: 250 Message accepted for delivery C: QUIT S: 221 hamburger.edu closing connection 11 12
MIME Multimedia Mail Extensions Mail Message Format MIME types MIME — Multimedia mail extensions (RFC 2045, 2056) Content-Type: <type>/<subtype>[; <parameters>] ◆ SMTP requires all data to be 7-bit ASCII characters » All non-ASCII data must be encoded as ASCII strings Content-Type: text/plain; charset=us-ascii (optional, type-dependent) Content-Type: application/pdf; filename=foo.pdf ◆ Additional lines in the message header declare MIME content type ◆ Text ◆ Video From: alice@crepes.fr » Subtypes: plain, html » Subtypes: mpeg, MIME version To: bob@hamburger.edu quicktime ◆ Image Subject: Picture of yummy crepe. Method used ◆ Application MIME-Version: 1.0 » Subtypes: jpeg, gif to encode data Content-Transfer-Encoding: base64 » Other data that must be ◆ Audio Content-Type: image/jpeg Multimedia data processed by reader » Subtypes: type, subtype, before it is “ viewable ” base64 encoded data ..... basic (8-bit µ -law encoded), parameter declaration ......................... » Subtypes: msword, 32kadpcm (32 kbps ADPCM) ......base64 encoded data octet-stream ASCII encoded data 13 14
MIME Types MIME Types Multipart Type Multipart Type From: alice@crepes.fr From: alice@crepes.fr To: bob@hamburger.edu To: bob@hamburger.edu MIME version MIME version Subject: Picture of yummy crepe. Subject: Picture of yummy crepe. MIME-Version: 1.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=98766789 Content-Type: multipart/mixed; boundary=98766789 --98766789 Indicates multiple, Defines parts Content-Transfer-Encoding: quoted-printable mixed types separator Content-Type: text/plain --98766789 Header/Body Dear Bob, Content-Transfer-Encoding: quoted-printable separators Please find a picture of a crepe. Content-Type: text/plain 1 part --98766789 Content-Transfer-Encoding: base64 Dear Bob, Content-Type: image/jpeg Please find a picture of a crepe. --98766789 base64 encoded data ..... Content-Transfer-Encoding: base64 ......................... Content-Type: image/jpeg Encoding & type ......base64 encoded data 1 part --98766789-- base64 encoded data ..... specified for ......................... each part ......base64 encoded data --98766789-- 15 16
Electronic Mail Electronic Mail SMTP notes Mail access protocols ◆ SMTP uses persistent connections mail mail user user server server SMTP SMTP POP agent agent ◆ SMTP is a “ push ” protocol IMAP ◆ SMTP requires that message (header & body) be in 7-bit ASCII Mail Local Remote Mail » All binary objects must be ASCII encoded Sender Mail Server Mail Server Recipient » Certain character strings are not permitted in a message » Message has to be encoded if these strings are used ◆ SMTP: Delivery to receiver’s server ◆ With MIME extensions, multiple objects can be sent in a single ◆ Mail access protocol: Retrieval from server by a user multipart message » POP [RFC 1939] — Authorization and download » IMAP (Internet Mail Access Protocol) [RFC 1730] ◆ SMTP server uses CRLF.CRLF to determine end of message ❖ More features (more complex) ❖ Manipulation of stored messages on server » HTTP: Hotmail , Yahoo! Mail, Gmail, etc . 17 18
Recommend
More recommend