Chapter - 2 - V7.01 Application Layer
Chapter - 2 - V7.01 Application Layer
Application
Layer
Computer
Networking: A Top
Down Approach
7th Edition, Global Edition
Jim Kurose, Keith Ross
Pearson
April 2016
Application Layer 2-1
Chapter 2: outline
2.1 principles of 2.5 P2P applications
network 2.6 video streaming
applications and content
2.2 Web and HTTP distribution
2.3 electronic mail networks
• SMTP, POP3, IMAP 2.7 socket
2.4 DNS programming with
UDP and TCP
core devices
network-core devices do
not run user applications
applications on end
systems allows for rapid Application Layer 2-5
Application architectures
possible structure of applications:
client-server
peer-to-peer (P2P)
clients:
communicate with
server
client/server
may be intermittently
connected
may have dynamic IP
addresses
do not communicate
directly with each
other Application Layer 2-7
P2P architecture
no always-on server peer-peer
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 Application Layer 2-8
2.1.2 Processes communicating
transport transport
network network controlled
link
by OS
link Internet
physical physical
~
~ entity body ~
~ body
URL method:
uses GET method
input is uploaded in URL field of request
line:
www.somesite.com/animalsearch?monkeys&banana
ebay 8734
usual http request msg Amazon server
cookie file creates ID
usual http response
1678 for user create backend
ebay 8734
set-cookie: 1678 entry database
amazon 1678
usual http request msg
cookie: 1678 cookie- access
specific
usual http response msg action
problem! institutional
consequences: network
LAN utilization: 0.15% 1 Gbps LAN
access link utilization = 99%
total delay = Internet delay
+ access delay + LAN delay
= 2 sec + minutes + usecs
Application Layer 2-40
Caching example: fatter
access link
assumptions:
avg object size: 100K bits
origin
avg request rate from servers
browsers to origin public
servers:15/sec Internet
avg data rate to browsers:
1.50 Mbps
RTT from institutional router
to any origin server: 2154
sec 1.54 Mbps
154 Mbps
access link rate: 1.54 Mbps access link
Mbps
institutional
consequences: network
LAN utilization: 0.15%9.9% 1 Gbps LAN
access link utilization = 99%
total delay = Internet delay +
access delay + LAN delay
msecs + usecs
= 2 sec + minutes
Cost: increased access link speed (not cheap!)
Application Layer 2-41
Caching example: install local
cache
assumptions:
avg object size: 100K bits
origin
avg request rate from servers
browsers to origin public
servers:15/sec Internet
avg data rate to browsers:
1.50 Mbps
RTT from institutional router
to any origin server: 2 sec 1.54 Mbps
access link rate: 1.54 Mbps access link
institutional
consequences: network
?
LAN utilization: 15% 1 Gbps LAN
?
access link utilization = 100%
Howdelay
to compute linkdelay + local web
total = Internet
utilization, cache
access delay + delay?
LAN delay
= 2 sec + minutes + usecs
Cost: web cache (cheap!)
Application Layer 2-42
Caching example: install local
cache
Calculating access link
utilization, delay with
origin
cache: servers
suppose cache hit rate is 0.4 public
• 40% requests satisfied at cache, Internet
60% requests satisfied at origin
access link utilization:
60% of requests use access link
data rate to browsers over access 1.54 Mbps
access link
link
= 0.6*1.50 Mbps = 0.9 Mbps institutional
utilization = 0.9/1.54 = 0.58 network
1 Gbps LAN
total delay
= 0.6 * (delay from origin servers) local web
+0.4 * (delay when satisfied at cache
cache)
= 0.6 (2.01) + 0.4 (~msecs) = ~
1.2 secs
less than with 154 Mbps link (and Application Layer 2-43
cheaper too!)
2.2.6 Conditional GET
Cache server
Goal: don’t send object
if cache has up-to-date
cached version HTTP request msg
object
If-modified-since: <date>
• no object transmission not
delay modified
• lower link utilization HTTP response
after
HTTP/1.0
cache: specify date of 304 Not Modified <date>
cached copy in HTTP
request
If-modified-since:
<date> HTTP request msg
server: response If-modified-since: <date> object
contains no object if modified
after
cached copy is up-to- HTTP response
HTTP/1.0 200 OK <date>
date:
<data>
HTTP/1.0 304 Not
Modified Application Layer 2-44
Chapter 2: outline
2.1 principles of 2.5 P2P applications
network 2.6 video streaming
applications and content
2.2 Web and HTTP distribution
2.3 electronic mail networks
• SMTP, POP3, IMAP 2.7 socket
2.4 DNS programming
with UDP and TCP
example 2
host at cis.poly.edu 3
TLD DNS server
wants IP address 4
for
gaia.cs.umass.edu 5
example 2 3
7
recursive query: 6
puts burden of TLD DNS
server
name resolution on
contacted name local DNS server
server dns.poly.edu 5 4
gaia.cs.umass.edu
2 bytes 2 bytes
identification flags
increases linearly in N
Application Layer 2-75
File distribution time: P2P
server transmission: must
upload at least one copy F
us
• time to send one copy: F/us
di
client: each client must
network
download file copy ui
• min client download time:
F/dmin as aggregate must download NF bits
clients:
• max upload rate (limiting max download rate) is us +
Sui
time to distribute F
DP2P > max{F/us,,F/dmin,,NF/(us + Sui)}
to N clients using
P2P approach
increases linearly in N …
… but so does this, as each peer brings service capacity
Application Layer 2-76
Client-server vs. P2P: example
client upload rate = u, F/u = 1 hour, us = 10u, dmin ≥ us
3.5
P2P
Minimum Distribution Time
3
Client-Server
2.5
1.5
0.5
0
0 5 10 15 20 25 30 35
N
Application Layer 2-77
P2P file distribution:
BitTorrent
file divided into 256Kb chunks
peers in torrent send/receive file chunks
Alice arrives …
… obtains list
of peers from tracker
… and begins exchanging
file chunks with peers in torrent
video
color (all purple), send only two
values: color value (purple) and
number of repeated values (N)
video: sequence of
images displayed at ……………………..
……………….…….
constant rate
• e.g., 24 or 30
images/sec
digital image: array of
pixels
• each pixel represented frame i
by bits
coding: use redundancy
within and between
images to decrease # bitstemporal coding example:
instead of sending
used to encode image complete frame at i+1,
send only differences from
• spatial (within image) frame i frame i+1
• temporal (from one
image to next) Application Layer 2-84
Multimedia: spatial coding example: instead
of sending N values of same
video
color (all purple), send only two
values: color value (purple) and
number of repeated values (N)
CBR: (constant bit rate):
video encoding rate fixed ……………………..
……………….…….
VBR: (variable bit rate):
video encoding rate
changes as amount of
spatial, temporal coding
changes
examples: frame i
• MPEG 1 (CD-ROM) 1.411
Mbps
• MPEG1 Layer 3- MP3 temporal coding example:
128kbps instead of sending
complete frame at i+1,
• MPEG2 (DVD) 3-6 Mbps send only differences from
• MPEG4 (often used in frame i
frame i+1
Internet, < 1 Mbps)
Internet
流式存储视频三个特色:
流:客户下载一部分文件后即可播放 - 要求将文件分片; 客户缓存
相互作用:暂停、前进、后退等操作 - 如 TCP 缓存机制、 HTTP 字节范围首部实现前进后退并防止浪费)
连续播放:自动连续接收数据
UDP 流、 HTTP 流、适应性流 DASH
Application Layer 2-86
2.6.2 Streaming multimedia:
DASH
DASH: Dynamic, Adaptive Streaming over
HTTP
server:
• divides video file into multiple chunks (e.g.
4sec/chunk in Netflix)
• each chunk stored, encoded at different rates
• manifest file: provides URLs for different chunks
client:
• periodically measures server-to-client bandwidth
• consulting manifest, requests one chunk at a time
• chooses max coding rate sustainable given
current bandwidth
• can choose different coding rates at different
points in time (depending on availableApplication
bandwidth Layer 2-87
2.6.2 Streaming multimedia:
DASH
DASH: Dynamic, Adaptive Streaming over
HTTP
“intelligence” at client: client determines
• when to request chunk (so that buffer
starvation, or overflow does not occur)
• what encoding rate to request (higher quality
when more bandwidth available)
• where to request chunk (can request from URL
server that is “close” to client or has high
available bandwidth)
… …
…
manifest file
…
where’s Madmen?
… …
Application Layer 2-91
Content Distribution Networks
(CDNs)
… …
Internet host-host communication as a service
…
OTT challenges: coping with a congested
…
Internet
from which CDN node to retrieve content?
viewer behavior in presence of congestion?
… …
what content to place in which CDN node?
more .. in chapter 7
CDN content access: a closer look
Bob (client) requests video http://netcinema.com/6Y7B23V
video stored in CDN at http://KingCDN.com/NetC6y&B23V
1. Bob manages
Netflix account CDN
server
4. DASH streaming
transport transport
network network controlled
link
by OS
link Internet
physical physical
write reply to
serverSocket read datagram from
specifying clientSocket
client address,
port number close
clientSocket
Application 2-99
Example app: UDP client
Python UDPClient
include Python’s socket
library from socket import *
serverName = ‘hostname’
serverPort = 12000
create UDP socket for clientSocket = socket(AF_INET,
server
SOCK_DGRAM)
get user keyboard
input message = raw_input(’Input lowercase sentence:’)
Attach server name, port to clientSocket.sendto(message.encode(),
message; send into socket
(serverName, serverPort))
read reply characters from modifiedMessage, serverAddress =
socket into string
clientSocket.recvfrom(2048)
print out received string print modifiedMessage.decode()
and close socket
clientSocket.close()
Application Layer 2-100
Example app: UDP server
Python UDPServer
from socket import *
serverPort = 12000
create UDP socket serverSocket = socket(AF_INET, SOCK_DGRAM)
bind socket to local port
number 12000
serverSocket.bind(('', serverPort))
print (“The server is ready to receive”)
loop forever while True:
Read from UDP socket into message, clientAddress = serverSocket.recvfrom(2048)
message, getting client’s
address (client IP and port) modifiedMessage = message.decode().upper()
send upper case string serverSocket.sendto(modifiedMessage.encode(),
back to this client clientAddress)
write reply to
connectionSocket read reply from
clientSocket
close
connectionSocket close
clientSocket