2.9 - Transmitting packets

Another capability libpcap gives us, is the ability to transmit raw datalink packets. This can be done in two different ways. The standard way is to send each packet out one at a time. WinPcap extensions to jNetPcap, only available on win32 platforms, give us a second way were we can send out a queue of packets out all at once, much more efficiently that we otherwise can.

WinPcap is only available on win32 platforms, and you must use WinPcap.isSupport() call to check if win32 extensions are available on your platform, even if you are sure that they are, you must use it otherwise your code will be unreliable.

The standard way is to either use Pcap.inject() or Pcap.sendPacket() calls. You supply to the call the entire packet including the datalink (i.e. ethernet header) and it will send that packet out on currently open live network interface. Note that these calls are unavailable for offline captures.

Both these calls are also optional and you must first check if they are supported with the following accessors, Pcap.isInjectSupported() and Pcap.isPacketSendSupported(). Both of these will typically be available, but you must none the less make sure and provide code for both cases. Even 3 cases if you also want to include the win32 senqueue as well.