
4530dc9b2c2f22ed055271b950194ee6.ppt
- Количество слайдов: 54
William Stallings Data and Computer Communications Chapter 19 Distributed Applications
Electronic Mail q Most heavily used application on any network q Simple Mail Transfer Protocol (SMTP) • TCP/IP • Delivery of simple text messages q Multi-purpose Internet Mail Extension (MIME) • Delivery of other types of data • Voice, images, video clips
SMTP q RFC 821 q Not concerned with format of messages or data • Covered in RFC 822 (see later) q SMTP uses info written on envelope of mail • Message header q Does not look at contents • Message body q Except: • Standardize message character set to 7 bit ASCII • Add log info to start of message • Shows path taken
Basic Operation q Mail created by user agent program (mail client) • Message consists of: • Header containing recipient’s address and other info • Body containing user data q Messages queued and sent as input to SMTP sender program • Typically a server process (daemon on UNIX)
Mail Message Contents q Each queued message has: • Message text • RFC 822 header with message envelope and list of recipients • Message body, composed by user • A list of mail destinations • • Derived by user agent from header May be listed in header May require expansion of mailing lists May need replacement of mnemonic names with mailbox names q If BCCs indicated, user agent needs to prepare correct message format
SMTP Sender q Takes message from queue q Transmits to proper destination host • Via SMTP transaction • Over one or more TCP connections to port 25 q Host may have multiple senders active q Host should be able to create receivers on demand q When delivery complete, sender deletes destination from list for that message q When all destinations processed, message is deleted
Optimization q If message destined for multiple users on a given host, it is sent only once • Delivery to users handled at destination host q If multiple messages ready for given host, a single TCP connection can be used • Saves overhead of setting up and dropping connection
Possible Errors q Host unreachable q Host out of operation q TCP connection fail during transfer q Sender can re-queue mail • Give up after a period q Faulty destination address • • User error Target user changed address Redirect if possible Inform user if not
SMTP Protocol - Reliability q Used to transfer messages from sender to receiver over TCP connection q Attempts to provide reliable service q No guarantee to recover lost messages q No end to end acknowledgement to originator q Error indication delivery not guaranteed q Generally considered reliable
SMTP Receiver q Accepts arriving message q Places in user mailbox or copies to outgoing queue forwarding q Receiver must: • Verify local mail destinations • Deal with errors • Transmission • Lack of disk space q Sender responsible for message until receiver confirm complete transfer • Indicates mail has arrived at host, not user
SMTP Forwarding q Mostly direct transfer from sender host to receiver host q May go through intermediate machine via forwarding capability • Sender can specify route • Target user may have moved
Conversation q SMTP limited to conversation between sender and receiver q Main function is to transfer messages q Rest of mail handling beyond scope of SMTP • May differ between systems
SMTP Mail Flow
SMTP System Overview q Commands and responses between sender and receiver q Initiative with sender • Establishes TCP connection q Sender sends commands to receiver • e. g. HELO
SMTP Replies q. Leading digit indicates category • • Positive completion reply (2 xx) Positive intermediate reply (3 xx) Transient negative completion reply (4 xx) Permanent negative completion reply (5 xx)
Operation Phases q. Connection setup q. Exchange of command-response pairs q. Connection termination
Connection Setup q Sender opens TCP connection with receiver q Once connected, receiver identifies itself • 220
Mail Transfer q Sender may send one or more messages to receiver q MAIL command identifies originator • Gives reverse path to used for error reporting • Receiver returns 250 OK or appropriate fail/error message q One or more RCPT commands identifies recipients for the message • Separate reply for each recipient q DATA command transfers message text • End of message indicated by line containing just period (. )
Closing Connection q Two steps q Sender sends QUIT and waits for reply q Then initiate TCP close operation q Receiver initiates TCP close after sending reply to QUIT
Sample SMTP Exchange q S: HELO pc-ycc R: 250 euler. im. ncnu. edu. tw Hello …, pleased to meet you q S: MAIL FROM:
Format for Text Messages- RFC 822 q Message viewed as having envelope and contents q Envelope contains information required to transmit and deliver message q Message is sequence of lines of text • Uses general memo framework • Header usually keyword followed by colon followed by arguments
Example Message Date: Tue, 16 Jan 1996 10: 37: 17 (EST) From: “William Stallings”
Multipurpose Internet Mail Extension (MIME) q Extension to RFC 822 q SMTP can not transmit executables • Uuencode and other schemes are available • Not standardized q Can not transmit text including international characters (e. g. â, å, ä, è, é, ê, ë) • Need 8 bit ASCII q Servers may reject mail over certain size q Translation between ASCII and EBCDIC not standard q SMTP gateways to X. 400 can not handle none text data in X. 400 messages q Some SMTP implementations do not adhere to standard • CRLF, truncate or wrap long lines, removal of white space, etc.
Overview of MIME q Five new message header fields • • • MIME version Content type Content transfer encoding Content Id Content Description q Number of content formats defines q Transfer encoding defined
Content Types q Text • text/plain, text/html q Multipart • Mixed, Parallel, Alternative, Digest q Message • RFC 822, Partial, External-body q Image • jpeg, gif q Video • mpeg q Audio • Basic q Application • Postscript • octet stream
To:
MIME Transfer Encodings q Reliable delivery across wide largest range of environments q Content transfer encoding field • Six values • Three (7 bit, 8 bit, binary) no encoding done • Provide info about nature of data q Quoted-printable • Data largely printable ASCII characters • Non-printing characters represented by hex code q Base 64 • Maps arbitrary binary input onto printable output q X-token • Named nonstandard encoding
Quoted-printable 一年=365天 Content-Type: text/plain; charset="big 5" Content-Transfer-Encoding: quoted-printable =A 4@=A 6~=3 D 365=A 4=D 1
Base 64 Encoding
POP 3 Post Office Protocol - Version 3 q RFC 1939 / Std 53 q To retrieve emails from server (POP 3 server) q Three states • Authorization State • Transaction State • Update State
POP 3 Commands q Authorization State • USER username • PASS password • APOP name digest q Transaction State • • STAT LIST [msg. No] RETR msg. No DELE msg. No NOOP RSET TOP msg. No line UIDL [msg. No] q Update State • QUIT
S: C: S: S: C: S: +OK POP 3 server ready <1896. 697170952@dbc. mtview. ca. us> USER mrose +OK User name accepted, password please PASS pwd 999 +OK Mailbox open, 2 messages (320 octets) STAT +OK 2 320 LIST +OK 2 messages (320 octets) 1 120 2 200. RETR 1 +OK 120 octets
Hypertext Transfer Protocol HTTP q Underlying protocol of the World Wide Web q Not a protocol for transferring hypertext • For transmitting information with efficiency necessary for hypertext jumps q Can transfer plain text, hypertext, audio, images, and Internet accessible information
HTTP Overview q Transaction oriented client/server protocol q Usually between Web browser (client) and Web server q Uses TCP connections q Stateless • Each transaction treated independently • Each new TCP connection for each transaction • Terminate connection when transaction complete
Key Terms q Cache q Client q Connection q Entity q Gateway q Message q Origin server q Proxy q Resource q Server q Tunnel q User agent Page 727
Examples of HTTP Operation
Intermediate HTTP Systems
HTTP Messages q Two types of messages: • Requests: Client to server • Responses: Server to client q Request line q Response line q General header q Request header q Response header q Entity body
General Header Fields q Cache control q Connection q Date q Forwarded q Keep alive q MIME version q Pragma q Upgrade
Request Methods q Request-Line = Method
Request Header Field q Accept charset q Accept encoding q Accept language q Authorization q From q Host q If modified since q Proxy authentication q Range q Referrer q Unless q User agent
Response Messages q Status line followed by one or more general, response and entity headers, followed by optional entity body q Status-Line = HTTP-Version
Status Codes q Informational q Successful q Redirection q Client error q Server error
Response Header Fields q Location q Proxy authentication q Public q Retry after q Server q WWW-Authenticate
Entity Header Fields q Allow q Content encoding q Content language q Content length q Content MD 5 q Content range q Content type q Content version q Derived from q Expires q Last modified q Link q Title q Transfer encoding q URL header q Extension header
Entity Body q Arbitrary sequence of octets q HTTP transfers any type of data including: • • • text binary data audio images video q Interpretation of data determined by header fields • Content encoding, content type, transfer encoding
Request GET http: //www. google. com. tw/ HTTP/1. 0 Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd. ms-powerpoint, application/vnd. ms-excel, application/msword, application/x-shockwave-flash, */* Accept-Language: zh-tw Cookie: PREF=ID=0665 fbe 20 f 4477 a 7: LD=zh. TW: NR=10: TM=1009076350: LM=1053234933: S=m. Pp 9 a 9 KRB 5 rtzjp. H User-Agent: Mozilla/4. 0 (compatible; MSIE 6. 0; Windows 98) Host: www. google. com. tw Proxy-Connection: Keep-Alive
Response HTTP/1. 0 200 OK Cache-Control: private Content-Type: text/html Server: GWS/2. 1 Content-Length: 4776 Date: Mon, 05 Jan 2004 13: 20: 44 GMT X-Cache: MISS from scorpius. ncnu. edu. tw X-Cache-Lookup: MISS from scorpius. ncnu. edu. tw: 3128 Proxy-Connection: keep-alive
Required Reading q Stallings chapter 19 q WWW Consortium q ASN. 1 Web site