week3lecture1_MSEE

advertisement
Chapter 2
Application Layer
Computer Networking: A
Top Down Approach,
4th edition.
Jim Kurose, Keith Ross
Addison-Wesley, July
2007.
Last Lecture
•Queuing Delay
•Internet Protocol Stack
•Layered Architecture
Chapter 2
•Application Layer
•What Transport Service does an
Application need?
•Internet Transport Protocols Services
Today’s Lecture
HTTP
 Persistent HTTP
 Non-Persistent HTTP
SMTP
Queuing Delay
 When is Queuing Delay large and
when it is insignificant?
 Rate at which traffic arrives at the
queue
 Transmission rate of the link
 Nature of the arriving traffic
 R=Transmission Rate (bps)
 L=packet length(bits)
 a=average packet arrival
rate(packets/sec)
Traffic Intensity = (Average rate at which bits arrive at the queue) =La
Transmission Rate
R
 La/R ~ 0: average queuing delay small
 La/R -> 1: delays become large (queue begins to get larger)
 La/R > 1: average rate at which bits arrive at the queue exceeds the
rate at which the bits can be transmitted from the queue.
 more “work” arriving than can be serviced
 Packet Loss will occur
Protocol Layers
Networks are complex!
• many “pieces”:
– hosts
– routers
– links of various
media
– applications
– protocols
– hardware,
software
Question:
Is there any way of
organizing network
architecture?
Answer:
Yes possible with a
layered architecture
Internet Protocol Stack
 Application: Provides user interfaces and
support for services such as e-mail, file
transfer etc.

FTP, HTTP
 Transport: Transports application-layer
messages between application end points.


Segmentation and reassembly
TCP, UDP
 Network: Routing of Datagrams from
source to destination

IP, routing protocols
 Link: Move a packet from one node (host or
router) to the next node in the route.
 Ethernet, WiFi
 Physical: Move the individual bits with in
frames from one node to next
Application
Transport
Network
Link
Physical
OSI Reference Model
 In 1970 International Organization for
Standardization proposed a seven layered
model called Open Systems
Interconnection (OSI) model.
 Presentation Layer: Provide services such
as data encryption, compression.
 Session Layer: Synchronization points
(checkpointing) and recovery of data
exchange.
 Internet stack “missing” these layers!
 these services, if needed, must be
implemented in the application by the
application developer.
What Transport Service does an
Application need?
Data Loss (Reliability)
 Loss Tolerant Applications


Some apps (e.g., audio, VoIP)
can tolerate some loss
2% tolerable for VoIP
 Other apps (e.g., file transfer,
email) require 100% reliable
data transfer
Timing
 Tight timing constraints
Multiplayer games, VoIP,
teleconferencing.
 In Non-real time lower delays
are preferred but no tight
constraint on end-to-end
delays.

Throughput
 Bandwidth sensitive
applications (e.g., multimedia)
require minimum amount of
throughput
 Other apps (“elastic apps”)
make use of whatever
throughput they get
e.g .Email, file transfer
Security
 Encryption, end point
authentication
Addressing processes
 To receive messages,
process must have
identifier
 host device has unique 32bit IP address
 To identify the receiving process


 Q: does IP address of host
on which process runs
suffice for identifying the
process?

A: No, many processes
can be running on same
host



two pieces of information need to
be specified:
IP address of the host
Port number
 Identifier that specifies the
receiving process in the
destination host
 Popular applications have been
assigned a specific port number.
Example port numbers:
 HTTP server: 80
 Mail server: 25
www.iana.org (well known port
numbers for all protocols)
More in chapter 3
Hyper Text Transfer Protocol (HTTP)
 HTTP defined in RFC 1945 and RFC 2616
 HTTP implemented on both client and server sides
 HTTP defines
structure of messages exchanged between client and
server.
How the client and server exchange the messages
 Web browsers implement the client side of HTTP
 Web Servers implement the server side of HTTP
 Host web objects each addressable by a URL
 Web page consists of objects
 Object can be HTML file, JPEG image, audio file …
 Web pages consist of base HTML file and several
referenced objects
 Each object is addressable by a URL
HTTP overview
HTTP: hypertext
transfer protocol
 Web’s application layer
protocol
 client/server model
 client: browser that
requests, receives,
“displays” Web objects
 server: Web server
sends objects in
response to requests
PC running
Explorer
Server
running
Apache Web
server
Linux running
Firefox
HTTP 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)
 Advantage of Layered architecture
 HTTP does not worry about lost data or how TCP
recovers from loss
HTTP is “stateless”
 Server maintains no information about past client
