0% found this document useful (0 votes)
6 views

Lecture 09

Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Lecture 09

Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 22

CSC339 – DATA

COMMUNICATIONS AND
COMPUTER NETWORKS
LECTURE 09
Course Instructors:
Dr. Waseem Abbas
AGENDA
 Web and HTTP
 Non-Persistent and Persistent Connections
 HTTP Message Format
 User-Server Interaction: Cookies
 Web Caching

Chapter 2: Application Layer


Book: Computer Networking: A Top Down
Approach.
Author: Jim Kurose, Keith Ross Addison-Wesley
WEB AND HTTP
First, a quick review…
 web page consists of objects, each of which can
be stored on different Web servers
 object can be HTML file, JPEG image, Java applet,
audio file,…
 web page consists of base HTML-file which
includes several referenced objects, each
addressable by a URL, e.g.,
www.someschool.edu/someDeptartment/picture.gif

host name path name


HTTP OVERVIEW
[RFC 1945][RFC 2616]

HTTP: hypertext transfer protocol


 Web’s application layer protocol
HT
 client/server model: PC running H
TP
req
ues
TTP t
• client: browser that requests, Firefox browser res
pon
receives, (using HTTP protocol) and se

“displays” Web objects u es


t
req
• server: Web server sends (using HTTP
p o ns server running
e
es Apache Web
HTTP protocol) objects in response HT
T P r
server
to requests
iPhone running
Safari browser
HTTP OVERVIEW (CONTINUED)
HTTP uses TCP: HTTP is “stateless”
 client initiates TCP connection  server maintains no
(creates socket) to server, port information about past client
80 requests
 server accepts TCP connection
from client aside
 HTTP messages (application- protocols that maintain
“state” are complex!
layer protocol messages)  past history (state) must be
exchanged between browser maintained
(HTTP client) and Web server  if server/client crashes, their
(HTTP server) views of “state” may be
 TCP connection closed inconsistent, must be reconciled
HTTP CONNECTIONS: TWO TYPES
Non-persistent HTTP Persistent HTTP
1. TCP connection opened  TCP connection opened
2. at most one object to a server
sent over TCP  multiple objects can be
connection sent over single TCP
3. TCP connection closed connection between
client, and that server
downloading multiple  TCP connection closed
objects required multiple
connections
NON-PERSISTENT HTTP: EXAMPLE
User enters URL: www.someSchool.edu/someDepartment/home.index
(containing text, references to 10 jpeg images)

1a. HTTP client initiates TCP


connection to HTTP server 1b. HTTP server at host
(process) at www.someSchool.edu waiting for
www.someSchool.edu on port TCP connection at port 80
80 “accepts” connection, notifying
2. HTTP client sends HTTP client
request message
(containing URL) into 3. HTTP server receives request
TCP connection socket. message, forms response
time Message indicates that message containing requested
client wants object object, and sends message into
someDepartment/home.inde its socket
NON-PERSISTENT HTTP: EXAMPLE (CONT.)
User enters URL: www.someSchool.edu/someDepartment/home.index
(containing text, references to 10 jpeg images)

4. HTTP server closes


5. HTTP client receives TCP connection.
response message
containing html file, displays
html. Parsing html file, finds
10 referenced jpeg objects
6. Steps 1-5 repeated
for each of 10 jpeg
time objects
NON-PERSISTENT HTTP: RESPONSE TIME

RTT (definition): round-trip


time (RTT) , time for a
small packet to travel from initiate TCP
client to server and back connection
RTT
HTTP response time (per
request file
object): time to
 one RTT to initiate TCP RTT
transmit
connection file
file
 one RTT for HTTP request and received
first few bytes of HTTP response
to return time time
 Non-persistent
object/file transmission time time = 2RTT+ file
HTTP response
transmission time
PERSISTENT HTTP (HTTP 1.1)
Non-persistent HTTP issues: Persistent HTTP (HTTP1.1):
 requires 2 RTTs per object  server leaves connection open
 OS overhead for each TCP after sending response
connection  subsequent HTTP messages
 browsers often open multiple between same client/server sent
parallel TCP connections to over open connection
fetch referenced objects in  client sends requests as soon as
parallel it encounters a referenced object
 as little as one RTT for all the
referenced objects (cutting
response time in half)
HTTP REQUEST MESSAGE
 two types of HTTP messages: request, response
 HTTP request message:
• ASCII (human-readable format)
carriage return character
line-feed character
request line (GET,
GET /index.html HTTP/1.1\r\n
POST, Host: www-net.cs.umass.edu\r\n
HEAD commands) User-Agent: Firefox/3.6.10\r\n
Accept: text/html,application/xhtml+xml\r\n
headerAccept-Language: en-us,en;q=0.5\r\n
linesAccept-Encoding: gzip,deflate\r\n
Accept-Charset: ISO-8859-1,utf-8;q=0.7\r\n
Keep-Alive: 115\r\n
Connection: keep-alive\r\n
carriage return, line \r\n
feed at start of line
indicates end of * Check out the online interactive exercises for more
header lines examples: http://gaia.cs.umass.edu/kurose_ross/interactive/
HTTP REQUEST MESSAGE: GENERAL FORMAT
OTHER HTTP REQUEST MESSAGES
POST method: HEAD method:
 web page often includes  requests headers (only)
