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

Chapter 2

Application Layer

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 Computer Networking:
(including this one) and slide content to suit your needs. They obviously A Top Down Approach
represent a lot of work on our part. In return for use, we only ask the
following: Featuring the Internet,
If you use these slides (e.g., in a class) in substantially unaltered form, 3rd edition.
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 Jim Kurose, Keith Ross
you note that they are adapted from (or perhaps identical to) our slides, and Addison-Wesley, July
note our copyright of this material.
2004.
Thanks and enjoy! JFK/KWR

All material copyright 1996-2005


J.F Kurose and K.W. Ross, All Rights Reserved
2: Application Layer 1
Chapter 2: Application layer
2.1 Principles of 2.6 P2P file sharing
network applications 2.7 Socket programming
2.2 Web and HTTP with TCP
2.3 FTP 2.8 Socket programming
2.4 Electronic Mail with UDP
SMTP, POP3, IMAP 2.9 Building a Web
2.5 DNS server

2: Application Layer 2
Chapter 2: Application Layer
Our goals: learn about protocols
conceptual, by examining popular
implementation application-level
aspects of network protocols
application protocols HTTP
client-server FTP
paradigm SMTP / POP3 / IMAP
peer-to-peer DNS
paradigm programming network
applications
socket API: application
programming interface

2: Application Layer 3
Some network apps
E-mail Internet telephone
Web Real-time video
Instant messaging conference
Remote login Massive parallel
P2P file sharing
computing

Multi-user network
games
Streaming stored
video clips

2: Application Layer 4
Chapter 2: Application layer
2.1 Principles of 2.6 P2P file sharing
network applications 2.7 Socket programming
2.2 Web and HTTP with TCP
2.3 FTP 2.8 Socket programming
2.4 Electronic Mail with UDP
SMTP, POP3, IMAP 2.9 Building a Web
2.5 DNS server

2: Application Layer 5
Creating a network app
Write programs that application
transport

run on different end


network
data link

systems and
physical

communicate over a
network.
e.g., Web: Web server
software communicates
with browser software
application
application transport
network core devices do transport
network
network
data link
not run user application data link
physical
physical

code

2: Application Layer 6
Application architectures
In choosing the application architecture
you will first need to decide on the
applications architecture:

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
Many servers are used to
create a powerful virtual
server
clients:
communicate with server
may be intermittently
connected
may have dynamic IP
addresses
do not communicate
directly with each other
Egs: Web, ftp, remote login,
email.
2: Application Layer 8
Pure P2P architecture
not always-on server
arbitrary end systems directly
communicate
peers are intermittently connected
and change IP addresses
example: Gnutella
An open source file-sharing
application.
Send and get files.

Highly scalable
millions of peers may participate as
servers

But difficult to manage


- distributed nature application:
ex: one peer may have the only
copy and suddenly drop out.

2: Application Layer 9
Hybrid of client-server and P2P
Napster: MP3 file-sharing application
P2P: MP3 files are exchanged directly among
peers.
Client/server: peer queries a central server to
determine which peers have the file currently.
Instant messaging
Chatting between two users is P2P
Presence detection/location centralized:
User registers its IP address with central server
when it comes online
User contacts central server to find IP addresses of
online buddies

2: Application Layer 10
What transport services does an app need?
Reliable Data Transfer Bandwidth
some apps (e.g., audio) can some apps (e.g.,
tolerate some loss multimedia) require
other apps (e.g., file minimum amount of
transfer, email) require bandwidth to be
100% reliable data
effective
transfer
other apps (elastic
Timing apps) make use of
some apps (e.g., whatever bandwidth
Internet telephony, they get (email, ftp)
interactive games)
require low delay to be
effective
2: Application Layer 15
Transport service requirements of common apps

Application Data loss Bandwidth 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, 100s msec
video:10kbps-5Mbps
stored audio/video loss-tolerant same as above yes, few secs
interactive games loss-tolerant few kbps up yes, 100s msec
instant messaging no loss elastic yes and no

2: Application Layer 16
Internet transport protocols services

TCP service: UDP service:


connection-oriented: setup unreliable data transfer
required between client and between sending and
server processes receiving process
reliable transport between does not provide:
sending and receiving process connection setup,
flow control: sender wont reliability, flow control,
overwhelm receiver congestion control, timing,
or bandwidth guarantee
congestion control: throttle
sender when network
overloaded Q: why bother? Why is
does not provide: timing, there a UDP?
minimum bandwidth
guarantees
2: Application Layer 17
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 proprietary TCP or UDP
(e.g. RealNetworks)
Internet telephony proprietary
(e.g., Vonage,Dialpad) typically UDP

