Вы находитесь на странице: 1из 62

Application Layer

Computer
Networking: A Top
Down Approach
6th edition
Jim Kurose, Keith Ross
Addison-Wesley

2-1
Outline
 principles of network
applications
 Web and HTTP
 FTP
 electronic mail
 SMTP, POP3, IMAP
 DNS

2-2
Some network apps
 e-mail  voice over IP (e.g., Skype)
 web  real-time video
 text messaging conferencing
 remote login  social networking
 P2P file sharing  search
 multi-user network games  …
 streaming stored video  …
(YouTube, Hulu, Netflix)

2-3
Creating a network app application
transport
network
data link

write programs that: physical

 run on (different) end systems


 communicate over network
 e.g., web server software
communicates with browser
software
no need to write software for application

network-core devices transport


network
data link application
 network-core devices do not physical transport
network
run user applications data link
physical

2-4
Application architectures
possible structure of applications:
 client-server
 peer-to-peer (P2P)

2-5
Client-server architecture
server:
 always-on host
 permanent IP address

clients:
 communicate with server
 may have dynamic IP
client/server addresses
 do not communicate directly
with each other

2-6
P2P architecture
 no always-on server peer-peer
 arbitrary end systems
directly communicate
 peers request service from
other peers, provide service
in return to other peers
 self scalability – new
peers bring new service
capacity, as well as new
service demands
 peers are intermittently
connected and change IP
addresses
 complex management

2-7
Processes communicating
process: program running clients, servers
within a host client process: process that
 within same host, two initiates communication
processes communicate server process: process that
using inter-process waits to be contacted
communication (defined by
OS)
 processes in different hosts
communicate by exchanging  aside: applications with P2P
messages architectures have client
processes & server
processes

2-8
Sockets
 process sends/receives messages to/from its socket
 socket analogous to door
 sending process shoves message out door
 sending process relies on transport infrastructure on
other side of door to deliver message to socket at
receiving process

application application
socket controlled by
process process app developer

transport transport
network network controlled
link by OS
link Internet
physical physical

2-9
Addressing processes
 to receive messages,  identifier includes both IP
process must have identifier address and port numbers
 host device has unique 32- associated with process on
bit IP address host.
 Q: does IP address of host  example port numbers:
on which process runs  HTTP server: 80
suffice for identifying the  mail server: 25
process?  to send HTTP message to
 A: no, many processes gaia.cs.umass.edu web
can be running on same server:
host  IP address: 128.119.245.12
 port number: 80
 more shortly…

2-10
App-layer protocol defines
 types of messages open protocols:
exchanged,  defined in RFCs
 e.g., request, response  e.g., HTTP, SMTP
 message syntax: proprietary protocols:
 what fields in messages  e.g., Skype
& how fields are
delineated
 message semantics
 meaning of information
in fields
 rules for when and how
processes send & respond
to messages

2-11
What transport service does an app need?
data integrity throughput
 some apps (e.g., file transfer,  some apps (e.g.,
web transactions) require multimedia) require
100% reliable data transfer minimum amount of
 other apps (e.g., audio) can
throughput to be
tolerate some loss “effective”
 other apps (“elastic apps”)

timing make use of whatever


throughput they get
 some apps (e.g., Internet
telephony, interactive security
games) require low delay
to be “effective”  encryption, data integrity,

2-12
Transport service requirements: common apps

application data loss throughput time sensitive

file transfer no loss elastic no


e-mail no loss elastic no
Web documents no loss elastic no
real-time audio/video loss-tolerant audio: 5kbps-1Mbps yes, 100’s
video:10kbps-5Mbps msec
stored audio/video loss-tolerant same as above
interactive games loss-tolerant few kbps up yes, few secs
text messaging no loss elastic yes, 100’s
msec
yes and no

2-13
Internet transport protocols services

TCP service: UDP service:


 Reliable transport between  Unreliable data transfer
