- All Implemented Interfaces:
TunnelInfo
Nested Class Summary
Nested classes/interfaces inherited from class TunnelCreatorConfig
TunnelCreatorConfig.LastChanceReasonModifier and TypeClassDescriptionstatic enumWhy a tunnel that would normally be dropped by the early-expiry gate was instead admitted for one last-chance test.Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanTrue to send through the tunnel without waiting for pacing.private longWhen the tunnel last carried a message.private longI2NP message ID of the most recent build request sent for this config.private booleanTrue to use the tunnel only when nothing better is available.private TunnelIdThe gateway tunnel paired with this one, by id only - storing the config itself leads to OOM.private final TunnelPoolThe pool this config belongs to.private static final longQuiet time past which the tunnel counts as inactive: 30 seconds.Fields inherited from class TunnelCreatorConfig
_context, FAILURE_COUNT_CEILING, FIRST_HOP_FAILURE_SPACING_MS, FIRST_HOP_FAILURE_THRESHOLD, FIRST_HOP_FAILURE_WINDOW_MS, MAX_CONSECUTIVE_TEST_FAILURES, REPLY_IV_LENGTHModifier and TypeFieldDescriptionprotected final RouterContextThe router context.static final intCeiling forTunnelCreatorConfig.incrementTestFailures().static final longMinimum spacing between first-hop send failures that count towardsTunnelCreatorConfig.FIRST_HOP_FAILURE_THRESHOLD.static final intConsecutive first-hop send failures before an outbound tunnel is retired.static final longWindow in which spaced first-hop send failures accumulate, mirroringTunnelCreatorConfig.SOFT_FAILURE_WINDOW_MS.static final intMaximum consecutive test failures before the tunnel is retired.static final intIV length forTunnelCreatorConfig.getAESReplyIV(int).Constructor Summary
ConstructorsConstructorDescriptionPooledTunnelCreatorConfig(RouterContext ctx, int length, boolean isInbound, Hash destination, TunnelPool pool) Creates a new instance of PooledTunnelCreatorConfig.Method Summary
Modifier and TypeMethodDescriptionvoidfirstHopSendFailureStreak(int streak) Re-warm the session to the first hop of an outbound tunnel whose send failures are approaching the fatal threshold.longGet the time this tunnel last processed a message.longThe I2NP message ID of the most recent build request sent for this config.Get the extra options configured on the owning pool.The ID of the gateway of the paired tunnel used to send/receive the build request.Get the pool this tunnel belongs to.booleanTest whether this build may ignore the per-peer in-flight guard.booleanTest whether this tunnel was built because the pool had nothing else.booleanTest whether this tunnel has been used recently enough to count as live.voidRecord activity on this tunnel (message processed).voidMark this build as emergency recovery: it must be sent even if the first-hop peer already has a build in flight.voidsetLastRequestMsgId(long msgId) Record the I2NP message ID of a build request just sent for this config.voidMark this tunnel as a last-resort fallback.voidsetPairedGW(TunnelId gw) The ID of the gateway of the paired tunnel used to send/receive the build request.(package private) static booleanshouldPreConnect(int streak) Whether a first-hop send-failure streak warrants a pre-connect re-warm.voidtestJobSuccessful(int ms) Record that a test of this tunnel succeeded, as TestJob does after a round trip.booleanThe tunnel failed a test, so (maybe) stop using it.voidWe failed to contact the first hop for an outbound tunnel, so immediately stop using it.Methods inherited from class TunnelCreatorConfig
addLatencySample, admitLastChance, claimPreConnectRetry, clearExpeditedTest, clearFirstHopFailures, clearLastChanceAdmission, clearSoftFailures, clearTestFailures, getAESReplyIV, getAESReplyKey, getAverageLatency, getBlankHash, getChaChaReplyAD, getChaChaReplyKey, getConfig, getConsecutiveFailures, getCreationTime, getDestination, getDestinationNickname, getEndpoint, getExpiration, getFarEnd, getFirstHopSendFailures, getGarlicReplyKeys, getGateway, getLastChanceAdmission, getLastChanceDeadline, getLastChanceReason, getLastLatency, getLastRealTraffic, getLastTransferred, getLength, getLocalHopMissingSince, getPeer, getPriority, getProcessedMessagesCount, getReceiveTunnelId, getRecentTestExemptions, getReplyMessageId, getReplyOrder, getSendTunnelId, getSoftFailures, getTestStatus, getTunnelFailed, getTunnelFailures, getVerifiedBytesTransferred, hadLocalHopSession, hasEnoughLatencyTests, incrementProcessedMessages, incrementRecentTestExemptions, incrementSoftFailures, incrementTestFailures, incrementVerifiedBytesTransferred, incrementVerifiedBytesTransferred, isEC, isInbound, isLastChanceAdmitted, needsExpeditedTest, recordFirstHopSendFailure, recordRealTraffic, requestExpeditedTest, setAESReplyKeys, setBlankHash, setChaChaReplyKeys, setDestinationNickname, setExpiration, setGarlicReplyKeys, setLastLatency, setLocalHopMissingSince, setLocalHopSessionEstablished, setPeer, setPriority, setReplyMessageId, setReplyOrder, setReused, setTestFailed, setTestFailing, setTestOverBudget, setTestStarted, setTestTooSlow, testSuccessful, toShortString, toString, toStringFull, tunnelFailedCompletely, wasReusedModifier and TypeMethodDescriptionvoidaddLatencySample(int ms) Add a latency sample from a test result.voidadmitLastChance(long now, TunnelCreatorConfig.LastChanceReason reason) Admit this tunnel for a last-chance test despite its remaining life being inside the early-expiry window.booleanclaimPreConnectRetry(long now, int maxRetries, long windowMs) Claim one of at mostmaxRetriespre-connect retries for this tunnel, forgetting retries older thanwindowMs.voidClear the expedited test flag after running the expedited test.voidReset the first-hop send failure streak and re-arm the escalation latch.voidRevoke the last-chance admission (test settled, or no longer needed).voidReset the soft streak: verified traffic proves the tunnel carries data, so congestion timeouts recorded before it no longer count.voidReset the consecutive failure counter and mark the tunnel as GOOD.byte[]getAESReplyIV(int hop) IV used to encrypt the reply sent for the tunnel creation crypto.getAESReplyKey(int hop) Key to encrypt the reply sent for the tunnel creation crypto.intThe average latency of the last 3 tests.Checksum for blank record.byte[]getChaChaReplyAD(int hop) The ECIES reply associated data for the given hop, or null.getChaChaReplyKey(int hop) The ECIES reply key for the given hop, or null.getConfig(int hop) Retrieve the config for the given hop.intThe number of consecutive test failures.longWhen this tunnel was built, in wall-clock ms.If this is a client tunnel, what destination is it for?Pool nickname for this tunnel, or null if not set.For convenience.longThe tunnel expiration, in ms since the epoch.For convenience.intEffective first-hop send failure streak, with failures older thanTunnelCreatorConfig.FIRST_HOP_FAILURE_WINDOW_MSdecayed out at read time.ECIES short OBEP record only.For convenience.longWhen the last-chance admission was granted (ms), or 0 if never.longWhen the last-chance admission expires (deadline snapshot).Why this tunnel was admitted for a last-chance test.intThe last recorded test latency.longWhen the tunnel last carried real traffic.longWhen we last sent or received data on this tunnel.intHow many hops are there in the tunnel? INCLUDING US.longWhen the local transport session was first seen missing, or 0 when present.getPeer(int hop) Retrieve the peer at the given hop (the gateway is hop 0).intOutbound message priority - for outbound tunnels only.intThe number of messages pumped through this tunnel.getReceiveTunnelId(int hop) Retrieve the tunnelId that the given hop receives messages on.intThe number of recent-traffic test exemptions used.longThe message ID for the new style reply.Component ordering in the new style request.getSendTunnelId(int hop) Retrieve the tunnelId that the given hop sends messages on.intSoft best-effort timeout count, with failures older thanTunnelCreatorConfig.SOFT_FAILURE_WINDOW_MSdecayed out at read time (the time-windowed form of the streak — no sweep required).The current test status of this tunnel for UI display.booleanHas the tunnel failed completely?intThe consecutive failure count.longThe total verified bytes transferred on this tunnel.booleanWhether this tunnel held a transport session to its local hop when it was built.booleanWhether at least 3 latency samples have been collected.voidTake note of a message being pumped through this tunnel.voidIncrement the recent-traffic test exemption counter.voidIncrement the soft best-effort timeout counter only.voidIncrement the failure count without triggering pool removal or reuse flag.voidincrementVerifiedBytesTransferred(int bytes) Record thatbytesmoved through this tunnel, counting as real traffic: it also stamps the last-real-traffic clock thatTunnelCreatorConfig.getLastTransferred()reports and the data-verified test trust in TestJob keys off.voidincrementVerifiedBytesTransferred(int bytes, boolean realTraffic) Record thatbytesmoved through this tunnel, optionally counting as real traffic.booleanisEC(int hop) Is it an ECIES hop?booleanIs this an inbound tunnel?booleanisLastChanceAdmitted(long now) Is a last-chance test admission still valid atnow? Only expiration shortens the window.booleanWhether the tunnel needs an expedited test due to slow detection.intRecord a failed send to the first hop of an outbound tunnel.voidRecord that the tunnel carried real traffic.voidThe tunnel appeared slow, so flag it for an expedited test.voidsetAESReplyKeys(int hop, SessionKey key, byte[] iv) Key and IV to encrypt the reply sent for the tunnel creation crypto.voidsetBlankHash(Hash h) Checksum for blank record.voidsetChaChaReplyKeys(int hop, SessionKey key, byte[] ad) The ECIES reply key and associated data for the given hop.voidsetDestinationNickname(String name) Optional display nickname for this tunnel (e.g.voidsetExpiration(long when) The tunnel expiration, in ms since the epoch.voidECIES short OBEP record only.voidsetLastLatency(int ms) The latency of the last completed test.voidsetLocalHopMissingSince(long when) Record or clear when the local transport session was first seen missing.voidsetLocalHopSessionEstablished(boolean established) Record whether a transport session to the local hop existed at build time.voidThe peer at the given hop.voidsetPriority(int priority) Outbound message priority - for outbound tunnels only.voidsetReplyMessageId(long id) The message ID for the new style reply.voidsetReplyOrder(List<Integer> order) The component ordering for the new style request.voidNote that we reused this tunnel.voidCalled when a test fails.voidMark the tunnel FAILING regardless of the hard-failure counter.voidMark tunnel as scheduled for early expiry due to pool being over budget.voidCalled when a test is started.voidMark tunnel as scheduled for early expiry (pruned from pool).voidtestSuccessful(int ms) Mark the tunnel as GOOD, recording the latency of the successful test.Compact one-line tunnel identifier for log output: role, client or exploratory, nickname and short destination.toString()Human-readable description of the tunnel, its peers, and its state.Render every hop, its peer, and its tunnel IDs, for a full description.voidThe tunnel failed completely, so definitely stop using it.booleanDid we reuse this tunnel?
Field Details
_pool
The pool this config belongs to._pairedGW
The gateway tunnel paired with this one, by id only - storing the config itself leads to OOM._lastActivity
private volatile long _lastActivityWhen the tunnel last carried a message._lastResort
private volatile boolean _lastResortTrue to use the tunnel only when nothing better is available._bypassPacing
private volatile boolean _bypassPacingTrue to send through the tunnel without waiting for pacing._lastRequestMsgId
private volatile long _lastRequestMsgIdI2NP message ID of the most recent build request sent for this config.This is the join key between the send side (
BuildRequestorlogs it as[MsgID ...], on both the direct and exploratory send paths) and the expiry side (BuildExecutor.logExpiredBuildWarnlogs it asreqMsgId=...), so a build that expires unanswered can be attributed to a specific send. Without it, "established, silent" is indistinguishable between a hop that never answered and a reply that was lost, which is why no amount of deadline tuning could be shown to help.0 means not yet sent, or not a
PooledTunnelCreatorConfig. Written on the build executor thread and read on the expiry path, hence volatile; a stale read costs only a missing correlation ID, never correctness.ACTIVITY_TIMEOUT
private static final long ACTIVITY_TIMEOUTQuiet time past which the tunnel counts as inactive: 30 seconds.- See Also:
Constructor Details
PooledTunnelCreatorConfig
public PooledTunnelCreatorConfig(RouterContext ctx, int length, boolean isInbound, Hash destination, TunnelPool pool) Creates a new instance of PooledTunnelCreatorConfig.- Parameters:
ctx- the router context supplying the transport and profile lookupslength- the tunnel length in hops, 1 minimum (a 0-hop tunnel is length 1)isInbound- true for a client inbound tunnel, false for an outbound onedestination- may be nullpool- the owning pool, never null
Method Details
testJobSuccessful
public void testJobSuccessful(int ms) Record that a test of this tunnel succeeded, as TestJob does after a round trip.- Parameters:
ms- the round-trip time of the successful tunnel test, in milliseconds
tunnelFailed
public boolean tunnelFailed()The tunnel failed a test, so (maybe) stop using it.- Overrides:
tunnelFailedin classTunnelCreatorConfig- Returns:
- false if we stopped using it, true if still ok
tunnelFailedFirstHop
public void tunnelFailedFirstHop()We failed to contact the first hop for an outbound tunnel, so immediately stop using it. For outbound non-zero-hop tunnels only.Does not blame any peer: first-hop send failures are local congestion, not a dead peer. Proportional blame still accumulated ~50 points per failure per hop — 8 consecutive failures banlisted the first hop and collapsed the pool.
- Overrides:
tunnelFailedFirstHopin classTunnelCreatorConfig
firstHopSendFailureStreak
public void firstHopSendFailureStreak(int streak) Re-warm the session to the first hop of an outbound tunnel whose send failures are approaching the fatal threshold. A direct transport send forces the connection up again, so the next tunnel message is not queued behind a stale session.Gated by
shouldPreConnect(int), so the DatabaseLookupMessage round-trip only ever reaches a hop the router has not yet given up on.- Overrides:
firstHopSendFailureStreakin classTunnelCreatorConfig- Parameters:
streak- the current first-hop failure streak
shouldPreConnect
static boolean shouldPreConnect(int streak) Whether a first-hop send-failure streak warrants a pre-connect re-warm.Fires only on the strike immediately below
TunnelCreatorConfig.FIRST_HOP_FAILURE_THRESHOLD— the last point at which the tunnel is still alive to benefit. Earlier strikes have not yet committed to blaming the peer, so a round-trip would only add load to a path that may merely be congested; the threshold strike itself retires the tunnel as soon as the hook returns, so re-warming there would send a lookup to a hop the router has already decided to blame.- Parameters:
streak- the current first-hop failure streak- Returns:
- true if the first-hop session should be re-warmed
getOptions
Get the extra options configured on the owning pool.- Overrides:
getOptionsin classTunnelCreatorConfig- Returns:
- the pool's unknown options, never null
getTunnelPool
Get the pool this tunnel belongs to.- Returns:
- the owning pool, never null
isLastResort
public boolean isLastResort()Test whether this tunnel was built because the pool had nothing else.- Returns:
- true if this tunnel was built as a last-resort fallback
setLastResort
public void setLastResort()Mark this tunnel as a last-resort fallback.isBypassPacing
public boolean isBypassPacing()Test whether this build may ignore the per-peer in-flight guard.- Returns:
- true if this build bypasses the per-peer in-flight guard in
setBypassPacing
public void setBypassPacing()Mark this build as emergency recovery: it must be sent even if the first-hop peer already has a build in flight. Set by the pool when it has zero usable tunnels and cannot wait for the guard to clear.recordActivity
public void recordActivity()Record activity on this tunnel (message processed).getLastActivity
public long getLastActivity()Get the time this tunnel last processed a message.- Returns:
- timestamp of last activity, or 0 if never used
isRecentlyActive
public boolean isRecentlyActive()Test whether this tunnel has been used recently enough to count as live.- Returns:
- true if this tunnel has been recently active (within ACTIVITY_TIMEOUT)
setPairedGW
The ID of the gateway of the paired tunnel used to send/receive the build request.- Parameters:
gw- for paired inbound, the GW rcv tunnel ID; for paired outbound, the GW send tunnel ID.
getPairedGW
The ID of the gateway of the paired tunnel used to send/receive the build request.- Returns:
- for paired inbound, the GW rcv tunnel ID; for paired outbound, the GW send tunnel ID. null if not previously set
setLastRequestMsgId
public void setLastRequestMsgId(long msgId) Record the I2NP message ID of a build request just sent for this config.A config may be retried, so this holds the most recent attempt rather than the first; the expiry report wants the send that actually went out.
- Parameters:
msgId- thegetUniqueId()of theTunnelBuildMessagehanded to the transport or dispatcher
getLastRequestMsgId
public long getLastRequestMsgId()The I2NP message ID of the most recent build request sent for this config.- Returns:
- the message ID, or 0 if no request has been sent yet