class ThrottledPumpedTunnelGatewayextends PumpedTunnelGateway
Specialized pumped tunnel gateway for inbound gateways (IBGWs) that throttles messages by checking bandwidth usage before queuing them.

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.

  • Field Details

    • _config

      private final HopConfig _config
      Configuration and statistics for this hop, used to count dropped messages.
    • _partBWE

      private final SyntheticREDQueue _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 allocation
      preprocessor - QueuePreprocessor for the gateway
      sender - Encrypting Sender for fragments
      receiver - Receiving entity consuming encrypted messages
      pumper - TunnelGatewayPumper managing pumping threads
      config - HopConfig containing bandwidth and message statistics
  • Method Details

    • add

      public boolean add(I2NPMessage msg, Hash toRouter, TunnelId toTunnel)
      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:
      add in class PumpedTunnelGateway
      Parameters:
      msg - the I2NP message to add
      toRouter - optional target router after the endpoint
      toTunnel - optional target tunnel after the endpoint
      Returns:
      true if the message was accepted, false if dropped for bandwidth or queue full
    • toString

      public String toString()
      Human-readable description differentiating inbound gateway and including tunnel ID.
      Overrides:
      toString in class Object
      Returns:
      String description of this inbound pumped tunnel gateway