cs 331-102-application layer

Download Report

Transcript cs 331-102-application layer

Application layer
 Principles of network
applications
 Web and HTTP
 FTP
 Electronic Mail

SMTP, POP3, IMAP
 DNS
1
Figure 2.16 TCP/IP and OSI model
2
Figure 2.14 Application layer
The application layer is responsible for
providing services to the user.
3
Figure 2.15 Summary of layers
4
Application Layer
Our goals:
 conceptual,
implementation
aspects of network
application protocols
 transport-layer
service models
 client-server
paradigm

 learn about protocols
by examining popular
application-level
protocols




HTTP
FTP
SMTP / POP3 / IMAP
DNS
peer-to-peer
paradigm
5
Some network apps
 E-mail
 Internet telephone
 Web
 Real-time video
 Instant messaging
 Remote login
 P2P file sharing
conference
 Massive parallel
computing
 Multi-user network
games
 Streaming stored
video clips
6
Creating a network app
Write programs that



run on different end
systems and
communicate over a
network.
e.g., Web: Web server
software communicates
with browser software
applicatio
n
transport
network
data link
physical
applicatio
n
transport
network
data link
physical
applicatio
n
transport
network
data link
physical
7
Application architectures
 Client-server
 Peer-to-peer (P2P)
 Hybrid of client-server and P2P
8
What transport service does an app need?
Data loss
 some apps (e.g., audio)
can tolerate some loss
 other apps (e.g., file
transfer, telnet, Ebanking) require 100%
reliable data transfer
Timing
 some apps (e.g.,
Internet telephony,
interactive games)
require low delay to
be “effective”
Bandwidth
 some apps (e.g.,
multimedia) require
minimum amount of
bandwidth to be
“effective”
 other apps (“elastic
apps”) make use of
whatever bandwidth
they get
9
Internet transport protocols services
TCP service:
 connection-oriented: setup




required between client and
server processes
reliable transport between
sending and receiving
process
flow control: sender won’t
overwhelm receiver
congestion control: throttle
sender when network
overloaded
does not providing: 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
10
Web and HTTP:
1st application protocol
First some jargon
 Web page consists of objects
 Object can be HTML file, JPEG image, Java
applet, audio file,…
 Web page consists of base HTML-file which
includes several referenced objects
 Each object is addressable by a URL
 Example URL:
www.someschool.edu/someDept/pic.gif
host name
path name
11
HTTP overview
HTTP: hypertext
transfer protocol
 Web’s application layer
protocol
 client/server model
 client: browser that
requests, receives,
“displays” Web objects
 server: Web server
sends objects in
response to requests
 HTTP 1.0: RFC 1945
 HTTP 1.1: RFC 2068
PC running
Explorer
Server
running
Apache Web
server
Mac running
Navigator
12
HTTP overview (continued)
Uses TCP:
 client initiates TCP
connection (creates socket)
to server, port 80 (wellknown)
 server accepts TCP
connection from client
 HTTP messages
(application-layer protocol
messages) exchanged
between browser (HTTP
client) and Web server
(HTTP server)
 TCP connection closed
HTTP is “stateless”
 server maintains no
information about past
client requests (we can use
cookies for implementing state)
13
HTTP connections
Nonpersistent HTTP
 At most one object is
sent over a TCP
connection.
 HTTP/1.0 uses
nonpersistent HTTP
Persistent HTTP
 Multiple objects can
be sent over single
TCP connection
between client and
server.
 HTTP/1.1 uses
