java.lang.Object
net.i2p.router.transport.udp.InboundMessageState.PartialBitfield
All Implemented Interfaces:
ACKBitfield
Enclosing class:
InboundMessageState

private static final class InboundMessageState.PartialBitfieldextends Object implements ACKBitfield
Bitfield of the fragments received so far.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final int
    Fragments acknowledged in the bitfield.
    private final long
    The message id the bitfield refers to.
    private final long
    The fragment ack bits.
    private final int
    Total fragments of the message.
    private final int
    Highest fragment number in the bitfield.
  • Constructor Summary

    Constructors
    Constructor
    Description
    PartialBitfield(long messageId, Object[] data, int size)
    Builds the bitfield from the fragments received.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Number of fragments acked in this bitfield.
    int
    The number of fragments covered in this bitfield.
    long
    The message ID this is partially ACKing.
    int
    Highest fragment number acked in this bitfield.
    private static long
    mask(int fragment)
    Returns the ack bit for a fragment number.
    boolean
    received(int fragmentNum)
    Check if the given fragment has been received.
    boolean
    Check if the entire message has been received completely.
     

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • _bitfieldMessageId

      private final long _bitfieldMessageId
      The message id the bitfield refers to.
    • _fragmentCount

      private final int _fragmentCount
      Total fragments of the message.
    • _ackCount

      private final int _ackCount
      Fragments acknowledged in the bitfield.
    • _highestReceived

      private final int _highestReceived
      Highest fragment number in the bitfield.
    • _fragmentAcks

      private final long _fragmentAcks
      The fragment ack bits.
  • Constructor Details

    • PartialBitfield

      public PartialBitfield(long messageId, Object[] data, int size)
      Builds the bitfield from the fragments received.
      Parameters:
      messageId - the message id
      data - the fragment array
      size - the total fragment count
  • Method Details

    • mask

      private static long mask(int fragment)
      Returns the ack bit for a fragment number.
      Parameters:
      fragment - the fragment number
      Returns:
      the bit mask
    • fragmentCount

      public int fragmentCount()
      Description copied from interface: ACKBitfield
      The number of fragments covered in this bitfield.
      Specified by:
      fragmentCount in interface ACKBitfield
      Returns:
      number of fragments
    • ackCount

      public int ackCount()
      Description copied from interface: ACKBitfield
      Number of fragments acked in this bitfield. Faster than looping through ACKBitfield.received(int).
      Specified by:
      ackCount in interface ACKBitfield
      Returns:
      number of fragments acked
    • highestReceived

      public int highestReceived()
      Description copied from interface: ACKBitfield
      Highest fragment number acked in this bitfield.
      Specified by:
      highestReceived in interface ACKBitfield
      Returns:
      highest fragment number acked, or -1 if none
    • getMessageId

      public long getMessageId()
      Description copied from interface: ACKBitfield
      The message ID this is partially ACKing.
      Specified by:
      getMessageId in interface ACKBitfield
      Returns:
      the 32 bit message ID from the session's outbound sequence
    • received

      public boolean received(int fragmentNum)
      Description copied from interface: ACKBitfield
      Check if the given fragment has been received.
      Specified by:
      received in interface ACKBitfield
      Parameters:
      fragmentNum - fragment number to check
      Returns:
      true if fragment has been received
    • receivedComplete

      public boolean receivedComplete()
      Description copied from interface: ACKBitfield
      Check if the entire message has been received completely.
      Specified by:
      receivedComplete in interface ACKBitfield
      Returns:
      true if message has been completely received
    • toString

      public String toString()
      Overrides:
      toString in class Object