You are on page 1of 29

Tutorial 1

CS 306:Computer Networks

Feb 14, 2023


Numerical Problems from Transport
Layer
Q1. Consider the GBN protocol with a sender window size
of 4 and a sequence number range of 1,024. Suppose that
at time t, the next in-order packet that the receiver is
expecting has a sequence number of k. Assume that the
medium does not reorder messages. Answer the following
questions:

a. What are the possible sets of sequence numbers inside


the sender’s window at time t?
Justify your answer.
b. What are all possible values of the ACK field in all
possible messages currently
propagating back to the sender at time t? Justify your
answer.
Q2. Consider transferring an enormous file of L bytes from
Host A to Host B. Assume an MSS of 536 bytes.

a. What is the maximum value of L such that TCP


sequence numbers are not exhausted?
Recall that the TCP sequence number field has 4 bytes.
b. For the L you obtain in (a), find how long it takes to
transmit the file. Assume that a total
of 66 bytes of transport, network, and data-link header
are added to each segment before the resulting packet is
sent out over a 155 Mbps link. Ignore flow control and
congestion control so A can pump out the segments back
to back and continuously.
Q3. Host A and B are communicating over a TCP connection,
and Host B has already received from A all bytes up through
byte 126. Suppose Host A then sends two segments to Host B
back-to-back. The first and second segments contain 80 and 40
bytes of data, respectively. In the first segment, the sequence
number is 127, the source port number is 302, and the
destination port number is 80. Host B sends an
acknowledgment whenever it receives a segment from Host A.
a. In the second segment sent from Host A to B, what are the
sequence number, source port number, and destination port
number?
b. If the first segment arrives before the second segment, in
the acknowledgment of the first arriving segment, what is the
acknowledgment number, the source port number, and the
destination port number?
Q3. (Cont)...
c. If the second segment arrives before the first segment, in
the acknowledgment of the first arriving segment, what is the
acknowledgment number?
d. Suppose the two segments sent by A arrive in order at B.
The first acknowledgment is lost and the second
acknowledgment arrives after the first timeout interval. Draw a
timing diagram, showing these segments and all other
segments and acknowledgments sent.

(Assume there is no additional packet loss.) For each segment


in your figure, provide the sequence number and the number
of bytes of data; for each acknowledgment that you
add, provide the acknowledgment number.
Q4. Host A and B are directly connected with a 100 Mbps link.
There is one TCP connection between the two hosts, and Host
A is sending to Host B an enormous file over this connection.
Host A can send its application data into its TCP socket at a rate
as high as 120 Mbps but Host B can read out of its TCP receive
buffer at a maximum rate of 50 Mbps. Describe the effect of
TCP flow control.
Consider the context of Round-Trip Time Estimation and
Timeout (for the next question) :
● The sample RTT, denoted SampleRTT , for a segment is
the amount of time between when the segment is sent
(that is, passed to IP) and when an acknowledgment for the
segment is received. Instead of measuring a SampleRTT for
every transmitted segment, most TCP implementations
take only one SampleRTT measurement at a time. That is,
at any point in time, the SampleRTT is being estimated for
only one of the transmitted but currently unacknowledged
segments, leading to a new value of SampleRTT
approximately once every RTT. Also, TCP never computes a
SampleRTT for a segment that has been retransmitted; it
only measures SampleRTT for segments that have been
transmitted once.
(cont)...
● SampleRTT values will fluctuate from segment to segment
due to congestion in the routers and to the varying load on
the end systems. Because of this fluctuation, any given
SampleRTT value may be atypical. In order to estimate a
typical RTT, it is therefore natural to take some sort of
average of the SampleRTT values. TCP maintains an
average, called EstimatedRTT , of the SampleRTT
values. Upon obtaining a new SampleRTT , TCP updates
EstimatedRTT according to the following formula:
EstimatedRTT=(1−α)⋅EstimatedRTT+α⋅SampleRTT
The recommended value of α is α = 0.125 (that is, 1/8).
EstimatedRTT=0.875⋅EstimatedRTT+0.125⋅Sample
RTT
(cont)...
● In addition to having an estimate of the RTT, it is also
valuable to have a measure of the variability of the RTT.
[RFC 6298] defines the RTT variation, DevRTT , as an
estimate of how much SampleRTT typically deviates from
EstimatedRTT :
DevRTT=(1−β)⋅DevRTT+β⋅|SampleRTT−EstimatedRTT|
● Note that DevRTT is an EWMA of the difference between
SampleRTT and EstimatedRTT . If the SampleRTT values
have little fluctuation, then DevRTT will be small; on the
other hand, if there is a lot of fluctuation, DevRTT will be
large. The recommended value of β is 0.25.
● Given values of EstimatedRTT and DevRTT , what value
should be used for TCP’s timeout interval? Clearly, the
interval should be greater than or equal to EstimatedRTT ,
or unnecessary retransmissions would be sent.
(cont)...
● But the timeout interval should not be too much larger than
EstimatedRTT ; otherwise, when a segment is lost, TCP would not
quickly retransmit the segment, leading to large data transfer
delays. It is therefore desirable to set the timeout equal to the
EstimatedRTT plus some margin. The margin should be large when
there is a lot of fluctuation in the SampleRTT values; it should be
small when there is little fluctuation. The value of DevRTT should
thus come into play here.
● All of these considerations are taken into account in TCP’s method
for determining the retransmission timeout interval:
TimeoutInterval=EstimatedRTT+4⋅DevRTT
An initial TimeoutInterval value of 1 second is recommended [RFC
6298]. Also, when a timeout occurs, the value of TimeoutInterval
is doubled to avoid a premature timeout occurring for a
subsequent segment that will soon be acknowledged. However, as
soon as a segment is received and EstimatedRTT is updated, the
TimeoutInterval is again computed using the formula above.
Q5. Based on the context above, Suppose that the five
measured SampleRTT values are 106 ms, 120ms, 140 ms, 90
ms, and 115 ms. Compute the EstimatedRTT after each of
these SampleRTT values is obtained, using a value of α=0.125
and assuming that the value of EstimatedRTT was 100 ms just
before the first of these five samples were obtained. Compute
also the DevRTT after each sample is obtained, assuming a
value of β=0.25 and assuming the value of DevRTT was 5 ms
just before the first of these five samples was obtained. Last,
compute the TCP TimeoutInterval after each of these samples
is obtained.
Q6. Consider the TCP procedure for estimating RTT. Suppose
that α=0.1. Let SampleRTT 1 be the most recent sample RTT, let
SampleRTT 2 be the next most recent sample RTT, and so on.