persistent connections
in default mode
14
Non-persistent HTTP
(contains text,
references to 10
Suppose user enters URL
jpeg images)
www.cse.cuhk.edu.hk/index.html
CLIENT
Server
1a. HTTP client initiates TCP
connection to HTTP server
(process) at
www.cse.cuhk.edu.hk on port
80
2. HTTP client sends HTTP
request message (containing
URL) into TCP connection
socket. Message indicates
that client wants object
index.html
time
1b. HTTP server at host
www.cse.cuhk.edu.hk waiting
for TCP connection at port
80. “accepts” connection,
notifying client
3. HTTP server receives
request message, forms
response message containing
requested object, and sends
message into its socket
(we don’t send jpeg here)
15
Nonpersistent HTTP (cont.)
4. HTTP server closes TCP
5. HTTP client receives
time 6.
connection.
response message containing
html file, displays html.
Parsing html file, finds 10
referenced jpeg objects
Steps 1-5 repeated for
each of 10 jpeg objects
16
Web caches (proxy server)
Goal: satisfy client request without involving origin server
 user sets browser: Web
origin
server
accesses via cache
 browser sends all HTTP
requests to cache


object in cache: cache
returns object
else cache requests
object from origin
server, then returns
object to client
client
client
Proxy
server
origin
server
17
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

18
FTP: separate control, data connections
 FTP client contacts FTP




server at port 21,
specifying TCP as transport
protocol
Client obtains authorization
over control connection
Client browses remote
directory by sending
commands over control
connection.
When server receives a
command for a file
transfer, the server opens
a TCP data connection to
client
After transferring one file,
server closes connection.
TCP control connection
port 21
FTP
client
TCP data connection
port 20
FTP
server
 Server opens a second TCP
data connection to transfer
another file.
 FTP server maintains
“state”: current directory,
earlier authentication (unlike
http which doesn’t maintain
state)
19
Electronic Mail
outgoing
message queue
Three major components:
user mailbox
user
agent
 user agents
 mail servers
 simple mail transfer protocol:
mail
server
SMTP
User Agent
 a.k.a. “mail reader”
 composing, editing, reading
mail messages
 e.g., Eudora, Outlook, elm,
pine, Netscape Messenger
 outgoing, incoming messages
stored on server
SMTP
SMTP
mail
server
user
agent
SMTP
user
agent
mail
server
user
agent
user
agent
user
agent
20
Electronic Mail: mail servers
user
agent
Mail Servers
 mailbox contains incoming
messages for user
 message queue of outgoing
(to be sent) mail messages
 SMTP protocol between
mail servers to send email
messages
 client: sending mail
server
 “server”: receiving mail
server
mail
server
SMTP
SMTP
mail
server
user
agent
SMTP
user
agent
mail
server
user
agent
user
agent
user
agent
21
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
 commands: ASCII text
 response: status code and phrase
 messages must be in 7-bit ASCII (problem
when we send multimedia files)
22
Scenario: Alice sends message to Bob
1) Alice uses pine to
compose message and “to”
[email protected]
2) Alice’s pine sends message
to her mail server;
message placed in
message queue
3) Client side of SMTP opens
TCP connection with Bob’s
mail server
1
user
agent
2
mail
server
3
4) SMTP client sends Alice’s
message over the TCP
connection
5) Bob’s mail server places
the message in Bob’s
mailbox
6) Bob invokes his user
agent to read message
mail
server
4
5
6
user
agent
23
Mail message format
SMTP: protocol for exchanging
email messages
RFC 822: standard for text
message format:
 header lines, e.g.,
To:
(????????)
 From:
 Subject:
different from SMTP
commands!
Define what is a
message. In other
words, the data
format
header
blank
line

body
 body


the “message”, ASCII
characters only
This doesn’t work for
multimedia (e.g, video/audio)
data.
24
Message format: multimedia extensions
 MIME: multimedia mail extension, RFC 2045 (audio),
2056 (video)
 additional lines in msg header declare MIME content
type
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
25
MIME types
Content-Type: type/subtype; parameters
Text
Video
 example subtypes:
 example subtypes: mpeg,
plain, html
Image
 example subtypes: jpeg,
gif
Audio
 exampe subtypes: basic
(8-bit mu-law encoded),
32kadpcm (32 kbps
coding)
quicktime
Application
 other data that must be
