Application Layer
Application Layer
2
Some network apps
r e-mail
r web
r instant messaging
r remote login
r P2P file sharing
r multi-user network games
r streaming stored video
clips
r voice over IP
r real-time video
conferencing
r grid computing
3
Application architectures
r Client-server
r Peer-to-peer (P2P)
r Hybrid of client-server and P2P
4
Client-server architecture
server:
❖ always-on host
❖ permanent IP address
❖ server farms for
scaling
clients:
❖ communicate with server
client/server
❖ may be intermittently
connected
❖ may have dynamic IP
addresses
❖ do not communicate
directly with each other
5
Pure P2P architecture
r no always-on server
r arbitrary end systems
directly communicate peer-peer
r peers are intermittently
connected and change IP
addresses
6
Hybrid of client-server and P2P
Instant messaging
❖ 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
• Example: spype
7
Processes communicating
Process: program running
within a host.
r within same host, two Client process: process
processes communicate that initiates
using inter-process communication
communication (IPC Server process:
defined by OS). process that waits
r processes in different to be contacted
hosts communicate by
exchanging messages
8
Sockets
host or host or
r process sends/receives server server
messages to/from its
socket controlled by
app developer
process
r socket analogous to door process
socke socke
❖ sending process shoves t t
message out door TCP with TCP with
buffers, Internet buffers,
❖ sending process relies on
variables variables
transport infrastructure on
other side of door which
brings message to socket controlled
by OS
at receiving process
9
Addressing processes
r to receive messages, process must have identifier
r host device has unique 32-bit IP address
10
Answer:
No, many processes can be running on same host
2: Application Layer 12
Application Layer Protocols
2: Application Layer 13
2: Application Layer 14
App-layer protocol defines:
r Message syntax:
❖ what fields in messages & how fields are defined
r Message semantics
❖ meaning of information in fields
15
What transport service does an app need?
Data loss Throughput
r some apps (e.g., audio) can r some apps (e.g.,
tolerate some loss known multimedia) require
as loss tolerant minimum amount of
applications.
throughput to be
r other apps (e.g., file
effective “Bandwidth
transfer, telnet) require
100% reliable data sensitive applications”
transfer r other apps (“elastic apps”)
make use of whatever
Timing throughput they get
r some apps (e.g.,
Security
Internet telephony,
interactive games) r Encryption, data integrity,
require low delay to …
be “effective”
16
Transport service requirements of common apps
17
Internet apps: application, transport protocols
Application Underlying
Application layer protocol transport protocol
20
First some jargon
www.someschool.edu/someDept/pic.gif
21
http://www.someschools.edu:80/calender.cgi
?month=july#week3
2: Application Layer 22
HTTP overview
HTTP: hypertext
transfer protocol HT
TP
req
r Web’s application layer PC running HT ues
TP t
protocol Explorer res
pon
se
r client/server model
❖ client: browser that
st
requests, receives, que
r e
P nse Server
“displays” Web objects H TT e sp o
running
r
❖ server: Web server TP Apache Web
HT
server
sends objects in
response to requests
Mac running
Navigator
2: Application Layer 23
HTTP overview (continued)
Uses TCP: HTTP is “stateless”
r client initiates TCP r server maintains no
connection (creates socket) information about
to server, port 80 past client requests
r server accepts TCP
connection from client aside
Protocols that maintain
r HTTP messages “state” are complex!
(application-layer protocol
r past history (state) must
messages) exchanged
be maintained
between browser (HTTP
r if server/client crashes,
client) and Web server
(HTTP server) their views of “state” may
be inconsistent, must be
r TCP connection closed
reconciled
24
HTTP connections
Non-persistent HTTP Persistent HTTP
r At most one object is r Multiple objects can
sent over a TCP be sent over single
connection. TCP connection
between client and
server.
r Also known as HTTP
Keep-alive or HTTP
Connection reuse.
25
Nonpersistent HTTP
(contains text,
Suppose user enters URL references to 10
www.someSchool.edu/someDepartment/home.index jpeg images)
time
26
Nonpersistent HTTP (cont.)
27
Non-Persistent HTTP: Response time
Definition of RTT: time for
a small packet to travel
from client to server
and back. initiate TCP
connection
Response time: RTT
r one RTT to initiate TCP request
file
connection time to
RTT
r one RTT for HTTP transmit
file
request and first few file
received
bytes of HTTP response
to return time time
r file transmission time
total = 2RTT+transmit time
28
r Serial fetching because:
❖ Multiple connection (TCP connection)
❖ Multiple tabs
❖ Download objects in parallel
2: Application Layer 29
HTTP 1.0 : default connection is non-persistent
2: Application Layer 30
2: Application Layer 31
2: Application Layer 32
2RTT+.25RTT +(2RTT+.25RTT)=4.5RTT
2: Application Layer 33
2: Application Layer 34
HTTP 1.1 : default connection is persistent
2: Application Layer 35
2: Application Layer 36
In Pipelined
connection 2RTT for
connection
establishment and
then 1RTT
(assuming no
window limit) for all
the objects i.e.
images/text
2: Application Layer 37
Advantages of persistent connections :
1) Lower CPU and memory usage because there are less
number of connections.
2) Allows HTTP pipelining of requests and responses.
3) Reduced network congestion (fewer TCP connections).
4) Reduced latency in subsequent requests (no handshaking).
5) Errors can be reported without the penalty of closing the
TCP connection.
Disadvantages of persistent connections :
Resources may be be kept occupied even when not needed
and may not be available to others.
2: Application Layer 38
Nonpersistent HTTP issues: Persistent HTTP
r requires 2 RTTs per object r server leaves connection
r OS overhead for each TCP open after sending
connection response
r browsers often open parallel r subsequent HTTP messages
TCP connections to fetch between same
referenced objects client/server sent over
open connection
r client sends requests as
soon as it encounters a
referenced object
r as little as one RTT for all
the referenced objects
39
r Suppose within your Web browser you click on a link to obtain a Web page.
The IP address for the associated URL is not cached in your local host, so a
DNS lookup is necessary to obtain the IP address. Suppose that n DNS servers
are visited before your host receives the IP address from DNS; the successive
visits incur an RTT of RTT1, . . ., RTTn. Further suppose that the Web page
associated with the link contains exactly one object, consisting of a small
amount of HTML text. Let RTT0 denote the RTT between the local host and
the server containing the object. Assuming zero transmission time of the
object, how much time elapses from when the client clicks on the link until the
client receives the object?
2: Application Layer 40
r suppose the HTML file references eight very small objects on the
same server. Neglecting transmission times, how much time elapses
with
r a. Non-persistent HTTP with no parallel TCP connections?
r b. Non-persistent HTTP with the browser configured for 5 parallel
connections?
r c. Persistent HTTP? (with pipelining)
r d. Persistent HTTP? (without pipelining)
2: Application Layer 41
2: Application Layer 42
Question
Suppose the HTML file references three very small objects on
the same server. Neglecting transmission times how much time
elapses with
a) Non persistent HTTP?
b) Persistent HTTP without pipelining?
c) Persistent HTTP with pipelining?
2: Application Layer 43
HTTP request and resposne
message
2: Application Layer 44
HTTP request message
request line
(GET, POST, GET /somedir/page.html HTTP/1.1
HEAD commands) Host: www.someschool.edu
User-agent: Mozilla/4.0
header Connection: close
lines Accept-language:fr
Carriage return,
(extra carriage return, line feed)
line feed
indicates end
of message
45
HTTP request message: general format
2: Application Layer 46
2: Application Layer 47
HTTP request Method types
HTTP/1.0 HTTP/1.1
1. GET r GET, POST, HEAD
2. POST r PUT
3. HEAD ❖ uploads an object used
in conjunction with web
publishing tools.
❖ uploads an object to a
specific path
(directory)in URL field
on a specific web
server.
r DELETE
❖ deletes file specified in
the URL field
48
Request Methods
r The three most commonly used request methods are: GET, POST
and HEAD.
r GET: Retrieve a Document
❖ This is the main method used for retrieving html, images, JavaScript, CSS,
etc. Most data that loads in your browser was requested using this method.
r POST: Send Data to the Server
❖ Even though you can send data to the server using GET and the query string,
in many cases POST will be preferable. Sending large amounts of data using
GET is not practical and has limitations.
r HEAD: Retrieve Header Information
❖ HEAD is identical to GET, except the server does not return the content in
the HTTP response. When you send a HEAD request, it means that you are
only interested in the response code and the HTTP headers, not the
document itself.
2: Application Layer 49
Conditional GET
1.Host
2. Content Length
3. Content-type
4. Authentication
5. Use Agent
6. Accept language
8. Cookie
51
HTTP response message
status line
(protocol
status code HTTP/1.1 200 OK
status phrase) Connection close
Date: Thu, 06 Aug 1998 12:00:15 GMT
header Server: Apache/1.3.0 (Unix)
lines Last-Modified: Mon, 22 Jun 1998 …...
Content-Length: 6821
Content-Type: text/html
2: Application Layer 52
HTTP response status codes
1xx :- indicates informational message only
53
HTTP response status codes
In first line in server->client response message.
A few sample codes:
200 OK
❖ request succeeded, response is included in the content
200 No response
❖ request succeeded, but no response is provided.
301 Moved Permanently
❖ Indicates that URL of the requested resource has changed.
302 Found
❖ It functions like 301 response except that the move is temporary
303 see other
❖ It indicates that the resource has temporarily moved and it is
obtained from new URL via GET request only.
54
400 Bad Request
❖ request message not understood by server due to bad
syntax
401 Unauthorized
❖ Indicates that the requested resource is in a protected
medium.
403 Forbidden
❖ Indicates that client is not allowed to access the
requested resource for some reasons, other than valid
HTTP login.
404 Not Found
❖ requested document not found on this server
408 Request time out
55
500 Internal server error
❖ Indicates that something happened on the server that
caused the transaction to fail.
503 Service unavailable
❖ Indicates that the server is unable to respond to the
request due to a high volume of traffic
505 HTTP Version Not Supported
56
HTTP response server Headers
1. Content length
2. Content type
3. Date
4. Last Modified
5. Location
6. Server
7. Set cookie
57
In this example, the idle timeout is
set to ten seconds and it can accept
up to 100 HTTP requests before
the HTTP Connection is forcibly
closed.
2: Application Layer 58
2: Application Layer 59
State True or False?
60
Ques:
2: Application Layer 61
User-server state: cookies
Example:
Many major Web sites
use cookies r Susan always access
Four components: Internet always from PC
1) cookie header line of r visits specific
HTTP response message e-commerce site for
2) cookie header line in first time
HTTP request message
3) cookie file kept on r when initial HTTP
user’s host, managed by requests arrives at site,
user’s browser
site creates:
4) back-end database at
Web site ❖ unique ID
❖ entry in backend
database for ID
62
Cookies: keeping “state” (cont.)
client server
ebay 8734
usual http request msg
Amazon server
cookie file usual http response creates ID
Set-cookie: 1678 1678 for user create
ebay 8734 entry
amazon 1678
usual http request msg
cookie: 1678 cookie- access
specific
one week later: usual http response msg action backend
database
access
ebay 8734 usual http request msg
amazon 1678 cookie: 1678 cookie-
spectific
usual http response msg action
63
Cookies (continued)
aside
What cookies can bring: Cookies and privacy:
r authorization r cookies permit sites to
r shopping carts learn a lot about you
r recommendations r you may supply name
and e-mail to sites
r user session state
(Web e-mail)
How to keep “state”:
r protocol endpoints: maintain state
at sender/receiver over multiple
transactions
r cookies: http messages carry state
64
Web caches (proxy server)
Goal: satisfy client request without involving origin server
2: Application Layer 67
Caching example
origin
Assumptions servers
r average object size = 100,000
public
bits Internet
r avg. request rate from
institution’s browsers to origin
servers = 15/sec
1.5 Mbps
r delay from institutional router access link
to any origin server and back
institutional
to router = 2 sec network
10 Mbps LAN
Consequences
r utilization on LAN = 15%
r utilization on access link = 100%
r total delay = Internet delay + institutional
access delay + LAN delay cache
= 2 sec + minutes + milliseconds
68
Caching example (cont)
origin
possible solution servers
r increase bandwidth of access
public
link to, say, 10 Mbps Internet
consequence
r utilization on LAN = 15%
r utilization on access link = 15%
10 Mbps
r Total delay = Internet delay + access link
access delay + LAN delay
institutional
= 2 sec + msecs + msecs network
10 Mbps LAN
r often a costly upgrade
institutional
cache
69
Caching example (cont)
origin
possible solution: install servers
cache public
r suppose hit rate is 0.4 Internet
consequence
r 40% requests will be
satisfied almost immediately
r 60% requests satisfied by 1.5 Mbps
origin server access link
r utilization of access link institutional
reduced to 60%, resulting in network
10 Mbps LAN
negligible delays (say 10
msec)
r total avg delay = Internet
delay + access delay + LAN
delay = .6*(2.01) secs + institutional
.4*milliseconds < 1.4 secs cache
70
r Does a Cookie Slow Down a Computer?
2: Application Layer 71
FTP
72
FTP: the file transfer protocol
73
2: Application Layer 74
2: Application Layer 75
2: Application Layer 76
FTP: separate control, data connections
TCP control connection
r FTP client contacts FTP server port 21
at port 21, TCP is transport
protocol TCP data connection
r client authorized over control FTP port 20 FTP
connection client server
r client browses remote
r server opens another TCP
directory by sending commands
data connection to transfer
over control connection.
another file.(data connections
r when server receives file are non persistent)
transfer command, server
r control connection: “out of
opens 2nd TCP connection (for
band”
file) to client
r FTP server maintains “state”:
r after transferring one file,
current directory, earlier
server closes data connection.
authentication
77
r In active mode, the client establishes the
command channel (from client port X to server
port 21) but the server establishes the data
channel (from server port 20 to client port Y,
where Y has been supplied by the client).
r In passive mode, the client establishes both
channels. In that case, the server tells the
client which port should be used for the data
channel.
2: Application Layer 78
FTP commands, responses
79
80
2: Application Layer 81
2: Application Layer 82
r Use UDP (connectionless) protocol
2: Application Layer 83
1. FTP server listens for connection on port number
a) 20
b) 21
c) 22
d) 23
2. In FTP protocol, client contacts server using ____ as the
transport protocol.
a) transmission control protocol
b) user datagram protocol
c) datagram congestion control protocol
d) stream control transmission protocol
3. In which mode FTP, the client initiates both the control and data
connections.
a) active mode
b) passive mode
c) both (a) and (b)
d) none of the mentioned
84
Electronic Mail
SMTP, POP3, IMAP
85
2: Application Layer 86
Electronic Mail outgoing
message queue
user mailbox
user
Three major components: agent
r user agents mail
user
r mail servers server
agent
r simple mail transfer SMTP mail
protocol: SMTP server user
87
Electronic Mail: mail servers
user
Mail Servers agent
r mailbox contains incoming mail
user
messages for user server
agent
r message queue of outgoing
(to be sent) mail messages
SMTP mail
server user
r SMTP protocol between mail
servers to send email SMTP agent
messages
SMTP
❖ client: sending mail mail user
server server agent
❖ transfer of messages
❖ closure ***Multipurpose Internet Mail
Extension (MIME) for audio, video,
r command/response interaction images, application programs
❖ commands: ASCII text
❖ response: status code and phrase
89
Scenario: Alice sends message to Bob
1) Alice uses UA to compose 4) SMTP client sends Alice’s
message and “to” message over the TCP
bob@someschool.edu connection
2) Alice’s UA sends message 5) Bob’s mail server places the
to her mail server; message message in Bob’s mailbox
placed in message queue 6) Bob invokes his user agent
3) Client side of SMTP opens to read message
TCP connection with Bob’s
mail server
1 mail
mail
server user
user server
2 agent
agent 3 6
4 5
90
Sample SMTP interaction
S: 220 hamburger.edu
C: HELO crepes.fr
S: 250 Hello crepes.fr, pleased to meet you
C: MAIL FROM: <alice@crepes.fr>
S: 250 alice@crepes.fr... Sender ok
C: RCPT TO: <bob@hamburger.edu>
S: 250 bob@hamburger.edu ... Recipient ok
C: DATA
S: 354 Enter mail, end with "." on a line by itself
C: Do you like ketchup?
C: How about pickles?
C: .
S: 250 Message accepted for delivery
C: QUIT
S: 221 hamburger.edu closing connection
91
SMTP: final words
r SMTP uses persistent Comparison with HTTP:
connections
r HTTP: pull
r SMTP requires message
r SMTP: push
(header & body) to be in
7-bit ASCII r both have ASCII
r SMTP server uses command/response
CRLF.CRLF to determine interaction, status codes
end of message
r HTTP: each object
encapsulated in its own
response msg
***HTTP encapsulates each object r SMTP: multiple objects
in its own HTTP response message. sent in multipart msg
Internet mail places all of the
message’s objects into one message
92
Mail message format
93
Message format: multimedia extensions
r MIME: multimedia mail extension, RFC 2045, 2056
r additional lines in msg header declare MIME content
type
From: alice@crepes.fr
MIME version To: bob@hamburger.edu
Subject: Picture of yummy crepe.
method used MIME-Version: 1.0
to encode data Content-Transfer-Encoding: base64
Content-Type: image/jpeg
multimedia data
type, subtype, base64 encoded data .....
parameter declaration .........................
......base64 encoded data
encoded data
94
Mail access protocols
SMTP SMTP access user
user
agent protocol agent
95
POP3 protocol[110 port] S: +OK POP3 server ready
C: user bob
authorization phase S: +OK
C: pass hungry
r client commands: S: +OK user successfully logged on
❖ user: declare username
C: list
❖ pass: password S: 1 498
r server responses S: 2 912
❖ +OK S: .
C: retr 1
❖ -ERR
S: <message 1 contents>
transaction phase, client: S: .
C: dele 1
r list: list message
C: retr 2
numbers S: <message 1 contents>
r retr: retrieve message by S: .
number C: dele 2
r dele: delete C: quit
S: +OK POP3 server signing
r quit off
96
2: Application Layer 97
POP3 (more) and IMAP
More about POP3 IMAP
Two Modes of POP3 r Keep all messages in
1. “download and delete” one place: the server
mode. r Allows user to
2. “Download-and-keep”: organize messages in
copies of messages on folders
different clients r IMAP keeps user state
across sessions:
POP3 is stateless across ❖ names of folders and
mappings between
sessions message IDs and folder
name
98
2: Application Layer 99
WEB-BASED MAIL
101
DNS: Domain Name System
102
DNS services
103
Why not centralize DNS?
doesn’t scale!
104
Distributed, Hierarchical Database
Root DNS Servers
a Verisign, Dulles, VA
c Cogent, Herndon, VA (also LA)
d U Maryland College Park, MD k RIPE London (also 16 other locations)
g US DoD Vienna, VA
h ARL Aberdeen, MD i Autonomica, Stockholm (plus
j Verisign, ( 21 locations) 28 other locations)
e NASA Mt View, CA m WIDE Tokyo (also Seoul,
f Internet Software C. Palo Alto, Paris, SF)
CA (and 36 other locations)
13 root name
servers worldwide
b USC-ISI Marina del Rey, CA
l ICANN Los Angeles, CA
106
2. 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
❖ Generic domains, country domains and inverse
domains
107
4. Local Name Server
108
109
Domain Name Syntax
❑ URL
❑ Host name
❑ domain name: Any name registered in the DNS is a domain name.
❑ A fully qualified domain name (FQDN) is a domain name that is
completely specified in the hierarchy of the DNS, having no omitted parts.
❑ partially-qualified domain name (PQDN) only specifies a portion of a
domain name. It is a relative name that has meaning only within a particular
context; the partial name must be interpreted within that context to fully
identify the node.
❑ Top level Domain
❑ Second level Domain
❑ Labels: A domain name consists of one or more parts, technically
called labels, that are conventionally concatenated, and delimited by dots
❑ Each label may contain up to 63 characters.
❑ Processing is done for sequence of domain labels from right to left,
going top to bottom within the tree.
110
r Tree: The DNS hierarchy can be visualized as a tree where each node in
the tree corresponds to a domain and the tree corresponds to the hosts
being named.
r Zones: partition of the hierarchy into sub trees called zones.
r Zone files: server makes a database called zone file and keeps all the
information for every node under that domain.
r Primary server
r Secondary server
r Zone transfer
❑ DNS uses TCP for Zone Transfer over Port: 53
❑ DNS uses UDP for DNS queries over Port:53
❑ Mapping names to addresses
❑ Mapping adresses to names
111
DNS name root DNS server
resolution example
2
3
r Host at cis.poly.edu TLD DNS server
wants IP address for 4
gaia.cs.umass.edu 5
gaia.cs.umass.edu
112
DNS name
root DNS server
resolution example
recursive query: 2 3
r puts burden of name 6
7
resolution on
TLD DNS server
contacted name
server
r heavy load? local DNS server
dns.poly.edu 5 4
1 8
gaia.cs.umass.edu
113
DNS: caching and updating records
r 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
114
DNS records
DNS: distributed db storing resource records (RR)
RR format: (name, value, type, ttl)
r Type=A r Type=CNAME
❖ name is hostname ❖ name is alias name for some
❖ value is IP address “canonical” (the real) name
www.ibm.com is really
r Type=NS
servereast.backup2.ibm.com
❖ name is domain (e.g.
❖ value is canonical name
foo.com)
❖ value is hostname of
r Type=MX
authoritative name server
❖ value is name of mailserver
for this domain
associated with name
115
DNS protocol, messages
DNS protocol : query and reply messages, both with
same message format
message header
r identification: 16 bit #
for query, reply to query
uses same #
r flags:
❖ 1 bit query or reply
❖ 1 bit recursion desired
❖ 1 bit recursion available
❖ 1 bit reply is
authoritative
116
DNS protocol, messages
RRs in response
to query
records for
authoritative servers
additional “helpful”
info that may be used
117
Inserting records into DNS
r example: new startup “Network Utopia”
r register name networkuptopia.com at DNS registrar
(e.g., Network Solutions)
❖ provide names, IP addresses of authoritative name server
(primary and secondary)
❖ registrar inserts two RRs into com TLD server:
118
Questions..
120
5. The root of the DNS tree is _______.
A)a string of characters
B)a string of 63 characters
C)an empty string
D)none of the above
122
12. The ____________ domain section uses two-character
country abbreviations.
A)Generic B)country C)inverse D)none of the above
13. In the domain name chal.atc.fhda.edu, _______ is the least specific label.
A)Chal
B)atc
C)edu
D)none of the above
123
Question:
125
Question : Is the user-agent (e.g., mail-reader) of the receiver
Of an email message uses SMTP to download the message from
The receiver’s mailbox. If yes/no then how it is done.
126
Question: Suppose within your web browser you click on a link
to obtain a Web page. The IP address for the associated URL is
not cached in your local host, so a DNS lookup is necessary to
obtain the IP address. Suppose that n DNS servers are visited
before your host received the IP address from DNS; the
successive visits incur an RTT of RTT1, RTT2, …, RTTn. Further
Suppose that the Web page associated with the link contains
exactly one object, consisting of a small amount of HTML text.
Let RTT0 denote the RTT between the local host and the
Server containing the object. Assuming zero transmission time
of the object, how much time elapses between when the client
clicks on the link until it receives the object?
127