Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
2: Application Layer 1
Applications and application-layer protocols
“user space”
exchange messages to
implement app
e.g., email, file transfer,
the Web
Application-layer protocols
application
one “piece” of an app application
transport
transport
network
network
define messages
data link
data link physical
physical
exchanged by apps and
actions taken
user services provided by
lower layer protocols
2: Application Layer 2
Network applications: some jargon
2: Application Layer 3
Client-server paradigm
Typical network app has two application
pieces: client and server transport
network
data link
Client: physical
2: Application Layer 6
Transport service requirements of common apps
2: Application Layer 7
Services provided by Internet
transport protocols
TCP service: UDP service:
connection-oriented: setup unreliable data transfer
required between client, between sending and
server receiving process
reliable transport between does not provide:
sending and receiving process connection setup,
flow control: sender won’t reliability, flow control,
overwhelm receiver congestion control, timing,
or bandwidth guarantee
congestion control: throttle
sender when network
overloaded Q: why bother? Why is
does not providing: timing, there a UDP?
minimum bandwidth
guarantees
2: Application Layer 8
Internet apps: their protocols and transport
protocols
Application Underlying
Application layer protocol transport protocol
2: Application Layer 9
The Web: some jargon
User agent for Web is
Web page:
called a browser:
consists of “objects”
MS Internet Explorer
addressed by a URL
Netscape Communicator
Most Web pages
Server for Web is
consist of:
called Web server:
base HTML page, and
Apache (public domain)
several referenced
objects. MS Internet
Information Server
URL has two
components: host name
and path name:
www.someSchool.edu/someDept/pic.gif
2: Application Layer 10
The Web: the http protocol
client/server model
client: browser that
requests, receives, Server
“displays” Web objects running
NCSA Web
server: Web server
server
sends objects in
response to requests
Mac running
http1.0: RFC 1945 Navigator
http1.1: RFC 2068
2: Application Layer 11
The http protocol: more
http: TCP transport http is “stateless”
service: server maintains no
client initiates TCP information about
connection (creates socket) past client requests
to server, port 80
aside
server accepts TCP Protocols that maintain
connection from client “state” are complex!
http messages (application- past history (state) must
layer protocol messages) be maintained
exchanged between browser if server/client crashes,
(http client) and Web server their views of “state” may
(http server) be inconsistent, must be
TCP connection closed reconciled
2: Application Layer 12
http example
Suppose user enters URL (contains text,
www.someSchool.edu/someDepartment/home.index references to 10
jpeg images)
1a. http client initiates TCP
connection to http server
(process) at
1b. http server at host
www.someSchool.edu waiting
www.someSchool.edu. Port 80
for TCP connection at port 80.
is default for http server.
“accepts” connection, notifying
client
2. http client sends http request
message (containing URL) into
TCP connection socket 3. http server receives request
message, forms response
message containing requested
object
(someDepartment/home.index),
sends message into socket
time
2: Application Layer 13
http example (cont.)
4. http server closes TCP
connection.
5. http client receives response
message containing html file,
displays html. Parsing html
file, finds 10 referenced jpeg
objects
6. Steps 1-5 repeated for each
of 10 jpeg objects
time
2: Application Layer 14
Non-persistent and persistent connections
Non-persistent Persistent
HTTP/1.0 default for HTTP/1.1
server parses request, on same TCP
responds, and closes connection: server,
TCP connection parses request,
2 RTTs to fetch each responds, parses new
object request,..
Each object transfer Client sends requests
suffers from slow for all referenced
start objects as soon as it
receives base HTML.
But most 1.0 browsers use Fewer RTTs and less
parallel TCP connections. slow start.
2: Application Layer 15
http message format: request
request line
(GET, POST, GET /somedir/page.html HTTP/1.0
HEAD commands) User-agent: Mozilla/4.0
Accept: text/html, image/gif,image/jpeg
header Accept-language:fr
lines
2: Application Layer 17
http message format: respone
status line
(protocol
status code HTTP/1.0 200 OK
status phrase) Date: Thu, 06 Aug 1998 12:00:15 GMT
Server: Apache/1.3.0 (Unix)
Last-Modified: Mon, 22 Jun 1998 …...
header
Content-Length: 6821
lines
Content-Type: text/html
2: Application Layer 18
http response status codes
In first line in server->client response message.
A few sample codes:
200 OK
request succeeded, requested object later in this message
301 Moved Permanently
requested object moved, new location specified later in
this message (Location:)
400 Bad Request
request message not understood by server
404 Not Found
requested document not found on this server
505 HTTP Version Not Supported
2: Application Layer 19
Trying out http (client side) for yourself
2: Application Layer 20
User-server interaction: authentication
2: Application Layer 22
User-server interaction: conditional GET
link out of
institutional/local ISP
network often institutional
bottleneck cache
2: Application Layer 25
ftp: the file transfer protocol
2: Application Layer 26
ftp: separate control, data connections
2: Application Layer 28
Electronic Mail outgoing
message queue
user mailbox
user
Three major components: agent
user agents mail
user
server
mail servers agent
simple mail transfer SMTP mail
protocol: smtp server user
SMTP agent
User Agent
a.k.a. “mail reader” SMTP
mail user
composing, editing, reading agent
server
mail messages
e.g., Eudora, Outlook, elm, user
Netscape Messenger agent
user
outgoing, incoming messages agent
stored on server
2: Application Layer 29
Electronic Mail: mail servers
user
Mail Servers agent
mailbox contains incoming mail
user
messages (yet to be read) server
agent
for user
SMTP
message queue of outgoing mail
server user
(to be sent) mail messages
smtp protocol between mail
SMTP agent
2: Application Layer 30
Electronic Mail: smtp [RFC 821]
2: Application Layer 31
Sample smtp interaction
S: 220 hamburger.edu
C: HELO crepes.fr
S: 250 Hello crepes.fr, pleased to meet you
C: MAIL FROM: <alice@crepes.fr>
S: 250 alice@crepes.fr... Sender ok
C: RCPT TO: <bob@hamburger.edu>
S: 250 bob@hamburger.edu ... 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
2: Application Layer 32
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)
2: Application Layer 33
smtp: final words
smtp uses persistent Comparison with http
connections
http: pull
smtp requires that
message (header & body) email: push
be in 7-bit ascii both have ASCII
certain character strings command/response
are not permitted in interaction, status codes
message (e.g., CRLF.CRLF).
Thus message has to be http: each object is
encoded (usually into either encapsulated in its own
base-64 or quoted response message
printable) smtp: multiple objects
smtp server uses message sent in a multipart
CRLF.CRLF to determine message
end of message
2: Application Layer 34
Mail message format
2: Application Layer 35
Message format: multimedia extensions
MIME: multimedia mail extension, RFC 2045, 2056
additional lines in msg header declare MIME content
type
From: alice@crepes.fr
MIME version To: bob@hamburger.edu
Subject: Picture of yummy crepe.
method used MIME-Version: 1.0
to encode data Content-Transfer-Encoding: base64
Content-Type: image/jpeg
multimedia data
type, subtype, base64 encoded data .....
parameter declaration .........................
......base64 encoded data
encoded data
2: Application Layer 36
MIME types
Content-Type: type/subtype; parameters
Text Video
example subtypes: plain, example subtypes: mpeg,
html quicktime
Image Application
example subtypes: jpeg, other data that must be
gif processed by reader
before “viewable”
Audio example subtypes:
exampe subtypes: basic
msword, octet-stream
(8-bit mu-law encoded),
32kadpcm (32 kbps
coding)
2: Application Layer 37
Multipart Type
From: alice@crepes.fr
To: bob@hamburger.edu
Subject: Picture of yummy crepe.
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=98766789
--98766789
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain
Dear Bob,
Please find a picture of a crepe.
--98766789
Content-Transfer-Encoding: base64
Content-Type: image/jpeg
2: Application Layer 38
Mail access protocols
SMTP SMTP POP3 or user
user
agent IMAP agent
2: Application Layer 39
POP3 protocol S: +OK POP3 server ready
C: user alice
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
S: .
+OK
C: retr 1
-ERR S: <message 1 contents>
transaction phase, client: S: .
C: dele 1
list: list message numbers C: retr 2
retr: retrieve message by S: <message 1 contents>
number S: .
C: dele 2
dele: delete
C: quit
quit S: +OK POP3 server signing off
2: Application Layer 40