sending and receiving between sending and
process receiving process
 Flow control: sender won’t  Does not provide:
overwhelm receiver reliability, flow control,
 Congestion control: throttle congestion control,
sender when network timing, throughput
overloaded guarantee, security, or
connection setup,
 Does not provide: timing,
minimum throughput
guarantee, security Q: Why bother? Why is
 Connection-oriented: setup there a UDP?
required between client and
server processes

2-14
Internet apps: application, transport protocols

application underlying
application layer protocol transport protocol

e-mail SMTP [RFC 2821] TCP


remote terminal access Telnet [RFC 854] TCP
Web HTTP [RFC 2616] TCP
file transfer FTP [RFC 959] TCP
streaming multimedia HTTP (e.g., YouTube), TCP or UDP
RTP [RFC 1889]
Internet telephony SIP, RTP, proprietary
(e.g., Skype) TCP or UDP

2-15
Outline
 principles of network
applications
 app architectures
 app requirements
 Web and HTTP
 FTP
 electronic mail
 SMTP, POP3, IMAP
 DNS

2-16
Web and HTTP
First, a review…
 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, e.g.,
www.someschool.edu/someDept/pic.gif

host name path name

2-17
HTTP overview
HTTP: hypertext
transfer protocol
 Web’s application layer
protocol PC running
 client/server model Firefox browser

 client: browser that


requests, receives,
(using HTTP protocol) server
and “displays” Web running
objects Apache Web
 server: Web server server
sends (using HTTP
protocol) objects in iphone running
response to requests Safari browser

2-18
HTTP overview (continued)
uses TCP: HTTP is “stateless”
 client initiates TCP  server maintains no
connection (creates information about
socket) to server, port 80 past client requests
 server accepts TCP
connection from client aside
protocols that maintain
 HTTP messages “state” are complex!
(application-layer protocol
 past history (state) must be
messages) exchanged maintained
between browser (HTTP  if server/client crashes, their
client) and Web server views of “state” may be
(HTTP server) inconsistent, must be
 TCP connection closed reconciled

2-19
HTTP connections
non-persistent HTTP persistent HTTP
 at most one object  multiple objects can
sent over TCP be sent over single
connection TCP connection
 connection then between client, server
closed
 downloading multiple
objects required
multiple connections

