Chapter 2 V6.2
Chapter 2 V6.2
Application Layer
clients:
❖ communicate with server
❖ may be intermittently
client/server
connected
❖ may have dynamic IP
addresses
❖ do not communicate directly
with each other
application application
proce socket proce controlled by
ss ss app developer
transport transport
network network controlled
link link by OS
Internet
physical physical
application underlying
application layer protocol transport protocol
time
6. Steps 1-5 repeated for each of
10 jpeg objects
connection RTT
~
~ entity body ~
~ body
URL method:
❖ uses GET method
❖ input is uploaded in URL
field of request line:
www.somesite.com/animalsearch?monkeys&banan
a
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)
… …
resolution example
2
❖ host at cis.poly.edu 3
TLD DNS server
wants IP address for 4
gaia.cs.umass.edu
5
resolution example
2 3
7
recursive query: 6
❖ puts burden of name TLD DNS
server
resolution on
contacted name local DNS server
server dns.poly.edu 5 4
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
type=NS ▪ www.ibm.com is really
▪ 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-78
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 + Σui
time to distribute F
to N clients using DP2P > max{F/us,,F/dmin,,NF/(us + Σui)}
P2P approach
increases linearly in N …
… but so does this, as each peer brings service capacity
Application Layer 2-79
Client-server vs. P2P: example
client upload rate = u, F/u = 1 hour, us = 10u, dmin ≥ us
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
12
60
13
48
25
40
32 “overlay network”
Resolving a query
60
13
48
O(N) messages 25
on avgerage to resolve
40
query, when there 32
are N peers
Circular DHT with shortcuts
1 What is the value for
value
12 key 53
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
3 (churn)
15
❖each peer knows address of
4 its two successors
❖each peer periodically pings
12
5 its two successors to check
10 aliveness
8 ❖if immediate successor
example: peer 5 abruptly leaves, choose next
leaves
successor as new immediate
successor
Peer churn handling peer churn:
1
❖peers may come and go (churn)
❖each peer knows address of its
3
15 two successors
❖each peer periodically pings its
4
two successors to check aliveness
12
❖ifimmediate successor leaves,
choose next successor as new
10
8 immediate successor
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
proce socket proce controlled by
ss ss 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 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-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
❖ 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-99
Example app: UDP client
Python UDPClient
include Python’s socket
from socket import *
library
serverName = ‘hostname’
serverPort = 12000
create UDP socket for
server clientSocket = socket(socket.AF_INET,
get user keyboard
socket.SOCK_DGRAM)
input
Attach server name, port to message = raw_input(’Input lowercase sentence:’)
message; send into socket
write reply to
connectionSocket read reply from
clientSocket
close
connectionSocket close
clientSocket