Record Class TransportParameters

java.lang.Object
java.lang.Record
io.github.mahmoudimus.quic.params.TransportParameters
Record Components:
originalDestinationConnectionId - server only: the Destination Connection ID of the client's first Initial, or null
maxIdleTimeout - the idle timeout in milliseconds, 0 to disable
statelessResetToken - server only: the reset token for the server's handshake connection ID, or null
maxUdpPayloadSize - the largest UDP payload the endpoint will receive, at least 1200
initialMaxData - the initial connection flow control limit
initialMaxStreamDataBidiLocal - the initial limit for bidirectional streams the endpoint opens
initialMaxStreamDataBidiRemote - the initial limit for bidirectional streams the peer opens
initialMaxStreamDataUni - the initial limit for unidirectional streams the peer opens
initialMaxStreamsBidi - how many bidirectional streams the peer may open, at most 260
initialMaxStreamsUni - how many unidirectional streams the peer may open, at most 260
ackDelayExponent - the exponent of the ACK Delay field, at most 20
maxAckDelay - the most milliseconds the endpoint delays acknowledgments, below 214
disableActiveMigration - whether the endpoint refuses active connection migration
preferredAddress - server only: an address to migrate to, or null
activeConnectionIdLimit - how many connection IDs the endpoint will store, at least 2
initialSourceConnectionId - the Source Connection ID of the endpoint's first Initial, or null
retrySourceConnectionId - server only: the Source Connection ID of the server's Retry, or null
maxDatagramFrameSize - the largest DATAGRAM frame the endpoint accepts, 0 if it accepts none (RFC 9221)
greaseQuicBit - whether the endpoint accepts packets with the Fixed Bit cleared (RFC 9287)
minAckDelay - the smallest ACK delay in microseconds the endpoint supports, or -1 if it does not support the ACK frequency extension
versionInformation - the version information (RFC 9368), or null
unknownParameters - parameters this module does not interpret, in order

public record TransportParameters(ConnectionId originalDestinationConnectionId, long maxIdleTimeout, StatelessResetToken statelessResetToken, long maxUdpPayloadSize, long initialMaxData, long initialMaxStreamDataBidiLocal, long initialMaxStreamDataBidiRemote, long initialMaxStreamDataUni, long initialMaxStreamsBidi, long initialMaxStreamsUni, long ackDelayExponent, long maxAckDelay, boolean disableActiveMigration, PreferredAddress preferredAddress, long activeConnectionIdLimit, ConnectionId initialSourceConnectionId, ConnectionId retrySourceConnectionId, long maxDatagramFrameSize, boolean greaseQuicBit, long minAckDelay, VersionInformation versionInformation, List<UnknownParameter> unknownParameters) extends Record
QUIC transport parameters (RFC 9000 section 18), with the extensions max_datagram_frame_size (RFC 9221), grease_quic_bit (RFC 9287), version_information (RFC 9368) and the ACK frequency draft's min_ack_delay.

Absent parameters take their RFC defaults: max_udp_payload_size 65527, ack_delay_exponent 3, max_ack_delay 25 ms, active_connection_id_limit 2, and 0, false or null otherwise (minAckDelay is -1 when absent). Integer parameters equal to their defaults are not encoded.

