Section 3 - Networks

Download as pdf or txt
Download as pdf or txt
You are on page 1of 27

AinShams University

Faculty of Engineering

CSE 351s: Computer networks


Section 3 Class textbook:
Computer Networking: A Top-
Down Approach (8th ed.)
Eng. Noha Wahdan J.F. Kurose, K.W. Ross
Pearson, 2020
http://gaia.cs.umass.edu/kurose_ross
HTTP overview
HTTP: hypertext transfer protocol
▪ Web’s application-layer protocol
▪ client/server model: PC running
• client: browser that requests, Firefox browser
receives, (using HTTP protocol) and
“displays” Web objects
• server: Web server sends (using server running
Apache Web
HTTP protocol) objects in response server
to requests
iPhone running
Safari browser

Application Layer: 2-2


• web page consists of base HTML-file which includes several
referenced objects, each addressable by a URL

www.someschool.edu/someDept/pic.gif

host name path name


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: Mozilla/5.0 (Macintosh; Intel Mac OS X
10.15; rv:80.0) Gecko/20100101 Firefox/80.0 \r\n
header Accept: text/html,application/xhtml+xml\r\n
lines Accept-Language: en-us,en;q=0.5\r\n
Accept-Encoding: gzip,deflate\r\n
Connection: keep-alive\r\n
\r\n
carriage return, line feed
at start of line indicates
end of header lines * Check out the online interactive exercises for more
examples: http://gaia.cs.umass.edu/kurose_ross/interactive/ Transport Layer: 3-4
HTTP response message
status line (protocol HTTP/1.1 200 OK
status code status phrase) Date: Tue, 08 Sep 2020 00:53:20 GMT
Server: Apache/2.4.6 (CentOS)
OpenSSL/1.0.2k-fips PHP/7.4.9
mod_perl/2.0.11 Perl/v5.16.3
header Last-Modified: Tue, 01 Mar 2016 18:57:50 GMT
lines ETag: "a5b-52d015789ee9e"
Accept-Ranges: bytes
Content-Length: 2651
Content-Type: text/html; charset=UTF-8
\r\n
data, e.g., requested data data data data data ...
HTML file

* Check out the online interactive exercises for more examples: http://gaia.cs.umass.edu/kurose_ross/interactive/
Transport Layer: 3-5
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
Transport Layer: 3-6
Sheet 2: Question 11
Consider the following string of ASCII characters that were captured when the browser sent an
HTTP GET message (i.e., this is the actual content of an HTTP GET message). Answer the
following questions, indicating where in the HTTP GET message below you find the answer.

