Class TransportConfig.Builder

java.lang.Object
io.github.mahmoudimus.quic.connection.TransportConfig.Builder
Enclosing class:
TransportConfig

public static final class TransportConfig.Builder extends Object
Builds a TransportConfig. Not thread-safe.
  • Method Details

    • maxConcurrentBidiStreams

      public TransportConfig.Builder maxConcurrentBidiStreams(long count)
      How many bidirectional streams the peer may have open at once.
      Parameters:
      count - 0 to 260
      Returns:
      this builder
    • maxConcurrentUniStreams

      public TransportConfig.Builder maxConcurrentUniStreams(long count)
      How many unidirectional streams the peer may have open at once.
      Parameters:
      count - 0 to 260
      Returns:
      this builder
    • maxIdleTimeout

      public TransportConfig.Builder maxIdleTimeout(Duration timeout)
      The idle timeout to offer (RFC 9000 section 10.1); the smaller of both sides' applies.
      Parameters:
      timeout - the timeout, or Duration.ZERO for none
      Returns:
      this builder
    • streamReceiveWindow

      public TransportConfig.Builder streamReceiveWindow(long bytes)
      The receive window of each stream: how much the peer may send ahead of what the application read.
      Parameters:
      bytes - at least 1
      Returns:
      this builder
    • receiveWindow

      public TransportConfig.Builder receiveWindow(long bytes)
      The receive window of the connection, across streams.
      Parameters:
      bytes - at least 1
      Returns:
      this builder
    • sendWindow

      public TransportConfig.Builder sendWindow(long bytes)
      The most outgoing stream data to buffer until it is acknowledged. Writers block beyond it.
      Parameters:
      bytes - at least 1
      Returns:
      this builder
    • sendFairness

      public TransportConfig.Builder sendFairness(boolean fair)
      Whether streams of equal priority share packets round-robin (true, the default) or one finishes before the next starts.
      Parameters:
      fair - the fairness
      Returns:
      this builder
    • packetThreshold

      public TransportConfig.Builder packetThreshold(int packets)
      The packet reordering threshold of loss detection (RFC 9002 section 6.1.1).
      Parameters:
      packets - at least 1
      Returns:
      this builder
    • timeThreshold

      public TransportConfig.Builder timeThreshold(double rtts)
      The time reordering threshold of loss detection, in RTTs (RFC 9002 section 6.1.2).
      Parameters:
      rtts - more than 1
      Returns:
      this builder
    • initialRtt

      public TransportConfig.Builder initialRtt(Duration rtt)
      The RTT assumed before the first sample.
      Parameters:
      rtt - positive
      Returns:
      this builder
    • initialMtu

      public TransportConfig.Builder initialMtu(int bytes)
      The UDP payload size to start with, at least minMtu(int).
      Parameters:
      bytes - the size
      Returns:
      this builder
    • minMtu

      public TransportConfig.Builder minMtu(int bytes)
      The UDP payload size the path is assumed to carry, at least 1200.
      Parameters:
      bytes - the size
      Returns:
      this builder
    • mtuDiscovery

      public TransportConfig.Builder mtuDiscovery(boolean enabled)
      Turns path MTU discovery (RFC 8899) on with its default settings, or off.
      Parameters:
      enabled - whether to probe for a larger MTU
      Returns:
      this builder
    • mtuDiscoveryConfig

      public TransportConfig.Builder mtuDiscoveryConfig(MtuDiscoveryConfig config)
      Path MTU discovery settings, or null to turn it off.
      Parameters:
      config - the settings
      Returns:
      this builder
    • persistentCongestionThreshold

      public TransportConfig.Builder persistentCongestionThreshold(int ptos)
      How many PTOs of loss make persistent congestion (RFC 9002 section 7.6).
      Parameters:
      ptos - at least 1
      Returns:
      this builder
    • keepAliveInterval

      public TransportConfig.Builder keepAliveInterval(Duration interval)
      Sends a PING after this much time without sending, to keep an idle connection open.
      Parameters:
      interval - the interval, or null for none (the default)
      Returns:
      this builder
    • cryptoBufferSize

      public TransportConfig.Builder cryptoBufferSize(int bytes)
      The most out-of-order CRYPTO data to buffer per encryption level; more is CRYPTO_BUFFER_EXCEEDED.
      Parameters:
      bytes - at least 1
      Returns:
      this builder
    • allowSpin

      public TransportConfig.Builder allowSpin(boolean allow)
      Whether to take part in the latency spin bit (RFC 9000 section 17.4); when on, a connection still opts out one time in eight.
      Parameters:
      allow - whether to spin
      Returns:
      this builder
    • datagramReceiveBufferSize

      public TransportConfig.Builder datagramReceiveBufferSize(int bytes)
      The DATAGRAM (RFC 9221) receive buffer; the oldest unread datagrams are dropped beyond it. 0 refuses DATAGRAM frames altogether.
      Parameters:
      bytes - 0 or more
      Returns:
      this builder
    • datagramSendBufferSize

      public TransportConfig.Builder datagramSendBufferSize(int bytes)
      The DATAGRAM send buffer; the oldest unsent datagrams are dropped beyond it.
      Parameters:
      bytes - at least 1
      Returns:
      this builder
    • congestionControl

      public TransportConfig.Builder congestionControl(TransportConfig.CongestionControl control)
      Chooses one of the provided congestion controllers with its default settings.
      Parameters:
      control - the controller
      Returns:
      this builder
    • congestionControllerFactory

      public TransportConfig.Builder congestionControllerFactory(ControllerFactory factory)
      A custom congestion controller.
      Parameters:
      factory - builds one controller per connection
      Returns:
      this builder
    • maxOutgoingBytesPerSecond

      public TransportConfig.Builder maxOutgoingBytesPerSecond(long bytesPerSecond)
      Caps the sending rate through the pacer.
      Parameters:
      bytesPerSecond - the cap, or -1 for none (the default)
      Returns:
      this builder
    • maxAckDelay

      public TransportConfig.Builder maxAckDelay(Duration delay)
      The max_ack_delay transport parameter: how long this endpoint may delay ACKs.
      Parameters:
      delay - below 214 ms
      Returns:
      this builder
    • activeConnectionIdLimit

      public TransportConfig.Builder activeConnectionIdLimit(int limit)
      The active_connection_id_limit transport parameter: how many of the peer's connection IDs to keep.
      Parameters:
      limit - at least 2
      Returns:
      this builder
    • maxUdpPayloadSize

      public TransportConfig.Builder maxUdpPayloadSize(int bytes)
      The max_udp_payload_size transport parameter: the largest datagram this endpoint receives.
      Parameters:
      bytes - 1200 to 65527
      Returns:
      this builder
    • keyLog

      public TransportConfig.Builder keyLog(KeyLog keyLog)
      Writes each connection's TLS secrets in the SSLKEYLOGFILE format, for Wireshark. For debugging only: anyone with the log can decrypt the traffic.
      Parameters:
      keyLog - the destination, or null for none (the default)
      Returns:
      this builder
    • qlog

      public TransportConfig.Builder qlog(QlogSink sink)
      Reports qlog-style events (packets sent, received and lost, metrics, state changes).
      Parameters:
      sink - the destination, or null for none (the default)
      Returns:
      this builder
    • build

      public TransportConfig build()
      Builds the configuration.
      Returns:
      the configuration
      Throws:
      IllegalArgumentException - if the MTU settings are inconsistent