Lecture 6: Lowering Latency
This lecture discusses some of the factors that affect the latency of
a TCP congestion. It considers TCP congestion control, the TCP Reno
and Cubic congestion control algorithms, and their behaviour and
performance in terms of throughput and latency. It then considers
alternative congestion control, such as the TCP Vegas and BBR
algorithms, and the use of explicit congestion notification (ECN),
as options to lower latency. Finally, it considers the impact of
sub-optimal Internet paths on latency, and the rationale for deploying
low-Earth orbit satellite constellations to reduce latency of Internet
paths.
Part 1: Lowering Latency
This first part of the lecture outlines the principle of congestion
control. It discusses packet loss as a congestion signal, conservation
of packets in flight, and the additive increase, multiplicative
decrease requirements for stability.
00:00:00.000
In this lecture I’d like to move
00:00:02.395
on from talking about how to transfer
00:00:04.789
data reliably, and talk about mechanisms and
00:00:07.184
means by which transport protocols go about
00:00:09.578
lowering the latency of the communication.
00:00:15.001
One of the key limiting factors of
00:00:17.966
performance of network systems, as we've discussed
00:00:20.932
in some of the previous lectures,
00:00:23.474
is latency.
00:00:24.421
Part of that is the latency for
00:00:26.799
establishing connections, and we've spoken about that
00:00:29.177
in detail already, where a lot of
00:00:31.555
the issue is the number of round
00:00:33.933
trip times needed to set up a
00:00:36.311
connection.
00:00:36.751
And, especially when secure connections are in
00:00:39.506
use, if you're using TCP and TLS,
00:00:42.262
for example, as we discussed, there’s a
00:00:45.017
large number of round trips needed to
00:00:47.772
actually get to the point where you
00:00:50.528
can establish a connection, negotiate security parameters,
00:00:53.283
and start to exchange data.
00:00:55.351
And we've already spoken about how the
00:00:58.788
QUIC Transport Protocol
00:01:00.361
has been developed to try and improve
00:01:03.221
latency in terms of establishing a connection.
00:01:06.181
The other aspects of latency, and reducing
00:01:08.580
the latency of communications, is actually in
00:01:10.980
terms of data transfer.
00:01:12.451
How you deliver data across the network
00:01:15.838
in a way which doesn't lead to
00:01:19.224
excessive delays, and how you can gradually
00:01:22.711
find ways of reducing the latency,
00:01:25.732
and making the network better suited to
00:01:29.256
real time applications, such as telephony,
00:01:32.277
and video conferencing, and gaming, and high
00:01:35.801
frequency trading, and
00:01:37.411
Internet of Things, and control applications.
00:01:43.081
A large aspect of that is in
00:01:44.982
terms of how you go about building
00:01:46.883
congestion control, and a lot of the
00:01:48.784
focus in this lecture is going to
00:01:50.685
be on how TCP
00:01:51.871
congestion control works, and how other protocols
00:01:54.708
do congestion, to deliver data in a
00:01:57.545
low latency manner.
00:01:58.861
But I’ll also talk a bit about
00:02:01.672
explicit congestion notification, and changes to the
00:02:04.483
way queuing happen in the network,
00:02:06.892
and about services such as SpaceX’s StarLink
00:02:09.703
which are changing the way the network
00:02:12.513
is built to reduce latency.
00:02:17.131
I want to start by talking about
00:02:19.525
congestion control, and TCP congestion control in
00:02:21.919
particular.
00:02:26.791
And, what I want to do in
00:02:28.677
this part, is talk about some of
00:02:30.563
the principles of congestion
00:02:31.741
control. And talk about what is the
00:02:34.343
problem that's being solved, and how can
00:02:36.944
we go about adapting the rate at
00:02:39.546
which a TCP connection delivers data over
00:02:42.148
the network
00:02:42.991
to make best use of the network
00:02:45.193
capacity, and to do so in a
00:02:47.396
way which doesn't build up queues in
00:02:49.598
the network and induce too much latency.
00:02:51.901
So in this part I’ll talk about
00:02:54.568
congestion control principles. In the next part
00:02:57.235
I move on to talk about loss-based
00:02:59.901
congestion control, and talk about TCP Reno
00:03:02.568
and TCP Cubic,
00:03:03.811
which are ways of making very effective
00:03:06.398
use of the overall network capacity,
00:03:08.616
and then move on to talk about
00:03:11.203
ways of lowering latency.
00:03:12.781
I’ll talk about latency reducing congestion control
00:03:15.861
algorithms, such as TCP Vegas or Google's
00:03:18.941
TCP BBR proposal. And then I’ll finish
00:03:22.021
up by talking a little bit about
00:03:25.101
Explicit Congestion Notification
00:03:26.521
in one of the later parts of
00:03:29.780
the lecture.
00:03:30.811
TCP is a
00:03:33.601
complex and very highly optimised protocol,
00:03:37.399
especially when it comes to congestion control
00:03:41.829
and loss recovery mechanisms.
00:03:44.461
iIm going to attempt to give you
00:03:46.985
a flavour of the way congestion control
00:03:49.509
works in this lecture, but be aware
00:03:52.034
that this is a very simplified review
00:03:54.558
of some quite complex issues.
00:03:56.461
The document listed on the slide is
00:04:00.181
entitled “A roadmap for TCP Specification Documents”,
00:04:03.900
and it's the latest IETF standard that
00:04:07.620
describes
00:04:08.251
how TCP works, and points to the
00:04:12.463
details of the different proposals.
00:04:15.571
This is a very long and complex
00:04:18.452
document. It’s about, if I remember right,
00:04:21.333
60 or 70 pages long.
00:04:23.491
And all it is, is a list
00:04:26.069
of references to other specifications, with one
00:04:28.648
paragraph about each one describing why that
00:04:31.226
specification is important.
00:04:32.431
And the complete specification for TCP is
00:04:35.114
several thousand pages of text. This is
00:04:37.796
a complex protocol with a lot of
00:04:40.479
features in it, and I’m necessarily giving
00:04:43.161
a simplified overview.
00:04:47.131
I’m going to talk about TCP.
00:04:49.360
I’m not going to talk much,
00:04:51.589
if at all, about QUIC in this
00:04:54.190
lecture.
00:04:54.661
That's not because QUIC isn't interesting,
00:04:57.518
it's because QUIC essentially adopts the same
00:05:00.850
congestion control mechanisms as TCP.
00:05:03.331
The QUIC version one standard says to
00:05:06.743
use TCP Reno, use the same congestion
00:05:10.154
control algorithm as TCP Reno.
00:05:12.691
And, in practice, most of the QUIC
00:05:15.418
implementations use the Cubic or the BBR
00:05:18.145
congestion control algorithms, which we'll talk about
00:05:20.872
later on.
00:05:21.751
QUIC is basically adopting the same mechanisms
00:05:24.565
as does TCP, and for that reason
00:05:27.379
that I’m not going to talk about
00:05:30.193
them too much separately.
00:05:36.691
So what is the goal of congestion
00:05:39.654
control? What are the principles of congestion
00:05:42.618
control?
00:05:43.141
Well, the idea of congestion control is
00:05:46.589
to find the right transmission rate for
00:05:50.036
a connection.
00:05:51.121
We're trying to find the fastest sending
00:05:53.612
rate which you can send at to
00:05:56.102
match the capacity of the network,
00:05:58.237
and to do so in a way
00:06:00.727
that doesn't build up queues, doesn't overload,
00:06:03.218
doesn't congest the network.
00:06:04.741
So we're looking to adapt the transmission
00:06:07.331
rate of a flow of TCP traffic
00:06:09.921
over the network, to match the available
00:06:12.511
network capacity.
00:06:13.351
And as the network capacity changes,
00:06:15.790
perhaps because other flows of traffic start
00:06:18.636
up, or perhaps because you're on a
00:06:21.482
mobile device and you move into an
00:06:24.328
area with different radio coverage,
00:06:26.461
the speed at which the TCP is
00:06:29.795
delivering the data should adapt to match
00:06:33.129
the changes and available capacity.
00:06:35.611
The fundamental principles of congestion control,
00:06:40.015
as applied in TCP,
00:06:43.051
were first described by Van Jacobson,
00:06:46.046
who we see on the picture on
00:06:49.541
the top right of the slide,
00:06:52.536
in the paper “Congestion Avoidance and Control”.
00:06:56.131
And those principles are that TCP responds
00:06:58.808
to packet loss as a congestion signal.
00:07:01.484
It treats the loss of a packet,
00:07:04.261
because the Internet is a best effort
00:07:06.820
packet network, and it loses, it discards
00:07:09.378
packets, if it can't deliver them,
00:07:11.572
and TCP treats that discard, that loss
00:07:14.130
of a packet, as a congestion signal,
00:07:16.689
and as a signal of it's sending
00:07:19.248
too fast and should slow down.
00:07:21.541
It relies on the principle of conservation
00:07:23.839
of packets. It tries to keep the
00:07:26.138
number of packets, which are traversing the
00:07:28.436
network roughly constant,
00:07:29.521
assuming nothing changes in the network.
00:07:32.048
And it relies on the principles of
00:07:34.996
additive increase, multiplicative decrease.
00:07:36.781
If it has to increase its sending
00:07:39.239
rate, it does so relatively slowly,
00:07:41.346
an additive increase in the rate.
00:07:43.453
And if it has to reduce its
00:07:45.911
sending rate, it does so quickly,
00:07:48.018
a multiplicative decrease.
00:07:49.171
And these are the fundamental principles that
00:07:52.402
Van Jacobson elucidated for TCP congestion control,
00:07:55.632
and for congestion control in general.
00:07:58.501
And it was Van Jacobson who did
00:08:02.860
the initial implementation of these into TCP
00:08:07.219
in the mid-1980s, about 1984, ’85,
00:08:10.956
or so.
00:08:12.301
Since then, the algorithms, the congestion control
00:08:15.104
algorithms, for TCP in general have been
00:08:17.906
maintained by a large number of people.
00:08:20.709
A lot of people have developed this.
00:08:23.611
Probably one of the leading people in
00:08:26.726
this space for the last 20 years
00:08:29.841
or so, is Sally Floyd who was
00:08:32.956
very much responsible for taking
00:08:35.281
the TCP standards, making them robust,
00:08:37.427
pushing them through the IETF to get
00:08:39.931
them standardised, and making sure they work,
00:08:42.434
and making sure they work and get
00:08:44.938
really high performance.
00:08:46.111
And she very much drove the development
00:08:48.793
to make these robust, and effective,
00:08:51.093
and high performance standards, and to make
00:08:53.775
TCP work as well as it does
00:08:56.458
today.
00:08:56.941
And Sally sadly passed away a year
00:09:00.444
or so back, which is a tremendous
00:09:03.947
shame, but we're grateful for her legacy
00:09:07.449
in moving things forward.
00:09:13.501
So talking back to the principles.
00:09:17.011
The first principle of congestion control in
00:09:20.246
the Internet, and in TCP, is that
00:09:23.480
packet loss is an indication that the
00:09:26.715
network is congested.
00:09:28.201
Data flying across the Internet flows from
00:09:31.421
the sender to the receiver through a
00:09:34.641
series of routers. The IP routers connect
00:09:37.861
together the different links that comprise the
00:09:41.081
network.
00:09:41.641
And routers perform two functions:
00:09:44.431
they perform a routing function, and a
00:09:48.647
forwarding function.
00:09:49.951
The purpose of the routing function is
00:09:52.555
to figure out how packets should get
00:09:55.160
to their destination. They receive a packet
00:09:57.764
from some network link, look at the
00:10:00.368
destination IP address, and decide which direction
00:10:02.972
to forward that packet. They’re responsible for
00:10:05.577
finding the right path through the network.
00:10:08.281
But they're also responsible for forwarding,
00:10:10.568
which is actually putting the packets into
00:10:13.236
the queue of outgoing traffic for the
00:10:15.904
link, and managing that queue of packets
00:10:18.572
to actually transmit the packets across the
00:10:21.240
network.
00:10:21.721
And routers in the network have a
00:10:24.260
set of different links; the whole point
00:10:26.799
of a router is to connect different
00:10:29.337
links. And at each link, they have
00:10:31.876
a queue of packets, which are enqueued
00:10:34.415
to be delivered on that link.
00:10:36.691
And, perhaps obviously, if packets are arriving
00:10:39.317
faster than the link can deliver those
00:10:41.943
packets, then the queue gradually builds up.
00:10:44.568
More and more packets get enqueued in
00:10:47.194
the router waiting to be delivered.
00:10:49.445
And if packets are arriving slower than
00:10:52.071
they can be forwarded,
00:10:53.671
then the queue gradually empties as the
00:10:57.927
packets get transmitted.
00:10:59.851
Obviously the router has a limited amount
00:11:02.119
of memory, and at some point it's
00:11:04.388
going to run out of space to
00:11:06.656
enqueue packets. So, if packets are being
00:11:08.925
delivered faster than they,
00:11:10.321
if packets arriving at the router faster
00:11:12.818
than they can be delivered down the
00:11:15.315
link, the queue will build up and
00:11:17.812
gradually fill, until it reaches its maximum
00:11:20.310
size. At that point, the router has
00:11:22.807
no space to keep the newly arrived
00:11:25.304
packets, and so it discards the packets.
00:11:27.901
And this is what TCP is using
00:11:30.334
as the congestion signal. It’s using the
00:11:32.767
fact that the queue of packets on
00:11:35.200
an outgoing link at a router has
00:11:37.633
filled up. It's using that as an
00:11:40.066
indication that
00:11:40.861
the queue fills up, the packet gets
00:11:43.220
lost, it uses that packet loss as
00:11:45.579
an indication that it's sending too fast.
00:11:47.938
It’s sending faster than the packets can
00:11:50.297
be delivered, and as a result the
00:11:52.656
queue has overflowed, a packet has been
00:11:55.015
lost, and so it needs to slow
00:11:57.374
down.
00:11:57.811
And that's the fundamental congestion signal in
00:12:00.664
the network. Packet loss is interpreted as
00:12:03.518
a sign that devices are sending too
00:12:06.371
fast, and should go slower. And if
00:12:09.224
they slow down, the queues will gradually
00:12:12.078
empty, and packets will stop being lost.
00:12:15.031
So that's the first fundamental principle.
00:12:20.521
The second principle is that
00:12:24.901
we want to keep the number of
00:12:27.949
packets in the network roughly constant.
00:12:30.661
TCP, as we saw in the last
00:12:33.264
lecture, sends acknowledgments for packets. When a
00:12:35.867
packet is transmitted it has a sequence
00:12:38.471
number, and the response will come back
00:12:41.074
from the receiver acknowledging receipt of that
00:12:43.677
sequence number.
00:12:44.521
The general approach for TCP, once the
00:12:47.337
connection has got going, is that every
00:12:50.153
time it gets an acknowledgement, it uses
00:12:52.968
that as a signal that a packet
00:12:55.784
has been received.
00:12:57.091
And if a packet has been received,
00:12:59.219
something has left the network. One of
00:13:01.347
the packets sent into the network has
00:13:03.475
reached the other side, and has been
00:13:05.603
removed from the network at the receiver.
00:13:07.831
That means there should be space to
00:13:10.863
put another packet into the network.
00:13:13.561
And it's an approach that’s called ACK
00:13:15.850
clocking. Every time a packet arrives at
00:13:18.140
the receiver, and you get an acknowledgement
00:13:20.429
back saying it was received, that indicates
00:13:22.719
you can put another packet in.
00:13:24.781
So the total number of packets and
00:13:27.569
transit across the network ends up being
00:13:30.358
roughly constant. One packet out, you put
00:13:33.146
another packet in.
00:13:34.441
And it has the advantage that if
00:13:37.288
you're clocking out new packets in receipt
00:13:40.135
of acknowledgments, if, for some reason,
00:13:42.576
the network gets congested, and it takes
00:13:45.423
longer for acknowledgments to come back,
00:13:47.863
because it's taking longer for them to
00:13:50.711
work their way across the network,
00:13:53.251
then, that will automatically slow down the
00:13:55.336
rate at which you send. Because it
00:13:57.420
takes longer for the next acknowledgment to
00:13:59.505
come back, therefore it's longer before you
00:14:01.590
send your next packet.
00:14:02.881
So, as the network starts to get
00:14:05.138
busy, as the queue starts to build
00:14:07.394
up, but before the queue has overflowed,
00:14:09.751
it takes longer for the acknowledgments to
00:14:12.246
come back, because the packets are queued
00:14:14.742
up in the intermediate links, and that
00:14:17.237
gradually slows down the behaviour of TCP.
00:14:19.733
It reduces the rate at which you
00:14:22.228
can send.
00:14:23.041
So it’s, to at least some extent,
00:14:25.499
self adjusting. The network gets busier,
00:14:27.607
the ACKs come back slower, therefore you
00:14:30.065
send a little bit slower.
00:14:31.921
And that's the second principle: conservation of
00:14:34.091
packets. One out, one in.
00:14:41.311
And the principle of conservation of packets
00:14:44.852
is great, provided the network is in
00:14:48.393
the steady state.
00:14:50.011
But you also need to be able
00:14:52.064
to adapt the rate at which you're
00:14:54.118
sending.
00:14:54.511
The way TCP adapts is very much
00:14:59.651
focused on starting slowly and gradually increasing.
00:15:04.891
When it needs to increase it’s sending
00:15:07.872
rate, TCP increases linearly. It adds a
00:15:10.853
small amounts to the sending rate each
00:15:13.833
round trip time.
00:15:15.211
So it just gradually, slowly, increases the
00:15:18.603
sending rating. It gradually
00:15:20.641
pushes up the rate
00:15:23.191
until it spots a loss. Until it
00:15:26.028
loses a packet. Until it overflows a
00:15:28.866
queue.
00:15:29.371
And then it responds to congestion by
00:15:32.409
rapidly decreasing its rate. If a congestion
00:15:35.446
event happens, if a packet is lost,
00:15:38.484
TCP halves its rate. It responds faster
00:15:41.522
than it increases, it slows down faster
00:15:44.559
than it increases.
00:15:45.961
And this is the final principle,
00:15:48.172
what’s known as additive increase, multiplicative decrease.
00:15:50.851
The goal is to keep the network
00:15:53.721
stable. The goal is to not overload
00:15:56.591
the network.
00:15:57.511
If you can, keep going at a
00:16:00.356
steady rate. Follow the ACK clocking approach.
00:16:03.301
Gradually, just slowly, increase the rate a
00:16:05.886
bit. Keep pushing, just in case there’s
00:16:08.471
more capacity than you think. So just
00:16:11.056
gradually keep probing to increase the rate.
00:16:13.741
If you overload the network, if you
00:16:16.154
cause congestion, if you overflow the queues,
00:16:18.567
cause a packet to be lost,
00:16:20.635
slow down rapidly. Halve your sending rate,
00:16:23.048
and gradually build up again.
00:16:24.871
The fact that you slow down faster
00:16:26.987
than you speed up, the fact that
00:16:29.103
you follow the one in, one out
00:16:31.219
approach,
00:16:31.621
keeps the network stable. It makes sure
00:16:33.689
it doesn't overload the network, and it
00:16:35.758
means that if the network does overload,
00:16:37.826
it responds and recovers quickly The goal
00:16:39.894
is to keep the traffic moving.
00:16:41.667
And TCP is very effective at doing
00:16:43.736
this.
00:16:47.371
So those are the fundamental principles of
00:16:50.344
TCP congestion control. Packet loss as an
00:16:53.317
indication of congestion.
00:16:54.691
Conservation of packets, and ACK clocking.
00:16:57.476
One in, one out, where possible.
00:17:00.361
If you need to increase the sending
00:17:03.225
rate, increase slowly. If a problem happens,
00:17:06.089
decrease quickly. And that will keep the
00:17:08.953
network stable.
00:17:09.871
In the next part I’ll talk about
00:17:12.483
TCP Reno, which is one of the
00:17:15.096
more popular approaches for doing this in
00:17:17.708
practice.
Part 2: TCP Reno
The second part of the lecture discusses TCP Reno congestion control.
It outlines the principles of window based congestion control, and
describes how they are implemented in TCP. The choice of initial
window, and how the recommended initial window has changed over time,
is discussed, along with the slow start algorithm for finding the
path capacity and the congestion avoidance algorithm for adapting
the congestion window.
00:00:00.000
In the previous part, I spoke about
00:00:02.360
the principles of TCP congestion control in
00:00:04.721
general terms. I spoke about the idea
00:00:07.081
of packet loss as a congestion signal,
00:00:09.541
about the conservation of packets, and about
00:00:12.059
the idea of additive increase multiplicative decrease
00:00:14.576
– increase slowly, decrease the sending quite
00:00:17.093
quickly as a way of achieving stability.
00:00:19.711
In this part I want to talk
00:00:21.890
about TCP Reno, and some of the
00:00:24.069
details of how TCP congestion control works
00:00:26.248
in practice.
00:00:26.971
I’ll talk about the basic TCP congestion
00:00:30.004
control algorithm, how the sliding window algorithm
00:00:33.036
works to adapt the sending rate,
00:00:35.636
and the slow start and congestion avoidance
00:00:38.668
phases of congestion control.
00:00:44.071
TCP is what's known as a window
00:00:48.169
based congestion control protocol.
00:00:50.611
That is, it maintains what's known as
00:00:53.431
a sliding window of data which is
00:00:56.250
available to be sent over the network.
00:00:59.070
And the sliding window determines what range
00:01:01.890
of sequence numbers can be sent by
00:01:04.710
TCP onto the network.
00:01:06.421
It uses the additive increase multiplicative decrease
00:01:09.345
approach to grow and shrink the window.
00:01:12.268
And that determines, at any point,
00:01:14.774
how much data TCP sender can send
00:01:17.698
onto the network.
00:01:19.051
It augments these with algorithms known as
00:01:21.998
slow start and congestion avoidance. Slow start
00:01:24.946
being the approach TCP uses to get
00:01:27.893
a connection going in a safe way,
00:01:30.841
and congestion avoidance being the approach it
00:01:33.788
uses to maintain the sending rate once
00:01:36.736
the flow has got started.
00:01:38.941
The fundamental goal of TCP is that
00:01:42.234
if you have several TCP flows sharing
00:01:45.527
a link, sharing a bottleneck link in
00:01:48.820
the network,
00:01:49.861
each of those flows should get an
00:01:52.747
approximately equal share of the bandwidth.
00:01:55.321
So, if you have four TCP flows
00:01:57.683
sharing a link, they should each get
00:02:00.044
approximately one quarter of the capacity of
00:02:02.406
that link.
00:02:03.181
And TCP does this reasonably well.
00:02:06.368
It’s not perfect. It, to some extent,
00:02:10.085
biases against long distance flows,
00:02:12.841
and shorter flows tend to win out
00:02:15.582
a little over long distance flows.
00:02:17.931
But, in general, it works pretty well,
00:02:20.672
and does give flows roughly a roughly
00:02:23.413
equal share of the bandwidth.
00:02:25.471
The basic algorithm it uses to do
00:02:27.837
this, the basic congestion control algorithm,
00:02:29.864
is an approach known as TCP Reno.
00:02:32.230
And this is the state of the
00:02:34.595
art in TCP as of about 1990.
00:02:42.451
TCP is an ACK based protocol.
00:02:45.871
You send a packet, and sometime later
00:02:48.939
an acknowledgement comes back telling you that
00:02:52.007
the packet arrived, and indicating the sequence
00:02:55.075
number of the next packet which is
00:02:58.143
expected.
00:02:58.681
The simplest way you might think that
00:03:00.989
would work, is you send a packet.
00:03:03.296
You wait for the acknowledgment. You send
00:03:05.604
another packet You wait for the acknowledgement.
00:03:07.912
And so on.
00:03:09.001
The problem with that, is that it
00:03:11.638
tends to perform very poorly.
00:03:13.621
It takes a certain amount of time
00:03:16.146
to send a packet down a link.
00:03:18.672
That depends on the size of the
00:03:21.197
packet, and the link bandwidth.
00:03:23.101
The size of the packet is expressed
00:03:25.132
some number of bits to be sent.
00:03:27.164
The link bandwidth is expressed in some
00:03:29.195
number of bits it can deliver each
00:03:31.226
second. And if you did divide the
00:03:33.258
packet size by the bandwidth, that gives
00:03:35.289
you the number of seconds it takes
00:03:37.320
to send each packet.
00:03:38.581
It takes a certain amount of time
00:03:41.006
so that packet to propagate down the
00:03:43.432
link to the receiver, and for the
00:03:45.857
acknowledgment come back to you, depending on
00:03:48.282
the round trip of the link.
00:03:50.461
And you can measure the round trip
00:03:52.765
time of the link.
00:03:54.181
And you can divide one by the
00:03:56.290
other. You can take the time it
00:03:58.398
takes to send a packet, and the
00:04:00.507
time it takes for the acknowledgment to
00:04:02.615
come back, and divide one by the
00:04:04.724
other, to get the link utilisation.
00:04:06.631
And, ideally, you want that fraction be
00:04:08.907
close to one. You want to be
00:04:11.183
spending most of the time sending packets,
00:04:13.459
and not much time waiting for the
00:04:15.735
acknowledgments to come back before you can
00:04:18.010
send the next packet.
00:04:19.411
The problem is that's often not the
00:04:22.316
case.
00:04:22.831
For example, if we assume we're trying
00:04:24.910
to send data, and we have a
00:04:26.990
gigabit link, which is connecting the machine
00:04:29.069
we're sending data from, and we’re trying
00:04:31.149
to go from Glasgow to London.
00:04:33.031
And this might be the case you
00:04:35.360
would find if you had a one
00:04:37.689
of the machines in the Boyd Orr
00:04:40.018
labs, which is connected to the University's
00:04:42.346
gigabit Ethernet, and the University has a
00:04:44.675
10 gigabit per second link to the
00:04:47.004
rest of the Internet, so the bottleneck
00:04:49.333
is that Ethernet.
00:04:50.431
If you're talking to a machine in
00:04:52.785
London,
00:04:53.221
let's make some assumptions on how long
00:04:56.994
this will take.
00:04:58.711
You’re sending using Ethernet, and the biggest
00:05:01.134
packet an Ethernet can deliver is 1500
00:05:03.556
bytes. So 1500 bytes, multiplied by eight
00:05:05.979
bits per byte, gives you a number
00:05:08.401
of bits in the packet. And it’s
00:05:10.824
a gigabit Ethernet, so it's sending a
00:05:13.247
billion bits per second.
00:05:14.731
So 1500 bytes, times eight bits,
00:05:17.191
divided by a billion bits per second.
00:05:20.161
It will take 12 microseconds, 0.000012 of
00:05:23.793
a second, 12 microseconds to send a
00:05:27.425
packet down the link. And that’s just
00:05:31.058
the time it takes to physically serialise
00:05:34.690
1500 bytes down a gigabit per second
00:05:38.322
link.
00:05:38.941
The round trip time to London,
00:05:41.306
if you measure it, is about
00:05:43.771
a 100th of a second, about 10
00:05:46.965
milliseconds.
00:05:47.521
If you divide one by the other,
00:05:50.771
you find that the utilisation is 0.0012.
00:05:54.121
0.12% of the link is in use.
00:05:57.028
The time it takes to send a
00:05:59.935
packet is tiny compared to the time
00:06:02.843
it takes to get a response.
00:06:05.335
So if you're just sending one packet,
00:06:08.242
and waiting for a response, the link
00:06:11.149
is idle 99.9% of the time.
00:06:13.741
The idea of a sliding window protocol
00:06:16.223
is to not just send one packets
00:06:18.705
and wait for an acknowledgement. It’s to
00:06:21.187
send several packets,
00:06:22.351
and wait for the acknowledgments. And the
00:06:24.973
window is the number of packets that
00:06:27.595
can be outstanding before the acknowledgement comes
00:06:30.216
back.
00:06:30.691
The ideas is, you can start several
00:06:32.762
packets going, and eventually the acknowledgement comes
00:06:34.834
back, and that starts triggering the next
00:06:36.905
packets to be clocked out. This idea
00:06:38.976
is to improve the utilisation by sending
00:06:41.048
more than one packet before you get
00:06:43.119
an acknowledgment.
00:06:46.681
And this is the fundamental approach to
00:06:49.262
sliding window protocols. The sender starts sending
00:06:51.844
data packets, and there's what's known as
00:06:54.425
a congestion window that's that specifies how
00:06:57.006
many packets that's it’s allowed to send
00:06:59.587
before it gets an acknowledgement.
00:07:01.531
And, in this example, the congestion window
00:07:04.485
is six packets.
00:07:05.851
And the sender starts. It sends the
00:07:08.482
first data packet, and that gets sent
00:07:11.114
and starts its way traveling down the
00:07:13.745
link.
00:07:14.221
And at some point later it sends
00:07:16.552
the next packet, and then the next
00:07:18.882
packet, and so.
00:07:19.981
After a certain amount of time that
00:07:22.364
first packet arrives at the receiver,
00:07:24.406
and the receiver generates the acknowledgments which
00:07:26.789
comes back towards the sender.
00:07:28.591
And while this is happening, the sender
00:07:30.647
is sending more of the packets from
00:07:32.703
its window.
00:07:33.391
And the receiver’s gradually receiving those and
00:07:35.934
sending that acknowledgments. And, at some point
00:07:38.478
later, the first acknowledgement makes it back
00:07:41.021
to the sender.
00:07:42.211
And in this case we've set the
00:07:44.917
window size to be six packets.
00:07:47.237
And it just so happens that the
00:07:49.943
acknowledgement for the first packet arrives back
00:07:52.649
at the sender, just as it has
00:07:55.355
finished sending packet six.
00:07:57.001
And that triggers the window to increase.
00:07:59.123
That triggers the window to slide along.
00:08:01.246
So instead of being allowed to send
00:08:03.368
packets one through six,
00:08:04.681
we're now allowed to send packets two
00:08:06.911
through seven. Because one packet has arrived,
00:08:09.140
that's opened up the window to allow
00:08:11.370
us to send one more packet.
00:08:13.381
And the acknowledgement indicates that packet one
00:08:15.591
has arrived. So just as we'd run
00:08:17.801
out of packets to send, just as
00:08:20.011
we've sent our six packets which are
00:08:22.221
allowed by the window, the acknowledgement arrives,
00:08:24.431
slides the window a long one,
00:08:26.325
tells us we can now send one
00:08:28.535
more.
00:08:28.951
And the idea is that you size
00:08:31.162
the window such that you send just
00:08:33.374
enough packets that by the time the
00:08:35.585
acknowledgement comes back, you're ready to slide
00:08:37.796
the window along. You've sent everything that
00:08:40.007
was in your window.
00:08:41.371
And each acknowledgement releases the next packet
00:08:44.346
for transmission, if you get the window
00:08:47.321
sized right.
00:08:48.271
And if there's a problem, if the
00:08:50.576
acknowledgments don't come back because something got
00:08:52.882
lost,
00:08:53.311
then it stalls. You hadn't sent too
00:08:56.143
many excess packets, you're not just keeping
00:08:58.975
sending without getting acknowledgments, you're just sending
00:09:01.806
enough
00:09:02.311
that the acknowledgments come back, just as
00:09:04.718
you run out of things to send.
00:09:07.125
And everything just keeps it sort-of balanced.
00:09:09.531
Every acknowledgement triggers the next packet to
00:09:11.938
be sent, and it rolls along.
00:09:14.101
How big should the window be? Well,
00:09:16.088
it should be sized to match the
00:09:18.074
bandwidth times the delay on the path.
00:09:20.161
And you work it out in bytes.
00:09:22.544
It's the bandwidth of the path,
00:09:24.587
a gigabit in the previous example,
00:09:26.630
times the latency,
00:09:27.751
100th of a second, and you multiply
00:09:29.822
those together and that tells you how
00:09:31.892
many bytes can be in flight.
00:09:33.667
And you divide that by the packet
00:09:35.737
size, and that tells you how many
00:09:37.808
packets you can send.
00:09:39.091
The problem is, the sender doesn't know
00:09:41.751
the bandwidth of the path, and it
00:09:44.411
doesn't know that latency. It doesn't know
00:09:47.071
the round trip time.
00:09:48.691
It can measure the round trip time,
00:09:50.618
but not until after it started sending.
00:09:52.545
Once it’s sent a packet, it can
00:09:54.472
wait for an acknowledgement to come back
00:09:56.400
and get an estimate of the round
00:09:58.327
trip time. But it can't do that
00:10:00.254
at the point where it starts sending.
00:10:02.281
And it can't know what is the
00:10:04.016
bandwidth. It knows the password for the
00:10:05.751
link it's connected to, but it doesn't
00:10:07.486
know the bandwidth for the rest of
00:10:09.222
the links throughout the network.
00:10:10.561
It doesn't know how many other TCP
00:10:12.742
flows it’s sharing the traffic with,
00:10:14.612
so it doesn't know how much of
00:10:16.793
that capacity it's got available.
00:10:18.451
And that this is the problem with
00:10:21.235
the sliding window algorithms. If you get
00:10:24.020
the window size right,
00:10:25.711
It allows you to do the ACK
00:10:27.466
clocking, it allows you to clock out
00:10:29.220
the packets at the right time,
00:10:30.724
just in time for the next packet
00:10:32.479
to become available.
00:10:33.331
But, in order to pick the right
00:10:34.726
window size, you need to know the
00:10:36.122
bandwidth and the delay, and you don't
00:10:37.517
know either of those at the start
00:10:38.913
of the connection.
00:10:43.711
TCP follows the sliding window approach.
00:10:46.935
TCP Reno is very much a sliding
00:10:50.696
window protocol, and it's optimised for not
00:10:54.457
knowing what the window sizes are.
00:10:57.781
And the challenge with TCP is to
00:11:00.011
pick what should be the initial window.
00:11:02.241
To pick how many packets you should
00:11:04.471
send, before you know anything about the
00:11:06.701
round trip time, or anything about bandwidth.
00:11:09.031
And how to find the path capacity,
00:11:11.424
how to figure out at what point
00:11:13.817
you've got the right size window.
00:11:15.868
And then how to adapt the window
00:11:18.361
to cope with changes in the capacity.
00:11:22.891
So there's two fundamental problems with TCP
00:11:26.778
Reno congestion control. Picking the initial window
00:11:30.666
size
00:11:31.321
for the first set of packets you
00:11:33.859
send.
00:11:34.321
And then, adapting that initial window size
00:11:36.828
to find the bottleneck capacity, and to
00:11:39.334
adapt to changes in that bottleneck capacity.
00:11:41.941
If you get the window size right,
00:11:43.978
you can make effective use of the
00:11:46.015
network capacity. If you get it wrong
00:11:48.052
you’ll either send too slowly, and end
00:11:50.089
up wasting capacity. Or you'll send too
00:11:52.126
quickly, and overload the network, and cause
00:11:54.163
packets to be lost because the queues
00:11:56.200
fill.
00:12:01.081
So, how does TCP find the initial
00:12:04.695
window?
00:12:05.311
Well, to start with, you have no
00:12:07.373
information. When you're making a TCP connection
00:12:09.434
to a host you haven't communicated with
00:12:11.496
before, you don't know the round trip
00:12:13.557
time to that host, you don’t know
00:12:15.619
how long it will take to get
00:12:17.680
a response, and you don't know the
00:12:19.742
network capacity.
00:12:20.431
So you have no information to know
00:12:23.891
what an appropriately sized window should be.
00:12:27.451
The only safe thing you can do.
00:12:29.667
The only thing which is safe in
00:12:31.883
all circumstances, is to send one packet,
00:12:34.099
and see if it arrives, see if
00:12:36.315
you get an ACK.
00:12:37.681
And if it works, send a little
00:12:40.195
bit faster next time.
00:12:41.731
And then gradually increase the rate at
00:12:44.202
which you send.
00:12:45.361
Right, the only safe thing to do
00:12:48.036
is to start at the lowest possible
00:12:50.712
rate, equivalent of stop-and-wait, and then gradually
00:12:53.387
increase your rate from there, once you
00:12:56.062
know that it works.
00:12:57.691
The problem is, of course, that's pessimistic,
00:13:00.162
in most cases.
00:13:01.321
Most links are not the slowest possible
00:13:04.467
link. Most links, you can send faster
00:13:07.612
than that.
00:13:08.611
What TCP has traditionally done, and the
00:13:11.638
traditional approach in TCP Reno, is declared
00:13:14.664
the initial window to be three packets.
00:13:17.791
So you can send three packets,
00:13:20.289
without getting any acknowledgments back.
00:13:22.471
And, by the time the third packet
00:13:24.548
has been sent, you should be just
00:13:26.624
about to get the acknowledgement back,
00:13:28.404
which will open it up for you
00:13:30.481
to send the fourth. And at that
00:13:32.558
point, it starts ACK clocking.
00:13:34.141
And why is it three packets? Because
00:13:37.373
someone did some measurements, and decided that
00:13:40.606
was what safe.
00:13:42.091
More recently, I guess, about 10 years
00:13:45.348
ago now, Nandita Dukkipati and her group
00:13:48.604
at Google did another set of measurements,
00:13:51.961
and showed that was actually pessimistic.
00:13:54.394
The networks had gotten a lot faster
00:13:57.232
in the time since TCP was first
00:14:00.070
standardised, and they came to the conclusion,
00:14:02.908
based on the measurements of browsers accessing
00:14:05.746
the Google site, that about 10 packets
00:14:08.584
was a good starting point.
00:14:10.711
And the idea here is that 10
00:14:13.124
packets, you can send 10 packets at
00:14:15.537
the start of a connection, and after
00:14:17.949
you’ve sent 10 packets you should have
00:14:20.362
got an acknowledgement back.
00:14:21.841
Why ten?
00:14:23.851
Again, it's a balance between safety and
00:14:26.504
performance. If you send too many packets
00:14:29.156
onto a network which can't cope with
00:14:31.809
them, those packets will get queued up
00:14:34.561
and, in the best case, it’ll just
00:14:36.795
add latency because they're all queued up
00:14:39.029
somewhere. And in the worst case they'll
00:14:41.262
overflow the queues, and cause packet loss,
00:14:43.496
and you'll have to re-transmit them.
00:14:45.511
So you don't want to send too
00:14:47.748
fast. Equally, you don't want to send
00:14:49.984
too slow, because that just wastes capacity.
00:14:52.321
And the measurements that Google came up
00:14:55.331
with
00:14:55.861
at this point, which was around 10
00:14:58.149
years ago, was that about 10 packets
00:15:00.436
was a good starting point for most
00:15:02.724
connections.
00:15:03.151
It was unlikely to cause congestion in
00:15:06.262
most cases, and was also unlikely to
00:15:09.373
waste too much bandwidth.
00:15:11.251
And I think what we'd expect to
00:15:13.240
see, is that over time the initial
00:15:15.228
window will gradually increase, as network connections
00:15:17.217
around the world gradually get faster.
00:15:19.021
And it's balancing making good use of
00:15:22.773
connections in well-connected
00:15:24.481
first-world parts of the world, where there’s
00:15:29.233
good infrastructure,
00:15:30.691
against not overloading connections in parts of
00:15:32.948
the world where the infrastructure at less
00:15:35.206
well developed.
00:15:39.811
The initial window lets you send something.
00:15:43.056
With a modern TCP, it lets you
00:15:46.300
send 10 packets.
00:15:47.791
And you can send those 10 packets,
00:15:50.158
or whatever the initial window is,
00:15:52.186
without waiting for an acknowledgement to come
00:15:54.553
back.
00:15:54.991
But it's probably not the right size;
00:15:57.716
it’s probably not the right window size.
00:16:00.541
If you're on a very fast connection,
00:16:02.734
in a well-connected part of the world,
00:16:04.928
you probably want a much bigger window
00:16:07.121
than 10 packets.
00:16:08.161
And if you're on a poor quality
00:16:10.483
mobile connection, or in a part of
00:16:12.805
the world where the infrastructure is less
00:16:15.127
well developed, you probably want a smaller
00:16:17.449
window.
00:16:17.881
So you need to somehow adapt the
00:16:20.622
window to match the network capacity.
00:16:23.071
And there's two parts to this.
00:16:25.714
What's called slow start, where you try
00:16:28.798
to quickly find the appropriate initial window,
00:16:31.981
where starting from initial window, you quickly
00:16:34.256
convert on what the right window is.
00:16:36.631
And congestion avoidance, where you adapt in
00:16:38.836
the long term to match changes in
00:16:41.041
capacity once the thing is running.
00:16:46.741
So how does slow start work? Well,
00:16:48.911
this is the phase at the beginning
00:16:51.081
of the connection.
00:16:52.111
It's easiest to illustrate if you assume
00:16:54.536
that the initial window is one packet.
00:16:57.061
If the initial window is one packet,
00:16:59.599
you send one packet, and at some
00:17:02.136
point later an acknowledgement comes back.
00:17:04.411
And the way slow start works is
00:17:07.055
that each acknowledgment you get back
00:17:09.421
increases the window by one.
00:17:13.321
So if you send one packet,
00:17:15.280
and get one packet back, that increases
00:17:17.565
the window from one to two,
00:17:19.523
so you can send two packets the
00:17:21.808
next time.
00:17:22.561
And you send those two packets,
00:17:24.511
and you get two acknowledgments back.
00:17:26.461
And each acknowledgments increases the window by
00:17:28.736
one, so it goes to three,
00:17:30.686
and then to four. So you can
00:17:32.961
send four packets the next time.
00:17:35.011
And then you get four acknowledgments back,
00:17:37.494
each of which increases the window,
00:17:39.623
so your window is now eight.
00:17:41.851
And, as we are all, I think,
00:17:45.089
painfully aware after the pandemic, this is
00:17:48.326
exponential growth.
00:17:49.351
The window is doubling each time.
00:17:51.506
So it's called slow start because it
00:17:54.020
starts very slow, with one packet or
00:17:56.534
three packets or 10 packets, depending on
00:17:59.048
the version of TCP you have.
00:18:01.203
But each round trip time the window
00:18:03.718
doubles. It doubles it's sending rate each
00:18:06.232
time.
00:18:06.691
And this carries on until it loses
00:18:09.233
a packet. This carries on until it
00:18:11.776
fills the queues and overflows the capacity
00:18:14.318
of the network somewhere.
00:18:15.871
At which points it halves back to
00:18:17.458
its previous value, and drops out of
00:18:19.044
the slow start phase.
00:18:23.131
If we look at this graphically,
00:18:24.939
what we see on the graph at
00:18:27.048
the bottom of the slide, we have
00:18:29.157
time on the X axis, and the
00:18:31.266
congestion window, the size of the congestion
00:18:33.375
window, on the y axis.
00:18:34.981
And we're assuming an initial window of
00:18:37.253
one packet. We see that, on the
00:18:39.524
first round trip it sends the one
00:18:41.796
packet, gets the acknowledgement back. The second
00:18:44.067
round trip it sends two packets.
00:18:46.014
And then four, and then eight,
00:18:47.961
and then 16. And each time it
00:18:50.233
doubles it's sending rate.
00:18:51.631
So you have this exponential growth phase,
00:18:54.279
starting at whatever the initial window is,
00:18:56.928
and doubling each time until it reaches
00:18:59.576
that network capacity.
00:19:00.811
And eventually it fills the network.
00:19:03.117
Eventually some queue, somewhere in the network,
00:19:05.808
is full. And it overflows and the
00:19:08.498
packet gets lost.
00:19:09.751
At that point the connection halves it’s
00:19:12.060
rate, back to the value just before
00:19:14.368
it last increased. In this example,
00:19:16.347
we see that it got up to
00:19:18.655
an initial window of 16, and then
00:19:20.964
something got lost, and then it halved
00:19:23.272
back down to a window of eight.
00:19:25.681
At that point TCP enters what's known
00:19:27.571
as the congestion avoidance phase.
00:19:32.881
The goal of congestion avoidance is to
00:19:37.355
adapt to changes in capacity.
00:19:40.651
After the slow start phase, you know
00:19:42.893
you've got approximately the right size window
00:19:45.134
for the path. It's telling you roughly
00:19:47.376
how many packets you should be sending
00:19:49.617
each round trip time. The goal,
00:19:51.539
once you’re in congestion avoidance, is to
00:19:53.780
adapt to changes.
00:19:54.841
Maybe the capacity of the path changes.
00:19:57.871
Maybe you're on a mobile device,
00:20:00.467
with a wireless connection, and the quality
00:20:03.497
of the wireless connection changes.
00:20:05.761
Maybe the amount of cross traffic changes.
00:20:08.249
Maybe additional people start sharing the link
00:20:10.736
with you, and you have less capacity
00:20:13.224
because you’re sharing with more TCP flows.
00:20:15.811
On maybe some of the cross traffic
00:20:18.264
goes away, and the amount of capacity
00:20:20.717
you have available increases because there's less
00:20:23.170
competing traffic.
00:20:23.971
And the congestion avoidance phase follows an
00:20:26.669
additive increase, multiplicative decrease, approach to adapting
00:20:29.368
the congestion window when that happens.
00:20:34.411
So, in congestion avoidance,
00:20:37.531
if it successfully manages to send a
00:20:40.258
complete window of packets, and gets acknowledgments
00:20:42.985
back for each of those packets.
00:20:45.323
So it send out
00:20:46.981
eight packets, for example, and gets eight
00:20:50.613
acknowledgments back,
00:20:51.751
it knows the network can support that
00:20:54.497
sending rate.
00:20:55.381
So it increases its window by one.
00:20:58.351
So the next time, it sends out
00:21:01.213
nine packets
00:21:02.131
and expects to get nine acknowledgments back
00:21:05.082
over the next round trip cycle.
00:21:07.711
And if it successfully does that,
00:21:09.964
it increases the window again.
00:21:11.941
And it says 10 packets, and expects
00:21:14.910
to get 10 acknowledgments back.
00:21:17.131
And we see that each round trip
00:21:19.991
it gradually increases the sending rate by
00:21:22.851
one. So it sends 8 packets,
00:21:25.302
then 9, then 10, then 11,
00:21:27.754
and 12, and keeps gradually, linearly,
00:21:30.205
increasing its rate.
00:21:31.531
Up until the point that something gets
00:21:33.885
lost.
00:21:36.961
And if a packet gets lost?
00:21:39.871
You’ll be able to detect that because,
00:21:42.307
as we saw in the previous lecture,
00:21:44.744
you've got a triple duplicates acknowledgement.
00:21:46.832
And that indicates that one of the
00:21:49.268
packets got lost, but the rest of
00:21:51.705
the data in the window was received.
00:21:54.241
And what you do at that point,
00:21:56.862
is you do a multiplicative decrease in
00:21:59.484
the window. You halve the window.
00:22:01.831
So, in this case, the sender was
00:22:04.520
sending with a window of
00:22:06.541
12 packets, and it successfully sent that.
00:22:10.332
And then it tried to send,
00:22:13.681
tried to increase its rate, realised it
00:22:16.518
didn't work, realised something got lost,
00:22:18.949
and so it halved its window back
00:22:21.785
down to six.
00:22:23.101
And then it gradually switches back,
00:22:25.205
it switches back, and goes back to
00:22:27.659
the gradual additive increase.
00:22:29.161
And it follows this sawtooth pattern.
00:22:31.921
Gradual linear increase, one packet more each
00:22:35.253
round trip time.
00:22:36.781
Until it sends too fast, causes a
00:22:39.493
packet to be lost because it overflows
00:22:42.205
a queue, halves it’s sending rate,
00:22:44.529
and then gradually starts increasing it again.
00:22:47.341
It follows this sawtooth pattern. Gradual increase,
00:22:50.556
quick back-off; gradual increase, quick back-off.
00:22:56.851
The other way TCP can detect the
00:22:59.856
loss is by what’s known as a
00:23:02.861
time out. It’s sending the packets,
00:23:05.437
and suddenly the acknowledgements stop coming back
00:23:08.442
entirely.
00:23:08.971
And this means that either the receiver
00:23:11.734
has crashed, the receiving system has gone
00:23:14.498
away, or perhaps more likely the network
00:23:17.261
has failed.
00:23:18.151
And the data it’s sending is either
00:23:21.184
not reaching the sender, or the reverse
00:23:24.218
path has failed, and the acknowledgments are
00:23:27.251
not coming back.
00:23:28.651
At that point, after nothing has come
00:23:31.661
back for a while,
00:23:33.481
it assumes a timeout has happened,
00:23:36.621
and resets the window down to the
00:23:40.284
initial window.
00:23:41.431
And in the example we see on
00:23:43.851
the slide, at time 14 we've got
00:23:46.271
a timeout, and it resets and the
00:23:48.691
initial window goes back to one packet.
00:23:51.211
At that point, it re-enters slow start.
00:23:53.548
It starts again from the beginning.
00:23:55.551
And whether your initial window is one
00:23:57.888
packet, or three packets, or ten packets,
00:24:00.225
it starts in the beginning, and it
00:24:02.562
re-enters slow start, and it tries again
00:24:04.899
for the connection.
00:24:06.001
And if this was a transient failure,
00:24:08.499
that will probably succeed. If it wasn’t,
00:24:10.997
it may end up in yet another
00:24:13.495
timeout, while it takes time for the
00:24:15.994
network to recover, or
00:24:17.521
for the system you're talking to,
00:24:19.356
to recover, and it will be a
00:24:21.496
while before it can successfully send a
00:24:23.636
packet. But, when it does, when the
00:24:25.776
network recovers, it starts sending again,
00:24:27.611
and resets the connection from the beginning.
00:24:29.851
How long, should the timeout be?
00:24:32.941
Well, the standard says a maximum of
00:24:36.032
one second, or the average round trip
00:24:39.123
time plus four times the statistical variance
00:24:42.213
in the round trip time.
00:24:44.521
And, if you're a statistician, you’ll recognise
00:24:47.334
that the RTT plus four times the
00:24:50.146
variance, if you're assuming a normal distribution
00:24:52.959
of
00:24:53.461
round trip time samples, accounts for 99%
00:24:56.664
of the samples falling within range.
00:24:59.409
So it's finding the 99th percentile of
00:25:02.611
the expected time to get an acknowledgement
00:25:05.814
back.
00:25:11.941
Now, TCP follows this saw tooth behaviour,
00:25:15.074
with gradual additive increase in the sending
00:25:18.207
rate, and then a back-off, halving it’s
00:25:21.340
sending rate, and then a gradual increase
00:25:24.473
again.
00:25:25.021
And we see this in the top
00:25:26.976
graph on the slide which is showing
00:25:28.932
a
00:25:29.311
measured congestion window for a real TCP
00:25:33.082
flow.
00:25:33.721
And, after dynamics of the slow start
00:25:36.620
at the beginning, we see it follows
00:25:39.519
this sawtooth pattern.
00:25:40.861
How does that affect the rest of
00:25:43.723
the network?
00:25:44.641
Well, the packets are, at some point,
00:25:48.338
getting queued up at whatever the bottleneck
00:25:52.035
link is.
00:25:53.191
And the second graph we see on
00:25:55.287
the left, going down, is the size
00:25:57.383
of the queue.
00:25:58.381
And we see that as the sending
00:26:00.956
rate increases, the queue gradually builds up.
00:26:03.631
Initially the queue is empty, and as
00:26:06.777
it starts sending faster, the queue gradually
00:26:09.922
gets fuller.
00:26:10.921
And at some point the queue gets
00:26:15.471
full, and overflows.
00:26:17.521
And when the queue gets full,
00:26:19.640
when the queue overflows, when packets gets
00:26:22.112
lost, TCP halves it’s sending rate.
00:26:24.331
And that causes the queue to rapidly
00:26:26.824
empty, because there's less packets coming in,
00:26:29.317
so the queue drains.
00:26:30.841
But what we see is that just
00:26:33.040
as the queue is getting to empty,
00:26:35.239
the rate is starting to increase again.
00:26:37.439
Just as the queue gets the point
00:26:39.638
where it would have nothing to send,
00:26:41.837
the rate starts picking up, such that
00:26:44.036
the queue starts to gradually refill.
00:26:46.021
So the queues in the routers also
00:26:48.738
follow a sawtooth pattern. They gradually fell
00:26:51.456
up until they get to a full
00:26:54.173
points,
00:26:54.661
And then the rate halves, the queue
00:26:57.807
empties rapidly because there's much less traffic
00:27:00.952
coming back,
00:27:01.951
and as it's emptying the rate at
00:27:04.228
which the sender is sending is gradually
00:27:06.504
filling up, and the queue size oscillates.
00:27:08.881
And we see the same thing happens
00:27:11.283
with the round trip time, in the
00:27:13.686
third of the graphs, as the queue
00:27:16.088
gradually
00:27:16.531
fills up, the round trip time goes
00:27:18.582
up, and up, and up, it's taking
00:27:20.634
longer for the packets because they're queued
00:27:22.685
up somewhere.
00:27:23.371
And then the rate reduces, the queue
00:27:26.260
drops, the round trip time drops.
00:27:28.736
And it gradually, as the rate picks
00:27:31.626
up afterwards
00:27:32.551
back into congestion avoidance, the queue gradually
00:27:35.546
fills, the round trip time gradually increases.
00:27:38.541
So, both window size, and the queue
00:27:41.536
size, and the round trip time,
00:27:44.104
all follow this characteristic sawtooth pattern.
00:27:46.771
What's interesting though, if we look at
00:27:49.296
the fourth graph down on the left,
00:27:51.821
is we're looking at the rate at
00:27:54.346
which packets are arriving at the receiver.
00:27:56.971
And we see that the rate at
00:27:59.207
which packets are arriving at the receiver
00:28:01.443
is pretty much constant.
00:28:02.821
What's happening is that the packets are
00:28:05.279
being queued up at the link,
00:28:07.387
and as the queue fills there's more
00:28:09.845
and more packets queued up
00:28:11.701
at the bottleneck link. And when TCP
00:28:14.787
backs-off, when it reduces it's window,
00:28:17.433
that lets the queue drain. But the
00:28:20.519
queue never quite empties. We just see
00:28:23.606
very occasional drops where the queue gets
00:28:26.692
empty, but typically the queue always has
00:28:29.778
something in it.
00:28:31.201
It's emptying rapidly, it’s getting less and
00:28:34.153
less data in it, but the queue,
00:28:37.105
if the buffer is sized right,
00:28:39.635
if the window is chosen right,
00:28:42.166
never quite empties.
00:28:43.531
So the TCP sender is following this
00:28:46.417
sawtooth pattern, with its sending window,
00:28:48.991
which is gradually filling up the queues.
00:28:51.386
And then the queues are gradually draining
00:28:53.782
when TCP backs-off and halves its rate,
00:28:56.177
but the queue never quite empties.
00:28:58.230
It always has some data to send,
00:29:00.626
so the receiver is always receiving data.
00:29:03.121
So, even though the sender's following the
00:29:05.695
sawtooth pattern, the receiver receives constant rate
00:29:08.270
data the whole time,
00:29:09.841
at approximately the bottleneck bandwidth.
00:29:13.471
And that's the genius of TCP.
00:29:16.519
It manages, by following this additive increase,
00:29:20.076
multiplicative decrease, approach, it manages to adapt
00:29:23.632
the rate such that the buffer never
00:29:27.189
quite empties, and the data continues to
00:29:30.745
be delivered.
00:29:31.861
And for that to work, it needs
00:29:34.437
the router to have enough buffering capacity
00:29:37.013
in it. And the amount of buffering
00:29:39.589
the router needs, is the bandwidth times
00:29:42.165
the delay of the path. And too
00:29:44.741
little buffering in the router
00:29:46.681
leads to
00:29:49.591
the queue overflowing, and it not quite
00:29:52.432
managing to sustain the rate. Too much,
00:29:55.274
you just get what’s known as buffer
00:29:58.115
bloat.
00:29:58.621
It's safe, I mean in terms of
00:30:00.795
throughput, it keeps receiving the data.
00:30:02.658
But the queues get very big,
00:30:04.521
and they never get anywhere near empty,
00:30:06.694
so the amount of data queued up
00:30:08.868
increases, and you just get increased latency.
00:30:14.581
So that's TCP Reno. It's really effective
00:30:17.379
at keeping the bottleneck fully utilised.
00:30:19.777
But it trades latency for throughput.
00:30:22.175
It tries to fill the queue,
00:30:24.573
it's continually pushing, it’s continually queuing up
00:30:27.371
data.
00:30:27.871
Making sure the queue is never empty.
00:30:30.178
Making sure the queue is never empty,
00:30:32.486
so provided there’s enough buffering in the
00:30:34.793
network there are always packets being delivered.
00:30:37.201
And that's great, if your goal is
00:30:39.634
to maximise the rate at which information
00:30:42.068
is delivered. TCP is really good at
00:30:44.501
keeping the bottleneck link fully utilised.
00:30:46.587
It’s really, really good at delivering data
00:30:49.020
as fast as the network can support
00:30:51.453
it.
00:30:51.901
But it trades that off for latency.
00:30:55.343
It's also really good at making sure
00:30:58.786
there are queues in the network,
00:31:01.736
and making sure that the network is
00:31:05.178
not operating at its lowest possible latency.
00:31:08.621
There's always some data queued up.
00:31:11.671
There are two other limitations, other than
00:31:14.814
an increased latency.
00:31:16.261
First, is that TCP assumes that losses
00:31:19.252
are due to congestion.
00:31:21.061
And historically that's been true. Certainly in
00:31:24.466
wired links, packet loss is almost always
00:31:27.871
caused by a queue filling up,
00:31:30.790
overflowing, and a router not having space
00:31:34.195
to enqueue a packet.
00:31:36.241
In certain types of wireless links,
00:31:38.523
in 4G or in WiFi links,
00:31:40.806
that's not always the case, and you
00:31:43.468
do get packet loss due to corruption.
00:31:46.231
And TCP will treat this as a
00:31:49.108
signal to slow down. Which means that
00:31:51.984
TCP sometimes behaves sub-optimally on wireless links.
00:31:54.961
And there's a mechanism called Explicit Congestion
00:31:57.301
Notification, which we'll talk about in one
00:31:59.640
of the later parts of this lecture,
00:32:01.980
which tries to address that.
00:32:03.751
The other, is that the congestion avoidance
00:32:06.267
phase can take a long time to
00:32:08.782
ramp up.
00:32:09.601
On
00:32:12.271
very long distance links, very high capacity
00:32:14.433
links, it can take a long time
00:32:16.595
to get up to, after packet loss,
00:32:18.758
it can take a very long time
00:32:20.920
to get back up to an appropriate
00:32:23.082
rate.
00:32:23.491
And there are some occasions with very
00:32:26.163
fast long distance links, where it performs
00:32:28.835
poorly, because of the way the congestion
00:32:31.508
avoidance works.
00:32:32.371
And there's an algorithm known as TCP
00:32:34.011
Cubic, which i'll talk about in the
00:32:35.651
next part, which tries to address that.
00:32:39.961
And that's the basics of TCP.
00:32:42.434
The basic TCP congestion control algorithm is
00:32:45.319
a sliding window algorithm, where the window
00:32:48.205
indicates how many packets you’re allowed to
00:32:51.090
send before getting an acknowledgement.
00:32:53.251
The goal of the slow start and
00:32:55.797
the congestion avoidance phases, and the additive
00:32:58.342
increase, multiplicative decrease, is to adapt the
00:33:00.888
size of the window to match the
00:33:03.434
network capacity.
00:33:04.261
It always tries to match the size
00:33:07.163
of the window exactly to the capacity,
00:33:10.065
so it's making the most use of
00:33:12.967
the network resources.
00:33:14.311
In the next part, I’ll move on
00:33:16.922
and talk about an extension to the
00:33:19.532
TCP Reno algorithm, known as TCP Cubic,
00:33:22.143
which is intended to improve performance on
00:33:24.753
very fast and long distance networks.
00:33:27.091
And then, in the later parts,
00:33:29.594
we'll talk about extensions to reduce latency,
00:33:32.513
and to work on wireless links where
00:33:35.433
there are non-congestive losses.
Part 3: TCP Cubic
The third part of the lecture talks about the TCP Cubic congestion
control algorithm, a widely used extension to TCP that improves its
performance on fast, long-distance, networks. The lecture discusses
the limitations of TCP Reno that led to the development of Cubic,
and outlines how Cubic congestion control improves performance but
retains fairness with Reno.
00:00:00.000
In the previous part, I spoke about
00:00:02.512
TCP Reno.
00:00:03.330
TCP Reno is the default congestion control
00:00:06.177
algorithms for TCP, but it's actually not
00:00:09.023
particularly widely used in practice these days.
00:00:11.970
What most modern TCP versions use is,
00:00:14.875
instead, an algorithm known as TCP Cubic.
00:00:17.880
And the goal of TCP cubic is
00:00:20.387
to improve TCP performance on fast long
00:00:22.894
distance networks.
00:00:25.380
So the problem with TCP Reno,
00:00:27.771
is that it’s performance can be comparatively
00:00:30.560
poor on networks with large bandwidth-delay products.
00:00:33.450
That is, networks where the product,
00:00:35.449
what you get when you multiply the
00:00:37.781
bandwidth of the network, in number of
00:00:40.113
bits per second, and the delay,
00:00:42.112
the round trip time of the network,
00:00:44.444
is large.
00:00:45.210
Now, this is not a problem that
00:00:48.057
most people, have most of the time.
00:00:50.904
But, it's a problem that began to
00:00:53.752
become apparent in the early 2000s when
00:00:56.599
people working at organisations like CERN were
00:00:59.446
trying to transfer very large data files
00:01:02.293
across fast long distance
00:01:04.020
networks between CERN and the universities that
00:01:08.137
were analysing the data.
00:01:10.590
For example, CERN is based at Geneva,
00:01:13.575
in Switzerland, and some of the big
00:01:16.560
sites for analysing the data are based
00:01:19.545
at, for example, Fermilab just outside Chicago
00:01:22.531
in the US.
00:01:23.910
And in order to get the data
00:01:27.945
from CERN to Fermilab, from Geneva to
00:01:31.979
Chicago, they put in place multi-gigabit transatlantic
00:01:36.014
links.
00:01:36.690
And if you
00:01:39.030
think about the congestion window needed to
00:01:41.585
make good use of a link like
00:01:44.140
that, you realise it actually becomes quite
00:01:46.695
large.
00:01:47.160
If you assume the link is 10
00:01:49.808
gigabit per second, which was cutting edge
00:01:52.456
in the early 2000s, but it is
00:01:55.104
now relatively common for high-end links these
00:01:57.752
days,
00:01:58.230
and assume 100 milliseconds round trip time,
00:02:01.587
which is possibly even slightly an under-estimate
00:02:04.943
for the path from Geneva to Chicago,
00:02:08.400
and in order to make good use
00:02:11.167
of that, you need a congestion window
00:02:13.934
which equals the bandwidth times the delay.
00:02:16.701
And 10 gigabits per second, times 100
00:02:19.467
milliseconds, gives you a congestion window of
00:02:22.234
about 100,000 packets.
00:02:23.520
And, partly, it takes TCP a long
00:02:26.817
time, a comparatively long time, to slow
00:02:30.113
start up to a 100,000 packet window.
00:02:33.510
But that's not such a big issue,
00:02:35.792
because that only happens once at the
00:02:38.074
start of the connection. The issue,
00:02:40.030
though, is in congestion avoidance.
00:02:41.760
If one packet is lost on the
00:02:44.510
link, out of a window of 100,000,
00:02:47.261
that will cause TCP to back-off and
00:02:50.011
halve it’s window. And it then increases
00:02:52.761
sending rate again, by one packet every
00:02:55.511
round trip time.
00:02:56.790
And backing off from 100,000 packet window
00:02:59.444
to a 50,000 packet window, and then
00:03:02.098
increasing by one each time, means it
00:03:04.751
takes 50,000 round trip times to recover
00:03:07.405
back up to the full window.
00:03:09.780
50,000 round trip times, when the round
00:03:12.926
trip time is 100 milliseconds, is about
00:03:16.071
1.4 hours.
00:03:17.070
So it takes TCP about one-and-a-half hours
00:03:20.380
to recover from a single packet loss.
00:03:23.790
And, with a window of 100,000 packets,
00:03:27.119
you're sending enough data, at 10 gigabits
00:03:30.449
per second,
00:03:31.500
that the imperfections in the optical fibre,
00:03:34.414
and imperfections in the equipment that are
00:03:37.328
transmitting the packets, become significant.
00:03:39.510
And you're likely to just see occasional
00:03:42.100
random packet losses, just because of imperfections
00:03:44.690
in the transmission medium, even if there's
00:03:47.280
no congestion. And this was becoming a
00:03:49.870
limiting factor, this was becoming a bottleneck
00:03:52.460
in the transmission.
00:03:53.670
It was becoming not possible to build
00:03:56.390
a network that was reliable enough,
00:03:58.722
that it never lost any packets in
00:04:01.442
transferring several hundreds of billions of packets
00:04:04.163
of data,
00:04:05.040
to exchange the data between CERN and
00:04:09.535
the sites which were doing the analysis.
00:04:14.130
TCP cubic is one of a range
00:04:16.462
of algorithms which were developed to try
00:04:18.795
and address this problem. To try and
00:04:21.127
recover much faster than TCP Reno would,
00:04:23.459
in the case when you had very
00:04:25.791
large congestion windows, and small amounts of
00:04:28.124
packet loss.
00:04:31.560
So the idea of TCP cubic,
00:04:34.189
is that it changes the way the
00:04:37.255
congestion control works in the congestion avoidance
00:04:40.322
phase.
00:04:40.860
So, in congestion avoidance, TCP cubic will
00:04:44.792
increase the congestion window faster than TCP
00:04:48.724
Reno would, in cases where the window
00:04:52.657
is large.
00:04:53.880
In cases where the window is relatively
00:04:56.704
small, in the types of networks were
00:04:59.528
Reno has good performance, TCP cubic behaves
00:05:02.353
in a very similar way.
00:05:04.470
But as the windows get bigger,
00:05:06.989
as it gets to a regime with
00:05:09.927
TCP Reno doesn't work effectively, TCP cubic
00:05:12.865
gets more aggressive in adapting its congestion
00:05:15.803
window, and increases the congestion window much
00:05:18.741
more quickly in response to loss.
00:05:21.360
However, as the rate of increase,
00:05:25.290
as the window approaches the value it
00:05:27.885
was before the loss, it slows its
00:05:30.480
rate of increase, so it starts increasing
00:05:33.076
rapidly, slows its rate of increase
00:05:35.400
as it approaches the previous value.
00:05:38.295
And if it then successfully manages to
00:05:41.672
send at that rate, if it successfully
00:05:45.048
moves above the previous sending rate,
00:05:47.943
then it gradually increases sending rate again.
00:05:51.420
It’s called TCP Cubic because it follows
00:05:54.043
a cubic equation to do this.
00:05:56.291
The shape of the equation, the shape
00:05:58.914
of the curve, we see on the
00:06:01.537
slide for TCP cubic is following a
00:06:04.161
cubic graph.
00:06:05.010
The paper listed on the slide,
00:06:07.448
the paper shown on the slide,
00:06:09.886
from Injong Rhee and his collaborators,
00:06:12.323
is the paper which describes the algorithm
00:06:15.167
in detail.
00:06:16.080
And it was eventually specified in IETF’s
00:06:19.088
RFC 8312 in 2018, although it's been
00:06:22.095
probably the most widely used TCP variant
00:06:25.103
for a number of years before that.
00:06:30.660
The details of how it works:
00:06:33.525
TCP cubic is a somewhat more complex
00:06:36.868
algorithm than Reno.
00:06:38.400
The two parts to the behaviour.
00:06:41.730
If a packet is lost when a
00:06:44.731
TCP cubic sender is in the congestion
00:06:47.732
avoidance phase,
00:06:48.690
it does a multiplicative decrease.
00:06:51.630
However, unlike TCP Reno, which does a
00:06:54.626
multiplicative decrease by multiplying by a factor
00:06:57.621
of 0.5, that is, it halves its
00:07:00.617
sending rate if a single packets is
00:07:03.612
lost,
00:07:04.140
TCP cubic multiples it's rate by 0.7.
00:07:08.670
So, instead of dropping back down to
00:07:11.215
50% of its previous sending rate,
00:07:13.397
it drops down to 70% of the
00:07:15.943
sending rate.
00:07:16.770
It backs-off less, it's more aggressive.
00:07:20.238
It’s more aggressive at using bandwidth.
00:07:23.706
It reduces it’s sending rate in response
00:07:27.752
to loss, but by smaller fraction.
00:07:31.320
After it's backed-off, TCP cubic also changes
00:07:34.861
the way in which increases it’s sending
00:07:38.402
rate in future.
00:07:40.020
So we saw in the previous slide,
00:07:42.940
TCP Reno increases it’s congestion window by
00:07:45.859
one, for every round trip when it
00:07:48.779
successfully sends data.
00:07:50.130
So if the window backs off to
00:07:52.510
10, then it goes to 11 the
00:07:54.890
next round trip time, then 12,
00:07:56.930
and 13, and so on, with a
00:07:59.310
linear increase in the window.
00:08:01.110
TCP cubic, on the other hand,
00:08:04.028
sets the window as we see in
00:08:07.431
the equation on the slide. It sets
00:08:10.835
the window to be a constant,
00:08:13.753
C, times T-K cubed, plus Wmax.
00:08:16.770
Where the constant, C, is set to
00:08:19.783
0.4, which is a threshold which controls
00:08:22.796
how fair it is to TCP Reno,
00:08:25.808
and was determined experimentally.
00:08:27.630
T is the time since the packet
00:08:29.920
loss. K is the time it will
00:08:32.209
increase, it will take to increase the
00:08:34.499
window backup to
00:08:35.580
the maximum it was before the packet
00:08:38.727
loss, and Wmax is the maximum window
00:08:41.873
size it reached before the loss.
00:08:44.670
And this gives the cubic growth function,
00:08:47.132
which we saw on the previous slide,
00:08:49.593
where the window starts to increase quickly,
00:08:52.055
the growth slows as it approaches that
00:08:54.517
previous value
00:08:55.320
it reached just before the loss,
00:08:57.747
and if it successfully passes through that
00:09:00.579
point, the rate of growth increases again.
00:09:03.510
Now, that's the high-level version. And we
00:09:06.669
can already see it's more complex than
00:09:09.828
the TCP Reno equation. The algorithm on
00:09:12.988
the right of the slide, which is
00:09:16.147
intentionally presented in a way which is
00:09:19.306
completely unreadable here,
00:09:20.760
shows the full details. The point is
00:09:23.755
that there's a lot of complexity here.
00:09:26.850
The basic equation, the basic back-off to
00:09:29.799
0.7 times and then follow the cubic
00:09:32.749
equation, to increase rapidly, slow the rate
00:09:35.698
of increase, and then increase rapidly again
00:09:38.648
if it successfully gets past the previous
00:09:41.597
bottleneck point,
00:09:42.540
is enough to illustrate the key principle.
00:09:45.004
The rest of the details are there
00:09:47.468
to make sure it's fair with TCP
00:09:49.932
Reno on links which are slower,
00:09:52.044
or where the round trip time is
00:09:54.508
shorter.
00:09:54.960
And so, in the regime where TCP
00:09:57.397
Reno can successfully make use of the
00:09:59.833
link, TCP Cubic behaves the same way.
00:10:02.370
And, as you get into a regime
00:10:04.534
where Reno can't effectively make use of
00:10:06.699
the capacity, because it can't sustain a
00:10:08.863
large enough congestion window,
00:10:10.200
then cubic starts to behave differently,
00:10:12.425
and starts to switch to the cubic
00:10:15.020
equation. And that allows it to recover
00:10:17.615
from losses more quickly, and to more
00:10:20.211
effectively continue to make use of higher
00:10:22.806
bandwidths and higher latency paths.
00:10:28.770
TCP cubic is the default in most
00:10:32.606
modern operating systems. It’s the default in
00:10:36.441
Linux, it's the default in FreeBSD,
00:10:39.729
I believe it's the default in macOS
00:10:43.564
and iPhones.
00:10:44.760
Microsoft Windows has an algorithm called Compound
00:10:48.104
TCP which is a different algorithm,
00:10:50.971
but has a similar effect.
00:10:53.460
It’s much more complex than TCP Reno.
00:10:56.485
The core response, the back off to
00:10:59.510
70% and then follow the characteristic cubic
00:11:02.536
curve, is conceptually relatively straightforward, but once
00:11:05.561
you start looking at the details of
00:11:08.586
how it behaves, there gets to be
00:11:11.611
a lot of complexity.
00:11:13.440
And most of that is in there
00:11:16.685
to make sure it's reasonably fair to
00:11:19.930
TCP, to TCP Reno, in the regime
00:11:23.175
where Reno typically works. But it improves
00:11:26.421
performance for networks with longer round trip
00:11:29.666
times and higher bandwidths.
00:11:31.620
Both TCP Cubic, and TCP Reno,
00:11:34.648
use congestion control, use packet loss as
00:11:38.180
a congestion signal. And they both eventually
00:11:41.712
filled the router buffers.
00:11:43.830
And TCP cubic does so more aggressively
00:11:46.440
than Reno. Som in both cases,
00:11:48.678
they're trading off latency for throughput,
00:11:50.916
They're trying to make sure the buffers
00:11:53.526
are full. They're trying to make sure
00:11:56.137
the buffers in the intermediate routers are
00:11:58.747
full.
00:11:59.220
And they're both making sure that they
00:12:01.955
keep the congestion window large enough to
00:12:04.690
keep the buffers fully utilised, so packets
00:12:07.424
keep arriving at the receiver at all
00:12:10.159
times.
00:12:10.650
And that's very good for achieving high
00:12:13.582
throughput, but it pushes the latency up.
00:12:16.514
So, again, they’re trading-off increased latency for
00:12:19.446
good performance, for good throughput.
00:12:24.720
And that's what I want to say
00:12:27.320
about Cubic. Again, the goal is to
00:12:29.920
use a different response function to improve
00:12:32.520
throughput on very fast, long distance,
00:12:34.749
links,
00:12:35.220
multi-gigabit per second transatlantic links, being the
00:12:40.742
common example.
00:12:42.420
And the goal is to make good
00:12:45.584
use of throughput.
00:12:47.040
In the next part I’ll talk about
00:12:50.424
alternatives which, rather than focusing on throughput,
00:12:53.809
focus on keeping latency bounded whilst achieving
00:12:57.193
reasonable throughput.
Part 4: Delay-based Congestion Control
The 4th part of the lecture discussed how both the Reno and Cubic
algorithms impact latency. It shows how their loss-based response
to congestion inevitably causes router queues to fill, increasing
path latency, and discusses how this is unavoidable with loss-based
congestion control. It introduces the idea of delay-based congestion
control and the TCP Vegas algorithm, highlights its potential benefits
and deployment challenges. Finally, TCP BBR is briefly introduced as
an experimental extension that aims to achieve some of the benefits
of delay-based congestion control, in a deployable manner.
00:00:00.000
In the previous parts, I’ve spoken about
00:00:02.986
TCP Reno and TCP cubic. These are
00:00:05.971
the standard, loss based, congestion control algorithms
00:00:08.957
that most TCP implementations use to adapt
00:00:11.942
their sending rate. These are the standard
00:00:14.928
congestion control algorithms for TCP.
00:00:17.160
What I want to do in this
00:00:20.211
part is recap, why these algorithms cause
00:00:23.263
additional latency in the network, and talk
00:00:26.314
about two alternatives which try to adapt
00:00:29.365
the sending rate of TCP without building
00:00:32.416
up queues, and without
00:00:34.260
overloading the network and causing too much
00:00:36.544
latency.
00:00:40.050
So, as I mentioned, TCP Cubic and
00:00:42.618
TCP Reno both aim to fill up
00:00:45.186
the network.
00:00:46.020
They use packet loss as a congestion
00:00:49.266
signal.
00:00:49.830
So the way they work is they
00:00:52.727
gradually increase their sending rate, they’re in
00:00:55.625
either slow start or congestion avoidance phase,
00:00:58.522
and they’re always gradually increasing the sending
00:01:01.419
rates, gradually filling up the queues in
00:01:04.317
the network, until those queues overflow.
00:01:06.900
At that point a packet is lost.
00:01:09.810
The TCP backs-off it's sending rate,
00:01:12.327
it backs-off its window, which allows the
00:01:15.264
queue to drain, but as the queue
00:01:18.201
is draining, both
00:01:19.560
Reno and Cubic are increasing their sending
00:01:22.269
rate, are increasing the sending window,
00:01:24.590
so are to gradually start filling up
00:01:27.299
the queue again.
00:01:28.560
As, we saw, the queues in the
00:01:31.410
network oscillate, but they never quite empty.
00:01:34.260
And both Reno and Cubic, the goal
00:01:37.109
is to keep some packets queued up
00:01:39.959
in the network, make sure there's always
00:01:42.809
some data queued up, so they can
00:01:45.659
keep delivering data.
00:01:46.980
And, no matter how big a queue
00:01:49.654
you put in the network, no matter
00:01:52.328
how much memory you give the routers
00:01:55.002
in the network, TCP Reno and TCP
00:01:57.676
cubic will eventually cause it to overflow.
00:02:00.450
They will keep sending, they'll keep increasing
00:02:03.406
the sending rate, until whatever queue is
00:02:06.362
in the network it's full, and it
00:02:09.318
overflows.
00:02:09.840
And the more memory in the routers,
00:02:12.018
the more buffer in the routers,
00:02:13.885
the longer that queue will get and
00:02:16.063
the worse the latency will be.
00:02:18.030
But in all cases, in order to
00:02:20.778
achieve very high throughput, in order to
00:02:23.525
keep the network busy, keep the bottleneck
00:02:26.273
link busy, TCP Reno and TCP cubic
00:02:29.020
queue some data up.
00:02:30.690
And this adds latency.
00:02:33.660
It means that, whenever there’s TCP Reno,
00:02:37.341
whenever there’s TCP cubic flows, using the
00:02:41.023
network, the queues will have data queued
00:02:44.704
up.
00:02:45.330
There’ll always be data queued up for
00:02:48.137
delivery. There's always packets waiting for delivery.
00:02:50.944
So it forces the network to work
00:02:53.751
in a regime where there's always some
00:02:56.558
excess latency.
00:03:00.960
Now, this is a problem for real-time
00:03:04.092
applications. It’s a problem if you're running
00:03:07.224
a video conferencing tool, or a telephone
00:03:10.356
application, or a game, or a real
00:03:13.488
time control application, because you want low
00:03:16.620
latency for those applications.
00:03:18.510
So it will be desirable if we
00:03:21.179
could have a an alternative to TCP
00:03:23.847
Reno or TCP cubic that can achieve
00:03:26.516
good throughput for TCP, without forcing the
00:03:29.185
queues to be full.
00:03:30.810
One attempt at doing this was a
00:03:34.717
proposal called TCP Vegas.
00:03:37.050
And the insight from TCP Vegas is
00:03:41.478
that
00:03:42.210
you can watch the rate of growth,
00:03:45.035
or increase, of the queue, and use
00:03:47.860
that to infer whether you're sending faster,
00:03:50.685
or slower, than the network can support.
00:03:53.610
The insight was, if you're sending,
00:03:55.810
if a TCP is sending, faster than
00:03:58.378
the maximum capacity a network can deliver
00:04:00.945
at, the queue will gradually fill up.
00:04:03.512
And as the queue gradually fills up,
00:04:06.079
the latency, the round trip time,
00:04:08.280
will gradually increase.
00:04:09.480
TCP Cubic, and TCP Reno, wait until
00:04:12.151
the queue overflows, wait until there's no
00:04:14.821
more space to put new packets in,
00:04:17.492
and a packet is lost, and at
00:04:20.162
that point they slow down.
00:04:22.170
The insight for TCP Vegas was to
00:04:25.285
watch as the delay increases, and as
00:04:28.400
it sees the delay increasing, it slows
00:04:31.515
down before the queue overflows.
00:04:33.840
So it uses the gradual increase in
00:04:36.168
the round trip time, as an indication
00:04:38.497
that it should send slower.
00:04:40.260
And as the round-trip time reduces,
00:04:42.196
as the round-trip time starts to drop,
00:04:44.455
it treats that as an indication that
00:04:46.713
the queue is draining, which means it
00:04:48.972
can send faster.
00:04:50.040
It wants a constant round trip time.
00:04:52.666
And, i the round trip time increases,
00:04:55.291
it reduces its rate; and if the
00:04:57.917
round-trip time decreases, it increases its rate.
00:05:00.543
So, it's trying to balance it’s rate
00:05:03.169
with the round trip time, and not
00:05:05.794
build or shrink the queues.
00:05:07.770
And because you can detect the queue
00:05:10.446
building up before it overflows, you can
00:05:13.121
take action before the queue is completely
00:05:15.797
full. And that means the queue is
00:05:18.473
running with lower occupancy, so you have
00:05:21.149
lower latency across the network.
00:05:23.160
It also means that because packets are
00:05:25.518
not being lost, you don't need to
00:05:27.876
re-transmit as many packets. So it improves
00:05:30.234
the throughput that way, because you're not
00:05:32.592
resending data that you've already sent and
00:05:34.949
has gotten lost.
00:05:36.060
And that's the fundamental idea of TCP
00:05:38.440
Vegas. It doesn't change the slow start
00:05:40.820
behaviour at all.
00:05:41.940
But, once you're into congestion avoidance,
00:05:43.709
it looks at the variation in round
00:05:45.773
trip time rather than looking at packet
00:05:47.837
loss, and uses that to drive the
00:05:49.901
variation in the speed at which it’s
00:05:51.965
sending.
00:05:56.130
The details of how it works.
00:05:59.010
Well, first, it tries to estimate what
00:06:01.795
it calls the base round trip time.
00:06:04.680
So every time it sends a packet,
00:06:07.019
it measures how long it takes to
00:06:09.357
get a response. And it tries to
00:06:11.696
find the smallest possible response time.
00:06:13.800
The idea being that the smallest time
00:06:15.935
it gets a response, would be the
00:06:18.070
time when the queue is that it's
00:06:20.205
emptiest.
00:06:20.610
It may not get the actual,
00:06:23.158
completely empty, queue, but the smaller the
00:06:26.131
response time, it's trying to estimate the
00:06:29.103
time it takes when there's nothing else
00:06:32.076
in the network.
00:06:33.450
And anything on top of that indicates
00:06:36.386
that there is data queued up somewhere
00:06:39.322
in the network.
00:06:40.680
Then it calculates an expected sending rate.
00:06:43.735
It takes the window size, which indicates
00:06:46.790
how many packets it's supposed to send
00:06:49.844
in that round-trip time,
00:06:51.690
how many bytes of data it’s supposed
00:06:54.056
to send in that round-trip time,
00:06:56.085
and it divides it by the base
00:06:58.451
round trip time. So if you divide
00:07:00.817
number of bytes by time, you get
00:07:03.183
a bytes per second, and that gives
00:07:05.550
you the rate at which it should
00:07:07.916
be sending data.
00:07:09.030
And if the network can
00:07:11.430
support sending at that rate, it should
00:07:14.377
be able to deliver that window of
00:07:17.323
packets within a complete round trip time.
00:07:20.370
And, if it can’t, it will take
00:07:22.583
longer than a round trip time to
00:07:24.795
deliver that window of packets, and the
00:07:27.008
queues will be gradually building up Alternatively,
00:07:29.220
if it takes less than a round
00:07:31.433
trip time, this is an indication that
00:07:33.646
the queues are decreasing.
00:07:35.010
And it measures the actual rate at
00:07:37.104
which it sends the packets.
00:07:38.700
And it compares them.
00:07:40.980
And if the actual rate at which
00:07:43.479
it's sending packets is less than the
00:07:45.978
expected rate, if it's taking longer than
00:07:48.477
a round-trip time to deliver the complete
00:07:50.975
window worth of packets, this is a
00:07:53.474
sign that the packets can’t all be
00:07:55.973
delivered.
00:07:56.430
And it,
00:07:58.020
you know, it's trying to send too
00:07:59.870
much. It’s trying to send at too
00:08:01.720
fast a rate, and it should reduce
00:08:03.570
its rate and let the queues drop.
00:08:05.520
Equally, in the other case it should
00:08:07.746
increase its rate, and measuring the difference
00:08:09.972
between the actual and the expected rates,
00:08:12.198
it can measure whether the queues growing
00:08:14.424
or shrinking.
00:08:18.300
And TCP Vegas compares the expected rate,
00:08:21.461
which actually manages to send at,
00:08:24.270
the expected rate at which it gets
00:08:27.130
the acknowledgments back, with the actual rate.
00:08:30.090
And it adjusts the window.
00:08:33.720
And if the expected rate, minus the
00:08:37.030
actual rate, is less than some threshold,
00:08:40.440
that indicates that it should increase its
00:08:42.900
window. And if they expected rate,
00:08:45.008
minus the actual rate, is greater than
00:08:47.468
some other threshold, then it should decrease
00:08:49.927
the window.
00:08:50.730
That is, if data is arriving at
00:08:53.049
the expected rate, or very close to
00:08:55.369
it, this is probably a sign that
00:08:57.688
the network can support a higher rate,
00:09:00.008
and you should try sending a little
00:09:02.327
bit faster.
00:09:03.090
Alternatively, if data is arriving slower than
00:09:05.065
it's being sent, this is a sign
00:09:07.039
that you're sending too fast and you
00:09:09.014
should slow down.
00:09:09.960
And the two thresholds, R1 and R2,
00:09:12.115
determine how close you have to be
00:09:14.270
to the expected rate, and how far
00:09:16.425
away from it you have to be
00:09:18.581
in order to slow down.
00:09:20.220
And the result is that TCP Vegas
00:09:24.450
follows a much smoother transmission rate.
00:09:27.807
Unlike TCP Reno, which follows the characteristic
00:09:31.724
sawtooth pattern, or TCP cubic which follows
00:09:35.640
the
00:09:36.300
cubic equation to change it’s rate,
00:09:39.028
both of which adapt quite abruptly whenever
00:09:42.211
it's a packet loss,
00:09:44.130
TCP Vegas makes a gradual change.
00:09:46.877
It gradually increases, or decreases, it’s sending
00:09:50.082
rate in line with the variations in
00:09:53.287
the queues. So, it’s a much smoother
00:09:56.492
algorithm, which doesn't continually build up and
00:09:59.696
empty the queues.
00:10:01.170
Because the queues are not continuing building
00:10:04.174
up, not continually being filled, this keeps
00:10:07.178
the latency down while still achieving recently
00:10:10.182
good performance.
00:10:15.270
Now.
00:10:16.710
TCP Vegas is a good idea in
00:10:20.507
principle.
00:10:21.150
This idea is known as delay-based congestion
00:10:23.899
control, and I think it's actually a
00:10:26.649
really good idea in principle. It reduces
00:10:29.398
the latency, because it doesn't fill the
00:10:32.147
queues.
00:10:32.640
It reduces the packet loss, because it's
00:10:35.068
not causing, t's not pushing the queues
00:10:37.496
to overflow and causing packets to be
00:10:39.924
lost. so the only packet losses you
00:10:42.352
get are those caused by transmission problems.
00:10:44.880
And this reduces unnecessary, reduces you having
00:10:47.781
to transmit packets, because you forced the
00:10:50.683
network into overload, and forced it to
00:10:53.584
lose the packets, and it reduces the
00:10:56.486
latency.
00:10:57.000
The problem with TCP Vegas is that
00:11:00.798
it doesn't work, doesn’t interwork work with,
00:11:04.597
TCP Reno or TCP cubic.
00:11:07.410
If you have any TCP Reno or
00:11:10.039
Cubic flows on the network, they will
00:11:12.669
aggressively increase their sending rate and try
00:11:15.298
to fill the queues, and the push
00:11:17.927
the queues into overload.
00:11:19.530
And this will increase the round-trip time,
00:11:22.397
reduce the rate at which Vegas can
00:11:25.264
send, and it will force TCP Vegas
00:11:28.131
to slow down.
00:11:29.460
Because TCP Vegas sees the queues increasing,
00:11:32.151
because Cubic and Reno are intentionally trying
00:11:34.843
to fill those queues, and if the
00:11:37.534
queues increase, this causes Vegas to slow
00:11:40.226
down.
00:11:40.710
That gradually means there's more space in
00:11:43.212
the queues, which Cubic and Reno will
00:11:45.714
gradually fill-up, which causes Vegas to slow
00:11:48.215
down, and they end up in a
00:11:50.717
spiral, where the TCP Vegas flows get
00:11:53.219
pushed down to zero, and the Reno
00:11:55.721
or Cubic flows use all of the
00:11:58.223
capacity.
00:11:58.680
So if we only have TCP Vegas
00:12:01.077
in the network, I think it would
00:12:03.475
behave really nicely, and we get really
00:12:05.873
good, low latency, behaviour from the network.
00:12:08.370
Unfortunately we're in a world where Reno,
00:12:11.420
and Cubic, have been deployed everywhere.
00:12:14.034
And without a step change, without an
00:12:17.084
overnight switch where we turn of Cubic,
00:12:20.134
and we turn off Reno, and we
00:12:23.183
turn on Vegas, everywhere we can't deploy
00:12:26.233
TCP Vegas because always loses out to
00:12:29.283
Reno and Cubic.
00:12:30.690
So, it's a good idea in principle,
00:12:32.525
but in practice it can't be used
00:12:34.359
because of the deployment challenge.
00:12:40.080
As I say, it's a good idea
00:12:43.036
in principle, and the idea of using
00:12:45.993
delay as a congestion signal is a
00:12:48.949
good idea in principle, because we can
00:12:51.906
get something which achieves lower latency.
00:12:54.540
Is it possible to deploy a different
00:12:57.733
algorithm? Maybe the problem is not principal,
00:13:00.925
maybe the problem is the algorithm in
00:13:04.118
TCP Vegas?
00:13:05.130
Well, people are trying alternatives which are
00:13:08.786
delay based.
00:13:09.930
And the most recent attempt at this
00:13:13.053
is an algorithm called TCP BBR,
00:13:15.729
Bottleneck Bandwidth and Round-trip time.
00:13:18.060
And again, this is a proposal that
00:13:20.555
came out of Google. And one of
00:13:23.050
the co-authors, if you look at the
00:13:25.545
paper on the right, is Van Jacobson,
00:13:28.040
who was the original designer of TCP
00:13:30.536
congestion control. So there's clearly some smart
00:13:33.031
people behind this.
00:13:34.200
The ideas is it tries to explicitly
00:13:36.495
measure the round-trip time as it sends
00:13:38.789
the packets. It tires to explicitly measure
00:13:41.084
the sending rate in much the same
00:13:43.379
way same way that
00:13:44.790
TCP Vegas does. And, based on those
00:13:47.319
measurements, and some probes where it varies
00:13:49.849
its rate to try and find if
00:13:52.378
it's got more capacity, or try and
00:13:54.908
sense if there is other traffic on
00:13:57.437
the network.
00:13:58.260
It tries to directly set a congestion
00:14:01.406
window that matches the network capacity,
00:14:04.102
based on those measurements.
00:14:06.000
And, because this came out of Google,
00:14:08.367
it got a lot of press,
00:14:10.397
and Google turned it on for a
00:14:12.764
lot of their traffic. I know they
00:14:15.131
were running it for YouTube for a
00:14:17.499
while, and a lot of people saw
00:14:19.866
this, and jumped on the bandwagon.
00:14:21.895
And, for a while, it was starting
00:14:24.263
to get a reasonable amount of deployments.
00:14:26.730
The problem is, it turns out not
00:14:29.358
to work very well.
00:14:30.960
And Justine Sherry at Carnegie Mellon University,
00:14:34.626
and her PhD student Ranysha Ware,
00:14:37.768
did a really nice bit of work
00:14:41.433
that showed that is incredibly unfair to
00:14:45.099
regular TCP traffic.
00:14:46.770
And, it's unfair in kind-of the opposite
00:14:49.769
way to Vegas. Whereas TCP Reno and
00:14:52.767
TCP Cubic would force TCP Vegas flows
00:14:55.766
down to nothing, TCP BBR is unfair
00:14:58.764
in the opposite way, and it demolishes
00:15:01.763
Reno and Cubic flows, and causes tremendous
00:15:04.761
amounts of packet loss for those flows.
00:15:07.860
So it's really much more aggressive than
00:15:10.759
the other flows in certain cases,
00:15:13.243
and this leads to really quite severe
00:15:16.142
unfairness problems.
00:15:17.070
And the Vimeo link on the slide
00:15:20.621
is a link to the talk at
00:15:24.172
the Internet Measurement Conference, where Ranysha talks
00:15:27.723
through that, and demonstrates really clearly that
00:15:31.274
TCP BBR version 2 is really quite
00:15:34.825
problematic, and
00:15:35.940
not very safe to deploy on the
00:15:39.596
current network.
00:15:40.740
And there's a there's a variant called
00:15:43.711
BBR v2, which is under development,
00:15:46.258
and seems to be changing,
00:15:48.480
certainly on a monthly basis, which is
00:15:50.935
trying to solve these problems. And this
00:15:53.390
is very much an active research area,
00:15:55.844
where people are looking to find better
00:15:58.299
alternatives.
00:16:01.470
So that's the principle of the delay-based
00:16:04.612
congestion control.
00:16:05.610
Traditional TCP, the Reno algorithm and the
00:16:09.097
Cubic algorithms, intentionally try to fill the
00:16:12.583
queues, they intentionally try to cause latency.
00:16:16.170
TCP Vegas is one well-known algorithm which
00:16:20.039
tries to solve this,
00:16:22.350
and
00:16:23.940
doesn't work in practice, but in principle
00:16:26.986
is a good idea, it just has
00:16:30.033
some deployment challenges, given the installed base
00:16:33.079
of Reno and Cubic.
00:16:34.920
And there are new algorithms, like TCP
00:16:37.963
BBR, which don't currently work well,
00:16:40.572
but have potential to solve this problem.
00:16:43.616
And, hopefully, in the future, a future
00:16:46.659
variant of BBR will work effectively,
00:16:49.268
and we'll be able to transition to
00:16:52.311
a lower latency version of TCP.
Part 5: Explicit Congestion Notification
The use of delay-based congestion control is one way of reducing
network latency. Another is to keep Reno and Cubic-style congestion
control, but to move away from using packet loss as an implicit
congestion signal, and instead provide an explicit congestion
notification from the network to the applications. This part of
the lecture introduces the ECN extension to TCP/IP that provides
such a feature, and discusses its operation and deployment.
00:00:00.000
In the previous parts of the lecture,
00:00:02.568
I’ve discussed TCP congestion control. I’ve discussed
00:00:05.136
how TCP tries to measure what the
00:00:07.704
network's doing and, based on those measurements,
00:00:10.272
adapt it’s sending rate to match the
00:00:12.839
available network capacity.
00:00:14.040
In this part, I want to talk
00:00:16.268
about an alternative technique, known as Explicit
00:00:18.497
Congestion Notification, which allows the network to
00:00:20.725
directly tell TCP when it's sending too
00:00:22.953
fast, and needs to reduce it’s transmission
00:00:25.182
rate.
00:00:28.500
So, as we've discussed, TCP infers the
00:00:31.841
presence of congestion in the network through
00:00:35.183
measurement.
00:00:35.760
If you're using TCP Reno or TCP
00:00:38.814
Cubic, like most TCP flows in the
00:00:41.868
network today, then the way it infers
00:00:44.922
that is because there's packet loss.
00:00:47.640
TCP Reno and TCP Cubic keep gradually
00:00:50.751
increasing their sending rates, trying to cause
00:00:53.862
the queues to overflow.
00:00:55.740
And they cause a queue overflow,
00:00:57.771
cause a packet to be lost,
00:00:59.801
and use that packet loss as the
00:01:02.170
signal that the network is busy,
00:01:04.201
that they've reached the network capacity,
00:01:06.231
and they should reduce the sending rate.
00:01:08.700
And this is problematic for two reasons.
00:01:12.006
First, is because it increases delay.
00:01:14.940
It's continually pushing the queues to be
00:01:17.937
full, which means the network’s operating with
00:01:20.933
full queues, with its maximum possible delay.
00:01:24.030
And the second is because it makes
00:01:27.015
it difficult to distinguish loss which is
00:01:30.000
caused because the queues overflowed, from loss
00:01:32.985
caused because of a transmission error on
00:01:35.970
a link, so called non-congestive loss,
00:01:38.529
which you might get due to interference
00:01:41.514
or a wireless link.
00:01:43.320
The other approach people have discussed,
00:01:45.658
is the approach in TCP Vegas,
00:01:47.996
where look at variation in queuing latency
00:01:50.723
and use that as an indication of
00:01:53.450
loss.
00:01:53.940
So, rather than pushing the queue until
00:01:56.438
it overflows, and detecting the overflow,
00:01:58.680
you watch to see as the queue
00:02:00.742
starts to get bigger, and use that
00:02:02.804
as an indication that you should reduce
00:02:04.866
your sending rate. Or, equally, you spot
00:02:06.928
the queue getting smaller, and use that
00:02:08.990
as an indication that you should maybe
00:02:11.052
increase your sending rate.
00:02:12.330
And this is conceptually a good idea,
00:02:15.268
as we discussed in the last part,
00:02:18.207
because it lets you run TCP with
00:02:21.145
lower latency. But it's difficult to deploy,
00:02:24.084
because it interacts poorly with TCP Cubic
00:02:27.022
and TCP Reno, both of which try
00:02:29.961
to fill the queues.
00:02:31.740
As a result, we're stuck with using
00:02:34.345
Reno and Cubic, and we're stuck with
00:02:36.950
full queues in the network. But we'd
00:02:39.556
like to avoid this, we'd like to
00:02:42.161
go for a lower latency way of
00:02:44.766
using TCP, and make the network work
00:02:47.371
without filling the queues.
00:02:48.960
So one way you might go about
00:02:51.841
doing this is, rather than have TCP
00:02:54.722
push the queues to overflow,
00:02:56.880
have the network rather tell TCP when
00:03:00.119
it's sending too fast.
00:03:02.070
Have something in the network tell the
00:03:05.007
TCP connections that they are congesting the
00:03:07.943
network, and they need to slow down.
00:03:10.980
And this thing's called Explicit Congestion Notification.
00:03:17.340
Explicit Congestion Notification, the ECN bits,
00:03:21.100
are present in the IP header.
00:03:24.960
The slide shows an IPv4 header with
00:03:27.514
the ECN bits indicated in red.
00:03:29.703
The same bits are also present in
00:03:32.257
IPv6, and they're located in the same
00:03:34.811
place in the packet in the IPv6
00:03:37.365
header.
00:03:37.830
The way these are used.
00:03:40.200
If the sender doesn't support ECN,
00:03:42.268
it sets these bits to zero when
00:03:44.680
it transmits the packet. And they stay
00:03:47.093
at zero, nothing touches them at that
00:03:49.505
point.
00:03:49.950
However, if the sender does support ECN,
00:03:52.588
and it sets these bits to have
00:03:55.225
the value 01, so it sets bit
00:03:57.862
15 of the header to be 1,
00:04:00.600
and it transmits the IP packets as
00:04:03.637
normal, except with this one bit set
00:04:06.673
to indicate that the sender understands ECN.
00:04:09.810
If congestion occurs in the network,
00:04:12.101
if some queue in the network is
00:04:14.773
beginning to get full, it’s not yet
00:04:17.446
at the point of overflow but it's
00:04:20.118
beginning to get full, such that some
00:04:22.790
router in the network thinks it's about
00:04:25.463
to start experiencing congestion,
00:04:27.090
then that router, that router in the
00:04:29.520
network, changes those bits in the IP
00:04:31.949
packets, of some of the packets going
00:04:34.379
past, and sets both of the ECN
00:04:36.809
bits to one.
00:04:37.950
This is known as an ECN Congestion
00:04:41.279
Experienced mark.
00:04:42.330
It's a signal. It's a signal from
00:04:45.326
the network to the endpoints, that the
00:04:48.322
network thinks it's getting busy, and the
00:04:51.318
endpoint should slow down.
00:04:53.130
And that's all it does. It monitors
00:04:55.456
the occupancy in the queues, and if
00:04:57.783
the queue occupancy is higher than some
00:05:00.109
threshold, it sets the ECN bits in
00:05:02.436
the packets going past, to indicate that
00:05:04.762
threshold has been reached and the network
00:05:07.088
is starting to get busy.
00:05:08.850
If the queue overflows,
00:05:11.130
if the endpoints keep sending faster and
00:05:13.203
the queue overflows, then it drops the
00:05:15.277
packet so as normal. The only difference
00:05:17.350
is that there's some intermediate point where
00:05:19.423
the network is starting to get busy,
00:05:21.497
but the queue has not yet overflowed.
00:05:23.670
And at that point, the network marks
00:05:25.500
the packets indicate that it's getting busy.
00:05:32.100
A receiver might get a TCP packet,
00:05:35.130
a TCP segment, delivered within an IP
00:05:38.160
packet, where that IP packet has the
00:05:41.189
ECN Congestion Experienced mark set. Where the
00:05:44.219
network has changed those two bits in
00:05:47.249
the IP header to 11, to indicate
00:05:50.279
that it's experiencing congestion.
00:05:52.110
What it does that point at that
00:05:55.110
point, is it sets a bit in
00:05:58.109
the TCP header of the acknowledgement packet
00:06:01.109
it sends back to the sender.
00:06:03.780
That bit’s known as the ECN Echo
00:06:06.857
field, the ECE field. It sets this
00:06:09.934
bit in the TCP header equal to
00:06:13.012
one on the next packet it sends
00:06:16.089
back to the sender, after it received
00:06:19.166
the IP packet, containing the TCP segment,
00:06:22.243
where that IP packet was marked Congestion
00:06:25.320
Experienced.
00:06:25.860
So the receiver doesn't really do anything
00:06:28.024
with the Congestion Experienced mark, other than
00:06:30.188
mark, send the equivalent mark in the
00:06:32.352
packet it sends back to the sender.
00:06:34.516
So it's telling the sender, “I got
00:06:36.680
a Congestion Experienced mark in one of
00:06:38.843
the packets you sent”.
00:06:43.590
When that packet gets to the sender,
00:06:46.331
the sender sees this bit in the
00:06:49.072
TCP header, the ECN Echo bit set
00:06:51.813
to one, and it realises that the
00:06:54.554
data it was sending
00:06:56.220
caused a router on the path to
00:06:59.653
set the ECN Congestion Experienced mark,
00:07:02.596
which the receiver has then fed back
00:07:06.029
to it.
00:07:07.110
And what it does at that point,
00:07:09.431
is it reduces its congestion window.
00:07:11.520
It acts as-if a packet had been
00:07:14.592
lost, in terms of how it changes
00:07:17.664
its congestion window.
00:07:19.080
So if it's a TCP Reno sender,
00:07:21.396
it will halve its congestion window,
00:07:23.381
the same way it would if a
00:07:25.697
packet was lost.
00:07:26.790
If it's a TCP Cubic sender,
00:07:29.894
it will back off its congestion window
00:07:33.516
to 70%, and then enter the weird
00:07:37.138
cubic equation for changing its congestion window.
00:07:40.860
After it does that, it sets another
00:07:43.764
bit in the header of the next
00:07:46.668
TCP segment it sends out. It sets
00:07:49.573
the CWR bit, the Congestion Window Reduced
00:07:52.477
bit, in the header to tell the
00:07:55.381
network and the receiver that it's done
00:07:58.285
it.
00:07:58.800
So the end result of this,
00:08:00.943
is that rather than a packet being
00:08:03.443
lost
00:08:03.900
because the queue overflowed, and then the
00:08:06.721
acknowledgments coming back indicating, via the triple
00:08:09.541
duplicate ACK, that's a packet had been
00:08:12.362
lost, and then TCP reducing its congestion
00:08:15.182
window and re-transmitting that lost packet.
00:08:17.700
What happens is,
00:08:20.430
the IP packets, TCP packets, in the
00:08:23.476
outbound direction gets a Congestion Experienced mark
00:08:26.523
set, to indicate that the network is
00:08:29.569
starting to get full.
00:08:31.410
The ECN Echo bit is set on
00:08:33.903
the reply, and at that point the
00:08:36.396
sender reduces its window,
00:08:37.920
as-if the loss had occurred.
00:08:42.450
And then carries on sending with the
00:08:44.534
CWR bit set to one on that
00:08:46.618
next packet. So it has the same
00:08:48.703
effect, in terms of reducing the congestion
00:08:50.787
window, as would
00:08:51.780
dropping a packet, but without dropping a
00:08:53.809
packet. So there's no actual packet loss
00:08:55.837
here, there’s just a mark to indicate
00:08:57.866
that the network was getting busy.
00:08:59.604
So it doesn't have to retransmit data,
00:09:01.633
and this happens before the queue is
00:09:03.661
full, so you get lower latency.
00:09:08.190
So ECN is a mechanism to allow
00:09:11.756
TCP to react to congestion before packet
00:09:15.321
loss occurs.
00:09:16.440
It allows routers in the network to
00:09:18.908
signal congestion before the queue overflows.
00:09:21.024
It allows routers in the network to
00:09:23.492
say to TCP, “if you don't slow
00:09:25.961
down, this queue is going to overflow,
00:09:28.429
and I’m going to throw your packets
00:09:30.897
away”.
00:09:31.350
it's independent of how TCP then responds,
00:09:33.897
whether it follows Reno or Cubic or
00:09:36.444
Vegas that doesn't really matter, it's just
00:09:38.991
an indication that it needs to slow
00:09:41.538
down because the queues are starting to
00:09:44.085
build up, and will overflow soon if
00:09:46.632
it doesn't.
00:09:47.460
And if TCP reacts to that,
00:09:49.411
reacts to the ECN Echo bit going
00:09:51.688
back, and the sender reduces its rate,
00:09:53.964
the queues will empty, the router will
00:09:56.241
stop marking the packets, and everything will
00:09:58.517
settle down at a slightly slower rates
00:10:00.794
without causing any packet loss.
00:10:02.520
And the system will adapt, and it
00:10:05.342
will it will achieve the same sort
00:10:08.163
of throughput, it will just react earlier,
00:10:10.985
so you have smaller queues and lower
00:10:13.807
latency.
00:10:14.310
And this gives you the same throughput
00:10:17.451
as you would with TCP Reno or
00:10:20.592
TCP Cubic, but with low latency,
00:10:23.284
which means it's better for competing video
00:10:26.425
conferencing or gaming traffic.
00:10:28.320
And I’ve described the mechanism for TCP,
00:10:31.070
but there are similar ECN extensions for
00:10:33.821
QUIC and for RTP, which is the
00:10:36.571
video conferencing protocol, all designed to achieve
00:10:39.321
the same goal.
00:10:44.400
So ECN, I think, is unambiguously a
00:10:46.590
good thing. It’s a signal from the
00:10:48.779
network to the endpoints that the network
00:10:50.969
is starting to get congested, and the
00:10:53.159
endpoints should slow down.
00:10:54.510
And if the endpoints believe it,
00:10:56.664
if they back off,
00:10:58.200
they reduce their sending rate before the
00:11:01.449
network is overloaded, and we end up
00:11:04.699
in a world where h we still
00:11:07.948
achieve good congestion control, good throughput,
00:11:10.733
but with lower latency.
00:11:12.690
And, if the endpoints don't believe it
00:11:15.207
well, eventually, the routers, the queues,
00:11:17.365
overflow and they lose packets, and we’re
00:11:19.882
no worse-off than we are now.
00:11:22.140
In order to deploy ECN, though,
00:11:24.254
we need to make changes. We need
00:11:26.719
to change the endpoints, to change the
00:11:29.185
end systems, to support these bits in
00:11:31.651
the IP header, and to support,
00:11:33.764
to add support for this into TCP.
00:11:36.330
And we need to update the routers,
00:11:39.406
to actually mark the packets when they're
00:11:42.482
starting to get overloaded.
00:11:44.340
Updating the end points has pretty much
00:11:46.815
been done by now.
00:11:48.330
I think
00:11:50.610
every TCP implementation,
00:11:53.970
implemented in the last 15-20 years or
00:11:57.212
so, supports ECN, and these days,
00:11:59.991
most of them have it turned on
00:12:03.234
by default.
00:12:04.260
And I think we actually have Apple
00:12:07.289
to thank for this.
00:12:09.120
ECN, for a long time, was implemented
00:12:12.156
but turned off by default, because there’d
00:12:15.191
been problems with some old firewalls which
00:12:18.227
reacted badly to it, 20 or so
00:12:21.263
years ago.
00:12:22.230
And, relatively recently, Apple decided that they
00:12:25.679
wanted these lower latency benefits, and they
00:12:29.127
though ECN should be deployed. So they
00:12:32.576
started turning it on by default in
00:12:36.025
the iPhone.
00:12:37.110
And they kind-of followed an interesting approach.
00:12:40.663
In that for iOS nine, a random
00:12:44.215
subset of 5% of iPhones would turn
00:12:47.768
on ECN for some of their connections.
00:12:51.420
And they measured what happened. And they
00:12:54.243
found out that in the overwhelming majority
00:12:57.067
of cases this worked fine, and occasionally
00:12:59.890
it would fail.
00:13:01.200
And they would call up the network
00:13:03.951
operators, who's networks were showing problems,
00:13:06.310
and they would say “your network doesn't
00:13:09.061
work with iPhones; and currently it's not
00:13:11.812
working well with 5% of iPhones but
00:13:14.563
we're going to increase that number,
00:13:16.922
and maybe you should fix it”.
00:13:19.380
And then, a year later, when iOS
00:13:21.905
10 came out, they did this 50%
00:13:24.430
of connections made by iPhones. And then
00:13:26.954
a year later, for all of the
00:13:29.479
connections.
00:13:29.940
And it's amazing what impact a
00:13:33.900
popular vendor
00:13:38.640
calling up a network operator connect can
00:13:41.491
have on getting them to fix the
00:13:44.343
equipment.
00:13:44.850
And, as a result,
00:13:46.920
ECN is now widely enabled by default
00:13:50.188
in the phones, and the network seems
00:13:53.456
to support it just fine.
00:13:55.890
Most of the routers also support ECN.
00:13:58.464
Although currently relatively few of them seem
00:14:01.038
to enable it by default. So most
00:14:03.612
of the endpoints are now
00:14:05.550
at the stage of sending ECN enabled
00:14:08.256
traffic, and are able to react to
00:14:10.962
the ECN marks, but most of the
00:14:13.668
networks are not currently setting the ECN
00:14:16.373
marks.
00:14:16.860
This is, I think, starting to change.
00:14:20.406
Some of the recent DOCSIS, which is
00:14:23.952
the cable modem standards, are starting to
00:14:27.498
support you ECN. We’re starting to see
00:14:31.044
cable modems, cable Internet connections, which enable
00:14:34.590
ECN by default.
00:14:36.210
And, we're starting to see interest from
00:14:38.912
3GPP, which is the mobile phone standards
00:14:41.615
body to enable this in 5G,
00:14:43.931
6G, networks, so I think it's coming.
00:14:46.634
but it's going to take time.
00:14:49.050
And, I think, as it comes,
00:14:51.221
as ECN gradually gets deployed, we’ll gradually
00:14:53.754
see a reduction in latency across the
00:14:56.287
networks. It’s not going to be dramatic.
00:14:58.920
It's not going to suddenly transform the
00:15:01.387
way the network behaves, but hopefully over
00:15:03.855
the next 5 or 10 years we’ll
00:15:06.322
gradually see the latency reducing as ECN
00:15:08.790
gets more widely deployed.
00:15:13.650
So that's what I want to say
00:15:15.810
about ECN. It’s a mechanism by which
00:15:17.970
the network can signal to the applications
00:15:20.129
that the network is starting to get
00:15:22.289
overloaded, and allow the applications to back
00:15:24.449
off more quickly, in a way which
00:15:26.609
reduces latency and reduces packet loss.
Part 6: Light Speed?
The final part of the lecture moves on from congestion control and
queueing, and discusses another factor that affects latency: the
network propagation delay. It outlines what is the propagation delay
and ways in which it can be reduced, including more direct paths and
the use of low-Earth orbit satellite constellations.
00:00:00.000
In this final part of the lecture,
00:00:02.014
I want to move on from talking
00:00:04.027
about congestion control, and the impact of
00:00:06.041
queuing delays on latency, and talk instead
00:00:08.054
about the impact of propagation delays.
00:00:12.299
So, if you think about the latency
00:00:15.169
for traffic being delivered across the network,
00:00:18.040
there are two factors which impact that
00:00:20.910
latency.
00:00:21.420
The first is the time packets spent
00:00:24.327
queued up at various routers within the
00:00:27.235
network.
00:00:27.750
As we've seen in the previous parts
00:00:30.478
of this lecture, this is highly influenced
00:00:33.205
by the choice of TCP congestion control,
00:00:35.933
and whether Explicit Congestion Notification is enabled
00:00:38.661
or not.
00:00:39.540
The other factor, that we've not really
00:00:41.916
discussed to date, is the time it
00:00:44.293
takes the packets to actually propagate down
00:00:46.669
the links between the routers. This depends
00:00:49.046
on the speed at which the signal
00:00:51.422
propagates down the transmission medium.
00:00:53.220
If you're using an optical fibre to
00:00:55.427
transmit the packets, it depends on the
00:00:57.633
speed at which the light propagates through
00:00:59.840
the fibre.
00:01:00.570
If you're using electrical signals in a
00:01:02.558
cable, it depends on the speed at
00:01:04.546
which electrical field propagates down the cable.
00:01:06.534
And if you're using radio signals,
00:01:08.238
it depends on the speed of light,
00:01:10.226
the speed at which the radio signals
00:01:12.214
propagate through the air.
00:01:17.010
As you might expect, physically shorter links
00:01:21.089
have lower propagation delays.
00:01:23.520
A lot of the time it takes
00:01:25.912
a packet to get down a long
00:01:28.305
distance link is just the time it
00:01:30.697
takes the signal to physically transmit along
00:01:33.089
the link. If you make the link
00:01:35.481
shorter it takes less time.
00:01:37.290
And what is perhaps not so obvious,
00:01:41.110
though, is that you can actually get
00:01:44.929
significantly significant latency benefits in certain paths,
00:01:48.749
because the existing network links follow quite
00:01:52.569
indirect routes.
00:01:53.760
For example, if you look at the
00:01:56.224
path the network links take, if you're
00:01:58.688
sending data from Europe to Japan.
00:02:00.900
Quite often, that data goes from Europe,
00:02:04.173
across the Atlantic to, for example,
00:02:06.979
New York or Boston, or somewhere like
00:02:10.252
that, across the US to
00:02:12.690
San Francisco, or Los Angeles, or Seattle,
00:02:16.248
or somewhere along those lines, and then
00:02:19.807
from there, in a cable across the
00:02:23.365
Pacific to Japan.
00:02:24.990
Or alternatively, it goes from Europe through
00:02:27.718
the Mediterranean, the Suez Canal and the
00:02:30.447
Middle East, and across India, and so
00:02:33.175
on, until it eventually reaches Japan the
00:02:35.903
other way around. But neither of these
00:02:38.631
is a particularly direct route.
00:02:40.680
And it turns out that there is
00:02:43.132
a much more direct, a much faster
00:02:45.585
route, to get from Europe to Japan,
00:02:48.037
which is to lay a an optical
00:02:50.490
fibre
00:02:50.940
through the Northwest Passage, across Northern Canada,
00:02:53.704
through the Arctic Ocean, and down through
00:02:56.467
the Bering Strait, and past Russia to
00:02:59.231
get directly to Japan. It's much closer
00:03:01.994
to the great circle route around the
00:03:04.758
globe, and it's much shorter than the
00:03:07.521
route that the networks currently take.
00:03:09.990
And, historically, this hasn't been possible because
00:03:12.688
of the ice in the Arctic.
00:03:15.000
But, with global warming, the Northwest Passage
00:03:17.697
is now ice-free for enough of the
00:03:20.395
year that people are starting to talk
00:03:23.092
about laying optical fibres along that route,
00:03:25.890
because they can get a noticeable latency
00:03:28.861
reduction, for certain amounts of traffic,
00:03:31.408
by just following the physically shorter route.
00:03:38.400
Another factor which influences the propagation delay
00:03:42.307
is the speed of light in the
00:03:46.214
transmission media.
00:03:47.430
Now, if you're sending data using radio
00:03:51.989
links,
00:03:52.740
or using lasers in a vacuum,
00:03:55.659
then these propagate at the speed of
00:03:59.064
light in the vacuum.
00:04:01.110
Which is about 300 million meters per
00:04:04.803
second.
00:04:05.430
The speed of light in optical fibre,
00:04:07.827
though, is slower. The speed at which
00:04:10.224
light propagates down that down a fibre,
00:04:12.621
the speed at which light propagates through
00:04:15.018
glass, is only about 200,000.
00:04:16.830
kilometres per second, 200 million meters per
00:04:19.475
second. So it’s about two thirds of
00:04:22.120
the speed at which it propagates in
00:04:24.764
a vacuum.
00:04:25.620
And this is the reason for systems
00:04:29.140
such as StarLink, which SpaceX is deploying.
00:04:32.760
And the idea of these systems is
00:04:35.579
that, rather than sending the Internet signals
00:04:38.399
down an optical fibre,
00:04:40.110
you send them 100, or a couple
00:04:42.965
of hundred miles, up to a satellite,
00:04:45.821
and they then go around between various
00:04:48.676
satellites in the constellation, in low earth
00:04:51.531
orbit, and then down to a receiver
00:04:54.386
near the destination.
00:04:55.710
And by propagating through vacuum, rather than
00:04:58.695
through optical fibre, the speed of light
00:05:01.679
in vacuum is significantly faster, it's about
00:05:04.664
50% faster than the speed of light
00:05:07.649
in fibre, and this can reduce the
00:05:10.634
latency.
00:05:11.160
And the estimates show that if you
00:05:14.235
have a large enough constellation of satellites,
00:05:17.310
and SpaceX is planning on deploying around
00:05:20.384
4000 satellites, I believe, and with careful
00:05:23.459
routing, you can get about a 40,
00:05:26.534
45, 50% reduction in latency.
00:05:28.830
Just because the signals are transmitting via
00:05:31.858
radio waves, and via inter-satellite laser links,
00:05:34.887
which are in a vacuum, rather than
00:05:37.915
being transmitted through a fibre optic cable.
00:05:40.943
Just because of the differences in the
00:05:43.972
speed of light between the two mediums.
00:05:47.100
And the link on the slide points
00:05:49.719
to some simulations of the StarLink network,
00:05:52.337
which try and demonstrate how this would
00:05:54.956
work, and how it can achieve
00:05:57.300
both network paths that closely follow the
00:06:01.875
great circle routes, and
00:06:04.590
how it can reduce the latency because
00:06:09.111
of the use of satellites.
00:06:13.440
So, what we see is that people
00:06:15.758
are clearly going to some quite extreme
00:06:18.076
lengths to reduce latency.
00:06:19.500
I mean, what we spoke about in
00:06:21.926
the previous part was the use of
00:06:24.352
ECN marking to reduce latency by reducing
00:06:26.779
the amount of queuing. And that's just
00:06:29.205
a configuration change, it’s a software change
00:06:31.631
to some routers. And that seems to
00:06:34.057
me like a reasonable approach to reducing
00:06:36.483
latency.
00:06:36.930
But some people are clearly willing to
00:06:39.689
go to the effort of
00:06:41.760
launching thousands of satellites, or
00:06:45.600
perhaps the slightly less extreme case of
00:06:48.927
laying new optical fibres through the Arctic
00:06:52.255
Ocean.
00:06:52.830
So why are people doing this? Why
00:06:55.624
do people care so much about reducing
00:06:58.418
latency, that they're willing to spend billions
00:07:01.212
of dollars launching thousands of satellites,
00:07:03.607
or running new undersea cables, to do
00:07:06.401
this?
00:07:06.900
Well, you'll be surprised to hear that
00:07:09.239
this is not to improve your gaming
00:07:11.577
experience. And this is not to improve
00:07:13.916
the experience of your zoom calls.
00:07:16.020
Why are people doing this? High frequency
00:07:19.559
share trading.
00:07:20.670
Share traders believe they can make a
00:07:23.947
lot of money, by getting a few
00:07:27.224
milliseconds worth
00:07:28.260
of latency reduction compared to their competitors.
00:07:33.600
Whether that's a good use of a
00:07:36.115
few billion dollars i'll let you decide.
00:07:38.730
But the end result may be,
00:07:40.548
hopefully, that we will get lower latency
00:07:42.669
for the rest of us as well.
00:07:48.720
And that concludes this lecture.
00:07:52.440
There are a bunch of reasons why
00:07:54.870
we have latency in the network.
00:07:56.952
Some of this is due to propagation
00:07:59.382
delays. Some of this, perhaps most of
00:08:01.812
it, in many cases, is due to
00:08:04.242
queuing at intermediate routers.
00:08:05.730
The propagation delays are driven by the
00:08:08.096
speed of light.
00:08:09.210
And unless you can launch many satellites,
00:08:12.754
or lay more optical fibres, that's pretty
00:08:16.298
much a fixed constant, and there's not
00:08:19.842
much we can do about it.
00:08:22.980
Queuing delays, though, are things which we
00:08:25.836
can change. And a lot of the
00:08:28.693
queuing delays in the network are caused
00:08:31.549
because of TCP Reno and TCP Cubic,
00:08:34.406
which push for the queues to be
00:08:37.262
full.
00:08:37.770
Hopefully, we will see improved TCP congestion
00:08:41.370
control algorithms. And TCP Vegas was one
00:08:44.969
attempt in this direction, which unfortunately proved
00:08:48.569
not to be deployable in practice,
00:08:51.655
TCP BBR was another attempt which
00:08:54.840
was problematic for other reasons, because of
00:08:57.283
its unfairness. But people are certainly working
00:08:59.726
on an alternative algorithms in this space,
00:09:02.169
and hopefully we'll see things deployed before
00:09:04.612
too long.
Discussion
Lecture 6 discussed TCP congestion control and its impact on latency.
It discussed the principles of congestion control (e.g., the sliding
window algorithm, AIMD, conservation of packets), and their realisation
in TCP Reno. It reviewed the choice of TCP initial window, slow start,
and the congestion avoidance phase, and the response of TCP to packet
loss as a congestion signal.
The lecture noted that TCP Reno cannot effectively make use of fast
and long distance paths (e.g., gigabit per second flows, running on
transatlantic links). It discussed the TCP Cubic algorithm, that
changes the behaviour of TCP in the congestion avoidance phase to
make more effective use of such paths.
And it noted that both TCP Reno and TCP Cubic will try to increase
their sending rate until packet loss occurs, and will use that loss
as a signal to slow down. The fills the in-network queues at routers
on the path, causing latency.
The lecture briefly discussed TCP Vegas, and the idea of using delay
changes as a congestion signal instead of packet loss, and it noted
that TCP Vegas is not deployable in parallel with TCP Reno or Cubic.
It highlighted ongoing research with TCP BBR to address some of the
limitations of TCP Vegas.
Finally, the lecture highlighted the possible use of Explicit Congestion
Notification as a way of signalling congestion to the endpoints, and of
causing TCP to reduce its sending rate, before the in-network queues
overflow. This potentially offers a way to reduce latency.
Discussion will focus on the behaviour of TCP Reno congestion control,
and of understanding how this leads to increased latency. It will discuss
the applicability and ease of deployment of ways of reducing that latency.