Section-23-2 1+2 2
Section-23-2 1+2 2
Application Layer
2: Application Layer 2
Chapter 2: Application Layer
Our goals: learn about protocols
conceptual, by examining
implementation popular application-
aspects of network level protocols
application HTTP
protocols FTP
transport-layer
SMTP / POP3 / IMAP
DNS
service models
programming
client-server
network applications
paradigm socket API
peer-to-peer
paradigm
2: Application Layer 3
Some network apps
e-mail voice over IP
web real-time video
instant messaging conferencing
remote login grid computing
P2P file sharing
multi-user network
games
streaming stored
video clips
2: Application Layer 4
Creating a network app applicatio
n
transport
network
2: Application Layer 6
Application architectures
Client-server
Peer-to-peer (P2P)
Hybrid of client-server and P2P
2: Application Layer 7
Client-server architecture
server:
always-on host
permanent IP address
server farms for
scaling
clients:
communicate with server
client/server may be intermittently
connected
may have dynamic IP
addresses
do not communicate
directly with each other
2: Application Layer 8
Pure P2P architecture
no always-on server
arbitrary end systems
directly communicatepeer-peer
peers are
intermittently
connected and change
IP addresses
2: Application Layer 9
Hybrid of client-server and
P2P
Skype
voice-over-IP P2P application
centralized server: finding address of
remote party:
client-client connection: direct (not through
server)
Instant messaging
chatting between two users is P2P
centralized service: client presence
detection/location
• user registers its IP address with central
server when it comes online
• user contacts central server to find IP
addresses of buddies
2: Application Layer 10
Processes communicating
Process: program Client process: process
running within a 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). Note: applications
processes in different with P2P architectures
hosts communicate by have client processes
exchanging messages & server processes
2: Application Layer 11
App-layer protocol defines
Types of messages Public-domain
exchanged, protocols:
e.g., request, response defined in RFCs
Message syntax: allows for
what fields in messages
interoperability
& how fields are
delineated e.g., HTTP, SMTP
Message semantics Proprietary protocols:
meaning of information e.g., Skype
in fields
Rules for when and
how processes send &
respond to messages
2: Application Layer 12
What transport service does an app
need?
Data loss Throughput
some apps (e.g., audio) some apps (e.g., multimedia)
2: Application Layer 13
Transport service requirements of common
apps
2: Application Layer 14
Internet transport protocols services
Application Underlying
Application layer protocol transport protocol
2: Application Layer 16
Chapter 2: Application layer
2.1 Principles of 2.6 P2P applications
network applications 2.7 Socket
app architectures programming with TCP
app requirements 2.8 Socket
2.2 Web and HTTP
programming with
2.4 Electronic Mail UDP
SMTP, POP3, IMAP
2.5 DNS
2: Application Layer 17
Web and HTTP
First some jargon
Web page consists of objects
Object can be HTML file, JPEG image, Java
applet, audio file,…
Web page consists of base HTML-file which
includes several referenced objects
Each object is addressable by a URL
Example URL:
www.someschool.edu/someDept/pic.gif
2: Application Layer 18
HTTP overview
HTTP: hypertext
transfer protocol HT
TP
requ
Web’s application layer H
PC running TT est
Pr
protocol Explorer esp
ons
client/server model e
2: Application Layer 19
HTTP overview (continued)
Uses TCP: HTTP is “stateless”
client initiates TCP server maintains no
connection (creates information about
socket) to server, port 80 past client requests
server accepts TCP
connection from client aside
Protocols that maintain
HTTP messages “state” are complex!
(application-layer protocol past history (state) must
messages) exchanged be maintained
between browser (HTTP if server/client crashes,
client) and Web server
their views of “state”
(HTTP server)
may be inconsistent,
TCP connection closed
must be reconciled
2: Application Layer 20
HTTP connections
Nonpersistent HTTP Persistent HTTP
At most one object is Multiple objects can
sent over a TCP be sent over single
connection. TCP connection
between client and
server.
2: Application Layer 21
Nonpersistent HTTP
(contains text,
Suppose user enters URL www.someSchool.edu/someDepartment/home.index
references to 10
jpeg images)
2: Application Layer 23
Non-Persistent HTTP: Response
time
Definition of RTT: time for a
small packet to travel
from client to server and
back. initiate TCP
Response time: connection
RTT
one RTT to initiate TCP
request
connection file
one RTT for HTTP request time to
RTT
transmit
and first few bytes of file
file
HTTP response to return received
file transmission time
total = 2RTT+transmit time time time
2: Application Layer 24
Persistent HTTP
2: Application Layer 25
HTTP request message
two types of HTTP messages: request,
response
HTTP request message:
ASCII (human-readable format)
request line
(GET, POST, GET /somedir/page.html HTTP/1.1
HEAD commands) Host: www.someschool.edu
User-agent: Mozilla/4.0
header Connection: close
lines Accept-language:fr
Carriage return,
line feed (extra carriage return, line feed)
indicates end
of message
2: Application Layer 26
HTTP request message: general
format
2: Application Layer 27
Uploading form input
Post method:
Web page often
includes form input URL method:
Input is uploaded to Uses GET method
server in entity body Input is uploaded in
URL field of request
line:
www.somesite.com/animalsearch?monkeys&banana
2: Application Layer 28
Method types
HTTP/1.0 HTTP/1.1
GET GET, POST, HEAD
POST PUT
HEAD uploads file in entity
body to path specified
asks server to leave
in URL field
requested object out
of response DELETE
deletes file specified
in the URL field
2: Application Layer 29
HTTP response message
status line
(protocol
status code HTTP/1.1 200 OK
status phrase) Connection close
Date: Thu, 06 Aug 1998 12:00:15 GMT
header Server: Apache/1.3.0 (Unix)
lines Last-Modified: Mon, 22 Jun 1998 …...
Content-Length: 6821
Content-Type: text/html
2: Application Layer 30
HTTP response status codes
In first line in server->client response message.
A few sample codes:
200 OK
request succeeded, requested object later in this
message
301 Moved Permanently
requested object moved, new location specified later
in this message (Location:)
400 Bad Request
request message not understood by server
404 Not Found
requested document not found on this server
505 HTTP Version Not Supported 2: Application Layer 31
Trying out HTTP (client side) for yourself
2: Application Layer 32
User-server state: cookies
Example:
Many major Web sites
Susan always access
use cookies
Four components: Internet always from PC
visits specific e-
1) cookie header line of
HTTP response commerce site for first
message time
2) cookie header line in when initial HTTP
HTTP request
message requests arrives at site,
3) cookie file kept on site creates:
user’s host, managed unique ID
by user’s browser
entry in backend
4) back-end database at
Web site database for ID
2: Application Layer 33
Cookies: keeping “state” (cont.)
client server
ebay 8734
usual http request
Amazon server
msg
cookie file usual http responsecreates ID
Set-cookie: 1678 1678 for user create
ebay 8734 entry
amazon 1678
usual http request
msg cookie- access
cookie: 1678 specific
one week later: usual http response action backend
msg database
access
ebay 8734 usual http request
amazon 1678 msg cookie-
cookie: 1678 spectific
usual http response action
msg
2: Application Layer 34
Cookies (continued)
aside
What cookies can bring: Cookies and privacy:
cookies permit sites to
authorization
learn a lot about you
shopping carts
you may supply name
recommendations and e-mail to sites
user session state
(Web e-mail)
How to keep “state”:
protocol endpoints: maintain
state at sender/receiver over
multiple transactions
cookies: http messages carry
state
2: Application Layer 35
Web caches (proxy server)
Goal: satisfy client request without involving origin server
2: Application Layer 36
More about Web caching
cache acts as both Why Web caching?
client and server reduce response time
typically cache is for client request
installed by ISP reduce traffic on an
(university, institution’s access
company, residential link.
ISP) Internet dense with
caches: enables
“poor” content
providers to
effectively deliver
content (but so does
P2P file sharing)
2: Application Layer 37
Caching example
origin
Assumptions servers
average object size = 100,000
bits public
Internet
avg. request rate from
institution’s browsers to origin
servers = 15/sec
delay from institutional router 1.5 Mbps
to any origin server and back access link
to router = 2 sec institutional
Consequences network
10 Mbps LAN
utilization on LAN = 15%
utilization on access link = 100%
total delay = Internet delay +
access delay + LAN delay institutional
= 2 sec + minutes + milliseconds cache
2: Application Layer 38
Caching example (cont)
origin
possible solution servers
increase bandwidth of
public
access link to, say, 10 Mbps Internet
consequence
utilization on LAN = 15%
utilization on access link = 10 Mbps
15% access link
Total delay = Internet delay +
institutional
access delay + LAN delay network
10 Mbps LAN
= 2 sec + msecs + msecs
often a costly upgrade
institutional
cache
2: Application Layer 39
Caching example (cont)
origin
possible solution: install servers
cache public
suppose hit rate is 0.4 Internet
consequence
40% requests will be
satisfied almost
immediately 1.5 Mbps
60% requests satisfied by access link
origin server institutional
utilization of access link
network
reduced to 60%, resulting in 10 Mbps LAN
negligible delays (say 10
msec)
total avg delay = Internet
delay + access delay + LAN institutional
delay = .6*(2.01) secs cache
+ .4*milliseconds < 1.4
secs
2: Application Layer 40
Conditional GET