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.Location
Location in the tunnel for RED logic
|
| Constructor and Description |
|---|
TunnelDispatcher(RouterContext ctx)
Creates a new instance of TunnelDispatcher
|
| Modifier and Type | Method and Description |
|---|---|
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
|
void |
dispatchOutbound(I2NPMessage msg,
TunnelId outboundTunnel,
Hash targetPeer)
Dispatch an outbound message through a tunnel
|
void |
dispatchOutbound(I2NPMessage msg,
TunnelId outboundTunnel,
TunnelId targetTunnel,
Hash targetPeer) |
int |
getAllocatedBW()
Get the total bandwidth allocated for participating tunnels
|
long |
getLastParticipatingExpiration()
Returns the timestamp of the last participating tunnel expiration.
|
(package private) int |
getMaxPerTunnelBandwidth(TunnelDispatcher.Location loc)
Get the max bandwidth per 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 |
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 |
renderStatusHTML(Writer out)
Deprecated.
|
void |
restart()
Restart the TunnelDispatcher
|
(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
|
public TunnelDispatcher(RouterContext ctx)
public void dispatch(TunnelDataMessage msg, Hash recvFrom)
public void dispatch(TunnelGatewayMessage msg)
public void dispatchOutbound(I2NPMessage msg, TunnelId outboundTunnel, Hash targetPeer)
public void dispatchOutbound(I2NPMessage msg, TunnelId outboundTunnel, TunnelId targetTunnel, Hash targetPeer)
public int getAllocatedBW()
public long getLastParticipatingExpiration()
int getMaxPerTunnelBandwidth(TunnelDispatcher.Location loc)
public TunnelId getNewIBEPID()
public TunnelId getNewIBZeroHopID()
public TunnelId getNewOBGWID()
public int getParticipatingCount()
public static int getShareBandwidth(RouterContext ctx)
public boolean hasOutboundGateway(TunnelId tid)
public boolean joinInbound(TunnelCreatorConfig cfg)
public boolean joinInboundGateway(HopConfig cfg)
public boolean joinOutbound(PooledTunnelCreatorConfig cfg)
public boolean joinOutboundEndpoint(HopConfig cfg)
public boolean joinParticipant(HopConfig cfg)
public List<HopConfig> listParticipatingTunnels()
public void remove(HopConfig cfg)
public void remove(TunnelCreatorConfig cfg)
@Deprecated public void renderStatusHTML(Writer out) throws IOException
renderStatusHTML in interface ServiceIOExceptionpublic void restart()
boolean shouldDropParticipatingMessage(TunnelDispatcher.Location loc, int type, int length, SyntheticREDQueue bwe)
public void shutdown()
public void startup()
public void updateParticipatingStats(int ms)