net.i2p.router.transport.udp
Class OutboundMessageState

java.lang.Object
  extended by net.i2p.router.transport.udp.OutboundMessageState
All Implemented Interfaces:
CDPQEntry, CDQEntry, PQEntry

 class OutboundMessageState
extends Object
implements CDPQEntry

Maintain the outbound fragmentation for resending, for a single message. All methods are thread-safe.


Field Summary
static int MAX_MSG_SIZE
           
 
Constructor Summary
OutboundMessageState(I2PAppContext context, I2NPMessage msg, PeerState peer)
          "injected" message from the establisher.
OutboundMessageState(I2PAppContext context, OutNetMessage m, PeerState peer)
          Normal constructor.
 
Method Summary
 boolean acked(ACKBitfield bitfield)
          Ack all the fragments in the ack list.
 void drop()
          For CDQ
 int fragmentSize(int fragmentNum)
          The size in bytes of the fragment
 long getEnqueueTime()
          For CDQ
 int getFragmentCount()
          How many fragments in the message.
 long getLifetime()
           
 int getMaxSends()
          The max number of sends for any fragment, which is the same as the push count, at least as it's coded now.
 OutNetMessage getMessage()
           
 long getMessageId()
           
 int getMessageSize()
          The size of the I2NP message.
 long getNextSendTime()
           
 PeerState getPeer()
           
 int getPriority()
          For CDPQ
 int getPushCount()
          The number of times we've pushed some fragments, which is the same as the max sends, at least as it's coded now.
 long getSeqNum()
          For CDPQ
 int getUnackedSize()
           
 boolean isComplete()
           
 boolean isExpired()
           
 boolean needsSending(int fragment)
           
 void push()
          Note that we have pushed the message fragments.
 void setEnqueueTime(long now)
          For CDQ
 void setNextSendTime(long when)
           
 void setSeqNum(long num)
          For CDPQ
 String toString()
           
 int writeFragment(byte[] out, int outOffset, int fragmentNum)
          Write a part of the the message onto the specified buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_MSG_SIZE

public static final int MAX_MSG_SIZE
See Also:
Constant Field Values
Constructor Detail

OutboundMessageState

public OutboundMessageState(I2PAppContext context,
                            I2NPMessage msg,
                            PeerState peer)
"injected" message from the establisher. Called from UDPTransport.

Throws:
IAE - if too big or if msg or peer is null

OutboundMessageState

public OutboundMessageState(I2PAppContext context,
                            OutNetMessage m,
                            PeerState peer)
Normal constructor. Called from OutboundMessageFragments.

Throws:
IAE - if too big or if msg or peer is null
Method Detail

getMessage

public OutNetMessage getMessage()

getMessageId

public long getMessageId()

getPeer

public PeerState getPeer()

isExpired

public boolean isExpired()

isComplete

public boolean isComplete()

getUnackedSize

public int getUnackedSize()

needsSending

public boolean needsSending(int fragment)

getLifetime

public long getLifetime()

acked

public boolean acked(ACKBitfield bitfield)
Ack all the fragments in the ack list.

Returns:
true if the message was completely ACKed

getNextSendTime

public long getNextSendTime()

setNextSendTime

public void setNextSendTime(long when)

getMaxSends

public int getMaxSends()
The max number of sends for any fragment, which is the same as the push count, at least as it's coded now.


getPushCount

public int getPushCount()
The number of times we've pushed some fragments, which is the same as the max sends, at least as it's coded now.


push

public void push()
Note that we have pushed the message fragments. Increments push count (and max sends... why?)


getFragmentCount

public int getFragmentCount()
How many fragments in the message.


getMessageSize

public int getMessageSize()
The size of the I2NP message. Does not include any SSU overhead.


fragmentSize

public int fragmentSize(int fragmentNum)
The size in bytes of the fragment

Parameters:
fragmentNum - the number of the fragment
Returns:
the size of the fragment specified by the number

writeFragment

public int writeFragment(byte[] out,
                         int outOffset,
                         int fragmentNum)
Write a part of the the message onto the specified buffer.

Parameters:
out - target to write
outOffset - into outOffset to begin writing
fragmentNum - fragment to write (0 indexed)
Returns:
bytesWritten

setEnqueueTime

public void setEnqueueTime(long now)
For CDQ

Specified by:
setEnqueueTime in interface CDQEntry
Since:
0.9.3

getEnqueueTime

public long getEnqueueTime()
For CDQ

Specified by:
getEnqueueTime in interface CDQEntry
Since:
0.9.3

drop

public void drop()
For CDQ

Specified by:
drop in interface CDQEntry
Since:
0.9.3

setSeqNum

public void setSeqNum(long num)
For CDPQ

Specified by:
setSeqNum in interface PQEntry
Since:
0.9.3

getSeqNum

public long getSeqNum()
For CDPQ

Specified by:
getSeqNum in interface PQEntry
Since:
0.9.3

getPriority

public int getPriority()
For CDPQ

Specified by:
getPriority in interface PQEntry
Returns:
OutNetMessage priority or 1000 for injected
Since:
0.9.3

toString

public String toString()
Overrides:
toString in class Object