form input that would be returned if
 user input sent from client specified URL were
to server in entity body of requested with an HTTP
HTTP POST request GET method.
message PUT method:
 uploads new file (object) to
GET method (for sending data to server
server):  completely replaces file
 include user data in URL field of that exists at specified URL
HTTP GET request message with content in entity body
(following a ‘?’): of POST HTTP request
www.somesite.com/animalsearch?monkeys&banana message
HTTP RESPONSE MESSAGE
status line (protocol HTTP/1.1 200 OK\r\n
status code status Date: Sun, 26 Sep 2010 20:09:20 GMT\r\n
Server: Apache/2.0.52 (CentOS)\r\n
phrase) Last-Modified: Tue, 30 Oct 2007 17:00:02
GMT\r\n
ETag: "17dc6-a5c-bf716880"\r\n
header Accept-Ranges: bytes\r\n
lines Content-Length: 2652\r\n
Keep-Alive: timeout=10, max=100\r\n
Connection: Keep-Alive\r\n
Content-Type: text/html; charset=ISO-8859-1\
r\n
\r\n
data, e.g., requested data data data data data ...
HTML file

* Check out the online interactive exercises for more examples: h ttp://gaia.cs.umass.edu/kurose_ross/interactive/
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 message
301 Moved Permanently
• requested object moved, new location specified later in this message (in
Location: field)
400 Bad Request
• request msg not understood by server
404 Not Found
• requested document not found on this server
505 HTTP Version Not Supported
USER-SERVER INTERACTION: COOKIES
[RFC 6265]

Recall: HTTP GET/response However, it is often desirable


interaction is stateless for a Web site to identify
 simplifies server design users
 permitted engineers to  either because the server
develop high-performance wishes to restrict user
Web servers access
 Handle thousands of  Or it wants to serve content
simultaneous TCP as a function of the user
connections identity
For these purposes, HTTP
uses cookies
MAINTAINING USER/SERVER STATE: COOKIES
Web sites and client browser Example:
use cookies to maintain  Susan uses browser on
laptop, visits specific e-
some state between commerce site for first
transactions time
 when initial HTTP
four components:
requests arrives at site,
1) cookie header line of HTTP site creates:
response message • unique ID (aka
2) cookie header line in next “cookie”)
HTTP request message • entry in backend
3) cookie file kept on user’s database for ID
host, managed by user’s • subsequent HTTP
browser requests from Susan to
this site will contain
MAINTAINING USER/SERVER STATE: COOKIES
client
server
ebay 8734
usual HTTP request Amazon server
cookie file msg creates ID
usual HTTP response 1678 for user create backend
ebay 8734 set-cookie: entry database
amazon 1678
1678
usual HTTP request
msg cookie- access
cookie: 1678 specific
usual HTTP response action
msg
one week later:
access
ebay 8734 usual HTTP request
amazon 1678
msg cookie-
cookie: 1678 specific
usual HTTP response action
time
msg time
HTTP COOKIES: COMMENTS
aside
What cookies can be used for: cookies and privacy:
 authorization  cookies permit sites
 shopping carts to learn a lot about
 recommendations you on their site.
 third party persistent
 user session state (Web e-mail) cookies (tracking
cookies) allow
common identity
Challenge: How to keep state: (cookie value) to be
 protocol endpoints: maintain state at
tracked across
sender/receiver over multiple
multiple web sites
transactions
 cookies: HTTP messages carry state
WEB CACHES (PROXY SERVERS)
Goal: satisfy client request without involving
origin server
 user configures browser proxy
HT st
to point to a Web cache TP
req server
req
u e
HT ues T P se
client TP t T n
 browser sends all HTTP res
pon
H
res p
o origin
se TP server
requests to cache t HT
u es
• if object in cache: req se
P n
HT
T
s po
cache returns object T Pr
e
to client HT

• else cache requests client


origin
object from origin server
server, caches
received object, then
returns object to client
WEB CACHES (PROXY SERVERS)
 Web cache acts as Why Web caching?
both client and  reduce response time for
server client request
• server for original • cache is closer to client
requesting client
• client to origin server
 reduce traffic on an
institution’s access link
 typically cache is
installed by ISP  Internet is dense with
(university, caches
company, • enables “poor” content
residential ISP) providers to more
effectively deliver content
NEXT LECTURE TOPICS
 File Transfer – FTP
 Electronic Mail in Internet

You might also like