Chris Bennetts writes, "This Sniffer package allows a high level programmer to sniff IP packets arriving at, and leaving their computer. A queue of IP packets is sent to the Java or C++ program and the programmer can analyse each packet in sequence. The programmer can optionally filter the queue of IP packets by specifying the IP addresses, protocols and port numbers for which packets are queued.. . .
Chris Bennetts writes, "This Sniffer package allows a high level programmer to sniff IP packets arriving at, and leaving their computer. A queue of IP packets is sent to the Java or C++ program and the programmer can analyse each packet in sequence. The programmer can optionally filter the queue of IP packets by specifying the IP addresses, protocols and port numbers for which packets are queued.

This is accomplished by one of the four subclasses of PacketReader:

  1. PacketReaderIn
  2. PacketReaderOut
  3. PacketReaderFilterIn
  4. PacketReaderFilterOut
Each PacketReader provides a different functionality. "In" PacketReaders queue ALL packets arriving at the host, and "Out" PacketReaders queue ALL packets leaving the host. "Filter" PacketReaders are created with a FilterRules object that specifies the rules used to queue packets to the PacketReader. This enables only some packets to be queued. For example: all TCP packets with destination port 80. Note: packets are compared to the rules within the kernel for speed and efficiency.

Once a packet is retrieved, fields from headers of packets can be accessed by their corresponding getX() methods, and the raw contents can be accessed as a byte array.

An enhanced library packet utilities(US$50), allows your program to drop packets based on rules, or you can review packets and decide to allow/drop each packet individually.

The link for this article located at Softengineering is no longer available.