a. For a given TCP connection, suppose four acknowledgments


have been returned with corresponding sample RTTs:
SampleRTT 4, SampleRTT 3, SampleRTT 2, and SampleRTT 1.
Express EstimatedRTT in terms of the four sample RTTs.

b. Generalize your formula for n sample RTTs.

c. For the formula in part (b) let n approach infinity. Comment


on why this averaging procedure is called an exponential
moving average.
Q7. Consider that only a single TCP (Reno) connection uses one
10Mbps link which does not buffer any data. Suppose that this
link is the only congested link between the sending and receiving
hosts. Assume that the TCP sender has a huge file to send to the
receiver, and the receiver’s receive buffer is much larger than the
congestion window. We also make the following assumptions:
each TCP segment size is 1,500 bytes; the two-way propagation
delay of this connection is 150 msec; and this TCP connection is
always in congestion avoidance phase, that is, ignore slow start.

a. What is the maximum window size (in segments) that this TCP
connection can achieve?
b. What is the average window size (in segments) and average
throughput (in bps) of this TCP connection?
c. How long would it take for this TCP connection to reach its
maximum window again after recovering from a packet loss?
Q8. In this problem, we consider the delay introduced by the TCP
slow-start phase. Consider a client and a Web server directly
connected by one link of rate R. Suppose the client wants to
retrieve an object whose size is exactly equal to 15 S, where S is
the maximum segment size (MSS). Denote the round-trip time
between client and server as RTT (assumed to be constant).
Ignoring protocol headers, determine the time to retrieve the
object (including TCP connection establishment) when

a. 4 S/R>S/R+RTT>2S/R
b. S/R+RTT>4 S/R
c. S/R>RTT.
Solutions
For Tutorial: Transport Layer
Q1.a
Here we have a window size of N=4. Suppose the receiver has received packet k-1,
and has ACKed that and all other preceding packets. If all of these ACK's have been
received by sender, then sender's window is [k, k+N-1]. Suppose next that none of
the ACKs have been received at the sender. In this second case, the sender's window
contains k-1 and the N packets up to and including k-1. The sender's window is thus
[k-N,k-1]. By these arguments, the senders window is of size 3 and begins
somewhere in the range [k-N,k].
Q1.b
If the receiver is waiting for packet k, then it has received (and ACKed) packet k-1

and the N-1 packets before that. If none of those N ACKs have been yet received by

the sender, then ACK messages with values of [k-N,k-1] may still be propagating

back.Because the sender has sent packets [k-N, k-1], it must be the case that the

sender has already received an ACK for k-N-1. Once the receiver has sent an ACK