processed by reader
before “viewable”
 example subtypes:
msword, octet-stream
(pdf format)
26
Mail access protocols
user
agent
SMTP
SMTP
sender’s mail
server
access
protocol
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
(provide userid and password)
IMAP: Internet Mail Access Protocol [RFC 1730]
• more features (more complex)
• manipulation of stored msgs on server
HTTP: Hotmail , Yahoo! Mail, etc.
27
DNS: Domain Name System
People: many identifiers:

HKID#, name, passport
#, CUHK ID #...etc
Internet hosts, routers:


IP address (32 bit) used for addressing
datagrams
“name”, e.g.,
idiotville.cse.cuhk.edu.hk
- 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)
28
DNS
DNS services
 Hostname to IP
address translation
 Host aliasing

Canonical and alias
names
 Mail server aliasing
Why not centralize DNS?
 single point of failure
 traffic volume
 distant centralized
database
 maintenance
 IP to hostname
mapping
29
Distributed, Hierarchical Database
Root DNS Servers
com DNS servers
yahoo.com
amazon.com
DNS servers DNS servers
org DNS servers
pbs.org
DNS servers
edu DNS servers
poly.edu
umass.edu
DNS serversDNS servers
Client wants IP for www.amazon.com; 1st approx:
 Client queries a root server to find com DNS
server
 Client queries com DNS server to get amazon.com
DNS server
 Client queries amazon.com DNS server to get IP
address for www.amazon.com
30
DOMAIN NAME SPACE
To have a hierarchical name space, a domain name
space was designed. In this design the names are
defined in an inverted-tree structure with the root at
the top. The tree can have only 128 levels: level 0
(root) to level 127.
31
Figure 25.2 Domain name space
32
Figure 25.3 Domain names and labels
33
Figure 25.8 DNS IN THE INTERNET
34
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
a NSI Herndon, VA
c PSInet Herndon, VA
d U Maryland College Park, MD
g DISA Vienna, VA
h ARL Aberdeen, MD
j NSI (TBD) Herndon, VA
k RIPE London
i NORDUnet Stockholm
m WIDE Tokyo
e NASA Mt View, CA
f Internet Software C. Palo Alto,
CA
b USC-ISI Marina del Rey, CA
l ICANN Marina del Rey, CA
13 root name
servers worldwide
35
TLD and Authoritative Servers
 Top-level domain (TLD) servers: responsible
for com, org, net, edu, etc, and all top-level
country domains uk, fr, ca, jp.
Network solutions maintains servers for com TLD
 Educause for edu TLD

 Authoritative DNS servers: organization’s
DNS servers, providing authoritative
hostname to IP mappings for organization’s
servers (e.g., Web and mail).

Can be maintained by organization or service
provider
36
Local Name Server
 Does not strictly belong to hierarchy
 Each ISP (residential ISP, company,
university) has one.

Also called “default name server”
 When a host makes a DNS query, query
is sent to its local DNS server

Acts as a proxy, forwards query into
hierarchy.
37
Example
root DNS
server
 Host at cis.poly.edu
2
3
wants IP address
for
gaia.cs.umass.edu
4
TLD DNS
server
5
local DNS server
dns.poly.edu
1
8
7
6
authoritative DNS server
dns.cs.umass.edu
requesting host
cis.poly.edu
gaia.cs.umass.edu
38
Recursive queries
recursive query:
2
 puts burden of name
resolution on
contacted name
server
 heavy load?
iterated query:
 contacted server
root DNS server
3
7
6
TLD DNS server
local DNS server
dns.poly.edu
1
5
4
8
replies with name of
server to contact
 “I don’t know this
requesting host
name, but ask this cis.poly.edu
server”
authoritative DNS server
dns.cs.umass.edu
gaia.cs.umass.edu
39
Figure 25.12 Recursive resolution
40
Figure 25.13 Iterative resolution
41
Figure 25.14 Query and response messages
42