Class QuicheTripTransport

java.lang.Object
org.tentackle.trip.transport.AbstractTransport
org.tentackle.quiche.QuicheTripTransport
All Implemented Interfaces:
Transport
Direct Known Subclasses:
CompressedQuicheTripTransport

@TransportService("tripj") public class QuicheTripTransport extends AbstractTransport
Transport implementation for QUIC on top of Cloudflare quiche, scheme "tripj".

This is the sibling of tentackle-quic, which provides the same transport on top of KWIK. Both speak RFC-9000 and interoperate; they register different URI schemes so that an application can use either, or both at once, and pick per connection. The URI parameters are described in the module's documentation (quiche.md).

  • Field Details

    • PROTOCOL

      public static final String PROTOCOL
      The protocol name for QUIC over quiche.
      See Also:
    • DEFAULT_MAX_IDLE_SECONDS

      public static final int DEFAULT_MAX_IDLE_SECONDS
      The default QUIC max idle timeout in seconds, applied if the URI does not specify quicidle.
      See Also:
    • DEFAULT_MAX_STREAMS

      public static final int DEFAULT_MAX_STREAMS
      The default maximum number of concurrent peer-initiated bidirectional streams, applied if the URI does not specify maxstreams.
      See Also:
    • DEFAULT_STREAM_WINDOW

      public static final int DEFAULT_STREAM_WINDOW
      The default flow control window per stream in bytes, applied if the URI does not specify streamwindow.
      See Also:
    • CONNECTION_WINDOW_FACTOR

      public static final int CONNECTION_WINDOW_FACTOR
      The factor by which the connection's flow control window exceeds the window of a single stream.

      The connection window must be larger than the stream window, or both limits would be exhausted at the very same offset and every transfer would proceed in lockstep with the credit updates. Keeping the connection window a multiple of the stream window makes the stream limit the binding one.

      Note that the connection window is shared by all streams of the connection, so the stream limit is the binding one only as long as fewer than this many streams transfer at full window at the same time. Sizing streamwindow so that ordinary calls fit into it keeps the number of streams that are blocked on flow control small.

      See Also:
    • MIN_STREAM_WINDOW

      public static final int MIN_STREAM_WINDOW
      The smallest flow control window accepted for streamwindow.

      A window must hold at least one maximum-sized QUIC packet.

      See Also:
    • DEFAULT_MIGRATION_PROBE_TIMEOUTS

      public static final int DEFAULT_MIGRATION_PROBE_TIMEOUTS
      The default number of consecutive probe timeouts without any acknowledgment after which a client migrates its QUIC connection to a new source port, applied if the URI does not specify migrate.

      Two is the smallest number that tells a stalled path from a single burst of losses: the first probe timeout alone fires on an ordinary lost tail, the second one means that not even the probe got through. Since the probe timeout backs off exponentially, two of them take about three times the first one, i.e., a few round trip times.

      See Also:
    • ACTIVE_CONNECTION_ID_LIMIT

      public static final int ACTIVE_CONNECTION_ID_LIMIT
      The number of connection IDs each side is willing to hold for the peer, including the one in use.

      Every migration needs a spare connection ID of the peer, and quiche keeps the network paths a connection has used for as long as they have connection IDs, so this also bounds how often a connection can migrate. A connection that cannot migrate any further stays where it is, and if its path does not recover, it runs into the idle timeout and the pool re-establishes it from a fresh source port.

      See Also:
  • Constructor Details

    • QuicheTripTransport

      public QuicheTripTransport(URI uri)
      Creates a new QUIC transport.
      Parameters:
      uri - the URI of the transport
  • Method Details

    • getClientAuth

      public SslParameters.ClientAuth getClientAuth()
      Gets the client-certificate policy of the accepting transport.
      Returns:
      the policy, SslParameters.ClientAuth.NONE if not accepting or no certificates are requested
    • accept

      public void accept()
      Description copied from interface: Transport
      Accepts connections from clients.
      Puts the transport into server mode.
      Specified by:
      accept in interface Transport
      Overrides:
      accept in class AbstractTransport
    • isAccepting

      public boolean isAccepting()
      Returns true if this transport is accepting connections.

      False as well once the endpoint closed itself because its event loop failed.

      Returns:
      true if accepting, false otherwise
    • getMaxIdleSeconds

      public int getMaxIdleSeconds()
      Gets the QUIC max idle timeout in seconds.
      A QUIC connection is discarded silently by both peers when it stays idle for longer than the minimum of the timeouts of both peers (see RFC-9000, 10.1). The same value is configured on the server and on the client, so that the effective timeout is well-defined.

      Note that this has nothing to do with the idle parameter, which is the timeout in minutes after which the connection pool closes unused connections.

      Returns:
      the timeout in seconds
    • getMaxStreams

      public int getMaxStreams()
      Gets the maximum number of concurrent peer-initiated bidirectional streams per QUIC connection.
      On the server this is the limit advertised to the clients. On the client it bounds the size of the connection pool, since every pooled connection holds one stream for as long as it is in the pool (see QuicheTripConnectionPool).
      Returns:
      the maximum number of streams, always ≥ 1
      Throws:
      TripRuntimeException - if the configured value is < 1
    • getStreamWindow

      public int getStreamWindow()
      Gets the flow control window per stream in bytes.
      A peer may send at most that many bytes on a stream before the receiving side has to grant further credits (see RFC-9000, 4). It is configured on both ends: on the server it applies to the data a client sends, i.e., to the size of the remote calls, and on the client to the size of the responses. The window should be at least as large as the largest call to be transferred without intermediate credit updates. The connection window is a multiple of it, see CONNECTION_WINDOW_FACTOR.
      Returns:
      the window in bytes
      Throws:
      TripRuntimeException - if the configured window is smaller than MIN_STREAM_WINDOW
    • getMigrationProbeTimeouts

      public int getMigrationProbeTimeouts()
      Gets after how many consecutive probe timeouts without any acknowledgment a client migrates its QUIC connection to a new source port.
      Some networks hash each flow onto one of several paths by its addresses and ports, and a flow that lands on a path that stopped delivering stays stuck there, whereas a new source port puts it onto another one. QUIC can move a connection without disturbing its streams (RFC-9000, 9).
      Returns:
      the number of probe timeouts, 0 if the client never migrates
      Throws:
      TripRuntimeException - if the configured value is < 0
    • close

      public void close()
      Closes this transport.

      Overridden to shut down the QUIC endpoint, which releases the UDP socket and terminates the connections of all clients.

      The endpoint is closed before the transport's thread pools are shut down, so that no incoming stream is dispatched to a pool that is already gone. Closing it sends every client a CONNECTION_CLOSE and waits up to a second for the event loop to stop, which is why it happens outside the transport's monitor: connection handlers still running must be able to invoke synchronized transport methods.

      Specified by:
      close in interface Transport
      Overrides:
      close in class AbstractTransport
    • stopAccepting

      protected Runnable stopAccepting()
      Detaches the QUIC endpoint from this transport, the first step of close().

      From then on accept() fails. Since the endpoint is closed outside the transport's monitor and the transport is marked closed only afterward, an accept() getting in between would otherwise start an endpoint that nobody closes anymore.

      Returns:
      the action closing what was detached, to be run without holding the transport's monitor
    • createClientConnectionPool

      protected Pool<Connection> createClientConnectionPool()
      Description copied from class: AbstractTransport
      Creates the connection pool for outgoing connections.
      Specified by:
      createClientConnectionPool in class AbstractTransport
      Returns:
      the connection pool