2-20
Non-persistent HTTP
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 on port www.someSchool.edu waiting
80 for TCP connection at port 80.
“accepts” connection, notifying
2. HTTP client sends HTTP request client
message (containing URL) into
TCP connection socket. 3. HTTP server receives request
Message indicates that client message, forms response
wants object message containing requested
someDepartment/home.index object, and sends message into
its socket
time
2-21
Non-persistent HTTP (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

time
6. Steps 1-5 repeated for each of
10 jpeg objects

2-22
Non-persistent HTTP: response time

RTT (definition): time for a


small packet to travel from
client to server and back
HTTP response time: initiate TCP
 one RTT to initiate TCP
connection

connection RTT

 one RTT for HTTP request


request
file
and first few bytes of HTTP RTT
time to
response to return transmit
file
 file transmission time file
received
 non-persistent HTTP
response time =
time time
2RTT+ file transmission
time

2-23
Persistent HTTP

non-persistent HTTP issues: persistent HTTP:


 requires 2 RTTs per object  server leaves connection
 browsers often open open after sending
parallel TCP connections response
to fetch referenced objects  subsequent HTTP
messages between same
client/server sent over
open connection
 client sends requests as
soon as it encounters a
referenced object
 as little as one RTT for all
the referenced objects

2-24
HTTP request message

 two types of HTTP messages: request, response


 HTTP request message:
 ASCII (human-readable format)
carriage return character
line-feed character
request line
(GET, POST, GET /index.html HTTP/1.1\r\n
HEAD commands) Host: www-net.cs.umass.edu\r\n
User-Agent: Firefox/3.6.10\r\n
Accept: text/html,application/xhtml+xml\r\n
header Accept-Language: en-us,en;q=0.5\r\n
lines Accept-Encoding: gzip,deflate\r\n
Accept-Charset: ISO-8859-1,utf-8;q=0.7\r\n
carriage return, Keep-Alive: 115\r\n
line feed at start Connection: keep-alive\r\n
\r\n
of line indicates
end of header lines
2-25
HTTP request message: general format

method sp URL sp version cr lf request


line
header field name value cr lf
header
~
~ ~
~ lines

header field name value cr lf


cr lf

~
~ entity body ~
~ body

2-26
Uploading form input
POST method:
 web page often includes
form input
 input is uploaded to
server in entity body

URL method:
 uses GET method
 input is uploaded in URL
field of request line:
www.somesite.com/animalsearch?monkeys&banana

2-27
Method types
HTTP/1.0: HTTP/1.1:
 GET  GET, POST, HEAD
 POST  PUT
 HEAD  uploads file in entity
 asks server to leave body to path specified
requested object out in URL field
of response  DELETE
 deletes file specified in
the URL field

2-28
HTTP response message
status line
(protocol
status code HTTP/1.1 200 OK\r\n
status phrase) Date: Sun, 26 Sep 2010 20:09:20 GMT\r\n
Server: Apache/2.0.52 (CentOS)\r\n
Last-Modified: Tue, 30 Oct 2007 17:00:02
GMT\r\n
header ETag: "17dc6-a5c-bf716880"\r\n
Accept-Ranges: bytes\r\n
lines Content-Length: 2652\r\n
Keep-Alive: timeout=10, max=100\r\n
Connection: Keep-Alive\r\n
Content-Type: text/html; charset=ISO-8859-
1\r\n
\r\n
data, e.g., data data data data data ...
requested
HTML file
2-29
HTTP response status codes
 status code appears in 1st line in server-to-
client response message.
 some sample codes:
200 OK
 request succeeded, requested object later in this msg
301 Moved Permanently
 requested object moved, new location specified later in this msg
(Location:)
400 Bad Request
 request msg not understood by server
404 Not Found
 requested document not found on this server
505 HTTP Version Not Supported
2-30
Web caches (proxy server)
goal: satisfy client request without involving origin server
 user sets browser: Web
accesses via cache
 browser sends all HTTP proxy
requests to cache server
 object in cache: cache client
origin
returns object server
 else cache requests
object from origin
server, then returns
object to client
client origin
server

2-31
More about Web caching
 cache acts as both why Web caching?
client and server  reduce response time
 server for original for client request
requesting client
 client to origin server  reduce traffic on an
 typically cache is institution’s access link
installed by ISP  Internet dense with
(university, company, caches: enables “poor”
residential ISP) content providers to
effectively deliver
content (so too does
P2P file sharing)

2-32
Caching Example (1)
Assumptions
 Average object size = 100,000 bits origin
 Avg. request rate from institution’s servers
browser to origin servers = 15/sec
public
 Delay from institutional router to
Internet
any origin server and back to
router = 2 sec
Consequences
 Utilization on LAN = 15% 1.5 Mbps
access link
 Utilization on access link = 100% institutional
network
 Total delay = Internet delay + access 10 Mbps LAN

delay + LAN delay

= 2 sec + minutes + milliseconds

2-33
Caching Example (2)
Possible solution
 Increase bandwidth of access link origin
to, say, 10 Mbps servers
 Often a costly upgrade
public
Internet
Consequences
 Utilization on LAN = 15%

 Utilization on access link = 15% 10 Mbps


access link
 Total delay = Internet delay + access
institutional
delay + LAN delay network
10 Mbps LAN
= 2 sec + msecs + msecs

2-34
Caching Example (3)
Install cache
 Suppose hit rate is .4 origin
Consequence servers
public
 40% requests will be satisfied almost Internet

immediately (say 10 msec)

 60% requests satisfied by origin server 1.5 Mbps


access link
 Utilization of access link reduced to institutional
network
10 Mbps LAN
60%, resulting in negligible delays

institutional
cache
2-35
Problems

 Over 50% of all HTTP objects are uncacheable – why?

 Not easily solvable


 Dynamic data  stock prices, scores, web cams

 CGI scripts  results based on passed parameters

 Obvious fixes
 SSL  encrypted data is not cacheable

 Cookies  results may be based on passed data

 What will be the end result?

2-36
Content Distribution Networks (CDNs)

 The content providers are the CDN origin server


customers.
in North America
Content replication
 CDN company installs hundreds of
CDN servers throughout Internet
CDN distribution node
 Close to users

 CDN replicates its customers’


content in CDN servers. When
provider updates content, CDN
updates servers CDN server
CDN server
in S. America CDN server
in Asia
in Europe

2-37
Outline
 principles of network
applications
 app architectures
 app requirements
 Web and HTTP
 FTP
 electronic mail
 SMTP, POP3, IMAP
 DNS

2-38
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
2-39
FTP: separate control, data connections

 FTP client contacts FTP server TCP control connection,


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

2-40
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

2-41
Outline
 principles of network
applications
 app architectures
 app requirements
 Web and HTTP
 FTP
 electronic mail
 SMTP, POP3, IMAP
 DNS

2-42
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
2-43
Electronic mail: mail servers
mail servers: user
agent
 mailbox contains incoming
messages for user mail user
server
 message queue of outgoing agent

(to be sent) mail messages SMTP mail user


 SMTP protocol between server agent
mail servers to send email SMTP
messages user
 client: sending mail SMTP
agent
mail
server server
 “server”: receiving mail user
agent
server
user
agent

2-44
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 ASCII
2-45
Scenario: Alice sends message to Bob
1) Alice uses UA to compose 4) SMTP client sends Alice’s
message “to” message over the TCP
bob@someschool.edu 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
2-46
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
command/response
interaction, status codes

