Sie sind auf Seite 1von 47

2: Application Layer 1

Chapter 2
Application Layer
Computer Networking:
A Top Down Approach,
4
th
edition.
Jim Kurose, Keith Ross
Addison-Wesley, July
2007.

A note on the use of these ppt slides:
Were making these slides freely available to all (faculty, students, readers).
Theyre in PowerPoint form so you can add, modify, and delete slides
(including this one) and slide content to suit your needs. They obviously
represent a lot of work on our part. In return for use, we only ask the
following:
! If you use these slides (e.g., in a class) in substantially unaltered form,
that you mention their source (after all, wed like people to use our book!)
! If you post any slides in substantially unaltered form on a www site, that
you note that they are adapted from (or perhaps identical to) our slides, and
note our copyright of this material.
Thanks and enjoy! JFK/KWR

All material copyright 1996-2007
J.F Kurose and K.W. Ross, All Rights Reserved
2: Application Layer 2
Killer Apps
1970s-1980s
! Text e-mail, remote access, file transfer,
newsgroup, text chat
mid-1990s
! World Wide Web, search, electronic commerce
End of the millennium
! Instant message, P2P file sharing
2000s
! Internet telephony, video sharing and streaming,
Internet radio and IPTV, wireless access
2: Application Layer 3
Chapter 2: Application layer
! 2.1 Principles of
network applications
! 2.2 Web and HTTP
! 2.3 FTP
! 2.4 Electronic Mail
" SMTP, POP3, IMAP
! 2.5 DNS
! 2.6 P2P Applications
! 2.7 Socket programming
with TCP
! 2.8 Socket programming
with UDP
2: Application Layer 4
Chapter 2: Application Layer
Our goals:
! conceptual,
implementation
aspects of network
application protocols
" networking
service models
" client-server
paradigm
" peer-to-peer
paradigm
! learn about protocols
by examining popular
application-level
protocols
" HTTP
" FTP
" SMTP / POP3 / IMAP
" DNS
! programming network
applications
" socket API
2: Application Layer 5
Creating a network app
Write programs that
" run on (different) end
systems
" communicate over network
" e.g., web server software
communicates with browser
software
Dont need to write software for
devices in network core
" network core devices do not
run user applications
" confining applications on end
systems has facilitated the
rapid app development,
propagation
application
transport
network
data link
physical
application
transport
network
data link
physical
application
transport
network
data link
physical
2: Application Layer 6
Application architectures
Designed by application developer and dictate
how the application is structed over the
various end systems
! Client-server
! Peer-to-peer (P2P)
! Hybrid of client-server and P2P
2: Application Layer 7
Client-server architecture
server:
" always-on host
" permanent IP address
" server farms for scaling,
infrastructure intensive
clients:
" communicate with server
" may be intermittently
connected
" may have dynamic IP
addresses
" do not communicate directly
with each other
client/server
2: Application Layer 8
! Server farm: a cluster of hosts
" Powerful virtual server to support many reqests
" Infrastructure intensive --- costly
Service providers to purchase, install and maintain
server farms
Also pay recurring interconnection and bandwidth
costs for sending receiving data
Search engine: Google, Baidu
Internet commerce: Amazon, e-Bay
Web-based email: Yahoo Mail, Gmail
Social network: facebook
Video sharing: YouTube
Client-server architecture
Google Data Centers
! Estimated cost of data center: $600M
! Google spent $2.4B in 2007 on new data
centers
! Each data center uses 50-100 megawatts
of power

