net.i2p.router.transport.udp
Class OutboundMessageState

java.lang.Object
  extended bynet.i2p.router.transport.udp.OutboundMessageState

public class OutboundMessageState
extends java.lang.Object

Maintain the outbound fragmentation for resending


Field Summary
static int MAX_FRAGMENTS
           
 
Constructor Summary
OutboundMessageState(I2PAppContext context)
           
 
Method Summary
 void acked(int[] ackedFragments)
          Ack all the fragments in the ack list
 void fragment(int fragmentSize)
          Prepare the message for fragmented delivery, using no more than fragmentSize bytes per fragment.
 int fragmentSize(int fragmentNum)
           
 int getFragmentCount()
          how many fragments in the message
 long getLifetime()
           
 int getMaxSends()
           
 OutNetMessage getMessage()
           
 long getMessageId()
           
 long getNextSendTime()
           
 PeerState getPeer()
           
 int getPushCount()
           
 boolean initialize(I2NPMessage msg, PeerState peer)
           
 boolean initialize(OutNetMessage msg)
           
 boolean isComplete()
           
 boolean isExpired()
           
 boolean isFragmented()
           
 int pickNextFragment()
          Pick a fragment that we still need to send.
 void push()
          note that we have pushed the message fragments
 void releaseResources()
           
 void setNextSendTime(long when)
           
 boolean shouldSend(int fragmentNum)
          should we continue sending this fragment?
 java.lang.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_FRAGMENTS

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

OutboundMessageState

public OutboundMessageState(I2PAppContext context)
Method Detail

initialize

public boolean initialize(OutNetMessage msg)

initialize

public boolean initialize(I2NPMessage msg,
                          PeerState peer)

releaseResources

public void releaseResources()

getMessage

public OutNetMessage getMessage()

getMessageId

public long getMessageId()

getPeer

public PeerState getPeer()

isExpired

public boolean isExpired()

isComplete

public boolean isComplete()

getLifetime

public long getLifetime()

acked

public void acked(int[] ackedFragments)
Ack all the fragments in the ack list


getNextSendTime

public long getNextSendTime()

setNextSendTime

public void setNextSendTime(long when)

getMaxSends

public int getMaxSends()

getPushCount

public int getPushCount()

push

public void push()
note that we have pushed the message fragments


isFragmented

public boolean isFragmented()

fragment

public void fragment(int fragmentSize)
Prepare the message for fragmented delivery, using no more than fragmentSize bytes per fragment.


getFragmentCount

public int getFragmentCount()
how many fragments in the message


shouldSend

public boolean shouldSend(int fragmentNum)
should we continue sending this fragment?


fragmentSize

public int fragmentSize(int fragmentNum)

pickNextFragment

public int pickNextFragment()
Pick a fragment that we still need to send. Current implementation picks the fragment which has been sent the least (randomly choosing among equals), incrementing the # sends of the winner in the process.

Returns:
fragment index, or -1 if all of the fragments were acked

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

toString

public java.lang.String toString()