net.i2p.router.transport.udp

## Class UDPPacket

- java.lang.Object
- - net.i2p.router.transport.udp.UDPPacket

     class UDPPacket
    extends Object

Basic delivery unit containing the datagram. This also maintains a cache of object instances to allow rapid reuse.

### Field Summary

Fields
`static byte` `BITFIELD_CONTINUATION`
`static byte` `DATA_FLAG_ACK_BITFIELDS`
`static byte` `DATA_FLAG_ECN`
`static byte` `DATA_FLAG_EXPLICIT_ACK`
`static byte` `DATA_FLAG_EXTENDED`
`static byte` `DATA_FLAG_WANT_ACKS`
`static byte` `DATA_FLAG_WANT_REPLY`
`static int` `IV_SIZE`
`static int` `MAC_SIZE`
`(package private) static int` `MAX_PACKET_SIZE`
`static int` `PAYLOAD_TYPE_DATA`
`static int` `PAYLOAD_TYPE_RELAY_INTRO`
`static int` `PAYLOAD_TYPE_RELAY_REQUEST`
`static int` `PAYLOAD_TYPE_RELAY_RESPONSE`
`static int` `PAYLOAD_TYPE_SESSION_CONFIRMED`
`static int` `PAYLOAD_TYPE_SESSION_CREATED`
`static int` `PAYLOAD_TYPE_SESSION_DESTROY`
`static int` `PAYLOAD_TYPE_SESSION_REQUEST` Message types, 4 bits max
`static int` `PAYLOAD_TYPE_TEST`

### Method Summary

Methods
`static UDPPacket` `acquire(I2PAppContext ctx, boolean inbound)`
`(package private) void` `afterHandling()` a packet handler has finished parsing out the good bits
`(package private) void` `beforeReceiveFragments()` a packet handler has decrypted and verified the packet and is about to parse out the good bits
`void` `decrypt(SessionKey cipherKey)` Decrypt this valid packet, overwriting the _data buffer's payload with the decrypted data (leaving the MAC and IV unaltered)
`(package private) void` `enqueue()` the UDPReceiver has tossed it onto the inbound queue
`(package private) long` `getAfterValidate()` when we finished validate()
`(package private) long` `getBeforeValidate()` when we began validate()
`long` `getBegin()`
`(package private) long` `getEnqueueTime()` when it was added to the endpoint's receive queue
`long` `getExpiration()`
`(package private) int` `getFragmentCount()`
`long` `getLifetime()`
`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
`(package private) int` `getMessageType()` only for debugging and stats, does not go on the wire
`DatagramPacket` `getPacket()`
`short` `getPriority()`
`(package private) long` `getReceivedTime()` when it was pulled off the endpoint receive queue
`(package private) RemoteHostId` `getRemoteHost()`
`(package private) long` `getTimeSinceEnqueue()` the UDPReceiver has tossed it onto the inbound queue
`(package private) long` `getTimeSinceHandling()` a packet handler has finished parsing out the good bits
`(package private) long` `getTimeSinceReceived()` a packet handler has pulled it off the inbound queue
`(package private) long` `getTimeSinceReceiveFragments()` a packet handler has decrypted and verified the packet and is about to parse out the good bits
`(package private) int` `getValidateCount()` how many times we tried to validate the packet
`void` `markType(int type)` flag this packet as a particular type for accounting purposes
`(package private) void` `received()` a packet handler has pulled it off the inbound queue
`void` `release()`
`void` `resetBegin()`
`(package private) void` `setFragmentCount(int count)`
`(package private) void` `setMessageType(int type)` only for debugging and stats, does not go on the wire
`String` `toString()`
`boolean` `validate(SessionKey macKey)` Validate the packet against the MAC specified, returning true if the MAC matches, false otherwise.
`void` `writeData(byte[] src, int offset, int len)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### MAX_PACKET_SIZE

    static final int MAX_PACKET_SIZE

See Also:
  Constant Field Values

#### IV_SIZE

    public static final int IV_SIZE

See Also:
  Constant Field Values

#### MAC_SIZE

    public static final int MAC_SIZE

See Also:
  Constant Field Values

#### PAYLOAD_TYPE_SESSION_REQUEST

    public static final int PAYLOAD_TYPE_SESSION_REQUEST

Message types, 4 bits max

See Also:
  Constant Field Values

#### PAYLOAD_TYPE_SESSION_CREATED

    public static final int PAYLOAD_TYPE_SESSION_CREATED

