public class TunnelDispatcher extends Object implements Service
For each type of tunnel, it creates a chain of handlers, as follows:
Following tunnels are created by us:
Outbound Gateway > 0 hops:
PumpedTunnelGateway
BatchedRouterPreprocessor -> OutboundSender -> OutboundReceiver -> OutNetMessagePool
Outbound zero-hop Gateway+Endpoint:
TunnelGatewayZeroHop
OutboundMessageDistributor -> OutNetMessagePool
Inbound Endpoint > 0 hops:
TunnelParticipant
RouterFragmentHandler -> InboundEndpointProcessor -> InboundMessageDistributor -> InNetMessagePool
Inbound zero-hop Gateway+Endpoint:
TunnelGatewayZeroHop
InboundMessageDistributor -> InNetMessagePool
Following tunnels are NOT created by us:
Participant (not gateway or endpoint)
TunnelParticipant
HopProcessor -> OutNetMessagePool
Outbound Endpoint > 0 hops:
OutboundTunnelEndpoint
RouterFragmentHandler -> HopProcessor -> OutboundMessageDistributor -> OutNetMessagePool
Inbound Gateway > 0 hops:
ThrottledPumpedTunnelGateway
BatchedRouterPreprocessor -> InboundSender -> InboundGatewayReceiver -> OutNetMessagePool
| Modifier and Type | Class and Description |
|---|---|
static class | TunnelDispatcher.LocationLocation in the tunnel for RED (Random Early Discard) logic. |
| Constructor and Description |
|---|
TunnelDispatcher(RouterContext ctx)Creates a new instance of TunnelDispatcher |
| Modifier and Type | Method and Description |
|---|---|
static void | adjustPumperThreads(int value) |
void | dispatch(TunnelDataMessage msg,
Hash recvFrom)Dispatch a TunnelDataMessage to the appropriate participant or endpoint |
void | dispatch(TunnelGatewayMessage msg)Dispatch a TunnelGatewayMessage to the appropriate gateway |
boolean | dispatchOutbound(I2NPMessage msg,
TunnelId outboundTunnel,
Hash targetPeer)Dispatch an outbound message through a tunnel. |
boolean | dispatchOutbound(I2NPMessage msg,
TunnelId outboundTunnel,
TunnelId targetTunnel,
Hash targetPeer)Dispatch an outbound message through a tunnel. |
void | freeBandwidth(int bw)Free allocated bandwidth for a tunnel. |
int | getAllocatedBW()Get the total bandwidth allocated for participating tunnels |
long | getLastParticipatingExpiration()Returns the timestamp of the last participating tunnel expiration. |
static int | getMaxIbMsgsPerPump() |
static int | getMaxObMsgsPerPump() |
(package private) int | getMaxPerTunnelBandwidth(TunnelDispatcher.Location loc)Get the max bandwidth per transit tunnel. |
TunnelId | getNewIBEPID()Get a new random receive tunnel ID that isn't a duplicate |
TunnelId | getNewIBZeroHopID()Get a new random receive tunnel ID that isn't a duplicate (zero hop) |
TunnelId | getNewOBGWID()Get a new random send tunnel ID that isn't a duplicate |
int | getParticipatingCount()Get the number of participating tunnels |
static int | getPumperMaxThreads() |
static int | getPumperQueueCapacity() |
static double | getPumperUtilization()Get pumper pool utilization as a ratio (0.0-1.0). |
static long | getRequeueTime() |
static int | getShareBandwidth(RouterContext ctx)Get the current bandwidth share in KBps |
boolean | hasOutboundGateway(TunnelId tid) |
boolean | joinInbound(TunnelCreatorConfig cfg)We are the inbound endpoint - we created this tunnel |
boolean | joinInboundGateway(HopConfig cfg)We are the inbound gateway in this tunnel, and did not create it |
boolean | joinOutbound(PooledTunnelCreatorConfig cfg)We are the outbound gateway - we created this tunnel |
boolean | joinOutboundEndpoint(HopConfig cfg)We are the outbound endpoint in this tunnel, and did not create it |
boolean | joinParticipant(HopConfig cfg)We are a participant in this tunnel, but not as the endpoint or gateway |
List<HopConfig> | listParticipatingTunnels()Get a list of participating tunnels (for console display). |
void | remove(HopConfig cfg)Remove a tunnel we're participating in |
void | remove(TunnelCreatorConfig cfg)Remove a tunnel we created |
void | removeFromExpirationQueue(HopConfig cfg)Remove a tunnel from the expiration queue. |
static void | resizePumperQueue(int value) |
void | restart()Restart the TunnelDispatcher |
static void | setMaxIbMsgsPerPump(int val) |
static void | setMaxObMsgsPerPump(int val) |
static void | setPumperMaxThreads(int value) |
static void | setPumperQueueCapacity(int value) |
static void | setRequeueTime(long ms) |
(package private) boolean | shouldDropParticipatingInboundMessage(TunnelDispatcher.Location loc,
int type,
int length,
SyntheticREDQueue bwe)Check if we should drop an inbound participating tunnel message. |
(package private) boolean | shouldDropParticipatingMessage(TunnelDispatcher.Location loc,
int type,
int length,
SyntheticREDQueue bwe)Implement RED (Random Early Discard) to enforce bandwidth limits. |
void | shutdown()Shut down TunnelDispatcher |
void | startup()Start up the TunnelDispatcher |
void | updateParticipatingStats(int ms)Update stats for participating tunnels |
(package private) void | updateThrottleFactors()Update cached transit throttle factors from router properties. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitrenderStatusHTMLpublic TunnelDispatcher(RouterContext ctx)
ctx - the router contextpublic static void adjustPumperThreads(int value)
public void dispatch(TunnelDataMessage msg, Hash recvFrom)
public void dispatch(TunnelGatewayMessage msg)
public boolean dispatchOutbound(I2NPMessage msg, TunnelId outboundTunnel, Hash targetPeer)
public boolean dispatchOutbound(I2NPMessage msg, TunnelId outboundTunnel, TunnelId targetTunnel, Hash targetPeer)
public void freeBandwidth(int bw)
public int getAllocatedBW()
public long getLastParticipatingExpiration()
public static int getMaxIbMsgsPerPump()
public static int getMaxObMsgsPerPump()
int getMaxPerTunnelBandwidth(TunnelDispatcher.Location loc)
public TunnelId getNewIBEPID()
public TunnelId getNewIBZeroHopID()
public TunnelId getNewOBGWID()
public int getParticipatingCount()
public static int getPumperMaxThreads()
public static int getPumperQueueCapacity()
public static double getPumperUtilization()
public static long getRequeueTime()
public static int getShareBandwidth(RouterContext ctx)
public boolean hasOutboundGateway(TunnelId tid)
public boolean joinInbound(TunnelCreatorConfig cfg)
cfg - config for the inbound tunnel we createdpublic boolean joinInboundGateway(HopConfig cfg)
public boolean joinOutbound(PooledTunnelCreatorConfig cfg)
cfg - config for the outbound tunnel we createdpublic boolean joinOutboundEndpoint(HopConfig cfg)
cfg - config for the tunnel we're joining as outbound endpointpublic boolean joinParticipant(HopConfig cfg)
cfg - config for the tunnel we're joining as participantpublic List<HopConfig> listParticipatingTunnels()
public void remove(HopConfig cfg)
public void remove(TunnelCreatorConfig cfg)
public void removeFromExpirationQueue(HopConfig cfg)
public static void resizePumperQueue(int value)
public static void setMaxIbMsgsPerPump(int val)
public static void setMaxObMsgsPerPump(int val)
public static void setPumperMaxThreads(int value)
public static void setPumperQueueCapacity(int value)
public static void setRequeueTime(long ms)
boolean shouldDropParticipatingInboundMessage(TunnelDispatcher.Location loc, int type, int length, SyntheticREDQueue bwe)
loc - location in tunnel (IBGP, PARTICIPANT, OBEP)type - message typelength - message size in bytesbwe - per-tunnel bandwidth estimator (may be null)boolean shouldDropParticipatingMessage(TunnelDispatcher.Location loc, int type, int length, SyntheticREDQueue bwe)
public void updateParticipatingStats(int ms)
void updateThrottleFactors()