Electronic Mail: COS 461: Computer Networks Spring 2006 (MW 1:30-2:50 in Friend 109)
Electronic Mail: COS 461: Computer Networks Spring 2006 (MW 1:30-2:50 in Friend 109)
Reading: 9.2.1
Jennifer Rexford
Teaching Assistant: Mike Wawrzoniak
http://www.cs.princeton.edu/courses/archive/spring06/cos461/ 1
Goals of Today’s Lecture
• Application-layer protocols
– Applications vs. application-layer protocols
– Tailoring the protocol to the application
• Electronic mail
– E-mail messages, and MIME
– E-mail addresses, and role of DNS
– E-mail servers and user agents
2
Application-Layer Protocols
• Network applications run on end systems
– They depend on the network to provide a service
– … but cannot run software on the network elements
4
Protocols Tailored to the Application
6
Comparing the Protocols
• Commands and replies
– Telnet sends commands in binary, whereas the other
protocols are text based
– Many of the protocols have similar request methods and
response codes
• Data types
– Telnet, FTP, and SMTP transmit text data in standard
U.S. 7-bit ASCII
– FTP also supports transfer of data in binary form
– SMTP uses MIME standard for sending non-text data
– HTTP incorporates some key aspects of MIME (e.g.,
classification of data formats)
7
Comparing the Protocols (Continued)
• Transport
– Telnet, FTP, SMTP, and HTTP all depend on reliable
transport protocol
– Telnet, SMTP, and HTTP use a single TCP connection
– … but FTP has separate control and data connections
• State
– In Telnet, FTP, and SMTP, the server retains information
about the session with the client
– E.g., FTP server remembers client’s current directory
– In contrast, HTTP servers are stateless
8
Reflecting on Application-Layer Protocols
• Protocols are tailored to the applications
– Each protocol is customized to a specific need
• Protocols have many key similarities
– Each new protocol was influenced by the previous ones
– New protocols commonly borrow from the older ones
• Protocols depend on same underlying substrate
– Ordered reliable stream of bytes (i.e., TCP)
– Domain Name System (DNS)
• Relevance of the protocol standards process
– Important for interoperability across implementations
– Yet, not necessary if same party writes all of the software
– …which is increasingly common (e.g., P2P software)
9
Electronic Mail
10
E-Mail Message
• E-mail messages have two parts
– A header, in 7-bit U.S. ASCII text
– A body, also represented in 7-bit U.S. ASCII text
• Header
– Lines with “type: value” header
– “To: [email protected]” blank
line
– “Subject: Go Tigers!”
• Body body
– The text message
– No particular structure
or meaning
11
E-Mail Message Format (RFC 822)
• E-mail messages have two parts
– A header, in 7-bit U.S. ASCII text
– A body, also represented in 7-bit U.S. ASCII text
• Header
– Series of lines ending in carriage return and line feed
– Each line contains a type and value, separated by “:”
– E.g., “To: [email protected]” and “Subject: Go Tigers”
– Additional blank line before the body begins
• Body
– Series of text lines with no additional structure/meaning
– Conventions arose over time (e.g., e-mail signatures)
12
Limitation: Sending Non-Text Data
• E-mail body is 7-bit U.S. ASCII
– What about non-English text?
– What about binary files (e.g., images and executables)?
• Solution: convert non-ASCII data to ASCII
– Base64 encoding: map each group of three bytes into
four printable U.S.-ASCII characters
– Uuencode (Unix-to-Unix Encoding) was widely used
begin 644 cat.txt
#0V%T
`
end
14
Multipurpose Internet Mail Extensions
• Additional headers to describe the message body
– MIME-Version: the version of MIME being used
– Content-Type: the type of data contained in the message
– Content-Transfer-Encoding: how the data are encoded
encoded data
16
Distribution of Content Types
• Content types in my own e-mail archive
– Searched on “Content-Type”, not case sensitive
– Extracted the value field, and counted unique types
– At UNIX command line: grep -i Content-Type * |
cut -d" " -f2 | sort | uniq -c | sort –nr
• Out of 44343 matches
– 25531: text/plain
– 7470: multipart to send attachments
– 4230: text/html
– 759: application/pdf
– 680: application/msword
– 479: application/octet-stream
– 292: image (mostly jpeg, and some gif, tiff, and bmp)
17
E-Mail Addresses
• Components of an e-mail address
– Local mailbox (e.g., jrex or bob.flower)
– Domain name (e.g., cs.princeton.edu)
user
user
agent
agent
• Mail servers
– Always on and always accessible
– Transferring e-mail to and from other servers
• User agents
– Sometimes on and sometimes accessible
– Intuitive interface for the user 19
SMTP Store-and-Forward Protocol
user user
agent agent
mail server mail server
• Client-server protocol
– Client is the sending mail server
– Server is the receiving mail server
• Push protocol
– Sending server pushes the file to the receiving server
– … rather than waiting for the receiver to request it 24
Simple Mail Transfer Protocol (Cont.)
• Command/response interaction
– Commands: ASCII text
– Response: three-digit status code and phrase
• Synchronous
– Sender awaits response from a command
– … before issuing the next command
– Though pipelining of commands was added later
1 mail
mail
server user
user server
2 agent
agent 3 6
4 5
26
Sample SMTP interaction
S: 220 hamburger.edu
C: HELO crepes.fr
S: 250 Hello crepes.fr, pleased to meet you
C: MAIL FROM: <[email protected]>
S: 250 [email protected]... Sender ok
C: RCPT TO: <[email protected]>
S: 250 [email protected] ... 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
27
Try SMTP For Yourself
• Running SMTP
– Run “telnet servername 25” at UNIX prompt
– See 220 reply from server
– Enter HELO, MAIL FROM, RCPT TO, DATA commands
29
Influence of PCs on E-Mail Retrieval
• Separate machine for personal use
– Users did not want to log in to remote machines
• Resource limitations
– Most PCs did not have enough resources to act as a full-
fledged e-mail server
• Intermittent connectivity
– PCs only sporadically connected to the network
– … due to dial-up connections, and shutting down of PC
– Too unwieldy to have sending server keep trying
33
Interactive Mail Access Protocol (IMAP)
• Supports connected and disconnected operation
– Users can download message contents on demand
• Multiple clients can connect to mailbox at once
– Detects changes made to the mailbox by other clients
– Server keeps state about message (e.g., read, replied to)
• Access to MIME parts of messages & partial fetch
– Clients can retrieve individual parts separately
– E.g., text of a message without downloading attachments
• Multiple mailboxes on the server
– Client can create, rename, and delete mailboxes
– Client can move messages from one folder to another
• Server-side searches
– Search on server before downloading messages
34
Web-Based E-Mail
• User agent is an ordinary Web browser
– User communicates with server via HTTP
– E.g., Gmail, Yahoo mail, and Hotmail
• Reading e-mail
– Web pages display the contents of folders
– … and allow users to download and view messages
– “GET” request to retrieve the various Web pages
• Sending e-mail
– User types the text into a form and submits to the server
– “POST” request to upload data to the server
– Server uses SMTP to deliver message to other servers
• Easy to send anonymous e-mail (e.g., spam)
35
Conclusions
• Application-layer protocols
– Rich and constantly evolving area
– Tailoring communication to the application
• Electronic-mail protocols
– SMTP to transfer e-mail messages
– Several retrieval techniques (POP, IMAP, and Web)
36