0% found this document useful (0 votes)
10 views30 pages

Application Layer in Computer Networks

Uploaded by

meherandanish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views30 pages

Application Layer in Computer Networks

Uploaded by

meherandanish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Computer Networks (EC-330)

Lecture 2 – Application Layer


Muhammad Salman, Ph.D.
msalman@[Link]
Chapter 2: outline
2.1 principles of network 2.6 P2P applications
applications 2.7 socket programming
2.2 Web and HTTP with UDP and TCP
2.3 FTP
2.4 electronic mail
▪ SMTP, POP3, IMAP
2.5 DNS

Application Layer 2-2


Some network apps
❖ e-mail ❖ voice over IP (e.g., Skype)
❖ web ❖ real-time video
❖ text messaging conferencing
❖ remote login ❖ social networking
❖ P2P file sharing ❖ search
❖ multi-user network games ❖ …
❖ streaming stored video ❖ …
(YouTube, Hulu, Netflix)

Application Layer 2-3


Creating a network app application
transport
network
data link

write programs that: physical

❖ run on (different) end systems


❖ communicate over network
❖ e.g., web server software
communicates with browser
software
no need to write software for application

network-core devices transport


network
data link application
❖ network-core devices do not physical transport
network
run user applications data link
physical

❖ applications on end systems


allows for rapid app
development, propagation

Application Layer 2-4


Application architectures
possible structure of applications:
❖ client-server
❖ peer-to-peer (P2P)

Application Layer 2-5


Client-server architecture
server:
❖ always-on host
❖ permanent IP address
❖ data centers for scaling

clients:
❖ communicate with server
client/server ❖ may be intermittently
connected
❖ may have dynamic IP
addresses
❖ do not communicate directly
with each other

Application Layer 2-6


P2P architecture
❖ no always-on server peer-peer
❖ arbitrary end systems
directly communicate
❖ 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

Application Layer 2-7


Hybrid of client-server and P2P
Napster
▪ File transfer P2P
▪ File search centralized:
• Peers register content at central server
• Peers query same central server to locate content
Instant messaging
▪ Chatting between two users is P2P
▪ Presence detection/location centralized:
• User registers its IP address with central server
when it comes online
• User contacts central server to find IP addresses of
buddies

2-8
Extra Learning
▪ Please watch the following lecture (there will be
5% bonus marks in mid/final exams from the
following series of lectures):

• Lecture (03): Socket Programming in C

Introduction 1-9
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 Layer 2-10


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.,
[Link]/someDept/[Link]

host name path name

Application Layer 2-11


Web and HTTP

Application Layer 2-12


HTTP overview
HTTP: hypertext
transfer protocol
❖ Web’s application layer
protocol PC running
❖ client/server model Firefox browser

▪ client: browser that


requests, receives,
(using HTTP protocol) server
and “displays” Web running
objects Apache Web
▪ server: Web server server
sends (using HTTP
protocol) objects in iphone running
response to requests Safari browser

Application Layer 2-13


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 be
messages) exchanged maintained
between browser (HTTP
❖ if server/client crashes, their
client) and Web server views of “state” may be
(HTTP server) inconsistent, must be
❖ TCP connection closed reconciled

Application Layer 2-14


HTTP connections
non-persistent HTTP persistent HTTP
❖ at most one object ❖ multiple objects can
sent over TCP be sent over single
connection TCP connection
▪ connection then between client, server
closed
❖ downloading multiple
objects required
multiple connections

Application Layer 2-15


Non-persistent HTTP
suppose user enters URL: (contains text,
[Link]/someDepartment/[Link] references to 10
jpeg images)
1a. HTTP client initiates TCP
connection to HTTP server
(process) at 1b. HTTP server at host
[Link] on port [Link] waiting
80 for TCP connection at port 80.
“accepts” connection, notifying
2. HTTP client sends HTTP request client
message (containing URL) into
TCP connection socket. 3. HTTP server receives request
Message indicates that client message, forms response
wants object message containing requested
someDepartment/[Link] object, and sends message into
its socket
time
Application Layer 2-16
Non-persistent HTTP (cont.)
4. HTTP server closes TCP
connection.
5. HTTP client receives response
message containing html file,
displays html. Parsing html file,
finds 10 referenced jpeg objects

time
6. Steps 1-5 repeated for each of
10 jpeg objects

Application Layer 2-17


Non-persistent HTTP: response time

RTT (definition): time for a


small packet to travel from
client to server and back
HTTP response time: initiate TCP
❖ one RTT to initiate TCP
connection

connection RTT

❖ one RTT for HTTP request


request
file
and first few bytes of HTTP RTT
time to
response to return transmit
file
❖ file transmission time file
received
❖ non-persistent HTTP
response time =
time time
2RTT+ file transmission
time

Application Layer 2-18


Persistent HTTP

non-persistent HTTP issues: persistent HTTP:


❖ requires 2 RTTs per object ❖ server leaves connection
❖ OS overhead for each TCP open after sending
connection response
❖ browsers often open ❖ subsequent HTTP
parallel TCP connections messages between same
to fetch referenced objects client/server sent over
open connection
❖ client sends requests as
soon as it encounters a
referenced object
❖ as little as one RTT for all
the referenced objects