requests
HTTP 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.
Nonpersistent HTTP
(contains text,
Suppose user enters URL
references to 10
www.someSchool.edu/someDepartment/home.index
jpeg images)
1a. HTTP client initiates TCP
connection to HTTP server
(process) at
www.someSchool.edu on port 80
2. HTTP client sends HTTP
request message (containing
URL) into TCP connection
socket. Message indicates that
client wants object
someDepartment/home.index
time
1b. HTTP server at host
www.someSchool.edu waiting
for TCP connection at port 80.
“accepts” connection, notifying
client
3. HTTP server receives request
message, forms response
message containing requested
object, and sends message into
its socket
Nonpersistent HTTP (cont.)
4. HTTP server closes TCP
5. HTTP client receives response
time
connection.
message containing html file,
displays html. Parsing html
file, finds 10 referenced jpeg
objects
6. Steps 1-4 repeated for each
of 10 jpeg objects
 When the user requests the webpage 11 TCP connections
are generated
Non-Persistent HTTP: Response time
Definition of RTT: time for
a packet to travel from
client to server and
back.
Response time:
 one RTT to initiate TCP
connection
 one RTT for HTTP
request response
 file transmission time
total = 2RTT+transmit time
initiate TCP
connection
RTT
request
file
RTT
file
received
time
time to
transmit
file
time
Persistent HTTP
Nonpersistent HTTP
issues:
 Requires 2 RTTs per
object
 Maintain TCP buffers in
both client and server
 Burden on the Web
Server
 High overhead
Persistent HTTP
 Server leaves
connection open after
sending response
 Subsequent HTTP
messages between
same client/server
sent over open
connection
 Default mode is
Persistent
HTTP Request Message
Two types of HTTP messages:
Request, Response
HTTP request message:
Human-readable format
A typical HTTP request message
GET /somedir/page.html HTTP/1.1
Host: www.someschool.edu
User-agent: Mozilla/4.0
Connection: close
Accept-language:fr
(Blank Line)
Body
HTTP Request Message
 Request Line
First Line of HTTP request message
 The request line has three fields
 Method field can take on several values
GET,POST, PUT, DELETE etc
Majority of HTTP request messages use GET
 URL field
 HTTP version field
 Header Lines
 Host: Host on which the object resides
 User-agent: Identifies the client program e.g. Mozilla/4.0
 Connection: Shows whether the connection should be closed
or not
 Accept-language: Shows the language the client prefers

HTTP Request Message
 Body is empty with
GET method
 Used with the POST
method
 Web page often
includes form input
 Input is sent to
server in body
PUT method:
 To upload objects to
web server
DELETE method
 Allows a user or an
application to delete
an object on web
server
Find out about OPTIONS, TRACE, HEAD?
HTTP Response Message
HTTP/1.1 200 OK
Connection: close
Date: Thu, 06 Aug 1998 12:00:15
GMT
Server: Apache/1.3.0 (Unix)
Last-Modified: Mon, 22 Jun 1998
Content-Length: 6821
Content-Type: text/html
Body contains Requested Object
HTTP Response Message
 Status Line
 Protocol Version
 Status Code and Status Message
 The status code and associated phrase indicate the result of
the request
 Header Line
 Connection: Shows whether the connection should be closed
or not
 Date and time: When the HTTP response was created
 Server: Analogous to user-agent in request message
 Last-modified: When the Object was last created or
modified
 Content-length: Number of bytes in object being sent
 Content-Type: Indicates the object type (HTML text etc.)
HTTP Response Status Codes
The status code and associated phrase indicate the result of
the request
200 OK

Request succeeded and information is returned in
response
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
503 Service Unavailable

The service is temporarily unavailable
User-Server Interaction: Cookies
 It is often desirable for web
servers to identify users
 Server wishes to restrict
user access
 Wants to serve content as a
function of user identity
 Many major Web sites use
cookies
Four components:
1) Cookie header line of
HTTP response message
2) Cookie header line in
HTTP request message
3) Cookie file kept on user’s
host, managed by user’s
browser
4) Back-end database at
Web site
Example:
• Susan accesses
Internet always from PC
• visits specific ecommerce site for first
time
• When initial HTTP
requests arrives at
server, server creates:
– unique ID
– entry in backend
database for ID
Cookies: keeping “state” (cont.)
Client
Server
usual http request msg
cookie file
usual http response
Set-cookie: 1678
amazon 1678
usual http request msg
cookie: 1678
one week later:
usual http response msg
Amazon server
creates ID
1678 for user create
entry
cookiespecific
action
access
access
amazon 1678
usual http request msg
cookie: 1678
usual http response msg
cookiespectific
action
backend
database
Cookies (continued)
Cookies
• Pages visited in which
order and at what
times
• Shopping carts
• One click shopping
• Recommendations of
other products
Cookies and privacy:
 Cookies permit sites to
