Module org.jnetpcap

Class PcapSendQueue

java.lang.Object
org.jnetpcap.windows.PcapSendQueue
All Implemented Interfaces:
AutoCloseable

public class PcapSendQueue extends Object implements AutoCloseable
Represents a queue of raw packets for efficient batch transmission on Microsoft Windows platforms. This class provides functionality to queue multiple packets and transmit them either as quickly as possible or with precise timing synchronization.

Native Structure

Maps to the native pcap_send_queue structure:

 struct pcap_send_queue {
     u_int maxlen;  // Maximum size of the queue buffer in bytes
     u_int len;     // Current size of the queue in bytes
     char *buffer;  // Buffer containing queued packets
 };
 

Usage Example


 try (PcapSendQueue queue = new PcapSendQueue(65536)) { // 64KB queue
 	// Queue multiple packets
 	queue.queue(header1, packet1);
 	queue.queue(header2, packet2);
 
 	// Transmit all queued packets with timing synchronization
 	int bytesSent = queue.transmit(pcapHandle, true);
 }
 

Performance Considerations

  • Using a send queue is more efficient than multiple pcap_sendpacket() calls due to reduced context switching
  • Synchronized transmission (sync=true) provides microsecond precision but requires more CPU resources
  • The CRC is automatically calculated by the network interface

Platform Support

This functionality is only available on Microsoft Windows platforms through WinPcap/Npcap.
Since:
WinPcap 1.0
See Also: