class PacketLocal extends Packet implements MessageOutputStream.WriteStatus
_nacks, _offlineSignature, _optionFrom, _optionSignature, _session, _transientExpires, _transientSigningPublicKey, 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_OFFLINE, FLAG_SIGNATURE_REQUESTED, FLAG_SYNCHRONIZE, MAX_DELAY_REQUEST, MAX_PAYLOAD_SIZE, MAX_STREAM_ID, MIN_DELAY_CHOKE, SEND_DELAY_CHOKE, STREAM_ID_UNKNOWN| Constructor and Description |
|---|
PacketLocal(I2PAppContext ctx,
Destination to,
Connection con)Constructor for a packet bound to a connection. |
PacketLocal(I2PAppContext ctx,
Destination to,
I2PSession session)Constructor for a packet not bound to a connection. |
| Modifier and Type | Method and Description |
|---|---|
void | ackReceived()Record that this packet was ACKed |
void | cancelled()Record that this packet was cancelled |
StringBuilder | formatAsString()Format as a string builder for logging. |
int | getAckTime()How long after packet creation was it acked? |
Connection | getConnection()Bound connection. |
long | getCreatedOn()Creation time. |
long | getLastSend()Time of the last send. |
long | getLifetime()Lifetime of this packet. |
int | getNACKs()Warning: This is different than getNacks() in super |
int | getNumSends()Number of times sent. |
(package private) static ByteCache | getPayloadCache()Shared outbound payload cache (MAX_PAYLOAD_SIZE buffers). |
int | getTimeout()Used by PacketQueue to feed an expiration to the router. |
Destination | getTo()Destination this packet is being sent to. |
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()Increment the number of times this packet has been sent |
boolean | isEnqueued() |
void | logTCPDump()Generate a pcap/tcpdump-compatible format,
so we can use standard debugging tools. |
void | markEnqueued() |
void | releasePayload()Return the payload to the shared pool instead of letting it GC. |
void | setOptionalFrom()This sets the from field in the packet to the Destination for the session
provided in the constructor. |
void | setTimeout(int timeout)Timeout for this packet. |
boolean | shouldSign()Whether this packet should be signed. |
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()Whether the send was accepted. |
boolean | writeFailed()Whether the send failed. |
int | writeSignedPacket(byte[] buffer,
int offset)Sign and write the packet to the buffer (starting at the offset) and return
the number of bytes written. |
boolean | writeSuccessful()Whether the send succeeded and was ACKed. |
acquirePayload, getAckThrough, getLocalPort, getNacks, getOptionalDelay, getOptionalFrom, getOptionalMaxSize, getOptionalSignature, getPayload, getPayloadSize, getReceiveStreamId, getRemotePort, getResendDelay, getSendStreamId, getSequenceNum, getSession, getTransientSPK, isFlagSet, logTCPDump, readPacket, setAckThrough, setFlag, setFlag, setLocalPort, setNacks, setOptionalDelay, setOptionalMaxSize, setOptionalSignature, setPayload, setReceiveStreamId, setRemotePort, setResendDelay, setSendStreamId, setSequenceNum, toId, toString, verifySignature, verifySignature, writePacket, writePacketpublic PacketLocal(I2PAppContext ctx, Destination to, Connection con)
public PacketLocal(I2PAppContext ctx, Destination to, I2PSession session)
public void ackReceived()
public void cancelled()
public StringBuilder formatAsString()
formatAsString in class Packetpublic int getAckTime()
public Connection getConnection()
public long getCreatedOn()
public long getLastSend()
public long getLifetime()
public int getNACKs()
public int getNumSends()
static ByteCache getPayloadCache()
public int getTimeout()
public Destination getTo()
public void incrementNACKs()
public void incrementSends()
public boolean isEnqueued()
public void logTCPDump()
public void markEnqueued()
public void releasePayload()
releasePayload in class Packetpublic void setOptionalFrom()
public void setTimeout(int timeout)
timeout - time from now, not absolute timepublic boolean shouldSign()
public void waitForAccept(int maxWaitMs)
throws IOException,
InterruptedExceptionwaitForAccept in interface MessageOutputStream.WriteStatusmaxWaitMs - MessageOutputStream is the only caller, generally with -1IOException - if the connection is closedInterruptedException - if the thread is interruptedpublic void waitForCompletion(int maxWaitMs)
throws IOException,
InterruptedExceptionwaitForCompletion in interface MessageOutputStream.WriteStatusmaxWaitMs - maximum time to wait in msIOException - if the connection is reset or cancelledInterruptedException - if the thread is interruptedpublic boolean writeAccepted()
writeAccepted in interface MessageOutputStream.WriteStatuspublic boolean writeFailed()
writeFailed in interface MessageOutputStream.WriteStatuspublic int writeSignedPacket(byte[] buffer,
int offset)
throws IllegalStateExceptionbuffer - data to be writtenoffset - starting point in the bufferIllegalStateException - if there is data missing or otherwise b0rkedpublic boolean writeSuccessful()