2: Application Layer 18
Chapter 2: Application layer
2.1 Principles of 2.6 P2P file sharing
network applications 2.7 Socket programming
app architectures with TCP
app requirements
2.8 Socket programming

2.2 Web and HTTP with UDP


2.4 Electronic Mail 2.9 Building a Web
SMTP, POP3, IMAP server
2.5 DNS

2: Application Layer 19
Web and HTTP
First some jargon
Web page (document) consists of objects
Object can be HTML file, JPEG image, Java
applet, audio file,
Web page consists of base HTML-file and several
referenced objects
Each object is addressable by a URL
Example URL:
www.someschool.edu/someDept/pic.gif

host name path name

HyperText Markup Language (HTML) 2: Application Layer 20


HTTP overview

HTTP: hypertext
transfer protocol
Webs application layer PC running
protocol Explorer

client/server model
client: browser that
requests, receives, Server
displays Web objects running
Apache Web
server: Web server
server
sends objects in
response to requests
Mac running
HTTP 1.0: RFC 1945 Navigator
HTTP 1.1: RFC 2068

2: Application Layer 21
HTTP overview (continued)
Uses TCP:
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

2: Application Layer 22
HTTP connections
Nonpersistent HTTP Persistent HTTP
At most one object is Multiple objects can
sent over a TCP be sent over single
connection. TCP connection
HTTP/1.0 uses between client and
nonpersistent HTTP server.
HTTP/1.1 uses
persistent connections
in default mode

2: Application Layer 23
Nonpersistent HTTP
(contains text,
Suppose user enters URL references to 10
www.someSchool.edu/someDepartment/home.index jpeg images)

1a. HTTP client initiates TCP


connection to HTTP server
(process) at
1b. HTTP server at host
www.someSchool.edu waiting
www.someSchool.edu on port 80
for TCP connection at port 80.
accepts connection, notifying
client
2. HTTP client sends HTTP
request message (containing
URL) into TCP connection 3. HTTP server receives request
socket. Message indicates message, forms response
that client wants object message containing requested
someDepartment/home.index object, and sends message
into its socket

time
2: Application Layer 24
Nonpersistent HTTP (cont.)

4. HTTP server closes TCP


connection.
5. HTTP client receives response - it makes sure that the sent
message containing html file, message was received by the
displays html. Parsing html client before it closes the
file, finds 10 referenced jpeg connection.
objects
time 6. Steps 1-5 repeated for each
of 10 jpeg objects

2: Application Layer 25
Response time modeling
Definition of RTT ( round
trip time) : time to send
a small packet to travel
from client to server
and back.
initiate TCP
connection
Response time: RTT

one RTT to initiate TCP


request
file
connection RTT
time to
transmit
one RTT for HTTP file
request and first few
file
received
bytes of HTTP response
to return time time

file transmission time


total = 2RTT+transmit time
2: Application Layer 26
Persistent HTTP
Persistent without pipelining:
Nonpersistent HTTP issues: client issues new request only
requires 2 RTTs per object
when previous response has
been received
overhead for each TCP
one RTT for each referenced
connection
object
delay
Persistent with pipelining:
default in HTTP/1.1
client sends requests as soon
Persistent HTTP as it encounters a referenced
server leaves connection open object
after sending response as little as one RTT for all the
subsequent HTTP messages referenced objects
between same client/server It does not make the server
sent over open connection always waiting to close the
HTTP server closes the connection when there are no
connection when it is not used requests;
for a certain time. Less delay
delay

2: Application Layer 27
2: Application Layer 36
2: Application Layer 37
Without Parallel Connections

With Pipelining

Non-Persistent HTTP: With Parallel Connections


- Response time=(M+1)O/R+2 RTT (TCP Conn)+ 1 RTT (Base HTML file) +1 RTT (M images)

Persistent HTTP: Without Pipelining


- Response time=(M+1)O/R+1 RTT (TCP Conn)+ 1 RTT (Base HTML file) + M*RTT (M images)

2: Application Layer 38
Cookies: keeping state (cont.)

client server
Cookie file usual http request msg server
usual http response + creates ID
ebay: 8734 Set-cookie: 1678 1678 for user

