Application Layer PDF
Application Layer PDF
Application Layer PDF
Application Layer
clients:
❖ Sometimes on or always on
client/server
❖ communicate with server
❖ may be intermittently
connected
❖ may have dynamic IP addresses
❖ do not communicate directly
Example: with each other
m Web, FTP, telnet, email …
http://gaia.cs.umass.edu/kurose-ross-ppt-6e/ Application Layer 2-8
P2P architecture
❖ no always-on server peer-peer
❖ arbitrary end systems directly
communicate
❖ Peers are not owned by
service providers
❖ 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
❖ Examples – file sharing
(BitTorrent)
http://gaia.cs.umass.edu/kurose-ross-ppt-6e/ Application Layer 2-9
P2P architecture
❖ Major challenges peer-peer
▪ ISP Friendly
▪ Security
▪ Incentives
fields
❖ rules for when and how
processes send & respond to
messages
application underlying
application layer protocol transport protocol
www.somesite.com/animalsearch?monkeys&banan
a
http://gaia.cs.umass.edu/kurose-ross-ppt-6e/ Application Layer 2-35
HTTP/1.1:
Method types ❖ GET, POST, HEAD
❖ PUT
HTTP/1.0: ▪ Used in conjunction with
❖ GET web publishing tools
▪ uploads file in entity body
❖ POST to path specified in URL
❖ HEAD field
▪ When the client wants ▪ Used by the client to
some information about provide a new or
the document but not replacement document to
the document itself be stored on the server.
▪ The document is included
▪ asks server to leave in the body of the request
requested object out of and will be stored in the
response location defined by the URL
▪ It is similar to GET, but ❖ DELETE
the response from the ▪ Used to remove a
server does not contain document on the server
the body. ▪ deletes file specified in the
URL field Application Layer 2-36
http://gaia.cs.umass.edu/kurose-ross-ppt-6e/
HTTP response message
status line
Version Status code Phrase
(protocol
status code HTTP/1.1 200 OK\r\n
status phrase) Date: Sun, 26 Sep 2010 20:09:20 GMT\r\n
Server: Apache/2.0.52 (CentOS)\r\n
Last-Modified: Tue, 30 Oct 2007 17:00:02
GMT\r\n
header ETag: "17dc6-a5c-bf716880"\r\n
lines Accept-Ranges: bytes\r\n
Content-Length: 2652\r\n
Keep-Alive: timeout=10, max=100\r\n
Connection: Keep-Alive\r\n
Content-Type: text/html;
charset=ISO-8859-1\r\n
\r\n
data, e.g., data data data data data ...
requested
HTML file
Body Body
Header Description
Cache-control Specifies information about caching
Connection Shows whether the connection should be closed
or not
Date Shows the current date
MIME-version Shows the MIME version used
Upgrade Specifies the preferred communication protocol
Header Description
Accept Shows the media format the client can accept
Accept-charset Shows the character set the client can handle
Accept-encoding Shows the encoding scheme the client can handle
Accept-language Shows the language the client can accept
Authorization Shows what permissions the client has
From Shows the email address of the user
Host Shows the host and port number of the client
If-modified-since Send the document if newer than specified date
If-match Send the document only if it matches given tag
If-non-match Send the document only if it does not match given tag
Header Description
Accept-range Shows if server accepts the range requested by the
client
Age Shows the age of the document
Public Shows the specified list of methods
Retry-after Specifies the date after which the server is available
Server Shows server name and version number
Header Description
Allow List valid methods that can be used with a URL
Content-encoding Specifies the encoding scheme
Content-language Specifies the language
Content-length Shows the length of the document
Content-range Specifies the range of the document
Content-type Specifies the media type
Etag Gives an entity tag
expires Gives the date and time when contents may change
Last-modified Gives the date and time of the last change
location Specifies the location of the created or moved
document
client server
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
▪ Store a copy
http://gaia.cs.umass.edu/kurose-ross-ppt-6e/ Application Layer 2-61
More about Web caching
❖ cache acts as both why Web caching?
client and server ❖ reduce response time
▪ server for original for client request
requesting client
▪ client to origin server ❖ reduce traffic on an
❖ typically cache is institution’s access link
installed by ISP
(university, company,
residential ISP)
local web
cache
above lets you send email without using email client (reader)
A: doesn’t scale!
resolution example
2
3
❖ host at cis.poly.edu TLD DNS server
4
wants IP address for
gaia.cs.umass.edu 5
gaia.cs.umass.edu
type=A type=CNAME
▪ name is hostname ▪ name is alias name for some “canonical”
▪ value is IP address (the real) name
▪ value is canonical name
▪ Provide standard hostname to IP
▪ Provide querying hosts the canonical name
address mapping
for a host name
▪ (relay1.bar.foo.com, 145.37.93.126, A)
▪ www.ibm.com is really
servereast.backup2.ibm.com
type=NS ▪ (foo.com, relay1.bar.foo.com, CNAME)
▪ name is domain (e.g., foo.com)
▪ value is hostname of authoritative type=MX
name server for this domain ▪ value is canonical name of a
▪ Used to route DNS queries further mailserver associated with alias
along in the query chain host-name name
▪ (foo.com, dns.foo.com, NS) ▪ (foo.com, mail.bar.foo.com, MX)
▪ Allow hostnames of mail servers to
have simple aliases Application Layer 2-104
http://gaia.cs.umass.edu/kurose-ross-ppt-6e/
DNS protocol, messages
❖ query and reply messages, both with same
message format 2 bytes 2 bytes
identification flags
12 bytes
# questions # answer RRs
Header section
# authority RRs # additional RRs
time to distribute F
to N clients using
P2P approach
increases linearly in N … … but so does this, as each peer brings service capacity
Alice arrives …
❖ DHT paradigm
❖ Peer churn
❖ Any peer will also be allowed to insert new (key, value) pairs
into the database
❖ Distributed Hash Table (DHT) – Distributed Database
3 (0011)
15
(1111)
4 (0100)
12
(1100) 5 (0101)
Tradeoff between 15
❖Number of
value
neighbors each 4
peer has to track
❖Number of 12
messages that 5
DHT needs to
send to resolve as 10
single query 8
http://gaia.cs.umass.edu/kurose-ross-ppt-6e/ Application Layer 2-138
Circular DHT with shortcuts
1 What is the value for
key 11?
3
15 value
4
12
5
10
8
• 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
application application
proce socket proce controlled by
ss ss app developer
transport transport
network network controlled
link link by OS
Internet
physical physical
write reply to
serverSocket read datagram from
specifying clientSocket
client address,
port number close
clientSocket
print modifiedMessage
clientSocket.close()
http://gaia.cs.umass.edu/kurose-ross-ppt-6e/ Application Layer 2-152
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
client TCP
socket
client TCP
socket
write reply to
connectionSocket read reply from
clientSocket
close
connectionSocket close
clientSocket