Upload
anne-miles
View
219
Download
2
Tags:
Embed Size (px)
Citation preview
1-1
1DT066Distributed Information Systems
Chapter 2Applications
2-2
Applications: outline
2.1 principles of network applications
2.2 Web and HTTP2.5 Domain Name
Server2.6 P2P applications
Adapted from: Computer Networking, Kurose/Ross
2-3
Some network apps e-mail web text messaging remote login P2P file sharing multi-user network
games streaming stored
video (YouTube, Hulu, Netflix)
voice over IP (e.g., Skype)
real-time video conferencing
social networking search … …
Adapted from: Computer Networking, Kurose/Ross
write programs that: run on (different) end
systems communicate over
networks e.g., web server software
communicates with browser software
no need to write software for network-core devices
network-core devices do not run user applications
applications on end systems allows for rapid app development, propagation
2-4
Creating a network appapplication
transportnetworkdata linkphysical
application
transportnetworkdata linkphysical
application
transportnetworkdata linkphysical
Adapted from: Computer Networking, Kurose/Ross, pp 109-110
Main reason for the
success of Internet
2-5
App processes communicatingprocess: runs a
program within a host Operating System, OS.
within same host, two processes communicate using inter-process communication (defined by OS)
Processes on different hosts communicate by exchanging messages
client process: process that initiates communication
server process: process that waits to be contacted
clients, servers
Adapted from: Computer Networking, Kurose/Ross, pp 114-115
2-6
Addressing processes
host machine/device has unique 32-bit IP address
to receive messages, process must have identifier that is known to the sender
Q: Why is not the IP address enough for identifying the process?
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
A: no, many processes can be running on same host
Adapted from: Computer Networking, Kurose/Ross, pp 116
2-7
Application architectures
Two dominating architecture/structures of applications:
client-server peer-to-peer (P2P)
Adapted from: Computer Networking, Kurose/Ross, pp 112-113
2-8
Client-server architectureserver: always-on host permanent IP address (i.e. “ I
know where you are”) often at a data center for scaling
capacity with demand
client: initiates the contact and
communicates with server may be intermittently connected may have dynamic IP addresses.
(Why not permanent?) clients do not communicate
directly with each other
client/server
Adapted from: Computer Networking, Kurose/Ross, pp 112-113
2-9
P2P architecture end systems (called
peers) communicate directly
peers request service from other peers and provide services in return to the others self scalability – new
peers bring new service capacity, (as well as new service demands)
not always-on server. May be switched off and may change IP addresses complex management.
Why?
peer-peer
Adapted from: Computer Networking, Kurose/Ross, pp 112-113
2-10
App-layer protocol defines types of messages
exchanged, e.g., request, response
message syntax: different fields in
messages, e.g. for application data and control information to other party
message semantics meaning of information in
control fields (not app data)
rules for when and how processes send & respond to messages
“open”/standard protocols:
defined in RFCs allows for
interoperability e.g., HTTP, SMTP“closed”/proprietary
protocols: e.g., Skype
Adapted from: Computer Networking, Kurose/Ross, pp 117-122
2-11
What transport service does an app need?data integrity (i.e. no lost or
modified data) some apps (e.g., file
transfer, web transactions) require 100% reliable data transfer
other apps (e.g., audio) can tolerate some loss
timing some apps (e.g.,
Internet telephony, interactive games) require low delay to be “effective”
throughput some apps (e.g.,
multimedia) require minimum amount of throughput to be “effective”
other apps (“elastic apps”) make use of whatever throughput they get
security encryption, data
integrity, …
Adapted from: Computer Networking, Kurose/Ross, pp 117-122
2-12
Transport service requirements: common apps
data loss
no lossno lossno lossloss-tolerant
loss-tolerantloss-tolerantno loss
throughput
elasticelasticelasticaudio: 5kbps-1Mbpsvideo:10kbps-5Mbpssame as above few kbps upelastic
time sensitive
nononoyes, 100’s msec
yes, few secsyes, 100’s msecyes and no
Adapted from: Computer Networking, Kurose/Ross, pp 117-122
2-13
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 a 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
Adapted from: Computer Networking, Kurose/Ross, pp 122-125
Universal
Resource
Locator
2-14
HTTP overview
HTTP: hypertext transfer protocol
Web’s application layer protocol
client/server model client: browser that
requests, receives, (using HTTP protocol) and “displays” Web objects
server: Web server sends (using HTTP protocol) objects in response to requests
PC runningFirefox browser
server running
Apache Webserver
iphone runningSafari browser
HTTP requestHTTP response
HTTP request
HTTP resp
onse
Adapted from: Computer Networking, Kurose/Ross, 126-129
Application Layer 2-15
HTTP overview (continued)
Uses Internets (reliable) transport protocol, TCP:
client initiates TCP connection to web server process, usually port 80.
server accepts TCP connection from client
HTTP messages are exchanged between browser (HTTP client) and Web server (HTTP server)
TCP connection closed
HTTP is “stateless” HTTP protocol at server
do not maintain any information about previous requests from client
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.
Why inconsistent?
aside
Adapted from: Computer Networking, Kurose/Ross, pp 126-129
2-16
HTTP request message
two fundamental types of HTTP messages: request, response
Format of a HTTP request message: Uses ASCII (human-readable format)
request line(GET, POST, HEAD commands)
header lines
carriage return, line feed at startof line indicatesend of header lines
GET /index.html HTTP/1.1\r\nHost: www-net.cs.umass.edu\r\nUser-Agent: Firefox/3.6.10\r\nAccept: text/html,application/xhtml+xml\r\nAccept-Language: en-us,en;q=0.5\r\nAccept-Encoding: gzip,deflate\r\nAccept-Charset: ISO-8859-1,utf-8;q=0.7\r\nKeep-Alive: 115\r\nConnection: keep-alive\r\n\r\n
carriage return character
line-feed character
Adapted from: Computer Networking, Kurose/Ross pp 126-129
2-17
HTTP request message: general format
requestline
headerlines
Body == data
method sp sp cr lfversionURL
cr lfvalueheader field name
cr lfvalueheader field name
~~ ~~
cr lf
entity body~~ ~~
Adapted from: Computer Networking, Kurose/Ross, pp 130-131
2-18
HTTP response message
status line(protocolstatus codestatus phrase)
header lines
data, e.g., requestedHTML file
HTTP/1.1 200 OK\r\nDate: Sun, 26 Sep 2010 20:09:20 GMT\r\nServer: Apache/2.0.52 (CentOS)\r\nLast-Modified: Tue, 30 Oct 2007 17:00:02
GMT\r\nETag: "17dc6-a5c-bf716880"\r\nAccept-Ranges: bytes\r\nContent-Length: 2652\r\nKeep-Alive: timeout=10, max=100\r\nConnection: Keep-Alive\r\nContent-Type: text/html; charset=ISO-8859-1\
r\n\r\ndata data data data data ...
Adapted from: Computer Networking, Kurose/Ross, pp 131-134
2-19
HTTP response status 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
status code appears in 1st line in server-to-client response message.
some sample codes:
Adapted from: Computer Networking, Kurose/Ross, pp 131-134
2-20
Trying out HTTP (client side) for yourself1. Telnet to your favorite Web server:
opens TCP connection to port 80(default HTTP server port) at cis.poly.edu.anything typed in sent to port 80 at cis.poly.edu
telnet cis.poly.edu 80
2. type in a GET HTTP request:
GET /~ross/ HTTP/1.1Host: cis.poly.edu
by typing this in (hit carriagereturn twice), you sendthis minimal (but complete) GET request to HTTP server
3. look at response message sent by HTTP server!
(or use Wireshark to look at captured HTTP request/response)Adapted from: Computer Networking, Kurose/Ross, pp 131-134
2-21
Cookies: keeping “state” between requests
client Amazonserver
usual http response msg
usual http response msg
cookie file
one week later:
usual http request msg
cookie: 1678cookie-specificaction
access
ebay 8734usual http request
msgAmazon server
creates ID1678 for user create
entry
usual http response
set-cookie: 1678
ebay 8734amazon 1678
usual http request msg
cookie: 1678cookie-specificaction
access
ebay 8734amazon 1678
backenddatabase
Adapted from: Computer Networking, Kurose/Ross, pp 134-136
2-22
Cookies (continued)what cookies can
be used for: 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
Adapted from: Computer Networking, Kurose/Ross, pp 134-136
2-23
DNS: domain name system
Q: how to map between IP address and host name, and vice versa ?
Internet hosts, routers: IP address (32 bit)
- used for addressing datagrams
“name”, e.g., www.yahoo.com - used by humans
Domain Name System: application-layer protocol:
hosts, name servers communicate to resolve names (address/name translation) Note: This is a core
Internet function, implemented as application-layer protocol
Again - complexity at network’s “edge”
distributed database implemented in hierarchy of many name servers
Adapted from: Computer Networking, Kurose/Ross, pp 156-158
2-24
DNS: services, structure It doesn’t scale? single point of failure traffic volume distant centralized
database, long delay. maintenance
DNS services hostname to IP address
translation – demo! host aliasing
canonical, alias names mail server aliasing load distribution
replicated Web servers: many IP addresses correspond to one name. Why and when?
why not centralize DNS
Adapted from: Computer Networking, Kurose/Ross, pp 156-159
2-25
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
DNS: a distributed, hierarchical database
client wants IP for www.amazon.com; 1st approx: client queries Root DNS server, to get .com server client queries .com DNS server to get the amazon.com
DNS server client queries amazon.com DNS server to get IP
address for www.amazon.com
… …
Adapted from: Computer Networking, Kurose/Ross, pp 156-158
2-26
requesting hostcis.poly.edu
gaia.cs.umass.edu
root DNS server
local DNS serverdns.poly.edu
1
23
4
5
6
authoritative DNS serverdns.cs.umass.edu
78
TLD DNS server
DNS name resolution bottom up example
host at cis.poly.edu wants IP address for gaia.cs.umass.edu
iterated query: contacted server
replies with name of server to contact
“I don’t know this name, but ask this server”
Adapted from: Computer Networking, Kurose/Ross, pp 160-163
2-27
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
Adapted from: Computer Networking, Kurose/Ross, pp 162-163
2-28
DNS: caching, updating records once (any) name server learns mapping,
it caches mapping cache entries timeout (disappear) after some
time (TTL) 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
Adapted from: Computer Networking, Kurose/Ross, pp 162-163
2-29
Pure P2P architecture no always-on server arbitrary end systems
communicate directly peers are
intermittently connected and may change IP addresses. Still participating.
examples: file distribution
(BitTorrent) Streaming (Spotify) VoIP (Skype)
Adapted from: Computer Networking, Kurose/Ross, pp 170-174
2-30
File distribution time: client-server server transmission: must
sequentially send (upload) N file copies: time to send one copy: F/us
time to send N copies: NF/us
increases linearly in N
time to distribute F to N clients using
client-server approach Dc-s > max{NF/us,,F/dmin}
client: each client must download file copy dmin = min client download
rate min client download time:
F/dmin
us
network
di
ui
F
Adapted from: Computer Networking, Kurose/Ross, pp 170-174
2-31
File distribution time: P2P server transmission:
must upload at least one copy time to send one copy:
F/us
time to distribute F to N clients using
P2P approach
us
network
di
ui
F
DP2P > max{F/us,,F/dmin,,NF/(us + ui)}
client: each client must download file copy min client download time:
F/dmin clients: as aggregate must download NF bits max upload rate (limting max download
rate) is us + ui
… but so does this, as each peer brings service capacityincreases linearly in N …
Adapted from: Computer Networking, Kurose/Ross, pp 170-174