learn a lot about you
 Can inform third
party
 You may supply name
and e-mail to sites
Third Party Cookies?
For more info on Cookies see
•
RFC-2109 HTTP State Management Mechanism
•
www.cookiecentral.com
Web Caches (Proxy Server)
Goal: Satisfy client request without involving origin server
• Web Cache has its own
disk storage
• Keeps copies of recently
requested objects in
storage
• 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
More about Web Caching
 Cache acts as both
client and server
 Typically cache is
installed by ISP
(university, company)
Why Web Caching?
 Reduce response time
for client request
 Reduce traffic on an
institution’s access link.
 Does not have to upgrade
bandwidth as quickly,
thereby reducing costs.
Conditional GET
 Problem: The copy of the object residing in the cache
may be stale
 The object may have been modified since the copy
was cached
 HTTP has a mechanism that allows a cache to verify
that its objects are up to date
Conditional GET message
 (1) The request message uses the GET method
 (2) The request message includes an If-Modified-
Since header line.
Conditional GET
 Goal: Don’t send object if
cache has up-to-date cached
version
 Cache: specify date of
cached copy in HTTP request
If-modified-since: <date>
 Server: Response contains no
object if cached copy is upto-date:
 HTTP/1.0 304 Not
Modified
 Waste bandwidth
 Increases response time
Server
Cache
HTTP request msg
If-modified-since:
<date>
HTTP response
Object
not
Modified
HTTP/1.0
304 Not Modified
HTTP request msg
If-modified-since:
<date>
HTTP response
HTTP/1.0 200 OK
<data>
Object
Modified
Electronic Mail
outgoing
message queue
user mailbox
Asynchronous Medium
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., Eudora, Outlook, Mozilla
Thunderbird
• Sends message to the mail
server
user
agent
mail
server
user
agent
SMTP
SMTP
mail
server
user
agent
SMTP
user
agent
mail
server
user
agent
user
agent
Electronic Mail
Mail Servers
 Each recipient has a mailbox
located in one of the mail servers
 Mailbox manages and maintains the
mail
messages that have been sent to
server
him.
 Message queue of outgoing (to be
sent) mail messages
SMTP
 Simple Mail Transfer Protocol
(SMTP) between mail servers to
send email messages
mail
 Client and Server
server
 Both client and sever sides of
SMTP run on every mail server.
 Runs on TCP at port 25.
user
agent
 RFC 5321
user
agent
SMTP
SMTP
user
agent
user
agent
mail
server
user
agent
user
agent
Scenario: Alice sends message to Bob
1) Alice uses UA to compose
message to
bob@someschool.edu
2) Alice’s UA sends message
to her mail server; message
placed in message queue
3) Client side of SMTP opens
TCP connection with Bob’s
mail server
1
user
agent
2
mail
server
3
4) SMTP client sends Alice’s
message over the TCP
connection
5) Bob’s mail server places the
message in Bob’s mailbox
6) Bob invokes his user agent
to read message
mail
server
4
5
6
user
agent
Sample SMTP Interaction
•Client SMTP establishes a TCP connection with Server
SMTP
•Application Layer handshaking to introduce themselves
Sample SMTP Interaction
S: 220 hamburger.edu (Service Ready)
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 (All lines after DATA command are treated as the
mail message)
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
SMTP
 SMTP uses persistent connections

Can send all of the messages over the same TCP connection
Comparison with HTTP:
 HTTP transfer files from web server to web client
 SMTP from one mail server to another
 Both use Persistent Connections
 HTTP: pull


Someone loads information on a web server and users use
HTTP to pull this info
TCP connection is initiated by the machine that wants to
receive the file
 SMTP: push


Sending mail sever pushes the file to the receiving mail server
TCP connection is initiated by the machine that wants to send
the file
Mail access protocols
SMTP
SMTP
user
agent
sender’s mail
server
access
protocol
receiver’s mail
server
 SMTP: delivery/storage to receiver’s server
 Mail access protocol: retrieval from server



POP: Post Office Protocol [RFC 1939]
IMAP: Internet Mail Access Protocol [RFC 1730]
HTTP: Gmail, Hotmail, Yahoo! Mail, etc.
• User agent is ordinary web browser
• HTTP to send email to web server
• HTTP to access mail box
user
agent
Reading Assignment
 POP:
Post Office Protocol (POP)
 IMAP: Internet Mail Access
Protocol(IMAP)
 File Transfer Protocol(FTP)
Thank You
Download