Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove indent from all pseudocode #4012

Merged
merged 2 commits into from Aug 18, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
208 changes: 102 additions & 106 deletions draft-ietf-quic-recovery.md
Expand Up @@ -1081,11 +1081,11 @@ kPacketNumberSpace:
: An enum to enumerate the three packet number spaces.

~~~
enum kPacketNumberSpace {
Initial,
Handshake,
ApplicationData,
}
enum kPacketNumberSpace {
Initial,
Handshake,
ApplicationData,
}
~~~

## Variables of interest {#ld-vars-of-interest}
Expand Down Expand Up @@ -1141,17 +1141,17 @@ At the beginning of the connection, initialize the loss detection variables as
follows:

~~~
loss_detection_timer.reset()
pto_count = 0
latest_rtt = 0
smoothed_rtt = kInitialRtt
rttvar = kInitialRtt / 2
min_rtt = 0
max_ack_delay = 0
for pn_space in [ Initial, Handshake, ApplicationData ]:
largest_acked_packet[pn_space] = infinite
time_of_last_ack_eliciting_packet[pn_space] = 0
loss_time[pn_space] = 0
loss_detection_timer.reset()
pto_count = 0
latest_rtt = 0
smoothed_rtt = kInitialRtt
rttvar = kInitialRtt / 2
min_rtt = 0
max_ack_delay = 0
for pn_space in [ Initial, Handshake, ApplicationData ]:
largest_acked_packet[pn_space] = infinite
time_of_last_ack_eliciting_packet[pn_space] = 0
loss_time[pn_space] = 0
~~~


Expand All @@ -1163,21 +1163,21 @@ to OnPacketSent are described in detail above in {{sent-packets-fields}}.
Pseudocode for OnPacketSent follows:

~~~
OnPacketSent(packet_number, pn_space, ack_eliciting,
in_flight, sent_bytes):
sent_packets[pn_space][packet_number].packet_number =
packet_number
sent_packets[pn_space][packet_number].time_sent = now()
sent_packets[pn_space][packet_number].ack_eliciting =
ack_eliciting
sent_packets[pn_space][packet_number].in_flight = in_flight
if (in_flight):
if (ack_eliciting):
time_of_last_ack_eliciting_packet[pn_space] = now()
OnPacketSentCC(sent_bytes)
sent_packets[pn_space][packet_number].sent_bytes =
sent_bytes
SetLossDetectionTimer()
OnPacketSent(packet_number, pn_space, ack_eliciting,
in_flight, sent_bytes):
sent_packets[pn_space][packet_number].packet_number =
packet_number
sent_packets[pn_space][packet_number].time_sent = now()
sent_packets[pn_space][packet_number].ack_eliciting =
ack_eliciting
sent_packets[pn_space][packet_number].in_flight = in_flight
if (in_flight):
if (ack_eliciting):
time_of_last_ack_eliciting_packet[pn_space] = now()
OnPacketSentCC(sent_bytes)
sent_packets[pn_space][packet_number].sent_bytes =
sent_bytes
SetLossDetectionTimer()
~~~

## On Receiving a Datagram
Expand Down Expand Up @@ -1510,12 +1510,12 @@ At the beginning of the connection, initialize the congestion control
variables as follows:

~~~
congestion_window = kInitialWindow
bytes_in_flight = 0
congestion_recovery_start_time = 0
ssthresh = infinite
for pn_space in [ Initial, Handshake, ApplicationData ]:
ecn_ce_counters[pn_space] = 0
congestion_window = kInitialWindow
bytes_in_flight = 0
congestion_recovery_start_time = 0
ssthresh = infinite
for pn_space in [ Initial, Handshake, ApplicationData ]:
ecn_ce_counters[pn_space] = 0
~~~


Expand All @@ -1525,8 +1525,8 @@ Whenever a packet is sent, and it contains non-ACK frames, the packet
increases bytes_in_flight.

~~~
OnPacketSentCC(bytes_sent):
bytes_in_flight += bytes_sent
OnPacketSentCC(bytes_sent):
bytes_in_flight += bytes_sent
~~~


Expand All @@ -1536,34 +1536,31 @@ Invoked from loss detection's OnAckReceived and is supplied with the
newly acked_packets from sent_packets.

~~~
InCongestionRecovery(sent_time):
return sent_time <= congestion_recovery_start_time

OnPacketsAcked(acked_packets):
for acked_packet in acked_packets:
OnPacketAcked(acked_packet)

OnPacketAcked(acked_packet):
// Remove from bytes_in_flight.
bytes_in_flight -= acked_packet.sent_bytes

// Do not increase congestion_window if application
// limited or flow control limited.
if (IsAppOrFlowControlLimited())
return

// Do not increase congestion window in recovery period.
if (InCongestionRecovery(acked_packet.time_sent)):
return

