2: Application Layer1
Application architectures
Client-server
Peer-to-peer (P2P)
Hybrid of client-server and P2P
2: Application Layer2
Client-server architecture
server:
always-on host
permanent IP address
server farms for scaling
clients:
communicate with server
may be intermittently
connected
may have dynamic IP
addresses
do not communicate directly
with each other
client/server
In client-server model, any process can act as
Server or Client.
It is not the type of machine, size of the machine,
or its computing power which makes it server;
it is the ability of serving request that makes a
machine a server.
A system can act as Server and Client
simultaneously.
That is, one process is acting as Server and another
is acting as a client.
This may also happen that both client and server
processes reside on the same machine.
Communication
Two processes in client-server model can
interact in various ways:
Sockets
Remote Procedure Calls (RPC)
Sockets
In this paradigm, the process acting as
Server opens a socket using a well-known
(or known by client) port and waits until
some client request comes.
The second process acting as a Client also
opens a socket but instead of waiting for
an incoming request, the client processes
‘requests first’.
Remote Procedure Call
it is a mechanism to call a procedure or a
function available on a remote computer.
RPC is a much older technology than the
Web.
Effectively, RPC gives developers a
mechanism for defining interfaces that can
be called over a network.
2: Application Layer7
Pure P2P architecture
no always-on server
arbitrary end systems
directly communicate
peers are intermittently
connected and change IP
addresses
Highly scalable but
difficult to manage
peer-peer
2: Application Layer8
Hybrid of client-server and P2P
Skype/WhatsAPP/ZOOM
voice-over-IP P2P application
centralized server: finding address of remote
party:
client-client connection: direct (not through
server)
Instant messaging/ WhatsAPP/Telegram
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 Layer9
File distribution: BitTorrent
tracker: tracks peers
participating in torrent
torrent: group of
peers exchanging
chunks of a file
obtain list
of peers
trading
chunks
peer
P2P file distribution
2: Application Layer10
BitTorrent (1)
file divided into 256KB chunks.
peer joining torrent:
has no chunks, but will accumulate them over time
registers with tracker to get list of peers, connects to
subset of peers (“neighbors”)
while downloading, peer uploads chunks to other peers.
peers may come and go
once peer has entire file, it may (selfishly) leave or
(altruistically) remain
2: Application Layer11
BitTorrent (2)
Pulling Chunks
at any given time, different
peers have different
subsets of file chunks
periodically, a peer (Alice)
asks each neighbor for list
of chunks that they have.
Alice sends requests for her
missing chunks
Sending Chunks: tit-for-tat
Alice sends chunks to four
neighbors currently sending
her chunks at the highest
rate
re-evaluate top 4 every 10
secs
every 30 secs: randomly
select another peer, starts
sending chunks
newly chosen peer may
join top 4
“optimistically unchoke”
Peers which have a better upload rate (as compared to the
downloaders) but aren't interested get unchoked.
If they become interested, the downloader with the worst upload rate
gets choked.
If a client has a complete file, it uses its upload rate rather than its
download rate to decide which peers to unchoke.
For optimistic unchoking, at any one time there is a single peer which
is unchoked regardless of its upload rate (if interested, it counts as
one of the four allowed downloaders).
Which peer is optimistically unchoked rotates every 30 seconds.
Newly connected peers are three times as likely to start as the
current optimistic unchoke as anywhere else in the rotation.
This gives them a decent chance of getting a complete piece to upload.
2: Application Layer13
BitTorrent: Tit-for-tat
(1) Alice “optimistically unchokes” Bob
(2) Alice becomes one of Bob’s top-four providers; Bob reciprocates
(3) Bob becomes one of Alice’s top-four providers
With higher upload rate,
can find better trading
partners & get file faster!
2: Application Layer14
Processes communicating
Process: program running
within a host.
within same host, two
processes communicate
using inter-process
communication (defined
by OS).
processes in different
hosts communicate by
exchanging messages
Client process: process
that initiates
communication
Server process: process
that waits to be
contacted
2: Application Layer15
Addressing processes
to receive messages,
process must have
identifier
identifier includes both IP
address and port numbers
associated with process on
host.
Example port numbers:
HTTPs server: 443
Mail server: 25
to send HTTPs message to
spit.ac.in web server:
IP address: 172.16.10.2
Port number: 443
2: Application Layer17
Transport service requirements of common apps
Application
file transfer
e-mail
Web documents
real-time audio/video
stored audio/video
interactive games
instant messaging
Data loss
no loss
no loss
no loss
loss-tolerant
loss-tolerant
loss-tolerant
no loss
Throughput
elastic
elastic
elastic
audio: 5kbps-1Mbps
video:10kbps-5Mbps
same as above
few kbps up
elastic
Time Sensitive
no
no
no
yes, 100’s msec
yes, few secs
yes, 100’s msec
yes and no
2: Application Layer18
Internet apps: application, transport protocols
Application
e-mail
remote terminal access
Web
file transfer
streaming multimedia
Internet telephony
Application
layer protocol
SMTP [RFC 2821]
Telnet [RFC 854]
HTTP [RFC 2616]
FTP [RFC 959]
HTTP (eg Youtube),
RTP [RFC 1889]
SIP, RTP, proprietary
(e.g., Skype)
Underlying
transport protocol
TCP
TCP
TCP
TCP
TCP or UDP
typically UDP
2: Application
Layer
2: Application Layer20
Internet transport protocols services
TCP service:
connection-oriented: setup
required between client and
server processes
reliable transport between
sending and receiving process
flow control: sender won’t
overwhelm receiver
congestion control: throttle
sender when network
overloaded
does not provide: timing,
minimum throughput
guarantees, security
UDP service:
unreliable data transfer
between sending and
receiving process
does not provide:
connection setup,
reliability, flow control,
congestion control, timing,
throughput guarantee, or
security
2: Application Layer21
Web and HTTP
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
host name
path name
2: Application Layer22
HTTP overview (continued)
HTTP is “stateless”
server maintains no
information about past
client requests
Protocols that maintain
“state” are complex!
past history (state) must
be maintained
aside
Http vs Https
Hyper-text exchanged using http goes as plain text i.e. anyone between the browser
and server can read it relatively easy if one intercepts this exchange of data.
But why do we need this security over the Web. ?
Think of ‘Online shopping’ at Amazon or Flipkart.
You might have noticed that as soon as we click on the Check-out on these online
shopping portals, the address bar strictly prefers https.
This is done so that the subsequent data transfer (i.e. financial transaction etc.) is
made secure. And that’s why https was introduced so that a secure session is
setup first between Server and Browser.
In fact, cryptographic protocols such as SSL and/or TLS turn http into https i.e.
https = http + cryptographic protocols.
Also, to achieve this security in https, Public Key Infrastructure (PKI) is used
because public keys can be used by several Web Browsers while private key can
be used by the Web Server of that particular website.
The distribution of these public keys is done via Certificates which are maintained
by the Browser. You can check these certificates in your Browser settings.
Also, another syntactic difference between
http and htpps is that http uses default port
80 while https uses default port 443.
But it should be noted that this security in
https is achieved at the cost of processing
time because Web Server and Web Browser
needs to exchange encryption keys using
Certificates before actual data can be
transferred.
Basically, setting up of a secure session is done
before the actual hypertext exchange
between server and browser.
2: Application
Layer
2: Application
Layer
Cookies
The main purpose of cookies is to identify users and possibly prepare
customized Web pages for them.
When you enter a Web site using cookies, you may be asked to fill out
a form providing such information as your name and interests.
This information is packaged into a cookie and sent to your Web
browser which stores it for later use.
The next time you go to the same Web site, your browser will send
the cookie to the Web server.
The server can use this information to present you with custom Web
pages.
For example, instead of seeing just a generic welcome page you might
see a welcome page with your name on it.
2: Application
Layer
2: Application Layer29
Cookies (continued)
What cookies can bring:
authorization
shopping carts
recommendations
user session state
(Web e-mail)
Cookies and privacy:
cookies permit sites to
learn a lot about you
you may supply name
and e-mail to sites
aside
Web caches (proxy server)
Goal: satisfy client request without involving origin server
2: Application
Layer
2: Application Layer32
More about Web caching
cache acts as both client and
server
typically cache is installed by
ISP (university, company,
residential ISP)
The proxy cache eases
bandwidth requirements and
reduces delays that are
inherent in a heavily
trafficked, Internet-connected
network.
Because the page is stored
locally on the proxy server, the
page is delivered to the next
request at local network
speeds.
The proxy cache also is
advantageous when browsing
multiple pages of the same
Web site.
The proxy cache also stores
all of the images and sub-
files for the visited pages
For example, the same
images, the proxy cache has
them already stored and can
load them into the user's
browser quicker than having
to retrieve them from the
Web site server's remote
site.
2: Application Layer33
Caching example
Assumptions
average object size = 100,000
bits
avg. request rate from
institution’s browsers to origin
servers = 15/sec
delay from institutional router
to any origin server and back to
router = 2 sec
Consequences
utilization on LAN = 15%
utilization on access link = 100%
total delay = Internet delay +
access delay + LAN delay
= 2 sec + minutes + milliseconds
origin
servers
public
Internet
institutional
network 10 Mbps LAN
1.5 Mbps
access link
institutional
cache
2: Application Layer34
Caching example (cont)
possible solution
increase bandwidth of access
link to, say, 10 Mbps
consequence
utilization on LAN = 15%
utilization on access link = 15%
Total delay = Internet delay +
access delay + LAN delay
= 2 sec + msecs + msecs
often a costly upgrade
origin
servers
public
Internet
institutional
network
10 Mbps LAN
10 Mbps
access link
institutional
cache
2: Application Layer35
Caching example (cont)
possible solution: install
cache
suppose hit rate is 0.4
consequence
40% requests will be
satisfied almost immediately
60% requests satisfied by
origin server
utilization of access link
reduced to 60%, resulting in
negligible delays (say 10
msec)
total avg delay = Internet
delay + access delay + LAN
delay = .6*(2.0) secs
+ .4*10milliseconds < 1.4 secs
origin
servers
public
Internet
institutional
network
10 Mbps LAN
1.5 Mbps
access link
institutional
cache
2: Application Layer36
DNS
DNS services
hostname to IP
address translation
host aliasing
Canonical, alias names
2: Application
Layer
2: Application Layer38
Root DNS Servers
com DNS servers
org DNS servers edu DNS servers
poly.edu
DNS servers
umass.edu
DNS servers
yahoo.com
DNS servers
amazon.com
DNS servers
pbs.org
DNS servers
Distributed, Hierarchical Database
2: Application Layer39
DNS: Root name servers
contacted by local name server that can not resolve name
root name server:
are a network of hundreds of servers in many countries around the world.
They are configured in the DNS root zone as 13 named authorities, as
follows.
13 root name
servers worldwide
b USC-ISI Marina del Rey, CA
l ICANN Los Angeles, CA
e NASA Mt View, CA
f Internet Software C. Palo Alto, CA (and 36
other locations)
i Autonomica, Stockholm (plus 28 other locations)
k RIPE London (also 16 other locations)
m WIDE Tokyo (also Seoul, Paris, SF)
a Verisign, Dulles, VA
c Cogent, Herndon, VA (also LA)
d U Maryland College Park, MD
g US DoD Vienna, VA
h ARL Aberdeen, MD
j Verisign, ( 21 locations)
2: Application Layer41
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.
Network Solutions maintains servers for com TLD
Educause for edu TLD
Authoritative DNS servers:
organization’s DNS servers, providing
authoritative hostname to IP mappings for
organization’s servers (e.g., Web, mail).
can be maintained by organization or service
provider
2: Application Layer42
Local Name Server
does not strictly belong to hierarchy
each ISP (residential ISP, company,
university) has one.
also called “default name server”
when host makes DNS query, query is sent
to its local DNS server
acts as proxy, forwards query into hierarchy
2: Application Layer43
requesting host
cis.poly.edu
gaia.cs.umass.edu
root DNS server
local DNS server
dns.poly.edu
1
2
3
4
5
6
authoritative DNS server
dns.cs.umass.edu
7
8
TLD DNS server
DNS name
resolution example
Host at cis.poly.edu
wants IP address for
gaia.cs.umass.edu
iterated query:
contacted server
replies with name of
server to contact
“I don’t know this
name, but ask this
server”
2: Application Layer44
requesting host
cis.poly.edu
gaia.cs.umass.edu
root DNS server
local DNS server
dns.poly.edu
1
2
4
5
6
authoritative DNS server
dns.cs.umass.edu
7
8
TLD DNS server
3
recursive query:
similar to a client
saying, "Find the IP
address for
this domain and don't
get back to me until
you”.
puts burden of name
resolution on
contacted name
server
heavy load
DNS name
resolution example
2: Application Layer45
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 Layer46
FTP: the file transfer protocol
transfer file to/from remote host
client/server model
client: side that initiates transfer (either to/from
remote)
server: remote host
ftp server: port 21
file transfer
FTP
server
FTP
user
interface
FTP
client
local file
system
remote file
system
user
at host
2: Application Layer47
FTP: separate control, data connections
FTP client contacts FTP server
at port 21, TCP is transport
protocol
client authorized over control
connection
client browses remote
directory by sending commands
over control connection.
when server receives file
transfer command, server opens
2
nd
TCP connection (for file) to
client
after transferring one file,
server closes data connection.
FTP
client
FTP
server
TCP control
connection
port 21
TCP data
connection
port 20
FTP works in the same way
as HTTP and SMTP.
FTP uses the Internet's
TCP/IP protocols to enable
data transfer.
FTP is most commonly used to
download a file from a server
using the Internet or to upload a
file to a server (e.g., uploading a
Web page file to a server).
2: Application
Layer
2: Application Layer49
Electronic Mail
Three major components:
user agents
mail servers
simple mail transfer protocol:
SMTP
User Agent
“mail reader”
composing, editing, reading mail
messages
e.g., Eudora, Outlook, elm,
Mozilla Thunderbird
outgoing, incoming messages
stored on server
user mailbox
outgoing
message queue
mail
server
user
agent
user
agent
user
agent
mail
server
user
agent
user
agent
mail
server
user
agent
SMTP
SMTP
SMTP
2: Application Layer50
Electronic Mail: mail servers
Mail Servers
mailbox contains incoming
messages for user
message queue of outgoing
(to be sent) mail messages
SMTP protocol between mail
servers is used to send
email messages
client: sending mail
server
“server”: receiving mail
server
mail
server
user
agent
user
agent
user
agent
mail
server
user
agent
user
agent
mail
server
user
agent
SMTP
SMTP
SMTP
SMTP
2: Application
Layer
2: Application
Layer
2: Application Layer53
Electronic Mail: SMTP
uses TCP to reliably transfer email message from client
to server, port 25
direct transfer: sending server to receiving server
three phases of transfer
handshaking (greeting)
transfer of messages
closure
messages must be in 7-bit ASCII
2: Application
Layer
Comparison with HTTP:
HTTP: pull protocol
SMTP: push protocol
The difference is that in push protocols, you get new events (such as a
new email, a new chat message, etc) literally instantly.
But you may experience a small time delay in pull protocols. Although
many apps using the pull protocol, check for new events so regular
(e.g. every 30 seconds) that the time delay is mostly not noticeable.
For example, your cell phone is always connected to the mobile
network. You can tell this by the signal bars on your phone's screen.
When a caller calls, the network sends the call to your cell phone via
that active connection your cell phone already have. This is PUSH.
But, when you're waiting for a specific program on your TV, you
repeatedly turn it on and check if your program started and then
turn in off. This is PULL.
2: Application Layer57
Mail access protocols
SMTP: delivery/storage to receiver’s server
Mail access protocol: retrieval from server
POP: Post Office Protocol [RFC 1939]: POP3 is a client/server
protocol in which e-mail is received and held for you by your
Internet server
•authorization (agent <-->server) and download
IMAP: Internet Mail Access Protocol [RFC 1730]
•more features (more complex)
•manipulation of stored msgs on server
user
agent
sender’s mail
server
user
agent
SMTP SMTP
access
protocol
receiver’s mail
server
2: Application
Layer
Here's why POP is bad:
You have to delete or file the
same email on every device
Logging into each device,
you will see lots of unread
emails with no indication of
which you deleted, read,
flagged or filed
Any folders you created and
organize on one device won't
be replicated on the other
devices
How do I know I'm using POP?
Sign 1: If I create folders on one
of my devices, they are not
replicated on others
Sign 2: If I read an email on one
of my devices, I see it as
unread on others
Sign 3: If I delete an email on
one of my devices, I still see it
on others