Homework 2 Solutions
Homework 2 Solutions
1. P19:
a) Here we have a window size of N=3. Suppose the receiver has received packet k-1, and
has ACKed that and all other preceeding 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].
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 in-flight ACK values can range from k-N-1 to k-1.
2. P22:
a) True. Suppose the sender has a window size of 3 and sends packets 1, 2, 3 at t0. At t1,
(t1>t0) the receiver ACKS 1, 2, 3. At t2, (t2>t1) the sender times out and resends 1, 2, 3.
At t3 the receiver receives the duplicates and re-acknowledges 1, 2, 3. At t4 the sender
receives the ACKs that the receiver sent at t1 and advances its window to 4, 5, 6. At t5
the sender receives the ACKs 1, 2, 3 the receiver sent at t2. These ACKs are outside its
window.
c) True.
d) True. Note that with a window size of 1, SR, GBN, and the alternating bit protocol are
functionally equivalent. The window size of 1 precludes the possibility of out-of-order
packets (within the window). A cumulative ACK is just an ordinary ACK in this situation,
since it can only refer to the single packet within the window.
3. P25:
a. In the second segment from Host A to B, the sequence number is 197, 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 197, 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.
d.
Host A Host B
Ack = 247
Seq = 127, 70 bytes
4. P34:
a).
GoBackN:
A sends 9 segments in total. They are initially sent segments 1, 2, 3, 4, 5 and later re-sent
segments 2, 3, 4, and 5.
B sends 8 ACKs. They are 4 ACKS with sequence number 1, and 4 ACKS with sequence
numbers 2, 3, 4, and 5.
Selective Repeat:
A sends 6 segments in total. They are initially sent segments 1, 2, 3, 4, 5 and later re-sent
segments 2.
B sends 5 ACKs. They are 4 ACKS with sequence number 1, 3, 4, 5. And there is one
ACK with sequence number 2.
TCP:
A sends 6 segments in total. They are initially sent segments 1, 2, 3, 4, 5 and later re-sent
segments 2.
B sends 5 ACKs. They are 4 ACKS with sequence number 2. There is one ACK with
sequence numbers 6. Note that TCP always send an ACK with expected sequence
number.
b). TCP. This is because TCP uses fast retransmit without waiting until time out.
5. P37:
6. P39:
If TCP were a stop-and-wait protocol, then the doubling of the time out interval would
suffice as a congestion control mechanism. However, TCP uses pipelining (and is therefore
not a stop-and-wait protocol), which allows the sender to have multiple outstanding
unacknowledged segments. The doubling of the timeout interval does not prevent a TCP
sender from sending a large number of first-time-transmitted packets into the network, even
when the end-to-end path is highly congested. Therefore a congestion-control mechanism is
needed to stem the flow of “data received from the application above” when there are signs
of network congestion.
7. P40:
In this problem, there is no danger in overflowing the receiver since the receiver’s receive
buffer can hold the entire file. Also, because there is no loss and acknowledgements are
returned before timers expire, TCP congestion control does not throttle the sender. However,
the process in host A will not continuously pass data to the socket because the send buffer
will quickly fill up. Once the send buffer becomes full, the process will pass data at an
average rate or R << S.
8. P43:
Let W denote the max window size measured in segments. Then, W*MSS/RTT =
10Mbps, as packets will be dropped if the maximum sending rate exceeds link capacity.
Thus, we have W*1500*8/0.1=10*10^6, then W is about 84 (ceiling of 83.3) segments.
As congestion window size varies from W/2 to W, then the average window size is
0.75W=63 segments. Average throughput is 63*1500*8/0.1=7.56Mbps.
84/2 *0.1= 4.2 seconds, as the number of RTTs (that this TCP connections needs in order
to increase its window size from W/2 to W) is given by W/2. Recall the window size
increases by one in each RTT.
9. P44:
Let W denote max window size. Let S denote the buffer size. For simplicity, suppose TCP
sender sends data packets in a round by round fashion, with each round corresponding to a
RTT. If the window size reaches W, then a loss occurs. Then the sender will cut its
congestion window size by half, and waits for the ACKs for W/2 outstanding packets before
it starts sending data segments again. In order to make sure the link always busying sending
data, we need to let the link busy sending data in the period W/(2*C) (this is the time interval
where the sender is waiting for the ACKs for the W/2 outstanding packets). Thus, S/C must
be no less than W/(2*C), that is, S>=W/2.
Let Tp denote the one-way propagation delay between the sender and the receiver.
When the window size reaches the minimum W/2 and the buffer is empty, we need to make
sure the link is also busy sending data. Thus, we must have W/2/(2Tp)>=C, thus,
W/2>=C*2Tp.
Thus, S>=C*2Tp.
10. P45:
a. Let W denote the max window size. Then, W*MSS/RTT = 10Gbps, as packets will be
dropped if maximum sending rate reaches link capacity. Thus, we have
W*1500*8/0.1=10*10^9, then W= 83334 segments.
b. As congestion window size varies from W/2 to W, then the average window size is
0.75W=62501 segments. Average throughput is 62501*1500*8/0.1=7.5Gbps.
c. 83334/2 *0.1 /60= 69 minutes. In order to speed up the window increase process, we can
increase the window size by a much larger value, instead of increasing window size only by
one in each RTT. Some protocols are proposed to solve this problem, such as ScalableTCP or
HighSpeed TCP.
11. P47:
a. The key difference between C1 and C2 is that C1’s RTT is only half of that of C2.
Thus C1 adjusts its window size after 100 msec, but C2 adjusts its window size after 200
msec.
Assume that whenever a loss event happens, C1 receives it after 100msec and C2
receives it after 200msec.
The following table describes the evolution of window sizes and sending rates based on
the above assumptions.
C1 C2
Time Window Size Average data sending Window Average data sending
(msec) rate (segments per Size(num. rate (segments per
(num. of second, =Window/0.1) of segments second, =Window/0.2)
segments sent sent in next
in next 200msec)
100msec)
(decreases
window size
as the avg.
total sending
rate to the link
in last
100msec is
150= 100+50)
200 2 20 5 25
(decreases (decreases
window size window size
as the avg. as the avg.
total sending total
rate to the link sending rate
in last to the link in
100msec is last
100= 50+50) 200msec is
125=
(100+50)/2
+
(50+50)/2)
300 1 10 25
(decreases
window size
as the avg.
total sending
rate to the link
in last
100msec is
45= (20+25)
400 1 10 2 10
500 2 20 10
600 3 30 3 15
700 1 10 15
800 2 20 1 5
900 3 30 5
1000 1 10 2 10
(decreases (increases
window size window size
as the avg. as the avg.
total sending total
rate to the link sending rate
in last to the link in
100msec is last
35= (30+5) 200msec is
30=
(20+30)/2 +
(5+5)/2)
1100 2 20 10
1200 3 30 3 15
1300 1 10 15
1400 2 20 1 5
1500 3 30 5
1600 1 10 2 10
1700 2 20 10
1800 3 30 3 15
1900 1 10 15
2000 2 20 1 5
2100 3 30 5
2200 1 10 2 10
Based on the above table, we find that after 2200 msec, C1’s window size is 1 segment
and C2’s window size is 2 segments.
b. No. In the long run, C1’s bandwidth share is roughly twice as that of C2’s, because C1
has shorter RTT, only half of that of C2, so C1 can adjust its window size twice as fast as
C2. If we look at the above table, we can see a cycle every 600msec, e.g. from 1400msec
to 1900msec, inclusive. Within a cycle, the sending rate of C1 is
(20+30+10+20+30+10)/6 = 120, which is twice as large as the sending of C2 given by
(5+5+10+10+15+15)/6=60.
12. P48:
a. Similarly as in last problem, we can compute their window sizes over time in the following
table. Both C1 and C2 have the same window size 2 after 2200msec.
C1 C2
Time (msec) Window Size Data sending Window Data sending
(num. of speed (segments Size(num. of speed (segments
segments sent in per second, segments sent in per second,
next 100msec) =Window/0.1) next 100msec) =Window/0.1)
0 15 150 (in [0- 10 100 (in [0-
100]msec] 100]msec)
100 7 70 5 50
200 3 30 2 20
300 1 10 1 10
400 2 20 2 20
500 1 10 1 10
600 2 20 2 20
700 1 10 1 10
800 2 20 2 20
900 1 10 1 10
1000 2 20 2 20
1100 1 10 1 10
1200 2 20 2 20
1300 1 10 1 10
1400 2 20 2 20
1500 1 10 1 10
1600 2 20 2 20
1700 1 10 1 10
1800 2 20 2 20
1900 1 10 1 10
2000 2 20 2 20
2100 1 10 1 10
2200 2 20 2 20
b. Yes, this is due to the AIMD algorithm of TCP and that both connections have the same
RTT.
c. Yes, this can be seen clearly from the above table. Their max window size is 2.
d. No, this synchronization won’t help to improve link utilization, as these two connections
act as a single connection oscillating between min and max window size. Thus, the link is not
fully utilized (recall we assume this link has no buffer). One possible way to break the
synchronization is to add a finite buffer to the link and randomly drop packets in the buffer
before buffer overflow. This will cause different connections cut their window sizes at
different times. There are many AQM (Active Queue Management) techniques to do that,
such as RED (Random Early Detect), PI (Proportional and Integral AQM), AVQ (Adaptive
Virtual Queue), and REM (Random Exponential Marking), etc.
13. P51:
An advantage of using the earlier values of cwnd and ssthresh at t2 is that TCP would not
have to go through slow start and congestion avoidance to ramp up to the throughput value
obtained at t1. A disadvantage of using these values is that they may be no longer accurate. In
particular, if the path has become more congested between t1 and t2, the sender will send a
large window’s worth of segments into an already (more) congested path.
14. P53: