0% found this document useful (0 votes)
13 views

Application Layer - 2

Uploaded by

Fatima Ismail
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Application Layer - 2

Uploaded by

Fatima Ismail
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Chapter 2: outline

2.1 principles of network 2.6 socket programming


applications with UDP and TCP
 app architectures
 app requirements
2.2 Web and HTTP
2.3 FTP
2.4 electronic mail
 SMTP, POP3, IMAP
2.5 DNS

Application Layer 2-44


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
Application Layer 2-45
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
over control connection  server opens another TCP
data connection to transfer
 when server receives file another file
transfer command, server
opens 2nd TCP data  control connection: “out of
connection (for file) to client band”
 after transferring one file,  FTP server maintains
server closes data connection “state”: current directory,
earlier authentication

Application Layer 2-46


FTP commands, responses
sample commands: sample return codes
 sent as ASCII text over  status code and phrase (as
control channel in HTTP)
 USER username  331 Username OK,
 PASS password password required
 LIST return list of file in  125 data
current directory connection
already open;
 RETR filename transfer starting
retrieves (gets) file  425 Can’t open
 STOR filename stores data connection
(puts) file onto remote  452 Error writing
host file

Application Layer 2-47


Chapter 2: outline
2.1 principles of network 2.6 socket programming
applications with UDP and TCP
 app architectures
 app requirements
2.2 Web and HTTP
2.3 FTP
2.4 electronic mail
 SMTP, POP3, IMAP
2.5 DNS

Application Layer 2-48


Electronic mail outgoing
message queue
user mailbox
Three major components: user
agent
 user agents
 mail servers mail user
server agent
 simple mail transfer
protocol: SMTP SMTP mail user
server agent

User Agent SMTP


 a.k.a. “mail reader” SMTP user
agent
 composing, editing, reading mail
server
mail messages user
 e.g., Outlook, Thunderbird, agent
iPhone mail client user
agent
 outgoing, incoming
messages stored on server
Application Layer 2-49
Electronic mail: mail servers
mail servers: user
agent
 mailbox contains incoming
messages for user mail user
server agent
 message queue of outgoing
(to be sent) mail messages SMTP mail user
 SMTP protocol between server agent
mail servers to send email SMTP
messages
 client: sending mail SMTP user
agent
mail
server server
user
 “server”: receiving mail agent
server
user
agent

Application Layer 2-50


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
Application Layer 2-51
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 5) Bob’s mail server places the
to her mail server; message message in Bob’s mailbox
placed in message queue 6) Bob invokes his user agent
3) client side of SMTP opens to read message
TCP connection with Bob’s
mail server

1 user mail user


mail agent
agent server server
2 3 6
4
5
Alice’s mail server Bob’s mail server
Application Layer 2-52
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

Application Layer 2-53


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)

Application Layer 2-54


SMTP: final words
 SMTP uses persistent comparison with HTTP:
connections
 HTTP: pull
 SMTP requires message
(header & body) to be in  SMTP: push
7-bit ASCII  both have ASCII
 SMTP server uses command/response
CRLF.CRLF to interaction, status codes
determine end of message
 HTTP: each object
encapsulated in its own
response msg
 SMTP: multiple objects
sent in multipart msg

Application Layer 2-55


Mail message format

SMTP: protocol for


exchanging email msgs header
blank
RFC 822: standard for text line
message format:
 header lines, e.g.,
 To: body
 From:
 Subject:
different from SMTP MAIL
FROM, RCPT TO:
commands!
 Body: the “message”
 ASCII characters only

Application Layer 2-56


Mail access protocols
user
mail access user
SMTP SMTP 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.

Application Layer 2-57


POP3 protocol
S: +OK POP3 server ready
C: user bob
authorization phase S:
C:
+OK
pass hungry
 client commands: S: +OK user successfully logged on
 user: declare username
 pass: password C: list
S: 1 498
 server responses
S: 2 912
 +OK S: .
 -ERR C: retr 1
transaction phase, client: S:
S:
<message 1 contents>
.
 list: list message numbers C: dele 1
 retr: retrieve message by C: retr 2
number S: <message 1 contents>
 dele: delete S: .
 quit C: dele 2
C: quit
S: +OK POP3 server signing off
Application Layer 2-58
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  keeps user state across
client sessions:
 POP3 “download-and-  names of folders and
keep”: copies of messages mappings between
on different clients message IDs and folder
 POP3 is stateless across name
sessions

Application Layer 2-59

You might also like