2-47
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:

 Body: the “message”


 ASCII characters only

2-48
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.

2-49
Outline
 principles of network
applications
 app architectures
 app requirements
 Web and HTTP
 FTP
 electronic mail
 SMTP, POP3, IMAP
 DNS

2-50
DNS: domain name system
people: many identifiers: Domain Name System:
 ID#, name, passport #  distributed database
Internet hosts, routers: implemented in hierarchy of
 IP address (32 bit) - many name servers
used for addressing  application-layer protocol: hosts,
datagrams name servers communicate to
 “name”, e.g., resolve names (address/name
www.yahoo.com - translation)
used by humans  note: core Internet function,
Q: how to map between IP implemented as application-
layer protocol
address and name, and
vice versa ?  complexity at network’s
“edge”

2-51
DNS: services, structure
DNS services why not centralize DNS?
 hostname to IP address  single point of failure
translation  traffic volume
 host aliasing  maintenance
 canonical, alias names
 mail server aliasing
 load distribution A: doesn’t scale!
 replicated Web
servers: many IP
addresses correspond
to one name

2-52
DNS: a distributed, hierarchical database
Root DNS Servers

… …

com DNS servers org DNS servers edu DNS servers

pbs.org poly.edu umass.edu


yahoo.com amazon.com
DNS servers DNS serversDNS servers
DNS servers DNS servers

client wants IP for www.amazon.com:


 client queries root server to find .com DNS server
 client queries .com DNS server to get amazon.com DNS server
 client queries amazon.com DNS server (local name server) to get
IP address for www.amazon.com

2-53
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

c. Cogent, Herndon, VA (5 other sites)


d. U Maryland College Park, MD k. RIPE London (17 other sites)
h. ARL Aberdeen, MD
j. Verisign, Dulles VA (69 other sites ) i. Netnod, Stockholm (37 other sites)

e. NASA Mt View, CA m. WIDE Tokyo


f. Internet Software C. (5 other sites)
Palo Alto, CA (and 48 other
sites)

