0% found this document useful (0 votes)
122 views41 pages

Lecture 3 To Lecture 5 (HTTP) PDF

This document discusses an agenda on the application layer protocol HTTP. It begins with introducing some network vocabulary terms. It then discusses what a protocol is and provides examples of a human protocol and a computer network protocol. It also discusses how network applications are created by having programs run on end systems that communicate over the network without needing to write software for network core devices. The document then discusses different application architectures, including client-server and peer-to-peer. It introduces the concept of processes communicating within and across hosts using sockets and addressing processes via IP addresses and port numbers. Finally, it provides an overview of the HTTP protocol, including how web pages consist of objects addressed via URLs, and the client-server model of HTTP with browsers as

Uploaded by

abhishek reddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
122 views41 pages

Lecture 3 To Lecture 5 (HTTP) PDF

This document discusses an agenda on the application layer protocol HTTP. It begins with introducing some network vocabulary terms. It then discusses what a protocol is and provides examples of a human protocol and a computer network protocol. It also discusses how network applications are created by having programs run on end systems that communicate over the network without needing to write software for network core devices. The document then discusses different application architectures, including client-server and peer-to-peer. It introduces the concept of processes communicating within and across hosts using sockets and addressing processes via IP addresses and port numbers. Finally, it provides an overview of the HTTP protocol, including how web pages consist of objects addressed via URLs, and the client-server model of HTTP with browsers as

Uploaded by

abhishek reddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

CS F303

(Computer Networks)
Vishal Gupta
Department of Computer Science and Information Systems
BITS Pilani Birla Institute of Technology and Science
Pilani|Dubai|Goa|Hyderabad
Pilani Campus, Pilani
BITS Pilani
Pilani|Dubai|Goa|Hyderabad

Agenda: Application Layer: HTTP

The slides aretaken from the slides made available for Computer Networking:ATop DownApproach 6th edition Jim Kurose,Keith RossAddison-Wesley
Network Vocabulary
• Hosts / End-Systems
• Communication Links
• Packet Switches (Routers, Link Layer
Switches)
• Transmission rate
• Packets
• Access Network
• Network Core
• Path
• Connection Oriented Service vs.
Connection Less Service
• ISP
• IETF (Internet Engineering Task Force)
• RFC
• IEEE (eg IEEE 802 LAN/MAN Standards
Committee)

VISHAL GUPTA, PhD 3 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
What is a Protocol

A protocol defines the format and the order of messages


exchanged between two or more communication entities, as
well as the actions taken on the transmission and/or receipt of a
message or the other event.

VISHAL GUPTA, PhD 4 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
What is a Protocol
a human protocol and a computer network protocol:

Hello TCP connection


request
Hello TCP connection
response
What is the
time? Get https://universe.bits- pilani.ac.in/pilani/vishalgupta/profile
2:00
<file>
time

VISHAL GUPTA, PhD 5 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Creating a Network
Application
application
transport
write programs that: network
data link

• run on (different) end systems physical

• communicate over network


• e.g., web server software
communicates with browser
software

no need to write software for


network-core devices application
transport
• network-core devices do not network
data link application
physical transport
run user applications network
data link
• applications on end systems physical

allows for rapid app


development, propagation
VISHAL GUPTA, PhD 6 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Application architectures
possible structure of applications:
• client-server
• peer-to-peer (P2P)

VISHAL GUPTA, PhD 7 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Client-server architecture
server:
• always-on host
• permanent IP address
• data centers for scaling

clients:
• communicate with server
client/server
• may be intermittently connected
• may have dynamic IP addresses
• do not communicate directly
with each other

VISHAL GUPTA, PhD 8 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
P2P architecture
• no always-on server peer-peer
• arbitrary end systems directly
communicate
• peers request service from
other peers, provide service in
return to other peers
– self scalability – new
peers bring new
service capacity, as
well as new service
demands
• peers are intermittently
connected and change IP
addresses
– complex management

