/
draft-ietf-quic-recovery.txt
2352 lines (1528 loc) · 85.3 KB
/
draft-ietf-quic-recovery.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
QUIC J. Iyengar, Ed.
Internet-Draft Fastly
Intended status: Standards Track I. Swett, Ed.
Expires: December 23, 2019 Google
June 21, 2019
QUIC Loss Detection and Congestion Control
draft-ietf-quic-recovery-latest
Abstract
This document describes loss detection and congestion control
mechanisms for QUIC.
Note to Readers
Discussion of this draft takes place on the QUIC working group
mailing list (quic@ietf.org), which is archived at
https://mailarchive.ietf.org/arch/search/?email_list=quic [1].
Working Group information can be found at https://github.com/quicwg
[2]; source code and issues list for this draft can be found at
https://github.com/quicwg/base-drafts/labels/-recovery [3].
Status of This Memo
This Internet-Draft is submitted in full conformance with the
provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet-
Drafts is at https://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress."
This Internet-Draft will expire on December 23, 2019.
Copyright Notice
Copyright (c) 2019 IETF Trust and the persons identified as the
document authors. All rights reserved.
Iyengar & Swett Expires December 23, 2019 [Page 1]
Internet-Draft QUIC Loss Detection June 2019
This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents
(https://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect
to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License.
Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4
2. Conventions and Definitions . . . . . . . . . . . . . . . . . 4
3. Design of the QUIC Transmission Machinery . . . . . . . . . . 5
3.1. Relevant Differences Between QUIC and TCP . . . . . . . . 5
3.1.1. Separate Packet Number Spaces . . . . . . . . . . . . 6
3.1.2. Monotonically Increasing Packet Numbers . . . . . . . 6
3.1.3. Clearer Loss Epoch . . . . . . . . . . . . . . . . . 6
3.1.4. No Reneging . . . . . . . . . . . . . . . . . . . . . 7
3.1.5. More ACK Ranges . . . . . . . . . . . . . . . . . . . 7
3.1.6. Explicit Correction For Delayed Acknowledgements . . 7
4. Generating Acknowledgements . . . . . . . . . . . . . . . . . 7
4.1. Crypto Handshake Data . . . . . . . . . . . . . . . . . . 8
4.2. ACK Ranges . . . . . . . . . . . . . . . . . . . . . . . 8
4.3. Receiver Tracking of ACK Frames . . . . . . . . . . . . . 8
4.4. Measuring and Reporting Host Delay . . . . . . . . . . . 8
5. Estimating the Round-Trip Time . . . . . . . . . . . . . . . 9
5.1. Generating RTT samples . . . . . . . . . . . . . . . . . 9
5.2. Estimating min_rtt . . . . . . . . . . . . . . . . . . . 10
5.3. Estimating smoothed_rtt and rttvar . . . . . . . . . . . 10
6. Loss Detection . . . . . . . . . . . . . . . . . . . . . . . 11
6.1. Acknowledgement-based Detection . . . . . . . . . . . . . 11
6.1.1. Packet Threshold . . . . . . . . . . . . . . . . . . 12
6.1.2. Time Threshold . . . . . . . . . . . . . . . . . . . 12
6.2. Crypto Retransmission Timeout . . . . . . . . . . . . . . 13
6.3. Probe Timeout . . . . . . . . . . . . . . . . . . . . . . 14
6.3.1. Computing PTO . . . . . . . . . . . . . . . . . . . . 14
6.3.2. Sending Probe Packets . . . . . . . . . . . . . . . . 15
6.3.3. Loss Detection . . . . . . . . . . . . . . . . . . . 16
6.4. Retry and Version Negotiation . . . . . . . . . . . . . . 16
6.5. Discarding Keys and Packet State . . . . . . . . . . . . 17
6.6. Discussion . . . . . . . . . . . . . . . . . . . . . . . 17
7. Congestion Control . . . . . . . . . . . . . . . . . . . . . 17
7.1. Explicit Congestion Notification . . . . . . . . . . . . 18
7.2. Slow Start . . . . . . . . . . . . . . . . . . . . . . . 18
7.3. Congestion Avoidance . . . . . . . . . . . . . . . . . . 18
7.4. Recovery Period . . . . . . . . . . . . . . . . . . . . . 18
Iyengar & Swett Expires December 23, 2019 [Page 2]
Internet-Draft QUIC Loss Detection June 2019
7.5. Ignoring Loss of Undecryptable Packets . . . . . . . . . 19
7.6. Probe Timeout . . . . . . . . . . . . . . . . . . . . . . 19
7.7. Persistent Congestion . . . . . . . . . . . . . . . . . . 19
7.8. Pacing . . . . . . . . . . . . . . . . . . . . . . . . . 20
7.9. Under-utilizing the Congestion Window . . . . . . . . . . 21
8. Security Considerations . . . . . . . . . . . . . . . . . . . 21
8.1. Congestion Signals . . . . . . . . . . . . . . . . . . . 21
8.2. Traffic Analysis . . . . . . . . . . . . . . . . . . . . 21
8.3. Misreporting ECN Markings . . . . . . . . . . . . . . . . 22
9. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 22
10. References . . . . . . . . . . . . . . . . . . . . . . . . . 22
10.1. Normative References . . . . . . . . . . . . . . . . . . 22
10.2. Informative References . . . . . . . . . . . . . . . . . 23
10.3. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Appendix A. Loss Recovery Pseudocode . . . . . . . . . . . . . . 24
A.1. Tracking Sent Packets . . . . . . . . . . . . . . . . . . 25
A.1.1. Sent Packet Fields . . . . . . . . . . . . . . . . . 25
A.2. Constants of interest . . . . . . . . . . . . . . . . . . 25
A.3. Variables of interest . . . . . . . . . . . . . . . . . . 26
A.4. Initialization . . . . . . . . . . . . . . . . . . . . . 27
A.5. On Sending a Packet . . . . . . . . . . . . . . . . . . . 27
A.6. On Receiving an Acknowledgment . . . . . . . . . . . . . 28
A.7. On Packet Acknowledgment . . . . . . . . . . . . . . . . 29
A.8. Setting the Loss Detection Timer . . . . . . . . . . . . 30
A.9. On Timeout . . . . . . . . . . . . . . . . . . . . . . . 32
A.10. Detecting Lost Packets . . . . . . . . . . . . . . . . . 32
Appendix B. Congestion Control Pseudocode . . . . . . . . . . . 33
B.1. Constants of interest . . . . . . . . . . . . . . . . . . 33
B.2. Variables of interest . . . . . . . . . . . . . . . . . . 34
B.3. Initialization . . . . . . . . . . . . . . . . . . . . . 35
B.4. On Packet Sent . . . . . . . . . . . . . . . . . . . . . 35
B.5. On Packet Acknowledgement . . . . . . . . . . . . . . . . 35
B.6. On New Congestion Event . . . . . . . . . . . . . . . . . 36
B.7. Process ECN Information . . . . . . . . . . . . . . . . . 36
B.8. On Packets Lost . . . . . . . . . . . . . . . . . . . . . 37
Appendix C. Change Log . . . . . . . . . . . . . . . . . . . . . 37
C.1. Since draft-ietf-quic-recovery-19 . . . . . . . . . . . . 37
C.2. Since draft-ietf-quic-recovery-18 . . . . . . . . . . . . 38
C.3. Since draft-ietf-quic-recovery-17 . . . . . . . . . . . . 38
C.4. Since draft-ietf-quic-recovery-16 . . . . . . . . . . . . 39
C.5. Since draft-ietf-quic-recovery-14 . . . . . . . . . . . . 39
C.6. Since draft-ietf-quic-recovery-13 . . . . . . . . . . . . 39
C.7. Since draft-ietf-quic-recovery-12 . . . . . . . . . . . . 40
C.8. Since draft-ietf-quic-recovery-11 . . . . . . . . . . . . 40
C.9. Since draft-ietf-quic-recovery-10 . . . . . . . . . . . . 40
C.10. Since draft-ietf-quic-recovery-09 . . . . . . . . . . . . 40
C.11. Since draft-ietf-quic-recovery-08 . . . . . . . . . . . . 40
C.12. Since draft-ietf-quic-recovery-07 . . . . . . . . . . . . 40
Iyengar & Swett Expires December 23, 2019 [Page 3]
Internet-Draft QUIC Loss Detection June 2019
C.13. Since draft-ietf-quic-recovery-06 . . . . . . . . . . . . 41
C.14. Since draft-ietf-quic-recovery-05 . . . . . . . . . . . . 41
C.15. Since draft-ietf-quic-recovery-04 . . . . . . . . . . . . 41
C.16. Since draft-ietf-quic-recovery-03 . . . . . . . . . . . . 41
C.17. Since draft-ietf-quic-recovery-02 . . . . . . . . . . . . 41
C.18. Since draft-ietf-quic-recovery-01 . . . . . . . . . . . . 41
C.19. Since draft-ietf-quic-recovery-00 . . . . . . . . . . . . 41
C.20. Since draft-iyengar-quic-loss-recovery-01 . . . . . . . . 42
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 42
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 42
1. Introduction
QUIC is a new multiplexed and secure transport atop UDP. QUIC builds
on decades of transport and security experience, and implements
mechanisms that make it attractive as a modern general-purpose
transport. The QUIC protocol is described in [QUIC-TRANSPORT].
QUIC implements the spirit of existing TCP loss recovery mechanisms,
described in RFCs, various Internet-drafts, and also those prevalent
in the Linux TCP implementation. This document describes QUIC
congestion control and loss recovery, and where applicable,
attributes the TCP equivalent in RFCs, Internet-drafts, academic
papers, and/or TCP implementations.
2. Conventions and Definitions
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
"OPTIONAL" in this document are to be interpreted as described in BCP
14 [RFC2119] [RFC8174] when, and only when, they appear in all
capitals, as shown here.
Definitions of terms that are used in this document:
ACK-only: Any packet containing only one or more ACK frame(s).
In-flight: Packets are considered in-flight when they have been sent
and are not ACK-only, and they are not acknowledged, declared
lost, or abandoned along with old keys.
Ack-eliciting Frames: All frames besides ACK or PADDING are
considered ack-eliciting.
Ack-eliciting Packets: Packets that contain ack-eliciting frames
elicit an ACK from the receiver within the maximum ack delay and
are called ack-eliciting packets.
Iyengar & Swett Expires December 23, 2019 [Page 4]
Internet-Draft QUIC Loss Detection June 2019
Crypto Packets: Packets containing CRYPTO data sent in Initial or
Handshake packets.
Out-of-order Packets: Packets that do not increase the largest
received packet number for its packet number space by exactly one.
Packets arrive out of order when earlier packets are lost or
delayed.
3. Design of the QUIC Transmission Machinery
All transmissions in QUIC are sent with a packet-level header, which
indicates the encryption level and includes a packet sequence number
(referred to below as a packet number). The encryption level
indicates the packet number space, as described in [QUIC-TRANSPORT].
Packet numbers never repeat within a packet number space for the
lifetime of a connection. Packet numbers monotonically increase
within a space, preventing ambiguity.
This design obviates the need for disambiguating between
transmissions and retransmissions and eliminates significant
complexity from QUIC's interpretation of TCP loss detection
mechanisms.
QUIC packets can contain multiple frames of different types. The
recovery mechanisms ensure that data and frames that need reliable
delivery are acknowledged or declared lost and sent in new packets as
necessary. The types of frames contained in a packet affect recovery
and congestion control logic:
o All packets are acknowledged, though packets that contain no ack-
eliciting frames are only acknowledged along with ack-eliciting
packets.
o Long header packets that contain CRYPTO frames are critical to the
performance of the QUIC handshake and use shorter timers for
acknowledgement and retransmission.
o Packets that contain only ACK frames do not count toward
congestion control limits and are not considered in-flight.
o PADDING frames cause packets to contribute toward bytes in flight
without directly causing an acknowledgment to be sent.
3.1. Relevant Differences Between QUIC and TCP
Readers familiar with TCP's loss detection and congestion control
will find algorithms here that parallel well-known TCP ones.
Protocol differences between QUIC and TCP however contribute to
Iyengar & Swett Expires December 23, 2019 [Page 5]
Internet-Draft QUIC Loss Detection June 2019
algorithmic differences. We briefly describe these protocol
differences below.
3.1.1. Separate Packet Number Spaces
QUIC uses separate packet number spaces for each encryption level,
except 0-RTT and all generations of 1-RTT keys use the same packet
number space. Separate packet number spaces ensures acknowledgement
of packets sent with one level of encryption will not cause spurious
retransmission of packets sent with a different encryption level.
Congestion control and round-trip time (RTT) measurement are unified
across packet number spaces.
3.1.2. Monotonically Increasing Packet Numbers
TCP conflates transmission order at the sender with delivery order at
the receiver, which results in retransmissions of the same data
carrying the same sequence number, and consequently leads to
"retransmission ambiguity". QUIC separates the two: QUIC uses a
packet number to indicate transmission order, and any application
data is sent in one or more streams, with delivery order determined
by stream offsets encoded within STREAM frames.
QUIC's packet number is strictly increasing within a packet number
space, and directly encodes transmission order. A higher packet
number signifies that the packet was sent later, and a lower packet
number signifies that the packet was sent earlier. When a packet
containing ack-eliciting frames is detected lost, QUIC rebundles
necessary frames in a new packet with a new packet number, removing
ambiguity about which packet is acknowledged when an ACK is received.
Consequently, more accurate RTT measurements can be made, spurious
retransmissions are trivially detected, and mechanisms such as Fast
Retransmit can be applied universally, based only on packet number.
This design point significantly simplifies loss detection mechanisms
for QUIC. Most TCP mechanisms implicitly attempt to infer
transmission ordering based on TCP sequence numbers - a non-trivial
task, especially when TCP timestamps are not available.
3.1.3. Clearer Loss Epoch
QUIC ends a loss epoch when a packet sent after loss is declared is
acknowledged. TCP waits for the gap in the sequence number space to
be filled, and so if a segment is lost multiple times in a row, the
loss epoch may not end for several round trips. Because both should
reduce their congestion windows only once per epoch, QUIC will do it
correctly once for every round trip that experiences loss, while TCP
may only do it once across multiple round trips.
Iyengar & Swett Expires December 23, 2019 [Page 6]
Internet-Draft QUIC Loss Detection June 2019
3.1.4. No Reneging
QUIC ACKs contain information that is similar to TCP SACK, but QUIC
does not allow any acked packet to be reneged, greatly simplifying
implementations on both sides and reducing memory pressure on the
sender.
3.1.5. More ACK Ranges
QUIC supports many ACK ranges, opposed to TCP's 3 SACK ranges. In
high loss environments, this speeds recovery, reduces spurious
retransmits, and ensures forward progress without relying on
timeouts.
3.1.6. Explicit Correction For Delayed Acknowledgements
QUIC endpoints measure the delay incurred between when a packet is
received and when the corresponding acknowledgment is sent, allowing
a peer to maintain a more accurate round-trip time estimate (see
Section 4.4).
4. Generating Acknowledgements
An acknowledgement SHOULD be sent immediately upon receipt of a
second ack-eliciting packet. QUIC recovery algorithms do not assume
the peer sends an ACK immediately when receiving a second ack-
eliciting packet.
In order to accelerate loss recovery and reduce timeouts, the
receiver SHOULD send an immediate ACK after it receives an out-of-
order packet. It could send immediate ACKs for in-order packets for
a period of time that SHOULD NOT exceed 1/8 RTT unless more out-of-
order packets arrive. If every packet arrives out-of- order, then an
immediate ACK SHOULD be sent for every received packet.
Similarly, packets marked with the ECN Congestion Experienced (CE)
codepoint in the IP header SHOULD be acknowledged immediately, to
reduce the peer's response time to congestion events.
As an optimization, a receiver MAY process multiple packets before
sending any ACK frames in response. In this case the receiver can
determine whether an immediate or delayed acknowledgement should be
generated after processing incoming packets.
Iyengar & Swett Expires December 23, 2019 [Page 7]
Internet-Draft QUIC Loss Detection June 2019
4.1. Crypto Handshake Data
In order to quickly complete the handshake and avoid spurious
retransmissions due to crypto retransmission timeouts, crypto packets
SHOULD use a very short ack delay, such as the local timer
granularity. ACK frames SHOULD be sent immediately when the crypto
stack indicates all data for that packet number space has been
received.
4.2. ACK Ranges
When an ACK frame is sent, one or more ranges of acknowledged packets
are included. Including older packets reduces the chance of spurious
retransmits caused by losing previously sent ACK frames, at the cost
of larger ACK frames.
ACK frames SHOULD always acknowledge the most recently received
packets, and the more out-of-order the packets are, the more
important it is to send an updated ACK frame quickly, to prevent the
peer from declaring a packet as lost and spuriously retransmitting
the frames it contains.
Below is one recommended approach for determining what packets to
include in an ACK frame.
4.3. Receiver Tracking of ACK Frames
When a packet containing an ACK frame is sent, the largest
acknowledged in that frame may be saved. When a packet containing an
ACK frame is acknowledged, the receiver can stop acknowledging
packets less than or equal to the largest acknowledged in the sent
ACK frame.
In cases without ACK frame loss, this algorithm allows for a minimum
of 1 RTT of reordering. In cases with ACK frame loss and reordering,
this approach does not guarantee that every acknowledgement is seen
by the sender before it is no longer included in the ACK frame.
Packets could be received out of order and all subsequent ACK frames
containing them could be lost. In this case, the loss recovery
algorithm may cause spurious retransmits, but the sender will
continue making forward progress.
4.4. Measuring and Reporting Host Delay
An endpoint measures the delays intentionally introduced between when
an ACK-eliciting packet is received and the corresponding
acknowledgment is sent. The endpoint encodes this delay for the
largest acknowledged packet in the Ack Delay field of an ACK frame
Iyengar & Swett Expires December 23, 2019 [Page 8]
Internet-Draft QUIC Loss Detection June 2019
(see Section 19.3 of [QUIC-TRANSPORT]). This allows the receiver of
the ACK to adjust for any intentional delays, which is important for
delayed acknowledgements, when estimating the path RTT. A packet
might be held in the OS kernel or elsewhere on the host before being
processed. An endpoint SHOULD NOT include these unintentional delays
when populating the Ack Delay field in an ACK frame.
An endpoint MUST NOT excessively delay acknowledgements of ack-
eliciting packets. The maximum ack delay is communicated in the
max_ack_delay transport parameter; see Section 18.1 of
[QUIC-TRANSPORT]. max_ack_delay implies an explicit contract: an
endpoint promises to never delay acknowledgments of an ack-eliciting
packet by more than the indicated value. If it does, any excess
accrues to the RTT estimate and could result in spurious
retransmissions from the peer. For Initial and Handshake packets, a
max_ack_delay of 0 is used.
5. Estimating the Round-Trip Time
At a high level, an endpoint measures the time from when a packet was
sent to when it is acknowledged as a round-trip time (RTT) sample.
The endpoint uses RTT samples and peer-reported host delays
(Section 4.4) to generate a statistical description of the
connection's RTT. An endpoint computes the following three values:
the minimum value observed over the lifetime of the connection
(min_rtt), an exponentially-weighted moving average (smoothed_rtt),
and the variance in the observed RTT samples (rttvar).
5.1. Generating RTT samples
An endpoint generates an RTT sample on receiving an ACK frame that
meets the following two conditions:
o the largest acknowledged packet number is newly acknowledged, and
o at least one of the newly acknowledged packets was ack-eliciting.
The RTT sample, latest_rtt, is generated as the time elapsed since
the largest acknowledged packet was sent:
latest_rtt = ack_time - send_time_of_largest_acked
An RTT sample is generated using only the largest acknowledged packet
in the received ACK frame. This is because a peer reports host
delays for only the largest acknowledged packet in an ACK frame.
While the reported host delay is not used by the RTT sample
measurement, it is used to adjust the RTT sample in subsequent
computations of smoothed_rtt and rttvar Section 5.3.
Iyengar & Swett Expires December 23, 2019 [Page 9]
Internet-Draft QUIC Loss Detection June 2019
To avoid generating multiple RTT samples using the same packet, an
ACK frame SHOULD NOT be used to update RTT estimates if it does not
newly acknowledge the largest acknowledged packet.
An RTT sample MUST NOT be generated on receiving an ACK frame that
does not newly acknowledge at least one ack-eliciting packet. A peer
does not send an ACK frame on receiving only non-ack-eliciting
packets, so an ACK frame that is subsequently sent can include an
arbitrarily large Ack Delay field. Ignoring such ACK frames avoids
complications in subsequent smoothed_rtt and rttvar computations.
A sender might generate multiple RTT samples per RTT when multiple
ACK frames are received within an RTT. As suggested in [RFC6298],
doing so might result in inadequate history in smoothed_rtt and
rttvar. Ensuring that RTT estimates retain sufficient history is an
open research question.
5.2. Estimating min_rtt
min_rtt is the minimum RTT observed over the lifetime of the
connection. min_rtt is set to the latest_rtt on the first sample in
a connection, and to the lesser of min_rtt and latest_rtt on
subsequent samples.
An endpoint uses only locally observed times in computing the min_rtt
and does not adjust for host delays reported by the peer
(Section 4.4). Doing so allows the endpoint to set a lower bound for
the smoothed_rtt based entirely on what it observes (see
Section 5.3), and limits potential underestimation due to
erroneously-reported delays by the peer.
5.3. Estimating smoothed_rtt and rttvar
smoothed_rtt is an exponentially-weighted moving average of an
endpoint's RTT samples, and rttvar is the endpoint's estimated
variance in the RTT samples.
The calculation of smoothed_rtt uses path latency after adjusting RTT
samples for host delays (Section 4.4). For packets sent in the
ApplicationData packet number space, a peer limits any delay in
sending an acknowledgement for an ack-eliciting packet to no greater
than the value it advertised in the max_ack_delay transport
parameter. Consequently, when a peer reports an Ack Delay that is
greater than its max_ack_delay, the delay is attributed to reasons
out of the peer's control, such as scheduler latency at the peer or
loss of previous ACK frames. Any delays beyond the peer's
max_ack_delay are therefore considered effectively part of path delay
and incorporated into the smoothed_rtt estimate.
Iyengar & Swett Expires December 23, 2019 [Page 10]
Internet-Draft QUIC Loss Detection June 2019
When adjusting an RTT sample using peer-reported acknowledgement
delays, an endpoint:
o MUST ignore the Ack Delay field of the ACK frame for packets sent
in the Initial and Handshake packet number space.
o MUST use the lesser of the value reported in Ack Delay field of
the ACK frame and the peer's max_ack_delay transport parameter
(Section 4.4).
o MUST NOT apply the adjustment if the resulting RTT sample is
smaller than the min_rtt. This limits the underestimation that a
misreporting peer can cause to the smoothed_rtt.
On the first RTT sample in a connection, the smoothed_rtt is set to
the latest_rtt.
smoothed_rtt and rttvar are computed as follows, similar to
[RFC6298]. On the first RTT sample in a connection:
smoothed_rtt = latest_rtt
rttvar = latest_rtt / 2
On subsequent RTT samples, smoothed_rtt and rttvar evolve as follows:
ack_delay = min(Ack Delay in ACK Frame, max_ack_delay)
adjusted_rtt = latest_rtt
if (min_rtt + ack_delay < latest_rtt):
adjusted_rtt = latest_rtt - ack_delay
smoothed_rtt = 7/8 * smoothed_rtt + 1/8 * adjusted_rtt
rttvar_sample = abs(smoothed_rtt - adjusted_rtt)
rttvar = 3/4 * rttvar + 1/4 * rttvar_sample
6. Loss Detection
QUIC senders use both ack information and timeouts to detect lost
packets, and this section provides a description of these algorithms.
If a packet is lost, the QUIC transport needs to recover from that
loss, such as by retransmitting the data, sending an updated frame,
or abandoning the frame. For more information, see Section 13.2 of
[QUIC-TRANSPORT].
6.1. Acknowledgement-based Detection
Acknowledgement-based loss detection implements the spirit of TCP's
Fast Retransmit [RFC5681], Early Retransmit [RFC5827], FACK [FACK],
Iyengar & Swett Expires December 23, 2019 [Page 11]
Internet-Draft QUIC Loss Detection June 2019
SACK loss recovery [RFC6675], and RACK [RACK]. This section provides
an overview of how these algorithms are implemented in QUIC.
A packet is declared lost if it meets all the following conditions:
o The packet is unacknowledged, in-flight, and was sent prior to an
acknowledged packet.
o Either its packet number is kPacketThreshold smaller than an
acknowledged packet (Section 6.1.1), or it was sent long enough in
the past (Section 6.1.2).
The acknowledgement indicates that a packet sent later was delivered,
while the packet and time thresholds provide some tolerance for
packet reordering.
Spuriously declaring packets as lost leads to unnecessary
retransmissions and may result in degraded performance due to the
actions of the congestion controller upon detecting loss.
Implementations that detect spurious retransmissions and increase the
reordering threshold in packets or time MAY choose to start with
smaller initial reordering thresholds to minimize recovery latency.
6.1.1. Packet Threshold
The RECOMMENDED initial value for the packet reordering threshold
(kPacketThreshold) is 3, based on best practices for TCP loss
detection [RFC5681] [RFC6675].
Some networks may exhibit higher degrees of reordering, causing a
sender to detect spurious losses. Implementers MAY use algorithms
developed for TCP, such as TCP-NCR [RFC4653], to improve QUIC's
reordering resilience.
6.1.2. Time Threshold
Once a later packet packet within the same packet number space has
been acknowledged, an endpoint SHOULD declare an earlier packet lost
if it was sent a threshold amount of time in the past. To avoid
declaring packets as lost too early, this time threshold MUST be set
to at least kGranularity. The time threshold is:
kTimeThreshold * max(SRTT, latest_RTT, kGranularity)
If packets sent prior to the largest acknowledged packet cannot yet
be declared lost, then a timer SHOULD be set for the remaining time.
Using max(SRTT, latest_RTT) protects from the two following cases:
Iyengar & Swett Expires December 23, 2019 [Page 12]
Internet-Draft QUIC Loss Detection June 2019
o the latest RTT sample is lower than the SRTT, perhaps due to
reordering where the acknowledgement encountered a shorter path;
o the latest RTT sample is higher than the SRTT, perhaps due to a
sustained increase in the actual RTT, but the smoothed SRTT has
not yet caught up.
The RECOMMENDED time threshold (kTimeThreshold), expressed as a
round-trip time multiplier, is 9/8.
Implementations MAY experiment with absolute thresholds, thresholds
from previous connections, adaptive thresholds, or including RTT
variance. Smaller thresholds reduce reordering resilience and
increase spurious retransmissions, and larger thresholds increase
loss detection delay.
6.2. Crypto Retransmission Timeout
Data in CRYPTO frames is critical to QUIC transport and crypto
negotiation, so a more aggressive timeout is used to retransmit it.
The initial crypto retransmission timeout SHOULD be set to twice the
initial RTT.
At the beginning, there are no prior RTT samples within a connection.
Resumed connections over the same network SHOULD use the previous
connection's final smoothed RTT value as the resumed connection's
initial RTT. If no previous RTT is available, or if the network
changes, the initial RTT SHOULD be set to 500ms, resulting in a 1
second initial handshake timeout as recommended in [RFC6298].
A connection MAY use the delay between sending a PATH_CHALLENGE and
receiving a PATH_RESPONSE to seed initial_rtt for a new path, but the
delay SHOULD NOT be considered an RTT sample.
When a crypto packet is sent, the sender MUST set a timer for twice
the smoothed RTT. This timer MUST be updated when a new crypto
packet is sent and when an acknowledgement is received which computes
a new RTT sample. Upon timeout, the sender MUST retransmit all
unacknowledged CRYPTO data if possible. The sender MUST NOT declare
in-flight crypto packets as lost when the crypto timer expires.
On each consecutive expiration of the crypto timer without receiving
an acknowledgement for a new packet, the sender MUST double the
crypto retransmission timeout and set a timer for this period.
Until the server has validated the client's address on the path, the
amount of data it can send is limited, as specified in Section 8.1 of
Iyengar & Swett Expires December 23, 2019 [Page 13]
Internet-Draft QUIC Loss Detection June 2019
[QUIC-TRANSPORT]. If not all unacknowledged CRYPTO data can be sent,
then all unacknowledged CRYPTO data sent in Initial packets should be
retransmitted. If no data can be sent, then no alarm should be armed
until data has been received from the client.
Because the server could be blocked until more packets are received,
the client MUST ensure that the crypto retransmission timer is set if
there is unacknowledged crypto data or if the client does not yet
have 1-RTT keys. If the crypto retransmission timer expires before
the client has 1-RTT keys, it is possible that the client may not
have any crypto data to retransmit. However, the client MUST send a
new packet, containing only PADDING frames if necessary, to allow the
server to continue sending data. If Handshake keys are available to
the client, it MUST send a Handshake packet, and otherwise it MUST
send an Initial packet in a UDP datagram of at least 1200 bytes.
Because packets only containing PADDING do not elicit an
acknowledgement, they may never be acknowledged, but they are removed
from bytes in flight when the client gets Handshake keys and the
Initial keys are discarded.
The crypto retransmission timer is not set if the time threshold
Section 6.1.2 loss detection timer is set. The time threshold loss
detection timer is expected to both expire earlier than the crypto
retransmission timeout and be less likely to spuriously retransmit
data. The Initial and Handshake packet number spaces will typically
contain a small number of packets, so losses are less likely to be
detected using packet-threshold loss detection.
When the crypto retransmission timer is active, the probe timer
(Section 6.3) is not active.
6.3. Probe Timeout
A Probe Timeout (PTO) triggers a probe packet when ack-eliciting data
is in flight but an acknowledgement is not received within the
expected period of time. A PTO enables a connection to recover from
loss of tail packets or acks. The PTO algorithm used in QUIC
implements the reliability functions of Tail Loss Probe [TLP] [RACK],
RTO [RFC5681] and F-RTO algorithms for TCP [RFC5682], and the timeout
computation is based on TCP's retransmission timeout period
[RFC6298].
6.3.1. Computing PTO
When an ack-eliciting packet is transmitted, the sender schedules a
timer for the PTO period as follows:
Iyengar & Swett Expires December 23, 2019 [Page 14]
Internet-Draft QUIC Loss Detection June 2019
PTO = smoothed_rtt + max(4*rttvar, kGranularity) + max_ack_delay
kGranularity, smoothed_rtt, rttvar, and max_ack_delay are defined in
Appendix A.2 and Appendix A.3.
The PTO period is the amount of time that a sender ought to wait for
an acknowledgement of a sent packet. This time period includes the
estimated network roundtrip-time (smoothed_rtt), the variance in the
estimate (4*rttvar), and max_ack_delay, to account for the maximum
time by which a receiver might delay sending an acknowledgement.
The PTO value MUST be set to at least kGranularity, to avoid the
timer expiring immediately.
When a PTO timer expires, the sender probes the network as described
in the next section. The PTO period MUST be set to twice its current
value. This exponential reduction in the sender's rate is important
because the PTOs might be caused by loss of packets or
acknowledgements due to severe congestion.
A sender computes its PTO timer every time an ack-eliciting packet is
sent. A sender might choose to optimize this by setting the timer
fewer times if it knows that more ack-eliciting packets will be sent
within a short period of time.
6.3.2. Sending Probe Packets
When a PTO timer expires, a sender MUST send at least one ack-
eliciting packet as a probe, unless there is no data available to
send. An endpoint MAY send up to two ack-eliciting packets, to avoid
an expensive consecutive PTO expiration due to a single packet loss.
It is possible that the sender has no new or previously-sent data to
send. As an example, consider the following sequence of events: new
application data is sent in a STREAM frame, deemed lost, then
retransmitted in a new packet, and then the original transmission is
acknowledged. In the absence of any new application data, a PTO
timer expiration now would find the sender with no new or previously-
sent data to send.
When there is no data to send, the sender SHOULD send a PING or other
ack-eliciting frame in a single packet, re-arming the PTO timer.
Alternatively, instead of sending an ack-eliciting packet, the sender
MAY mark any packets still in flight as lost. Doing so avoids
sending an additional packet, but increases the risk that loss is
declared too aggressively, resulting in an unnecessary rate reduction
by the congestion controller.
Iyengar & Swett Expires December 23, 2019 [Page 15]
Internet-Draft QUIC Loss Detection June 2019
Consecutive PTO periods increase exponentially, and as a result,
connection recovery latency increases exponentially as packets
continue to be dropped in the network. Sending two packets on PTO
expiration increases resilience to packet drops, thus reducing the
probability of consecutive PTO events.
Probe packets sent on a PTO MUST be ack-eliciting. A probe packet
SHOULD carry new data when possible. A probe packet MAY carry
retransmitted unacknowledged data when new data is unavailable, when
flow control does not permit new data to be sent, or to
opportunistically reduce loss recovery delay. Implementations MAY
use alternate strategies for determining the content of probe
packets, including sending new or retransmitted data based on the
application's priorities.
When the PTO timer expires multiple times and new data cannot be
sent, implementations must choose between sending the same payload
every time or sending different payloads. Sending the same payload
may be simpler and ensures the highest priority frames arrive first.
Sending different payloads each time reduces the chances of spurious
retransmission.
6.3.3. Loss Detection
Delivery or loss of packets in flight is established when an ACK
frame is received that newly acknowledges one or more packets.
A PTO timer expiration event does not indicate packet loss and MUST
NOT cause prior unacknowledged packets to be marked as lost. When an
acknowledgement is received that newly acknowledges packets, loss
detection proceeds as dictated by packet and time threshold
mechanisms; see Section 6.1.
6.4. Retry and Version Negotiation
A Retry or Version Negotiation packet causes a client to send another
Initial packet, effectively restarting the connection process and
resetting congestion control and loss recovery state, including
resetting any pending timers. Either packet indicates that the
Initial was received but not processed. Neither packet can be
treated as an acknowledgment for the Initial.
The client MAY however compute an RTT estimate to the server as the
time period from when the first Initial was sent to when a Retry or a
Version Negotiation packet is received. The client MAY use this
value to seed the RTT estimator for a subsequent connection attempt
to the server.
Iyengar & Swett Expires December 23, 2019 [Page 16]
Internet-Draft QUIC Loss Detection June 2019
6.5. Discarding Keys and Packet State
When packet protection keys are discarded (see Section 4.9 of
[QUIC-TLS]), all packets that were sent with those keys can no longer
be acknowledged because their acknowledgements cannot be processed
anymore. The sender MUST discard all recovery state associated with
those packets and MUST remove them from the count of bytes in flight.
Endpoints stop sending and receiving Initial packets once they start
exchanging Handshake packets (see Section 17.2.2.1 of
[QUIC-TRANSPORT]). At this point, recovery state for all in-flight
Initial packets is discarded.
When 0-RTT is rejected, recovery state for all in-flight 0-RTT
packets is discarded.
If a server accepts 0-RTT, but does not buffer 0-RTT packets that
arrive before Initial packets, early 0-RTT packets will be declared
lost, but that is expected to be infrequent.
It is expected that keys are discarded after packets encrypted with
them would be acknowledged or declared lost. Initial secrets however
might be destroyed sooner, as soon as handshake keys are available
(see Section 4.10 of [QUIC-TLS]).
6.6. Discussion
The majority of constants were derived from best common practices
among widely deployed TCP implementations on the internet.
Exceptions follow.
A shorter delayed ack time of 25ms was chosen because longer delayed
acks can delay loss recovery and for the small number of connections
where less than packet per 25ms is delivered, acking every packet is
beneficial to congestion control and loss recovery.
7. Congestion Control
QUIC's congestion control is based on TCP NewReno [RFC6582]. NewReno
is a congestion window based congestion control. QUIC specifies the
congestion window in bytes rather than packets due to finer control
and the ease of appropriate byte counting [RFC3465].
QUIC hosts MUST NOT send packets if they would increase
bytes_in_flight (defined in Appendix B.2) beyond the available
congestion window, unless the packet is a probe packet sent after a
PTO timer expires, as described in Section 6.3.
Iyengar & Swett Expires December 23, 2019 [Page 17]
Internet-Draft QUIC Loss Detection June 2019
Implementations MAY use other congestion control algorithms, such as
Cubic [RFC8312], and endpoints MAY use different algorithms from one
another. The signals QUIC provides for congestion control are
generic and are designed to support different algorithms.
7.1. Explicit Congestion Notification
If a path has been verified to support ECN, QUIC treats a Congestion
Experienced codepoint in the IP header as a signal of congestion.
This document specifies an endpoint's response when its peer receives
packets with the Congestion Experienced codepoint. As discussed in
[RFC8311], endpoints are permitted to experiment with other response
functions.
7.2. Slow Start
QUIC begins every connection in slow start and exits slow start upon
loss or upon increase in the ECN-CE counter. QUIC re-enters slow
start anytime the congestion window is less than ssthresh, which only
occurs after persistent congestion is declared. While in slow start,
QUIC increases the congestion window by the number of bytes
acknowledged when each acknowledgment is processed.
7.3. Congestion Avoidance
Slow start exits to congestion avoidance. Congestion avoidance in
NewReno uses an additive increase multiplicative decrease (AIMD)
approach that increases the congestion window by one maximum packet
size per congestion window acknowledged. When a loss is detected,
NewReno halves the congestion window and sets the slow start
threshold to the new congestion window.
7.4. Recovery Period
Recovery is a period of time beginning with detection of a lost
packet or an increase in the ECN-CE counter. Because QUIC does not
retransmit packets, it defines the end of recovery as a packet sent
after the start of recovery being acknowledged. This is slightly
different from TCP's definition of recovery, which ends when the lost
packet that started recovery is acknowledged.
The recovery period limits congestion window reduction to once per
round trip. During recovery, the congestion window remains unchanged
irrespective of new losses or increases in the ECN-CE counter.