class UDPPacket extends Object implements CDPQEntry
| Modifier and Type | Field and Description |
|---|---|
static int |
IV_SIZE
Size of initialization vector in bytes.
|
static int |
MAC_SIZE
Size of MAC (Message Authentication Code) in bytes.
|
(package private) static int |
MAX_PACKET_SIZE
Maximum UDP packet size accepted.
|
static int |
MAX_PAYLOAD_TYPE |
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 |
static int |
PAYLOAD_TYPE_TEST |
| Modifier and Type | Method and Description |
|---|---|
static UDPPacket |
acquire(RouterContext ctx,
boolean inbound)
Acquires a UDPPacket instance, either from the cache or by creating a new instance.
|
static void |
clearCache()
Clears the internal packet cache if caching is enabled.
|
void |
drop()
Convenience method to release the packet.
|
FIFOBandwidthLimiter.Request |
getBandwidthRequest()
Returns the current bandwidth request associated with this packet.
|
long |
getBegin()
Gets the packet initialization timestamp in milliseconds.
|
long |
getEnqueueTime()
Gets the time the packet was enqueued.
|
(package private) int |
getFragmentCount() |
long |
getLifetime()
Returns how long this packet has existed since initialization.
|
int |
getMarkedType()
Gets the currently marked type of the packet.
|
(package private) int |
getMessageType() |
DatagramPacket |
getPacket()
Gets the underlying
DatagramPacket. |
int |
getPriority()
Gets the packet priority.
|
(package private) RemoteHostId |
getRemoteHost()
Lazily obtains the
RemoteHostId representing the sender's address and port. |
long |
getSeqNum()
Gets the packet sequence number.
|
(package private) long |
getTimeSinceReceived()
Returns the amount of time elapsed since the packet was received.
|
void |
markType(int type)
Marks the packet with a custom type for internal identification.
|
static String |
payloadTypeToString(int type)
Converts payload type integer constant to human-readable string.
|
(package private) void |
received()
Marks the packet as received, recording the current time.
|
static void |
reduceCacheSize()
Reduces cache size under memory pressure.
|
void |
release()
Releases this packet back to the object cache and aborts any outstanding bandwidth request.
|
void |
requestOutboundBandwidth()
Requests outbound bandwidth for sending this packet.
|
void |
resetBegin()
Resets the initialization timestamp to current time.
|
void |
setEnqueueTime(long now)
Sets the enqueue time timestamp, indicating when the packet was queued for processing.
|
(package private) void |
setFragmentCount(int count) |
(package private) void |
setMessageType(int type) |
void |
setPriority(int pri)
Sets the packet priority.
|
void |
setSeqNum(long num)
Sets the packet sequence number.
|
String |
toString()
Returns a detailed string representation of this packet, including address, size,
priority, message and mark types, fragment counts, and timing information.
|
public static final int IV_SIZE
public static final int MAC_SIZE
static final int MAX_PACKET_SIZE
public static final int MAX_PAYLOAD_TYPE
public static final int PAYLOAD_TYPE_DATA
public static final int PAYLOAD_TYPE_RELAY_INTRO
public static final int PAYLOAD_TYPE_RELAY_REQUEST
public static final int PAYLOAD_TYPE_RELAY_RESPONSE
public static final int PAYLOAD_TYPE_SESSION_CONFIRMED
public static final int PAYLOAD_TYPE_SESSION_CREATED
public static final int PAYLOAD_TYPE_SESSION_DESTROY
public static final int PAYLOAD_TYPE_SESSION_REQUEST
public static final int PAYLOAD_TYPE_TEST
public static UDPPacket acquire(RouterContext ctx, boolean inbound)
ctx - RouterContext for timing and logginginbound - true if this packet is inbound, false if outbound (currently unused)public static void clearCache()
public void drop()
public FIFOBandwidthLimiter.Request getBandwidthRequest()
public long getBegin()
public long getEnqueueTime()
getEnqueueTime in interface CDQEntryint getFragmentCount()
public long getLifetime()
public int getMarkedType()
int getMessageType()
public DatagramPacket getPacket()
DatagramPacket.IllegalStateException - if the packet has been releasedpublic int getPriority()
getPriority in interface PQEntryRemoteHostId getRemoteHost()
RemoteHostId representing the sender's address and port.
This is initialized once per packet and cached thereafter.public long getSeqNum()
long getTimeSinceReceived()
public void markType(int type)
type - integer representing a mark typepublic static String payloadTypeToString(int type)
type - the payload type constantvoid received()
public static void reduceCacheSize()
public void release()
public void requestOutboundBandwidth()
public void resetBegin()
public void setEnqueueTime(long now)
setEnqueueTime in interface CDQEntrynow - enqueue time in millisecondsvoid setFragmentCount(int count)
void setMessageType(int type)
public void setPriority(int pri)
pri - priority level to assignpublic void setSeqNum(long num)