Professional Documents
Culture Documents
Communication Networks
EE-357 -TE-54
By Dr Mir Yasir Umair
Assistant Professor, MCS, NUST
Application Layer
Lecture 02
Chapter 2: outline
2.1 principles of network 2.6 P2P applications
applications 2.7 socket programming
o app architectures
with UDP and TCP
o app requirements
2.5 DNS
Application Layer
World Wide Web
The World Wide Web (WWW) is an information space where
documents and other web resources are identified by URLs
(Uniform Resource Locator), interlinked by hypertext links, and can
be accessed via the Internet.
Web standards
• Representation:
o HyperText Markup Language (HTML)
• Transfer:
o HyperText Transfer Protocol (HTTP)
Web and HTTP
First, a review…
• 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, e.g.,
www.someschool.edu/someDept/pic.gif
Application Layer
HTTP overview
HTTP: hypertext
transfer protocol
• Web’s application
layer protocol PC running
• client/server model Firefox browser
o client: browser that
requests, receives,
(using HTTP
protocol) and
“displays” Web server
objects running
o server: Web server Apache Web
sends (using HTTP server
protocol) objects in
response to iphone running
requests Safari browser
Application Layer
HTTP overview (continued)
uses TCP: HTTP is
• client initiates TCP
“stateless”
• server maintains no
connection (creates information about
socket) to server, port 80 past client requests
• server accepts TCP
connection from client aside
• HTTP messages protocols that maintain
(application-layer “state” are complex!
protocol messages) ❖ past history (state) must be
maintained
exchanged between ❖ if server/client crashes, their
browser (HTTP client) and views of “state” may be
Web server (HTTP server) inconsistent, must be
• TCP connection closed reconciled
Application Layer
HTTP connections
non-persistent HTTP persistent HTTP
• at most one object sent • multiple objects
over TCP connection can be sent over
o connection then closed single TCP
• downloading multiple connection
objects required multiple between client,
connections server
Application Layer
Non-persistent HTTP
suppose user enters URL: (contains text,
www.someSchool.edu/someDepartment/home.index references to 10
jpeg images)
Application Layer
Non-persistent HTTP: response time
RTT (definition): time for a
small packet to travel
from client to server and
back
initiate TCP
HTTP response time: connection
• one RTT to initiate TCP RTT
connection request
file
• one RTT for HTTP request time to
and first few bytes of HTTP RTT transmit
response to return file
file
• file transmission time received
• non-persistent HTTP
response time = time time
2RTT+ file transmission time
Application Layer
Persistent HTTP
Application Layer
HTTP Request Message
Reques Method Directory Version
t Line
Get /dir/page.html HTTP/1.1
Host: www.nust.edu.pk Domain
Header Line
Application Layer
Method types
HTTP/1.0: HTTP/1.1:
• GET • GET, POST, HEAD
• POST • PUT
• HEAD o For Publishing as a
o For developers – tool
for debugging a • DELETE
website o deletes file
specified in the URL
field
Application Layer
HTTP response message
status line
(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
Accept-Ranges: bytes\r\n
lines 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
Application Layer
HTTP response status codes
❖ status code appears in 1st line in server-to-
client response message.
❖ some sample codes:
200 OK
o request succeeded, requested object later in this msg
301 Moved Permanently
o requested object moved, new location specified later in
this msg (Location:)
400 Bad Request
o request msg not understood by server
404 Not Found
o requested document not found on this server
505 HTTP Version Not Supported
Application Layer
User-server state:
example:
cookies
many Web sites use
cookies • Susan always access
four components: Internet from PC
1) cookie header line • visits specific e-
of HTTP response commerce site for first
message
time
2) cookie header line
in next HTTP request • when initial HTTP
message requests arrives at site,
3) cookie file kept on site creates:
user’s host, o unique ID
managed by user’s
browser o entry in backend
4) back-end database database for ID
at Web site
Application Layer
Cookies: keeping “state” (cont.)
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
Application Layer
Web caches (proxy server)
goal: satisfy client request without involving origin server
• user sets browser: Web
accesses via cache
• browser sends all HTTP proxy
requests to cache server
client
o object in cache: origin
cache returns object server
Application Layer
More about Web caching
• cache acts as why Web caching?
both client and • reduce response time
for client request
server • reduce traffic on an
o server for original institution’s access
requesting client link
o client to origin server • Internet dense with
• typically cache is caches: enables
installed by ISP “poor” content
providers to
(university, effectively deliver
company, content (so too does
P2P file sharing)
residential ISP)
Application Layer
Caching example:
Application Layer
Caching example: faster access link
Application Layer
Caching example: install local cache
Application Layer
Conditional GET
client server
• Goal: don’t send
object if cache has up-
to-date cached version HTTP request msg
o no object transmission If-modified-since: <date> object
delay not
o lower link utilization HTTP response
modified
• cache: specify date of HTTP/1.0
before
cached copy in HTTP 304 Not Modified
<date>
request
If-modified-since:
<date>
• server: response HTTP request msg
contains no object if If-modified-since: <date> object
cached copy is up-to- modified
date: HTTP response after
HTTP/1.0 304 Not HTTP/1.0 200 OK <date>
Modified
<data>
Application Layer
Example
Application Layer
Thank you
Application Layer
Application Layer