Cookie file
usual http request msg
amazon: 1678 cookie: 1678 cookie-
ebay: 8734 specific
usual http response msg action
one week later:
usual http request msg
Cookie file cookie-
cookie: 1678
amazon: 1678 specific
ebay: 8734 usual http response msg action

2: Application Layer 40
Cookies (continued)
aside
What cookies can bring: Cookies and privacy:
shopping carts cookies permit sites to
recommendations
learn a lot about you
you may supply name
user session state
Not stateless any more
and e-mail to sites
search engines use
redirection & cookies
to learn yet more
advertising companies
obtain info across
sites

2: Application Layer 41
Web caches (proxy server)
Goal: satisfy client request without involving origin server

user sets browser: Web origin


accesses via cache server

browser sends all HTTP Proxy


requests to cache server
object in cache: cache client
returns object
else cache requests
object from origin
server, then returns
object to client
client
origin
server

2: Application Layer 42
More about Web caching
Cache acts as both client Why Web caching?
and server Reduce response time for
Typically cache is installed client request.
by ISP (university, Reduce traffic on an
company, residential ISP) institutions access link.

2: Application Layer 43
Caching example
origin
Assumptions
servers
average object size = 100,000
bits public
Internet
avg. request rate from
institutions browsers to origin
servers = 15/sec
1.5 Mbps
delay from institutional router
access link
to any origin server and back
institutional
to router = 2 sec
network
10 Mbps LAN
Consequences
utilization on LAN = 15%
utilization on access link = 100%
total delay = Internet delay + institutional
access delay + LAN delay cache
= 2 sec + minutes + milliseconds
2: Application Layer 44
Caching example (cont)
origin
Possible solution
servers
increase bandwidth of access
link to, say, 10 Mbps public
Internet
Consequences
utilization on LAN = 15%
utilization on access link = 15%
10 Mbps
Total delay = Internet delay + access link
access delay + LAN delay
institutional
= 2 sec + msecs + msecs
network
often a costly upgrade 10 Mbps LAN

institutional
cache

2: Application Layer 45
Caching example (cont)
origin
Install cache servers
suppose hit rate is 0.4 public
Consequence Internet
40% requests will be
satisfied almost immediately
60% requests satisfied by
origin server 1.5 Mbps
access link
utilization of access link
reduced to 60%, resulting in institutional
negligible delays (say 10 network
10 Mbps LAN
msec)
total avg delay = Internet
delay + access delay + LAN
delay = .6*(2.01) secs +
milliseconds < 1.4 secs institutional
cache

2: Application Layer 46
Conditional GET

Goal: dont send object if cache server


cache has up-to-date cached HTTP request msg
version If-modified-since:
object
cache: specify date of
<date>
not
cached copy in HTTP request modified
HTTP response
If-modified-since:
HTTP/1.0
<date> 304 Not Modified
server: response contains no
object if cached copy is up-
HTTP request msg
to-date: If-modified-since:
HTTP/1.0 304 Not <date> object
Modified modified
HTTP response
HTTP/1.0 200 OK
<data>
2: Application Layer 47
Chapter 2: Application layer
2.1 Principles of 2.6 P2P file sharing
network applications 2.7 Socket programming
2.2 Web and HTTP with TCP
2.3 FTP 2.8 Socket programming
2.4 Electronic Mail with UDP
SMTP, POP3, IMAP 2.9 Building a Web
2.5 DNS server

2: Application Layer 48
FTP: the file transfer protocol

FTP file transfer


user FTP FTP
Interface Client Server
(agent) process process
user
at host local file remote 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: Application Layer 49
FTP: separate control, data connections
TCP control connection
FTP client contacts FTP port 21
server at port 21, specifying
TCP as transport protocol
TCP data connection
Client obtains authorization FTP port 20 FTP
over control connection client server
Client browses remote Server opens a second TCP data
directory by sending connection to transfer another
commands over control file.
connection. Control connection remains open.
When server receives a Control connection: out of band
command for a file transfer, FTP server maintains state:
the server opens a TCP data current directory, earlier
connection to client authentication
Constrains the number of
After transferring one file, sessions to track.
server closes connection.
2: Application Layer 50
Type ftp://ftp.microsoft.com/
Browse to : /bussys/winnt/winnt-public/reskit/nt35/i386

Or go to CMD
Enter CD C:\Temp\Download (assuming that directory exists).
Enter: ftp ftp.microsoft.com