2: Application Layer 10
Pure P2P architecture
! no always-on server
! arbitrary end systems directly
communicate
! peers are intermittently
connected and change IP
addresses
! Traffic-intensive applications:
" File distribution: BitTorrent
" IPTV: PPlive
Self-scalability: add service capacity to
the system by distributing files to
peers
Cost effective: dont require significant
server infrastructure and server
bandwidth
But secure problem and difficult to
manage
peer-peer
2: Application Layer 11
Hybrid of client-server and P2P
Skype
" voice-over-IP P2P application
" centralized server: finding address of remote
party:
" client-client connection: direct (not through
server)
Instant messaging
" chatting between two users is P2P
" centralized service: client presence detection/
location
user registers its IP address with central
server when it comes online
user contacts central server to find IP
addresses of buddies
2: Application Layer 12
Processes communicating
Process: program running
within a host.
! within same host, two
processes communicate
using inter-process
communication (defined
by OS).
! processes in different
hosts communicate by
exchanging messages
Client process: process
that initiates
communication
Server process: process
that waits to be
contacted



! Note: applications with
P2P architectures have
client processes &
server processes
2: Application Layer 13
Interface between the process and
the computer network: Sockets
! process sends/receives
messages to/from its
socket---software
interface
! socket analogous to door
" sending process shoves
message out door
" sending process relies on
transport infrastructure
on other side of door which
brings message to socket
at receiving process
process
TCP with
buffers,
variables
socket
host or
server
process
TCP with
buffers,
variables
socket
host or
server
Internet
controlled
by OS

controlled by
app developer
! API: (1) choice of transport protocol; (2) ability to fix
a few parameters (maximum buffer, maximum
segment sizes)

2: Application Layer 14
Addressing processes
How does a process indicate which process it wants to
communicate with using these services?

To identify the receiving process, two pieces of
information need to be specified
1. The name or address of the host
--- host device has unique 32-bit IP address
2. The identifier that specifies the receiving process
in the destination host
--- port number

2: Application Layer 15
Addressing processes
! identifier includes both IP address and port numbers
associated with process on host.
! Example port numbers:
" HTTP server: 80
" Mail server: 25
! to send HTTP message to gaia.cs.umass.edu web
server:
" IP address: 128.119.245.12
" Port number: 80
2: Application Layer 16
App-layer protocol defines
! Types of messages
exchanged,
" e.g., request, response
! Message syntax:
" what fields in messages &
how fields are delineated
! Message semantics
" meaning of information in
fields
! Rules for when and how
processes send &
respond to messages
Public-domain protocols:
! defined in RFCs
! allows for
interoperability
! e.g., HTTP, SMTP
Proprietary protocols:
! e.g., Skype
2: Application Layer 17
What transport service does an app need?
Reliable Data Transfer
! some apps (e.g., audio) can tolerate
some loss
! other apps (e.g., file transfer,
telnet) require 100% reliable data
transfer
Timing
! some apps (e.g., Internet
telephony, interactive games)
require low delay to be
effective
Throughput/Bandwidth: the rate at
which the sending process can
deliver bits to the receiving process
--- fluctuate with time
! some apps (e.g., multimedia) require
minimum amount(32kbps for voice
encoding) of bandwidth to be
effective
! other apps (elastic apps) make use
of whatever bandwidth they get
Security
! Confidentiality: encrypt/decrypt
! Data integrity and end-point
authentication
2: Application Layer 18
Transport service requirements of common apps
Application

file transfer
e-mail
Web documents
real-time audio/video

stored audio/video
interactive games
instant messaging
Data loss

no loss
no loss
no loss
loss-tolerant

loss-tolerant
loss-tolerant
no loss
Bandwidth

elastic
elastic
elastic
audio: 5kbps-1Mbps
video:10kbps-5Mbps
same as above
few kbps up
elastic
Time Sensitive

no
no
no
yes, 100s msec

yes, few secs
yes, 100s msec
yes and no
2: Application Layer 19
Internet transport protocols services
TCP service:
! connection-oriented: client and
server exchange transport layer
control info. with each other
setup before app. level messages
begin to flow
" After handshaking, a TCP connection
is said to exist between the sockets
of the two processes
" Connection is full-duplex
! reliable transport : without error
and in the proper order between
sending and receiving process
! flow control: sender wont
overwhelm receiver
! congestion control: throttle
sender when network overloaded
! does not provide: timing,
minimum bandwidth guarantees
UDP service: lightweight
protocol
! No handshaking
! unreliable data transfer
between sending and
receiving process
! does not provide: connection
setup, reliability, flow
control, congestion control,
timing, or bandwidth
guarantee
Q: why bother? Why is there a
UDP?
2: Application Layer 20
Internet apps: application, transport protocols
Application

