Upload
others
View
8
Download
0
Embed Size (px)
Citation preview
Chapter 2Application Layer
Computer Networking: A Top Down Approach, 4th edition. Jim Kurose, Keith RossAddison-Wesley, July 2007.
A note on the use of these ppt slides:The notes used in this course are substantially based on powerpoint slides developed and copyrighted by J.F. Kurose and K.W. Ross, 2007
2: Application Layer 1
Chapter 2: Application Layer
2.1 Principles of network applications2.2 Web and HTTP2.3 FTP 2.4 Electronic Mail
SMTP, POP3, IMAP
2.5 DNS
2.6 P2P file sharing2.7 Socket programming with TCP2.8 Socket programming with UDP2.9 Building a Web server
2: Application Layer 2
Application Architectures
Client‐server
Peer‐to‐peer (P2P)
Hybrid of client‐server and P2P
2: Application Layer 3
clientclient
client
Processes CommunicatingProcess: program running within a host.Within same host, two processes communicate using inter‐process communication (defined by OS)Processes in different
Client process: process that initiates communication
Server process: process that waits to be contacted
Note: applications with P2P architectures have client processes & server processes
hosts communicate by exchanging messages
2: Application Layer 4
Addressing Processes
Identifier includes both IP address and port numbersassociated with process on hostExample port numbers:
HTTP server: 80Mail server: 25
To send HTTP message to www.cs.ust.hk web server:
IP address: 143.89.40.4Port number: 80
To receive messages, process must have identifierHost device has unique 32‐bit IP addressQ: does IP address of host on which process runs suffice for identifying the process?Answer: NO, many processes can be running on same host
2: Application Layer 5
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 RFCsAllows for interoperabilitye.g., HTTP, SMTP
Proprietary protocols:e.g., KaZaA
2: Application Layer 6
What Transport Service does an App Need?
Data lossSome apps (e.g., audio, video) can tolerate some lossOther apps (e.g., file transfer, telnet) require 100% reliable data transfer
BandwidthSome apps (e.g., multimedia) require minimum amount of bandwidth to be “effective”Other apps (“elastic apps”) make use of whatever bandwidth they get (Best‐Efforts)
TimingSome apps (e.g., Internet telephony, interactive games) require low delay to be “effective”
2: Application Layer 7
Chapter 2: Application Layer
2.1 Principles of network applications
app architecturesapp requirements
2.2 Web and HTTP2.4 Electronic Mail
SMTP, POP3, IMAP
2.5 DNS
2.6 P2P file sharing2.7 Socket programming with TCP2.8 Socket programming with UDP
2: Application Layer 8
HTTP Overview
HTTP: hypertext transfer protocolWeb’s application layer protocolClient/server model
Client: browser that requests, receives, “displays”Web objectsServer:web server sends objects in response to requests
HTTP 1.0: RFC 1945HTTP 1.1: RFC 2068
HTTP request
HTTP request
HTTP response
HTTP response
PC runningExplorer
Server running
Apache Webserver
Mac runningNavigator
2: Application Layer 9
HTTP Overview (cont.)
HTTP is “stateless”Server maintains no
Uses TCP:Client initiates TCP connection (creates socket) to server, port 80Server accepts TCP connection from clientHTTP messages (application‐layer protocol messages) exchanged between browser (HTTP client) and Web server (HTTP server)TCP connection closed
information about past client requests
2: Application Layer 10
Protocols that maintain “state”are complex!Past history (state) must be maintainedIf server/client crashes, their views of “state” may be inconsistent, must be reconciled
aside
HTTP Connections
Nonpersistent HTTP Persistent HTTPAt most one object is sent over a TCP connectionEach TCP connection is closed after the server sends the objectHTTP/1.0 uses nonpersistent HTTP
Multiple objects can be sent over single TCP connection between client and serverHTTP/1.1 uses persistent connections in default mode
2: Application Layer 11
Persistent HTTP
Nonpersistent HTTP issues:Requires 2 RTTs per objectOS overhead for each TCP connectionBrowsers often open parallel TCP connections to fetch referenced objects
Persistent HTTPServer leaves connection open after sending responseSubsequent HTTP messages between same client/server sent over open connection
Persistent without pipelining:Client issues new request only when previous response has been receivedOne RTT for each referenced object
Persistent with pipelining:Default in HTTP/1.1Client sends requests as soon as it encounters a referenced objectAs little as one RTT for all the referenced objects
2: Application Layer 12
User-Server State: Cookies
Why need cookies?HTTP server is stateless
Simplify server design and handle thousands of simultaneous TCP connections
It is often desirable to identify usersRestrict user accessServe content as a function of the user identity
Cookies [RFC 2109]Allow sites to keep track of users
2: Application Layer 13
User-Server State: Cookies
Many major Web sites use cookies
Four components:
Example:Susan access Internet always from same PCShe visits a specific e‐commerce site for first timeWhen initial HTTP requests
1) Cookie header line of HTTP responsemessage
2) Cookie header line in HTTP requestmessage
3) Cookie file kept on user’s host, managed by user’s browser
4) Back‐end database at Web site
arrives at site, site creates a unique ID and creates an entry in backend database for ID
2: Application Layer 14
Cookies: Keeping “State” (cont.)
client serverusual http request msg
usual http response +Set-cookie: 1678
usual http request msgcookie: 1678
usual http response msg
usual http request msgcookie: 1678
usual http response msg
servercreates ID
1678 for user
Cookie file
ebay: 8734
entry in backend database
access
access
Cookie file
amazon: 1678ebay: 8734
cookie-specificaction
one week later:
Cookie file
amazon: 1678ebay: 8734
cookie-spectific
action
2: Application Layer 15
Cookies (continued)What cookies can bring:
AuthorizationShopping cartsRecommendationsUser session state (Web e‐mail)
162: Application Layer
Cookies and privacy:Cookies permit sites to learn a lot about youYou may supply name and e‐mail to sites
aside
How to keep “state”:Protocol endpoints: maintain state at sender/receiver over multiple transactionsCookies: http messages carry state
Web Caches (Proxy Server)
User sets browser: Web accesses via cacheBrowser sends all HTTP requests to cache
Object in cache: cache returns object Else cache requests object from origin server, then returns object to client
Goal: satisfy client request without involving origin server
client
Proxyserver
clientorigin server
origin server
HTTP request
HTTP request
HTTP response
HTTP response
HTTP request
HTTP response
2: Application Layer 17
More about Web Caching
Why Web caching?Cache acts as both client and serverTypically cache is installed by
Reduce response time for client request.Reduce traffic on an institution’s access link.Internet dense with caches:
ISP (university, company, residential ISP)
enables “poor” content providers to effectively deliver content (but so does P2P file sharing)
2: Application Layer 18
Conditional GET
Goal: don’t send object if cache has up‐to‐date cached versionCache: specify date of cached copy in HTTP requestIf-modified-since:
<date>
Server: response contains no object if cached copy is up‐to‐date: HTTP/1.0 304 Not
Modified
The copy of an object residing in the cache may be stale cache server
HTTP request msgIf-modified-since:
<date>
HTTP responseHTTP/1.0
304 Not Modified
object not
modified
HTTP request msgIf-modified-since:
<date>
HTTP responseHTTP/1.0 200 OK
<data>
object modified
2: Application Layer 19
Chapter 2: Application Layer
2.1 Principles of network applications2.2 Web and HTTP2.3 FTP2.4 Electronic Mail
SMTP, POP3, IMAP
2.5 DNS
2.6 P2P file sharing2.7 Socket programming with TCP2.8 Socket programming with UDP2.9 Building a Web server
2: Application Layer 20
FTP: the File Transfer Protocol
Transfer file to/from remote hostClient/server model
Client: side that initiates transfer (either to/from remote)Server: remote host
Ftp: RFC 959Ftp server: port 21
file transferFTP
serverFTPuser
interface
FTPclient
local filesystem
remote filesystem
user at host
2: Application Layer 21
FTP: Separate Control, Data Connections
FTP client contacts FTP server at port 21, specifying TCP as transport protocolClient obtains authorization over control connectionClient browses remote directory by sending commands over control connection.When server receives file transfer command, server opens 2nd TCP connection (for file) to clientAfter transferring one file, server closes data connection.
2: Application Layer 22
TCP control connectionport 21
TCP data connectionport 20
Server opens another TCP data connection to transfer another file.Control connection: “out of band”FTP server maintains “state”: current directory, earlier authentication
FTPclient
FTPserver
Chapter 2: Application Layer
2.1 Principles of network applications2.2 Web and HTTP2.3 FTP 2.4 Electronic Mail
SMTP, POP3, IMAP
2.5 DNS
2.6 P2P file sharing2.7 Socket programming with TCP2.8 Socket programming with UDP2.9 Building a Web server
2: Application Layer 23
Electronic Mail
Three major components:User agents Mail servers Simple mail transfer protocol: SMTP
User Agenta.k.a. “mail reader”Composing, editing, reading mail messagese.g., Eudora, Outlook, elm, Netscape MessengerOutgoing, incoming messages stored on server
2: Application Layer 24
user mailbox
outgoing message queue
useragent
useragent
useragent
useragent
useragent
useragent
mailserver
mailserver
mailserver
SMTP
SMTP
SMTP
Electronic Mail: Mail Servers
Mail ServersMailbox contains incoming messages for userMessage queue of outgoing (to be sent) mail messagesSMTP protocol between mail servers to send email messages
Client: sending mail serverServer: receiving mail server
2: Application Layer 25
useragent
useragent
useragent
useragent
useragent
useragent
mailserver
mailserver
mailserver
SMTP
SMTP
SMTP
user mailbox
outgoing message queue
Scenario: Alice sends Message to Bob
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
1) Alice uses UA to compose message and “to”[email protected]
2) Alice’s UA sends message to her mail server; message placed in message queue
3) Client side of SMTP opens TCP connection with Bob’s mail server
mailserver
mailserver user
agent
1
2 3 4 56
useragent
2: Application Layer 26
Mail Access Protocols
SMTP: delivery/storage to receiver’s serverMail access protocol: retrieval from server
POP: Post Office Protocol [RFC 1939]Authorization (agent <‐‐>server) and download
IMAP: Internet Mail Access Protocol [RFC 1730]More features (more complex)Manipulation of stored msgs on server
HTTP: Hotmail , Yahoo! Mail, etc.
SMTP SMTP accessprotocol
sender’s mail server
useragent
receiver’s mail server
useragent
2: Application Layer 27
Chapter 2: Application Layer
2.1 Principles of network applications2.2 Web and HTTP2.3 FTP 2.4 Electronic Mail
SMTP, POP3, IMAP
2.5 DNS
2.6 P2P file sharing2.7 Socket programming with TCP2.8 Socket programming with UDP2.9 Building a Web server
2: Application Layer 28
DNS: Domain Name System
People: many identifiers:SSN, name, passport #
Internet hosts, routers:IP address (32 bit) ‐ used for addressing datagrams“Name”, e.g., ww.yahoo.com‐ used by humans
Q: map between IP addresses and name ?
Domain Name System:Distributed databaseimplemented in hierarchy of many name serversApplicationlayer protocol host, routers, name servers to communicate to resolve names (address/name translation)
Note: core Internet function, implemented as application‐layer protocolComplexity at network’s “edge”
2: Application Layer 29
Distributed, Hierarchical Database
Client wants IP for www.amazon.com; 1st approx:Client queries a root server to find com DNS server (top‐level domain)Client queries com DNS server to get amazon.com DNS server (authoritative)Client queries amazon.com DNS server to get IP
Root DNS Servers
com DNS servers org DNS servers edu DNS servers
poly.eduDNS servers
umass.eduDNS serversyahoo.com
DNS serversamazon.comDNS servers
pbs.orgDNS servers
address for www.amazon.com
2: Application Layer 30
DNS: Root Name ServersContacted by local name server that can not resolve nameRoot name server:
Contacts authoritative name server if name mapping not knownGets mappingReturns mapping to local name server
2: Application Layer 31
13 root name servers worldwide
b USC-ISI Marina del Rey, CAl ICANN Los Angeles, CA
e NASA Mt View, CAf Internet Software C. Palo Alto, CA (and 36 other locations)
i Autonomica, Stockholm (plus 3 other locations)
k RIPE London (also Amsterdam, Frankfurt)
m WIDE Tokyo
a Verisign, Dulles, VAc Cogent, Herndon, VA (also Los Angeles)d U Maryland College Park, MDg US DoD Vienna, VAh ARL Aberdeen, MDj Verisign, ( 21 locations)
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 TLDEducause 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
2: Application Layer 32
Local Name Server
Does not strictly belong to hierarchyEach ISP (residential ISP, company, university) has oneAlso called “default name server”
When a host makes a DNS query, query is sent to its local DNS serverActs as a proxy, forwards query into hierarchy
2: Application Layer 33
Example root DNS server
Host at cis.poly.eduwants IP address for gaia.cs.umass.edu
local DNS serverdns.poly.edu
23
4
5
6781
requesting hostcis.poly.edu
gaia.cs.umass.edu
authoritative DNS serverdns.cs.umass.edu
TLD DNS server
Recursive query
Iterated query
2: Application Layer 34
Recursive QueriesRecursive query:
Puts burden of name resolution on contacted name serverHeavy load?
Iterated query:Contacted server replies with name of server to contact“I don’t know this name, but ask this server” requesting host
cis.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 query
2: Application Layer 35
Chapter 2: Application layer
2.1 Principles of network applications
app architecturesapp requirements
2.2 Web and HTTP2.4 Electronic Mail
SMTP, POP3, IMAP
2.5 DNS
2.6 P2P file sharing2.7 Socket programming with TCP2.8 Socket programming with UDP2.9 Building a Web server
2: Application Layer 36
P2P: Centralized Directory
Original “Napster” design1) When peer connects, it informs central server:
IP addressContent
2) Alice queries for “Hey Jude”3) Alice requests file from Bob
centralizeddirectory server
peers
Alice
Bob
1
1
1
12
3
2: Application Layer 37
P2P: Problems with Centralized Directory
Single point of failurePerformance bottleneckCopyright infringement
File transfer is decentralized, but locating content is highly centralized
2: Application Layer 38
Query Flooding: Gnutella
Fully distributedNo central server
Public domain protocolMany Gnutella clients implementing protocol
Overlay network: graphEdge between peer X and Y if there’s a TCP connectionAll active peers and edges is overlay netEdge is not a physical linkGiven peer will typically be connected with < 10 overlay neighbors
2: Application Layer 39
Gnutella: Protocol
2: Application Layer 40
Query
QueryHit
Query
Query
QueryHit
Query
Query
QueryH
it
File transfer:HTTPQuery message
sent over existing TCPconnections
Peers forwardQuery message
QueryHit sentover reversepath
Scalability:limited scope flooding
Hierarchical Overlay
Between centralized index, query flooding approachesEach peer is either a group leader or assigned to a group leader.
TCP connection between peer and its group leader.TCP connections between some pairs of group leaders.
Group leader tracks content ordinary peer
group-leader peer
neighoring relationshipsin overlay network
in its children
2: Application Layer 41
Comparing Client-Server, P2P Architectures
Question : How much time distribute file initially at one server to N other computers?
us: server upload bandwidth
2: Application Layer
us
u2d1 d2u1
Serverui: client/peer i upload bandwidth
42
uN
dN Network (with abundant bandwidth)
di: client/peer i download bandwidthFile, size F
Comparing Client-Server, P2P Architectures
0
0.5
1
1.5
2
2.5
3
3.5
0 5 10 15 20 25 30 35
N
Min
imum
Dis
tribu
tion
Tim
e P2PClient-Server
P2P Case Study: BitTorrent
tracker: tracks peers participating in torrent
442: Application Layer
torrent: group of peers exchanging chunks of a file
obtain listof peers
trading chunks
peer
P2P file distribution
BitTorrent (1)
File divided into 256KB chunksPeer joining torrent:
Has no chunks, but will accumulate themover timeRegisters with tracker to get list of peers, connects to subset of peers (“neighbors”)
While downloading, peer uploads chunks to other peersPeers may come and goOnce peer has entire file, it may (selfishly) leave or (altruistically) remain
2: Application Layer 45
BitTorrent (2)Pulling ChunksAt any given time, different peers have different subsets of file chunksPeriodically, a peer (Alice) asks each neighbor for list of chunks that they have.Alice issues requests for her missing chunks
rarest first
Sending Chunks: tit‐for‐tat
2: Application Layer 46
Alice sends chunks to four neighbors currently sending her chunks at the highest rate
re‐evaluate top 4 every 10 secs
every 30 secs: randomly select another peer, starts sending chunks
newly chosen peer may join top 4
P2P Case Study: Skype
P2P (pc‐to‐pc, pc‐to‐phone, phone‐to‐pc) Voice‐Over‐IP (VoIP) application
also IMProprietary application‐layer protocol (inferred via reverse engineering) Hierarchical overlay
Skype clients (SC)
Supernode(SN)
Skype login server
2: Application Layer 47
Skype: Making a Call
User starts SkypeSC registers with SN
list of bootstrap SNs
SC logs in (authenticate)
Skype login server
Call: SC contacts SN will callee ID
SN contacts other SNs(unknown protocol, maybe flooding) to find addr of callee; returns addr to SC
2: Application Layer
SC directly contacts callee, over TCP48
Chapter 2: Summary
Typical request/reply message exchange:
Client requests info or serviceServer responds with data, status code
Message formats:Headers: fields giving info about dataData: info being communicated
Most importantly: learned about protocols
2: Application Layer
Important themes: Control vs. data msgs
In‐band, out‐of‐bandCentralized vs. decentralized Stateless vs. statefulReliable vs. unreliable msg transfer “Complexity at network edge”
49