You should now see a prompt similar to this:


Connected to ftp.microsoft.com.
220 Microsoft FTP Service
User (ftp.microsoft.com:(none)):

For the userid, Enter: anonymous

You should see a prompt similar to this:


331 Anonymous access allowed, send identity (e-mail name) as password.
Password:
Enter: userid@domain.com as the password at the "Password:" prompt.

To download i386.exe from the bussys/winnt/winnt-public/reskit/nt35/i386 directory,


Enter: get bussys/winnt/winnt-public/reskit/nt35/i386/i386.exe
To end the FTP session, Enter: quit or bye.

Try pwd (print working directory)

2: Application Layer 51
Chapter 2: Application layer
2.1 Principles of 2.6 P2P file sharing
network applications 2.7 Socket programming
2.2 Web and HTTP with TCP
2.3 FTP 2.8 Socket programming
2.4 Electronic Mail with UDP
SMTP, POP3, IMAP 2.9 Building a Web
2.5 DNS server

2: Application Layer 53
Electronic Mail outgoing
message queue
user mailbox
user
Three major components: agent
user agents mail
user
server
mail servers agent
simple mail transfer SMTP mail
protocol: SMTP server user
SMTP agent
User Agent
a.k.a. mail reader SMTP
mail user
composing, editing, reading agent
server
mail messages
e.g., Eudora, Outlook, elm, user
Netscape Messenger agent
user
outgoing, incoming messages agent
stored on server
2: Application Layer 54
Electronic Mail: mail servers
user
Mail Servers agent
mailbox contains incoming mail
user
messages for user server
agent
message queue of outgoing
SMTP
(to be sent) mail messages mail
server user
SMTP protocol between mail
servers to send email SMTP agent

messages. It has two sides: SMTP


client: executes on mail user
agent
senders mail server server
server: executes on
user
recipients mail server agent
user
agent

2: Application Layer 55
Electronic Mail: SMTP [RFC 2821]
uses TCP to reliably transfer email message from client to
server, port 25
Persistent connection./more than one message can be sent over the
same connection.
direct transfer: sending server to receiving server
three phases of transfer
handshaking (greeting)
transfer of messages
closure
command/response interaction
commands: ASCII text
response: status code and phrase
messages must be in 7-bit ASCII
it requires binary multimedia data to be encoded to ASCII
before being sent over SMTP;
and it requires the corresponding ASCII message to be
decoded back to binary after SMTP transport

2: Application Layer 56
Scenario: Alice sends message to Bob
1) Alice uses UA to compose 4) SMTP client sends Alices
message and to message over the TCP
bob@someschool.edu connection
2) Alices UA sends message 5) Bobs mail server places the
to her mail server; message message in Bobs mailbox
placed in message queue 6) Bob invokes his user agent
3) Client side of SMTP opens to read message
TCP connection with Bobs
mail server

1 mail
mail
server user
user server
2 agent
agent 3 6
4 5

2: Application Layer 57
SMTP: final words Comparison with HTTP:
Both protocols are used to
both have ASCII
transfer files from one host command/response
to another; interaction, status codes
HTTP transfers files (or
objects) from Web server to HTTP: each object
Web user agent (i.e., the encapsulated in its own
browser);
response msg
SMTP transfers files (i.e.,
email messages) from one mail SMTP: places all of the
server to another mail server. message's objects into one
message.
HTTP: pull
TCP connection is initiated by
the machine that wants to
receive the file.
SMTP: push
the TCP connection is
initiated by the machine that
wants to send the file

2: Application Layer 60
Message format: multimedia extensions
MIME: multimedia mail extension, RFC 2045, 2056
additional lines in msg header declare MIME content
type

From: alice@crepes.fr
MIME version To: bob@hamburger.edu
Subject: Picture of yummy crepe.
method used MIME-Version: 1.0
to encode data Content-Transfer-Encoding: base64
Content-Type: image/jpeg
multimedia data
type, subtype, base64 encoded data .....
parameter declaration .........................
......base64 encoded data
encoded data

2: Application Layer 62
Mail access protocols
SMTP SMTP access user
user
agent protocol agent

senders mail receivers mail


server server

SMTP: delivery/storage to receivers server


Mail 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.

