java.lang.Object
net.i2p.router.tunnel.pool.BuildRequestor
Utility class for creating and dispatching tunnel build request messages.
This class handles:
- Preparation of tunnel hop IDs
- Selection of paired or exploratory tunnels for replies
- Construction of
TunnelBuildMessage, including legacy and new-style (Short/Variable) formats - Garlic encryption for inbound builds
- Timeout and failure handling
Paired tunnels are always used (as of 0.9.50+) to improve client isolation and prevent correlation across tunnel pools.
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final StringProposal 168 available bandwidth property key.(package private) static final StringProposal 168 maximum bandwidth property key.(package private) static final StringProposal 168 minimum bandwidth property key.(package private) static final StringProperty to enable/disable pre-connect fallback on build failure.(package private) static final StringProposal 168 required bandwidth property key.Method Summary
All MethodsModifier and TypeMethodDescriptionstatic HashThe peer that will receive the tunnel build request (TBM): the gateway (peer 0) for inbound tunnels, or the next hop (peer 1) for outbound tunnels.static intHow long the OutNetMessage for the first hop gets before TunnelBuildFirstHopFailJob fires.static intHow long we wait for a reply before trying a different pool/peers.(package private) static booleanpreConnectFallback(RouterContext ctx, Hash peer, PooledTunnelCreatorConfig cfg, BuildExecutor exec) Approach 2: Fire-and-forget fallback — attempt to establish the transport session and retry the build once.static booleanrequest(RouterContext ctx, PooledTunnelCreatorConfig cfg, BuildExecutor exec, long firstHopTimeout) Initiates a tunnel build request.static voidsetFirstHopTimeout(int ms) Set the first-hop timeout (called by Tuner).static voidsetRequestTimeout(int ms) Set the build request timeout (called by Tuner).
Field Details
PROP_PRECONNECT_ENABLED
Property to enable/disable pre-connect fallback on build failure.- See Also:
PROP_MIN_BW
Proposal 168 minimum bandwidth property key.- See Also:
PROP_REQ_BW
Proposal 168 required bandwidth property key.- See Also:
PROP_MAX_BW
Proposal 168 maximum bandwidth property key.- See Also:
PROP_AVAIL_BW
Proposal 168 available bandwidth property key.- See Also:
Method Details
setRequestTimeout
public static void setRequestTimeout(int ms) Set the build request timeout (called by Tuner).- Parameters:
ms- the build request timeout in ms
setFirstHopTimeout
public static void setFirstHopTimeout(int ms) Set the first-hop timeout (called by Tuner).- Parameters:
ms- the first-hop timeout in ms
getRequestTimeout
How long we wait for a reply before trying a different pool/peers. Adaptive mechanism in BuildExecutor adjusts this upward when success rates are low or timeout rates are high. Default: 13s (normal), 18s (slow systems).- Parameters:
ctx- the router context- Returns:
- request timeout in ms
getFirstHopTimeout
How long the OutNetMessage for the first hop gets before TunnelBuildFirstHopFailJob fires. Shorter than request timeout so first-hop failure is detected before the full build timeout.- Parameters:
ctx- the router context- Returns:
- first hop timeout in ms
getBuildRequestPeer
The peer that will receive the tunnel build request (TBM): the gateway (peer 0) for inbound tunnels, or the next hop (peer 1) for outbound tunnels. BuildExecutor's per-peer pacing guard must target the same peer the dispatch code sends the request to, so both use this single derivation.Returns null for a config too short to have a hop 1. Exploratory pools build length-1 tunnels whose peer array holds only the gateway, so asking for hop 1 would throw and abandon the build outright — which stops every exploratory pool from populating.
- Parameters:
cfg- non-null; may be a short config- Returns:
- the dispatch target peer, or null if the config has no hop 1
request
public static boolean request(RouterContext ctx, PooledTunnelCreatorConfig cfg, BuildExecutor exec, long firstHopTimeout) Initiates a tunnel build request.- Parameters:
ctx- the router context issuing the buildcfg- tunnel configuration (must have ReplyMessageId set)exec- executor to notify on completionfirstHopTimeout- adaptive first-hop timeout ms (from BuildExecutor stats)- Returns:
trueif request was successfully dispatched
preConnectFallback
static boolean preConnectFallback(RouterContext ctx, Hash peer, PooledTunnelCreatorConfig cfg, BuildExecutor exec) Approach 2: Fire-and-forget fallback — attempt to establish the transport session and retry the build once. Called fromTunnelBuildFirstHopFailJobwhen the first hop has no established or connecting transport session.Calls
TunnelPeerSelector.preConnectTo(RouterContext, Hash)to force the session handshake, then re-dispatches the tunnel build message. Returns true if the retry was initiated.- Parameters:
ctx- the router contextpeer- the first-hop peer that failedcfg- the tunnel configurationexec- the build executor to notify on completion- Returns:
- true if the retry was initiated, false if pre-connect failed and the build should be abandoned