java.lang.Object
net.i2p.client.streaming.impl.Packet
net.i2p.client.streaming.impl.ConnectionHandler.PoisonPacket
- Enclosing class:
ConnectionHandler
Simple end-of-queue marker. The standard class limits the delay to POISON_MAX_DELAY_REQUEST so an evil user can't use this to shut us down.
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDelay request that stops a sender thread.Fields inherited from class 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_UNKNOWNModifier and TypeFieldDescriptionprotected long[]Sequence numbers the sender has not had acknowledged.protected SignatureDestination's signature made with the transient key of an offline block.protected DestinationSending destination, when that option is included.protected SignatureTime to wait before resending, in ms, one of the four fields set only when the flags say so.protected final I2PSessionSession the packet travels over, set at construction.protected longThe transient signing key of the peer, the three fields that follow it are for offline signatures.protected SigningPublicKeyEphemeral signing public key taken from the offline signing block.static final intDEFAULT_MAX_SIZE.static final intThe sender of this packet will not be sending any more payload data.static final intThis packet includes an explicit request for the recipient to delay sending any packets with data for a given amount of time.static final intIf set, this packet is a ping (if sendStreamId is set) or a ping reply (if receiveStreamId is set).static final intThis packet includes the full I2P destination of the packet's sender.static final intThis packet includes a request that the recipient not send any subsequent packets with payloads greater than a specific size.static final intIf set, this packet doesn't really want to ack anything.static final intIf set, this packet is travelling as part of an interactive flow, meaning it is more lag sensitive than throughput sensitive.static final intThis packet is being sent to signify that the socket does not exist (or, if in response to an initial synchronize packet, that the connection was refused).static final intThis packet contains a DSA signature from the packet's sender.static final intIf set, an offline signing block is in the options.static final intThis packet wants the recipient to include signatures on subsequent packets sent to the creator of this packet.static final intThis packet is creating a new socket connection (if the receiveStreamId is STREAM_ID_UNKNOWN) or it is acknowledging a request to create a connection and in turn is accepting the socket.protected static final intLargest delay in milliseconds a peer may request before being choked.static final intLargest payload a streaming packet may carry, in bytes.static final longLargest stream ID the 32-bit field can carry.static final intDelay request at or above which the peer is treated as choked.static final intDelay sent to a choked peer, asking it to pause roughly a minute.static final longThe receiveStreamId will be set to this when the packet doesn't know what ID will be assigned by the remote peer (aka this is the initial synchronize packet).Constructor Summary
ConstructorsMethod Summary
All MethodsModifier and TypeMethodDescriptionintHow many milliseconds the sender of this packet wants the recipient to wait before sending any more data (only valid if the flag for it is set).toString()String representation of this packet.Methods inherited from class Packet
acquirePayload, alignSignatureToType, formatAsString, formatAsString, getAckThrough, getLocalPort, getNacks, 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, signatureSpaceLen, toId, verifySignature, verifySignature, writePacket, writePacket, writtenSizeModifier and TypeMethodDescriptionAllocate a MAX_PAYLOAD_SIZE buffer for this packet.(package private) booleanalignSignatureToType(SigType type) Recast the signature to the signing key's type when the bytes we read are long enough to be a signature of that type.protected StringBuilderFormat as a string builder for logging, full form.protected StringBuilderformatAsString(boolean withContext) Format as a string builder for logging.longThe highest packet sequence number that received on the receiveStreamId.intLocal port.long[]getNacks()List of packet sequence numbers below thePacket.getAckThrough()value have not been received.Sender of the packet, only included if the flag for it is set.intWhat is the largest payload the sender of this packet wants to receive?The signature on the packet (only included if the flag for it is set)Actual payload of the message, may be null.intPayload size in bytes.longStream the replies should be sent on.intRemote port.intHow long is the creator of this packet going to wait before resending this packet (if it hasn't yet been ACKed).longStream we send data to the peer on.long0-indexed sequence number for this Packet in the sendStream.Return the session this packet belongs to.Transient signing public key, only if an offline signing block was included, else null.booleanisFlagSet(int flag) Is a particular flag set on this packet?voidlogTCPDump(Connection con) Generate a pcap/tcpdump-compatible format, so we can use standard debugging tools.voidreadPacket(byte[] buffer, int offset, int length) Read the packet from the buffer (starting at the offset) and return the number of bytes read.voidNo-op, payload buffers are garbage-collected, not pooled.voidsetAckThrough(long id) ACK-through value to set; if < 0, sets FLAG_NO_ACK.voidsetFlag(int flag) Marks the flag(s) set.voidsetFlag(int flag, boolean set) Marks the flag(s) set or clear.voidsetLocalPort(int port) Must be called to change the port, not set by readPacket() as the port is out-of-band in the I2CP header.voidsetNacks(long[] nacks) NACK list to set.voidsetOptionalDelay(int delayMs) Caller must also call setFlag(FLAG_DELAY_REQUESTED).voidsetOptionalMaxSize(int numBytes) This also sets flag FLAG_MAX_PACKET_SIZE_INCLUDED.voidThis also sets flag FLAG_SIGNATURE_INCLUDED.voidsetPayload(ByteArray payload) Payload to set.voidsetReceiveStreamId(long id) Stream the peer will send replies on.voidsetRemotePort(int port) Must be called to change the port, not set by readPacket() as the port is out-of-band in the I2CP header.voidsetResendDelay(int numSeconds) Unused.voidsetSendStreamId(long id) Stream the peer will receive data on.voidsetSequenceNum(long num) Sequence number to set.(package private) intsignatureSpaceLen(SigType keyType) How many option bytes to reserve for the signature when this packet is written, which is also how many bytes the signature covers.(package private) static final StringtoId(long id) Format a stream ID for display.booleanverifySignature(I2PAppContext ctx, byte[] buffer) Determine whether the signature on the data is valid.booleanverifySignature(I2PAppContext ctx, SigningPublicKey altSPK, byte[] buffer) Determine whether the signature on the data is valid.intwritePacket(byte[] buffer, int offset) Write the packet to the buffer (starting at the offset) and return the number of bytes written.protected intwritePacket(byte[] buffer, int offset, int fakeSigLen) Write the packet to the buffer, leaving room for a fake signature if requested.(package private) intwrittenSize(SigType keyType) Size of this packet if written to a buffer.
Field Details
POISON_MAX_DELAY_REQUEST
public static final int POISON_MAX_DELAY_REQUESTDelay request that stops a sender thread.- See Also:
Constructor Details
PoisonPacket
public PoisonPacket()Builds the packet that stops a sender thread.
Method Details
getOptionalDelay
public int getOptionalDelay()Description copied from class:PacketHow many milliseconds the sender of this packet wants the recipient to wait before sending any more data (only valid if the flag for it is set).- Overrides:
getOptionalDelayin classPacket- Returns:
- How long the sender wants the recipient to wait before sending any more data in ms.
toString