Package com.voytechs.jnetstream.io

Stream based, capture file processing.

See:
          Description

Interface Summary
HeuristicPattern  
 

Class Summary
BitStackInputStream todo comment this class :)
CaptureOutputStream Base abstract class for all Capture file specific *OutputStream objects.
DefaultPacketCounter  
DupPacketOutputStream Output stream which duplicates capture file format and contents.
ExpandableByteArrayInputStream Allows a regular ByteArrayInputStream to be expanded and size and capacity after its creation.
MarkerBuffer A special byte buffer that keeps track of holes as the buffer is filled in.
OutputBuffer A specialized buffer that can either work in String or stream mode.
PacketBuffer Converts a MarkerBuffer into a PacketInputStream so it can be used in conjunction with the decoder.
PacketInputStream Stream object that reads either an InputStream of bytes and allows access to the byte stream with the following features:
1) data can be read in either bytes or individual bits.
2) position within the stream can be pushed on to a stack
3) position can be poped off of the stack.
4) a packet structure is imposed on the stream so that you can query or be notified when the end of an individual packet byte stream is over and when the next packet byte stream is beginning.
5) data can be read in any binary format (Big Endian or Little Endian)
6) Packet capture information is accessable, such as:
a) IP address of the capture device.
b) interface or filename the packet was captured on.
c) capture time of the packet
d) length of the entire packet in bytes
e) OS name of the capture device
d) OS version of the capture device
PacketInputStream.BufferedHeader Debug class which returns byte buffer of the headers mainly for debug purposes.
PacketOutputStream Base class for OutputStreams that follow the Packetized structure.

PacketOutputStream is used to output to various CAPTURE stream or file formats, such as PCAP, SNOOP and other sniffer and protocol analyzer formats.



This stream enforces a structure on the stream where certain information about the capture streams can be set and then written out.
PcapInputStream Deprecated. This class should no longer be used as its no longer needed or maintained.
PcapOutputStream Output stream which writes out a capture file in PCAP format.
ProtocolDataInputStream This stream object extends the DataInputStream which defines how to read basic data types from a binary stream.
ProtocolDataOutputStream Writes native JAVA types into the stream.
QueuePacketInputStream Allows packet data to be passed in as byte[] directly into the inputstream.
RandomAccessCaptureFile  
RawformatInputStream This input stream, reads in a capture file and applies capture file definitions found in a NPL file to try to find the right definition for the capture file.
SnoopInputStream For structure of the Snoop file see RFC1761 http://www.faqs.org/rfcs/rfc1761.html
SnoopOutputStream Output stream which writes out a capture file in PCAP format.
StackInputStream  
StreamUtil  
 

Exception Summary
EOPacket  
EOPacketStream  
ProtocolStreamException Base class for Protocol Stream exceptions.
StreamFormatException  
 

Package com.voytechs.jnetstream.io Description

Stream based, capture file processing. This package allows one to manipulate and parse various capture file using JAVA's stream based facilities. You can open a PCAP, Snoop (more in near future) capture files and process their contents. The stream is initialized to the position of packet data and several properties can get inquired to get information about the stream such as getPacketLength() and many others. When the end of packet data in the stream is reached, a call to nextPacket() has to be made inorder to advance the stream to the beginning of the next packet and appropriate properties describing the next packet are updated.

If you try to read the stream past a packets boundary, a EOFPacketException will be thrown. If there is a problem with the stream format, a StreamFormatException will be thrown.


FileInputStream file = new FileInputStream("somefile.pcap"); 
PacketInputStream in = new PcapInputStream(file); // Matches the file type.

while(in.nextPacket()) {
        System.out.println("packet length=" + in.getPacketLength();
        System.out.println("packet snap length=" + in.getPacketSnaplen();
        System.out.println("packet link frame type=" + in.getLinkType(); // Returned as a String

        System.out.println("Ethernet DST=" + 
                in.readUnsignedByte() + ":" +
                in.readUnsignedByte() + ":" +
                in.readUnsignedByte() + ":" +
                in.readUnsignedByte() + ":" +
                in.readUnsignedByte() + ":" +
                in.readUnsignedByte());

        System.out.println("Ethernet SRC=" + 
                in.readUnsignedByte() + ":" +
                in.readUnsignedByte() + ":" +
                in.readUnsignedByte() + ":" +
                in.readUnsignedByte() + ":" +
                in.readUnsignedByte() + ":" +
                in.readUnsignedByte());

        System.out.println("Ethernet protocol=" + Integer.toHexString(in.readUnsignedShort()));

}