a. Verisign, Los Angeles CA 13 root name


(5 other sites)
b. USC-ISI Marina del Rey, CA
“servers”
l. ICANN Los Angeles, CA worldwide
(41 other sites)
g. US DoD Columbus,
OH (5 other sites)

2-54
TLD, authoritative servers
top-level domain (TLD) servers:
 responsible for com, org, net, edu, aero, jobs, museums,
and all top-level country domains, e.g.: pk, fr, ca, jp
 Network Solutions maintains servers for .com TLD
 Educause for .edu TLD
authoritative DNS servers:
 organization’s own DNS server(s), providing
authoritative hostname to IP mappings for organization’s
named hosts
 can be maintained by organization or service provider

2-55
Local DNS name server
 does not strictly belong to hierarchy
 each ISP (residential ISP, company, university) has
one
 also called “default name server”
 when host makes DNS query, query is sent to its
local DNS server
 has local cache of recent name-to-address translation
pairs (but may be out of date!)
 acts as proxy, forwards query into hierarchy

2-56
DNS name root DNS server
resolution example
2
 host at cis.poly.edu 3
TLD DNS server
wants IP address for 4
gaia.cs.umass.edu
5

iterated query: local DNS server


dns.poly.edu
 contacted server 7 6
1 8
replies with name of
server to contact
authoritative DNS server
 “I don’t know this dns.cs.umass.edu
name, but ask this requesting host
server” cis.poly.edu

gaia.cs.umass.edu

2-57
DNS name root DNS server
resolution example
2 3
recursive query: 7
6
 puts burden of name TLD DNS
server
resolution on
contacted name local DNS server
server dns.poly.edu 5 4

 heavy load at upper 1 8


levels of hierarchy?
authoritative DNS server
dns.cs.umass.edu
requesting host
cis.poly.edu

gaia.cs.umass.edu

2-58
DNS: caching, updating records
 once (any) name server learns mapping, it caches
mapping
 cache entries timeout (disappear) after some time (TTL)
 TLD servers typically cached in local name servers
• thus root name servers not often visited
 cached entries may be out-of-date (best effort
name-to-address translation!)
 if name host changes IP address, may not be known
Internet-wide until all TTLs expire
 update/notify mechanisms proposed IETF standard
 RFC 2136

2-59
DNS records
DNS: distributed db storing resource records (RR)
RR format: (name, value, type, ttl)

type=A type=CNAME
 name is hostname  name is alias name for some
 value is IP address “canonical” (the real) name
type=NS  www.ibm.com is canonical and
 name is domain (e.g., servereast.backup2.ibm.com
foo.com) is alias
 value is hostname of  value is canonical name
authoritative name type=MX
server for this domain  value is name of mailserver
associated with name

2-60
Inserting records into DNS
 example: new startup “Network Utopia”

 register name networkuptopia.com at DNS registrar


(e.g., Network Solutions)
 provide names, IP addresses of authoritative name server
 registrar inserts two RRs into .com TLD server:

(networkutopia.com, dns1.networkutopia.com, NS)


(dns1.networkutopia.com, 212.212.212.1, A)

 create type A record for www.networkuptopia.com in authoritative server;


and type MX record for networkutopia.com if needed

2-61
A real scenario
a) Alice wants to view the web f) The local DNS server then
page sends a DNS query to
www.networkutopia.com. 212.212.212.1, asking for the
b) Her host will first send a DNS type A record corresponding
query to her local DNS to www.networkutopia.com
server. g) This record provides the IP
c) The local DNS server will address of the desired web
then contact a TLD com server, say, 212.212.71.4,
server. which the local DNS server
d) TLD server contains the type passes back to Alice’s host.
NS and type A RRs h) Alice’s browser can now
e) The TLD server replies to initiate a TCP connection to
ALICE’s local DNS server, the host 212.212.71.4 and
with containing the two RRs. send an HTTP request over
the connection.

2-62

Вам также может понравиться