This class drops messages early based on bandwidth heuristics to more efficiently preserve network and system resources compared to processing fragments.
The drop decision is made here instead of deeper in the tunnel to allow dropping whole I2NP messages, where message type and size are known accurately.
Thread safety and behavior otherwise follows PumpedTunnelGateway.
Nested Class Summary
Nested classes/interfaces inherited from class TunnelGateway
TunnelGateway.DelayedFlush, TunnelGateway.QueuePreprocessor, TunnelGateway.Receiver, TunnelGateway.SenderModifier and TypeClassDescriptionprotected classDelayed flush timer event.static interfaceInterface for preprocessing queued tunnel messages.static interfaceInterface for receiving encrypted tunnel data.static interfaceInterface for sending preprocessed tunnel data.Field Summary
FieldsModifier and TypeFieldDescriptionprivate final HopConfigConfiguration and statistics for this hop, used to count dropped messages.private final SyntheticREDQueueSynthetic Random Early Drop queue to estimate bandwidth usage and perform drops.Fields inherited from class PumpedTunnelGateway
_isInbound, PROP_INITIAL_OB_QUEUE, PROP_MAX_IB_MSGS_PER_PUMP, PROP_MAX_IB_QUEUE, PROP_MAX_OB_MSGS_PER_PUMPModifier and TypeFieldDescriptionfinal booleanWhether this gateway is inbound (vs outbound).static final StringProperty key for initial outbound queue size.static final StringProperty key for max inbound messages per pump.static final StringProperty key for max inbound queue size.static final StringProperty key for max outbound messages per pump.Fields inherited from class TunnelGateway
_context, _delayedFlush, _lastFlush, _log, _messagesSent, _preprocessor, _queue, _receiver, _senderModifier and TypeFieldDescriptionprotected final RouterContextThe router context.protected final TunnelGateway.DelayedFlushThe delayed flush timer.protected longThe last flush time.protected final LogThe log instance.protected intThe messages sent count.protected final TunnelGateway.QueuePreprocessorThe queue preprocessor.protected final List<PendingGatewayMessage> The message queue.protected final TunnelGateway.ReceiverThe message receiver, consuming encrypted messages for forwarding.protected final TunnelGateway.SenderThe message sender, encrypting and forwarding preprocessed messages.Constructor Summary
ConstructorsConstructorDescriptionThrottledPumpedTunnelGateway(RouterContext context, TunnelGateway.QueuePreprocessor preprocessor, TunnelGateway.Sender sender, TunnelGateway.Receiver receiver, TunnelGatewayPumper pumper, HopConfig config) A pump-driven gateway that drops excess messages based on estimated bandwidth.Method Summary
All MethodsMethods inherited from class PumpedTunnelGateway
add, getMaxIbMsgsPerPump, getMaxObMsgsPerPump, pump, setMaxIbMsgsPerPump, setMaxObMsgsPerPumpModifier and TypeMethodDescriptionprotected booleanadd(PendingGatewayMessage cur) Adds a PendingGatewayMessage to the prequeue and notifies the pumper to process it.static intThe maximum inbound messages per pump.static intThe cap the pump applies to outbound messages, read once per pump pass so a single busy iteration cannot monopolise the thread.booleanpump(List<PendingGatewayMessage> queueBuf) Pumps messages from the internal prequeue into the processing queue.static voidsetMaxIbMsgsPerPump(int val) The maximum inbound messages per pump.static voidsetMaxObMsgsPerPump(int val) The maximum outbound messages per pump.Methods inherited from class TunnelGateway
add, getMessagesSentModifier and TypeMethodDescriptionbooleanadd(TunnelGatewayMessage msg) Add a message to be sent down the tunnel, where we are the inbound gateway.intThe number of messages sent.
Field Details
_config
Configuration and statistics for this hop, used to count dropped messages._partBWE
Synthetic Random Early Drop queue to estimate bandwidth usage and perform drops.
Constructor Details
ThrottledPumpedTunnelGateway
public ThrottledPumpedTunnelGateway(RouterContext context, TunnelGateway.QueuePreprocessor preprocessor, TunnelGateway.Sender sender, TunnelGateway.Receiver receiver, TunnelGatewayPumper pumper, HopConfig config) A pump-driven gateway that drops excess messages based on estimated bandwidth.Allocated bandwidth value is retrieved from config or set to reasonable default.
- Parameters:
context- the router context supplying the bandwidth allocationpreprocessor- QueuePreprocessor for the gatewaysender- Encrypting Sender for fragmentsreceiver- Receiving entity consuming encrypted messagespumper- TunnelGatewayPumper managing pumping threadsconfig- HopConfig containing bandwidth and message statistics
Method Details
add
Adds a message to the inbound gateway after a bandwidth-based drop check.Drops messages early based on estimated size and bandwidth usage, tracking statistics.
We do this here instead of in the InboundGatewayReceiver because it is much smarter to drop whole I2NP messages, where we know the message type and length, rather than tunnel messages containing I2NP fragments.
Hard to do this exactly, but we'll assume 2:1 batching for the purpose of estimating outgoing size. We assume that it's the outbound bandwidth that is the issue...
- Overrides:
addin classPumpedTunnelGateway- Parameters:
msg- the I2NP message to addtoRouter- optional target router after the endpointtoTunnel- optional target tunnel after the endpoint- Returns:
- true if the message was accepted, false if dropped for bandwidth or queue full
toString