Skip to content

Main content

QUIC Varint Leading Length Bits Tool

Compute quic varint leading length bits from explicit bounded inputs.

Loading tool…

Description

Read the top two bits of firstOctet as an exponent.

QUIC uses compact fields and truncated packet numbers. Their interpretation depends on the unprotected header bits and connection state; decoding a number does not authenticate a packet.

Read the top two bits of firstOctet as an exponent.

When to use this tool

Use QUIC Varint Leading Length Bits when you need one QUIC field interpretation from already available bytes or state.

How to use the tool and how it works

  1. Enter firstOctet. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read lengthBytes, payloadBits. Use the output convention below.

Read the top two bits of firstOctet as an exponent. Return 2 raised to that exponent as lengthBytes and 8 × lengthBytes - 2 as payloadBits.1

Input fieldMeaning and unitsAccepted input
firstOctetFirst OctetRequired. Safe integer; minimum 0; maximum 255.
Output fieldInterpretationReturned shape
lengthBytesLength BytesRequired. Safe integer.
payloadBitsPayload BitsRequired. Safe integer.
json
{
  "input": {
    "firstOctet": 192
  },
  "output": {
    "lengthBytes": 8,
    "payloadBits": 62
  }
}

Limitations and assumptions

  • Only the length prefix is decoded; the remaining bytes and value are not read.
  • Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.
  • Numeric calculations use binary floating point unless exact decimal-integer arithmetic is explicitly stated. No hidden measurement tolerance or decimal rounding is added; nonfinite or out-of-contract results are rejected. Numeric signed-zero results are exported as zero.

Alternative or Complementary methods

Use a complete QUIC implementation to remove header protection, track packet state, and authenticate payloads.

References

  1. Calculation and input contract: network/quic-varint-leading-length-bits — tool.io

Similar or alternative tools