Remove Watermark Wondershare
PDFelement
CNT122
File Transfer Protocol and Electronic
mail
CNT122 - Computer Communications and Networks I 1
Remove Watermark Wondershare
PDFelement
FTP: the file transfer protocol
file transfer
FTP FTP FTP
user client server
interface
user
at host remote file
local file system
system
transfer file to/from remote host
client/server model
client: side that initiates transfer (either to/from remote)
server: remote host
ftp: RFC 959
ftp server: port 21
CNT122 - Computer Communications and Networks I 2
Remove Watermark Wondershare
PDFelement
FTP: separate control, data connections
TCP control connection,
• FTP client contacts FTP server server port 21
at port 21, using TCP
• client authorized over control TCP data connection,
connection FTP server port 20 FTP
client server
• client browses remote
directory, sends commands server opens another TCP
over control connection data connection to transfer
• when server receives file another file
transfer command, server control connection: “out of
opens 2nd TCP data connection band”
(for file) to client FTP server maintains “state”:
• after transferring one file, current directory, earlier
authentication
server closes data connection
CNT122 - Computer Communications and Networks I 3
Remove Watermark Wondershare
PDFelement
FTP commands, responses
sample commands: sample return codes
• sent as ASCII text over • status code and phrase (as in
control channel HTTP)
• USER username • 331 Username OK,
• PASS password password required
• 125 data connection
• LIST return list of file in
already open;
current directory
transfer starting
• RETR filename retrieves • 425 Can’t open data
(gets) file connection
• STOR filename stores • 452 Error writing
(puts) file onto remote host file
CNT122 - Computer Communications and Networks I 4
Remove Watermark Wondershare
PDFelement
Electronic mail outgoing
message queue
user mailbox
Three major components: user
agent
• user agents
• mail servers mail user
• simple mail transfer protocol: server agent
SMTP
SMTP mail user
server agent
User Agent
SMTP
• a.k.a. “mail reader”
• composing, editing, reading SMTP user
mail messages agent
mail
• e.g., Outlook, Thunderbird, server
iPhone mail client user
agent
• outgoing, incoming messages
stored on server user
agent
CNT122 - Computer Communications and Networks I 5
Remove Watermark Wondershare
PDFelement
Electronic mail: mail servers
user
agent
mail servers:
mail
• mailbox contains incoming server
user
agent
messages for user
SMTP
• message queue of outgoing mail user
server agent
(to be sent) mail messages
SMTP
• SMTP protocol between
mail servers to send email SMTP user
agent
messages mail
server
– client: sending mail user
server agent
– “server”: receiving mail user
agent
server
CNT122 - Computer Communications and Networks I 6
Remove Watermark Wondershare
PDFelement
Electronic Mail: SMTP [RFC 2821]
• uses TCP to reliably transfer email message from
client to server, port 25
• direct transfer: sending server to receiving server
• three phases of transfer
– handshaking (greeting)
– transfer of messages
– closure
• command/response interaction (like HTTP, FTP)
– commands: ASCII text
– response: status code and phrase
• messages must be in 7-bit ASCI
CNT122 - Computer Communications and Networks I 7
Remove Watermark Wondershare
PDFelement
Scenario: Alice sends message to Bob
1) Alice uses UA to compose 4) SMTP client sends Alice’s
message “to” message over the TCP
[email protected] connection
2) Alice’s UA sends message to 5) Bob’s mail server places the
her mail server; message message in Bob’s mailbox
placed in message queue
3) client side of SMTP opens 6) Bob invokes his user agent to
TCP connection with Bob’s read message
mail server
1 user mail user
mail agent
agent server server
2 3 6
4
5
Alice’s mail server Bob’s mail server
CNT122 - Computer Communications and Networks I 8
Remove Watermark Wondershare
PDFelement
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
CNT122 - Computer Communications and Networks I 9
Remove Watermark Wondershare
PDFelement
Try SMTP interaction for yourself:
• telnet servername 25
• see 220 reply from server
• enter HELO, MAIL FROM, RCPT TO, DATA, QUIT commands
above lets you send email without using email client (reader)
CNT122 - Computer Communications and Networks I 10
Remove Watermark Wondershare
PDFelement
SMTP: final words
• SMTP uses persistent comparison with HTTP:
connections • HTTP: pull
• SMTP requires message • SMTP: push
(header & body) to be in
7-bit ASCII • both have ASCII
command/response
• SMTP server uses
interaction, status codes
CRLF.CRLF to
determine end of • HTTP: each object
message encapsulated in its own
response msg
• SMTP: multiple objects
sent in multipart msg
CNT122 - Computer Communications and Networks I 11
Remove Watermark Wondershare
PDFelement
Mail message format
SMTP: protocol for
exchanging email msgs header
blank
RFC 822: standard for text line
message format:
• header lines, e.g., body
– To:
– From:
– Subject:
• Body: the “message”
– ASCII characters only
CNT122 - Computer Communications and Networks I 12
Remove Watermark Wondershare
PDFelement
Mail access protocols
mail access
user SMTP SMTP user
protocol
agent agent
(e.g., POP,
IMAP)
sender’s mail receiver’s mail
server server
• SMTP: delivery/storage to receiver’s server
• mail access protocol: retrieval from server
– POP: Post Office Protocol [RFC 1939]: authorization, download
– IMAP: Internet Mail Access Protocol [RFC 1730]: more
features, including manipulation of stored msgs on server
– HTTP: gmail, Hotmail, Yahoo! Mail, etc.
CNT122 - Computer Communications and Networks I 13
Remove Watermark Wondershare
PDFelement
POP3 protocol
S: +OK POP3 server ready
C: user bob
authorization phase S: +OK
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
– +OK S: .
– -ERR C: retr 1
S: <message 1 contents>
transaction phase, client: S: .
• list: list message numbers C: dele 1
• retr: retrieve message by C: retr 2
number S: <message 1 contents>
S: .
• dele: delete C: dele 2
• quit C: quit
S: +OK POP3 server signing off
CNT122 - Computer Communications and Networks I 14
Remove Watermark Wondershare
PDFelement
POP3 (more) and IMAP
more about POP3 IMAP
• previous example uses • keeps all messages in one
POP3 “download and place: at server
delete” mode
• allows user to organize
– Bob cannot re-read e- messages in folders
mail if he changes
client • keeps user state across
• POP3 “download-and- sessions:
keep”: copies of messages – names of folders and
on different clients mappings between
• POP3 is stateless across message IDs and folder
sessions name
CNT122 - Computer Communications and Networks I 15