e-mail
remote terminal access
Web
file transfer
streaming multimedia

Internet telephony

Application
layer protocol

SMTP [RFC 2821]
Telnet [RFC 854]
HTTP [RFC 2616]
FTP [RFC 959]
HTTP, RTP
(e.g. YouTube)
SIP, RTP or proprietary
(e.g., skype)
Underlying
transport protocol

TCP
TCP
TCP
TCP
TCP or UDP


typically UDP
2: Application Layer 21
App-layer protocols
! An app-layer protocol
defines how an apps
processes, running on
different end system, pass
messages to each other:
" Types of messages exchanged,
e.g., request, response
" Message syntax:
what fields in messages & how
fields are delineated
" Message semantics
meaning of information in fields
" Rules for when and how
processes send & respond to
messages
Public-domain protocols:
! defined in RFCs
! allows for
interoperability
! e.g., HTTP, SMTP
Proprietary protocols:
! e.g., Skype
2: Application Layer 22
Chapter 2: Application layer
! 2.1 Principles of
network applications
" app architectures
" app requirements
! 2.2 Web and HTTP
! 2.3 FTP
! 2.4 Electronic Mail
" SMTP, POP3, IMAP
! 2.5 DNS
! 2.6 P2P file sharing
! 2.7 Socket programming
with TCP
! 2.8 Socket programming
with UDP
2: Application Layer 23
Web and HTTP (HyperText Transfer Protocol)
1994, Berners-Lee, World Wide Web: the application
that elevated the Internet from just one of many data
networks to essentially the one and only one data
network
" Operate on demand: users receive what they want, when they
want it
" enormously easy for any individual to make information
available over the web
" Hyperlinks and search engines help us navigate through an
ocean of web sites
! HTTP: the webs application-layer protocol
" The heart of the Web [RFC 1945, RFC 2616]
" Implemented in two programs: client and server program, executing
on different end systems, talk to each other by exchanging HTTP
messages


WEB
2: Application Layer 24
First some jargon
! Web page consists of objects
! An object is a file: 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 (Uniform Resource
Locator) that has three components
! Example URL:
http://www.someschool.edu/someDept/pic.gif
host name of the server
objects path name
protocol
2: Application Layer 25
HTTP overview
HTTP: hypertext transfer
protocol, defines how Web
clients request Web pages
from Web servers and how
servers transfer Web pages
to clients
! Webs application layer
protocol --- at the heart of
the Web
" define message structure
" exchange of the messages
! client/server model
" client: browser that
requests, receives,
displays Web objects
" server: Web server sends
objects in response to
requests
PC running
Explorer
Server (running Apache Web Server or
Microsoft Internet Information Server):
Implement the server side of HTTP
House Web objects, each addressable by a URL

Mac running
Navigator
HTTP 1.0: RFC 1945
HTTP 1.1: RFC 2068
2: Application Layer 26
HTTP overview (continued)
Uses TCP as underlying
transport protocol:
! client initiates TCP
connection (creates socket)
to server, port 80
! 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
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
reconciled
aside
2: Application Layer 27
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
Client-server interaction is
taking place over TCP
! Series of requests made back-to-
back, periodically at regular
intervals, or intermittently
Q: should each request/response pair
be sent over separate TCP connection
or all over the same TCP
connection?
2: Application Layer 28
Nonpersistent HTTP
Suppose user enters URL www.someSchool.edu/
someDepartment/home.index
1a. HTTP client initiates TCP
connection to HTTP server
(process) at
www.someSchool.edu on port 80
2. HTTP client sends HTTP
request message (containing
URL) into TCP connection
socket. Message indicates
that client wants object
someDepartment/home.index
1b. HTTP server at host
www.someSchool.edu 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
time
(contains HTML file,
references to 10
jpeg images)
2: Application Layer 29
Nonpersistent HTTP (cont.)
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
4. HTTP server closes TCP
connection.
time
Q: 10 JPEG objects obtained
over 10 serial TCP
connections, or over parallel
TCP connections?
" Most browsers open 5-10
parallel connections
2: Application Layer 30
Non-Persistent HTTP: Response time
Definition of RTT: time to send
a small packet to travel from
client to server and back.
" Propagation delay, queuing
delay, packet-processing delays
Response time:
! one RTT to initiate TCP
connection
! one RTT for HTTP request
and first few bytes of HTTP
response to return
! file transmission time
total = 2RTT+transmit time of
the requested file

