java.lang.Object
net.i2p.router.transport.udp.InboundMessageFragments

class InboundMessageFragmentsextends Object
Organize the received data message fragments, feeding completed messages to the MessageReceiver and telling the PeerState to ACK. In addition, it drops failed fragments and keeps a minimal list of the most recently completed messages (even though higher up in the router we have full blown replay detection, its nice to have a basic line of defense here).
  • Field Details

    • _context

      private final RouterContext _context
      The router receiving the datagrams.
    • _recentlyCompletedMessages

      private volatile DecayingBloomFilter _recentlyCompletedMessages
      List of message IDs recently received, so we can ignore in flight dups.
    • _transport

      private final UDPTransport _transport
      The transport the datagrams arrived on.
    • _messageReceiver

      private final MessageReceiver _messageReceiver
      Where complete messages are handed on.
    • _alive

      private volatile boolean _alive
      False once the job has been cancelled.
    • DECAY_PERIOD

      private static final int DECAY_PERIOD
      Decay the recently completed every 10 seconds.
      See Also:
  • Constructor Details

    • InboundMessageFragments

      public InboundMessageFragments(RouterContext ctx, OutboundMessageFragments outbound, UDPTransport transport)
      Creates the message receiver and registers the fragment reassembly stats.
      Parameters:
      ctx - our router context
      outbound - the outbound fragment pool to hand completed messages to
      transport - the UDP transport this receiver belongs to
  • Method Details

    • startup

      public void startup()
      Start the receiver and duplicate filter.
    • shutdown

      public void shutdown()
      Shut down the receiver and duplicate filter.
    • isAlive

      public boolean isAlive()
      Whether the receiver is alive.
      Returns:
      true until shutdown() has been called
    • adjustMessageReceiverThreads

      void adjustMessageReceiverThreads()
      Dynamically adjust MessageReceiver thread count to match the target.
    • getReceiverQueueSize

      int getReceiverQueueSize()
      Returns the current queue depth of the message receiver.
      Returns:
      the number of messages currently queued for processing
    • getReceiverQueueCapacity

      int getReceiverQueueCapacity()
      Returns the maximum capacity of the message receiver queue.
      Returns:
      the queue size at which incoming messages are dropped
    • getMessageReceiverUtilization

      double getMessageReceiverUtilization()
      Message receiver pool utilization as a ratio (0.0-1.0).
      Returns:
      queued messages as a fraction of the queue capacity
    • messageReceived

      public boolean messageReceived(long messageID)
      This message was received - SSU 2 only. No stats updated here, caller should handle stats.
      Parameters:
      messageID - message identifier added to the recently-completed bloom filter
      Returns:
      true if this message was a duplicate
    • wasRecentlyReceived

      public boolean wasRecentlyReceived(long messageID)
      Was this message recently received? SSU 2 only. No stats updated here, caller should handle stats.
      Parameters:
      messageID - message identifier tested against the recently-completed bloom filter
      Returns:
      true if this message was recently received.