Chapter 2 V6.3
Chapter 2 V6.3
Chapter 2 V6.3
Application Layer
clients:
communicate with server
client/server
may be intermittently
connected
may have dynamic IP
addresses
do not communicate directly
with each other
application application
socket controlled by
process process app developer
transport transport
network network controlled
link
by OS
link Internet
physical physical
application underlying
application layer protocol transport protocol
time
6. Steps 1-5 repeated for each of 10
jpeg objects
response time =
2RTT+ file transmission time time
time
~
~ 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
above lets you send email without using email client (reader)
A: doesn’t scale!
… …
gaia.cs.umass.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
www.ibm.com is really
type=NS
name is domain (e.g., servereast.backup2.ibm.com
foo.com) value is canonical name
value is hostname of
authoritative name type=MX
server for this domain
value is name of mailserver
associated with name
2 bytes 2 bytes
identification flags
time to distribute F
to N clients using
Dc-s > max{NF/us,,F/dmin}
client-server approach
increases linearly in N
Application Layer 2-81
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
clients: as aggregate must download NF bits
max upload rate (limting max download rate) is us + Sui
time to distribute F
DP2P
to N clients using > max{F/us,,F/dmin,,NF/(us + Sui)}
P2P approach
increases linearly in N …
… but so does this, as each peer brings service capacity
Application Layer 2-82
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-83
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
DHT paradigm
Peer churn
Simple Database
Simple database with(key, value) pairs:
• key: human name; value: social security #
Key Value
John Washington 132-54-3570
Diana Louise Jones 761-55-3791
Xiaoming Liu 385-41-0902
Rakesh Gopal 441-89-1956
Linda Cohen 217-66-5609
……. ………
Lisa Kobayashi 177-23-0199
60 12
13
48
25
40
32 “overlay network”
Resolving a query
13
48
O(N) messages 25
on avgerage to resolve
query, when there 40
32
are N peers
Circular DHT with shortcuts
1 What is the value for
value key 53
12
60
13
48
25
40
32
• each peer keeps track of IP addresses of predecessor,
successor, short cuts.
• reduced from 6 to 3 messages.
• possible to design shortcuts with O(log N) neighbors, O(log N)
messages in query
Peer churn handling peer churn:
1 peers may come and go (churn)
each peer knows address of its
3 two successors
15
each peer periodically pings its
4 two successors to check
aliveness
12 if immediate successor leaves,
5
choose next successor as new
10 immediate successor
8
example: peer 5 abruptly leaves
Peer churn handling peer churn:
1 peers may come and go (churn)
each peer knows address of its
3 two successors
15
each peer periodically pings its
4 two successors to check
aliveness
12 if immediate successor leaves,
choose next successor as new
10 immediate successor
8
example: peer 5 abruptly leaves
peer 4 detects peer 5’s departure; makes 8 its immediate
successor
4 asks 8 who its immediate successor is; makes 8’s
immediate successor its second successor.
Chapter 2: outline
2.1 principles of network 2.6 P2P applications
applications 2.7 socket programming
app architectures with UDP and TCP
app requirements
2.2 Web and HTTP
2.3 FTP
2.4 electronic mail
SMTP, POP3, IMAP
2.5 DNS
application application
socket controlled by
process process app developer
transport transport
network network controlled
link
by OS
link Internet
physical physical
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-100
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
rcvr 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-102
Example app: UDP client
Python UDPClient
include Python’s socket
library from socket import *
serverName = ‘hostname’
serverPort = 12000
create UDP socket for clientSocket = socket(socket.AF_INET,
server
write reply to
connectionSocket read reply from
clientSocket
close
connectionSocket close
clientSocket
Introduction 1-111
application
packet (www browser,
OS
packet Transport (TCP/UDP)