2: Application Layer 63
POP3 protocol S: +OK POP3 server ready
Three phases: C: user bob
authorization phase S: +OK
client commands: C: pass hungry
user: declare username
S: +OK user successfully logged on
pass: password
server responses C: list
+OK: server is saying that the previous S: 1 498
command was fine
-ERR:If you misspell a command, the S: 2 912
POP3 server will reply with an -ERR S: .
message.
transaction phase, client: C: retr 1
list: list message numbers S: <message 1 contents>
retr: retrieve message by number S: .
dele: delete C: dele 1
Quit C: retr 2
update phase, S: <message 1 contents>
occurs after the client has issued S: .
the quit command ending the POP3
session C: dele 2
the mail server deletes the C: quit
messages that were marked for S: +OK POP3 server signing off
deletion.
2: Application Layer 64
POP3 (more) and IMAP
More about POP3 IMAP
Previous example uses download
Keep all messages in one
and delete mode.
Bob cannot re-read e-mail if he
place: the server
changes client Allows user to remotely
( ex: checking the mail from the

organize messages in
office and trying to check from
home) folders
Download-and-keep: copies of search the messages
messages on different clients matching certain criteria
the user agent leaves the
IMAP keeps user state
messages on the mail server
after downloading them
across sessions:
POP3 is stateless across sessions names of folders and
is not required to carry state mappings between message
information across POP3 sessions IDs and folder name

2: Application Layer 65
Chapter 2: Application layer
2.1 Principles of 2.6 P2P file sharing
network applications 2.7 Socket programming
2.2 Web and HTTP with TCP
2.3 FTP 2.8 Socket programming
2.4 Electronic Mail with UDP
SMTP, POP3, IMAP 2.9 Building a Web
2.5 DNS server

2: Application Layer 66
DNS: Domain Name System

People: many identifiers: Domain Name System:


SSN, name, passport # distributed database
Internet hosts, routers: implemented in hierarchy of
IP address (32 bit) - used many name servers
for addressing datagrams application-layer protocol
name, e.g., allows hosts to query the
www.yahoo.com - used by distributed DB.
humans
DNS is commonly employed by
other application-layer
protocols -- including HTTP,
SMTP and FTP - to translate
user-supplied host names to
IP addresses

2: Application Layer 67
DNS: Domain Name System, cont
ex: As an example, consider what happens when a browser (i.e., an HTTP
client), running on some user's machine, requests the URL
www.someschool.edu/index.html.

In order for the user's machine to be able to send an HTTP request


message to the Web server www.someschool.edu, the user's machine
must obtain the IP address of www.someschool.edu.

This is done as follows:


1. The same user machine runs the client-side of the DNS application.
2. The browser extracts the hostname, www.someschool.edu, from the URL and
passes the hostname to the client-side of the DNS application.
3. The DNS client sends a query containing the hostname to a DNS server.
4. The DNS client eventually receives a reply, which includes the IP address for
the hostname.
5. Once the browser receives the IP address from DNS, it initiate a TCP
connection to the HTTP server process located at that IP address.

2: Application Layer 68
DNS
DNS services DNS services cont.
Hostname to IP address
translation Load distribution
Host aliasing Replicated Web servers: set of IP
west-coast.enterprise.com addresses for one canonical name
www.enterprise.com The DNS database contains this
Mail server aliasing set of IP addresses.
When clients make a DNS query
bob@hotmail.com
for a name mapped to a set of
However, the hostname of the addresses, the server responds
Hotmail mail server is more with the entire set of IP
complicated than simply addresses, but rotates the
hotmail.com: ex: ordering of the addresses within
relay1.west-coast.hotmail.com each reply.
Because a client typically sends
its HTTP request message to the
Why not centralize DNS? IP address that is listed first in
the set,
single point of failure DNS rotation distributes the
traffic among all the replicated
traffic volume servers.
distant centralized database
Ex: Cnn.com
Maintenance
Huge database to keep updated
for new hosts. 2: Application Layer 69
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; 1st approx:


Client queries a root server to find com DNS
server
Client queries com DNS server to get amazon.com
DNS server
Client queries amazon.com DNS server to get IP
address for www.amazon.com
2: Application Layer 70
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
a Verisign, Dulles, VA
c Cogent, Herndon, VA (also Los Angeles)
d U Maryland College Park, MD
k RIPE London (also Amsterdam,
g US DoD Vienna, VA
Frankfurt) Stockholm (plus 3
i Autonomica,
h ARL Aberdeen, MD
j Verisign, ( 11 locations) other locations)

m WIDE Tokyo
e NASA Mt View, CA
f Internet Software C. Palo Alto,
CA (and 17 other locations)

