Package net.i2p.router.tunnel
Class PumpedTunnelGateway
java.lang.Object
net.i2p.router.tunnel.TunnelGateway
net.i2p.router.tunnel.PumpedTunnelGateway
- Direct Known Subclasses:
ThrottledPumpedTunnelGateway
class PumpedTunnelGateway extends TunnelGateway
This is used for all gateways with more than zero hops.
Serve as the gatekeeper for a tunnel, accepting messages, coalescing and/or
fragmenting them before wrapping them up for tunnel delivery. The flow here
is:
- add an I2NPMessage (and a target tunnel/router, if necessary)
- that message is queued up into a TunnelGateway.Pending and offered to the assigned QueuePreprocessor.
- that QueuePreprocessor may then take off any of the TunnelGateway.Pending messages or instruct the TunnelGateway to offer it the messages again in a short while (in an attempt to coalesce them).
- when the QueueProcessor accepts a TunnelGateway.Pending, it preprocesses it into fragments, forwarding each preprocessed fragment group through the Sender.
- the Sender then encrypts the preprocessed data and delivers it to the Receiver.
- the Receiver now has the encrypted message and may do with it as it pleases (e.g. wrap it as necessary and enqueue it onto the OutNetMessagePool, or if debugging, verify that it can be decrypted properly)
-
Nested Class Summary
Nested classes/interfaces inherited from class net.i2p.router.tunnel.TunnelGateway
TunnelGateway.DelayedFlush, TunnelGateway.QueuePreprocessor, TunnelGateway.Receiver, TunnelGateway.Sender
-
Field Summary
Fields Modifier and Type Field Description boolean
_isInbound
static String
PROP_INITIAL_OB_QUEUE
static String
PROP_MAX_IB_MSGS_PER_PUMP
static String
PROP_MAX_IB_QUEUE
static String
PROP_MAX_OB_MSGS_PER_PUMP
Fields inherited from class net.i2p.router.tunnel.TunnelGateway
_context, _delayedFlush, _lastFlush, _log, _messagesSent, _preprocessor, _queue, _receiver, _sender
-
Constructor Summary
Constructors Constructor Description PumpedTunnelGateway(RouterContext context, TunnelGateway.QueuePreprocessor preprocessor, TunnelGateway.Sender sender, TunnelGateway.Receiver receiver, TunnelGatewayPumper pumper)
-
Method Summary
Modifier and Type Method Description void
add(I2NPMessage msg, Hash toRouter, TunnelId toTunnel)
Add a message to be sent down the tunnel, either sending it now (perhaps coalesced with other pending messages) or after a brief pause (_flushFrequency).protected void
add(PendingGatewayMessage cur)
boolean
pump(List<PendingGatewayMessage> queueBuf)
run in one of the TunnelGatewayPumper's threads, this pulls pending messages off the prequeue, adds them to the queue and then tries to preprocess the queue, scheduling a later delayed flush as necessary.
-
Field Details
-
_isInbound
public final boolean _isInbound -
PROP_MAX_OB_MSGS_PER_PUMP
- See Also:
- Constant Field Values
-
PROP_MAX_IB_MSGS_PER_PUMP
- See Also:
- Constant Field Values
-
PROP_INITIAL_OB_QUEUE
- See Also:
- Constant Field Values
-
PROP_MAX_IB_QUEUE
- See Also:
- Constant Field Values
-
-
Constructor Details
-
PumpedTunnelGateway
public PumpedTunnelGateway(RouterContext context, TunnelGateway.QueuePreprocessor preprocessor, TunnelGateway.Sender sender, TunnelGateway.Receiver receiver, TunnelGatewayPumper pumper)- Parameters:
preprocessor
- this pulls Pending messages off a list, builds some full preprocessed messages, and pumps those into the sendersender
- this takes a preprocessed message, encrypts it, and sends it to the receiverreceiver
- this receives the encrypted message and forwards it off to the first hop
-
-
Method Details
-
add
Add a message to be sent down the tunnel, either sending it now (perhaps coalesced with other pending messages) or after a brief pause (_flushFrequency). If it is queued up past its expiration, it is silently dropped This is only for OBGWs. See TPTG override for IBGWs.- Overrides:
add
in classTunnelGateway
- Parameters:
msg
- message to be sent through the tunneltoRouter
- router to send to after the endpoint (or null for endpoint processing)toTunnel
- tunnel to send to after the endpoint (or null for endpoint or router processing)
-
add
-
pump
run in one of the TunnelGatewayPumper's threads, this pulls pending messages off the prequeue, adds them to the queue and then tries to preprocess the queue, scheduling a later delayed flush as necessary. this allows the gw.add call to go quickly, rather than blocking its callers on potentially substantial processing.- Parameters:
queueBuf
- Empty list for convenience, to use as a temporary buffer. Must be empty when called; will always be emptied before return.- Returns:
- true if we did not finish, and the pumper should be requeued.
-