Application Layer 2-19


HTTP request message

❖ two types of HTTP messages: request, response


❖ HTTP request message:
▪ ASCII (human-readable format)
carriage return character
line-feed character
request line
(GET, POST, PUT, GET /[Link] HTTP/1.1\r\n
DELETE HEAD Host: [Link]\r\n
User-Agent: Firefox/3.6.10\r\n
commands)
Accept: text/html,application/xhtml+xml\r\n
header Accept-Language: en-us,en;q=0.5\r\n
lines Accept-Encoding: gzip,deflate\r\n
Accept-Charset: ISO-8859-1,utf-8;q=0.7\r\n
carriage return, Keep-Alive: 115\r\n
Connection: keep-alive\r\n
line feed at start
\r\n
of line indicates
end of header lines
Application Layer 2-20
HTTP request message: general format

method sp URL sp version cr lf request


line
header field name value cr lf
header
~
~ ~
~ lines

header field name value cr lf


cr lf

~
~ entity body ~
~ body

Application Layer 2-21


Method types
HTTP/1.0: HTTP/1.1:
❖ GET ❖ GET, POST, HEAD
❖ POST ❖ PUT
❖ HEAD ▪ uploads file in entity
▪ asks server to leave body to path specified
requested object out in URL field
of response ❖ DELETE
▪ deletes file specified in
the URL field

Application Layer 2-22


HTTP response message
status line
(protocol
status code HTTP/1.1 200 OK\r\n
status phrase) Date: Sun, 26 Sep 2010 [Link] GMT\r\n
Server: Apache/2.0.52 (CentOS)\r\n
Last-Modified: Tue, 30 Oct 2007 [Link]
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 2-23
HTTP response status codes
❖ status code appears in 1st line in server-to-
client response message.
❖ some sample codes:
200 OK
▪ request succeeded, requested object later in this msg
301 Moved Permanently
▪ requested object moved, new location specified later in this msg
(Location:)
400 Bad Request
▪ request msg not understood by server
404 Not Found
▪ requested document not found on this server
505 HTTP Version Not Supported
Application Layer 2-24
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
▪ object in cache: cache client
origin
returns object server
▪ else cache requests
object from origin
server, then returns
object to client
client origin
server

Application Layer 2-25


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 ❖ Internet dense with
(university, company, caches: enables “poor”
residential ISP) content providers to
effectively deliver
content (so too does
P2P file sharing)

Application Layer 2-26


Caching example:
assumptions:
▪ avg object size: 100K bits
▪ avg request rate from browsers to origin
origin servers:15 req. /sec servers
public
▪ avg data rate to browsers: 1.50 Mbps Internet
▪ RTT from institutional router to any
origin server: 2 sec
▪ access link rate: 1.54 Mbps
consequences: 1.54 Mbps
▪ LAN utilization: 0.15% access link
▪ access link utilization = 97.4% institutional
▪ total delay = Internet delay + access network
1 Gbps LAN
delay + LAN delay problem!
= 2 sec + minutes + usecs

Application Layer 2-27


Caching example: fatter access link
assumptions:
▪ avg object size: 100K bits
▪ avg request rate from browsers to origin
origin servers:15/sec servers
public
▪ avg data rate to browsers: 1.50 Mbps Internet
▪ RTT from institutional router to any
origin server: 2 sec
▪ access link rate: 1.54 Mbps
consequences: 154 Mbps 1.54 Mbps
154 Mbps
▪ LAN utilization: 15% access link
▪ access link utilization = 97.4% institutional
▪ total delay = Internet delay + access network
delay + LAN delay 9.74% 1 Gbps LAN
= 2 sec + minutes + usecs

msecs

Cost: increased access link speed (not cheap!)


Application Layer 2-28
Caching example: install local cache
assumptions:
▪ avg object size: 100K bits
▪ avg request rate from browsers to origin
origin servers:15/sec servers
public
▪ avg data rate to browsers: 1.50 Mbps Internet
▪ RTT from institutional router to any
origin server: 2 sec
▪ access link rate: 1.54 Mbps
1.54 Mbps
❖ Alternative Solution: access link

▪ web cache (cheap!) institutional


network
How to compute link 1 Gbps LAN
utilization, delay? local web
cache

Application Layer 2-29


Caching example: install local cache
Calculating access link
utilization, delay with cache:
origin
❖ suppose cache hit rate is 0.4 servers
▪ 40% requests satisfied at cache, public
60% requests satisfied at origin Internet

▪ access link utilization:


▪ 60% of requests use access link
▪ data rate to browsers over access link 1.54 Mbps
= 0.6*1.50 Mbps = .9 Mbps access link
▪ utilization = 0.9/1.54 = .58
institutional
network
1 Gbps LAN
▪ total delay
▪ = 0.6 * (delay from origin servers) +0.4 local web
* (delay when satisfied at cache)
▪ = 0.6 (2) + 0.4 (~msecs) = ~ 1.2 secs cache
▪ less than with 154 Mbps link (and
cheaper too!)

Application Layer 2-30

You might also like