for k-N-1 it will never send an ACK that is less that k-N-1. Thus the range of inflight ACK
values can range from k-N-1 to k-1.
Q2.a
There are 4,294,967,2 296 32 = possible sequence numbers.

The sequence number does not increment by one with each segment. Rather, it

increments by the number of bytes of data sent. So the size of the MSS is
irrelevant.

The maximum size file that can be sent from A to B is simply the number of bytes
representable by Gbytes 4.19232.
Q2(Cont)...
Q3.
a) In the second segment from Host A to B, the sequence number is 207, source port
number is 302 and destination port number is 80.
b) If the first segment arrives before the second, in the acknowledgement of the first
arriving segment, the acknowledgement number is 207, the source port number is 80
and the destination port number is 302.
c) If the second segment arrives before the first segment, in the acknowledgement of the
first arriving segment, the acknowledgement number is 127, indicating that it is still
waiting for bytes 127 and onwards.
Q3.d
Q4
Since the link capacity is only 100 Mbps, so host A’s sending rate can be at most
100Mbps. Still, host A sends data into the receive buffer faster than Host B can remove
data from the buffer. The receive buffer fills up at a rate of roughly 40Mbps. When the
buffer is full, Host B signals to Host A to stop sending data by setting RcvWindow = 0.
Host A then stops sending until it receives a TCP segment with RcvWindow > 0. Host A
will thus repeatedly stop and start sending as a function of the RcvWindow values it
receives from Host B. On average, the long-term rate at which Host A sends data to Host
B as part of this connection is no more than 60Mbps.
Q5
DevRTT = (1- beta) * DevRTT + beta * | SampleRTT - EstimatedRTT |
EstimatedRTT = (1-alpha) * EstimatedRTT + alpha * SampleRTT
TimeoutInterval = EstimatedRTT + 4 * DevRTT
After obtaining first SampleRTT 106ms:
DevRTT = 0.75*5 + 0.25 * | 106 - 100 | = 5.25ms
EstimatedRTT = 0.875 * 100 + 0.125 * 106 = 100.75 ms
TimeoutInterval = 100.75+4*5.25 = 121.75 ms
Q5 (Cont)...
After obtaining 120ms:
DevRTT = 0.75*5.25 + 0.25 * | 120 – 100.75 | = 8.75 ms
EstimatedRTT = 0.875 * 100.75 + 0.125 * 120 = 103.16 ms
TimeoutInterval = 103.16+4*8.75 = 138.16 ms
After obtaining 140ms:
DevRTT = 0.75*8.75 + 0.25 * | 140 – 103.16 | = 15.77 ms
EstimatedRTT = 0.875 * 103.16 + 0.125 * 140 = 107.76 ms
TimeoutInterval = 107.76+4*15.77 = 170.84 ms
Q5 (Cont)...
After obtaining 90ms:
DevRTT = 0.75*15.77 + 0.25 * | 90 – 107.76 | = 16.27 ms
EstimatedRTT = 0.875 * 107.76 + 0.125 * 90 = 105.54 ms
TimeoutInterval = 105.54+4*16.27 =170.62 ms
After obtaining 115ms:
DevRTT = 0.75*16.27 + 0.25 * | 115 – 105.54 | = 14.57 ms
EstimatedRTT = 0.875 * 105.54 + 0.125 * 115 = 106.72 ms
TimeoutInterval = 106.72+4*14.57 =165 ms
Q6
Recall the TCP’s formula for estimating RTT:

EstimatedRTT = (1 − α) · EstimatedRTT + α · SampleRTT

For part c. In order to get a generalized formula, we can take our answer
from part (a) and examine the pattern.
Q7
a.) Maximum window size:
Wmax = (BW×RTT)/MSS
=106×0.15 /8*1500
=125
So, the maximum window size is indeed 125 segments.
b.) The average window size (in segments) is given by;
Average = 0.75 * Window size
Average = 0.75 * 125
Average Window size = 9.375 sec
Q7 (Cont)...
c.) When there is a packet loss, W becomes W/2, i.e., 125/2=62.

(125 - 62) *0.15 = 9.45 seconds, as the number of RTTs (that this TCP
connections needs in order to increase its window size from 62 to 125) is 63.
Recall the window size increases by one in each RTT.
Q8.
a) Referring to the figure , we see that the total
delay is

RTT + RTT + S/R + RTT + S/R + RTT + 12S/R =


4RTT + 14 S/R

b) Similarly, the delay in this case is:

RTT+RTT + S/R + RTT + S/R + RTT + S/R + RTT +


8S/R = 5RTT +11 S/R

c) Similarly, the delay in this case is:

RTT + RTT + S/R + RTT + 14 S/R = 3 RTT + 15


S/R

You might also like