time to
transmit
file
initiate TCP
connection
RTT
request
File + ack
RTT
entire file
received
time
time
2: Application Layer 31
Persistent HTTP
Nonpersistent HTTP issues:
! requires 2 RTTs per object
! OS overhead for each TCP connection: TCP buffer
allocated and TCP variables kept in both client and server
! browsers often open parallel TCP connections to fetch
referenced objects

Persistent HTTP
! server leaves connection open after sending response
! subsequent HTTP messages between same client/server
sent over open connection
2: Application Layer 32
Persistent HTTP
Nonpersistent HTTP issues:
! requires 2 RTTs per object
! OS overhead for each TCP
connection
! browsers often open parallel
TCP connections to fetch
referenced objects
Persistent HTTP
! server leaves connection
open after sending response
! subsequent HTTP messages
between same client/server
sent over open connection
Persistent without pipelining:
! client issues new request
only when previous
response has been received
! one RTT for each
referenced object
Persistent with pipelining:
! default in HTTP/1.1
! client sends requests as
soon as it encounters a
referenced object
! as little as one RTT for all
the referenced objects
2: Application Layer 33
HTTP request message
! two types of HTTP messages: request, response
! HTTP request message:
" ASCII (human-readable format)
GET /somedir/page.html HTTP/1.1
Host: www.someschool.edu
User-agent: Mozilla/4.0
Connection: close
Accept-language:fr

(extra carriage return, line feed)
request line
(Method: GET, POST,
HEAD commands)
header
lines
Carriage return,
line feed
indicates end
of message
doesnt want
persistent connections
Can send different versions
to diff. types of agents
2: Application Layer 34
HTTP request message: general format
Request line
GET: requests an object; POST: uploads a form,e.g., when a user
provides search words to a search engine
HEAD: as GET but no requested object in response, for debug
2: Application Layer 35
Method types
HTTP/1.0
! GET
! POST
! HEAD
" asks server to leave
requested object out of
response
HTTP/1.1
! GET, POST, HEAD
! PUT
" uploads file in entity body
to a specific path on a
specific Web server
(specified in URL field)
! DELETE
" deletes file on a Web
server (specified in the
URL field)
2: Application Layer 36
HTTP response message
HTTP/1.1 200 OK
Connection close
Date: Thu, 06 Aug 1998 12:00:15 GMT
Server: Apache/1.3.0 (Unix)
Last-Modified: Mon, 22 Jun 1998 ...
Content-Length: 6821
Content-Type: text/html

