You are on page 1of 46

Module-V

Application
Layer
Outline

 Principles of Network Applications


 The Web and HTTP
 Electronic mail in the Internet
o SMTP, POP3, IMAP
 DNS-The Internet Directory

• Text book 2: Computer Networking: A Top down Approach-


James F Kurose 7th Edition

Application Layer 2-2


Principles of Network Applications
 Network-applications are the driving forces for
the explosive development of the internet.
 Examples:
Creating a network app application
transport
network
data link
physical
Write Programs That:
• run on (different) end systems
• communicate over network
• e.g., web server software
communicates with browser
software.
application
transport
network
Possible Structure of Applications: data link
physical
application
transport
network
• client-server data link
physical

• peer-to-peer (P2P)
Client-Server Architecture
Server:
 always-on host
 permanent IP address
 data centers for scaling

Clients:
 Randomly on
client/server  communicate with server
 may be intermittently
connected
 do not communicate directly
with each other.
 Examples: FTP, Web, e-mail
Data Center
 A data-center is used to create a powerful virtual server.
 In date center, hundreds of servers must be powered and
maintained.
 example: Google has around 50 data-centers distributed around the world.
These 50 data-centers handle : search, YouTube, Gmail etc.
P2P architecture
 No dedicated server
 Pairs of hosts are called peers. peer-peer
 The peers communicate directly with each
other.
 The peers are not owned by the service-
provider, instead these are laptops
controlled by users.
 Ex file sharing (BitTorrent), Internet
telephone (Skype)
 self-scalability ,Cost effective
 Challenges: ISP friendly : P2P traffic does
not conform to traditional ISP traffic
policies.
 Security: Openness & distribution
 Incentives: convincing users to volunteer
bandwidth & resources to the applications.
Processes Communicating
Client process: process that
Process: program running within initiates communication
a host.
Server process: process that
• within same host, two
waits to be contacted
processes communicate using
IPC (defined by OS).
• processes in different hosts
communicate by exchanging
messages.
App-layer protocol defines
• types of messages exchanged, open protocols:
– e.g., request, response • defined in RFCs
• message syntax: • allows for interoperability
– what fields in messages • e.g., HTTP, SMTP
& how fields are proprietary protocols:
delineated
• e.g., Skype
• message semantics
– meaning of information
in fields
• rules for when and how
processes send & respond to
messages

Application Layer 2-9


Transport Services Available to Applications
1. Reliable Data Transfer 2. Throughput
 BW sensitive app:
some apps (e.g., file transfer,
web transactions) require Guaranteed throughput
(e.g., multimedia)
100% reliable data transfer  Elastic app: May not need
• other apps (e.g., audio) can guarantee throughput file
tolerate some loss transfer, email

3. Timing
• some apps (e.g., Internet 4. Security
telephony, interactive  encryption, data integrity,
games) require low delay to …
be “effective”
Internet Transport Protocols Services

TCP service: UDP service:


• unreliable data transfer
• reliable transport between between sending and
sending and receiving process
• flow control: sender won’t receiving process
overwhelm receiver • does not provide: reliability,
• congestion control: throttle flow control, congestion
sender when network control, timing, throughput
overloaded
• connection-oriented: setup guarantee, security, or
required between client and connection setup,
server processes

2-12
Web and HTTP
 web page consists of objects(HTML)
 object is a file - HTML file, JPEG image, audio file,…
 web page consists of HTML-file & several
referenced objects.
 object is addressable by a URL,

www.someschool.edu/someDept/pic.gif

host name path name


HTTP overview
HTTP: hypertext
transfer
protocol( port 80)
• client/server model HT T
P re
que
– client: browser that PC running
HTT
st
Firefox browser P re
requests, receives, spo
nse
and “displays” Web
objects est
u
– server: Web server TP
req
se
server
HT on
sends objects in resp running
Apache Web
TP
response to requests HT
server

iphone running
Safari browser
HTTP overview (continued)

uses TCP: HTTP is