if (congestion_window < ssthresh):
// Slow start.
congestion_window += acked_packet.sent_bytes
else:
// Congestion avoidance.
congestion_window +=
max_datagram_size * acked_packet.sent_bytes
/ congestion_window
InCongestionRecovery(sent_time):
return sent_time <= congestion_recovery_start_time

OnPacketsAcked(acked_packets):
martinthomson marked this conversation as resolved.
Show resolved Hide resolved
for acked_packet in acked_packets:
OnPacketAcked(acked_packet)

OnPacketAcked(acked_packet):
martinthomson marked this conversation as resolved.
Show resolved Hide resolved
// Remove from bytes_in_flight.
bytes_in_flight -= acked_packet.sent_bytes
// Do not increase congestion_window if application
// limited or flow control limited.
if (IsAppOrFlowControlLimited())
return
// Do not increase congestion window in recovery period.
if (InCongestionRecovery(acked_packet.time_sent)):
return
if (congestion_window < ssthresh):
// Slow start.
congestion_window += acked_packet.sent_bytes
else:
// Congestion avoidance.
congestion_window +=
max_datagram_size * acked_packet.sent_bytes
/ congestion_window
~~~


Expand All @@ -1574,16 +1571,16 @@ detected. May start a new recovery period and reduces the congestion
window.

~~~
OnCongestionEvent(sent_time):
// Start a new congestion event if packet was sent after the
// start of the previous congestion recovery period.
if (!InCongestionRecovery(sent_time)):
congestion_recovery_start_time = now()
congestion_window *= kLossReductionFactor
congestion_window = max(congestion_window, kMinimumWindow)
ssthresh = congestion_window
// A packet can be sent to speed up loss recovery.
MaybeSendOnePacket()
OnCongestionEvent(sent_time):
// Start a new congestion event if packet was sent after the
// start of the previous congestion recovery period.
if (!InCongestionRecovery(sent_time)):
congestion_recovery_start_time = now()
congestion_window *= kLossReductionFactor
congestion_window = max(congestion_window, kMinimumWindow)
ssthresh = congestion_window
// A packet can be sent to speed up loss recovery.
MaybeSendOnePacket()
~~~


Expand All @@ -1592,13 +1589,13 @@ window.
Invoked when an ACK frame with an ECN section is received from the peer.

~~~
ProcessECN(ack, pn_space):
// If the ECN-CE counter reported by the peer has increased,
// this could be a new congestion event.
if (ack.ce_counter > ecn_ce_counters[pn_space]):
ecn_ce_counters[pn_space] = ack.ce_counter
sent_time = sent_packets[ack.largest_acked].time_sent
OnCongestionEvent(sent_time)
ProcessECN(ack, pn_space):
// If the ECN-CE counter reported by the peer has increased,
// this could be a new congestion event.
if (ack.ce_counter > ecn_ce_counters[pn_space]):
ecn_ce_counters[pn_space] = ack.ce_counter
sent_time = sent_packets[ack.largest_acked].time_sent
OnCongestionEvent(sent_time)
~~~


Expand All @@ -1607,28 +1604,27 @@ Invoked when an ACK frame with an ECN section is received from the peer.
Invoked when DetectAndRemoveLostPackets deems packets lost.

~~~
InPersistentCongestion(largest_lost):
// Persistent congestion cannot be declared on the
// first RTT sample.
if (is first RTT sample):
return false
pto = smoothed_rtt + max(4 * rttvar, kGranularity) +
max_ack_delay
congestion_period = pto * kPersistentCongestionThreshold
// Determine if all packets in the time period before the
// largest newly lost packet, including the edges and
// across all packet number spaces, are marked lost.
return AreAllPacketsLost(largest_lost, congestion_period)

OnPacketsLost(lost_packets):
// Remove lost packets from bytes_in_flight.
for lost_packet in lost_packets:
bytes_in_flight -= lost_packet.sent_bytes
OnCongestionEvent(lost_packets.largest().time_sent)

// Collapse congestion window if persistent congestion
if (InPersistentCongestion(lost_packets.largest())):
congestion_window = kMinimumWindow
InPersistentCongestion(largest_lost):
// Persistent congestion cannot be declared on the
// first RTT sample.
if (is first RTT sample):
return false
pto = smoothed_rtt + max(4 * rttvar, kGranularity) +
max_ack_delay
congestion_period = pto * kPersistentCongestionThreshold
// Determine if all packets in the time period before the
// largest newly lost packet, including the edges and
// across all packet number spaces, are marked lost.
return AreAllPacketsLost(largest_lost, congestion_period)

OnPacketsLost(lost_packets):
martinthomson marked this conversation as resolved.
Show resolved Hide resolved
// Remove lost packets from bytes_in_flight.
for lost_packet in lost_packets:
bytes_in_flight -= lost_packet.sent_bytes
OnCongestionEvent(lost_packets.largest().time_sent)
// Collapse congestion window if persistent congestion
if (InPersistentCongestion(lost_packets.largest())):
congestion_window = kMinimumWindow
~~~

## Upon dropping Initial or Handshake keys
Expand Down