GET /cs453/index.html HTTP/1.1<cr><lf> a. What is the URL of the document requested by the
Host: gaia.cs.umass.edu<cr><lf> browser?
User-Agent: Mozilla/5.0 (Windows;U; Windows NT 5.1; en-US; b. What version of HTTP is the browser running?
rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax)<cr><lf>
c. Does the browser request a non-persistent or a
Accept:ext/xml, application/xml, application/xhtml+xml,
text/html;q=0.9, persistent connection?
text/plain;q=0.8,image/png,*/*;q=0.5<cr><lf> d. What is the IP address of the host on which the
Accept-Language: en-us,en;q=0.5<cr><lf> browser is running?
AcceptEncoding: zip,deflate<cr><lf> e. What type of browser initiates this message? Why is
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7<cr><lf> the browser type needed in an HTTP request message?
Keep-Alive:300<cr><lf>
Connection:keep-alive<cr><lf><cr><lf>
Sheet 2: Question 11 (Continued)
gaia.cs.umass.edu/cs453/index.html

URL GET /cs453/index.html HTTP/1.1<cr><lf>


Host: gaia.cs.umass.edu<cr><lf>
Version User-Agent: Mozilla/5.0 (Windows;U; Windows NT 5.1; en-US;
rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax)<cr><lf>
Connection type Accept:ext/xml, application/xml, application/xhtml+xml,
text/html;q=0.9,
Host IP 🗶 text/plain;q=0.8,image/png,*/*;q=0.5<cr><lf>
Accept-Language: en-us,en;q=0.5<cr><lf>
Browser Version AcceptEncoding: zip,deflate<cr><lf>
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7<cr><lf>
Why need Browser type ?? Keep-Alive:300<cr><lf>
different browsers may Connection:keep-alive<cr><lf><cr><lf>
handle the same web page Persistent
differently
Sheet 2: Question 12
The text below shows the reply sent from the server in response to the HTTP GET message in
the previous problem. Answer the following questions, indicating where in the message below
you find the answer.
HTTP/1.1 200 OK<cr><lf> a. Was the server able to successfully find the
Date: Tue, 07 Mar 2008 12:39:45 GMT<cr><lf> document or not?
Server: Apache/2.0.52 (Fedora)<cr><lf> b. What time was the document reply provided?
Last-Modified: Sat, 10 Dec2005 18:27:46 GMT<cr><lf>
c. When was the document last modified?
ETag: “526c3-f22-a88a4c80”<cr><lf>
Accept-Ranges: bytes<cr><lf> d. How many bytes are there in the document being
Content-Length: 3874<cr><lf> returned?
Keep-Alive:timeout=max=100<cr><lf> e. What are the first 5 bytes of the document being
Connection:Keep-Alive<cr><lf> returned? Did the server agree to a persistent
Content-Type: text/html; charset=ISO-8859-1<cr><lf> connection?
<cr><lf>
<!doctype html public “-//w3c//dtd html
4.0transitional//en”><lf>
much more document text following here (not shown)>
Sheet 2: Question 12 (Continued)
HTTP/1.1 200 OK<cr><lf>
Successfully found ?
Date: Tue, 07 Mar 2008 12:39:45 GMT<cr><lf>
Response time Server: Apache/2.0.52 (Fedora)<cr><lf>
Last-Modified: Sat, 10 Dec2005 18:27:46 GMT<cr><lf>
Last modified time ETag: “526c3-f22-a88a4c80”<cr><lf>
Accept-Ranges: bytes<cr><lf>
How many bytes in Content-Length: 3874<cr><lf>
the returned Keep-Alive:timeout=max=100<cr><lf>
document Connection:Keep-Alive<cr><lf>
Content-Type: text/html; charset=ISO-8859-1<cr><lf>
first 5 bytes in the
<cr><lf>
returned document
<!doctype html public “-//w3c//dtd html
Did the server agree to a 4.0transitional//en”><lf>
persistent connection? much more document text following here (not shown)>
HTTP connections: two types
Non-persistent HTTP Persistent HTTP
1. TCP connection opened ▪TCP connection opened to
2. at most one object sent a server
over TCP connection ▪multiple objects can be
3. TCP connection closed sent over single TCP
connection between client,
downloading multiple and that server
objects required multiple ▪TCP connection closed
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 on www.someSchool.edu waiting for TCP
port 80 connection at port 80 “accepts”
connection, notifying client
2. HTTP client sends HTTP
request message (containing
URL) into TCP connection 3. HTTP server receives request message,
socket. Message indicates forms response message containing
time that client wants object requested object, and sends message
someDepartment/home.index into 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 TCP


5. HTTP client receives response connection.
message containing html file,
displays html. Parsing html file,
finds 10 referenced jpeg objects

6. Steps 1-5 repeated for


