Package net.i2p.router.transport.udp
Class UDPPacket
java.lang.Object
net.i2p.router.transport.udp.UDPPacket
Basic delivery unit containing the datagram. This also maintains a cache
of object instances to allow rapid reuse.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final bytestatic final bytestatic final byteunusedstatic final bytestatic final byteunusedstatic final bytestatic final bytestatic final byteDefined in the spec from the beginning, Used starting in 0.9.24static final byteDefined in the spec from the beginning, Unusedstatic final intstatic final int(package private) static final intActually it is one less than this, we assume if a received packet is this big it is truncated.static final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intMessage types, 4 bits maxstatic final intstatic final intset to 1 to request a session tag, i.e.static final int -
Method Summary
Modifier and TypeMethodDescriptionstatic UDPPacketacquire(RouterContext ctx, boolean inbound) static voidCall at shutdown/startup to not hold ctx refsvoiddecrypt(SessionKey cipherKey) Decrypt this valid packet, overwriting the _data buffer's payload with the decrypted data (leaving the MAC and IV unaltered) SSU 1 only.voiddrop()For CDQSo that we can compete with NTCP, we want to request bandwidth in parallel, on the way into the queue, not on the way out.longgetBegin()longFor CDQ(package private) intonly for debugging and statslongintflag this packet as a particular type for accounting purposes, with 1 implying the packet is an ACK, otherwise it is a data packet(package private) intonly for debugging and stats, does not go on the wireintHigher is higher priority(package private) RemoteHostIdlongCDPQEntry(package private) longa packet handler has pulled it off the inbound queuevoidmarkType(int type) flag this packet as a particular type for accounting purposes(package private) voidreceived()a packet handler has pulled it off the inbound queuevoidrelease()voidDeprecated.unusedvoidSo that we can compete with NTCP, we want to request bandwidth in parallel, on the way into the queue, not on the way out.voidvoidsetEnqueueTime(long now) For CDQ(package private) voidsetFragmentCount(int count) only for debugging and stats(package private) voidsetMessageType(int type) only for debugging and stats, does not go on the wirevoidsetPriority(int pri) voidsetSeqNum(long num) CDPQEntrytoString()how many times we tried to validate the packetbooleanvalidate(SessionKey macKey, HMACGenerator hmac) Validate the packet against the MAC specified, returning true if the MAC matches, false otherwise.
-
Field Details
-
MAX_PACKET_SIZE
static final int MAX_PACKET_SIZEActually it is one less than this, we assume if a received packet is this big it is truncated. This is bigger than PeerState.LARGE_MTU, as the far-end's LARGE_MTU may be larger than ours. Due to longstanding bugs, a packet may be larger than LARGE_MTU (acks and padding). Together with an increase in the LARGE_MTU to 1492 in release 0.8.9, routers from 0.8.9 - 0.8.11 can generate packets up to 1536. Data packets are always a multiple of 16, so make this 4 + a multiple of 16.- See Also:
-
IV_SIZE
public static final int IV_SIZE- See Also:
-
MAC_SIZE
public static final int MAC_SIZE- See Also:
-
PAYLOAD_TYPE_SESSION_REQUEST
public static final int PAYLOAD_TYPE_SESSION_REQUESTMessage types, 4 bits max- See Also:
-
PAYLOAD_TYPE_SESSION_CREATED
public static final int PAYLOAD_TYPE_SESSION_CREATED- See Also:
-
PAYLOAD_TYPE_SESSION_CONFIRMED
public static final int PAYLOAD_TYPE_SESSION_CONFIRMED- See Also:
-
PAYLOAD_TYPE_RELAY_REQUEST
public static final int PAYLOAD_TYPE_RELAY_REQUEST- See Also:
-
PAYLOAD_TYPE_RELAY_RESPONSE
public static final int PAYLOAD_TYPE_RELAY_RESPONSE- See Also:
-
PAYLOAD_TYPE_RELAY_INTRO
public static final int PAYLOAD_TYPE_RELAY_INTRO- See Also:
-
PAYLOAD_TYPE_DATA
public static final int PAYLOAD_TYPE_DATA- See Also:
-
PAYLOAD_TYPE_TEST
public static final int PAYLOAD_TYPE_TEST- See Also:
-
PAYLOAD_TYPE_SESSION_DESTROY
public static final int PAYLOAD_TYPE_SESSION_DESTROY- Since:
- 0.8.1
- See Also:
-
MAX_PAYLOAD_TYPE
public static final int MAX_PAYLOAD_TYPE- See Also:
-
HEADER_FLAG_REKEY
public static final byte HEADER_FLAG_REKEYDefined in the spec from the beginning, Unused- Since:
- 0.9.24
- See Also:
-
HEADER_FLAG_EXTENDED_OPTIONS
public static final byte HEADER_FLAG_EXTENDED_OPTIONSDefined in the spec from the beginning, Used starting in 0.9.24- Since:
- 0.9.24
- See Also:
-
SESS_REQ_MIN_EXT_OPTIONS_LENGTH
public static final int SESS_REQ_MIN_EXT_OPTIONS_LENGTH- See Also:
-
SESS_REQ_EXT_FLAG_REQUEST_RELAY_TAG
public static final int SESS_REQ_EXT_FLAG_REQUEST_RELAY_TAGset to 1 to request a session tag, i.e. we want him to be an introducer for us- See Also:
-
DATA_FLAG_EXPLICIT_ACK
public static final byte DATA_FLAG_EXPLICIT_ACK- See Also:
-
DATA_FLAG_ACK_BITFIELDS
public static final byte DATA_FLAG_ACK_BITFIELDS- See Also:
-
DATA_FLAG_ECN
public static final byte DATA_FLAG_ECNunused- See Also:
-
DATA_FLAG_WANT_ACKS
public static final byte DATA_FLAG_WANT_ACKS- See Also:
-
DATA_FLAG_WANT_REPLY
public static final byte DATA_FLAG_WANT_REPLY- See Also:
-
DATA_FLAG_EXTENDED
public static final byte DATA_FLAG_EXTENDEDunused- See Also:
-
BITFIELD_CONTINUATION
public static final byte BITFIELD_CONTINUATION- See Also:
-
-
Method Details
-
setSeqNum
public void setSeqNum(long num) CDPQEntry -
getSeqNum
public long getSeqNum()CDPQEntry -
getPacket
-
getPriority
public int getPriority()Description copied from interface:PQEntryHigher is higher priority- Specified by:
getPriorityin interfacePQEntry
-
setPriority
public void setPriority(int pri) - Since:
- 0.9.53
-
getBegin
public long getBegin() -
getLifetime
public long getLifetime() -
resetBegin
public void resetBegin() -
markType
public void markType(int type) flag this packet as a particular type for accounting purposes -
getMarkedType
public int getMarkedType()flag this packet as a particular type for accounting purposes, with 1 implying the packet is an ACK, otherwise it is a data packet -
getMessageType
int getMessageType()only for debugging and stats, does not go on the wire -
setMessageType
void setMessageType(int type) only for debugging and stats, does not go on the wire -
getFragmentCount
int getFragmentCount()only for debugging and stats -
setFragmentCount
void setFragmentCount(int count) only for debugging and stats -
getRemoteHost
RemoteHostId getRemoteHost() -
validate
Validate the packet against the MAC specified, returning true if the MAC matches, false otherwise. -
decrypt
Decrypt this valid packet, overwriting the _data buffer's payload with the decrypted data (leaving the MAC and IV unaltered) SSU 1 only. SSU 2 decryption is in PacketHandler. -
setEnqueueTime
public void setEnqueueTime(long now) For CDQ- Specified by:
setEnqueueTimein interfaceCDQEntry- Since:
- 0.9.3
-
received
void received()a packet handler has pulled it off the inbound queue -
getEnqueueTime
public long getEnqueueTime()For CDQ- Specified by:
getEnqueueTimein interfaceCDQEntry- Since:
- 0.9.3
-
getTimeSinceReceived
long getTimeSinceReceived()a packet handler has pulled it off the inbound queue -
requestInboundBandwidth
Deprecated.unusedSo that we can compete with NTCP, we want to request bandwidth in parallel, on the way into the queue, not on the way out. Call before enqueueing.- Since:
- 0.9.21
-
requestOutboundBandwidth
public void requestOutboundBandwidth()So that we can compete with NTCP, we want to request bandwidth in parallel, on the way into the queue, not on the way out. Call before enqueueing.- Since:
- 0.9.21
-
getBandwidthRequest
So that we can compete with NTCP, we want to request bandwidth in parallel, on the way into the queue, not on the way out. Call after dequeueing.- Since:
- 0.9.21
-
toString
how many times we tried to validate the packet -
acquire
- Parameters:
inbound- unused
-
drop
public void drop()For CDQ -
release
public void release() -
clearCache
public static void clearCache()Call at shutdown/startup to not hold ctx refs- Since:
- 0.9.2
-