data data data data data ...
status line
(protocol,
status code,
status phrase)
header
lines
Entity body:
data, e.g.,
requested
HTML file
2: Application Layer 37
HTTP response status codes
200 OK
" request succeeded, requested object later in this message
301 Moved Permanently
" requested object moved, new URL is specified in Location:
header of the response message. The client software will
automatically retrieve the new URL
400 Bad Request
" request message not understood by server
404 Not Found
" requested document not found on this server
505 HTTP Version Not Supported
In first line in server->client response message.
" Indicate the result of a request
A few sample codes:
2: Application Layer 38
User-Server Interaction:
Cookies
! Stateless HTTP server is simple with high
performance, but it is often desirable for a
Web site to identify users
" To restrict user access
" To serve content as a function of the user
identity
! Defined in RFC 2965
" Allow sites to keep track of users
2: Application Layer 39
User-server state: cookies
Many major Web sites
use cookies
Four components:
1) cookie header line of
HTTP response message
2) cookie header line in
HTTP request message
3) cookie file kept on
users host, managed by
users browser
4) back-end database at
Web site
Example:
! Susan always access
Internet always from PC
! visits specific e-
commerce site for first
time
! when initial HTTP
requests arrives at site,
site creates:
" unique ID
" entry in backend
database for ID
2: Application Layer 40
Cookies: keeping state (cont.)
client
server
usual http response msg
usual http response msg
cookie file
one week later:
usual http request msg
cookie: 1678
cookie-
specific
action
access
ebay 8734
usual http request msg
Amazon server
creates ID
1678 for user
create
entry
usual http response
Set-cookie: 1678
ebay 8734
amazon 1678
usual http request msg
cookie: 1678
cookie-
spectific
action
access
ebay 8734
amazon 1678
backend
database
2: Application Layer 41
Cookies (continued)
What cookies can bring:
! authorization
! shopping carts
! recommendations
! user session state
(Web e-mail)
Cookies and privacy:
! cookies permit sites to
learn a lot about you
! you may supply name
and e-mail to sites
aside
How to keep state:
! protocol endpoints: maintain state
at sender/receiver over multiple
transactions
! cookies: http messages carry state
2: Application Layer 42
Web caches (proxy server)
! Network entity
" Has its own disk storage,
keeps copies of recently
requested objects
! 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 over the existing
TCP connection
Goal: satisfy client request without involving origin server

client
Proxy
server
client
origin
server
origin
server
2: Application Layer 43
Benefit of Caches: an example
Assumptions
! average object size = 1Mbits
! avg. request rate from institutions browsers
to origin servers = 15/sec
! delay from router on the Internet side of
access link to any origin server and back to
router (Internet delay) = 2 sec
! total delay = Internet delay + access delay
(delay between two routers) + LAN delay
Consequences
! traffic intensity on the LAN = (15req/
sec*1Mbits/req)/100Mbps = 0.15 (tens of
millisecond)
! traffic intensity on access link = (15req/
sec*1Mbits/req)/15Mbps = 1 (very large and
grows without bound)
! avg: the order of minutes)
! total delay = Internet delay + access delay +
LAN delay
= 2 sec + minutes + milliseconds
origin
servers
public
Internet
institutional
network
100Mbps LAN
15 Mbps
access link
2: Application Layer 44
Caching example (cont)
possible solution
! increase bandwidth of access
link to, say, from 15Mbps to
100 Mbps
consequence
! traffic intensity (utilization) on
LAN = 0.15
! traffic intensity on access link =
0.15
! Total delay = Internet delay +
access delay + LAN delay
= 2 sec + msecs + msecs
! often a costly upgrade
origin
servers
public
Internet
institutional
network
100 Mbps LAN
15->100 Mbps
access link
2: Application Layer 45
More about Web caching
! cache acts as both
client and server
! typically cache is
installed by ISP
(university, company,
residential ISP)
Why Web caching?
2: Application Layer 46
Caching example (cont)
possible solution: install
cache
! suppose hit rate is 0.4

consequence
! 40% requests will be satisfied
almost immediately
! 60% requests satisfied by origin
server
" traffic intensity reduced from 1 to
0.6, delay is about tens of ms
! utilization of access link reduced
to 60%, resulting in negligible
delays (say 10 of msec)
! total avg delay = Internet delay
+ access delay + LAN delay =
0.6*(2.01) secs +
0.4*(0.01)seconds =~ 1.2 secs
" Lower response time than the
upgrade solution
" Save cost
origin
servers
public
Internet
institutional
network
100 Mbps LAN
15 Mbps
access link
institutional
cache
2: Application Layer 47
Why Web caching?
! reduce response time for client request
! reduce traffic on an institutions access link to the
Internet
" The institution does not have to upgrade bandwidth as
quickly
! reduce Web traffic in the Internet as a whole: enables
poor content providers to effectively deliver content

Das könnte Ihnen auch gefallen