• client initiates TCP “stateless”
• server maintains no
connection (creates socket) information about
to server, port 80 past client requests
• server accepts TCP
connection from client
• HTTP messages exchanged
between browser (HTTP
client) and Web server (HTTP
server)
• TCP connection closed

2-15
HTTP connections

non-persistent HTTP persistent


• at most one object HTTP(default)
sent over TCP • multiple objects can
connection be sent over single
– connection then TCP connection
closed between client,
• downloading multiple server
objects required
multiple connections
Non-persistent HTTP: 1Req->1Resp
suppose user enters URL: (contains text,
www.someSchool.edu/someDepartment/home.index references to 10
jpeg images)

1a. HTTP client initiates TCP


connection to HTTP server 1b. HTTP server at host
(process) at www.someSchool.edu waiting for
www.someSchool.edu on port TCP connection at port 80.
80 “accepts” connection, notifying
client
2. HTTP client sends HTTP request
message (containing URL) into
TCP connection socket. Message 3. HTTP server receives request message,
indicates that client wants object forms response message containing
someDepartment/home.index requested object, and sends message
into its socket

time
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
Non-persistent HTTP: response time

RTT: Time for a small packet to


travel from client to server and
back
HTTP response time: initiate TCP
connection
• one RTT: To initiate TCP RTT
connection request
file
• one RTT: HTTP request and first time to
RTT
few bytes of HTTP response to transmit
file
return file
received
• file transmission time
• non-persistent HTTP response
time time
time =
2RTT+ file transmission
time
Persistent HTTP

non-persistent HTTP persistent HTTP:


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

2-20
HTTP message: general format
Two types of HTTP messages: request, response
HTTP request message
GET: Browser requests an object from the server.
POST: User fills out a form & sends to the server.
PUT: Upload objects to servers. DELETE: Allows application to delete object on a
server.

carriage return character


line-feed character
request line
(GET, POST, GET /index.html HTTP/1.1\r\n
,PUT,DELETE) Host: www-net.cs.umass.edu\r\n obj residing
User-Agent: Firefox/3.6.10\r\n browser
header Accept: text/html,application/xhtml+xml\r\n
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
line feed at start Connection: keep-alive\r\n
of line indicates \r\n
end of header lines
HTTP Response Message
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
Accept-Ranges: bytes\r\n
header Content-Length: 2652\r\n
lines 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 data data data data ...

data, e.g.,
requested
HTML file

Application Layer 2-24


User-server Interaction: cookies
Websites to keep track of user

Small text file created by website,


stored in user
computer(temporarily/permanen example:
t) • Susan always access Internet
four components: from PC
1) cookieheader line of • visits specific e-commerce
HTTP response message site for first time
2) cookie header line in next • when initial HTTP requests
HTTP request message arrives at site, site creates:
3) cookie file kept on user’s – unique ID
host, managed by user’s
browser – entry in backend DB
4) back-end DB at Web site for ID
Cookies: keeping “state” (cont.)
Client
Server
Host
Host
ebay 8734
usual http request msg Amazon server
cookie file creates ID
usual http response backend
Header set-cookie: 1678
1678 for user create
Browser ebay 8734 entry database
tores ID into amazon 1678
cookie file
usual http request msg
cookie: 1678 cookie- access
specific
usual http response msg action

one week later:


access
ebay 8734 usual http request msg
amazon 1678 cookie: 1678 cookie-
specific
Browser put action
ID in http
usual http response msg
request
Web caching (Proxy Server)
Goal: satisfy client request without involving origin server
• user sets browser: Web accesses via
cache
• browser sends all HTTP requests to
cache
Web Cache/
– object in cache: cache returns proxy
HT T
object P re server q uest
H
que
T P re
T st T e
– else cache requests object client TP H ons origin
resp
on P resp
from origin server, then se H TT server
returns object to client t
ues
P req se
– Advantages HT T on
resp
1) To reduce response-time for TP
HT
client-request.
2) To reduce traffic on an client origin
institution’s access-link to the server
Internet.
3) To reduce Web-traffic in the
The Conditional GET
client server
• It is a mechanism that
allows a cache to verify that
HTTP request msg
the objects are up to date. If-modified-since: <date> object
not
modified
• cache: specify date of HTTP response
before
HTTP/1.0
cached copy in HTTP 304 Not Modified <date>
request
If-modified-since:
<date>
HTTP request msg
• server: response contains If-modified-since: <date> object
no object if cached copy is modified
up-to-date: HTTP response after
HTTP/1.0 200 OK <date>
HTTP/1.0 304 Not
<data>
Modified
The Conditional GET
 It is a mechanism that allows a cache to verify that the
