class UDPSender extends Object
Each UDPSender instance corresponds to a UDPEndpoint, owning its own dedicated sending thread and queue. Packets to be sent are enqueued by the PacketPusher.
This class utilizes a CoDel-based priority blocking queue to limit packet queueing delay and manages bandwidth throttling for sending.
Supports graceful startup and shutdown signaling using a poison packet.
| Modifier and Type | Field and Description |
|---|---|
static String |
PROP_CODEL_INTERVAL |
static String |
PROP_CODEL_TARGET |
(package private) static long[] |
RATES
Time rate intervals for statistics collection.
|
| Constructor and Description |
|---|
UDPSender(RouterContext ctx,
DatagramSocket socket,
String name,
SocketListener lsnr)
Constructs a UDPSender with the given context, socket, name, and endpoint listener.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(UDPPacket packet)
Adds a UDP packet to the send queue.
|
void |
clear()
Clears the outbound packet queue.
|
boolean |
fullStats()
Returns whether detailed full statistics gathering is enabled.
|
void |
shutdown()
Gracefully shuts down the UDP sender thread.
|
void |
startup()
Starts the UDP sender thread.
|
public static final String PROP_CODEL_INTERVAL
public static final String PROP_CODEL_TARGET
static final long[] RATES
public UDPSender(RouterContext ctx, DatagramSocket socket, String name, SocketListener lsnr)
ctx - the router contextsocket - the UDP datagram socket to send packets onname - thread name identifier for this senderlsnr - the associated socket listener endpointpublic void add(UDPPacket packet)
This operation blocks if the queue is full, which may back up the PacketPusher thread. Packets that are too large or too small are dropped or warned respectively. Bandwidth requests for the packet are initiated before queueing.
packet - the UDP packet to enqueue for sendingpublic void clear()
Typically used in preparation for sending destroy notifications.
public boolean fullStats()
public void shutdown()
Clears the outbound queue and signals the runner thread to stop by enqueueing a poison packet. Waits briefly for the queue to drain.
public void startup()
This method cannot be called more than once as the socket is final.