Title: Application Layer
1Application Layer
- We will learn about protocols by examining
popular application-level protocols - HTTP
- FTP
- SMTP / POP3 / IMAP
- Focus on client-server model
- Web
- HTML
1-1
2Client-server architecture
- server
- always-on host
- permanent IP address
- clients
- communicate with server
- may be intermittently connected
- may have dynamic IP addresses
- do not communicate directly with each other
1-2
3Web and HTTP
- First some jargon
- What is WWW?
- Web page consists of objects
- Objects can be HTML file, JPEG image, JavaScript,
video file, - Web page consists of base HTML-file which
includes several referenced objects - Each object is addressable by a URL
- Example URL
1-3
4HTTP overview
- HTTP hypertext transfer protocol
- Webs application layer protocol
- Resources to be accessed by HTTP are identified
using Uniform Resource Identifiers (URIs)or,
more specifically, Uniform Resource Locators
(URLs)
HTTP request
PC running Explorer
HTTP response
HTTP request
Server running Apache Web server
HTTP response
Mac running Navigator
1-4
5HTTP overview (continued)
- Uses TCP
- client initiates TCP connection (creates socket)
to server, port 80 - server accepts TCP connection from client
- HTTP messages (application-layer protocol
messages) exchanged between browser (HTTP client)
and Web server (HTTP server) - TCP connection closed
- HTTP is stateless
- server maintains no information about past client
requests
1-5
6HTTP connections
- Nonpersistent HTTP
- At most one object is sent over a TCP connection.
- Persistent HTTP
- Multiple objects can be sent over single TCP
connection between client and server.
1-6
7Nonpersistent HTTP
(contains text, references to 10 jpeg images)
- Suppose user enters URL www.someSchool.edu/someDep
artment/home.index
- 1a. HTTP client initiates TCP connection to HTTP
server (process) at www.someSchool.edu on port 80
1b. HTTP server at host www.someSchool.edu
waiting for TCP connection at port 80. accepts
connection, notifying client
2. HTTP client sends HTTP request message
(containing URL) into TCP connection socket.
Message indicates that client wants object
someDepartment/home.index
3. HTTP server receives request message, forms
response message containing requested object, and
sends message into its socket
time
1-7
8Nonpersistent 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
1-8
9Non-Persistent HTTP Response time
- Definition of RTT time for a small packet to
travel from client to server and back. - Response time
- one RTT to initiate TCP connection
- one RTT for HTTP request and first few bytes of
HTTP response to return - file transmission time
- total 2RTTtransmit time
1-9
10Persistent HTTP
- Nonpersistent HTTP issues
- requires 2 RTTs per object
- OS overhead for each TCP connection
- browsers often open parallel TCP connections to
fetch referenced objects
- Persistent HTTP
- server leaves connection open after sending
response - subsequent HTTP messages between same
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
1-10
11Hands-on!Trying out HTTP (client side) for
yourself
- 1. Telnet to your favorite Web server
Opens TCP connection to port 80 (default HTTP
server port)
telnet jjcweb.jjay.cuny.edu 80
- 2. Type in a GET HTTP request
By typing this in (hit carriage return twice),
you send this minimal (but complete) GET request
to HTTP server
GET /ssengupta/ HTTP/1.1 Host jjcweb.jjay.cuny.ed
u
3. Look at response message sent by HTTP server!
1-11
12Request Method types
- GET
- Requests a representation of the specific
resource. - POST
- Submits data to be processed (e.g., from an HTML
form) to the identified resource. The data is
included in the body of the request. This may
result in the creation of a new resource or the
updates of existing resources or both. - PUT
- Uploads a representation of the specific
resource. - DELETE
- Deletes the specific resource.
- TRACE
- Echoes back the received request, so that a
client can see what intermediate servers are
adding or changing in the request.
1-12
13How about Utilization?
- An example
- average object size 100,000 bits
- avg. request rate from institutions browsers to
origin servers 15/sec - Internet 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 seconds milliseconds
- Huge delay
origin servers
public Internet
1.5 Mbps access link
institutional network
10 Mbps LAN
1-13
14How to speed up Internet access?
origin servers
- 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
public Internet
10 Mbps access link
institutional network
10 Mbps LAN
1-14
15A better solution Web Cache
origin servers
- Install web 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
public Internet
1.5 Mbps access link
institutional network
10 Mbps LAN
institutional cache
1-15
16Web caches (proxy server)
Goal satisfy client request without involving
origin server
- user sets browser Web accesses via cache
- browser sends all HTTP requests to cache
- object in cache cache returns object
- else cache requests object from origin server,
then returns object to client
origin server
Proxy server
client
client
origin server
1-16
17More about Web caching
- Why Web caching?
- reduce response time for client request
- reduce traffic on an institutions access link.
- Internet dense with caches enables poor
content providers to effectively deliver content
origin server
Proxy server
client
client
origin server
1-17
18HTTP overview (continued)
- If HTTP is stateless, how does it remember our
session information?
1-18
19User-server state cookies
- Example
- When initial HTTP requests arrives at site, site
creates - unique ID
- entry in backend database for ID
- Many major Web sites use cookies
- 1) cookie file kept on users host, managed by
users browser - 2) back-end database at Web site
- Cookies are not cache!
1-19
20Cookies keeping state (cont.)
client
server
cookie file
backend database
one week later
1-20
21Cookies (continued)
Remember HTTP is stateless
aside
- What cookies can bring
- Authorization (e.g., bypass popup blocker)
- Previous session (e.g., shopping carts)
- Cookies and privacy
- cookies permit sites to learn a lot about you!!!
- Security???
1-21
22Application layer
- 2.1 Web browsing and HTTP
- 2.2 File transferring and FTP (File Transfer
Protocol) - 2.3 Email and SMTP
23FTP the file transfer protocol
file transfer
user at host
remote file system
local file system
- 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
24FTP separate control, data connections
- FTP client contacts FTP server at port 21
- client authorized over control connection
- client browses remote directory by sending
commands over control connection. - when server receives file transfer command,
server opens 2nd TCP connection (for file) to
client - after transferring one file, server closes data
connection.
25Application layer
- 2.1 Web browsing and HTTP
- 2.2 File transferring and FTP
- 2.3 Email and SMTP (Simple Mail Transfer
Protocol)
26Electronic Mail
- Three major components
- user agents
- mail servers
- simple mail transfer protocol SMTP
- User Agent
- a.k.a. mail reader
- composing, editing, reading mail messages
- e.g., Outlook, Mozilla Thunderbird
- outgoing, incoming messages stored on server
27Electronic 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 to send email
messages - client sending mail server
- server receiving mail server
28Scenario Alice sends message to Bob
- 4) Client side of SMTP opens TCP connection with
Bobs mail server and sends Alices message - 5) Bobs mail server places the message in Bobs
mailbox - 6) Bob invokes his user agent to read message
- 1) Alice uses UA to compose message and to
bob_at_someschool.edu - 2) Alices UA sends message to her mail server
- 3) Message placed in message queue
1
2
6
3
4
5
29SMTP comparison with HTTP
- Comparison with HTTP
- HTTP pull
- SMTP push
- HTTP each object encapsulated in its own
response msg - SMTP multiple objects handled
- SMTP uses persistent connections
30Mail access protocols
SMTP
access protocol
receivers mail server
- Post Office Protocol (POP3)
- Internet Message Access Protocol (IMAP)
31POP3 and IMAP Comparison
- POP3
- Uses download and delete mode.
- Bob cannot re-read e-mail if he changes client
- POP3 is stateless across sessions
- IMAP
- Keep all messages in one place the server
- Allows user to organize messages in folders
- IMAP keeps user state across sessions
- names of folders and mappings between message IDs
and folder name
32Summary comparison among the protocols?