Application Layer 8-1 Chapter 2: Application Layer Our goals: r conceptual / implementation aspects...
-
date post
22-Dec-2015 -
Category
Documents
-
view
215 -
download
0
Transcript of Application Layer 8-1 Chapter 2: Application Layer Our goals: r conceptual / implementation aspects...
Application Layer 8-1
Chapter 2: Application LayerOur goals: conceptual /
implementation aspects of network application protocols transport-layer
service models client-server
paradigm peer-to-peer
paradigm
learn about application-layer protocols by looking at examples: HTTP (web) FTP (file
transfer) DNS (web
addressing)
interface to transport layer the socket concept
Application Layer 8-2
Creating network applications
Write programs that run on different end systems
and communicate over a
network. e.g., Web: Web server
software communicates with browser software
No app. software written for devices in network core Network core devices do not
function at application layer This design allows for rapid
app development
application
transportnetworkdata linkphysical
application
transportnetworkdata linkphysical
application
transportnetworkdata linkphysical
Application Layer 8-3
App-layer protocol defines Types of messages
exchanged, e.g. request & response messages
Syntax of message types: what fields in messages & where fields are located
Semantics of the fields, i.e. meaning of information in fields
Rules for when and how processes send & respond to messages
2TYPES OF PROTOCOLS: Public-domain protocols: defined in RFCs enable interoperability eg: HTTP, SMTP, SIP
Proprietary protocols: owned by a company eg: Skype, Messenger
Application Layer 8-4
Client / Server concepts
Hardware view Process / interaction view Client-Server architecture Peer-to-Peer architecture
Application Layer 8-5
Client Hosts /Server Hosts
server host : always-on host permanent IP address server farms for scaling
client host (=workstation): located next to user may be intermittently
connected may have dynamic IP
addressNote: Both client and server are called hosts
Application Layer 8-6
Process: program running within a host.
processes in different hosts communicate by exchanging messages
when processes cooperate for a common purpose, there must be one of them that initiates the common work Sends the first message
Client process: process that initiates communication
Server process: process that waits to be contacted by client
Note: Client process may run on a client host or on a server
host Server process may run on a client host (see Peer to
Peer architecture)
Client Process/Server Process
Application Layer 8-7
Process Interaction Scenarioserver process:
waits all the time for work its IP address must be
known to the client process before interaction starts
client process: initiates interaction with
server process when needs its help
if server process agrees : the two processes
exchange messages the messages enable
them to cooperate to get the work done
Note: Server host usually runs several server processes in
parallel
Client process 1
Client process 2
Server proc. 1Server proc. 2
Application Layer 8-8
Client-Server architectureserver process:
runs on server host only the server host’s IP
address is publicly known
client process: runs in most cases on
client host (personal computers)
in some applications, client process may run on a server computer
• e,g, in e-mail application, the mail server may run a mail client process
Application Layer 8-9
Peer to Peer (P2P) architecture
most of the data in such application exchanged between client hosts
one of the client hosts (say A) must initiate the interaction with the other one (say B). Thus: A runs a client process B runs a server process
• note: B is a client host In order to start, A must know B’s
IP address, which is usually not publicly advertised. therefore P2P interaction is
usually preceded by a preliminary stage which uses the Client-Server (C-S) architecture
datainitializatio
n
C-S
C-SP2P
P2P
Application Layer 8-10
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) require 100% reliable data transfer
Timing some apps (e.g.,
Internet telephony, interactive games) require low delay or low delay variation 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
Application Layer 8-11
Transport service requirements of common apps
Application
file transfere-mail
Web documentsreal-time audio/video
stored audio/videointeractive gamesinstant messaging
Data loss
no lossno lossno lossloss-tolerant
loss-tolerantloss-tolerantno loss
Bandwidth
elasticelasticelasticaudio: 5kbps-1Mbpsvideo:10kbps-5Mbpssame as above few kbps upelastic
Time Sensitive
nononoyes, 100’s msec
yes, a few secsyes, 100’s msecyes and no
Application Layer 8-12
Web and HTTP
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
Application Layer 8-13
HTTP overviewHTTP: hypertext
transfer protocol Web’s application layer
protocol client/server model
client : browser that requests, receives and “displays” Web objects
server : Web server that sends objects in response to requests
HTTP 1.0 : RFC 1945 HTTP 1.1 : RFC 2616
PC runningExplorer
Server running
Apache Webserver
Mac runningNavigator
HTTP request
HTTP request
HTTP response
HTTP response
Note: Different H/W and S/W use the same protocol
Application Layer 8-14
HTTP overview (continued)HTTP uses TCP: client initiates TCP
connection (creates socket) to server port 80 (WKP)
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” HTTP keeps
no information about past client requests BUT, cookies allow
Web server to run stateful applications
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
Application Layer 8-15
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
Application Layer 8-16
Nonpersistent HTTPSuppose user enters URL of a page :
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
(page contains text and references to10 jpeg images)
Client Server
www.someSchool.edu/someDepartment/home.index
time
Application Layer 8-17
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. after sending the object, HTTP server closes TCP connection.
time
requestfile
RTT
time time
Application Layer 8-18
Response time modelingDefinition of RTT: time to
send a small packet to travel from client to server and back.
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 = 2 RTT + transmit time
initiate TCPconnection
RTT
filereceived
time to transmit file
Application Layer 8-19
Persistent HTTPNonpersistent HTTP issues: 2 RTT overhead per object
Extra Delay OS must work and allocate
host resources 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 are sent over same connection
Persistent without pipelining: client issues new request
only when previous response has been received
one RTT overhead for each referenced object
Qn: What time is saved?Persistent with pipelining: default in HTTP/1.1 client sends requests as
soon as it encounters a referenced object
only one RTT for all the referenced objects
Qn: Can you see an advantage of Persistent?
Application Layer 8-20
HTTP request message
two types of HTTP messages: request, response both use ASCII format (human-readable format)
HTTP request message (example):GET /somedir/page.html HTTP/1.1Host: www.someschool.edu User-agent: Mozilla/4.0Connection: close Accept-language:fr
(extra carriage return, line feed)
request line(GET, POST,
HEAD commands)
header lines
Carriage return, line feed
indicates end of message
Application Layer 8-21
HTTP request message: general format
(Optional)
Application Layer 8-22
Uploading form input
Using the POST method: Input is uploaded to
server in entity body of the POST message
Using GET with parameters: Uses GET method Input is uploaded as part
of the URL field of request line:
www.somesite.com/animalsearch?monkeys&banana
Web page often includes form input
The input can be uploaded to the server in two ways:
Application Layer 8-23
Methods
HTTP/1.0 GET POST HEAD
asks server to leave requested object out of response
Sends only header fields
Used for debugging
HTTP/1.1 GET, POST, HEAD PUT
uploads file in the entity body to the path specified in URL field
DELETE deletes file specified
in the URL field
Application Layer 8-24
HTTP response message
HTTP/1.1 200 OK Date: Thu, 06 Aug 1998 12:00:15 GMT Server: Apache/1.3.0 (Unix) Last-Modified: Mon, 22 Jun 1998 …... Content-Length: 6821Connection: close Content-Type: text/html data data data data data ...
status line
header lines
message body*
cr-lf
(Closing TCP connection after data transmitted)
status phraseprotocol status code
* message body = data e.g., requested HTML file
Application Layer 8-25
HTTP response status 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
In first line of the response message.A few examples of status codes:
Application Layer 8-26
User-server state: cookiesMany major Web sites use cookies
Four components:1) the HTTP server sends
response message with a ‘Set-Cookie:’ header
2) user’s browser puts the cookie header content in cookie file on user’s host, labeled with server name
3) next request message to this server will contain Cookie: header with the same value
4) cookie points to database record at server site
Example: Susan accesses
Internet always from same PC
She visits a specific e-commerce site for first time
When initial HTTP requests arrives at site, site creates a unique ID and an entry in backend database for that ID
The ID is the cookie between them
Application Layer 8-27
Cookies: keeping “state” (cont.)
client server
http request to ebay
usual http response +
Set-cookie: 1678
next http request +cookie: 1678
usual http response msg
http request to ebay +
cookie: 1678usual http response msg
cookie-specificaction
cookie-specificaction
servercreates ID
1678 for user
entry in backend
database
access
acce
ss
Cookie file
ebay : 1678
amazon : 8734
Cookie file
amazon : 8734
Cookie file
ebay : 1678amazon : 8734
one week later:
Application Layer 8-28
Cookies (continued)
What cookies can bring:
user session state (e.g. in Web e-mail)
user identification on given workstation
shopping carts recommendations
Cookies and privacy: cookies permit sites
to learn a lot about you
you may supply name and e-mail to sites
advertising companies obtain info across sites from inserted banner addso info collected by
the advertizing server
aside
Application Layer 8-29
Web cache (proxy server)
user sets up browser to access Web via proxy
browser sends all HTTP requests to proxy IF object in the
proxy’s cache: proxy returns object
ELSE proxy requests object from origin server, then returns object to client
keeps file in its cache
Goal: satisfy client request without involving origin server
client
ProxyServer
(web cache)
client
HTTP request
HTTP request
HTTP response
HTTP response
HTTP request
HTTP response
origin server
origin server
Application Layer 8-30
More about Web caching proxy acts as HTTP
client and server Typically proxy is
installed by ISP (Organization, ISP)
Caching advantages Reduce response time for
client request. Reduce traffic on an
institution’s access link. Internet dense with
proxies enables “poor” content providers to effectively deliver content
Qn :what is the main problem with caching as described?
Caching rules Origin server may :
forbid caching allow caching by private
cache only (privacy) Origin server sends:
Last Modified date/time Expiration time or Max. Age
Proxy should respect age and other restrictions
Application Layer 8-31
Conditional GET Goal: don’t send object if
proxy has up-to-date cached version used if cacheability
conditions or data are missing
proxy specifies date of cached copy in HTTP request header:
server sends short response if cached copyis up-to-date:
(see Case 1 on this slide)
HTTP/1.0 304 Not Modified(contains no object)
If-modified-since: <date>
proxy server
HTTP request msgIf-modified-since:
<date>
HTTP responseHTTP/1.0
304 Not Modified
object not
modified
Case 1
HTTP request msgIf-modified-since:
<date>
HTTP responseHTTP/1.0 200 OK
<data>
object modified
proxy serverCase 2
Application Layer 8-32
FTP: the file transfer protocol (RFC 959)
transfer file to/from remote host remote management of a file system
client/server model client (user’s workstation) initiates the connection server (file server) responds to client’s commands
• mainly files transfers to or from client ftp Well Known Port for control traffic : 21 ftp Well Known Port for data traffic : 20
file transfer FTPserver
FTPuser
interface
FTPclient
local filesystem
remote filesystem
user at host
Application Layer 8-33
FTP: separate control, data connections
FTP client contacts FTP server by TCP at port 21, sets up control connection
client obtains authorization over control connection
client browses remote directory by sending commands over control connection.
before a file transfer, client asks server to open a data-connection to a client port N (from server port 20)
client sends command:RETR or STOR (see next slide)
After sending/receiving one file, data connection is closed
FTPclient
FTPserver
TCP control connection, server
port 21
TCP data connection,server port 20
Server opens a second TCP data connection to transfer another file.
Control connection: “out of band”
FTP server maintains “state” throughout the session: current directory, authentication state
Application Layer 8-34
FTP commands, responsesSample commands:(sent as ASCII text over control
channel) USER username PASS password LIST - list the files in
current directory CWD – change working dir. PORT N – set up data
connect. to my port N RETR <filename> -
download a file from server to client
STOR <filename> - upload a file from client to server
Sample return codes(status code and phrase:
same as in HTTP) 331 Username OK,
password required 125 data connection
already open; transfer starting
425 Can’t open data connection
452 Error writing file
226 File transfer OK, closing connectionNote:in Windows FTP user
writes GET for RETR PUT for STOR
Application Layer 8-35
DNS: Domain Name System
People: many identifiers: SSN, name, passport
#Internet hosts, routers:
IP address (32 bit) - used for addressing datagrams (packets) – good for routers
“name”, e.g., www.yahoo.com – good for human use
Q: map between name and IP addresses ?
Domain Name System:1. distributed name database
implemented in hierarchy of many name servers
2. application-layer protocol host, routers, name servers communicate to resolve names (name-to-address translation) (WKP: UDP 53) Note: Internet
infrastructure (תשתית) function, implemented as application-layer protocol
all the work at network’s “edge”, not in the core
Application Layer 8-36
DNS
Why not centralize DNS? single point of failure traffic volume distant centralized
database maintenance difficult doesn’t scale!
DNS services Hostname to IP
address translation Host aliasing
canonical name = main name of computer
alias = additional name
Finding server names e.g hostname of mail
server for domain
Load distribution Replicated Web servers:
set of IP addresses for one canonical name
Application Layer 8-37
Root DNS Servers (*)
com DNS servers org DNS servers edu DNS servers
poly.eduDNS servers
umass.eduDNS servers
yahoo.comDNS servers
amazon.comDNS servers
pbs.orgDNS servers
Distributed, Hierarchical Database
Client (NS) wants IP address for www.amazon.com : Client queries a root server to find com DNS server Client queries com DNS server to get amazon.com DNS
(name-) server (by sending message to UDP port 53) Client queries amazon.com DNS server to get IP address for
www.amazon.com
(*) There are 13 root servers world-wide; their addresses are known to all name servers
Application Layer 8-38
TLD, Authoritative Servers, Zones
Top-level domain (TLD) servers: responsible for com, org, net, edu, etc, and all top-level country domains uk, fr, ca, jp, il Network Solutions maintains servers for com TLD Educause does the same for edu TLD
Authoritative DNS server: organization’s DNS server, providing authoritative hostname to IP mappings for organization’s servers It is responsible for a “zone” (or several zones) Zone = Domain – { subdomains that have their own zones }
Example: ns.tau.ac.il zone includes all natural science faculty except dep”ts
that have their own zones (e.g. cs.ns.tau.ac.il & math.ns,tau.ac.il )
Application Layer 8-39
Resolver and Local Name Server
Each host has a Resolver = Host software dealing with DNS
Each ISP (residential ISP, company, university) has a “Local name server” Also called “default name server”
When application needs to translate a DNS name, it calls the resolver on its computer
Resolver sends a DNS query to its local name server (LNS)
LNS finds the answer in its cache or by querying other name servers and sends answer to Resolver
Resolver supplies answer to the application
Application Layer 8-40
gaia.cs.umass.edu
authoritative DNS serverdns.cs.umass.edu
resolver atcis.poly.edu
root DNS server
local DNS serverdns.poly.edu
1
23
4
5
678
TLD DNS server
DNS operation modes Name server can
operate in two modes: iterative recursive (next slide)
iterated query contacted server replies
with name of server to contact
“I don’t know this name, but ask this server”
the example on this slide shows LNS querying several iterative NS’s
Example: Host at cis.poly.edu wants IP address for gaia.cs.umass.edu
Application Layer 8-41
requesting hostcis.poly.edu
gaia.cs.umass.edu
root DNS server
local DNS serverdns.poly.edu
1
2
45
6
authoritative DNS serverdns.cs.umass.edu
7
8
TLD DNS server
3
Recursive queriesrecursive query: contacted server asks
other NS’s the same query and returns final answer to the originator of query
puts burden of name resolution on contacted name server
a query may also involve mix of the two modes.
Note: root name servers are usually iterative
Example: same example with all NS’s operating in recursive mode
Application Layer 8-42
DNS: caching and mirroring once (any) name server learns mapping, it
caches mapping cache entries timeout (disappear) after
some time (each response includes a TTL) TLD servers typically cached in all local
name servers• Thus root name servers less often visited
Usually zone database is duplicated on several authoritative name servers (mirroring) the main one is updated by the administrator by a file the others copy the zone from the main one main NS notifies the others when update available
Application Layer 8-43
DNS records
DNS: distributed db storing resource records (RR)
Type=NS name is domain (e.g.
foo.com) value is IP address of
authoritative name server for this domain
RR format: (name, value, type, ttl)
Type=Aname is hostnamevalue is IP address
Type=CNAMEname is alias name for
some “canonical” (the real) name
www.ibm.com is really servereast.backup2.ibm.com
value is canonical name Type=MX name is domain, e.g.
gmail.com value is hostname of mail
server