Application Layer Protocols Overview
Application Layer Protocols Overview
2:
Application
Layer
2: Application 1
Layer
Chapter 2: Application
layer
❒ 2.1 Principles of network
applications
❒ 2.2 Web and HTTP
❒ 2.3 FTP
❒ 2.4 Electronic Mail
SMTP, POP3, IMAP
❒ 2.5 DNS
❒ 2.6 P2P file sharing
❒ 2.9 Building a Web server
If we have time
❒ 2.7Socket programming with TCP
❒ 2.8 Socket programming with UDP
2: Application 2
Layer
Chapter 2: Application
layer
❒ 2.1 Principles of ❒ 2.6 P2P file sharing
network ❒ 2.7 Socket
applications programming with
❒ 2.2 Web and HTTP TCP
❒ 2.3 FTP ❒ 2.8 Socket
❒ 2.4 Electronic Mail programming with
SMTP, POP3, IMAP UDP
❒ 2.5 DNS ❒ 2.9 Building a
Web server
2: Application 3
Layer
Some network
apps
❒ Web ❒ Internet
❒ E-mail telephone
❒ Instant ❒ Real-time
messaging video
❒ Remote login conference
❒ P2P file sharing ❒ Massive
parallel
❒ Multi-user
computing
network games
❒ Streaming
stored video
clips
An application runs on a particular
protocol 2: Application 4
Layer
Creating a network
app
Write programs that applicatio
n
run on different end transport
network
systems data link
physical
communicate with each
other over a network.
e.g., Web: Web server
software communicates
with browser software
No software written for
applicatio
devices in network applicatio
n
n
transport
transport
core network
data link
network
data link
physical
Network core devices physical
Low cost ??
3 major
challenges:
a. ISP Friendly
b. Security
c. Incentives
8
P2P Architecture
Torrenting is a peer-to-peer (P2P) file-sharing protocol that allows users to distribute and
download files over the internet without relying on a central server. The key to torrenting is
its decentralized nature, where files are shared directly between users rather than being
hosted on a central location.
● A torrent file (.torrent) is a small file containing metadata about the file you want
to download (e.g., its name, size, and the server locations of the peers sharing it).
2. Torrent Client
● To download files via torrent, you need a torrent client, such as BitTorrent or
uTorrent. The client uses the information in the torrent file or magnet link to
connect to other users (peers) who have the file or parts of it.
P2P Architecture
● Seeders: Users who have the complete file and are sharing it with others.
● Peers: Users who are downloading the file but may not have the complete file
yet.
● Leechers: Users who are downloading the file but are not sharing parts of it back
to others (which can be seen as bad torrent etiquette).
● Instead of downloading the entire file from one source, torrenting splits the file
into small parts (or chunks). Your torrent client will download these parts from
multiple seeders and peers simultaneously. This allows for faster downloads,
especially if there are many seeders.
● As you download chunks of the file, you also upload them to others. This mutual
sharing speeds up the overall download
Processes
communicating Client process:
Process: program
running within a process that
host. initiates
❒ within same host, two communication
processes Server process:
communicate using process that waits
inter-process to be contacted
communication ❒ Note: applications
(defined by OS). with P2P
❒ processes in architectures have
different hosts client processes &
communicate by server processes
exchanging
2: Application Layer 9
messages
Sockets : Interfaces between the
Application layers and the Transport layers
2: Application
Layer
Chapter 2: Application
layer
❒ 2.1 Principles of ❒ 2.6 P2P file sharing
network ❒ 2.7 Socket
applications programming with
app architectures TCP
app requirements ❒ 2.8 Socket
❒ 2.2 Web and HTTP programming with
❒ 2.4 Electronic Mail UDP
SMTP, POP3, IMAP ❒ 2.9 Building a
❒ 2.5 DNS Web server
2: Application
Layer
Web and HyperText Transfer
Protocol (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:
[Link]/someDept/[Link]
host path
name name
2: Application
Layer
HTTP
overview
HTTP: hypertext
transfer
protocol PC
❒ Web’s application running
Explorer
layer protocol
❒ client/server model
client: browser that Server
requests, receives, running
Apache
“displays” Web Web
objects server
server: Web server Mac
sends objects in running
response to Navigator
requests
❒ HTTP 1.0: RFC 1945 2: Application
Layer
HTTP overview
(continued) HTTP is “stateless”
Uses TCP:
❒ client initiates TCP ❒ server maintains
connection (creates no information
socket) to server, port about past client
80 requests
❒ server accepts TCP Protocols thataside
connection from client maintain
❒ HTTP messages “state”
❒ are complex!
past history (state)
(application- layer must be maintained
protocol messages)
❒ if server/client crashes,
exchanged between
their views of “state”
browser (HTTP client) and
may be inconsistent,
Web server (HTTP server)
must be reconciled
❒ TCP connection closed
2: Application
Layer
HTTP
connections
Nonpersistent HTTP Persistent HTTP
❒ At most one object ❒ Multiple objects
is sent over a TCP can be sent over
connection. single TCP
❒ HTTP/1.0 uses connection
nonpersistent between client
HTTP and server.
❒ Takes more time ❒ HTTP/1.1 uses
than persistent persistent
HTTP connections in
default mode
2: Application
Layer
(contains text,
Nonpersistent references to 10
HTTP jpeg images)
[Link]/someDepartment/[Link]
Suppose user enters URL
1a. HTTP client initiates TCP
connection to HTTP server
(process) at
1b. HTTP server at host
[Link] waiting
[Link] on port 80
for TCP connection at port
80. “accepts” connection,
notifying client
2. HTTP client sends HTTP
request message
(containing URL) into TCP 3. HTTP server receives
connection socket. request message, forms
Message indicates that response message
client wants object containing requested
someDepartment/[Link] object, and sends message
into its socket
tim
e 2: Application
Layer
Nonpersistent 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
tim
6. Steps 1-5 repeated for
e each of 10 jpeg objects
2: Application
Layer
Response time
modeling
Definition of RRT(round
trip time): time to
send a small packet
to travel
from client to initiate TCP
(GET,
request line GET /somedir/[Link] HTTP/1.1
POST,
HEAD Host: [Link]
commands)
header User-agent: Mozilla/4.0
2: Application
Layer
Method
types
HTTP/1.0 HTTP/1.1
❒ GET ❒ GET, POST, HEAD
❒ POST ❒ PUT
❒ HEAD uploads file in entity
body to path
asks server to leave
specified in URL
requested object out
field
of response
❒ DELETE
deletes file specified
in the URL field
2: Application
Layer
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
2: Application
505 HTTP Version Not Supported Layer
User-Server Interaction:
Authorization and Cookies
❒ HTTP server is stateless – simplifies server
design
❒ Sometime server needs to identify user
❒ Two mechanism for identification:
[Link] &
2. CooKies
Authorization:
1)Provide username and password to access
documents on
server
2) Status code 401: Authorization Required
2: Application
Layer
User-server state:
cookies
Many major Web Example:
sites use cookies Susan access
Four components: Internet always
from same PC
1) cookie header line
She visits a specific e-
in the HTTP
commerce site for
response
first time
message
When initial HTTP
2) cookie header
requests arrives at
line in HTTP request
site, site creates a
message
unique ID and
3) cookie file kept creates an entry in
on user’s host and backend database for
managed by user’s ID
browser
4) back-end 2: Application
Layer
Cookies: keeping “state”
(cont.)
clien server
Cookie file
t usual http request server
msg
usual http response creates ID
ebay: 8734 1678 for
+
Set-cookie: 1678 user
Cookie file
usual http request msg
amazon: 1678 cookie
ebay: 8734 cookie: 1678 -
usual http response specifi
one week msg c
later: action
usual http request msg cookie-
Cookie file cookie: 1678 spectific
amazon: 1678 usual http response action
ebay: 8734 msg
2: Application
Layer
Cookies
(continued)
What cookies can
aside
Cookies and privacy:
bring: ❒ cookies permit sites
❒ authorization to learn a lot about
❒ shopping carts you
❒ recommendations ❒ you may supply
❒ user session name and e-mail
state (Web e- to sites
mail) ❒ search engines use
redirection &
cookies to learn
yet more
❒ advertising
companies obtain
2: Application
Layer
Conditional
GET
❒ Goal: don’t send object if cach serve
cache has up-to-date e r
HTTP request msg
cached version If-modified-since: object
❒ cache: specify date of <date>
not
cached copy in HTTP modifie
request If-modified- HTTP response
d
HTTP/1.1
since:
304 Not Modified
<date>
❒ server: response contains no
object if cached copy is HTTP request msg
If-modified-since:
up- to-date: object
<date>
HTTP/1.0 304 Not modifie
Modified HTTP response d
HTTP/1.1 200 OK
<data>
2: Application
Layer
Chapter 2: Application
layer
❒ 2.1 Principles of ❒ 2.6 P2P file sharing
network ❒ 2.7 Socket
applications programming with
❒ 2.2 Web and HTTP TCP
❒ 2.3 FTP ❒ 2.8 Socket
❒ 2.4 Electronic Mail programming with
SMTP, POP3, IMAP UDP
❒ 2.5 DNS ❒ 2.9 Building a
Web server
2: Application
Layer
FTP: the file transfer
protocol
FTP file transfer
FTP FTP
user client serve
interfac
r
user e
at local remote
host file file
system system
2: Application
Layer
FTP commands,
responses
Sample commands: Sample return codes
❒ sent as ASCII text over ❒ status code and phrase
control channel (as in HTTP)
❒ USER username ❒ 331 Username OK,
❒ PASS password password required
❒ 125 data connection
❒ LIST return list of file in
already open;
current directory
transfer starting
❒ RETR filename ❒ 425 Can’t open data
retrieves (gets) file connection
❒ STOR filename ❒ 452 Error writing
stores (puts) file onto file
remote host
2: Application
Layer
Chapter 2: Application
layer
❒ 2.1 Principles of ❒ 2.6 P2P file sharing
network ❒ 2.7 Socket
applications programming with
❒ 2.2 Web and HTTP TCP
❒ 2.3 FTP ❒ 2.8 Socket
❒ 2.4 Electronic Mail programming with
SMTP, POP3, IMAP UDP
❒ 2.5 DNS ❒ 2.9 Building a
Web server
2: Application
Layer
Electronic outgoin
g message
One of the Internet’s most
Mailapplications to date
important
killer use
queue
user mailbox
r
agen
Three major mai t
user
components: l
serve
agen
❒ user agents r
t
SMTP mail
❒ mail servers
serve user
❒ simple mail transfer SMTP r agen
protocol: SMTP t
SMTP
User Agent mai user
2: Application
Layer
SMTP: final
words
❒ SMTP uses persistent Comparison with
connections HTTP:
❒ SMTP requires message
(header & body) to be in ❒ HTTP: pull
7- bit ASCII ❒ SMTP: push
❒ SMTP server uses ❒ both have ASCII
[Link] to command/response
determine end of interaction, status
message codes
❒ HTTP: each object
encapsulated in its
own response msg
❒ SMTP: multiple objects
sent in multipart msg
2: Application
Layer
Mail access
protocols
SMTP SMTP
user
access use
protoco r
agen
t
agen l
t
sender’s receiver’s
mail mail
server server
❒ SMTP: delivery/storage to receiver’s server
❒ Mail access protocol: retrieval from server
POP: Post Office Protocol [RFC 1939]
• authorization (agent <-->server) and download
IMAP: Internet Mail Access Protocol [RFC
1730]
• more features (more complex)
• manipulation of stored msgs on server
HTTP: Hotmail , Yahoo! Mail, etc.
Email demands both push (SMTP) and pull (POP3/IMAP)
2: Application
Layer
POP3 S: +OK POP3 server ready
protocol C:
S:
user bob
+OK
authorization phase
C: pass hungry
❒ client commands: S: +OK user successfully logged
user: declare on
username C: list
pass: password S: 1 498
S: 2 912
❒ server responses
S: .
🔾 +OK C: retr 1
-ERR S: <message 1
contents> S: .
transaction phase, C: dele 1
client: C: retr 2
❒ list: list message S: <message 1 contents>
numbers S: .
C: dele 2
❒ retr: retrieve message C: quit
by number S: +OK POP3 server signing off
2: Application
❒ dele: delete Layer
POP3 (more) and
IMAP
More about POP3 IMAP
❒ Previous example ❒ Keep all messages
uses “download in one place: the
and delete” mode. server
❒ Bob cannot re-read ❒ Allows user to
e- mail if he organize messages
changes client in folders
❒ “Download-and- ❒ IMAP keeps user
keep”: copies of state across
messages on sessions:
different clients names of folders and
❒ POP3 is mappings between
message IDs and
stateless
folder name
across sessions 2: Application
Layer
Chapter 2: Application
layer
❒ 2.1 Principles of ❒ 2.6 P2P file sharing
network ❒ 2.7 Socket
applications programming with
❒ 2.2 Web and HTTP TCP
❒ 2.3 FTP ❒ 2.8 Socket
❒ 2.4 Electronic Mail programming with
SMTP, POP3, IMAP UDP
❒ 2.5 DNS ❒ 2.9 Building a
Web server
2: Application
Layer
DNS: Domain Name
System
Translates hostname to Domain Name System:
IP address ❒ Is a distributed database
implemented in hierarchy
of many name servers
Need a translation
❒ An application-layer
service.
protocol that allows host
and name servers to
communicate in order to
provide translation service
(IP address from host
name).
2: Application
Layer
When browser requests the
URL
[Link]/index.h
tml
2: Application
Layer
DNS
DNS services
❒ Hostname to IP address translation
❒ Host aliasing
Canonical and alias names
❒ Mail server aliasing
❒ Load distribution
Replicated Web servers: set of IP addresses for one
canonical name
2: Application
Layer
Host
Aliasing:
2: Application
Layer
Mail Server
Aliasing:
2: Application
Layer
Load
Distribution:
2: Application
Layer
Distributed, Hierarchical
Database Root DNS Servers
2: Application
Layer
DNS: Root name
servers
❒ contacted by local name server that can not resolve name
❒ The local name server behaves as DNS client and queries
one of the root name servers. If the root name server has
a record for the hostname, it sends a DNS reply to the
local server, and the local server then sends a DNS reply
to the querying host.
a Verisign, Dulles, VA
c Cogent, Herndon, VA (also Los Angeles)
d U Maryland College Park, MD
k RIPE London (also Amsterdam,
g US DoD Vienna, VA
h ARL Aberdeen, MD i AFruatonnkfoumrti)ca,
j Verisign, ( 11 locations) other locations)
Stockholm (plus 3
m WIDE Tokyo
e NASA Mt View, CA
f Internet Software C. Palo Alto,
CA (and 17 other locations)
13 root name
servers
b USC-ISI Marina del Rey, CA
l ICANN Los Angeles, CA worldwide
2: Application
Layer
TLD and Authoritative
Servers
❒ Top-level domain (TLD) servers:
responsible for com, org, net, edu, etc,
and all top-level country domains uk, fr,
ca, jp.
Gives ip address of authoritative DNS server
❒ Authoritative DNS servers:
organization’s DNS servers, providing
authoritative hostname to IP mappings
for organization’s servers (e.g., Web
and mail).
Can be maintained by organization or
service
2: Application
provider Layer
Local Name
Server
❒ Does not strictly belong to hierarchy
❒ Each ISP (residential ISP,
company, university) has one.
Also called “default name server”
❒ When a host makes a DNS query,
query is sent to its local DNS server
Acts as a proxy, forwards query into
hierarchy.
2: Application
Layer
Exampl root DNS
server
e 2
❒ Host at [Link] 3
TLD DNS
wants IP address 4 server
for
5
[Link]
local DNS
iterated query: server
[Link]
❒ contacted server 7 6
1 8
replies with name
of server to
contact authoritative DNS
server
[Link]
❒ “I don’t know requesting
this name, but host
ask this server” [Link] [Link]
2: Application
Layer
Recursive root DNS
queries
server
recursive query:
2 3
❒ puts burden of
name resolution 7 6
on contacted TLD DNS
name server serv
❒ Every server has
to store the local DNS
server
[Link] 5 4
response
message. 1 8
authoritative DNS
server
[Link]
requesting
host
[Link] [Link]
2: Application
Layer
DNS: caching and updating
records
❒ once (any) name server learns mapping, it
caches
mapping
cache entries timeout (disappear) after
some
time
TLD servers typically cached in local
name servers
• Thus root name servers not often visited
2: Application
Layer
DNS: caching
(cont.)
2: Application
Layer
DNS
records
DNS: distributed db storing resource records
(RR)
RR format: (name, value, type, ttl)
❒ Type=A ❒ Type=CNAME
name is hostname name is alias name for
value is IP some “cannonical” (the
address real) name [Link] is
really
❒ Type=NS [Link]
name is domain
[Link] m
(e.g.
)
value is the hostname of ❒ value is cannonical name
an authoritative value is name of mailserver
Type=MX associated with name
name server.
([Link],[Link],MX)
2: Application
Layer
Inserting records into
DNS
❒ Example: just created startup “Network Utopia”
❒ Register name [Link] at a registrar
(e.g.,
Network Solutions)
Need to provide registrar with names and IP addresses of
your authoritative name server (primary and secondary)
Registrar inserts two RRs into the com TLD server:
2: Application
Layer
Content
Distribution
Web is wonderfully rich in content
Access time of an object can be undesirably slow
and face ‘world wide wait’ for the following
reasons:
Path contains at least one low-speed link.
Path contains at least one congested link causing
long queuing delay.
Web server of the desired content is over loaded.
2: Application
Layer
Caching
example
Assumptions
origi
n
❒ average object size = server
100,000 public
Internet s
bits
❒ avg. request rate from
institution’s browsers to
origin servers = 15/sec 1.5 Mbps
access
❒ delay from institutional link
institutiona
router to any origin server
l
and back to router = 2 10 Mbps
network
LAN
sec
Consequences
❒ total
❒ utilization
delayon LAN== 15%
Internet institutiona
❒ delay + access
utilization delaylink
on access + = l
= LAN
100% delay
2 sec + minutes + cache
milliseconds 2: Application
Layer
Caching example
(cont)
Possible solution
origi
n
❒ increase bandwidth of server
access public
Internet s
link to, say, 10 Mbps
Consequences
❒ utilization on LAN = 100%
❒ utilization on access link = 10 Mbps
access
100% link
❒= Total delay = Internet institutiona
2 sec + msecs
l
❒+ delay
msecs
often a+costly network
10 Mbps
access LAN
upgradedelay + LAN delay
institutiona
l
cache
2: Application
Layer
Caching example
(cont) origi
Install cache n
❒ suppose hit rate server
public
Internet s
is .4
❒ 40% requests will be
Consequence
satisfied almost
❒ 60% requests satisfied
immediately
origin 1.5 Mbps
by access
❒ server
utilization of access link
reduced
link to 60%, resulting institutiona
negligible
in delays (say 10 l
10 Mbps
❒ msec)
total avg network
LAN
delay
+
= .4*(0.01) secs + .6*(2.01)
< 1.4
milliseconds
secs institutiona
secs
l
cache
2: Application
Layer
Content Distribution
Networks(CDNs)
A CDN company provides the content
distribution service to get content with short
delays
2: Application
Layer
Web
Caching
❒ As an example, we use the web to
illustrate caching and other related
issues reques
Web
t
browse
r serve
respons
e r
reques reques
t Web Proxy t
Web
browse
r
cache serve
respons respons
e
r
e
Web Cache Can’t Reduce
Internet Delay
Internet delay=2
Sec
Total delay =
(2 + .01) x 0.6 = 1.2 delay = tens of
Sec ΔAL = milliseconds
72
Δ – traffic
Problems of
caching
❒ Can’t reduce internet delay
❒ Caching proxies do not serve all
Internet users.
❒ Content providers (say, Web
servers) cannot rely on existence
and correct implementation of
caching proxies.
❒ Accounting issues with caching proxies:
Example: [Link] needs to know the
number of hits to the advertisements
displayed on the web page.
Content Distribution Network of
Caches
Web Web
server server
Paren
t
74
Content Distribution Networks
(CDN)
❒ Business Model: A content provider
such as [Link] or Yahoo pays a
CDN company (such as Akamai) to get
its content to the requesting users with
short delays.
❒ A CDN provides a mechanism for
Replicating content on multiple
servers in the Internet
Providing clients with a means to
determine the servers that can
deliver the content fastest.
CDN: Basic
original
Idea content
Replic
a
congested
Replica
Not congested
Client
76
Terminolog
y
❒ Content: Any publicly accessible
combination of text, images, applets,
frames, MP3, video, flash, virtual reality
objects, etc.
❒ Content Provider: Any individual,
organization, or company that has
content that it wishes to make available
to users.
❒ Origin Server: Content provider’s
server , where the content is first
uploaded.
❒ Surrogate Server (sometimes called
edge server): Content distributor’s
server, where the replicated content is
kept.
CDN:
Distribution
❒ The CDN company places hundreds of CDN
servers in Internet hosting centers.
❒ The CDN replicates its customers’ content in
the CDN servers. Whenever, a customer
updates its content (e.g., web page), the
CDN redistributes the fresh content to the
CDN servers.
❒ The CDN provides a mechanism so that when
a user requests content, the content is
provided by the CDN server that can most
rapidly deliver the content to the user.
This can be the closest CDN server to the user
(perhaps in the same ISP as the user) or may be a
CDN:
Distribution Origin server
in North
America
push
content push content
push
CDN server in CDN server in
South
conte Asia
America nt
CDN server
in
Europe
CDN: Functional
Components
❒ Distribution Service
❒ Redirection Service
❒ Accounting and Billing
system
CDN:Distribution
Service
❒ The content provider determines which
of its objects it wants the CDN to
distribute.
❒ The content provider tags and then
pushes this content to a CDN node,
which in turn replicates and pushes
the content to all its CDN servers.
CDN vs. Caching
Proxies
Caching Proxies CDN
Used by ISP to reduce Used by Content Providers
bandwidth consumption. to increase QoS.
2: Application
Layer