Documente Academic
Documente Profesional
Documente Cultură
Application
Layer
A note on the use of these Powerpoint 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: Computer
If you use these slides (e.g., in a class) that you mention their source
(after all, wed like people to use our book!) Networking: A Top-
Down Approach
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.
7th Edition, Global Edition
Thanks and enjoy! JFK/KWR Jim Kurose, Keith Ross
Pearson
All material copyright 1996-2016
April 2016
J.F Kurose and K.W. Ross, All Rights Reserved
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
server:
always-on host
permanent IP address
data centers for scaling
clients:
communicate with server
may be intermittently
client/server
connected
may have dynamic IP
addresses
do not communicate
directly with each other
data center housing a large number of hosts, is often used to create a powerful
Application Layer 2-7
virtual server
P2P architecture
no always-on server peer-to-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 management
Application Layer 2-8
Processes communicating
process: program clients, servers
running within a client process: process
host that initiates
within same host, two communication
processes server process:
communicate using process that waits to
inter-process be contacted
communication
(defined by OS) aside: applications
processes in different with P2P architectures
hosts communicate have client processes
by exchanging & server processes
messages
application application
socket process
controlled by
process app developer
transport transport
network network controlled
link link by OS
Internet
physical physical
~
~ ~
~ Header lines
~
~ entity body ~
~ Entity 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
client origin
server
resolution
example 2
3
host at cis.poly.edu TLD DNS server
wants IP address for 4
gaia.cs.umass.edu
5
resolution
example 2 3
recursive query: 7
6
puts burden of TLD DNS
name resolution server
heavy load at 1 8
upper levels of
authoritative DNS server
hierarchy? dns.cs.umass.edu
requesting host
cis.poly.edu
gaia.cs.umass.edu
type=A type=CNAME
name is hostname name is alias name for some
value is IP address canonical (the real) name
(relay1.bar.foo.com, 145.37.93.126, A) www.ibm.com is really
servereast.backup2.ibm.com
type=NS value is canonical name
name is domain (e.g., (foo.com, relay1.bar.foo.com, CNAME)
foo.com)
value is hostname of type=MX
authoritative name value is name of
server for this domain
mailserver associated with
(foo.com, dns.foo.com, NS) name mail.bar.foo.com,
(foo.com, Application Layer 2-67
MX)
DNS protocol, messages
query and reply messages, both with same message format
2 bytes 2 bytes
ex. the answer field a mail server and its canonical hostname
the additional information IP address for the canonical hostname
2 bytes 2 bytes
identification flags
increases linearly in N
Application Layer 2-75
File distribution time: P2P
server transmission:
must upload at least F
us
one copy
di
time to
client: sendclient
each one copy:
must network
F/us
download file copy ui
min. client download time:
F/dmin
clients: as aggregate must download NF
bits
max. upload rate (limiting max. download
rate) is us + ui
time to distribute F
to N clients using DP2P > max{F/us, F/dmin, NF/(us + ui)}
P2P approach
video
video: sequence of
values: color value (purple) and
number of repeated values (N)
images displayed at ..
..
constant rate
e.g., 24 images/sec
digital image: array of
pixels
each pixel represented
by bits
frame i
coding: use redundancy
within and between
images to decrease #
bits used to encode
temporal coding example:
image instead of sending
spatial (within image) complete frame at i+1,
send only differences from
temporal (from one frame i frame i+1
image to next)
video
CBR: (constant bit
values: color value (purple) and
number of repeated values (N)
Internet
manifest file
wheres Madmen?
Application Layer 2-91
Content Distribution Networks
(CDNs)
Internet host-to-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 9
CDN content access: a closer
look
Bob (client) requests video http://netcinema.com/6Y
video stored in CDN at http://KingCDN.com/NetC6y&B23V
1. Bob manages
Netflix account CDN
server
4. DASH streaming
application application
socket process
controlled by
process app developer
transport transport
network network controlled
link link by OS
Internet
physical physical
Application Example:
1. client reads a line of characters (data)
from its keyboard and sends data to
server
2. server receives the data and converts
characters to uppercase
3. server sends modified data to client
4. client receives modified data and Application Layer 2-97
Socket programming with
UDP
UDP: no connection between client &
server
no handshaking before sending data
sender explicitly attaches IP destination
address and port # to each packet
receiver extracts sender IP address and port #
from received packet
UDP: transmitted data may be lost or
received out-of-order
Application viewpoint:
UDP provides unreliable transfer of groups of
bytes (datagrams) between client and server
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 Pythons socket
library from socket import *
serverName = hostname
serverPort = 12000
create UDP socket for clientSocket = socket(AF_INET,
client
SOCK_DGRAM)
get user keyboard
input message = raw_input(Input lowercase sentence:)
Attach server name, port to
message; send into socket
clientSocket.sendto(message.encode(),
(serverName, serverPort))
read reply characters from
modifiedMessage, serverAddress =
socket into string
clientSocket.recvfrom(2048)
print out received string
and close socket
print(modifiedMessage.decode())
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, getting clients
message, clientAddress = serverSocket.recvfrom(2048)
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