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 nullmaxIdleTimeout- the idle timeout in milliseconds, 0 to disablestatelessResetToken- server only: the reset token for the server's handshake connection ID, or nullmaxUdpPayloadSize- the largest UDP payload the endpoint will receive, at least 1200initialMaxData- the initial connection flow control limitinitialMaxStreamDataBidiLocal- the initial limit for bidirectional streams the endpoint opensinitialMaxStreamDataBidiRemote- the initial limit for bidirectional streams the peer opensinitialMaxStreamDataUni- the initial limit for unidirectional streams the peer opensinitialMaxStreamsBidi- how many bidirectional streams the peer may open, at most 260initialMaxStreamsUni- how many unidirectional streams the peer may open, at most 260ackDelayExponent- the exponent of the ACK Delay field, at most 20maxAckDelay- the most milliseconds the endpoint delays acknowledgments, below 214disableActiveMigration- whether the endpoint refuses active connection migrationpreferredAddress- server only: an address to migrate to, or nullactiveConnectionIdLimit- how many connection IDs the endpoint will store, at least 2initialSourceConnectionId- the Source Connection ID of the endpoint's first Initial, or nullretrySourceConnectionId- server only: the Source Connection ID of the server's Retry, or nullmaxDatagramFrameSize- 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 extensionversionInformation- the version information (RFC 9368), or nullunknownParameters- 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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuildsTransportParameters, starting from the defaults. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longThe defaultack_delay_exponent.static final longThe default and smallestactive_connection_id_limit.static final longThe defaultmax_ack_delay, in milliseconds.static final longThe defaultmax_udp_payload_size: the largest UDP payload.static final longThe largest validack_delay_exponent.static final longThe smallest invalidmax_ack_delay, 214 milliseconds.static final longThe largest valid stream count, 260.static final longThe smallest validmax_udp_payload_size. -
Constructor Summary
ConstructorsConstructorDescriptionTransportParameters(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. -
Method Summary
Modifier and TypeMethodDescriptionlongReturns the value of theackDelayExponentrecord component.longReturns the value of theactiveConnectionIdLimitrecord component.booleanallowsResumptionFrom(TransportParameters remembered) Whether a server whose parameters these are may accept 0-RTT from a client that remembersremembered(RFC 9000 section 7.4.1): none of the limits the client may use in 0-RTT is smaller now than then.voidauthenticateConnectionIds(boolean sentByServer, ConnectionId peerInitialSourceId, ConnectionId originalDestinationId, ConnectionId retrySourceId) Authenticates the connection IDs of the handshake (RFC 9000 section 7.3): both endpoints must sendinitial_source_connection_idmatching the Source Connection ID of their first Initial; a server must sendoriginal_destination_connection_id, andretry_source_connection_idif and only if it sent a Retry.static TransportParameters.Builderbuilder()A builder starting from the defaults.static TransportParametersdecode(byte[] encoded, boolean sentByServer) Decodes and validates the peer's transport parameters from an array.static TransportParametersdecode(ByteBuffer in, boolean sentByServer) Decodes and validates the peer's transport parameters.static TransportParametersdefaults()The parameters a peer is assumed to have when it sends none: all defaults.booleanReturns the value of thedisableActiveMigrationrecord component.byte[]encode()Encodes the parameters, in ID order with unknown parameters last.voidencode(ByteBuffer out) Encodes the parameters at the buffer's position.intThe encoded length.final booleanIndicates whether some other object is "equal to" this one.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.booleanReturns the value of thegreaseQuicBitrecord component.final inthashCode()Returns a hash code value for this object.longReturns the value of theinitialMaxDatarecord component.longReturns the value of theinitialMaxStreamDataBidiLocalrecord component.longReturns the value of theinitialMaxStreamDataBidiRemoterecord component.longReturns the value of theinitialMaxStreamDataUnirecord component.longReturns the value of theinitialMaxStreamsBidirecord component.longReturns the value of theinitialMaxStreamsUnirecord component.Returns the value of theinitialSourceConnectionIdrecord component.longReturns the value of themaxAckDelayrecord component.longReturns the value of themaxDatagramFrameSizerecord component.longReturns the value of themaxIdleTimeoutrecord component.longReturns the value of themaxUdpPayloadSizerecord component.longReturns the value of theminAckDelayrecord component.Returns the value of theoriginalDestinationConnectionIdrecord component.Returns the value of thepreferredAddressrecord component.Returns the value of theretrySourceConnectionIdrecord component.Returns the value of thestatelessResetTokenrecord component.A builder starting from these parameters.final StringtoString()Returns a string representation of this record class.Returns the value of theunknownParametersrecord component.voidvalidateResumptionFrom(TransportParameters remembered) 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'svalidate_resumption_from).Returns the value of theversionInformationrecord component.
-
Field Details
-
DEFAULT_MAX_UDP_PAYLOAD_SIZE
public static final long DEFAULT_MAX_UDP_PAYLOAD_SIZEThe defaultmax_udp_payload_size: the largest UDP payload.- See Also:
-
DEFAULT_ACK_DELAY_EXPONENT
public static final long DEFAULT_ACK_DELAY_EXPONENTThe defaultack_delay_exponent.- See Also:
-
DEFAULT_MAX_ACK_DELAY
public static final long DEFAULT_MAX_ACK_DELAYThe defaultmax_ack_delay, in milliseconds.- See Also:
-
DEFAULT_ACTIVE_CONNECTION_ID_LIMIT
public static final long DEFAULT_ACTIVE_CONNECTION_ID_LIMITThe default and smallestactive_connection_id_limit.- See Also:
-
MIN_UDP_PAYLOAD_SIZE
public static final long MIN_UDP_PAYLOAD_SIZEThe smallest validmax_udp_payload_size.- See Also:
-
MAX_ACK_DELAY_EXPONENT
public static final long MAX_ACK_DELAY_EXPONENTThe largest validack_delay_exponent.- See Also:
-
MAX_ACK_DELAY_LIMIT
public static final long MAX_ACK_DELAY_LIMITThe smallest invalidmax_ack_delay, 214 milliseconds.- See Also:
-
MAX_STREAM_COUNT
public static final long MAX_STREAM_COUNTThe 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 nullmaxIdleTimeout- the idle timeout in millisecondsstatelessResetToken- the stateless reset token, or nullmaxUdpPayloadSize- the largest UDP payloadinitialMaxData- the connection flow control limitinitialMaxStreamDataBidiLocal- the limit for local bidirectional streamsinitialMaxStreamDataBidiRemote- the limit for remote bidirectional streamsinitialMaxStreamDataUni- the limit for unidirectional streamsinitialMaxStreamsBidi- the bidirectional stream count limitinitialMaxStreamsUni- the unidirectional stream count limitackDelayExponent- the ACK delay exponentmaxAckDelay- the maximum ACK delay in millisecondsdisableActiveMigration- whether active migration is disabledpreferredAddress- the preferred address, or nullactiveConnectionIdLimit- the active connection ID limitinitialSourceConnectionId- the initial Source Connection ID, or nullretrySourceConnectionId- the Retry Source Connection ID, or nullmaxDatagramFrameSize- the largest DATAGRAM frame, 0 for nonegreaseQuicBit- whether a cleared Fixed Bit is acceptedminAckDelay- the minimum ACK delay in microseconds, or -1versionInformation- the version information, or nullunknownParameters- the uninterpreted parameters
-
-
Method Details
-
defaults
The parameters a peer is assumed to have when it sends none: all defaults.- Returns:
- the defaults
-
builder
A builder starting from the defaults.- Returns:
- the builder
-
toBuilder
A builder starting from these parameters.- Returns:
- the builder
-
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
Whether a server whose parameters these are may accept 0-RTT from a client that remembersremembered(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
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'svalidate_resumption_from).- Parameters:
remembered- the parameters the client used for 0-RTT- Throws:
QuicException-PROTOCOL_VIOLATIONif 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_parametersTLS extension value
-
encode
Encodes the parameters at the buffer's position.- Parameters:
out- the buffer- Throws:
BufferOverflowException- if the buffer has too little room
-
decode
Decodes and validates the peer's transport parameters.- Parameters:
in- the encoded parameters between position and limit; the position moves to the limit on successsentByServer- whether the peer is the server, which allows the server-only parameters- Returns:
- the parameters, with defaults for those absent
- Throws:
QuicException- withTRANSPORT_PARAMETER_ERRORif the parameters are malformed, duplicated, out of range or not allowed from the peer's role
-
decode
Decodes and validates the peer's transport parameters from an array.- Parameters:
encoded- the encoded parameterssentByServer- whether the peer is the server- Returns:
- the parameters
- Throws:
QuicException- withTRANSPORT_PARAMETER_ERRORif 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 sendinitial_source_connection_idmatching the Source Connection ID of their first Initial; a server must sendoriginal_destination_connection_id, andretry_source_connection_idif and only if it sent a Retry.- Parameters:
sentByServer- whether these are the server's parameterspeerInitialSourceId- the Source Connection ID of the peer's first Initial packetoriginalDestinationId- for a server's parameters, the Destination Connection ID of the client's first Initial; ignored for a client'sretrySourceId- 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- withTRANSPORT_PARAMETER_ERRORif a parameter is missing, unexpected or different
-
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
originalDestinationConnectionId
Returns the value of theoriginalDestinationConnectionIdrecord component.- Returns:
- the value of the
originalDestinationConnectionIdrecord component
-
maxIdleTimeout
public long maxIdleTimeout()Returns the value of themaxIdleTimeoutrecord component.- Returns:
- the value of the
maxIdleTimeoutrecord component
-
statelessResetToken
Returns the value of thestatelessResetTokenrecord component.- Returns:
- the value of the
statelessResetTokenrecord component
-
maxUdpPayloadSize
public long maxUdpPayloadSize()Returns the value of themaxUdpPayloadSizerecord component.- Returns:
- the value of the
maxUdpPayloadSizerecord component
-
initialMaxData
public long initialMaxData()Returns the value of theinitialMaxDatarecord component.- Returns:
- the value of the
initialMaxDatarecord component
-
initialMaxStreamDataBidiLocal
public long initialMaxStreamDataBidiLocal()Returns the value of theinitialMaxStreamDataBidiLocalrecord component.- Returns:
- the value of the
initialMaxStreamDataBidiLocalrecord component
-
initialMaxStreamDataBidiRemote
public long initialMaxStreamDataBidiRemote()Returns the value of theinitialMaxStreamDataBidiRemoterecord component.- Returns:
- the value of the
initialMaxStreamDataBidiRemoterecord component
-
initialMaxStreamDataUni
public long initialMaxStreamDataUni()Returns the value of theinitialMaxStreamDataUnirecord component.- Returns:
- the value of the
initialMaxStreamDataUnirecord component
-
initialMaxStreamsBidi
public long initialMaxStreamsBidi()Returns the value of theinitialMaxStreamsBidirecord component.- Returns:
- the value of the
initialMaxStreamsBidirecord component
-
initialMaxStreamsUni
public long initialMaxStreamsUni()Returns the value of theinitialMaxStreamsUnirecord component.- Returns:
- the value of the
initialMaxStreamsUnirecord component
-
ackDelayExponent
public long ackDelayExponent()Returns the value of theackDelayExponentrecord component.- Returns:
- the value of the
ackDelayExponentrecord component
-
maxAckDelay
public long maxAckDelay()Returns the value of themaxAckDelayrecord component.- Returns:
- the value of the
maxAckDelayrecord component
-
disableActiveMigration
public boolean disableActiveMigration()Returns the value of thedisableActiveMigrationrecord component.- Returns:
- the value of the
disableActiveMigrationrecord component
-
preferredAddress
Returns the value of thepreferredAddressrecord component.- Returns:
- the value of the
preferredAddressrecord component
-
activeConnectionIdLimit
public long activeConnectionIdLimit()Returns the value of theactiveConnectionIdLimitrecord component.- Returns:
- the value of the
activeConnectionIdLimitrecord component
-
initialSourceConnectionId
Returns the value of theinitialSourceConnectionIdrecord component.- Returns:
- the value of the
initialSourceConnectionIdrecord component
-
retrySourceConnectionId
Returns the value of theretrySourceConnectionIdrecord component.- Returns:
- the value of the
retrySourceConnectionIdrecord component
-
maxDatagramFrameSize
public long maxDatagramFrameSize()Returns the value of themaxDatagramFrameSizerecord component.- Returns:
- the value of the
maxDatagramFrameSizerecord component
-
greaseQuicBit
public boolean greaseQuicBit()Returns the value of thegreaseQuicBitrecord component.- Returns:
- the value of the
greaseQuicBitrecord component
-
minAckDelay
public long minAckDelay()Returns the value of theminAckDelayrecord component.- Returns:
- the value of the
minAckDelayrecord component
-
versionInformation
Returns the value of theversionInformationrecord component.- Returns:
- the value of the
versionInformationrecord component
-
unknownParameters
Returns the value of theunknownParametersrecord component.- Returns:
- the value of the
unknownParametersrecord component
-