java.lang.Object
net.i2p.client.streaming.impl.I2PSocketOptionsImpl
net.i2p.client.streaming.impl.ConnectionOptions
All Implemented Interfaces:
I2PSocketOptions

class ConnectionOptionsextends I2PSocketOptionsImpl
Define the current options for the con (and allow custom tweaking midstream).

Static fields with volatile and class-level setters (e.g., setInitialRTO(int), setMaxWindowSize(int)) are globally shared and adjusted by the Tuner. Per-connection fields are copied from these globals when a new Connection is created.

  • Field Details

    • _connectDelay

      private int _connectDelay
      Connect delay.
    • _fullySigned

      private boolean _fullySigned
      Fully signed.
    • _answerPings

      private boolean _answerPings
      Answer pings.
    • _windowSize

      private volatile int _windowSize
      Window size.
    • _profile

      private int _profile
      Connection traffic profile (only bulk supported).
    • _maxConnectTimeout

      private long _maxConnectTimeout
      Max connect timeout override in ms, 0 = use global i2p.streaming.maxConnectTimeout.
    • _smoothedRtt

      private volatile int _smoothedRtt
      Smoothed rtt. Volatile: read from the throttle/retransmit hot path (writer thread, timer thread, reader thread) without the monitor the compound methods still use.
    • _minRtt

      private volatile int _minRtt
      Min rtt. Unknown until the first sample: seeding the floor with a guess (e.g. the initial RTT) would fabricate a minimum on any path whose real floor is higher, and _minRtt feeds the bandwidth-derived ssthresh floor. Like mainline: Integer.MAX_VALUE until updateRTT(int) narrows it.
    • _rttDeviation

      private volatile int _rttDeviation
      Rtt deviation.
    • _retransmitTimeout

      private volatile int _retransmitTimeout
      Retransmit timeout.
    • _retransmitDelay

      private int _retransmitDelay
      Retransmit delay.
    • _ackDelay

      private int _ackDelay
      Ack delay.
    • _maxMessageSize

      private int _maxMessageSize
      Max message size.
    • _maxInitialMessageSize

      private int _maxInitialMessageSize
      Max initial message size.
    • _maxResends

      private int _maxResends
      Max resends.
    • _stallGiveupMs

      private long _stallGiveupMs
      Wall-clock ms an established connection may hold an unacked packet; see PROP_STALL_GIVEUP_MS.
    • _inactivityTimeout

      private int _inactivityTimeout
      Inactivity timeout.
    • _inactivityAction

      private int _inactivityAction
      Inactivity action.
    • _inboundBufferSize

      private volatile int _inboundBufferSize
      Inbound buffer size.
    • _maxWindowSize

      private volatile int _maxWindowSize
      Max window size.
    • _congestionAvoidanceGrowthRateFactor

      private volatile int _congestionAvoidanceGrowthRateFactor
      Congestion avoidance growth rate factor.
    • _slowStartGrowthRateFactor

      private volatile int _slowStartGrowthRateFactor
      Slow start growth rate factor.
    • _accessListEnabled

      private volatile boolean _accessListEnabled
      Access list enabled.
    • _blackListEnabled

      private volatile boolean _blackListEnabled
      Black list enabled.
    • _accessList

      private Set<Hash> _accessList
      Access list.
    • _blackList

      private Set<Hash> _blackList
      Black list.
    • _maxConnsPerMinute

      private volatile int _maxConnsPerMinute
      Max conns per minute.
    • _maxConnsPerHour

      private volatile int _maxConnsPerHour
      Max conns per hour.
    • _maxConnsPerDay

      private volatile int _maxConnsPerDay
      Max conns per day.
    • _maxTotalConnsPerMinute

      private volatile int _maxTotalConnsPerMinute
      Max total conns per minute.
    • _maxTotalConnsPerHour

      private volatile int _maxTotalConnsPerHour
      Max total conns per hour.
    • _maxTotalConnsPerDay

      private volatile int _maxTotalConnsPerDay
      Max total conns per day.
    • _passiveFlushDelay

      private volatile int _passiveFlushDelay
      Per-connection passive flush delay; <= 0 means use Tuner-managed global default.
    • _maxConns

      private volatile int _maxConns
      Max conns.
    • _disableRejectLog

      private volatile boolean _disableRejectLog
      Disable reject log.
    • _limitAction

      private volatile String _limitAction
      Limit action.
    • _tagsToSend

      private volatile int _tagsToSend
      Tags to send.
    • _tagThreshold

      private volatile int _tagThreshold
      Tag threshold.
    • _lastRtoDoubleTime

      private long _lastRtoDoubleTime
      Prevents RTO overshoot from rapid RetransmitEvent + ResendPacketEvent double-fires.
    • _nanoTime

      java.util.function.LongSupplier _nanoTime
      Nanosecond time source for the RTO-doubling gap.

      Package-visible and replaceable so the gap can be tested without burning real time: the guard is MIN_RTO_DOUBLE_GAP_MS at minimum, so a test that exercises it honestly has to wait a second per iteration.

    • _maxPacketCount

      private volatile int _maxPacketCount
      Hybrid byte+packet buffer limit; default 1024 for optimal performance.
    • _rttState

      private ConnectionOptions.RttState _rttState
      Synchronizes access to the RTT state.
    • INACTIVITY_ACTION_NOOP

      public static final int INACTIVITY_ACTION_NOOP
      No action taken when inactivity timeout fires.
      See Also:
    • INACTIVITY_ACTION_DISCONNECT

      public static final int INACTIVITY_ACTION_DISCONNECT
      Disconnect the connection when inactivity timeout fires.
      See Also:
    • INACTIVITY_ACTION_SEND

      public static final int INACTIVITY_ACTION_SEND
      Send a keepalive when inactivity timeout fires.
      See Also:
    • RTT_ALPHA

      private static final float RTT_ALPHA
      RFC 6298 RTT smoothing constants.
      See Also:
    • RTT_BETA

      private static final float RTT_BETA
      Rtt beta.
      See Also:
    • RTT_KAPPA

      private static final float RTT_KAPPA
      Rtt kappa.
      See Also:
    • MIN_RTO_DOUBLE_GAP_MS

      static final long MIN_RTO_DOUBLE_GAP_MS
      Minimum gap enforced between RTO doublings. Floors the once-per-RTT guard in doubleRTO() so a degenerately small smoothed RTT cannot make the guard a no-op.
      See Also:
    • PROP_INITIAL_RTO

      private static final String PROP_INITIAL_RTO
      Prop initial rto.
      See Also:
    • PROP_MAX_RTO

      static final String PROP_MAX_RTO
      Prop max rto.
      See Also:
    • PROP_STALL_GIVEUP_MS

      static final String PROP_STALL_GIVEUP_MS
      How long an established connection may keep a packet in flight with no forward progress before it is force-closed, in ms.

      Deliberately its own setting rather than a product of maxResends and maxRTO. maxResends is the per-packet budget and governs loss tolerance; multiplying it by an RTO cap produced a four-minute connection lifetime as a side effect of a loss-tolerance knob. While the client tunnel pool is short of healthy tunnels, every second a dead stream is held is a second it occupies capacity that a live stream needs, and the resulting reconnects starve the pool further. Ninety seconds still rides out several firings past the RTO cap, so a genuinely transient loss survives.

      See Also:
    • defaultInitialRTO

      private static volatile int defaultInitialRTO
      Default initial RTO (ms) before any RTT measurement. Set to 9000 — accommodates typical I2P RTT up to ~6s without premature SYN retransmit, matching i2pd's INITIAL_RTO. The Tuner adjusts this adaptively based on network conditions.
    • maxRTO

      private static volatile int maxRTO
      Default 8000 accommodates RTT up to ~4s with standard TCP deviation. Shorter than the historical 30000 so a stalled path costs less: a lost packet blocks the stream head-of-line until its RTO backoff expires, and the Tuner only tightens this on paths that keep confirming sends. On a dead path (no confirmTime events) the Tuner sees no signal, so the code default IS the retransmit pace and the zombie-window backstop (maxResends * maxRTO) for that path. 8000 keeps each loss stall modest and the default 30-resend backstop (~4 min) inside a range a recovered path can still resume from, instead of the 15-min hang the 30s default gave. Tuner may raise this for very high-latency networks.
    • PROP_RTO_MULTIPLIER

      static final String PROP_RTO_MULTIPLIER
      RTO multiplier as percentage (e.g. 120 = 1.2x), clamped to [100, 500].
      See Also:
    • rtoMultiplier

      private static volatile int rtoMultiplier
      Growth factor doubleRTO() applies to the RTO on congestion, as a percentage; 100 means no growth, so the floor is 1.0x.
    • minResendDelay

      private static volatile int minResendDelay
      Min resend delay.
    • maxResendDelay

      private static volatile int maxResendDelay
      Max resend delay (ms). Raised to 20000 to accommodate high-RTT paths without premature retransmit while still providing faster recovery than the 30000 default.
    • PROP_CONNECT_DELAY

      public static final String PROP_CONNECT_DELAY
      Delay before starting connection setup, in ms.
      See Also:
    • PROP_MAX_CONNECT_TIMEOUT

      public static final String PROP_MAX_CONNECT_TIMEOUT
      See Also:
    • PROP_MAX_MESSAGE_SIZE

      public static final String PROP_MAX_MESSAGE_SIZE
      Maximum size of a streaming message, in bytes.
      See Also:
    • PROP_MAX_RESENDS

      public static final String PROP_MAX_RESENDS
      Maximum number of times a message is resent.
      See Also:
    • PROP_INITIAL_RESEND_DELAY

      public static final String PROP_INITIAL_RESEND_DELAY
      Initial delay before retransmitting, in ms.
      See Also:
    • PROP_INITIAL_ACK_DELAY

      public static final String PROP_INITIAL_ACK_DELAY
      Initial delay before sending an ACK, in ms.
      See Also:
    • PROP_INITIAL_WINDOW_SIZE

      public static final String PROP_INITIAL_WINDOW_SIZE
      Initial congestion window size (messages in flight).
      See Also:
    • PROP_INACTIVITY_TIMEOUT

      public static final String PROP_INACTIVITY_TIMEOUT
      Idle time before inactivity action fires, in ms.
      See Also:
    • PROP_INACTIVITY_ACTION

      public static final String PROP_INACTIVITY_ACTION
      Action to take on inactivity timeout.
      See Also:
    • PROP_MAX_WINDOW_SIZE

      public static final String PROP_MAX_WINDOW_SIZE
      Maximum congestion window size.
      See Also:
    • PROP_CONGESTION_AVOIDANCE_GROWTH_RATE_FACTOR

      public static final String PROP_CONGESTION_AVOIDANCE_GROWTH_RATE_FACTOR
      Congestion avoidance window growth rate factor.
      See Also:
    • PROP_SLOW_START_GROWTH_RATE_FACTOR

      public static final String PROP_SLOW_START_GROWTH_RATE_FACTOR
      Slow start window growth rate factor.
      See Also:
    • PROP_ANSWER_PINGS

      public static final String PROP_ANSWER_PINGS
      Whether to respond to ping messages.
      See Also:
    • PROP_ENABLE_ACCESS_LIST

      public static final String PROP_ENABLE_ACCESS_LIST
      Enable destination access list filtering.
      See Also:
    • PROP_ENABLE_BLACKLIST

      public static final String PROP_ENABLE_BLACKLIST
      Enable destination blacklist filtering.
      See Also:
    • PROP_ACCESS_LIST

      public static final String PROP_ACCESS_LIST
      Comma-separated list of allowed or blocked destination hashes.
      See Also:
    • PROP_MAX_CONNS_MIN

      public static final String PROP_MAX_CONNS_MIN
      Max connections per minute from a single peer.
      See Also:
    • PROP_MAX_CONNS_HOUR

      public static final String PROP_MAX_CONNS_HOUR
      Max connections per hour from a single peer.
      See Also:
    • PROP_MAX_CONNS_DAY

      public static final String PROP_MAX_CONNS_DAY
      Max connections per day from a single peer.
      See Also:
    • PROP_MAX_TOTAL_CONNS_MIN

      public static final String PROP_MAX_TOTAL_CONNS_MIN
      Max total connections per minute across all peers.
      See Also:
    • PROP_MAX_TOTAL_CONNS_HOUR

      public static final String PROP_MAX_TOTAL_CONNS_HOUR
      Max total connections per hour across all peers.
      See Also:
    • PROP_MAX_TOTAL_CONNS_DAY

      public static final String PROP_MAX_TOTAL_CONNS_DAY
      Max total connections per day across all peers.
      See Also:
    • PROP_MAX_STREAMS

      public static final String PROP_MAX_STREAMS
      Per-tunnel cap on concurrent streams; a manager's effective cap is the min of this and the Tuner override.
      See Also:
    • PROP_MAX_MAX_STREAMS

      public static final String PROP_MAX_MAX_STREAMS
      Operator-tunable ceiling for the Tuner's maxConcurrentStreamsOverride. The effective cap taken by a manager is the min of its configured value (PROP_MAX_STREAMS) and the override, so this only bounds the Tuner; it can never raise a manager above its own per-tunnel ceiling.
      See Also:
    • maxMaxConcurrentStreams

      static volatile int maxMaxConcurrentStreams
      Default ceiling; operator may raise via PROP_MAX_MAX_STREAMS. @since 0.9.71+.
    • PROP_DISABLE_REJ_LOG

      public static final String PROP_DISABLE_REJ_LOG
      Suppress connection rejection logging @since 0.9.4 default false.
      See Also:
    • PROP_LIMIT_ACTION

      public static final String PROP_LIMIT_ACTION
      Reset, drop, http, or custom string; default reset @since 0.9.34.
      See Also:
    • PROP_TAGS_TO_SEND

      public static final String PROP_TAGS_TO_SEND
      Number of ElGamal tags a session sends up front; default 40 @since 0.9.34.
      See Also:
    • PROP_TAG_THRESHOLD

      public static final String PROP_TAG_THRESHOLD
      Tag count below which the session treats itself as tag-short @since 0.9.34.
      See Also:
    • PROP_PASSIVE_FLUSH_DELAY

      public static final String PROP_PASSIVE_FLUSH_DELAY
      Passive flush delay in ms for MessageOutputStream. When set to 0 (default), uses the Tuner-managed global default. When profile is INTERACTIVE and no explicit value is set, defaults to half the Tuner global (min 10).
      See Also:
    • initialWindowSize

      static volatile int initialWindowSize
      RFC 6928 recommends 10; raised to 64 in 0.9.48 for I2P's high-latency environment and to 128 for the 0.9.71+ fast-ramp profile: each stream starts with up to 128 messages in flight, so the first RTT on a high-bandwidth path is not spent proving link capacity.
    • DEFAULT_MAX_SENDS

      static final int DEFAULT_MAX_SENDS
      Default maximum number of times a single message will be retransmitted.
      See Also:
    • DEFAULT_STALL_GIVEUP_MS

      static final long DEFAULT_STALL_GIVEUP_MS
      Default wall-clock budget for giving up on forward progress. See PROP_STALL_GIVEUP_MS.
      See Also:
    • maxConcurrentStreamsOverride

      static volatile int maxConcurrentStreamsOverride
      Reactive cap on concurrent streams (both per-manager inbound budget and the outbound wait queue), written by the router's Tuner under saturation. Applies to every ConnectionManager. 0 (the default) means "no override": each manager uses its own configured i2p.streaming.maxConcurrentStreams captured at init. When positive, a manager enforces the min(configured, override).
    • receiveWorkerThreads

      static volatile int receiveWorkerThreads
      Tuner-managed default for inbound packet receive workers, read when a PacketDispatcher is created. 0 (the default) means "no override": each manager uses its configured i2p.streaming.receiveWorkerThreads or the platform core count. When positive, new dispatchers start with this many shards; the Tuner also resizes live dispatchers via PacketDispatcher.resizeAll. Bounded by the per-manager cap used by PacketHandler.
    • acceptWorkerThreads

      static volatile int acceptWorkerThreads
      Accept worker threads, Tuner-managed override; 0 = no override. @since 0.9.71+.
    • DEFAULT_INITIAL_RTT

      public static final int DEFAULT_INITIAL_RTT
      Initial RTT estimate before first measurement. I2P typically has 2-10s RTT, so 2s provides a conservative starting point without a long initial recovery window.
      See Also:
    • maxRTT

      private static volatile int maxRTT
      Max RTT to prevent pathological RTO cases. Tunable via i2p.streaming.maxRtt (default 10000).
    • defaultInitialAckDelay

      private static volatile int defaultInitialAckDelay
      500ms provides a reasonable delayed-ACK window for I2P's high-latency, allowing data piggybacking and reducing ACK-only packet floods. Ref: RFC 5681 sec. 4.3, RFC 1122 sec. 4.2.3.3, ticket #2706.
    • MIN_WINDOW_SIZE

      static final int MIN_WINDOW_SIZE
      Minimum congestion window size (one message in flight).
      See Also:
    • DEFAULT_ANSWER_PINGS

      private static final boolean DEFAULT_ANSWER_PINGS
      Default answer pings.
      See Also:
    • defaultInactivityTimeout

      static volatile int defaultInactivityTimeout
      Idle time before the inactivity action fires; default 300s @since 0.9.70+ mutable for adaptive tuning.
    • DEFAULT_INACTIVITY_ACTION

      private static final int DEFAULT_INACTIVITY_ACTION
      Default inactivity action.
      See Also:
    • maxSlowStartWindow

      static volatile int maxSlowStartWindow
      Window at which slow start hands over to congestion avoidance @since 0.9.70+ mutable for adaptive tuning.
    • immediateAckDelay

      private static volatile int immediateAckDelay
      Immediate ack delay.
    • defaultRetransmitDelay

      private static volatile int defaultRetransmitDelay
      Delay before the first retransmit of a packet, in ms; the fallback for PROP_INITIAL_RESEND_DELAY when that property is absent.
    • defaultCongestionAvoidanceGrowthRateFactor

      private static volatile int defaultCongestionAvoidanceGrowthRateFactor
      Divisor the linear congestion-avoidance growth uses, so the window gains roughly 1/N messages per RTT; 1 is the slowest (1 per RTT).
    • defaultSlowStartGrowthRateFactor

      private static volatile int defaultSlowStartGrowthRateFactor
      Divisor the slow-start growth uses, so the window gains roughly acked/N messages per ACK; 1 is the fastest (a full acked per ACK).
    • minPacingRate

      private static volatile long minPacingRate
      Minimum pacing rate. Below this, pacing is disabled to avoid excessive delays. Default 16 KB/s, tunable via Tuner.
    • DEFAULT_LIMIT_ACTION

      private static final String DEFAULT_LIMIT_ACTION
      Action taken when connections exceed a limit; one of "reset", "drop", "http" @since 0.9.34.
      See Also:
    • DEFAULT_TAGS_TO_SEND

      public static final int DEFAULT_TAGS_TO_SEND
      ElGamal tags sent up front before blocking on tag generation; default 40 @since 0.9.34.
      See Also:
    • DEFAULT_TAG_THRESHOLD

      public static final int DEFAULT_TAG_THRESHOLD
      Tag count below which the session is considered tag-short; default 30 @since 0.9.34.
      See Also:
    • DEFAULT_MAX_MESSAGE_SIZE

      public static final int DEFAULT_MAX_MESSAGE_SIZE
      Default maximum streaming message payload size, derived from 2 tunnel messages.
      See Also:
    • MIN_MESSAGE_SIZE

      public static final int MIN_MESSAGE_SIZE
      Minimum allowed message size.
      See Also:
    • DEFAULT_MAX_MESSAGE_SIZE_RATCHET

      public static final int DEFAULT_MAX_MESSAGE_SIZE_RATCHET
      Override max message size for ratcheted connections per proposal 144 @since 0.9.47.
      See Also:
    • maxInboundBuffer

      private static volatile int maxInboundBuffer
      Maximum inbound buffer cap, tunable via Tuner. Default 8MB accommodates high-BDP paths without excess memory use.
  • Constructor Details

    • ConnectionOptions

      public ConnectionOptions()
      Create options with default values from system properties.
    • ConnectionOptions

      public ConnectionOptions(Properties opts)
      Create options initialized from the given properties.
      Parameters:
      opts - properties to initialize from, may be null
    • ConnectionOptions

      public ConnectionOptions(I2PSocketOptions opts)
      Create options as a copy of the given I2PSocketOptions, then apply system property defaults for streaming-specific fields.
      Parameters:
      opts - options to copy, may be null
    • ConnectionOptions

      public ConnectionOptions(ConnectionOptions opts)
      Create options as a deep copy of the given ConnectionOptions, applying system property defaults then overlaying all local fields.
      Parameters:
      opts - options to copy, may be null
  • Method Details

    • getInitialRTO

      static int getInitialRTO()
      Retransmit timeout in ms armed before any RTT measurement exists.
      Returns:
      the initial RTO in ms
    • setInitialRTO

      static void setInitialRTO(int val)
      Retransmit timeout in ms used before any RTT measurement, clamped to [500, 30000].
      Parameters:
      val - the initial RTO in ms
    • getMaxRTOStatic

      public static int getMaxRTOStatic()
      Ceiling the RTO backoff in doubleRTO() may reach.
      Returns:
      the max RTO in ms
    • setMaxRTO

      public static void setMaxRTO(int val)
      Ceiling on the backed-off RTO in ms, clamped to [1000, 60000].
      Parameters:
      val - the max RTO in ms
    • getRTOMultiplier

      static int getRTOMultiplier()
      Factor doubleRTO() scales the RTO by on congestion.
      Returns:
      the multiplier percentage (120 = 1.2x)
    • setRTOMultiplier

      static void setRTOMultiplier(int val)
      RTO backoff factor as a percentage, clamped to [100, 500].
      Parameters:
      val - the multiplier percentage (100 = no growth)
    • getMinResendDelayStatic

      public static int getMinResendDelayStatic()
      Floor computeRTO() clamps the computed RTO to.
      Returns:
      the min resend delay in ms
    • setMinResendDelay

      public static void setMinResendDelay(int val)
      Floor on the computed RTO in ms, clamped to [100, 5000].
      Parameters:
      val - the min resend delay in ms
    • getMaxResendDelayStatic

      public static int getMaxResendDelayStatic()
      Ceiling computeRTO() clamps the computed RTO to.
      Returns:
      the max resend delay in ms
    • setMaxResendDelay

      public static void setMaxResendDelay(int val)
      Ceiling on the computed RTO in ms, clamped to [1000, 60000].
      Parameters:
      val - the max resend delay in ms
    • getMaxRTO

      private int getMaxRTO()
      Instance-scoped view of the global RTO backoff ceiling.
      Returns:
      the max RTO in ms
    • getMinResendDelay

      private int getMinResendDelay()
      Instance-scoped view of the global minimum resend delay.
      Returns:
      the min resend delay in ms
    • getMaxResendDelay

      private int getMaxResendDelay()
      Instance-scoped view of the global maximum resend delay.
      Returns:
      the max resend delay in ms
    • getInitialWindowSize

      static int getInitialWindowSize()
      Initial window size.
      Returns:
      messages in flight at connection setup
    • setInitialWindowSize

      static void setInitialWindowSize(int val)
      Initial window size, clamped to [4, 1024] to match the Tuner's InitialWindowSizeParam bounds; the previous 512 cap silently truncated the param's 513-1024 range.
      Parameters:
      val - messages in flight to start with
    • getMaxConcurrentStreamsOverride

      static int getMaxConcurrentStreamsOverride()
      The Tuner's stream-cap override; 0 = none. @since 0.9.71+.
      Returns:
      the reactive stream-cap override
    • setMaxConcurrentStreamsOverride

      static void setMaxConcurrentStreamsOverride(int val)
      The Tuner's stream-cap override; clamped to a sane [0, maxMaxConcurrentStreams]. @since 0.9.71+.
      Parameters:
      val - the reactive stream-cap override; 0 means no override
    • getReceiveWorkerThreads

      static int getReceiveWorkerThreads()
      The Tuner's receive-worker default; 0 = none. @since 0.9.71+.
      Returns:
      the reactive receive-worker default
    • setReceiveWorkerThreads

      static void setReceiveWorkerThreads(int val)
      The Tuner's receive-worker default; clamped to a sane [0, PacketHandler.MAX_RECEIVE_WORKERS]. @since 0.9.71+.
      Parameters:
      val - the reactive receive-worker default; 0 means no override
    • getAcceptWorkerThreads

      static int getAcceptWorkerThreads()
      The Tuner's accept-worker override; 0 = no override, so the configured i2p.streaming.acceptWorkerThreads applies. @since 0.9.71+.
      Returns:
      the reactive accept-worker override, or 0 if none
    • setAcceptWorkerThreads

      static void setAcceptWorkerThreads(int val)
      The Tuner's accept-worker override; clamped to [0, 16]. @since 0.9.71+.
      Parameters:
      val - the reactive accept-worker override; 0 removes it
    • getMaxMaxConcurrentStreams

      static int getMaxMaxConcurrentStreams()
      Operator-tunable ceiling for the Tuner's stream-cap override. Reads from router.config via i2p.streaming.maxMaxConcurrentStreams, falling back to the compiled default.
      Returns:
      the current ceiling
    • setMaxMaxConcurrentStreams

      static void setMaxMaxConcurrentStreams(int val)
      Operator-tunable ceiling for the Tuner's stream-cap override; clamped to [64, 8192].
      Parameters:
      val - the ceiling on the stream-cap override
    • getMaxRtt

      private int getMaxRtt()
      Per-connection view of the global RTT sample ceiling.
      Returns:
      the max RTT in ms
    • setMaxRtt

      public static void setMaxRtt(int val)
      Max RTT, clamped to [1000, 60000] ms.
      Parameters:
      val - the per-connection RTT sample ceiling in ms
    • getMaxRttStatic

      public static int getMaxRttStatic()
      Max RTT.
      Returns:
      the max rtt static
    • getDefaultInitialAckDelay

      public static int getDefaultInitialAckDelay()
      Default initial ACK delay.
      Returns:
      the default initial ack delay
    • setDefaultInitialAckDelay

      public static void setDefaultInitialAckDelay(int val)
      Default initial ACK delay, clamped to [10, 500] ms.
      Parameters:
      val - the initial ACK delay in ms
    • getDefaultInactivityTimeout

      public static int getDefaultInactivityTimeout()
      Default inactivity timeout.
      Returns:
      the default inactivity timeout
    • setDefaultInactivityTimeout

      public static void setDefaultInactivityTimeout(int val)
      Default inactivity timeout, clamped to [60000, 600000] ms.
      Parameters:
      val - the idle time before the inactivity action fires, in ms
    • getMaxSlowStartWindowStatic

      static int getMaxSlowStartWindowStatic()
      Max slow start window static.
      Returns:
      the slow-start/CA handover threshold in messages
    • setMaxSlowStartWindow

      static void setMaxSlowStartWindow(int val)
      Max slow start window, clamped to [8, Connection.ABSOLUTE_MAX_WINDOW].
      Parameters:
      val - the slow-start/CA handover threshold in messages
    • getImmediateAckDelayStatic

      static int getImmediateAckDelayStatic()
      Immediate ack delay static.
      Returns:
      the cap in ms on how soon an immediate ACK may be scheduled
    • setImmediateAckDelay

      static void setImmediateAckDelay(int val)
      Immediate ack delay, clamped to [1, 1000] ms.
      Parameters:
      val - the cap in ms on how soon an immediate ACK may be scheduled
    • getDefaultResendDelayStatic

      public static int getDefaultResendDelayStatic()
      Default resend delay.
      Returns:
      the default resend delay static
    • setDefaultResendDelay

      public static void setDefaultResendDelay(int val)
      Default resend delay, clamped to [100, 3000] ms.
      Parameters:
      val - the default resend delay in ms
    • getDefaultCongestionAvoidanceGrowthRateFactorStatic

      public static int getDefaultCongestionAvoidanceGrowthRateFactorStatic()
      Default congestion avoidance growth rate factor.
      Returns:
      the default congestion avoidance growth rate factor static
    • setDefaultCongestionAvoidanceGrowthRateFactor

      public static void setDefaultCongestionAvoidanceGrowthRateFactor(int val)
      Default congestion avoidance growth rate factor, clamped to [1, 4].
      Parameters:
      val - the congestion avoidance growth rate factor
    • getDefaultSlowStartGrowthRateFactorStatic

      public static int getDefaultSlowStartGrowthRateFactorStatic()
      Default slow start growth rate factor.
      Returns:
      the default slow start growth rate factor static
    • setDefaultSlowStartGrowthRateFactor

      public static void setDefaultSlowStartGrowthRateFactor(int val)
      Default slow start growth rate factor, clamped to [1, 4].
      Parameters:
      val - the slow start growth rate factor
    • getMinPacingRate

      public static long getMinPacingRate()
      Min pacing rate.
      Returns:
      the min pacing rate
    • setMinPacingRate

      public static void setMinPacingRate(long val)
      Min pacing rate.
      Parameters:
      val - the floor on pacing throughput in bytes/sec
    • getMinPacingRateKBps

      public static int getMinPacingRateKBps()
      KB/s view of getMinPacingRate().
      Returns:
      the floor on pacing throughput in KB/s, rounded down
    • setMinPacingRateKBps

      public static void setMinPacingRateKBps(int val)
      KB/s wrapper for Tuner int reflection.
      Parameters:
      val - the floor on pacing throughput in KB/s, clamped to [1, 256]
    • updateAll

      public void updateAll(ConnectionOptions opts)
      Copy all parent-class options then overlay ours from opts.
      Parameters:
      opts - source options to copy from, may be null
    • update

      private void update(ConnectionOptions opts)
      Copy all local (streaming-specific) options from opts. Note: getMaxWindowSize() returns the effective value (clamped by the Tuner global), so copying that would pin the destination's window down- only if the global ever decreased. Copy the raw configured value instead so a later Tuner re-enable propagates to this connection.
      Parameters:
      opts - source options to copy from, may be null
    • initFromProperties

      private void initFromProperties(Properties opts)
      Initialize from Properties with defaults (called from constructors). Applies configured values or defaults for all properties.
      Parameters:
      opts - properties to initialize from, may be null
    • setProperties

      public void setProperties(Properties opts)
      Update from properties — only applies explicitly set values. Also handles PROP_CONNECT_TIMEOUT not covered by applyProperties (it's in the parent class's constructor path).
      Overrides:
      setProperties in class I2PSocketOptionsImpl
      Parameters:
      opts - properties to apply, may be null
    • applyProperties

      private void applyProperties(Properties opts, boolean onlyIfSet)
      Apply properties from opts. When onlyIfSet is true, only properties explicitly present in opts are applied (used by setProperties(Properties)). When false, defaults are applied for missing properties (used by constructors).
      Parameters:
      opts - properties to read from, ignored when null
      onlyIfSet - if true, only properties present in opts are applied
    • applyInt

      private void applyInt(Properties opts, String key, int def, boolean onlyIfSet, java.util.function.IntConsumer setter)
      Apply an integer property: if onlyIfSet, skip when property key is absent. Otherwise apply value (or default).
      Parameters:
      opts - properties to read from, may be null
      key - property key to look up
      def - default value if key is absent
      onlyIfSet - if true, skip when key is not present in opts
      setter - consumer to apply the parsed value
    • applyLong

      private void applyLong(Properties opts, String key, long def, boolean onlyIfSet, java.util.function.LongConsumer setter)
      Long-valued sibling of applyInt(Properties, String, int, boolean, IntConsumer), for budgets expressed in ms.
      Parameters:
      opts - properties to read from, ignored when null
      key - property key to look up
      def - default in ms used when key is absent or unparseable
      onlyIfSet - if true, skip when key is not present in opts
      setter - consumer to apply the parsed value
    • getConnectDelay

      public int getConnectDelay()
      Delay before starting the connection.
      Returns:
      delay before starting connection, in ms
    • setConnectDelay

      public void setConnectDelay(int delayMs)
      Delay before starting the connection.
      Parameters:
      delayMs - delay before starting connection, in ms
    • getMaxConnectTimeout

      public long getMaxConnectTimeout()
      Absolute cap on the time an outbound connect waits for a SYN ACK. 0 (the default) is not a real cap; the router-wide PROP_MAX_CONNECT_TIMEOUT value is used instead.
      Returns:
      cap in ms, or 0 to use the global default
    • setMaxConnectTimeout

      public void setMaxConnectTimeout(long maxConnectTimeoutMs)
      Set an absolute cap on the time an outbound connect waits for a SYN ACK. Overrides the router-wide PROP_MAX_CONNECT_TIMEOUT value for this connection. This is what lets per-tunnel client options (e.g. the IRC client tunnel) raise the ceiling above the global default.
      Parameters:
      maxConnectTimeoutMs - cap in ms, or <= 0 to use the global default
    • getRequireFullySigned

      public boolean getRequireFullySigned()
      Whether every packet on this connection must be signed, or only SYN/FIN-class packets.

      Defaults to false, and no property or GUI setting exposes it: it is only ever set in-process via setRequireFullySigned(boolean) and carried to a new connection when options are copied from an existing one. When true it takes effect in both directions: every outbound packet gets FLAG_SIGNATURE_INCLUDED and FLAG_SIGNATURE_REQUESTED, and ConnectionPacketHandler rejects any inbound packet that does not carry a valid signature.

      Returns:
      true if all packets must be signed, false for SYN/FIN only
    • setRequireFullySigned

      public void setRequireFullySigned(boolean sign)
      Whether all packets on this connection require signing. See getRequireFullySigned() for the effect; there is no property to configure this with.
      Parameters:
      sign - true to require all packets signed
    • getAnswerPings

      public boolean getAnswerPings()
      Whether ping messages are answered.
      Returns:
      true if ping messages are answered
    • setAnswerPings

      public void setAnswerPings(boolean yes)
      Whether ping messages are answered.
      Parameters:
      yes - true to respond to pings
    • getDisableRejectLogging

      public boolean getDisableRejectLogging()
      Whether connection reject logging is suppressed.
      Returns:
      true if connection reject logging is suppressed
    • setDisableRejectLogging

      public void setDisableRejectLogging(boolean yes)
      Whether connection reject logging is suppressed.
      Parameters:
      yes - true to suppress reject log messages
    • getWindowSize

      public int getWindowSize()
      Messages in flight before waiting for ACK.
      Returns:
      current congestion window size in messages
    • setWindowSize

      public void setWindowSize(int numMsgs)
      Congestion window size in messages.
      Parameters:
      numMsgs - clamped to [MIN_WINDOW_SIZE, maxWindowSize]
    • getRTT

      public int getRTT()
      Smoothed round-trip time estimate in ms.
      Returns:
      current SRTT value in ms
    • isRTTEstablished

      public boolean isRTTEstablished()
      Whether a real RTT sample has ever been recorded for this connection.

      Until the first sample arrives, getRTT() and getWindowSize() hold the class defaults rather than a measurement. A connection torn down before that — a hard kill during connect, say — must not have those defaults published as though they were observed, or every such teardown biases the lifetime aggregates the Tuner reads toward the floor.

      Returns:
      true if at least one RTT sample has been recorded
    • getMinRTT

      public int getMinRTT()
      Minimum RTT observed, greater than zero.
      Returns:
      minimum RTT in ms
    • setRTT

      private void setRTT(int ms)
      Smoothed RTT. Not public, use updateRTT().

      The value is NOT clamped to maxRtt here: clamping the smoothed value lets a stale outlier pin steady-state RTT at the ceiling, which in turn pins RTO at its max and locks the recovery cadence. Single samples are already clamped at ingestion (see updateRTT(int)), and RTO is independently bounded by computeRTO(), so the smoothed value tracks the path honestly.

      Parameters:
      ms - new RTT value in ms
    • clampRttSample

      static int clampRttSample(int sample, int maxRtt)
      Pure clamp for a raw RTT sample before it enters the smoother.

      A clearly pathological single sample (e.g. tens of seconds from a stale reference after a long idle) must not inject a step into the smoothed RTT / RTO; the sample is reined to the per-connection ceiling instead. Zero and negative samples pass through unchanged so the caller's sentinel handling is preserved.

      Parameters:
      sample - raw measured RTT in ms (may be negative or zero)
      maxRtt - per-connection sample ceiling in ms; <= 0 disables clamping
      Returns:
      sample clamped to [0, maxRtt]
    • getRTO

      public int getRTO()
      Retransmit timeout, clamped to [minResendDelay, maxResendDelay].
      Returns:
      current RTO in ms
    • getRTTDev

      int getRTTDev()
      RTT deviation for RTO calculation.
      Returns:
      RTT variance in ms
    • setRTTDev

      private void setRTTDev(int rttDev)
      RTT deviation for RTO calculation.
      Parameters:
      rttDev - RTT deviation in ms
    • loadFromCache

      void loadFromCache(int rtt, int rttDev, int wdw)
      Load cached RTT/deviation/window from TCB and transition directly to STEADY state.
      Parameters:
      rtt - cached RTT value in ms
      rttDev - cached RTT deviation in ms
      wdw - cached window size
    • computeRTO

      private void computeRTO()
      Recalculate RTO from current smoothed RTT and deviation per RFC 6298.
    • doubleRTO

      int doubleRTO()
      Double RTO after congestion per RFC 6298 sec. 5 item 5.5. Guards against rapid double-fires from RetransmitEvent + ResendPacketEvent by limiting to once per RTT, floored at MIN_RTO_DOUBLE_GAP_MS so a degenerate smoothed RTT cannot turn the guard into a no-op.
      Returns:
      the new RTO value in ms
    • updateRTT

      public void updateRTT(int measuredValue)
      Update the smoothed RTT with a new measurement.

      The dropout sample is clamped before entering the smoother (clampRttSample(int, int)) so a single pathological reading can never pin the smoothed RTT (and thus the RTO recovery cadence) at the ceiling. The minimum-RTT floor is updated from the raw value instead: it feeds the bandwidth-derived ssthresh, and clamping it first would fabricate a 10s floor on any path slower than maxRtt.

      Parameters:
      measuredValue - must be positive
    • receivedAck

      public boolean receivedAck()
      Has at least one ACK been received?
      Returns:
      true once an ACK has advanced the RTT state machine past INIT
    • getResendDelay

      public int getResendDelay()
      Delay before retransmitting a packet in ms.
      Returns:
      the retransmit timer delay in ms
    • setResendDelay

      public void setResendDelay(int ms)
      Resend delay, clamped to [minResendDelay, maxResendDelay].
      Parameters:
      ms - the retransmit timer delay in ms
    • getSendAckDelay

      public int getSendAckDelay()
      Delay before sending a forced ACK when no data packets arrive. Ref: RFC 5681 sec. 4.3, RFC 1122 sec. 4.2.3.3, ticket #2706.
      Returns:
      the send ack delay
    • setSendAckDelay

      public void setSendAckDelay(int delayMs)
      Changing the default is not recommended. Ref: RFC 5681 sec. 4.3, RFC 1122 sec. 4.2.3.3, ticket #2706.
      Parameters:
      delayMs - delay before a forced ACK, clamped to [10, 500] ms
    • getMaxMessageSize

      public int getMaxMessageSize()
      Maximum message size (MTU/MRU).
      Returns:
      the message size cap in bytes
    • setMaxMessageSize

      public void setMaxMessageSize(int bytes)
      Maximum message size, floored at MIN_MESSAGE_SIZE.
      Parameters:
      bytes - the message size cap in bytes
    • getMaxInitialMessageSize

      public int getMaxInitialMessageSize()
      Largest message to send in SYN; taken as the min of the current maximum message size and DEFAULT_MAX_MESSAGE_SIZE. @since 0.9.47.
      Returns:
      the SYN message size in bytes
    • setMaxInitialMessageSize

      public void setMaxInitialMessageSize(int bytes)
      Largest message to send in SYN; stored unclamped.
      Parameters:
      bytes - the SYN message size in bytes
    • getProfile

      public int getProfile()
      Connection profile. Only bulk is supported. @since 0.9.64.
      Returns:
      the traffic profile
    • setProfile

      public void setProfile(int profile)
      Connection profile.
      Parameters:
      profile - the traffic profile; only bulk is supported
    • getPassiveFlushDelay

      public int getPassiveFlushDelay()
      Effective passive flush delay in ms.
      Returns:
      effective passive flush delay in ms: explicit value if set, otherwise the Tuner-managed global default
    • setPassiveFlushDelay

      public void setPassiveFlushDelay(int delayMs)
      Passive flush delay for the output stream.
      Parameters:
      delayMs - 0 to use Tuner-managed global default, positive for explicit delay
    • getMaxResends

      public int getMaxResends()
      Maximum retries per message.
      Returns:
      the per-packet resend budget
    • getStallGiveupMs

      public long getStallGiveupMs()
      Wall-clock ms an established connection may hold a packet in flight with no forward progress before being force-closed.
      Returns:
      the stall give-up budget in ms
    • setStallGiveupMs

      public void setStallGiveupMs(long ms)
      Wall-clock budget for giving up on forward progress. See PROP_STALL_GIVEUP_MS.
      Parameters:
      ms - wall-clock budget in ms; negative or zero disables the backstop
    • setMaxResends

      public void setMaxResends(int numSends)
      Maximum retries per message.
      Parameters:
      numSends - the per-packet resend budget; negative values clamp to 0, which disables the retransmit give-up
    • getInactivityTimeout

      public int getInactivityTimeout()
      Inactivity timeout before action in ms.
      Returns:
      the idle time before the inactivity action fires, in ms
    • setInactivityTimeout

      public void setInactivityTimeout(int timeout)
      Inactivity timeout before action.
      Parameters:
      timeout - the idle time before the inactivity action fires, in ms; stored unclamped
    • getInactivityAction

      public int getInactivityAction()
      Action taken when the inactivity timeout fires.
      Returns:
      the inactivity action
    • setInactivityAction

      public void setInactivityAction(int action)
      Action taken when the inactivity timeout fires.
      Parameters:
      action - one of INACTIVITY_ACTION_NOOP, _DISCONNECT or _SEND
    • getMaxWindowSize

      public int getMaxWindowSize()
      Maximum window size cap.
      Returns:
      per-connection cap if set, otherwise the Tuner-managed global ceiling
    • setMaxWindowSize

      public void setMaxWindowSize(int msgs)
      A value of 0 or less resets to the Tuner-managed global default. Clamped to [2, ABSOLUTE_MAX_WINDOW].
      Parameters:
      msgs - messages in flight; <= 0 clears the per-connection override
    • getInboundBufferSize

      public int getInboundBufferSize()
      Inbound buffer size.
      Returns:
      the inbound buffer size
    • setInboundBufferSize

      public void setInboundBufferSize(int bytes)
      Inbound buffer size in bytes.
      Parameters:
      bytes - the receive buffer size in bytes, stored unclamped
    • getMaxPacketCount

      public int getMaxPacketCount()
      Maximum packets to buffer regardless of byte size (hybrid byte+packet limit).
      Returns:
      the inbound packet-count cap
    • getCongestionAvoidanceGrowthRateFactor

      public int getCongestionAvoidanceGrowthRateFactor()
      In congestion avoidance, window grows at 1/(windowSize*factor). I2P uses messages vs TCP's bytes, so factor=maxMessageSize mimics TCP; smaller factor grows faster.
      Returns:
      the congestion avoidance growth rate factor
    • setCongestionAvoidanceGrowthRateFactor

      public void setCongestionAvoidanceGrowthRateFactor(int factor)
      Congestion avoidance growth rate factor.
      Parameters:
      factor - window growth divisor in congestion avoidance
    • getSlowStartGrowthRateFactor

      public int getSlowStartGrowthRateFactor()
      In slow start, window grows at 1/factor. factor=maxMessageSize mimics TCP; smaller factor grows faster.
      Returns:
      the slow start growth rate factor
    • setSlowStartGrowthRateFactor

      public void setSlowStartGrowthRateFactor(int factor)
      Slow start growth rate factor.
      Parameters:
      factor - window growth divisor during slow start
    • getMaxConnsPerMinute

      public int getMaxConnsPerMinute()
      Max connections per minute from a single peer.
      Returns:
      the max conns per minute
    • getMaxConnsPerHour

      public int getMaxConnsPerHour()
      Max connections per hour.
      Returns:
      the max conns per hour
    • getMaxConnsPerDay

      public int getMaxConnsPerDay()
      Max connections per day.
      Returns:
      the max conns per day
    • getMaxTotalConnsPerMinute

      public int getMaxTotalConnsPerMinute()
      Max total connections per minute.
      Returns:
      the max total conns per minute
    • getMaxTotalConnsPerHour

      public int getMaxTotalConnsPerHour()
      Max total connections per hour.
      Returns:
      the max total conns per hour
    • getMaxTotalConnsPerDay

      public int getMaxTotalConnsPerDay()
      Max total connections per day.
      Returns:
      the max total conns per day
    • getMaxConns

      public int getMaxConns()
      Concurrent stream ceiling a manager enforces; see PROP_MAX_STREAMS.
      Returns:
      the max concurrent streams
    • isAccessListEnabled

      public boolean isAccessListEnabled()
      Whether the access list is enabled.
      Returns:
      whether access list enabled
    • isBlacklistEnabled

      public boolean isBlacklistEnabled()
      Whether the blacklist is enabled.
      Returns:
      whether blacklist enabled
    • getAccessList

      public Set<Hash> getAccessList()
      Access list.
      Returns:
      the access list
    • getBlacklist

      public Set<Hash> getBlacklist()
      Destinations refused outright, consulted when blacklisting is enabled.
      Returns:
      the set as held, without copying; null unless isBlacklistEnabled() is true
    • getLimitAction

      public String getLimitAction()
      "reset", "drop", "http", or custom string; default "reset" @since 0.9.34.
      Returns:
      the action taken when a connection limit is exceeded
    • getTagsToSend

      public int getTagsToSend()
      Mostly handled on router side; PacketQueue needs to know for override limits @since 0.9.34.
      Returns:
      the number of ElGamal tags to send
    • getTagThreshold

      public int getTagThreshold()
      Tag count below which the session is considered tag-short.
      Returns:
      the tag count below which the session is considered tag-short
    • initLists

      private void initLists(ConnectionOptions opts)
      Copy the access/blacklist sets and their enable flags from another instance.
      Parameters:
      opts - source of the lists to share
    • initLists

      private void initLists(Properties opts)
      Build the access/blacklist sets from a comma, semicolon or space separated PROP_ACCESS_LIST, logging and skipping unparseable entries.
      Parameters:
      opts - properties to read the enable flags and hash list from
    • error

      private static void error(String s)
      Log an error message against the ConnectionOptions log.
      Parameters:
      s - message describing the problem
    • toString

      public String toString()
      Human-readable summary of the options.
      Overrides:
      toString in class Object
    • getMaxInboundBufferStatic

      public static int getMaxInboundBufferStatic()
      Maximum inbound buffer cap, tunable via Tuner.
      Returns:
      the inbound buffer cap in bytes
    • setMaxInboundBufferStatic

      public static void setMaxInboundBufferStatic(int val)
      Maximum inbound buffer cap, clamped to [512KB, 64MB].
      Parameters:
      val - the inbound buffer cap in bytes
    • initializeInboundBufferSize

      private void initializeInboundBufferSize()
      Initialize inbound buffer size and packet count cap.
    • getBool

      private static boolean getBool(Properties opts, String name, boolean defaultVal)
      Parse a boolean property from opts.
      Parameters:
      opts - properties to read from, may be null
      name - property key to look up
      defaultVal - fallback when opts is null or the key is absent
      Returns:
      the parsed flag, or defaultVal if unset; anything Boolean.parseBoolean(String) does not read as true is false