objects are up to date.
 An HTTP request-message is called conditional GET if
1) Request-message uses the GET method and
2) Response-message includes an If-Modified-Since:
header-line.
File Transfer: FTP
• Used by local host to transfer files to or from a remote-host over
the network.
• FTP uses client-server architecture
• FTP uses 2 parallel TCP connections
1) Control Connection : User ID, password ,commands to change
directory , put & get files.
2) Data Connection: To transfer files.
FTP commands & replies: USER,PASS,LIST(all files), RETR, STOR
FTP commands, responses

sample commands: sample return codes


• USER username • 331 Username OK,
• PASS password password required
• LIST return list of file in • 125 data connection
already open;
current directory
transfer starting
• RETR filename • 425 Can’t open data
retrieves (gets) file connection
• STOR filename stores • 452 Error writing
(puts) file onto remote host file
Electronic mail outgoing
message queue

Three major user


user mailbox

components: agent

• User agents(UA) mail user


server agent
• Mail servers(MS)
SMTP mail user
• Simple mail transfer protocol: server agent
SMTP SMTP
SMTP user
User Agent mail agent
server
• Read, reply, forward save user
compose messages agent
user
• e.g., Outlook, Thunderbird, agent
iPhone mail client
Electronic mail: mail servers outgoing
Message Q
user mailbox
user
Mail servers: agent
• mailbox contains incoming mail user
messages for user server agent
• message queue of outgoing SMTP mail user
(to be sent) mail messages server agent
SMTP
SMTP user
SMTP protocol: mail
agent
server
• Between mail servers to send user
email messages , TCP , port - agent

25 user
agent

2-33
Scenario: Alice sends message to Bob
1) Alice uses UA to compose 4) SMTP client sends Alice’s message
message “to” over the TCP connection
bob@someschool.edu 5) Bob’s mail server places the
2) Alice’s UA sends message to her message in Bob’s mailbox
mail server; message placed in 6) Bob invokes his UA to read
message queue message
3) client side of SMTP opens TCP
connection with Bob’s mail
server

1 user mail user


mail agent
agent server SMTP server
2 3 6
4
5
Alice’s mail server Bob’s mail server
Mail Message Format

SMTP: protocol for exchanging


email msgs header
blank
standard for text message line

format:
• header lines, e.g.,
body
– To:
– From:
– Subject:
• Body: the “message”
– ASCII characters only
Mail Access Protocols
mail access
user SMTP SMTP user
protocol
agent agent
(e.g., POP,
IMAP)

sender’s mail receiver’s mail


server server

• SMTP: delivery/storage to receiver’s server


• Mail access protocol: retrieval from server
– POP: Post Office Protocol : authorization, download
– IMAP: Internet Mail Access Protocol : manipulation of stored msgs
on server, allows user to organize messages in folders

– HTTP: gmail, Hotmail, Yahoo! Mail, etc.


POP3 protocol-port 110
S: +OK POP3 server ready
1. Authorization phase C: user bob
S: +OK
• client commands: C: pass hungry
– user: username S: +OK user successfully logged on
– pass: password
C: list
• server responses S: 1 498
– +OK S: 2 912
– -ERR S: .
C: retr 1
2. Transaction phase, S: <message 1 contents>
client: S: .
C: dele 1
• list: list message numbers
C: retr 2
• retr: retrieve message by number S: <message 1 contents>
• dele: delete S: .
• Quit C: dele 2
C: quit
S: +OK POP3 server signing off
3. Update
DNS -The Internet’s Directory Service(port-53)

 Translates domain names  IP addresses.


 ex: domain-name(Host name) “www.google.com” IP address
