Application Layer
Download
Report
Transcript Application Layer
Application Layer
Goals:
conceptual + implementation aspects of
network application protocols
client-server paradigm
peer-to-peer (p2p) paradigm
learn about protocols by examining popular
application-level protocols
HTTP, FTP, SMTP, POP, DNS
Application Layer
1
Applications and application-layer protocols
Application: communicating,
distributed processes
running in network hosts
in “user space”
exchange messages to
implement app
e.g., email, file transfer,
the Web
Application-layer protocols
define messages
exchanged by apps and
actions taken
uses services provided by
lower layer protocols
application
transport
network
data link
physical
application
transport
network
data link
physical
application
transport
network
data link
physical
Application Layer
2
Client-server paradigm
Typical network app has two
pieces: client and server
Client:
initiates contact with server
typically requests service from
server (e.g., request WWW
page, send email)
Server:
provides requested service to
client
e.g., sends requested WWW
page, receives/stores received
email
application
transport
network
data link
physical
request
reply
application
transport
network
data link
physical
Application Layer
3
Transport service requirements of apps
Data Delivery
some apps (e.g., audio) can tolerate some loss
other apps (e.g., file transfer, telnet) require 100%
reliable data transfer
Bandwidth
some apps (e.g., multimedia) require minimum amount
of bandwidth to be “effective”
other apps (“elastic apps”) make use of whatever
bandwidth they can get
Timing
some apps (e.g., Internet telephony, interactive
games) require low delay to be “effective”
Application Layer
4
Transport service requirements of common apps
Data loss
Bandwidth
Time Sensitive
file transfer
e-mail
Web documents
real-time audio/video
no loss
no loss
no loss
loss-tolerant
no
no
no
yes, 100’s msec
stored audio/video
interactive games
financial apps
loss-tolerant
loss-tolerant
no loss
elastic
elastic
elastic
audio: 5Kb-1Mb
video:10Kb-5Mb
same as above
few Kbps up
elastic
Application
yes, few secs
yes, 100’s msec
yes and no
Application Layer
5
Services provided by Internet
transport protocols
TCP service:
connection-oriented: setup
required between client,
server
reliable transport between
sending and receiving process
flow control: sender won’t
overwhelm receiver
congestion control: throttle
sender when network
overloaded
does not provide: timing,
minimum bandwidth
guarantees
UDP service:
unreliable data transfer
between sending and
receiving process
does not provide:
connection setup,
reliability, flow control,
congestion control, timing,
or bandwidth guarantee
Application Layer
6
Internet apps: application & transport protocols
Application
e-mail
remote terminal access
Web
file transfer
streaming multimedia
remote file server
Internet telephony
Application
layer protocol
Underlying
transport protocol
SMTP [RFC 821]
Telnet [RFC 854]
HTTP [RFC 2068]
FTP [RFC 959]
proprietary
(e.g. WMT)
NFS
proprietary
(e.g., Vocaltec)
TCP
TCP
TCP
TCP
TCP or UDP
TCP or UDP
typically UDP
Application Layer
7
WWW: the HTTP protocol
HTTP: HyperText
Transfer Protocol
WWW’s application layer
protocol
client/server model
client: browser that
requests, receives,
“displays” WWW
objects
server: WWW server
sends objects in
response to requests
http1.0: RFC 1945
http1.1: RFC 2068
PC running
Explorer
Server
running
Apache
Web
server
Mac running
Navigator
Application Layer
8
HTTP
TCP transport service:
client initiates a TCP
connection to server,
port 80
server accepts TCP
connection from client
http messages
(application-layer
protocol messages)
exchanged between
browser and WWW
server
TCP connection closed
http is “stateless”
server maintains no
information about
past client requests
aside
Protocols that maintain
“state” are complex!
past history (state)
must be maintained
if server/client
crashes, their views
of “state” may be
inconsistent, must be
recovered
Application Layer
9
http example
Suppose user enters URL
www.someUniv.ac.kr/someDepartment/index.html
(contains text,
references to 10
jpeg images)
1a. http client initiates TCP
connection to http server
(process) at
www.someUniv.ac.kr. Port 80 is
default for http server.
2. http client sends http request
message (containing URL) into
TCP connection socket
time
1b. http server at host
www.someUniv.ac.kr waiting
for TCP connection at port 80.
“accepts” connection, notifying
client
3. http server receives request
message, forms response
message containing requested
object
(someDepartment/index.html),
sends message into socket
Application Layer
10
http example (cont.)
4. http server closes TCP
5. http client receives response
connection.
message containing html file,
displays html. Parsing html
file, finds 10 referenced jpeg
objects
6. Steps 1-5 repeated for each
time
of 10 jpeg objects
non-persistent connection: one object in each TCP
connection
some browsers create multiple TCP connections
simultaneously - one per object (HTTP v1.0)
persistent connection: multiple objects transferred
within one TCP connection (HTTP v.1.1)
Application Layer
11
http message format: Request
two types of http messages: request, response
http request message:
ASCII (human-readable format)
request line
(GET, POST,
HEAD commands)
GET /somedir/page.html HTTP/1.1
Connection: close
User-agent: Mozilla/4.0
header Accept: text/html, image/gif,image/jpeg
lines Accept-language:fr
Carriage return,
line feed
indicates end
of message
(extra carriage return, line feed)
Application Layer
12
http request message: general format
Application Layer
13
http message format: Reply
status line
(protocol
status code
status phrase)
header
lines
data, e.g.,
requested
html file
HTTP/1.1 200 OK
Connection: close
Date: Fri, 12 May 2000 12:30:00 GMT
Server: Apache/1.3.0 (Unix)
Last-Modified: Mon, 22 Jun 1998 …...
Content-Length: 6821
Content-Type: text/html
data goes here ...
Application Layer
14
http reply status codes
In the first line of response message. 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
304 Not Modified
requested document has not been modified (Conditional GET)
505 HTTP Version Not Supported
Application Layer
15
User-server interaction: conditional GET
Goal: don’t send object
if client has up-to-date
stored (cached) version
client: specify date of
cached copy in http
request
If-modified-since:
<date>
client
server
http request msg
If-modified-since:
<date>
http response
HTTP/1.0
304 Not Modified
object
not
modified
server: response
contains no object if
cached copy up-todate:
HTTP/1.0 304 Not
Modified
http request msg
If-modified-since:
<date>
http response
object
modified
HTTP/1.1 200 OK
…
<data>
Application Layer
16
User-server interaction: Authentication
Goal: control access to server
server
client
documents
usual http request msg
stateless: client must
401: authorization req.
present authorization in
WWW authenticate:
each request
authorization: typically
usual http request msg
name, password
+ Authorization:line
authorization: header
usual http response msg
line in request
if no authorization
usual http request msg
presented, server
+ Authorization:line
refuses access, sends
WWW authenticate:
header line in response
usual http response msg
Application Layer
time
17
User-server interaction: Cookies
Cookies is a way of
remembering things for client
you (e.g., authentication,
usual http request msg
user preferences,
usual http response +
previous choices)
Set-cookie: #
server sends “cookie” to
client in response
usual http request msg
Set-cookie: #
client present cookie in
later requests
cookie: #
server matches
presented-cookie with
server-stored cookies
http://cookiescache.tripod.com/
cookie: #
usual http response msg
usual http request msg
cookie: #
usual http response msg
server
cookiespecific
action
cookiespecific
action
Application Layer
18
Web Caching
Goal: satisfy client request without involving origin server
user sets browser:
WWW accesses via
web cache
client sends all http
requests to web cache
if object at web cache,
web cache immediately
returns object in http
response
else requests the object
from origin server, saves
it in the cache, then
returns object in http
response
origin
server
client
Cache
server
client
origin
server
Application Layer
19
Why Web Caching?
Assume: cache is “close” to
client (e.g., in the same
network)
faster response time:
cache “closer” to client
decrease traffic to
distant servers
link out of enterprise
network often bottleneck
Cache server farm could
origin
servers
public
Internet
T1 Internet
link
enterprise
network
enterprise
cache server
100 Mbps LAN
be deployed to distribute
load thus to increase
performance
Application Layer
20
FTP: the file transfer protocol
user
at host
FTP
FTP
user
client
interface
file transfer
local file
system
FTP
server
remote file
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
21
FTP: separate control, data connections
ftp client contacts ftp
server at port 21, specifying
TCP as transport protocol
two parallel TCP connections
opened:
control: exchange
commands, responses
FTP
between client, server.
client
“out of band control”
data: file data to/from
server
ftp server maintains “state”:
current directory, earlier
authentication
TCP control connection
port 21
TCP data connection
port 20
FTP
server
Application Layer
22
Passive Mode FTP
client
2834
FTP Server
connect
accept
21
client
2834
2834
connect
data transfer
disconnect
accept
Active Mode
connect
accept
21
passive mode request
passive mode 3848
active mode 2835
2835
2835
FTP Server
20
20
2835
2835
21
2834
connect
data transfer
disconnect
accept
3848
3848
21
Passive Mode
Passive Mode FTP
when client is located inside a firewall.
Use dynamically generated port number instead of 20
A client connect to the FTP server first for data transfer
Cannot detect the ftp data transfer by the packet header only
Application Layer
23
Analysis of Passive FTP traffic
Use the same mechanism as the multimedia traffic
analysis
Examination of FTP control packet payload
The payload data from a FTP server to a FTP client
IP, TCP Header
FTP Payload
227 Entering Passive Mode (141,223,82,141,128,40)
The IP address of the FTP server
= 141.223.82.141
The port number of the FTP server for data transfer
= 128 * 256 + 40 = 32808
Application Layer
24
Electronic Mail
outgoing
message queue
Three major components:
user mailbox
user
agent
user agents
mail servers
simple mail transfer
protocol (SMTP) is used
between mail servers
User Agent
a.k.a. “mail reader”
composing, editing, reading
mail messages
e.g., Outlook, elm, mutt
also uses SMTP between
agent and server
mail
server
SMTP
SMTP
mail
server
user
agent
SMTP
user
agent
mail
server
user
agent
user
agent
user
agent
Application Layer
25
Electronic Mail: mail servers
Mail Servers
user
agent
mailbox contains incoming
mail
messages (yet to be read)
server
for users
SMTP
message queue of outgoing
(to be sent) mail messages
smtp protocol between mail SMTP
servers to send email
SMTP
messages
mail
server
client: sending mail
server
user
“server”: receiving mail
agent
user
server
user
agent
mail
server
user
agent
user
agent
agent
Application Layer
26
Electronic Mail: SMTP [RFC 821]
uses TCP to reliably transfer email msg from
client to server, port 25
direct transfer: sending server to receiving
server
three phases of transfer
handshaking (greeting)
transfer
closure
command/response interaction
commands: ASCII text
response: status code and phrase
Application Layer
27
Mail message format
RFC 822: standard for
text message
format:
header lines
To:
From:
Subject:
header
blank
line
body
the “message”, ASCII
characters only
body
.
line containing only `.’
Application Layer
28
Message format: multimedia extensions
MIME: Multipurpose Internet Mail Extension, RFC
2045, 2056
MIME content type declared in msg header
MIME version
method used
to encode data
multimedia data
type, subtype,
parameter declaration
encoded data
From: [email protected]
To: [email protected]
Subject: Picture of yummy crepe.
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Type: image/jpeg
base64 encoded data .....
.........................
......base64 encoded data
.
Application Layer
29
MIME types
Text
Video
example subtypes:
example subtypes:
Image
Application
plain, html
example subtypes:
jpeg, gif
Audio
example subtypes:
basic (8-bit mu-law
encoded), 32kadpcm
(32 kbps coding)
mpeg, quicktime
other data that must
be processed by
reader before
“viewable”
example subtypes:
msword, octetstream
Application Layer
30
Mail access protocols
user
agent
SMTP
SMTP
sender’s mail
server
POP3 or
IMAP
user
agent
receiver’s mail
server
SMTP: delivery/storage to receiver’s server
Mail Access Protocol: retrieval from server
POP:
Post Office Protocol [RFC 1939]
• authorization (agent <-->server) and download
IMAP: Internet Mail Access Protocol [RFC 1730]
• more features (more complex)
• manipulation of stored msgs on server
Application Layer
31
POP3 protocol
authorization phase
client commands:
user: username
pass: password
server responses
+OK
-ERR
transaction phase, client:
list: list message
numbers
retr: retrieve message by
number
dele: delete
quit
S:
C:
S:
C:
S:
+OK POP3 server ready
user alice
+OK
pass hungry
+OK user successfully logged
C:
S:
S:
S:
C:
S:
S:
C:
C:
S:
S:
C:
C:
S:
list
1 498
2 912
.
retr 1
<message 1 contents>
.
dele 1
retr 2
<message 1 contents>
.
dele 2
quit
+OK POP3 server signing off
Application Layer
on
32
IMAP
More functionalities than POP
users can manipulate messages on server, e.g., to
create hierarchy of folders
folders organization accessed from all user’s
machines (office, @home, mobile)
users can retrieve only part(s) of a multipart
message, e.g., downloading in a small portable
terminal only header or text part of a multimedia
message.
More complex
server maintains state, e.g., hierarchy of folders
for each user
Application Layer
33
Web Mail
user
agent
HTTP
SMTP
ordinary
sender’s mail
Web browser
server
receiver’s mail
server
HTTP
user
agent
ordinary
Web browser
Convenient for the user on the go (Internet Café,
WebTV, …)
User can organize their hierarchy of folders on servers
May be slow:
server typically far from client
interaction with server through CGI scripts
Application Layer
34
DNS: Domain Name System
People:
many identifiers: SSN,
name, Passport #
Internet hosts, routers:
IP address (32 bit) used for addressing
datagrams
“name”, e.g.,
www.postech.ac.kr used by humans
Q: map between IP
addresses and name ?
Domain Name System:
distributed database
implemented in hierarchy of
many name servers
application-layer protocol
host, routers, name servers to
communicate to resolve names
(address/name translation)
note: core Internet function
implemented as applicationlayer protocol
complexity at network’s
“edge”
Application Layer
35
DNS name servers
Why not centralize DNS?
single point of failure
traffic volume
distant centralized
database
maintenance
Just doesn’t scale!
no server has all name-
to-IP address mappings
local name servers:
each ISP, company has
local (default) name server
host DNS query first goes
to local name server
authoritative name server:
for a host: stores that
host’s IP address, name
can perform name/address
translation for that host’s
name
Application Layer
36
DNS: Root name servers
contacted by local
name server that
can not resolve name
root name server:
contacts
authoritative
name server if
name mapping not
known
gets mapping
returns mapping
to local name
server
13 root name
servers worldwide
Application Layer
37
Simple DNS example
host surf.eurecom.fr
wants IP address of
gaia.cs.umass.edu
root name server
2
4
5
1. Contacts its local DNS
server, dns.eurecom.fr
local name server
dns.eurecom.fr
2. dns.eurecom.fr contacts
root name server, if
1
6
necessary
3. root name server contacts
authoritative name server,
requesting host
dns.umass.edu, if
surf.eurecom.fr
necessary
3
authorititive name server
dns.umass.edu
gaia.cs.umass.edu
Application Layer
38
DNS example
root name server
Root name server:
may not know
authoritative name
server
may know
intermediate name
server: who to
contact to find
authoritative name
server
6
2
7
local name server
dns.eurecom.fr
1
8
requesting host
3
intermediate name server
dns.umass.edu
4
5
authoritative name server
dns.cs.umass.edu
surf.eurecom.fr
gaia.cs.umass.edu
Application Layer
39
DNS: iterated queries
root name server
recursive query:
puts burden of name
resolution on
contacted name
server
heavy load?
iterated query:
contacted server
replies with name of
server to contact
“I don’t know this
name, but ask this
server”
iterated query
2
3
4
7
local name server
dns.eurecom.fr
1
8
requesting host
intermediate name server
dns.umass.edu
5
6
authoritative name server
dns.cs.umass.edu
surf.eurecom.fr
gaia.cs.umass.edu
Application Layer
40
DNS: caching and updating records
once (any) name server learns mapping, it
caches mapping
cache entries timeout (disappear)
after some time
DNS Related RFCs http://www.zoneedit.com/doc/rfc/
Application Layer
41
DNS records
DNS: distributed db storing resource records (RR)
RR format: (name,
Type=A
name is hostname
value is IP address
Type=NS
name is domain (e.g.
foo.com)
value is IP address of
authoritative name
server for this domain
value, type,ttl)
Type=CNAME
name is an alias name
for some “cannonical”
(the real) name
value is cannonical
name
Type=MX
value is hostname of
mailserver associated with
name
Application Layer
42
DNS protocol, messages
DNS protocol : query and repy messages, both with
the same message format
msg header
identification: 16 bit # for
query, repy to query uses
same #
flags:
query or reply
recursion desired
recursion available
reply is authoritative
Application Layer
43
DNS protocol, messages
Name, type fields
for a query
RRs in reponse
to query
records for
authoritative servers
additional “helpful”
info that may be used
Application Layer
44
Peer-to-peer (P2P) paradigm
Peer has the functionality of both client and server
Client-Server Architecture
P2P Architecture
Peer
Client
Client
Server
Client
Peer
Peer
Client
http://www.peer-to-peerwg.org/
Peer
Peer
Application Layer
45
Why peer-to-peer (P2P)?
The information creation, distribution and
consummation are ideally a decentralized and
distributed process
The relationship between consumer and provider
of information normally is peer to peer
Popular P2P applications
o Instant Messaging – MSN/Yahoo Messengers, ICQ, etc.
o File Sharing – WinMX, Kazaa, Morpheus, e-donkey, Vshare, etc.
P2P apps use proprietary, Freenet, Gnutella, FastTrack
protocols
Application Layer
46
P2P Profit Model
Many businesses are attempting to utilize P2P for commercial purposes
Super
Computing
File Sharing
DRM
Web Hard
Temporary
Back Up
Local
Search Engine
Video
Conference
Hard Disk공유
CPU공유
Contents
Distribution
Internet
Infrastructure
Collaboration
Component
SI
Company’s
Infrastructure
Providing
By Product
Infrastructure
KMS
GroupWare
EDMS
Service Model
Application
Profit Model
Commerce
SCM
Intermediary
Collaboration
Payment
Contents
Distribution
B2B,B2C
Infra제공
복덕방
벼룩시장
광고
가입비/수수료
광고
Messenger
Video
File Sharing
Conference
중고 매매
Commerce
B2B
C2C
B2C
P2P결재
컨텐츠
수수료 유통 수수료
CP
가입비
P2P광고
Application Layer
47
Summary
Learned the conceptual + implementation
aspects of network application protocols
client-server paradigm
peer-to-peer (p2p) paradigm
Learned about protocols by examining
popular application-level protocols
HTTP, FTP, SMTP, POP, DNS
Application Layer
48