VISHAL GUPTA, PhD 9 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Processes communicating
process: program running clients, servers
within a host client process: process
• within same host, two that initiates
communication
processes communicate
using inter-process server process: process
communication (defined by that waits to be contacted
OS)
• processes in different hosts  aside: applications with P2P
communicate by architectures have client
exchanging messages processes & server
processes

Application Layer 2-10


Sockets
• process sends/receives messages to/from its socket
• socket analogous to door
– sending process shoves message out door
– sending process relies on transport infrastructure on
other side of door to deliver message to socket at
receiving process

application application
socket controlled by
process process app developer

transport transport
network network controlled
link by OS
link Internet
physical physical

Application Layer 2-11


Addressing processes
• to receive messages, • identifier includes both IP
process must have address and port numbers
identifier associated with process on
• host device has unique 32- host.
bit IP address • example port numbers:
• Q: does IP address of host – HTTP server: 80
on which process runs – mail server: 25
suffice for identifying the • to send HTTP message to
process? gaia.cs.umass.edu web
 A: no, many processes server:
can be running on same – IP address: 128.119.245.12
host – port number: 80
• more shortly…
Application Layer 2-12
BITS Pilani
Pilani|Dubai|Goa|Hyderabad

HTTP Protocol
Hyper Text Transfer Protocol
Web and HTTP
First, a review…
• web page consists of objects
• object can be HTML file, JPEG image, Java
applet, audio file,…
• web page consists of base HTML-file which
includes several referenced objects
• each object is addressable by a URL, e.g.,
www.someschool.edu/someDept/pic.gif

host name path name

Application Layer 2-14 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
HTTP overview
HTTP: hypertext transfer
protocol
• Web’s application layer
protocol PC running
Firefox browser
• client/server model
– client: browser that
requests, receives,
(using HTTP protocol) server
and “displays” Web running
objects Apache Web
– server: Web server server
sends (using HTTP
protocol) objects in iphone running
response to requests Safari browser

Application Layer 2-15


HTTP overview (continued)
uses TCP: HTTP is “stateless”
• client initiates TCP connection • server maintains no
(creates socket) to server, information about
past client requests
port 80
• server accepts TCP connection
aside
from client protocols that maintain
• HTTP messages (application- “state” are complex!
layer protocol messages)  past history (state) must be
maintained
exchanged between browser  if server/client crashes, their
(HTTP client) and Web server views of “state” may be
(HTTP server) inconsistent, must be
• TCP connection closed reconciled

Application Layer 2-16


HTTP connections
non-persistent HTTP persistent HTTP
• at most one object sent • multiple objects can
over TCP connection be sent over single
– connection then TCP connection
closed between client, server
• downloading multiple
objects required
multiple connections

Application Layer 2-17


Non-persistent HTTP
suppose user enters URL: (contains text,
www.someSchool.edu/someDepartment/home.index 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
www.someSchool.edu on port for TCP connection at port 80.
80 “accepts” connection, notifying
2. HTTP client sends HTTP request client
message (containing URL) into
TCP connection socket. 3. HTTP server receives request
Message indicates that client message, forms response
wants object message containing requested
someDepartment/home.index object, and sends message into
its socket
time
Application Layer 2-18
Non-persistent 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

Application Layer 2-19


Non-persistent HTTP: response time
RTT (definition): time for a small
packet to travel from client to
server and back
HTTP response time:
• one RTT to initiate TCP initiate TCP
connection
connection
RTT
• one RTT for HTTP request and
first few bytes of HTTP request
file
response to return time to
• file transmission time RTT transmit
file
• non-persistent HTTP response file
time = received
2RTT+ file transmission
time time time

Application Layer 2-20


Persistent HTTP

non-persistent HTTP persistent HTTP:


issues: • server leaves connection
• requires 2 RTTs per object open after sending response
• subsequent HTTP messages
• OS overhead for each TCP
between same client/server
connection sent over open connection
• browsers often open • client sends requests as
parallel TCP connections to soon as it encounters a
fetch referenced objects referenced object
• as little as one RTT for all the
referenced objects

Application Layer 2-21


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, POST, GET /index.html HTTP/1.1\r\n
HEAD commands) Host: www-net.cs.umass.edu\r\n
User-Agent: Firefox/3.6.10\r\n
Accept: text/html,application/xhtml+xml\r\n
header Accept-Language: en-us,en;q=0.5\r\n
lines Accept-Encoding: gzip,deflate\r\n
Accept-Charset: ISO-8859-1,utf-8;q=0.7\r\n
carriage return, Keep-Alive: 115\r\n
line feed at start Connection: keep-alive\r\n
\r\n
of line indicates
end of header lines
Application Layer 2-22 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
HTTP request message: general format

