net.i2p.client.streaming
Class PacketLocal

java.lang.Object
  extended by net.i2p.client.streaming.Packet
      extended by net.i2p.client.streaming.PacketLocal
All Implemented Interfaces:
MessageOutputStream.WriteStatus

 class PacketLocal
extends Packet
implements MessageOutputStream.WriteStatus

coordinate local attributes about a packet - send time, ack time, number of retries, etc.


Field Summary
 
Fields inherited from class net.i2p.client.streaming.Packet
DEFAULT_MAX_SIZE, FLAG_CLOSE, FLAG_DELAY_REQUESTED, FLAG_ECHO, FLAG_FROM_INCLUDED, FLAG_MAX_PACKET_SIZE_INCLUDED, FLAG_NO_ACK, FLAG_PROFILE_INTERACTIVE, FLAG_RESET, FLAG_SIGNATURE_INCLUDED, FLAG_SIGNATURE_REQUESTED, FLAG_SYNCHRONIZE, MAX_DELAY_REQUEST, MAX_PAYLOAD_SIZE, MAX_STREAM_ID, STREAM_ID_UNKNOWN
 
Constructor Summary
PacketLocal(I2PAppContext ctx, Destination to)
          not bound to a connection
PacketLocal(I2PAppContext ctx, Destination to, Connection con)
           
 
Method Summary
 void ackReceived()
           
 void cancelled()
           
 StringBuilder formatAsString()
           
 int getAckTime()
          how long after packet creation was it acked?
 Connection getConnection()
           
 long getCreatedOn()
           
 SessionKey getKeyUsed()
          Deprecated. should always return null
 long getLastSend()
           
 long getLifetime()
           
 int getNACKs()
           
 int getNumSends()
           
 SimpleTimer2.TimedEvent getResendEvent()
           
 Set getTagsSent()
          Deprecated. should always return null or an empty set
 Destination getTo()
           
 void incrementNACKs()
          Will force a fast restransmit on the 3rd call (FAST_RETRANSMIT_THRESHOLD) but only if it's the lowest unacked (see Connection.ResendPacketEvent)
 void incrementSends()
           
 void prepare()
          last minute update of ack fields, just before write/sign
 void setKeyUsed(SessionKey key)
          Deprecated. I2PSession throws out the tags
 void setResendPacketEvent(SimpleTimer2.TimedEvent evt)
           
 void setTagsSent(Set tags)
          Deprecated. I2PSession throws out the tags
 boolean shouldSign()
           
 void waitForAccept(int maxWaitMs)
          Blocks until outbound window is not full.
 void waitForCompletion(int maxWaitMs)
          block until the packet is acked from the far end
 boolean writeAccepted()
          the write was accepted.
 boolean writeFailed()
          did the write fail?
 boolean writeSuccessful()
          did the write succeed?
 
Methods inherited from class net.i2p.client.streaming.Packet
acquirePayload, getAckThrough, getLocalPort, getNacks, getOptionalDelay, getOptionalFrom, getOptionalMaxSize, getOptionalSignature, getPayload, getPayloadSize, getReceiveStreamId, getRemotePort, getResendDelay, getSendStreamId, getSequenceNum, isFlagSet, readPacket, releasePayload, setAckThrough, setFlag, setFlag, setFlags, setLocalPort, setNacks, setOptionalDelay, setOptionalFrom, setOptionalMaxSize, setOptionalSignature, setPayload, setReceiveStreamId, setRemotePort, setResendDelay, setSendStreamId, setSequenceNum, toId, toString, verifySignature, writePacket, writeSignedPacket
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PacketLocal

public PacketLocal(I2PAppContext ctx,
                   Destination to)
not bound to a connection


PacketLocal

public PacketLocal(I2PAppContext ctx,
                   Destination to,
                   Connection con)
Method Detail

getTo

public Destination getTo()

getKeyUsed

public SessionKey getKeyUsed()
Deprecated. should always return null


setKeyUsed

public void setKeyUsed(SessionKey key)
Deprecated. I2PSession throws out the tags


getTagsSent

public Set getTagsSent()
Deprecated. should always return null or an empty set


setTagsSent

public void setTagsSent(Set tags)
Deprecated. I2PSession throws out the tags


shouldSign

public boolean shouldSign()

prepare

public void prepare()
last minute update of ack fields, just before write/sign


getCreatedOn

public long getCreatedOn()

getLifetime

public long getLifetime()

incrementSends

public void incrementSends()

ackReceived

public void ackReceived()

cancelled

public void cancelled()

getResendEvent

public SimpleTimer2.TimedEvent getResendEvent()

getAckTime

public int getAckTime()
how long after packet creation was it acked?

Returns:
how long after packet creation the packet was ACKed in ms

getNumSends

public int getNumSends()

getLastSend

public long getLastSend()

getConnection

public Connection getConnection()
Returns:
null if not bound

incrementNACKs

public void incrementNACKs()
Will force a fast restransmit on the 3rd call (FAST_RETRANSMIT_THRESHOLD) but only if it's the lowest unacked (see Connection.ResendPacketEvent)


getNACKs

public int getNACKs()

setResendPacketEvent

public void setResendPacketEvent(SimpleTimer2.TimedEvent evt)

formatAsString

public StringBuilder formatAsString()
Overrides:
formatAsString in class Packet

waitForAccept

public void waitForAccept(int maxWaitMs)
Blocks until outbound window is not full. See Connection.packetSendChoke().

Specified by:
waitForAccept in interface MessageOutputStream.WriteStatus
Parameters:
maxWaitMs - MessageOutputStream is the only caller, generally with -1

waitForCompletion

public void waitForCompletion(int maxWaitMs)
block until the packet is acked from the far end

Specified by:
waitForCompletion in interface MessageOutputStream.WriteStatus
Parameters:
maxWaitMs - -1 = forever

writeAccepted

public boolean writeAccepted()
Description copied from interface: MessageOutputStream.WriteStatus
the write was accepted. aka did the socket not close?

Specified by:
writeAccepted in interface MessageOutputStream.WriteStatus

writeFailed

public boolean writeFailed()
Description copied from interface: MessageOutputStream.WriteStatus
did the write fail?

Specified by:
writeFailed in interface MessageOutputStream.WriteStatus

writeSuccessful

public boolean writeSuccessful()
Description copied from interface: MessageOutputStream.WriteStatus
did the write succeed?

Specified by:
writeSuccessful in interface MessageOutputStream.WriteStatus