networks5-ch2-2
DESCRIPTION
computer networks...............TRANSCRIPT
-
1
Computer Networks
HTTP
1
Web and HTTP
First some jargon
Web page consists of objects Object can be HTML le, JPEG image, Java applet, audio le, Web page consists of base HTML-le which includes several
referenced objects
Each object is addressable by a URL Example URL:
2
www.someschool.edu/someDept/pic.gif
host name path name
-
2
HTTP overview HTTP: hypertext transfer protocol Webs applicaOon layer protocol client/server model
client: browser that requests, receives, displays Web objects
server: Web server sends objects in response to requests
Uses TCP: client iniOates TCP connecOon (creates socket) to server, port 80 server accepts TCP connecOon from client HTTP messages (applicaOon-layer protocol messages) exchanged between browser (HTTP
client) and Web server (HTTP server) TCP connecOon closed HTTP is stateless server maintains no informaOon about past client requests Protocols that maintain state are complex! past history (state) must be maintained if server/client crashes, their views of state may be inconsistent, must be reconciled
3
PC running Explorer
Server running Apache Web server Mac running
Navigator
HTTP request
HTTP re
quest
HTTP response
HTTP re
sponse
HTTP connecOons
Nonpersistent HTTP
At most one object is sent over a TCP connecOon.
Persistent HTTP
MulOple objects can be sent over single TCP connecOon between client and server.
4
-
3
Nonpersistent HTTP Suppose user enters URL www.someSchool.edu/someDepartment/home.index (contains text, references to 10 jpeg images)
1a. HTTP client iniOates TCP connecOon to HTTP server (process) at www.someSchool.edu on port 80
5
2. HTTP client sends HTTP request message (containing URL) into TCP connecOon socket. Message indicates that client wants object someDepartment/home.index
1b. HTTP server at host www.someSchool.edu waiOng for TCP connecOon at port 80. accepts connecOon, noOfying client
3. HTTP server receives request message, forms response message containing requested object, and sends message into its socket
Ome
5. HTTP client receives response message containing html le, displays html. Parsing html le, nds 10 referenced jpeg objects
4. HTTP server closes TCP connecOon.
6. Steps 1-5 repeated for each of 10 jpeg objects
Non-Persistent HTTP: Response Ome
DeniOon of RTT: Ome for a small packet to travel from client to server and back.
Response Ome:
one RTT to iniOate TCP connecOon
one RTT for HTTP request and rst few bytes of HTTP response to return
le transmission Ome total = 2RTT+transmit Ome
6
time to transmit file
initiate TCP connection
RTT request file
RTT
file received
time time
-
4
Persistent HTTP
Nonpersistent HTTP issues:
requires 2 RTTs per object OS overhead for each TCP
connecOon
browsers oeen open parallel TCP connecOons to fetch referenced objects
Persistent HTTP
server leaves connecOon open aeer sending response
subsequent HTTP messages between same client/server sent over open connecOon
client sends requests as soon as it encounters a referenced object
as lifle as one RTT for all the referenced objects
7
HTTP request message
two types of HTTP messages: request, response HTTP request message:
ASCII (human-readable format)
8
GET /somedir/page.html HTTP/1.1 Host: www.someschool.edu User-agent: Mozilla/4.0 Connection: close Accept-language:fr
(extra carriage return, line feed)
request line (GET, POST,
HEAD commands)
header lines
Carriage return, line feed
indicates end of message
-
5
HTTP request message: general format
9
Uploading form input
Post method:
Web page oeen includes form input
Input is uploaded to server in enOty body
URL method:
Uses GET method Input is uploaded in URL
eld of request line:
10
www.somesite.com/animalsearch?monkeys&banana
-
6
Method types
HTTP/1.0
GET POST HEAD
asks server to leave requested object out of response
HTTP/1.1
GET, POST, HEAD PUT
uploads le in enOty body to path specied in URL eld
DELETE deletes le specied in the
URL eld
11
HTTP response message
12
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 data data data data data ...
status line (protocol
status code status phrase)
header lines
data, e.g., requested HTML file
-
7
HTTP response status codes
200 OK request succeeded, requested object later in this message
301 Moved Permanently requested object moved, new locaOon specied later in this
message (LocaOon:)
304 Not modied See condiOonal GET
400 Bad Request request message not understood by server
404 Not Found requested document not found on this server
505 HTTP Version Not Supported 13
In rst line in server -> client response message.
A few sample codes:
User-server state: cookies
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 le kept on users host,
managed by users browser 4) back-end database at Web
site
Example:
Susan always access Internet always from PC
visits specic e-commerce site for rst Ome
when iniOal HTTP requests arrives at site, site creates:
unique ID entry in backend database for ID
14
-
8
Cookies: keeping state (cont.)
15
client server
usual http response msg
usual http response msg
cookie file
one week later:
usual http request msg cookie: 1678 cookie- specific action
access
ebay 8734 usual http request msg Amazon server
creates ID 1678 for user create entry
usual http response Set-cookie: 1678 ebay 8734 amazon 1678
usual http request msg cookie: 1678 cookie- spectific
action
access ebay 8734 amazon 1678
backend database
Cookies (conOnued) What cookies can bring:
authorizaOon shopping carts recommendaOons user session state (Web e-
mail)
16
Cookies and privacy:
cookies permit sites to learn a lot about you
you may supply name and e-mail to sites
aside
How to keep state:
protocol endpoints: maintain state at sender/receiver over mulOple transacOons
cookies: hfp messages carry state
-
9
Web caches (proxy 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
17
Goal: satisfy client request without involving origin server
client
Proxy server
client
HTTP re
quest
HTTP re
sponse
HTTP request HTTP req
uest
origin server
origin server
HTTP response HTTP res
ponse
More about Web caching
cache acts as both client and server
typically cache is installed by ISP (university, company, residenOal ISP)
Why Web caching?
reduce response Ome for client request
reduce trac on an insOtuOons access link.
Internet dense with caches: enables poor content providers to eecOvely deliver content (but so does P2P le sharing)
18
-
10
Caching example AssumpOons average object size = 1,000,000
bits avg. request rate from insOtuOons
browsers to origin servers = 15/sec delay from insOtuOonal router to
any origin server and back to router = 2 sec
Consequences uOlizaOon on LAN = 15% uOlizaOon on access link = 100% total delay = Internet delay + access
delay + LAN delay = 2 sec + minutes + milliseconds
19
origin servers
public Internet
institutional network 100 Mbps LAN
15 Mbps access link
institutional cache
Caching example (cont) possible soluOon increase bandwidth of access link
to, say, 100 Mbps
consequence uOlizaOon on LAN = 15% uOlizaOon on access link = 15% Total delay = Internet delay + access
delay + LAN delay
= 2 sec + msecs + msecs oeen a costly upgrade
20
origin servers
public Internet
institutional network 100 Mbps LAN
100 Mbps access link
institutional cache
-
11
Caching example (cont)
possible soluOon: install cache suppose hit rate is 0.4 consequence 40% requests will be saOsed
almost immediately 60% requests saOsed by origin
server uOlizaOon of access link reduced
to 60%, resulOng in negligible delays (say 10 msec)
total avg delay = Internet delay + access delay + LAN delay = .6*(2.01) secs + .4*milliseconds < 1.4 secs
21
origin servers
public Internet
institutional network 100 Mbps LAN
15 Mbps access link
institutional cache
CondiOonal GET
Goal: dont send object if cache has up-to-date cached version
cache: specify date of cached copy in HTTP request If-modified-since:
server: response contains no
object if cached copy is up-to-date: HTTP/1.0 304 Not
Modified
22
cache server HTTP request msg
If-modified-since:
HTTP response HTTP/1.0
304 Not Modified
object not
modified
HTTP request msg If-modified-since:
HTTP response HTTP/1.0 200 OK
object modified