method sp URL sp version cr lf request


line
header field name value cr lf
header
~
~ ~
~ lines

header field name value cr lf


cr lf

~
~ entity body ~
~ body

Application Layer 2-23


BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Uploading form input
POST method:
• web page often includes
form input
• 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

Application Layer 2-24


Method types
HTTP/1.0: HTTP/1.1:
• GET • GET, POST, HEAD
• POST • PUT
• HEAD – uploads file in entity
– asks server to leave body to path specified
requested object out in URL field
of response • DELETE
– deletes file specified in
the URL field

Application Layer 2-25


HTTP response message
status line
(protocol
status code HTTP/1.1 200 OK\r\n
status phrase) Date: Sun, 26 Sep 2010 20:09:20 GMT\r\n
Server: Apache/2.0.52 (CentOS)\r\n
Last-Modified: Tue, 30 Oct 2007 17:00:02
GMT\r\n
header ETag: "17dc6-a5c-bf716880"\r\n
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., data data data data data ...
requested
HTML file

Application Layer 2-26 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
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
Application Layer 2-27
Trying out HTTP (client side) for yourself
1. Telnet to your favorite Web server:

telnet cis.poly.edu 80 opens TCP connection to port 80


(default HTTP server port) at cis.poly.edu.
anything typed in sent
to port 80 at cis.poly.edu

2. type in a GET HTTP request:


GET /~ross/ HTTP/1.1 by typing this in (hit carriage
Host: cis.poly.edu return twice), you send
this minimal (but complete)
GET request to HTTP server

3. look at response message sent by HTTP server!


(or use Wireshark to look at captured HTTP request/response)
Application Layer 2-28
User-server state: cookies
example:
many Web sites use cookies
four components: • Susan always access
Internet from PC
1) cookie header line of
HTTP response • visits specific e-commerce
message site for first time
2) cookie header line in • when initial HTTP requests
next HTTP request arrives at site, site creates:
message – unique ID
3) cookie file kept on
user’s host, managed – entry in backend
by user’s browser database for ID
4) back-end database at
Web site
Application Layer 2-29
Cookies: keeping “state” (cont.)
client server

ebay 8734
usual http request msg Amazon server
cookie file creates ID
usual http response
1678 for user create backend
ebay 8734
set-cookie: 1678 entry database
amazon 1678
usual http request msg
cookie: 1678 cookie- access
specific
usual http response msg action

one week later:


access
ebay 8734 usual http request msg
amazon 1678 cookie: 1678 cookie-
specific
usual http response msg action
Application Layer 2-30
Cookies (continued)
aside
what cookies can be cookies and privacy:
used for:  cookies permit sites to
• authorization learn a lot about you
• shopping carts  you may supply name and
• recommendations e-mail to sites
• user session state (Web e-
mail)

how to keep “state”:


 protocol endpoints: maintain state at
sender/receiver over multiple
transactions
 cookies: http messages carry state

Application Layer 2-31


Web caches (proxy server)
goal: satisfy client request without involving origin server
• user sets browser: Web
accesses via cache
• browser sends all HTTP proxy
requests to cache server
– object in cache: cache client
origin
returns object server

– else cache requests


object from origin
server, then returns
object to client client origin
server

Application Layer 2-32


More about Web caching
• cache acts as both why Web caching?
client and server • reduce response time for
– server for original client request
requesting client
• reduce traffic on an
– client to origin server
institution’s access link
• typically cache is • Internet dense with
installed by ISP caches: enables “poor”
(university, company, content providers to
residential ISP) effectively deliver
content (so too does P2P
file sharing)
Application Layer 2-33
Caching example:
assumptions:
 avg object size: 100K bits
 avg request rate from browsers to origin
