Lecture 5
Lecture 5
& Networks
CSNC-2413
Lec: 5
• Web & HTTP Computer
Networking: A Top
Down Approach
6th edition
Jim Kurose, Keith Ross
Addison-Wesley
March 2012
Chapter 2: outline
2.1 Principles of network applications
2.2 Web and HTTP
2.3 FTP
2.4 Electronic mail
SMTP, POP3
2.5 DNS
2.6 P2P applications
2.7 Socket programming with UDP and TCP
2
Web and HTTP
First, a review…
web page consists of a base HTML file
which may include several referenced objects
object can be…
HTML file, JPEG image, Java applet, audio file, etc
each object is addressable by a URL, e.g,
www.someschool.edu/someDept/page.html
3
HTTP overview
HTTP: Hypertext Transfer Protocol
Web’s application layer protocol HT
TP
req
PC running ues
HTTP implemented in two HT
T
t
Firefox browser Pr
programs; clients & servers es p
ons
e
Client (browser) requests
t
web objects u es
req server
T P n se
Server sends objects in response HT s po running
r e Apache Web
T TP
HTTP defines messages exchanged H server
between client/server
iphone running
structure of messages Safari browser
and their sequence
4
HTTP overview
HTTP uses TCP: HTTP is “stateless”
HTTP client initiates TCP server maintains no
connection to server at port 80 information about past
HTTP server accepts TCP client requests
connection from client simplifies design
HTTP client/server then access
TCP thru their socket interfaces aside
exchange HTTP messages
protocols that maintain “ state
” are complex!
TCP provides reliable data delivery need to maintain past history
to HTTP (state)
HTTP need not worry about data
loss, re-ordering
5
HTTP connections
Non-persistent HTTP Persistent HTTP
at most one object sent over multiple objects can be sent
a TCP connection over single TCP connection
connection then closed between
client & server
downloading multiple
objects requires multiple
connections
6
Non-persistent HTTP
(contains text,
suppose user enters URL: references to 10
www.someSchool.edu/someDept/page.html jpeg images)
8
Non-persistent HTTP: response time
RTT : time for a small packet to travel from client to server, & back
9
Persistent HTTP
Persistent HTTP:
Non-persistent HTTP
issues: server leaves TCP connection
open after sending response
requires 2 RTTs per object
subsequent HTTP messages
OS overhead for each TCP between same client/server sent
connection over open connection
browsers often open client sends requests as soon as it
parallel TCP connections to encounters a referenced object
fetch referenced objects
as little as 1 RTT for all the
referenced objects
10
HTTP request message
Two types of HTTP messages: Request, Response
HTTP Request Message general format
11
HTTP request message
HTTP Request message - Example:
ASCII (human-readable format)
If user enters URL: www.someSchool.edu/someDept/page.html
12
HTTP Methods
Some of the common HTTP request methods…
13
Uploading form input
POST method:
web page often includes form input (e.g, user input data)
input is uploaded to server in entity body
URL method:
uses GET method
input is uploaded in URL field of request line:
www.somesite.com/animalsearch?monkeys&banana
14
Method types
HTTP/1.0: HTTP/1.1:
GET GET, POST, HEAD
POST PUT
HEAD uploads file in entity body to
path specified in URL field
DELETE
deletes file specified in the
URL field
15
HTTP response message: general format
16
HTTP response message
status line
(version,
status code,
status phrase) HTTP/1.1 200 OK\r\n
Connection: close\r\n
Date: Sat, 07 Jul 2007 12:00:15 GMT\r\n
header Server: Apache/1.3.0 (Unix)\r\n
lines
Last-Modified: Sun, 06 May 2007 09:23:24 GMT\r\n
Content-Length: 6821\r\n
Content-Type: text/html\r\n
\r\n
data, e.g., data data data data data ...
requested
HTML file
17
HTTP response status codes
status code appears in 1st line in server-to-client response message
some sample codes:
200 OK
request succeeded, requested object later in this msg
301 Moved Permanently
requested object moved, new location specified later in
this msg (Location:)
400 Bad Request
request msg not understood by server
404 Not Found
requested document not found on this server
505 HTTP Version Not Supported
18
Cookies
HTTP server is stateless
Web sites often need to identify users
to restrict access
to serve content as function of user identity
HTTP uses Cookies (unique ID): allow sites to track users
used by most major web sites
Cookie Components:
1) cookie header line in HTTP response message
2) cookie header line in next HTTP request message
3) cookie file kept on user’s host, managed by user’s browser
4) back-end database at Web site
19
Cookies: keeping “ state”
Example:
User visits a specific e-commerce site for first time
When initial HTTP request arrives at site, it creates:
unique ID (cookie)
entry in backend database for ID
sends ID back to user
20
Cookies: keeping “ state”
21
Cookies
What cookies can be used
for:
cookies and privacy:
authorization
cookies permit sites to learn
shopping carts about you…
you may supply name, e-
recommendations
mail, account info, to sites
usersession state info may be misused
(Web e-mail)
22
Web caches (proxy server)
Goal: satisfy client request without involving origin server
user sets browser:
web access via cache
browser sends all HTTP HT proxy
TP ue st
requests to cache req server req
HT ues P se
client TP t H TT p on
res res origin
if, object in cache: pon
se TP server
HT
cache returns object u est
req e
T P o ns
else, cache requests object HT
res
p
TP
from origin server, then H T
returns object to client
client origin
server
23
More about Web caching
Cache acts as both client and Why Web caching?
server reduce response time
as server, to original for client request
requesting client reduce traffic
as client, to origin server on an institution’s access
Typically cache is installed link
by ISP (university, company,
residential ISP)
Limitation: copy of cached
object may be stale…
24
More about Web caching
If-modified-since: <date>