See Also:
  Constant Field Values

#### PAYLOAD_TYPE_SESSION_CONFIRMED

    public static final int PAYLOAD_TYPE_SESSION_CONFIRMED

See Also:
  Constant Field Values

#### PAYLOAD_TYPE_RELAY_REQUEST

    public static final int PAYLOAD_TYPE_RELAY_REQUEST

See Also:
  Constant Field Values

#### PAYLOAD_TYPE_RELAY_RESPONSE

    public static final int PAYLOAD_TYPE_RELAY_RESPONSE

See Also:
  Constant Field Values

#### PAYLOAD_TYPE_RELAY_INTRO

    public static final int PAYLOAD_TYPE_RELAY_INTRO

See Also:
  Constant Field Values

#### PAYLOAD_TYPE_DATA

    public static final int PAYLOAD_TYPE_DATA

See Also:
  Constant Field Values

#### PAYLOAD_TYPE_TEST

    public static final int PAYLOAD_TYPE_TEST

See Also:
  Constant Field Values

#### PAYLOAD_TYPE_SESSION_DESTROY

    public static final int PAYLOAD_TYPE_SESSION_DESTROY

Since:
  0.8.1
See Also:
  Constant Field Values

#### DATA_FLAG_EXPLICIT_ACK

    public static final byte DATA_FLAG_EXPLICIT_ACK

See Also:
  Constant Field Values

#### DATA_FLAG_ACK_BITFIELDS

    public static final byte DATA_FLAG_ACK_BITFIELDS

See Also:
  Constant Field Values

#### DATA_FLAG_ECN

    public static final byte DATA_FLAG_ECN

See Also:
  Constant Field Values

#### DATA_FLAG_WANT_ACKS

    public static final byte DATA_FLAG_WANT_ACKS

See Also:
  Constant Field Values

#### DATA_FLAG_WANT_REPLY

    public static final byte DATA_FLAG_WANT_REPLY

See Also:
  Constant Field Values

#### DATA_FLAG_EXTENDED

    public static final byte DATA_FLAG_EXTENDED

See Also:
  Constant Field Values

#### BITFIELD_CONTINUATION

    public static final byte BITFIELD_CONTINUATION

See Also:
  Constant Field Values

### Method Detail

#### writeData

    public void writeData(byte[] src,
                 int offset,
                 int len)

#### getPacket

    public DatagramPacket getPacket()

#### getPriority

    public short getPriority()

#### getExpiration

    public long getExpiration()

#### 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()

#### setFragmentCount

    void setFragmentCount(int count)

#### getRemoteHost

    RemoteHostId getRemoteHost()

#### validate

    public boolean validate(SessionKey macKey)

Validate the packet against the MAC specified, returning true if the MAC matches, false otherwise.

#### decrypt

    public void decrypt(SessionKey cipherKey)

Decrypt this valid packet, overwriting the _data buffer's payload with the decrypted data (leaving the MAC and IV unaltered)

#### enqueue

    void enqueue()

the UDPReceiver has tossed it onto the inbound queue

#### received

    void received()

a packet handler has pulled it off the inbound queue

#### beforeReceiveFragments

    void beforeReceiveFragments()

a packet handler has decrypted and verified the packet and is about to parse out the good bits

#### afterHandling

    void afterHandling()

a packet handler has finished parsing out the good bits

#### getTimeSinceEnqueue

    long getTimeSinceEnqueue()

the UDPReceiver has tossed it onto the inbound queue

#### getTimeSinceReceived

    long getTimeSinceReceived()

a packet handler has pulled it off the inbound queue

#### getTimeSinceReceiveFragments

    long getTimeSinceReceiveFragments()

a packet handler has decrypted and verified the packet and is about to parse out the good bits

#### getTimeSinceHandling

    long getTimeSinceHandling()

a packet handler has finished parsing out the good bits

#### getEnqueueTime

    long getEnqueueTime()

when it was added to the endpoint's receive queue

#### getReceivedTime

    long getReceivedTime()

when it was pulled off the endpoint receive queue

#### getBeforeValidate

    long getBeforeValidate()

when we began validate()

#### getAfterValidate

    long getAfterValidate()

when we finished validate()

#### getValidateCount

    int getValidateCount()

how many times we tried to validate the packet

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

#### acquire

    public static UDPPacket acquire(I2PAppContext ctx,
                    boolean inbound)

#### release

    public void release()