TCP File Transfer Time Analysis
TCP File Transfer Time Analysis
Protocol) - Solutions
COM-208: Computer Networks
1
A B A B
A B
1
1
1
2 2 x
2 x
3
3 3
(a)
4
1
1
1
2 2 x
2 x
3
3 3
(a)
4
(c)
4
(b)
2
𝑀𝑆𝑆
3. 𝐴 Transmits the 8th segments and waits for the ACK: 𝑅 +
2 ⋅ 𝑑𝑝𝑟𝑜𝑝 secs.
𝑀𝑆𝑆
4. 𝐴 Transmits the 5th segment, and it arrives at 𝐵: 𝑅 + 𝑑𝑝𝑟𝑜𝑝
secs.
A B A B
A B
1
1
1
2 2 x
2 x
3
3 3
(a)
4
(c)
4
(b)
3
File transfer over TCP
Consider the topology shown in Figure 1. Host 𝐴 opens a TCP connection to host 𝐵,
and starts sending a file of size 𝐹 = 10 bytes, in segments of size 𝑀 𝑆𝑆 = 1byte each.
As a result of a faulty link, the 5-th packet (without counting the SYN packet in the
TCP handshake) transmitted by 𝐴 is lost.
• Complete the sequence diagram in Figure 3 with all packets exchanged between 𝐴
and 𝐵 (we have completed part of the diagram to help you get started.).
4
State of the Sequence number diagram
cwndA ssthreshA
congestion
[bytes] [bytes]
control algorithm Sequence Acknowledgement
for host A number number
A B
1 ∞ — SYN, SEQ 0
RTT1
ACK 2
RTT1
ACK 3
ACK 4
ACK 5
ACK 5
RTT1
ACK 10
Congestion
2 2 SEQ 10
avoidance
RTT1 / 2
ACK 11
5
• Calculate how much time it takes for 𝐵 to finish receiving the file.
(Note: The one-way propagation delay from 𝐴 to 𝐵 is 𝑅𝑇2𝑇1 )
You can view the time duration marked down on the sequence dia-
gram in Figure 3. With the connection setup time included, it takes
6.5 × 𝑅𝑇 𝑇1 time to complete the file transfer, from start to finish.
Now, assume 𝐴 uses node 𝑃 , which runs an application-layer proxy to transmit the file
to 𝐵, as shown in Figure 4.
When 𝑃 receives a connection request from 𝐴, it connects a TCP socket with 𝐵. After
that, the proxy application receives data from the TCP socket connected to 𝐴 (the input
socket), and writes data out to the TCP socket connected to 𝐵 (the output socket). 𝑃
forwards these packets to the output socket, the moment it can read them from the input
socket. The proxy’s operations do not incur any processing delay.
𝑃 is located exactly in the middle of the path between 𝐴 and 𝐵, such that the round-trip
times between 𝐴 and 𝑃 , and between 𝑃 and 𝐵 are both equal to 𝑅𝑇 𝑇2 = 𝑅𝑇2𝑇1 .
The faulty link described previously is now located on the part of the path between 𝑃
and 𝐵 (the second half of the path). As a result, the 5-th packet transmitted on that
part of the path is lost. No packet loss occurs on the part of the path between 𝐴 and
𝑃.
• Calculate the time it takes for the file transfer to be completed in this new setting.
(Note: Do not forget to adjust the timeout interval for the two TCP flows;
from 𝐴 to 𝑃 , and from 𝑃 to 𝐵. The timeout interval for the two flows is equal to
2 × 𝑅𝑇 𝑇2 = 𝑅𝑇 𝑇1 )
6
the time it will take to propagate the first (connection) packet from
𝐴 to 𝑃 .
Now for the communication between 𝑃 and 𝐵, the sequence diagram
will be an exact replica of the one we created in figure 3. The only
difference now is that the round-trip time between 𝑃 and 𝐵 is half
the round-trip time between 𝐴 and 𝐵. Hence, it will take 6.5×𝑅𝑇 𝑇2 .
Thus, the total file transfer delay will be:
𝑅𝑇 𝑇2 7 ⋅ 𝑅𝑇 𝑇1
6.5 × 𝑅𝑇 𝑇2 + = 7 × 𝑅𝑇 𝑇2 =
2 2
• Does the introduction of the application-layer proxy in the previous part improve
or worsen the file transfer? Which features of TCP are responsible for this?
The main reason why the file transfer will take shorter to complete
is the reduction of the end-to-end RTT for each flow. This reduction
in RTT will have the following effects on TCP:
– The congestion window will converge faster to an ideal value
(assuming that link capacity is limited). In our example, where
the capacity is unlimited, slow start will benefit even more.
– This will make TCP more responsive in detecting and correcting
channel error (e.g., the 5-th packet which was lost). This is be-
cause the timeout interval adjusts to the RTT estimate; a smaller
RTT means that a packet is retransmitted faster. We would ob-
serve the same behavior in the case where fast-retransmit was
also activated.
7
Now with routing
Consider the topology shown in Figure 5. End-host 𝐴 sends end-host 𝐵 a large file.
This is the only active flow in the network and all the traffic traverses links 𝐿1 , 𝐿2 , 𝐿3
and 𝐿4 . 𝐴 sends application data into its TCP socket at a rate of 80 Mbps. 𝐵 can read
data from its TCP socket at a rate of 30 Mbps.
L2(40Mbps) L3(45Mbps)
L1(50Mbps) L4(50Mbps)
A B
L5(40Mbps) L6(45Mbps)
• What is the max transfer rate for the TCP flow in the following scenarios? Which
aspect of TCP limits it?
– The TCP receive buffer at 𝐵 can hold only a small portion of the file.
Now, Assume that the TCP receive buffer at 𝐵 can hold only a small portion of the
file. During the file transfer Link 𝐿2 fails and the traffic between 𝐴 and 𝐵 is rerouted
via links 𝐿1 , 𝐿5 , 𝐿6 and 𝐿4 . The RTT between 𝐴 and 𝐵 increases from 𝑅𝑇 𝑇𝑜𝑟𝑖𝑔 to
𝑅𝑇 𝑇𝑛𝑒𝑤 = 5 ⋅ 𝑅𝑇 𝑇𝑜𝑟𝑖𝑔 .
• Do 𝐴 and 𝐵 need to establish a new TCP connection? If yes, describe the message
exchange.
8
There will be no handshake involved; the connection will be pre-
served. Routing will take care of the path change and nothing but
the increased RTT will be visible at the transport layer. This is be-
cause it is only the end-hosts that maintain TCP connection state.
Flow control, again, only involves 𝐴 and 𝐵. Thus, flow control will
not be affected by the path change.
• What effect will the path change have on the TCP traffic between 𝐴 and 𝐵?
9
TCP fairness
Consider the topology shown in Figure 6. Links 𝐴-𝑅, 𝐵-𝑅 and 𝐶-𝑅 have identical
characteristics, and have a higher transmission rate than link 𝑅-𝐷. Transmitting hosts
𝐴, 𝐵 and 𝐶 all have to share the same link to send data to host 𝐷.
(Note: Assume that TCP is fair, in the sense that all TCP connections sharing the same
bottleneck link will equally share the link’s bandwidth.)
A B C
Calculate the share of the link capacity of 𝑅-𝐷 that each host gets (a long time after
the connections have been established) in each of the following cases.
You should justify your answers.
• 𝐴, 𝐵 and 𝐶 are transmitting data. Each host uses a single TCP flow.
After the TCP flows stabilize, they use the entire available transmis-
sion rate on the path from source to destination.
The common link R-D is the bottleneck for each flow (its transmission
rate is smaller than the transmission rate of any other link on the
path). So all three TCP flows share the same bottleneck.
Since TCP flows are fair to each other, and the paths they traverse
have the same characteristics, this means that all flows will have
equal throughput: 𝑇𝐴 = 𝑇𝐵 = 𝑇𝐶 = rate3𝑅−𝐷 .
• Only 𝐴 and 𝐵 are transmitting data. 𝐴 uses only one TCP flow, and 𝐵 uses two
parallel TCP flows.
10
Given that TCP fairness works on a per-flow basis (and not on a per-
host basis), this question is similar to the previous one. After the
TCP flows stabilize they use up the entire available capacity on the
bottleneck link, and share the capacity equally among them. Since
there are three flows, the throughput of each flow becomes rate3𝑅−𝐷 .
Finally, given that 𝐵 uses two flows, the throughput for each host
becomes 𝑇𝐴 = rate3𝑅−𝐷 and 𝑇𝐵 = 2×rate 3
𝑅−𝐷
. This means that 𝑇𝐵 =
2𝑇𝐴 .
• 𝐴, 𝐵 and 𝐶 are transmitting data. 𝐴 and 𝐵 each use one TCP flow. 𝐶 uses
a UDP-based application which transmits data at a constant rate of 40% of the
transmission rate of link 𝑅-𝐷.
UDP does not adjust its transmission rate, even if there exists any
other source of traffic in the network. Thus the throughput of host
C is 𝑇𝐶 = 0.4 × rate𝑅−𝐷 .
Similar to the previous questions, the TCP flows are fair to one
another, and each will get an equal portion of the remaining (60%)
capacity of the bottleneck link. Thus, 𝑇𝐴 = 𝑇𝐵 = 0.3 × rate𝑅−𝐷 .
Therefore, we have that 𝑇𝐴 = 𝑇𝐵 = 34 𝑇𝐶 .
11
Multiple TCP flows
Two flows, 𝑓𝑙𝑜𝑤1 (from 𝐴 to 𝐶) and 𝑓𝑙𝑜𝑤2 (from 𝐵 to 𝐶) traverse the same bottleneck
link, 𝑅-𝐶, as shown in Figure 7. The end-hosts use a variant of TCP where the congestion
window is fixed to 60 packets (i.e., the window does not adapt to network conditions).
You know that the capacity of link 𝑅-𝐶 is 3100 packets/sec.
A dprop = 5ms
dprop = 5ms
dprop = 10ms
R C
B
• Suppose that the transmission delay is negligible. Compute the throughput that
𝑓𝑙𝑜𝑤1 (𝑇 𝑝𝑢𝑡1 ) and 𝑓𝑙𝑜𝑤2 (𝑇 𝑝𝑢𝑡2 ) would achieve if only one flow is active at a time,
and no packet is ever dropped. Compute ratio 𝑇𝑇 𝑝𝑢𝑡𝑝𝑢𝑡1
.
2
Since the window size is fixed, each sender will transmit 60 packets
per RTT seconds (where RTT is the two-way propagation delay) and,
thus, 𝑡ℎ𝑟𝑜𝑢𝑔ℎ𝑝𝑢𝑡 = 2×𝑑60 . According to this scheme we have that
𝑝𝑟𝑜𝑝
60 60
𝑇 𝑝𝑢𝑡1 = 0.020 = 3000 pkts/sec and 𝑇 𝑝𝑢𝑡2 = 0.030 = 2000 pkts/sec.
Both throughput values are smaller than the bottleneck link capacity
and, thus, they are feasible. The ratio of the throughput values is
𝑇 𝑝𝑢𝑡1
𝑇 𝑝𝑢𝑡 = 1.5.
2
• You run an ns-2 simulation where both flows are active at the same time, and you
get that 𝑇𝑇 𝑝𝑢𝑡
𝑝𝑢𝑡1
= 1.28. In your simulation, you have set the buffer size of router 𝑅
2
to 1000 packets, so that no packet is ever dropped.
Explain why the ratio between the throughput of the two flows is different from
what you computed in the previous sub-question.
12
of each flow will increase by 𝑄 (the queueing delay), which means
60
that 𝑡ℎ𝑟𝑜𝑢𝑔ℎ𝑝𝑢𝑡 = 𝑄+2×𝑑 . For a large enough value of 𝑄, link
𝑝𝑟𝑜𝑝
𝑇 𝑝𝑢𝑡1
propagation delay becomes insignificant, and 𝑇 𝑝𝑢𝑡2 goes closer to 1.
13
Thinking creatively about TCP
Suppose that each router in the network has infinite buffer space which can hold all
packets the router has to forward, so that no packet is ever dropped. Given this setting:
There are two mechanisms in TCP which are relevant here; conges-
tion control and RTT estimation. The outcome will depend on how
these two interact with each other. In the worst case, the sender’s
estimate of RTT will keep up with the increasing queuing delay and
no timeout will occur (transmission timeout depends on RTT). This
will cause the congestion window size (and queuing delay) to grow
indefinitely.
At first glance, this will not affect TCP throughput that much.
However, new TCP flows will take longer to establish (the time
duration of the TCP handshake is proportional to RTT), and will
not be able to catch up with pre-existing flows, since nobody will
back off (this will affect fairness). Finally, network congestion will
affect latency-sensitive applications (e.g. video calls, DNS lookups)
and will render the network pretty much unusable.
A variant of TCP
Consider a variant of TCP were flow control is disabled. Is the congestion control in
this case sufficient to control the transmission rate of a sender if it is overwhelming a
14
receiver (i.e., when the receiver has no more buffer space)?
Justify your answers.
Congestion control will throttle the sender when the receiver becomes
overwhelmed; the receiver will start dropping packets, which the sender
will perceive as a congestion event. In particular, the sender will
experience a transmission timeout and remain in the Slow Start state
for as long as the receiver has no buffer space left.
15
Reading congestion window plot
Consider the graph shown in Figure 8, which plots the window size of a TCP sender as
a function of time.
50
Window Size (number of packets)
40
30
20
10
0
0 1 2 3 4 5 6 7 8 9
Time (seconds)
16
this event. We know that the previous state was Congestion
Avoidance because the window size was increasing linearly (+1
packet per RTT)
(iii) at t = 3.5 secs, the sender transitions from
Slow start to Congestion Avoidance. This is because
the congestion window becomes larger than ssthresh. We
can see this transition from the difference in the curves. (Slow
Start and Congestion Avoidance, as explained before)
(iv) at t = 8 secs, the sender transitions from Congestion avoidance
to Fast recovery. We can see that Triple duplicate ACKs has
occurred, and not a timeout, because the window size decreases
to half, and a Congestion Avoidance state follows.
• Calculate the number of packets that the TCP sender transmits between t = 6 secs
and t = 8 secs.
We know that the window size changes by 1 packet per RTT. Fol-
lowing up on the analysis done in the previous question, the window
size changes 20 times from t = 6 secs till t = 8 secs (from 20 packets
8−6
to 40 packets). Thus, 𝑅𝑇 𝑇 = 40−20 = 0.1 secs.
17
Finding a security loophole
In Figure 9, Alice is sending a large file to Bob using TCP. Denis tries to disrupt their
communication by sending traffic to Céline. No other hosts send any traffic.
L4 L5
Alice Bob
L2
R1 R2
L1 L3
Denis Céline
• Describe the simplest attack strategy that achieves Denis’s goal. What condition
needs to hold for the transfer rates of the links such that this strategy works?
Denis prevent Alice and Bob from communicating with each other
by flooding link 𝐿2 . To do so, Denis could send a constant stream of
high-volume UDP traffic to Céline.
This attack will succeed if and only iff the capacity of 𝐿1 is greater
or equal to the capacity of 𝐿2 .
If the capacity of 𝐿1 is greater or equal to the capacity of 𝐿2 , Denis
can send traffic at a rate equal to the capacity of 𝐿2 . Since 𝐿1 can
carry Denis’ attack traffic, all of it will reach 𝐿2 at the desired rate.
Thus, Denis’ attack will succeed.
Otherwise, if the capacity of 𝐿1 is lower than the capacity of 𝐿2 , the
attack will fail. This is because, even if Denis sends attack traffic
at a higher rate, 𝐿1 cannot carry traffic at a higher rate than the
capacity of 𝐿1 . Since the capacity of 𝐿1 is lower than the capacity of
𝐿2 , 𝐿2 will have some spare capacity to accommodate Alice’s traffic.
Thus, we have proven that the condition we described is both neces-
sary and sufficient.
• How will the TCP connection between Alice and Bob be affected by this attack?
Draw a simple diagram that shows how Alice’s congestion window, 𝑐𝑤𝑛𝑑, evolves
over time during the attack. You do not need to provide specific time values on
the 𝑥-axis, just show the trend (e.g., does 𝑐𝑤𝑛𝑑 increase monotonically?)
18
We can see an example diagram at Figure 10. You can see that
after the attack has commenced (sometime between 6 seconds and 8
seconds), Alice is no longer able to reliably reach Bob.
Thus, Alice’s transmissions will almost always timeout.
(In the figure it is not shown how the timeout estimation algorithm
of TCP will make Alice’s timeout achieve increasingly bigger values,
as Alice tries to determine the 𝑅𝑇 𝑇 between her and Bob.)
10
9
Congestion window size [MSS]
0
0 2 4 6 8 10 12 14 16
Time after T0 [seconds]
• Describe the attack strategy that achieves Denis’s goal while minimizing the
amount of traffic that Denis sends to Céline.
Hint: Denis does not need to send traffic at a constant rate.
19
those retransmission events. Every time that Denis expects Alice to
retransmit her packets, he sends a burst of traffic to saturate the
buffers of 𝑅1 . Thus, when Alice’s retransmitted packet arrives at
the congested router, 𝑅1 will drop the segment of Alice, and Alice
will have to wait for her timeout again. Naturally, Denis can stop
transmitting flood traffic for as long as Alice is not about to transmit
a new segment.
An added benefit of targeting timeout retransmissions is that such
failed retransmissions cause TCP to exponentially increase its time-
out interval. Thus, Alice will be sending progressively less frequently.
This means that Denis will have to send even less traffic as time goes
on.
What we have described so far is an attack strategy that works. In
order to argue that this strategy is optimal, we need to examine
whether an attack where we transmit a fewer number of messages is
possible.
Note that the goal of Alice is to be able to send traffic to Bob at some
predictable rate, even if this rate is significantly lower than before
Denis’ intervention. The goal of Denis is to make it so that Alice
has no guarantee about how long it will take for Alice’s segment to
reach Bob.
Denis only transmits attack messages while Alice is retransmitting
timed-out packets. If Denis fails to transmit enough messages to
flood 𝐿2 , the segment of Alice will not get dropped, and Alice will be
able to transmit a new piece of information to Bob. This will make
Denis’ attack ineffective. Thus, for Denis’ strategy to be effective,
Denis should always transmit at least as many messages are necessary
to block Alice’s retransmissions. Since Denis is not transmitting any
attack traffic at any other point in time, it is impossible that there
exists a strategy more optimal than the one we described.
20
A recap of everything
Alice has opened a persistent TCP connection to Bob. At time 𝑇0 , Alice starts sending
to Bob, over this connection, a file of size 12 bytes in segments of 𝑀 𝑆𝑆 = 1 byte.
Figure 11 shows how the congestion window of Alice, 𝑐𝑤𝑛𝑑, changes over time after 𝑇0
and until the file transfer completes. Each of the 𝑓𝑖𝑣𝑒 points in the graph shows the
time a change in 𝑐𝑤𝑛𝑑 took place and 𝑐𝑤𝑛𝑑’s value after the change.
Make the following assumptions:
- Transmission delay is negligible.
- Bob sends an ACK for each segment it receives.
- The first segment that Alice transmits after 𝑇0 has sequence number 10.
- Fast-retransmit is disabled.
- Only one segment gets lost after 𝑇0 , and it is a segment sent by Alice.
- B stores (does not discard) all out-of-order packets.
7
Congestion window size [bytes]
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
Time after T0 [seconds]
21
The RTT between Alice and Bob is 0.5 seconds.
We can extract this piece of information from what happens at time
1 seconds after 𝑇0 and 1.5 seconds after 𝑇0 . TCP is in Congestion
avoidance phase during that time, and the size of the congestion
window increases by 1 MSS (=1 byte) per RTT during that phase.
Since the congestion window increases from 4 to 5, between 1 secs
and 1.5 secs, RTT is equal to:
1.5−1
5−4 = 0.5 secs
• What was the size of Alice’s congestion window, 𝑐𝑤𝑛𝑑, the last time a packet was
lost before 𝑇0 ?
The size of 𝑐𝑤𝑛𝑑 the last time a packet was lost before 𝑇0 was 8 (or
9) bytes.
The value of ssthresh updated if and only if there is a packet loss,
and it is set to 𝑐𝑤𝑛𝑑
2 . Since, in our sequence diagram, the current
value of ssthresh is 4, the last there was a packet loss (and ssthresh’s
value was updated), 𝑐𝑤𝑛𝑑 was 2 ⋅ 4 = 8 bytes.
If we assume that ssthresh has any non-integral values rounded down,
another possible value could have been 9, since 9 divided by 2 also
yields 4.
• Complete the diagram in Figure 13 that shows what happens after 𝑇0 and until
the file transfer completes:
- All segments exchanged between Alice and Bob.
- The sequence numbers sent by Alice and the acknowledgment numbers sent
by Bob.
22
- The state of Alice’s congestion-control algorithm.
- The size of Alice’s congestion window, cwnd, in bytes.
- The value of Alice’s slow-start threshold, ssthresh, in bytes.
23
State of the Sequence number diagram
cwnd ssthresh
congestion
[bytes] [bytes]
control algorithm Sequence Acknowledgement
for Alice number number
Alice Bob
T0
1 4 Slow start SEQ 10
ACK 11
ACK 12
ACK 13
SEQ 13
4 4 SEQ 14
Congestion Avoidance SEQ 15
SEQ 16
ACK 14
{
ACK 15
ACK 16
ACK 17
SEQ 17
SEQ 18
5 4 Congestion Avoidance SEQ 19
SEQ 20
SEQ 21
X
ACK 17
ACK 17
ACK 17
ACK 17
Timeout:
SEQ 17
ACK 22
2 2 Congestion Avoidance
24
• How long does the file transfer take? Assume that the file transfer completes once
Alice has received the final ACK for file data.
From the sequence diagram, we can see that the complete file transfer
takes:
– 3 × 𝑅𝑇 𝑇 (to receive the ACKs for packets 13 to 16)
– A timeout
– 1 × 𝑅𝑇 𝑇 (to receive the ACK for packet 17, which has been
retransmitted)
Thus, in total we have 4 ⋅ 𝑅𝑇 𝑇 + 𝑡𝑖𝑚𝑒𝑜𝑢𝑡 = 4 ⋅ 0.5 + 2 = 4 seconds.
• Now assume (just for this part) that fast-retransmit is enabled. Does this change
the duration of the file transfer and how/why?
If Fast-Retransmit were enabled, the file transfer would take 2.5 sec-
onds instead.
This is because at time 2 seconds, Alice would have finished receiv-
ing 3 triple duplicate ACKs for SEQ 17. Thus, Alice would have
retransmitted the lost packet at time 2 seconds, as opposed to time
3.5 seconds (which is the case in the sequence diagram).
As a result, this would decrease the file transfer time by 1.5 seconds.
Thus, the total transfer time would be 4 − 1.5 = 2.5 seconds.
25