each of 10 jpeg objects
time
Non-persistent HTTP: response time
RTT (definition): time for a small
packet to travel from client to
server and back. initiate TCP
connection
The RTT includes packet-propagation RTT
delays, packet-queuing delays in
request file
intermediate routers and switches,
time to
and packet-processing delays. RTT
transmit
file
HTTP response time (per object): file received
▪ one RTT to initiate TCP connection
▪ one RTT for HTTP request and first few time time
bytes of HTTP response to return
▪ object/file transmission time
Non-persistent HTTP response time = 2RTT+ file transmission time
Time for N objects = N* (2RTT+FTT) Time for N objects T= RTT + N*(RTT+FTT)
Sheet 2: Question 15
Consider a short, 10-meter link, over which a sender can transmit at
a rate of 150 bits/sec in both directions.
Suppose that packets containing data are 100,000 bits long, and packets
containing only control (e.g., ACK or handshaking) are 200 bits long.
Assume that N parallel connections each get 1/N of the link bandwidth.
Now consider the HTTP protocol and suppose that each downloaded object is
100 Kbits long, and that the initial downloaded object contains 10 referenced
objects from the same sender.
A- Would parallel downloads via parallel instances of non-persistent HTTP make
sense in this case?

B- Now consider persistent HTTP. Do you expect significant gains over the non-
persistent case? Justify and explain your answer.
Sheet 2: Question 15 (Continued)
• Multiple parallel downloads using non-persistent HTTP connections .
• each downloaded object can be completely put into one data packet (100Kbits)
• Parallel downloads would allow 10 connections to share the 150 bits/sec
bandwidth, giving each just 15 bits/sec.
• Thus, the total time needed to receive all objects is given by:
(200/150+dprop + 200/150 +dprop + 200/150+ dprop + 100,000/150+ dprop)
+ (200/(150/10)+dprop + 200/(150/10) +dprop + 200/(150/10)+dprop + 100,000/(150/10)+ dprop)
= 7377 + 8*dprop (seconds)

• Persistent HTTP connection. The total time needed is given by:


dprop =
(200/150+ dprop + 200/150 + dprop + 200/150+ dprop + 100,000/150+ dprop ) 10 /(3x108)
+ 10* (200/150+ dprop + 100,000/150+ dprop ) = 0.03 µsec
= 7351 + 24*dprop (seconds)
Thus, we see that persistent HTTP is not significantly faster (less than 1 percent)
than the non-persistent case with parallel download.
Think about….
▪ Why is persistent HTTP not significantly faster than the non-
persistent case with parallel download?
Hint: compare connection-setup overhead with the required time to
transfer the data objects.
▪ Why did the propagation delay increase when we considered
persistent serial connections vs. non-persistent parallel connections?
▪ Would it make sense in this case to use persistent parallel
connections? Try to calculate the delays.
▪ Compare using parallel vs. serial non-persistent connections?
Specifically, consider what would the transmission and propagation
delays be.

Introduction: 1-18
Web caches (aka proxy servers)
Goal: satisfy client requests without Why Web caching?
involving origin server ▪ reduce response time for client
request (cache is closer to client)
client
Web ▪ reduce traffic on an institution’s
cache access link
origin
server ▪ enables “poor” content providers to
more effectively deliver content

▪ server tells cache about which


client
object to cache (in response
▪ Web cache acts as both client header):
and server
• server for original requesting client
• client to origin server
Recall : The Expected Value

▪ As an example, suppose there is a 20% chance of 1 inch of rain, a


70% chance of 2 inches of rain, and a 10% chance of 3 inches of rain.

▪ We would calculate the expected value for the amount of rain to be:
▪ Expected value = 0.2*1 + 0.7*2 + 0.1*3 = 1.9 inches
Introduction: 1-20
Sheet 2: Question 14
In the shown figure, there is an institutional network connected to the Origin servers
Internet. Suppose that the average object size is 850,000 bits and that
the average request rate from the institution’s browsers to the origin
servers is 16 requests per second. Also suppose that the amount of
public
time it takes from when the router on the Internet side of the access Internet
link forwards an HTTP request until it receives the response is three
seconds on average. Model the total average response time as the sum
of the average access delay (that is, the delay from Internet router to 15 Mbps
institution router) and the average Internet delay. For the average access link
access delay, use Δ/(1 – Δβ), where Δ is the average time required to
send an object over the access link and β is the arrival rate of objects to
the access link. 100 Mbps LAN
a. Find the total average response time. institutional
b. Now suppose a cache is installed in the institutional LAN. network

