Package net.i2p.client.streaming.impl
Class PacketLocal
- java.lang.Object
-
- net.i2p.client.streaming.impl.Packet
-
- net.i2p.client.streaming.impl.PacketLocal
-
- All Implemented Interfaces:
MessageOutputStream.WriteStatus
class PacketLocal extends Packet implements MessageOutputStream.WriteStatus
This is the class used for outbound packets. coordinate local attributes about a packet - send time, ack time, number of retries, etc.
-
-
Field Summary
-
Fields inherited from class net.i2p.client.streaming.impl.Packet
_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 Summary
Constructors Constructor Description PacketLocal(I2PAppContext ctx, Destination to, I2PSession session)not bound to a connectionPacketLocal(I2PAppContext ctx, Destination to, Connection con)bound to a connection
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidackReceived()voidcancelled()StringBuilderformatAsString()intgetAckTime()how long after packet creation was it acked?ConnectiongetConnection()longgetCreatedOn()SessionKeygetKeyUsed()Deprecated.should always return nulllonggetLastSend()longgetLifetime()intgetNACKs()intgetNumSends()Set<SessionTag>getTagsSent()Deprecated.should always return null or an empty setintgetTimeout()Used by PacketQueue to feed an expiration to the router.DestinationgetTo()voidincrementNACKs()Will force a fast restransmit on the 3rd call (FAST_RETRANSMIT_THRESHOLD) but only if it's the lowest unacked (see Connection.ResendPacketEvent)voidincrementSends()voidlogTCPDump()Generate a pcap/tcpdump-compatible format, so we can use standard debugging tools.voidsetKeyUsed(SessionKey key)Deprecated.I2PSession throws out the tagsvoidsetOptionalFrom()This sets the from field in the packet to the Destination for the session provided in the constructor.voidsetTagsSent(Set<SessionTag> tags)Deprecated.I2PSession throws out the tagsvoidsetTimeout(int timeout)booleanshouldSign()voidwaitForAccept(int maxWaitMs)Blocks until outbound window is not full.voidwaitForCompletion(int maxWaitMs)block until the packet is acked from the far endbooleanwriteAccepted()Was the write was accepted.booleanwriteFailed()did the write fail?intwriteSignedPacket(byte[] buffer, int offset)Sign and write the packet to the buffer (starting at the offset) and return the number of bytes written.booleanwriteSuccessful()did the write succeed?-
Methods inherited from class net.i2p.client.streaming.impl.Packet
acquirePayload, getAckThrough, getLocalPort, getNacks, getOptionalDelay, getOptionalFrom, getOptionalMaxSize, getOptionalSignature, getPayload, getPayloadSize, getReceiveStreamId, getRemotePort, getResendDelay, getSendStreamId, getSequenceNum, getSession, getTransientSPK, isFlagSet, logTCPDump, readPacket, releasePayload, setAckThrough, setFlag, setFlag, setLocalPort, setNacks, setOptionalDelay, setOptionalMaxSize, setOptionalSignature, setPayload, setReceiveStreamId, setRemotePort, setResendDelay, setSendStreamId, setSequenceNum, toId, toString, verifySignature, verifySignature, writePacket, writePacket
-
-
-
-
Constructor Detail
-
PacketLocal
public PacketLocal(I2PAppContext ctx, Destination to, I2PSession session)
not bound to a connection
-
PacketLocal
public PacketLocal(I2PAppContext ctx, Destination to, Connection con)
bound to a connection
-
-
Method Detail
-
setOptionalFrom
public void setOptionalFrom()
This sets the from field in the packet to the Destination for the session provided in the constructor. This also sets flag FLAG_FROM_INCLUDED. Also, as of 0.9.39, sets the offline signing data if supported by the session.- Since:
- 0.9.39 moved from super
-
getTo
public Destination getTo()
-
getKeyUsed
@Deprecated public SessionKey getKeyUsed()
Deprecated.should always return null
-
setKeyUsed
@Deprecated public void setKeyUsed(SessionKey key)
Deprecated.I2PSession throws out the tags
-
getTagsSent
@Deprecated public Set<SessionTag> getTagsSent()
Deprecated.should always return null or an empty set
-
setTagsSent
@Deprecated public void setTagsSent(Set<SessionTag> tags)
Deprecated.I2PSession throws out the tags
-
shouldSign
public boolean shouldSign()
-
getCreatedOn
public long getCreatedOn()
-
getLifetime
public long getLifetime()
-
incrementSends
public void incrementSends()
-
ackReceived
public void ackReceived()
-
cancelled
public void cancelled()
-
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()
-
getTimeout
public int getTimeout()
Used by PacketQueue to feed an expiration to the router.- Returns:
- time from now, not absolute time. May be zero if unset.
- Since:
- 0.9.46
-
setTimeout
public void setTimeout(int timeout)
- Parameters:
timeout- time from now, not absolute time- Since:
- 0.9.46
-
writeSignedPacket
public int writeSignedPacket(byte[] buffer, int offset) throws IllegalStateExceptionSign and write the packet to the buffer (starting at the offset) and return the number of bytes written.- Parameters:
buffer- data to be writtenoffset- starting point in the buffer- Returns:
- Count of bytes written
- Throws:
IllegalStateException- if there is data missing or otherwise b0rked- Since:
- 0.9.20 moved from Packet
-
formatAsString
public StringBuilder formatAsString()
- Overrides:
formatAsStringin classPacket
-
waitForAccept
public void waitForAccept(int maxWaitMs) throws IOException, InterruptedExceptionBlocks until outbound window is not full. See Connection.packetSendChoke().- Specified by:
waitForAcceptin interfaceMessageOutputStream.WriteStatus- Parameters:
maxWaitMs- MessageOutputStream is the only caller, generally with -1- Throws:
IOExceptionInterruptedException
-
waitForCompletion
public void waitForCompletion(int maxWaitMs) throws IOException, InterruptedExceptionblock until the packet is acked from the far end- Specified by:
waitForCompletionin interfaceMessageOutputStream.WriteStatus- Parameters:
maxWaitMs- -1 = forever- Throws:
IOExceptionInterruptedException
-
writeAccepted
public boolean writeAccepted()
Description copied from interface:MessageOutputStream.WriteStatusWas the write was accepted. aka did the socket not close?- Specified by:
writeAcceptedin interfaceMessageOutputStream.WriteStatus
-
writeFailed
public boolean writeFailed()
Description copied from interface:MessageOutputStream.WriteStatusdid the write fail?- Specified by:
writeFailedin interfaceMessageOutputStream.WriteStatus
-
writeSuccessful
public boolean writeSuccessful()
Description copied from interface:MessageOutputStream.WriteStatusdid the write succeed?- Specified by:
writeSuccessfulin interfaceMessageOutputStream.WriteStatus
-
logTCPDump
public void logTCPDump()
Generate a pcap/tcpdump-compatible format, so we can use standard debugging tools.
-
-