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

Packet number encoding appendix #4315

Merged
merged 7 commits into from Nov 3, 2020
Merged
Changes from 1 commit
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
15 changes: 9 additions & 6 deletions draft-ietf-quic-transport.md
Expand Up @@ -7415,18 +7415,21 @@ The EncodePacketNumber function takes two arguments:

~~~
EncodePacketNumber(full_pn, largest_acked):
// If no packets in the current space have been
// acknowledged, the full packet number is used.
if largest_acked is None:
return full_pn

// The number of bits must be at least one more
// than the base-2 logarithm of the number of contiguous
// unacknowledged packet numbers, including the new packet.
num_unacked = full_pn - largest_acked
if largest_acked is None:
num_unacked = full_pn + 1
else:
num_unacked = full_pn - largest_acked

min_bits = log(num_unacked, 2) + 1
num_bytes = ceil(min_bits / 8)
return full_pn[-num_bytes:]

// Return the value after truncating the full packet number
// to num_bytes least-significant bytes
MikeBishop marked this conversation as resolved.
Show resolved Hide resolved
MikeBishop marked this conversation as resolved.
Show resolved Hide resolved
return truncate(full_pn, num_bytes)
MikeBishop marked this conversation as resolved.
Show resolved Hide resolved
~~~
{: #alg-encode-pn title="Sample Packet Number Encoding Algorithm"}

Expand Down