Suppose the miss rate is 0.4. Find the total response time.
Sheet 2 Q14: (a) without a Web Cache origin
servers
▪ Avg. amount of time it takes from when the router on the
Internet side of the access link forwards an HTTP request until it
receives the response : 3 sec
▪ Avg. object size: 850,000 bits
public
▪ average request rate from browsers to origin servers: 16 req/sec Internet

Access Link Performance:


▪ Avg. Transmission Time Δ = (850,000 bits)/(15 x 106 bits/sec) = 15 Mbps
0.0567 sec access link
▪ Avg. arrival rate β = 16 req/sec
▪ Avg. delay = Δ/(1 – Δβ) = (0.0567)/(1- 0.0567 x 16) 100 Mbps LAN
≈ 0.6 sec institutional
network
Total avg. response time= 0.6 sec + 3 sec = 3.6 sec.
Note that delay on LAN is ignored because it is < 0.01 sec
Sheet 2 Q14 : (b) with a Web Cache origin
Solutions: servers
▪ Buy a faster access link →Cost: expensive!
▪ Install a web cache →Cost: cheap!
suppose a cache is installed and the miss rate is 0.4 public
Access Link Performance: Internet

▪ Avg. Transmission Time Δ = (850,000 bits)/(15 x 106 bits/sec) =


0.0567 sec
15 Mbps
▪ Avg. arrival rate β = 0.4 x 16 = 6.4 req/sec access link

▪ Avg. delay = Δ/(1 – Δβ) = (0.0567)/(1- 0.0567 x 6.4)


≈ 0.089 sec Reduced to
100 Mbps LAN
≈one third
Total avg. response time = 0.6x(0)+0.4x(0.089+3) = 1.24 sec.
institutional
local web cache
Web Caching: reduces response time for client request network
and reduces traffic on the access link
Sheet 2: Question 5
Describe how Web caching can reduce the delay in receiving a requested object.
Will Web caching reduce the delay for all objects requested by a user or for only
some of the objects? Why?

Web caching can bring the desired content “closer” to the user, perhaps to the
same LAN to which the user host is connected.
Web caching can reduce the delay for all objects, even objects that are not
cached, since caching reduces the traffic on links.
Sheet 3: Question 14
In the shown figure, there is an institutional network connected to the Origin servers
Internet. Suppose that the average object size is 1,000,000 bits and that
the average request rate from the institution’s browsers to the origin
servers is 16 requests per second. Also suppose that the amount of
public
time it takes from when the router on the Internet side of the access Internet
link forwards an HTTP request until it receives the response is three
seconds on average. Model the total average response time as the sum
of the average access delay (that is, the delay from Internet router to 15 Mbps
institution router) and the average Internet delay. For the average access link
access delay, use Δ/(1 – Δβ), where Δ is the average time required to
send an object over the access link and β is the arrival rate of objects to
the access link. 100 Mbps LAN
a. Find the total average response time. institutional
b. Now suppose a cache is installed in the institutional LAN. network

Suppose the miss rate is 0.4. Find the total response time.
Conditional GET
client server

Goal: don’t send object if cache has


HTTP request msg
up-to-date cached version If-modified-since: <date> object
• no object transmission delay (or use not
modified
of network resources) HTTP response
before
HTTP/1.0
<date>
▪ client: specify date of cached copy 304 Not Modified
in HTTP request
If-modified-since: <date>
▪ server: response contains no HTTP request msg
If-modified-since: <date> object
object if cached copy is up-to- modified
date: HTTP response after
HTTP/1.0 200 OK <date>
HTTP/1.0 304 Not Modified <data>
Thanks

You might also like