decode(java.nio.ByteBuffer, boolean) rejects, with TRANSPORT_PARAMETER_ERROR: malformed values, duplicate parameters, values outside RFC 9000's limits, server-only parameters from a client, and invalid version information. Unknown and reserved (GREASE) parameters are kept in unknownParameters(). Instances are immutable.

  • Field Details

    • DEFAULT_MAX_UDP_PAYLOAD_SIZE

      public static final long DEFAULT_MAX_UDP_PAYLOAD_SIZE
      The default max_udp_payload_size: the largest UDP payload.
      See Also:
    • DEFAULT_ACK_DELAY_EXPONENT

      public static final long DEFAULT_ACK_DELAY_EXPONENT
      The default ack_delay_exponent.
      See Also:
    • DEFAULT_MAX_ACK_DELAY

      public static final long DEFAULT_MAX_ACK_DELAY
      The default max_ack_delay, in milliseconds.
      See Also:
    • DEFAULT_ACTIVE_CONNECTION_ID_LIMIT

      public static final long DEFAULT_ACTIVE_CONNECTION_ID_LIMIT
      The default and smallest active_connection_id_limit.
      See Also:
    • MIN_UDP_PAYLOAD_SIZE

      public static final long MIN_UDP_PAYLOAD_SIZE
      The smallest valid max_udp_payload_size.
      See Also:
    • MAX_ACK_DELAY_EXPONENT

      public static final long MAX_ACK_DELAY_EXPONENT
      The largest valid ack_delay_exponent.
      See Also:
    • MAX_ACK_DELAY_LIMIT

      public static final long MAX_ACK_DELAY_LIMIT
      The smallest invalid max_ack_delay, 214 milliseconds.
      See Also:
    • MAX_STREAM_COUNT

      public static final long MAX_STREAM_COUNT
      The largest valid stream count, 260.
      See Also:
  • Constructor Details

    • TransportParameters

      public TransportParameters(ConnectionId originalDestinationConnectionId, long maxIdleTimeout, StatelessResetToken statelessResetToken, long maxUdpPayloadSize, long initialMaxData, long initialMaxStreamDataBidiLocal, long initialMaxStreamDataBidiRemote, long initialMaxStreamDataUni, long initialMaxStreamsBidi, long initialMaxStreamsUni, long ackDelayExponent, long maxAckDelay, boolean disableActiveMigration, PreferredAddress preferredAddress, long activeConnectionIdLimit, ConnectionId initialSourceConnectionId, ConnectionId retrySourceConnectionId, long maxDatagramFrameSize, boolean greaseQuicBit, long minAckDelay, VersionInformation versionInformation, List<UnknownParameter> unknownParameters)
      Transport parameters.
      Parameters:
      originalDestinationConnectionId - the original Destination Connection ID, or null
      maxIdleTimeout - the idle timeout in milliseconds
      statelessResetToken - the stateless reset token, or null
      maxUdpPayloadSize - the largest UDP payload
      initialMaxData - the connection flow control limit
      initialMaxStreamDataBidiLocal - the limit for local bidirectional streams
      initialMaxStreamDataBidiRemote - the limit for remote bidirectional streams
      initialMaxStreamDataUni - the limit for unidirectional streams
      initialMaxStreamsBidi - the bidirectional stream count limit
      initialMaxStreamsUni - the unidirectional stream count limit
      ackDelayExponent - the ACK delay exponent
      maxAckDelay - the maximum ACK delay in milliseconds
      disableActiveMigration - whether active migration is disabled
      preferredAddress - the preferred address, or null
      activeConnectionIdLimit - the active connection ID limit
      initialSourceConnectionId - the initial Source Connection ID, or null
      retrySourceConnectionId - the Retry Source Connection ID, or null
      maxDatagramFrameSize - the largest DATAGRAM frame, 0 for none
      greaseQuicBit - whether a cleared Fixed Bit is accepted
      minAckDelay - the minimum ACK delay in microseconds, or -1
      versionInformation - the version information, or null
      unknownParameters - the uninterpreted parameters
  • Method Details

    • defaults

      public static TransportParameters defaults()
      The parameters a peer is assumed to have when it sends none: all defaults.
      Returns:
      the defaults
    • builder

      public static TransportParameters.Builder builder()
      A builder starting from the defaults.
      Returns:
      the builder
    • toBuilder

      public TransportParameters.Builder toBuilder()
      A builder starting from these parameters.
      Returns:
      the builder
    • forZeroRtt

      public TransportParameters forZeroRtt()
      The parameters a client remembers from a session for 0-RTT (RFC 9000 section 7.4.1), as quinn keeps them: the flow control and stream limits, the idle timeout, the payload size, the connection ID limit and DATAGRAM support, but not the connection IDs, the reset token, the preferred address or the ACK delay parameters, which belong to one connection.
      Returns:
      the parameters to use until the server's new ones arrive
    • allowsResumptionFrom

      public boolean allowsResumptionFrom(TransportParameters remembered)
      Whether a server whose parameters these are may accept 0-RTT from a client that remembers remembered (RFC 9000 section 7.4.1): none of the limits the client may use in 0-RTT is smaller now than then.
      Parameters:
      remembered - the parameters the server had when it issued the ticket
      Returns:
      true if 0-RTT data within the remembered limits is within these
    • validateResumptionFrom

      public void validateResumptionFrom(TransportParameters remembered) throws QuicException
      Checks, on a client whose 0-RTT data the server accepted, that the server's new parameters allow all it may have sent under the remembered ones (quinn's validate_resumption_from).
      Parameters:
      remembered - the parameters the client used for 0-RTT
      Throws:
      QuicException - PROTOCOL_VIOLATION if the server lowered a limit
    • encodedLength

      public int encodedLength()
      The encoded length.
      Returns:
      the bytes encode(ByteBuffer) writes
    • encode

      public byte[] encode()
      Encodes the parameters, in ID order with unknown parameters last.
      Returns:
      the encoded bytes, the quic_transport_parameters TLS extension value
    • encode

      public void encode(ByteBuffer out)
      Encodes the parameters at the buffer's position.
      Parameters:
      out - the buffer
      Throws:
      BufferOverflowException - if the buffer has too little room
    • decode

      public static TransportParameters decode(ByteBuffer in, boolean sentByServer) throws QuicException
      Decodes and validates the peer's transport parameters.
      Parameters:
      in - the encoded parameters between position and limit; the position moves to the limit on success
      sentByServer - whether the peer is the server, which allows the server-only parameters
      Returns:
      the parameters, with defaults for those absent
      Throws:
      QuicException - with TRANSPORT_PARAMETER_ERROR if the parameters are malformed, duplicated, out of range or not allowed from the peer's role
    • decode

      public static TransportParameters decode(byte[] encoded, boolean sentByServer) throws QuicException
      Decodes and validates the peer's transport parameters from an array.
      Parameters:
      encoded - the encoded parameters
      sentByServer - whether the peer is the server
      Returns:
      the parameters
      Throws:
      QuicException - with TRANSPORT_PARAMETER_ERROR if they are invalid
    • authenticateConnectionIds

      public void authenticateConnectionIds(boolean sentByServer, ConnectionId peerInitialSourceId, ConnectionId originalDestinationId, ConnectionId retrySourceId) throws QuicException
      Authenticates the connection IDs of the handshake (RFC 9000 section 7.3): both endpoints must send initial_source_connection_id matching the Source Connection ID of their first Initial; a server must send original_destination_connection_id, and retry_source_connection_id if and only if it sent a Retry.
      Parameters:
      sentByServer - whether these are the server's parameters
      peerInitialSourceId - the Source Connection ID of the peer's first Initial packet
      originalDestinationId - for a server's parameters, the Destination Connection ID of the client's first Initial; ignored for a client's
      retrySourceId - for a server's parameters, the Source Connection ID of the Retry the client processed, or null if none; ignored for a client's
      Throws:
      QuicException - with TRANSPORT_PARAMETER_ERROR if a parameter is missing, unexpected or different
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • originalDestinationConnectionId

      public ConnectionId originalDestinationConnectionId()
      Returns the value of the originalDestinationConnectionId record component.
      Returns:
      the value of the originalDestinationConnectionId record component
    • maxIdleTimeout

      public long maxIdleTimeout()
      Returns the value of the maxIdleTimeout record component.
      Returns:
      the value of the maxIdleTimeout record component
    • statelessResetToken

      public StatelessResetToken statelessResetToken()
      Returns the value of the statelessResetToken record component.
      Returns:
      the value of the statelessResetToken record component
    • maxUdpPayloadSize

      public long maxUdpPayloadSize()
      Returns the value of the maxUdpPayloadSize record component.
      Returns:
      the value of the maxUdpPayloadSize record component
    • initialMaxData

      public long initialMaxData()
      Returns the value of the initialMaxData record component.
      Returns:
      the value of the initialMaxData record component
    • initialMaxStreamDataBidiLocal

      public long initialMaxStreamDataBidiLocal()
      Returns the value of the initialMaxStreamDataBidiLocal record component.
      Returns:
      the value of the initialMaxStreamDataBidiLocal record component
    • initialMaxStreamDataBidiRemote

      public long initialMaxStreamDataBidiRemote()
      Returns the value of the initialMaxStreamDataBidiRemote record component.
      Returns:
      the value of the initialMaxStreamDataBidiRemote record component
    • initialMaxStreamDataUni

      public long initialMaxStreamDataUni()
      Returns the value of the initialMaxStreamDataUni record component.
      Returns:
      the value of the initialMaxStreamDataUni record component
    • initialMaxStreamsBidi

      public long initialMaxStreamsBidi()
      Returns the value of the initialMaxStreamsBidi record component.
      Returns:
      the value of the initialMaxStreamsBidi record component
    • initialMaxStreamsUni

      public long initialMaxStreamsUni()
      Returns the value of the initialMaxStreamsUni record component.
      Returns:
      the value of the initialMaxStreamsUni record component
    • ackDelayExponent

      public long ackDelayExponent()
      Returns the value of the ackDelayExponent record component.
      Returns:
      the value of the ackDelayExponent record component
    • maxAckDelay

      public long maxAckDelay()
      Returns the value of the maxAckDelay record component.
      Returns:
      the value of the maxAckDelay record component
    • disableActiveMigration

      public boolean disableActiveMigration()
      Returns the value of the disableActiveMigration record component.
      Returns:
      the value of the disableActiveMigration record component
    • preferredAddress

      public PreferredAddress preferredAddress()
      Returns the value of the preferredAddress record component.
      Returns:
      the value of the preferredAddress record component
    • activeConnectionIdLimit

      public long activeConnectionIdLimit()
      Returns the value of the activeConnectionIdLimit record component.
      Returns:
      the value of the activeConnectionIdLimit record component
    • initialSourceConnectionId

      public ConnectionId initialSourceConnectionId()
      Returns the value of the initialSourceConnectionId record component.
      Returns:
      the value of the initialSourceConnectionId record component
    • retrySourceConnectionId

      public ConnectionId retrySourceConnectionId()
      Returns the value of the retrySourceConnectionId record component.
      Returns:
      the value of the retrySourceConnectionId record component
    • maxDatagramFrameSize

      public long maxDatagramFrameSize()
      Returns the value of the maxDatagramFrameSize record component.
      Returns:
      the value of the maxDatagramFrameSize record component
    • greaseQuicBit

      public boolean greaseQuicBit()
      Returns the value of the greaseQuicBit record component.
      Returns:
      the value of the greaseQuicBit record component
    • minAckDelay

      public long minAckDelay()
      Returns the value of the minAckDelay record component.
      Returns:
      the value of the minAckDelay record component
    • versionInformation

      public VersionInformation versionInformation()
      Returns the value of the versionInformation record component.
      Returns:
      the value of the versionInformation record component
    • unknownParameters

      public List<UnknownParameter> unknownParameters()
      Returns the value of the unknownParameters record component.
      Returns:
      the value of the unknownParameters record component