13 root name
servers worldwide
b USC-ISI Marina del Rey, CA
l ICANN Los Angeles, CA

2: Application Layer 71
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 company maintains servers for com TLD
Educause company maintains servers for edu TLD
Authoritative DNS servers: organizations DNS
servers, providing authoritative hostname to IP
mappings for organizations servers (e.g., Web and
mail).
Can be maintained by organization or service provider

2: Application Layer 72
Local Name Server
Does not strictly belong to hierarchy
Each ISP (residential ISP, company,
university) has one.
Also called default name server
When a host makes a DNS query, query is
sent to its local DNS server
Acts as a proxy, forwards query into hierarchy.

2: Application Layer 73
Example root DNS server

2
Host at cis.poly.edu 3
TLD DNS server
wants IP address for 4
gaia.cs.umass.edu
5

local DNS server


dns.poly.edu
7 6
1 8

authoritative DNS server


dns.cs.umass.edu
Iterated query requesting host
cis.poly.edu

gaia.cs.umass.edu

2: Application Layer 74
Recursive queries root DNS server

recursive query:
2
puts burden of name 3
resolution on 7 6
contacted name TLD DNS serve
server
heavy load?
local DNS server
iterated query: dns.poly.edu 5 4

contacted server 1 8
replies with name of
server to contact authoritative DNS server
I dont know this
dns.cs.umass.edu
requesting host
name, but ask this cis.poly.edu
server
gaia.cs.umass.edu

2: Application Layer 75
DNS: caching and updating records
once (any) name server learns mapping, it caches
mapping
cache entries timeout (disappear) after some
time
TLD servers typically cached in local name
servers
Thus root name servers not often visited

2: Application Layer 76
Chapter 2: Application layer
2.1 Principles of 2.6 P2P file sharing
network applications 2.7 Socket programming
app architectures with TCP
app requirements
2.8 Socket programming

2.2 Web and HTTP with UDP


2.4 Electronic Mail 2.9 Building a Web
SMTP, POP3, IMAP server
2.5 DNS

2: Application Layer 81
P2P file sharing
Alice chooses one of
Example the peers, Bob.
Alice runs P2P client File is copied from
application on her Bobs PC to Alices
notebook computer notebook: HTTP
Intermittently While Alice downloads,
connects to Internet; other users uploading
gets new IP address from Alice.
for each connection Alices peer is both a
Asks for Hey Jude Web client and a
transient Web server.
Application displays
other peers that have All peers are servers =
copy of Hey Jude. highly scalable!
2: Application Layer 82
Architectures for locating contents in P2P file sharing

1. Centralized directory
2. Query flooding
3. Exploiting heterogeneity

2: Application Layer 83
P2P: 1. centralized directory
Bob
original Napster design centralized
1) when peer connects, it directory server
1
informs central server: peers

IP address 1

content
1 3
2) Alice queries for Hey
2
Jude 1

3) Alice requests file from


Bob.

Alice
Hybrid client-server model

2: Application Layer 84
P2P: problems with centralized directory

Single point of failure file transfer is


Performance decentralized, but
bottleneck locating content is
Copyright issues
highly centralized

2: Application Layer 85
P2P : 2. Query flooding: Gnutella
File transfer:
fully distributed: HTTP using another TCP
no central server connection

Query message
sent over existing TCP Query
connections QueryHit
peers forward
Query message
QueryHit
sent over
reverse Query
path QueryHit

Scalability:
limited scope
flooding *
2: Application Layer 86
P2P : 3. Exploiting heterogeneity: KaZaA

Each 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 the
content in all its children.
Group leader usually has
higher bandwidth and higher
connectivity
ordinary peer

group-leader peer

neighoring relationships
in overlay network

2: Application Layer 88
KaZaA tricks to improve its performance

Request queuing
User can put Limitations on simultaneous
uploads, (ex. 3 downloads at the same time)
Incentive priorities:
user can give priority to users, ( ex. Give more
priority to those who upload more than
download)

2: Application Layer 90
Chapter 2: Application layer
2.1 Principles of 2.6 P2P file sharing
network applications 2.7 Socket programming
2.2 Web and HTTP with TCP
2.3 FTP 2.8 Socket programming
2.4 Electronic Mail with UDP
SMTP, POP3, IMAP 2.9 Building a Web
2.5 DNS server

2: Application Layer 91

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