java.lang.Object
net.i2p.router.transport.udp.InboundMessageState.PartialBitfield
- All Implemented Interfaces:
ACKBitfield
- Enclosing class:
InboundMessageState
Bitfield of the fragments received so far.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final intFragments acknowledged in the bitfield.private final longThe message id the bitfield refers to.private final longThe fragment ack bits.private final intTotal fragments of the message.private final intHighest fragment number in the bitfield.Constructor Summary
ConstructorsConstructorDescriptionPartialBitfield(long messageId, Object[] data, int size) Builds the bitfield from the fragments received.Method Summary
Modifier and TypeMethodDescriptionintackCount()Number of fragments acked in this bitfield.intThe number of fragments covered in this bitfield.longThe message ID this is partially ACKing.intHighest fragment number acked in this bitfield.private static longmask(int fragment) Returns the ack bit for a fragment number.booleanreceived(int fragmentNum) Check if the given fragment has been received.booleanCheck if the entire message has been received completely.toString()
Field Details
_bitfieldMessageId
private final long _bitfieldMessageIdThe message id the bitfield refers to._fragmentCount
private final int _fragmentCountTotal fragments of the message._ackCount
private final int _ackCountFragments acknowledged in the bitfield._highestReceived
private final int _highestReceivedHighest fragment number in the bitfield._fragmentAcks
private final long _fragmentAcksThe fragment ack bits.
Constructor Details
PartialBitfield
Builds the bitfield from the fragments received.- Parameters:
messageId- the message iddata- the fragment arraysize- 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:ACKBitfieldThe number of fragments covered in this bitfield.- Specified by:
fragmentCountin interfaceACKBitfield- Returns:
- number of fragments
ackCount
public int ackCount()Description copied from interface:ACKBitfieldNumber of fragments acked in this bitfield. Faster than looping throughACKBitfield.received(int).- Specified by:
ackCountin interfaceACKBitfield- Returns:
- number of fragments acked
highestReceived
public int highestReceived()Description copied from interface:ACKBitfieldHighest fragment number acked in this bitfield.- Specified by:
highestReceivedin interfaceACKBitfield- Returns:
- highest fragment number acked, or -1 if none
getMessageId
public long getMessageId()Description copied from interface:ACKBitfieldThe message ID this is partially ACKing.- Specified by:
getMessageIdin interfaceACKBitfield- Returns:
- the 32 bit message ID from the session's outbound sequence
received
public boolean received(int fragmentNum) Description copied from interface:ACKBitfieldCheck if the given fragment has been received.- Specified by:
receivedin interfaceACKBitfield- Parameters:
fragmentNum- fragment number to check- Returns:
- true if fragment has been received
receivedComplete
public boolean receivedComplete()Description copied from interface:ACKBitfieldCheck if the entire message has been received completely.- Specified by:
receivedCompletein interfaceACKBitfield- Returns:
- true if message has been completely received
toString