“198.105.232.4”.
 Because domain-names are alphabetic, easier to
remember for human being.
DNS provides following services
1) Host Aliasing : A host with a complicated hostname can
have one or more alias names.

2) Mail Server Aliasing: For obvious reasons, it is highly desirable that


e-mail addresses be mnemonic.

3) Load Distribution : It perform load distribution among replicated


servers.
Overview of How DNS Works
Distributed database design is more preferred over
centralized :

1) A Single Point of Failure : If the DNS server crashes then the


entire Internet will not stop.
2) Traffic Volume : A Single DNS Server cannot handle the huge
global DNS traffic.
3) Distant Centralized DB: A single DNS server cannot be “close
to” all the querying clients.
➢ If we put the single DNS server in Mysore, then all queries from USA must
travel to the other side of the globe, leads delay.
4) Maintenance: The single DNS server would have to keep
records for all Internet hosts.
DNS: a distributed, hierarchical database
Root DNS Servers

… …

com DNS servers org DNS servers edu DNS servers

pbs.org poly.edu umass.edu


yahoo.com amazon.com
DNS servers DNS servers DNS servers
DNS servers DNS servers

Authoritative

client wants IP for www.amazon.com:


• client queries root server to find com DNS server
• client queries .com DNS server to get amazon.com DNS server
• client queries amazon.com DNS server to get IP address for
www.amazon.com
DNS name
resolution example root DNS server

2
• host at cis.poly.edu wants 3
TLD DNS server
IP address for 4
gaia.cs.umass.edu
5

local DNS server


iterative query: dns.poly.edu
 contacted server replies 7 6
with name of server to 1 8
contact
 “I don’t know this authoritative DNS server
dns.cs.umass.edu
name, but ask this requesting host
server” cis.poly.edu

gaia.cs.umass.edu
DNS name
resolution example root DNS server

2 3
recursive query: 7
6
 puts burden of name TLD DNS
resolution on contacted server
name server local DNS server
 heavy load at upper dns.poly.edu 5 4
levels of hierarchy? 1 8

authoritative DNS server


dns.cs.umass.edu
requesting host
cis.poly.edu

gaia.cs.umass.edu
DNS Record:
Instructions in authoritative DNS servers, provide info( Domain+ IP address )

DNS: distributed database storing resource records (RR)


when a resource
RR format: (name, value, type, ttl) should be removed
from a cache

type=A(Address) type=CNAME
 name is hostname  name is alias name for some “canonical”
 value is IP address (the real) name
 value is canonical name

type=NS(Name Server) type=MX(mail exchange)


– name is domain  value is name of mailserver
– value is hostname of associated with name
authoritative name server for
this domain
DNS : Messages
• Query(Request) and reply messages, both with same message format

2 bytes 2 bytes

msg header identification flags


Header
 identification: 16 bit # for query, # questions # answer RRs Section
reply to query uses same # (12bytes
 flags: # authority RRs # additional RRs
 1.query(0) or reply(1)
 2. Authoritative: set in questions (variable # of questions) Question
reply msg when DNS is Section
authoritative server
answers (variable # of RRs)
 3. Recursion Desired: Set
when client desires DNS
performs recursion authority (variable # of RRs)

additional info (variable # of RRs)


DNS Protocol, Messages

2 bytes 2 bytes

question being identification flags


asked about the
domain-name # questions # answer RRs
domain-name
# authority RRs # additional RRs

Info about query: name, type fields


for a query questions (variable # of questions)

RRs in response answers (variable # of RRs)


to query
records for authority (variable # of RRs)
authoritative servers

additional “helpful” additional info (variable # of RRs)


info that may be used

You might also like