Draft: draft-ietf-quic-recovery

Commentary: This seems like an unwieldy PR , so I 'll state what I 've done . I 've simply moved all pseudocode to the appendix with no changes to text , except for the addition of a single sentence at the beginning of the appendices . It might be easier to see the rendered draft . Subsequent PRs will clean each part up . 
 This is a good start . I expect some of the text in the pseudocode sections will need to move up , but one step at a time .
Paragraph (version A):
To correctly implement congestion control, a QUIC sender tracks every
ack-eliciting packet until the packet is acknowledged or lost.  It is
expected that implementations will be able to access this information
by packet number and crypto context and store the per-packet fields
(sent-packets-fields) for loss recovery and congestion control.
Paragraph (version A):
After a packet is declared lost, it SHOULD be tracked for an amount
of time comparable to the maximum expected packet reordering, such as
1 RTT.  This allows for detection of spurious retransmissions.
Paragraph (version A):
Sent packets are tracked for each packet number space, and ACK
processing only applies to a single space.
Paragraph (version A):
The packet number of the sent packet.
Paragraph (version A):
A boolean that indicates whether a packet is ack-eliciting.  If
true, it is expected that an acknowledgement will be received,
though the peer could delay sending the ACK frame containing it by
up to the MaxAckDelay.
Paragraph (version A):
A boolean that indicates whether the packet counts towards bytes
in flight.
Paragraph (version A):
A boolean that indicates whether the packet contains cryptographic
handshake messages critical to the completion of the QUIC
handshake.  In this version of QUIC, this includes any packet with
the long header that includes a CRYPTO frame.
Paragraph (version A):
The number of bytes sent in the packet, not including UDP or IP
overhead, but including QUIC framing overhead.
Paragraph (version A):
The time the packet was sent.
Paragraph (version A):
Constants used in loss recovery are based on a combination of RFCs,
papers, and common practice.  Some may need to be changed or
negotiated in order to better suit a variety of environments.
Paragraph (version A):
Maximum reordering in packets before packet threshold loss
detection considers a packet lost.  The RECOMMENDED value is 3.
Paragraph (version A):
Maximum reordering in time before time threshold loss detection
considers a packet lost.  Specified as an RTT multiplier.  The
RECOMMENDED value is 9/8.
Paragraph (version A):
Timer granularity.  This is a system-dependent value.  However,
implementations SHOULD use a value no smaller than 1ms.
Paragraph (version A):
The RTT used before an RTT sample is taken.  The RECOMMENDED value
is 100ms.
Paragraph (version A):
Multi-modal timer used for loss detection.
Paragraph (version A):
The number of times all unacknowledged CRYPTO data has been
retransmitted without receiving an ack.
Paragraph (version A):
The number of times a PTO has been sent without receiving an ack.
Paragraph (version A):
The time the most recent ack-eliciting packet was sent.
Paragraph (version A):
The time the most recent crypto packet was sent.
Paragraph (version A):
The packet number of the most recently sent packet.
Paragraph (version A):
The largest packet number acknowledged in the packet number space
so far.
Paragraph (version A):
The most recent RTT measurement made when receiving an ack for a
previously unacked packet.
Paragraph (version A):
The minimum RTT seen in the connection, ignoring ack delay.
Paragraph (version A):
The maximum amount of time by which the receiver intends to delay
acknowledgments, in milliseconds.  The actual ack_delay in a
received ACK frame may be larger due to late timers, reordering,
or lost ACKs.
Paragraph (version A):
The time at which the next packet will be considered lost based on
exceeding the reordering window in time.
Paragraph (version A):
An association of packet numbers to information about them.
Described in detail above in tracking-sent-packets.
Paragraph (version A):
After a packet is sent, information about the packet is stored.  The
parameters to OnPacketSent are described in detail above in sent-
packets-fields.
Paragraph (version A):
When an ACK frame is received, it may newly acknowledge any number of
packets.
Paragraph (version A):
When a packet is acknowledged for the first time, the following
OnPacketAcked function is called.  Note that a single ACK frame may
newly acknowledge several packets.  OnPacketAcked must be called once
for each of these newly acknowledged packets.
Paragraph (version A):
OnPacketAcked takes one parameter, acked_packet, which is the struct
detailed in sent-packets-fields.
Paragraph (version A):
QUIC loss detection uses a single timer for all timeout loss
detection.  The duration of the timer is based on the timer's mode,
which is set in the packet and timer events further below.  The
function SetLossDetectionTimer defined below shows how the single
timer is set.
Paragraph (version A):
This algorithm may result in the timer being set in the past,
particularly if timers wake up late.  Timers set in the past SHOULD
fire immediately.
Paragraph (version A):
When the loss detection timer expires, the timer's mode determines
the action to be performed.
Paragraph (version A):
DetectLostPackets is called every time an ACK is received and
operates on the sent_packets for that packet number space.  If the
loss detection timer expires and the loss_time is set, the previous
largest acknowledged packet is supplied.
Paragraph (version A):
Constants used in congestion control are based on a combination of
RFCs, papers, and common practice.  Some may need to be changed or
negotiated in order to better suit a variety of environments.
Paragraph (version A):
The sender's maximum payload size.  Does not include UDP or IP
overhead.  The max packet size is used for calculating initial and
minimum congestion windows.  The RECOMMENDED value is 1200 bytes.
Paragraph (version A):
Default limit on the initial amount of data in flight, in bytes.
Taken from RFC6928.  The RECOMMENDED value is the minimum of 10 *
kMaxDatagramSize and max(2* kMaxDatagramSize, 14600)).
Paragraph (version A):
Minimum congestion window in bytes.  The RECOMMENDED value is 2 *
kMaxDatagramSize.
Paragraph (version A):
Reduction in congestion window when a new loss event is detected.
The RECOMMENDED value is 0.5.
Paragraph (version A):
Number of consecutive PTOs required for persistent congestion to
be established.  The rationale for this threshold is to enable a
sender to use initial PTOs for aggressive probing, as TCP does
with Tail Loss Probe (TLP) TLP RACK, before establishing
persistent congestion, as TCP does with a Retransmission Timeout
(RTO) RFC5681.  The RECOMMENDED value for
kPersistentCongestionThreshold is 2, which is equivalent to having
two TLPs before an RTO in TCP.
Paragraph (version A):
The highest value reported for the ECN-CE counter by the peer in
an ACK frame.  This variable is used to detect increases in the
reported ECN-CE counter.
Paragraph (version A):
The sum of the size in bytes of all sent packets that contain at
least one ack-eliciting or PADDING frame, and have not been acked
or declared lost.  The size does not include IP or UDP overhead,
but does include the QUIC header and AEAD overhead.  Packets only
containing ACK frames do not count towards bytes_in_flight to
ensure congestion control does not impede congestion feedback.
Paragraph (version A):
Maximum number of bytes-in-flight that may be sent.
Paragraph (version A):
The time when QUIC first detects a loss, causing it to enter
recovery.  When a packet sent after this time is acknowledged,
QUIC exits recovery.
Paragraph (version A):
Slow start threshold in bytes.  When the congestion window is
below ssthresh, the mode is slow start and the window grows by the
number of bytes acknowledged.
Paragraph (version A):
Whenever a packet is sent, and it contains non-ACK frames, the packet
increases bytes_in_flight.
Paragraph (version A):
Invoked from loss detection's OnPacketAcked and is supplied with the
acked_packet from sent_packets.
Paragraph (version A):
Invoked from ProcessECN and OnPacketsLost when a new congestion event
is detected.  May start a new recovery period and reduces the
congestion window.
Paragraph (version A):
Invoked when an ACK frame with an ECN section is received from the
peer.
Paragraph (version A):
Invoked by loss detection from DetectLostPackets when new packets are
detected lost.