origin servers:15/sec servers
public
 avg data rate to browsers: 1.50 Mbps Internet
 RTT from institutional router to any
origin server: 2 sec
 access link rate: 1.54 Mbps
consequences: 1.54 Mbps
 LAN utilization: 15% access link
 access link utilization = 99% problem! institutional
 total delay = Internet delay + access network
1 Gbps LAN
delay + LAN delay
= 2 sec + minutes + usecs

Application Layer 2-34


Caching example: fatter access link
assumptions:
 avg object size: 100K bits
 avg request rate from browsers to origin
origin servers:15/sec servers
public
 avg data rate to browsers: 1.50 Mbps Internet
 RTT from institutional router to any
origin server: 2 sec
 access link rate: 1.54 Mbps
consequences: 154 Mbps 1.54 Mbps
154 Mbps
 LAN utilization: 15% access link
 access link utilization = 99% institutional
 total delay = Internet delay + access network
delay + LAN delay 9.9% 1 Gbps LAN
= 2 sec + minutes + usecs

msecs
Cost: increased access link speed (not cheap!)
Application Layer 2-35
Caching example: install local cache
assumptions:
 avg object size: 100K bits
 avg request rate from browsers to origin
origin servers:15/sec servers
public
 avg data rate to browsers: 1.50 Mbps Internet
 RTT from institutional router to any
origin server: 2 sec
 access link rate: 1.54 Mbps
consequences: 1.54 Mbps
 LAN utilization: 15% access link
 access link utilization = 100% institutional
 total delay = Internet delay + access network
delay + LAN delay ? 1 Gbps LAN
= 2 sec + minutes? + usecs
local web
How to compute link cache
utilization, delay?
Cost: web cache (cheap!)
Application Layer 2-36
Caching example: install local cache
Calculating access link
utilization, delay with cache:
• suppose cache hit rate is 0.4 origin
– 40% requests satisfied at cache, 60% servers
requests satisfied at origin public
Internet

 access link utilization:


 60% of requests use access link
 data rate to browsers over access link 1.54 Mbps
= 0.6*1.50 Mbps = .9 Mbps access link
 utilization = 0.9/1.54 = .58
institutional
 total delay network
1 Gbps LAN
 = 0.6 * (delay from origin servers) +0.4
* (delay when satisfied at cache) local web
 = 0.6 (2.01) + 0.4 (~msecs)
 = ~ 1.2 secs cache
 less than with 154 Mbps link (and
cheaper too!)
Application Layer 2-37
Conditional GET
client server
• Goal: don’t send object if
cache has up-to-date
cached version HTTP request msg
object
– no object transmission delay If-modified-since: <date>
not
– lower link utilization modified
HTTP response
• cache: specify date of HTTP/1.0
before
cached copy in HTTP 304 Not Modified
<date>
request
If-modified-since:
<date>
• server: response contains HTTP request msg
no object if cached copy is If-modified-since: <date> object
up-to-date: modified
HTTP response after
HTTP/1.0 304 Not
HTTP/1.0 200 OK <date>
Modified
<data>
Application Layer 2-38
HTTP
• Web page consists of: ?????
• What is a URL ??
• _____________ implement client side of HTTP ??
• _____________ implement server side of HTTP ??
• HTTP uses ____________ underlying Transport layer protocol ??
• HTTP is a stateless protocol. What does it mean ??
• What is non-persistant and persistant HTTP ??
• When a user request a web page that consists of some text and two images.
For this page, the client will send one request message and receive three
response messages. True/False.
• Two distinct web pages can be sent over the same persistent connection.
True/False.
• The date header in the HTTP request message indicates when the object in
the response was last modified. True/False.

January 17, 2020 COMPUTER NETWORKS 39 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
• What is the use of cookies ??
• What is the difference between web caching and proxy server ??
• Conditional Get.

January 17, 2020 COMPUTER NETWORKS 40 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
BITS Pilani
Pilani|Dubai|Goa|Hyderabad

You might also like