CS3201 Ch2
CS3201 Ch2
permanent IP address
often in data centers, for scaling
clients: local or
regional ISP
contact, communicate with server
may be intermittently connected home network content
provider
may have dynamic IP addresses network datacenter
network
application application
socket controlled by
process process app developer
transport transport
network network controlled
link by OS
link Internet
physical physical
time time
Non-persistent HTTP response time = 2RTT+ file transmission time
Application Layer: 2-18
Persistent HTTP (HTTP 1.1)
Non-persistent HTTP issues: Persistent HTTP (HTTP1.1):
requires 2 RTTs per object server leaves connection open after
OS overhead for each TCP 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 it
parallel encounters a referenced object
as little as one RTT for all the
referenced objects (cutting
response time in half)
Application Layer: 2-19
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
Keep-Alive: 115\r\n
Connection: keep-alive\r\n
carriage return, line feed \r\n
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/ Application Layer: 2-20
HTTP request message: general format
method sp URL sp version cr lf request
line
header field name value cr lf
header
~
~ ~
~ lines
~
~ entity body ~
~ body
* Check out the online interactive exercises for more examples: http://gaia.cs.umass.edu/kurose_ross/interactive/
Application Layer: 2-23
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
Application Layer: 2-24
Maintaining user/server state: cookies
lower average end-end delay than with 154 Mbps link (and cheaper too!) Application Layer: 2-34
Conditional GET
client server
in HTTP request
If-modified-since: <date>
HTTP request msg
server: response contains no If-modified-since: <date> object
object if cached copy is up-to-date: modified
HTTP response after
HTTP/1.0 304 Not Modified HTTP/1.0 200 OK <date>
<data>
e. NASA Mt View, CA
f. Internet Software C.
Palo Alto, CA (and 48 other sites)
g. US DoD Columbus, OH (5
other sites)
Application Layer: 2-45
TLD and Authoritative Servers
Top-Level Domain (TLD) servers:
responsible for .com, .org, .net, .edu, .aero, .jobs, .museums, and all
top-level country domains, e.g.: .cn, .uk, .fr, .ca, .jp
Network Solutions: authoritative registry for .com, .net TLD
Educause: .edu TLD
Authoritative DNS servers:
organization’s own DNS server(s), providing authoritative hostname
to IP mappings for organization’s named hosts
can be maintained by organization or service provider
7 6
Recursive query: 1 TLD DNS server
puts burden of name 8
resolution on requesting host at local DNS server
5 4
engineering.nyu.edu dns.nyu.edu
contacted name gaia.cs.umass.edu
server
heavy load at upper authoritative DNS server
levels of hierarchy? dns.cs.umass.edu
identification flags
message header:
identification: 16 bit # for query, # questions # answer RRs
reply to query uses same # # authority RRs # additional RRs
flags:
questions (variable # of questions)
• query or reply
• recursion desired
answers (variable # of RRs)
• recursion available
• reply is authoritative authority (variable # of RRs)
identification flags
communicate
peers request service from other
peers, provide service in return to
other peers local or
regional ISP
• self scalability – new peers bring new
service capacity, and new service demands home network content
provider
peers are intermittently connected network datacenter
network
and change IP addresses
• complex management
examples: P2P file sharing (BitTorrent), enterprise
network
streaming (KanKan), VoIP (Skype)
Application Layer: 2-56
File distribution: client-server vs P2P
Q: How much time to distribute file (size F) from
1 server to N peers?
• upload/download capacity is limited resource
us: server upload
capacity
di: peer i download
file, size F u1 d1 u2 capacity
us d2
server
di
uN Internet core (with abundant
bandwidth) ui
dN
ui: peer i upload
capacity
Introduction: 1-57
File distribution time: client-server
server transmission: must sequentially
send (upload) N file copies:
F
• time to send one copy: F/u
Flus
s us
• time to send N copies: NF/u
FlM s
di
us
network
ui
client: each client must download
file copy
• dmin = minimum client download rate
• min client download time: F/dmin
1.5
0.5
0
0 5 10 15 20 25 30 35
N
Application Layer: 2-60
P2P file distribution: BitTorrent
file divided into 256Kb chunks
peers in torrent send/receive file chunks
tracker: tracks peers torrent: group of peers
participating in torrent exchanging chunks of a file
Alice arrives …
… obtains list
of peers from tracker
… and begins exchanging
file chunks with peers in torrent
Internet
Main challenges:
server-to-client bandwidth will vary over time, with changing network
congestion levels (in house, in access network, in network core, at
video server)
packet loss and delay due to congestion will delay playout, or result in
poor video quality
Application Layer: 2-67
Streaming stored video: challenges
continuous playout constraint: once client
playout begins, playback must match original
timing
• … but network delays are variable (jitter), so will
need client-side buffer to match playout
requirements
other challenges:
• client interactivity: pause, fast-forward, rewind,
jump through video
• video packets may be lost, retransmitted
Application Layer: 2-68
Streaming stored video: playout buffering
constant bit
rate video client video constant bit
transmission reception rate video
playout at client
variable
buffered
network
video
delay
manifest file
where’s S1E5?
netcinema’s
authoritative DNS KingCDN.com KingCDN
authoritative DNS
Application Layer: 2-75
Case study: Netflix
Amazon cloud upload copies of
multiple versions of
video to CDN servers
CDN
server
Netflix registration,
accounting servers
Bob browses
Netflix video CDN
2 Manifest file, server
requested
1 3 returned for
Bob manages specific video
Netflix account
CDN
4 server
DASH server
selected, contacted,
streaming begins
Application Layer: 2-76
CS3201 Computer Networks
Tutorial 2 (Week 2)
average queueing
delay
L: packet length (bits)
a: average packet arrival rate
2-7
1. Suppose that you click a URL link within a web browser to retrieve a web page.
Suppose that the web page associated with that link contains 8 objects.
Let RTT denote the Round Trip Time between the local host, and the server contains the
base HTML and all 8 objects. Suppose that the transmission time is negligible. How long
does it take before the host can receive all objects?
Answer:
If non-persistent HTTP is used, it needs to setup a TCP connection for each HTTP
request.
- It takes 2 RTTs to retrieve the Base HTML.
- It takes 2 RTTs to retrieve each referenced object.
- Thus, it takes 2 RTT +8 * 2 RTT=18 RTTs.
2-8
b) Persistent HTTP is used.
Answer:
- Only one TCP connection is established.
- It takes 2RTTs to receive the Base HTML file.
- All requests for the following 8 objects will be sent back-to-back.
- The responses for the 8 objects will be sent by the server back-to-back (in pipeline).
Thus, it takes 2RTT+RTT=3RTTs.
2-
Solution:
a) Probability that the i-th link does not fail: (1 – p).
This is the same for all i.
Since a packet is successfully received only if none of the links fails, we
thus have
Pr[ no link fails ] = Pr[ 1st link doesn’t fail ] … Pr[ n-th link doesn’t fail]
= (1 – p)n
(b) The delay due to the 4 packets that are ahead of the
arriving packet P is:
2-
Solution:
a) We number the packets 1,…,N.
Here we are looking at the first N/2 packets that arrive at the router
at time 0.
The 1st packet has 0 delay.
The 2nd packet has delay of L/R.
The i-th packet will have a delay of (i-1)(L/R) sec.
b) We now are looking at the second group, i.e., the remaining N/2
packets, that simultaneously arrive at the router at time L/R.
At time L/R, the router has just finished sending one packet of the
first group of packets, therefore:
The (N/2+1)-th packet will have a delay of:
(N/2 – 1)(L/R) sec.
The (N/2+2)-th packet will have a delay of:
(N/2)(L/R) sec.
(N/2+3)-th packet will have a delay of;
(N/2 + 1)(L/R) sec.
The i-th packet (i> N/2) will have a delay of (i – 2)(L/R) sec.
Solution: c) To compute the average delay, we will first compute the total delay
of all N packets and then divide by the number of packets. The total delay is
calculated as follows (assuming N is even):
𝑁𝑁/2 𝐿𝐿 𝐿𝐿
∑𝑖𝑖=1 (𝑖𝑖 − 1) + ∑𝑁𝑁 𝑖𝑖=𝑁𝑁/2+1 𝑅𝑅 𝑖𝑖 − 2
𝑅𝑅
𝐿𝐿 𝑁𝑁/2 𝐿𝐿 𝑁𝑁
= ∑𝑁𝑁/2
𝑖𝑖=1 𝑅𝑅 (𝑖𝑖 − 1) + ∑ 𝑖𝑖=1 𝑅𝑅 + 𝑖𝑖 − 2
2
𝐿𝐿 𝑁𝑁
= ∑𝑁𝑁/2
𝑖𝑖=1 𝑖𝑖 − 1 + + 𝑖𝑖 − 2
𝑅𝑅 2
𝐿𝐿 𝑁𝑁
= ∑𝑁𝑁/2𝑖𝑖=1 2𝑖𝑖 − 3 +
𝑅𝑅 2
𝐿𝐿 𝑁𝑁/2 𝑁𝑁/2 𝑁𝑁/2 𝑁𝑁
= 2 ∑𝑖𝑖=1 𝑖𝑖 − ∑𝑖𝑖=1 3 + ∑𝑖𝑖=1
𝑅𝑅 2
𝐿𝐿 𝑁𝑁/2 3𝑁𝑁 𝑁𝑁 𝑁𝑁
= 2(∑𝑖𝑖=1 𝑖𝑖) − +
𝑅𝑅 2 2 2
𝐿𝐿 𝑁𝑁 𝑁𝑁 3𝑁𝑁 𝑁𝑁2
= +1 − +
𝑅𝑅 2 2 2 4
𝐿𝐿 𝑁𝑁2 𝑁𝑁 3𝑁𝑁 𝑁𝑁2 𝐿𝐿 𝑁𝑁2
= + − + = ( − 𝑵𝑵)
𝑅𝑅 4 2 2 4 𝑅𝑅 2
𝐿𝐿
Therefore, the average queueing delay is (N/2 – 1).
𝑅𝑅
CS3201 Computer Networks
Tutorial (Week 3)
contacted server 8 5
replies with name of requesting host at local DNS server
server to contact engineering.nyu.edu dns.nyu.edu
gaia.cs.umass.edu
7 6
“I don’t know this
name, but ask this
server” authoritative DNS server
dns.cs.umass.edu
Application Layer: 2-6
puts burden of 8
name resolution requesting host at
engineering.nyu.edu
local DNS server
dns.nyu.edu 5 4
on contacted gaia.cs.umass.edu
name server
heavy load at authoritative DNS server
dns.cs.umass.edu
upper levels of
hierarchy?
Work on questions
2-7
1. Suppose that A has a file with size of 1 Gbits to
send to B through the following path. How much
time (in sec) will pass from the time when B
receives the first bit of the file until B has
received the whole file?
40Mbps 10Mbps
A B
3-8
Answer:
1Gbits=1000M bits
The throughput of the routing path is 10Mbps,
i.e., B can receive 10M bits per sec from A.
It thus takes 1Gbits/10Mbps=100 sec for B to
receive the file.
2. Suppose within your Web browser you click on a link to obtain
a Web page. The IP address for the associated URL is not cached
in your local host, so a DNS lookup is necessary to obtain the IP
address. It takes RTT0 = 5 msecs for the host to send a DNS
lookup and get the IP address. The Web page associated with the
link does not reference any other objects. The RTT between the
local host and the Web server containing the object is
RTTHTTP = 15 msecs.
3-10
Answer:
The time from when the Web request is made in
the browser until the page is displayed in the
browser is
RTT0 + 2*RTTHTTP = 5 + 2*15 = 35 msecs.
Note that 2 RTTHTTPs are needed to fetch the
HTML object - one RTTHTTP to establish the TCP
connection, and the other RTTHTTP to perform the
HTTP GET/response over that TCP connection.
Authoritative
3. Consider the networks shown in the figure in www.b.com
DNS server
for b.com
the right side. There are two user machines
m1.a.com and m2.a.com in the network a.com.
Suppose the user at m1.a.com types in the URL
www.b.com/bigfile.htm into a browser to
retrieve a 1Gbit (or 1,000 Mbit) file from 1 Gbps
www.b.com. We have the following LAN
assumptions: R2
R1
The packets containing any DNS commands and
HTTP commands such as GET are very small
compared to the size of the file, and thus their
transmission times (but not their propagation
1 Gbps
times) can be neglected. m1.a.com
LAN
Propagation delays within the
HTTP Local
LAN are small enough to be m2.a.com DNS
ignored. The propagation from cache
server
router R1 to router R2 is small enough to be
ignored.
The propagation delay from anywhere
in a.com to any other site in the Internet
(except b.com) is 500 ms (=0.5 seconds).
3-12
List the sequence of DNS and HTTP messages sent/received from/by m1.a.com as well
as any other messages that leave/enter the a.com network that are not directly
sent/received by m1.a.com from the point that the URL is entered into the browser
until the file is completely received. Indicate the source and destination of each message.
You can assume that every HTTP request by m1.a.com is first directed to the HTTP
cache in a.com. Assume that all caches (HTTP cache and local DNS server) are initially
empty. Moreover, all DNS requests are iterated queries. Calculate the time for
m1.a.com to receive the file.
Answer:
Name resolution messages and delay:
M1.a.com needs to resolve the name www.b.com to an IP address so it sends a DNS
REQUEST message to its local DNS resolver
• (this takes no time given the assumptions)
Local DNS server does not have any information so it contacts a root DNS server with a
REQUEST message
• (this take 500 ms given the assumptions)
Root DNS server returns name of DNS Top Level Domain server for .com
• (this takes 500 ms given the assumptions)
Local DNS server contacts .com TLD
• (this takes 500 ms given the assumptions)
TLD .com server returns the authoritative name server for b.com
(this takes 500 ms given the assumptions)
Local DNS server contacts the authoritative name server for b.com
• ( this takes no time given the assumptions)
Authoritative name server for b.com returns IP address of www.b.com.
• (this takes no time given the assumptions)
3-13
Answer (continued):
3-14
Now assume that machine m2.a.com makes a request to exactly the same URL that
m1.a.com made.
List the sequence of DNS and HTTP messages sent/received from/by m2.a.com as well
as any other messages that leave/enter the a.com network that are not directly
sent/received by m2.a.com from the point that the URL is entered into the browser
until the file is completely received. Indicate the source and destination of each message.
Answer:
m2.a.com needs to resolve the name www.b.com to an IP address, so it sends a DNS
REQUEST message to its local DNS resolver
• this takes no time given the assumptions
The local DNS server looks in its cache and finds the IP address for www.b.com, since
m1.a.com had just requested that name which has been resolved already, and returns the
IP address to m2.a.com.
• this takes no time given the assumptions
HTTP client at m2.a.com sends a HTTP GET message to www.b.com, which it sends to the
HTTP cache in the a.com network (this takes no time given the assumptions).
The HTTP cache finds the requested document in its cache, so it sends a GET request with
an If-Modified-Since to www.b.com. (this takes no time given the assumptions)
www.b.com receives the GET request. The document has not changed, so www.b.com sends
a short HTTP RESPONSE message to the HTTP cache in a.com indicating that the cached
copy is valid. (this takes no time given the assumptions)
There is a 1 sec delay to send the 1Gbps file from the HTTP cache to m2.a.com.
The total delay is thus: 1 sec
3-15
4. You accessed Amazon.com before. When you access Amazon.com
again, the website lists the items that you browsed before and provide
some recommendations to you. Explain how this happens.
Answer:
Amazon’s server has a backend database.
When a client accesses Amazon’s web server for the first time, a cookie
(for the user) will be generated and an entry will be added to its
backend database.
This cookie can be stored at the client’s computer permanently.
When a client browses an item, the cookie and the item’s id are saved
in the backend database of Amazon’s web server.
When the client visits Amazon’s web server again, the cookie is
included in the HTTP request sent to Amazon’s web server.
By using the cookie id, all items that the client browsed previously can
be retrieved from the backend database of the Amazon’s web server.
5. Suppose that a web browser wants to display a web
page that contains references to 10 objects. Assume that
the web page and its referenced objects are very small,
hence their transmission times can be ignored.
For each one of the scenarios (a-d) stated below, answer
the following two questions:
increases linearly in N
File distribution time: P2P
server transmission: must upload at
least one copy:
F
• time to send one copy: F/us us
client: each client must download file copy di
• min client download time: F/dmin network
ui
clients: as aggregate must download NF bits
• max upload rate (limiting max download rate) is: us + Σui
Alice arrives …
… obtains list
of peers from tracker
… and begins exchanging
file chunks with peers in torrent
Application Layer: 2-
7
P2P file distribution: BitTorrent
peer joining torrent:
• has no chunks, but will accumulate them
over time from other peers
• registers with tracker to get list of
peers, connects to subset of peers
(“neighbors”)
while downloading, peer uploads chunks to other peers
peer may change group of peers with whom it exchanges chunks
churn: peers may come and go
once peer has an entire file, it may (selfishly) leave or (altruistically)
remain in torrent
Application Layer: 2-
8
BitTorrent: requesting, sending file chunks
Requesting chunks: Sending chunks: tit-for-tat
at any given time, different Alice sends chunks to those four
peers have different peers currently sending her chunks
subsets of file chunks at highest rate
periodically, Alice asks each • other peers are “choked” by Alice
peer for list of chunks that (do not receive chunks from her)
they have • re-evaluate top 4 every 10 secs
Alice requests missing every 30 secs: randomly select
chunks from peers another peer, starts sending
“rarest first” rule chunks
• “optimistically unchoke” this peer
• newly chosen peer may join top 4
Application Layer: 2-
9
UDP checksum
Goal: detect errors (i.e., flipped bits) in transmitted segment
sender: receiver:
treat contents of UDP compute checksum of received
segment (including UDP header segment
fields and IP addresses) as
sequence of 16-bit integers check if computed checksum equals
checksum: addition (1s checksum field value:
complement sum) of segment • Not equal - error detected
content • Equal - no error detected. But maybe
checksum value put into errors nonetheless?
UDP checksum field
Work on your questions
01010011
01010111
+ 01110100
100011110
• Add the carry out to the least significant bit, we have 00011111,
• the checksum is: 11100000
• Q: what do we get if we compute: sum + checksum ?
0 1
1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 0
1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
wraparound 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 Even though
numbers have
sum 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0 changed (bit
flips), no change
checksum 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1 in checksum!
3. Consider distributing a file of F = 15 Gbits to N peers. The server has an upload rate
of us = 30 Mbps, and each peer has a download rate of di = 2 Mbps and an upload rate of
u = 700 Kbps. Give the minimum distribution time for N = 10 and N = 1,000 for both
(a) client-server distribution; and (b) P2P distribution.
For calculating the minimum distribution time, we use:
• For client-server: DCS >= max{ N F / us, F / dmin}, dmin is the minimum
download rate
• For p2p: Dp2p >= max{ F / us, F / dmin, N F / (us + ∑ui)}
Before plugging the values of F and u into these formulas, we convert them
to Mbps.
N=10
DCS >= max{ 10 * 15*103 / 30, 15*103 / 2 }
= 7,500 sec (2nd term dominates because # of users is small)
DP2P >= max{15*103 / 30, 15*103 / 2, 10 * 15*103 / (30 + 10*0.7) }
= max{ 500, 7,500, 4,054 } = 7,500 sec
Numerator and denominator
N=1,000 both scale with N, (almost)
DCS >= max{ 1,000*(15*10 / 30), (15*10 / 2)}
3 3
cancel each other out
= max{ 500,000, 7,500 } = 500,000 sec
DP2P >= max{15*103/30, 15*103 / 2, 1,000 * 15*103 / (30 + 1,000*0.7) }
= max{ 500, 7,500, 20,548 } = 20,548 sec
3-15
4. Suppose that Alice writes a Bittorrent client that
doesn’t allow other clients to download any data from
her system. She claims that, by using this client, she can
join a torrent and still receive a complete copy of the
shared file. Is Alice’s claim possible? Why or why not?
Answer:
Yes, it is possible.
Note that even though Alice will never become one of
the top-4 hosts of other peers, she might nevertheless
become “optimistically unchoked” by other peers and
start receiving chunks for some time.
Thus, if she waits long enough, she is likely to receive
all chunks of the file.
3-16
5. Consider a short, 10-meter link with a propagation speed of 300*106 m/sec,
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 that contain
only control messages (TCP or HTTP GET request ) are 200 bits long. Assume that
there are N parallel connections with each having 1/N of the link bandwidth.
Consider the HTTP protocol and suppose that each downloaded object is 100 Kbits
long, and that the base HTML file contains 10 referenced objects located at the same
host.
a) Would parallel downloads via 10 parallel instances of non-persistent HTTP make
sense in this case? How long does it take?
3-17
5. Consider a short, 10-meter link with a propagation speed of 300*106 m/sec,
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 that contain
only control messages (TCP or HTTP GET request ) are 200 bits long. Assume that
there are N parallel connections with each having 1/N of the link bandwidth.
Consider the HTTP protocol and suppose that each downloaded object is 100 Kbits
long, and that the base HTML file contains 10 referenced objects located at the same
host.
a) Would parallel downloads via 10 parallel instances of non-persistent HTTP make
sense in this case? How long does it take?
Answer:
Let Tp denote the one-way propagation delay between the client and the server.
• Tp = 10 / (300 * 10^6) = 0.03333 microsec. (1 second=10^6 micorseconds)
Each downloaded object can be completely put into one data packet.
Time to get the base HTML file:
• B = (200/150+Tp + 200/150 +Tp + 200/150+Tp + 100,000/150+ Tp )
Time to get 10 objects over parallel connections of non-persistent HTTP:
• 200/(150/10)+Tp + 200/(150/10) +Tp + 200/(150/10)+Tp + 100,000/(150/10)+
Tp
In total: Only (1/10)-th of bandwidth
• 7,377 + 8*Tp (seconds)
3-18
5. Consider a short, 10-meter link with a propagation speed of 300*106 m/sec,
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 (TCP or HTTP GET request ) are 200 bits long. Assume that N parallel
connections each gets 1/N of the link bandwidth. Now consider the HTTP protocol
and suppose that each downloaded object is 100 Kbits long, and that the base HTML
file contains 10 referenced objects located at the same host.
b) Consider persistent HTTP (without parallel connections). Do you expect significant
gains over the non-persistent case?
tcp
• Answer: total time = time to get the base HTML file (B) + 10 tcp
req/res sent back-to-back:
• After having received the base HTML file, the client sends 10
requests back-to-back
• This takes 10 * 200/150 + Tp = 13 sec start transm.
• However, as soon as the server receives the 1st request, it will obj 1