Escolar Documentos
Profissional Documentos
Cultura Documentos
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 see the animations; and 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:
v If you use these slides (e.g., in a class) that you mention their source
(after all, wed like people to use our book!)
v If you post any slides 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.
Computer
Networking: A Top
Down Approach
6th edition
Jim Kurose, Keith Ross
Addison-Wesley
March 2012
creating network
applications
socket API
e-mail
web
text messaging
remote login
P2P file sharing
multi-user network games
streaming stored video
(YouTube, Hulu, Netflix)
v
v
v
v
v
v
Application architectures
possible structure of applications:
v client-server
v peer-to-peer (P2P)
Client-server architecture
server:
v
v
v
always-on host
permanent IP address
data centers for scaling
clients:
v
client/server
P2P architecture
v
v
no always-on server
arbitrary end systems
directly communicate
peers request service from
other peers, provide service
in return to other peers
self scalability new
peers bring new service
capacity, as well as new
service demands
peers are intermittently
connected and change IP
addresses
complex management
peer-peer
Processes communicating
process: program running
within a host
v
clients, servers
client process: process that
initiates communication
server process: process that
waits to be contacted
Sockets
v
v
process
socket
application
process
transport
transport
network
network
link
physical
Internet
link
controlled by
app developer
controlled
by OS
physical
Addressing processes
v
to receive messages,
process must have identifier
host device has unique 32bit IP address
Q: does IP address of host
on which process runs
suffice for identifying the
process?
A: no, many processes
can be running on same
host
more shortly
throughput
v some apps (e.g.,
multimedia) require
minimum amount of
throughput to be
effective
v other apps (elastic apps)
make use of whatever
throughput they get
security
v encryption, data integrity,
data loss
throughput
file transfer
e-mail
Web documents
real-time audio/video
no loss
no loss
no loss
loss-tolerant
stored audio/video
interactive games
text messaging
loss-tolerant
loss-tolerant
no loss
elastic
no
elastic
no
elastic
no
audio: 5kbps-1Mbps yes, 100s msec
video:10kbps-5Mbps
same as above
yes, few secs
few kbps up
yes, 100s msec
elastic
yes and no
time sensitive
v
v
UDP service:
v
application
layer protocol
underlying
transport protocol
TCP
TCP
TCP
TCP
TCP or UDP
TCP or UDP
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
open protocols:
v defined in RFCs
v allows for interoperability
v e.g., HTTP, SMTP
proprietary protocols:
v e.g., Skype
Chapter 2: outline
2.1 principles of network
applications
app architectures
app requirements
2.5 DNS
path name
HTTP overview
HTTP: hypertext
transfer protocol
v
v
PC running
Firefox browser
server
running
Apache Web
server
iphone running
Safari browser
HTTP is stateless
v
server maintains no
information about
past client requests
aside
protocols that maintain
state are complex!
v
v
HTTP connections
non-persistent HTTP
v at most one object
sent over TCP
connection
connection then
closed
v downloading multiple
objects requires
multiple connections
persistent HTTP
v multiple objects can
be sent over single
TCP connection
between client, server
Non-persistent HTTP
suppose user enters URL:
www.someSchool.edu/someDepartment/home.index
(contains text,
references to 10
jpeg images)
time
Application Layer 2-20
time
initiate TCP
connection
RTT
request
file
time to
transmit
file
RTT
file
received
time
time
Persistent HTTP
non-persistent HTTP issues:
v
v
persistent HTTP:
v
request line
(GET, POST,
HEAD commands)
header
lines
carriage return,
line feed at start
of line indicates
end of header lines
sp
URL
sp
value
version
cr
cr
value
cr
request
line
header
lines
~
~
header field name
lf
lf
~
~
~
~
cr
lf
lf
entity body
~
~
body
URL method:
v
v
Method types
HTTP/1.0:
v
v
v
GET
POST
HEAD
asks server to leave
requested object out
of response
HTTP/1.1:
v
v
header
lines
data, e.g.,
requested
HTML file
200 OK
request succeeded, requested object later in this msg
example:
v Susan always access Internet
from PC
v visits specific e-commerce
site for first time
v when initial HTTP requests
arrives at site, site creates:
unique ID
entry in backend
database for ID
cookie file
ebay 8734
amazon 1678
server
usual http request msg
usual http response
set-cookie: 1678
usual http request msg
cookie: 1678
usual http response msg
Amazon server
creates ID
1678 for user create backend
entry database
cookiespecific
action
access
access
usual http request msg
cookie: 1678
usual http response msg
cookiespecific
action
Application Layer 2-31
Cookies (continued)
what cookies can be used
for:
v
v
v
v
authorization
shopping carts
recommendations
user session state (Web
e-mail)
aside
proxy
server
client
client
origin
server
origin
server
typically cache is
installed by ISP
(university, company,
residential ISP)
Caching example:
assumptions:
v
v
v
v
origin
servers
public
Internet
15.4 Mbps
access link
consequences:
v
v
v
problem!
LAN utilization: 15%
access link utilization = 99%
total delay = Internet delay + access
delay + LAN delay
= 2 sec + minutes + usecs
institutional
network
100Mbps LAN
v
v
origin
servers
public
Internet
15.4 Mbps
154 Mbps
access link
consequences:
v
v
v
institutional
network
msecs
v
v
origin
servers
public
Internet
15.4 Mbps
access link
consequences:
v
v
v
utilization, delay?
institutional
network
local web
cache
origin
servers
link utilization:
15 Mbps
access link
v total
delay
institutional
network
local web
cache
Conditional GET
server
client
v
HTTP response
HTTP/1.0
304 Not Modified
object
not
modified
after
<date>
If-modified-since:
<date>
v
HTTP response
HTTP/1.0 200 OK
object
modified
after
<date>
<data>
Application Layer 2-39
Chapter 2: outline
2.1 principles of network
applications
app architectures
app requirements
2.5 DNS
Electronic mail
Three major components:
v
v
v
user agents
mail servers
mail protocols
simple mail transfer protocol(SMTP)
POP3, IMAP
Electronic mail
outgoing
message queue
user mailbox
User Agent
v
v
user
agent
mail
server
user
agent
SMTP
mail
server
user
agent
SMTP
Mail Servers
v
outgoing, incoming
messages stored on server
mailbox contains incoming
messages for user
message queue of outgoing
(to be sent) mail messages
SMTP
mail
server
user
agent
user
agent
user
agent
Electronic mail
Mail Protocols:
v
v
SMTP
SMTP
mail access
protocol
user
agent
(e.g., POP,
IMAP)
senders mail
server
receivers mail
server
1 user
agent
2
mail
server
3
Alices mail server
user
agent
mail
server
4
6
5
Bobs mail server
Application Layer 2-44
user
agent
mail
server
user
agent
SMTP
mail
server
user
agent
SMTP
SMTP
mail
server
user
agent
user
agent
user
agent
220 hamburger.edu
HELO crepes.fr
250 Hello crepes.fr, pleased to meet you
MAIL FROM: <alice@crepes.fr>
250 alice@crepes.fr... Sender ok
RCPT TO: <bob@hamburger.edu>
250 bob@hamburger.edu ... Recipient ok
DATA
354 Enter mail, end with "." on a line by itself
Do you like ketchup?
How about pickles?
.
250 Message accepted for delivery
QUIT
221 hamburger.edu closing connection
HTTP: pull
SMTP: push
SMTP
SMTP
mail access
protocol
user
agent
(e.g., POP,
IMAP)
senders mail
server
v
v
receivers mail
server
POP3 protocol
authorization phase
v
client commands:
user: declare username
pass: password
server responses
+OK
-ERR
v
v
S:
C:
S:
C:
S:
C:
S:
S:
S:
C:
S:
S:
C:
C:
S:
S:
C:
C:
S:
list
1 498
2 912
.
retr 1
<message 1 contents>
.
dele 1
retr 2
<message 2 contents>
.
dele 2
quit
+OK POP3 server signing off
on
IMAP
v
Chapter 2: outline
2.1 principles of network
applications
app architectures
app requirements
2.5 DNS
distributed database
implemented in hierarchy of
many name servers
application-layer protocol: hosts,
name servers communicate to
resolve names (address/name
translation)
note: core Internet function,
implemented as applicationlayer protocol
complexity at networks
edge
hostname to IP address
translation
host aliasing
canonical, alias names
v
v
mail server
load distribution
replicated Web
servers: many IP
addresses correspond
to one name
A: doesnt scale!
http://www.krnic.or.kr/jsp/resources/dns/dnsInfo.jsp
13 root name
servers
worldwide
up to 2012
Application Layer 2-60
DNS name
resolution example
2
v
host at cis.poly.edu
wants IP address for
gaia.cs.umass.edu
iterated query:
v
contacted server
replies with name of
server to contact
I dont know this
name, but ask this
server
requesting host
cis.poly.edu
gaia.cs.umass.edu
Application Layer 2-61
DNS name
resolution example
2
7
recursive query:
v
6
TLD DNS
server
8
authoritative DNS server
dns.cs.umass.edu
requesting host
cis.poly.edu
gaia.cs.umass.edu
Application Layer 2-62
2
3
4
TLD DNS
server
3
7
6
TLD DNS
server
5
local DNS server
dns.poly.edu
dns.poly.edu
requesting host
requesting host
cis.poly.edu
cis.poly.edu
gaia.cs.umass.edu
gaia.cs.umass.edu
Application Layer 2-63
DNS records
DNS: distributed db storing resource records (RR)
RR format: (name,
type=A
name is hostname
value is IP address
type=NS
name is domain (e.g.,
foo.com)
value is hostname of
authoritative name
server for this domain
type=CNAME
name is alias name for some
canonical (the real) name
www.ibm.com is really
servereast.backup2.ibm.com
type=MX
value is name of mailserver
associated with name
Application Layer 2-65
msg header
v
identification
flags
# questions
# answer RRs
# authority RRs
# additional RRs
2 bytes
identification
flags
# questions
# answer RRs
# authority RRs
# additional RRs
RRs in response
to query
records of
authoritative servers
additional helpful
info that may be used
2
root DNS server
register NS and A RR
for auth. DNS server for
networkutopia.com
http://www.networkutopia.com
Local name
server
DNS
client
4
9
.com TLD
DNS server
Network
Registrar
for .com
(Net. Sol.)
1
7
8
10
authoritative DNS server
dns.networkutopia.com
web server
www.networkutopia.com
mail server
Application Layer 2-71
Chapter 2: outline
2.1 principles of network
applications
app architectures
app requirements
2.5 DNS
no always-on server
arbitrary end systems
directly communicate
peers are intermittently
connected and change IP
addresses
examples:
file distribution
(BitTorrent)
Streaming (KanKan)
VoIP (Skype)
file, size F
server
uN
dN
us
u1
d1
u2
d2
di
ui
ui: peer i upload
capacity
Application Layer 2-74
us
di
network
ui
us
di
network
ui
time to distribute F
to N clients using
P2P approach
increases linearly in N
but so does this, as each peer brings service capacity
Application Layer 2-76
3.5
P2P
Client-Server
3
2.5
2
1.5
1
0.5
0
0
10
15
20
25
30
35
N
Application Layer 2-77
Alice arrives
obtains list
of peers from tracker
and begins exchanging
file chunks with peers in torrent
Application Layer 2-78
v
v
v
v
BitTorrent: tit-for-tat
(1) Alice optimistically unchokes Bob
(2) Alice becomes one of Bobs top-four providers; Bob reciprocates
(3) Bob becomes one of Alices top-four providers
Chapter 2: outline
2.1 principles of network
applications
app architectures
app requirements
2.5 DNS
Socket programming
goal: learn how to build client/server applications that
communicate using sockets
socket: door between application process and endend-transport protocol
application
process
socket
application
process
transport
transport
network
network
link
physical
Internet
link
controlled by
app developer
controlled
by OS
physical
Socket programming
Two socket types for two transport services:
UDP: unreliable datagram
TCP: reliable, byte stream-oriented
Application Example:
1.
Client reads a line of characters (data) from its
keyboard and sends the data to the server.
2.
The server receives the data and converts
characters to uppercase.
3.
The server sends the modified data to the client.
4.
The client receives the modified data and displays
the line on its screen.
Application Layer 2-84
client
create socket:
clientSocket =
socket(AF_INET,SOCK_DGRAM)
Create datagram with server IP and
port=x; send datagram via
clientSocket
clientSocket = socket(socket.AF_INET,
socket.SOCK_DGRAM)
clientSocket.sendto(message,(serverName, serverPort))
modifiedMessage, serverAddress =
print modifiedMessage
clientSocket.recvfrom(2048)
clientSocket.close()
Application Layer 2-87
serverSocket.bind(('', serverPort))
print The server is ready to receive
loop forever
while 1:
serverSocket.sendto(modifiedMessage, clientAddress)
modifiedMessage = message.upper()
application viewpoint:
TCP provides reliable, in-order
byte-stream transfer (pipe)
between client and server
Application Layer 2-89
setup
create socket,
connect to hostid, port=x
clientSocket = socket()
send request using
clientSocket
serverPort = 12000
clientSocket = socket(AF_INET, SOCK_STREAM)
clientSocket.connect((serverName,serverPort))
sentence = raw_input(Input lowercase sentence:)
clientSocket.send(sentence)
modifiedSentence = clientSocket.recv(1024)
print From Server:, modifiedSentence
clientSocket.close()
Chapter 2: summary
our study of network apps now complete!
v
application architectures
client-server
P2P
application service
requirements:
reliability, bandwidth, delay
Internet transport service
model
connection-oriented,
reliable: TCP
unreliable, datagrams: UDP
specific protocols:
HTTP
FTP
SMTP, POP, IMAP
DNS
P2P: BitTorrent, DHT
socket programming: TCP,
UDP sockets
Chapter 2: summary
most importantly: learned about protocols!
v
typical request/reply
message exchange:
client requests info or
service
server responds with
data, status code
message formats:
headers: fields giving
info about data
data: info being
communicated
important themes:
v
v
v
v