com.voytechs.jnetstream.io
Class SnoopInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by com.voytechs.jnetstream.io.ProtocolDataInputStream
          extended by com.voytechs.jnetstream.io.PacketInputStream
              extended by com.voytechs.jnetstream.io.SnoopInputStream
All Implemented Interfaces:
java.io.Closeable

public class SnoopInputStream
extends PacketInputStream

For structure of the Snoop file see RFC1761 http://www.faqs.org/rfcs/rfc1761.html


Nested Class Summary
 
Nested classes/interfaces inherited from class com.voytechs.jnetstream.io.PacketInputStream
PacketInputStream.BufferedHeader
 
Field Summary
 
Fields inherited from class com.voytechs.jnetstream.io.PacketInputStream
captureDeviceArch, captureDeviceFilename, captureDeviceIp, captureDeviceOS, captureLive, debugHeaders, fileHeader, linkType, packetCaptureTimestamp, packetEnd, packetLength, packetSnaplen, packetStart, recordEnd, recordHeader, recordLength, recordStart, stackIn
 
Fields inherited from class com.voytechs.jnetstream.io.ProtocolDataInputStream
bitsLeft, in
 
Constructor Summary
SnoopInputStream(java.io.InputStream snoopFileFormatInputStream)
           
SnoopInputStream(java.lang.String filename)
          Opens up the given file and starts processing the data.
 
Method Summary
 byte[] getSnoopMagicNumber()
          Returns the magic number found at the beginning of the SNOOP file.
 long getSnoopMajorVer()
          Returns the major version number of the SNOOP file.
protected  void initPacketStream()
          Since we know we are dealing with a Snoop-file formatted stream (i.e.
protected  void initRecordHeader()
          Read pre-packet header from stream.
 long snoopLinktype()
          The link type of the first header in the packet.
 long snoopPacketCaptureNanos()
          Number of naono seconds found in the raw data file.
 long snoopPacketCaptureSecs()
          Number of raw number of the capture file.
 long snoopSnaplen()
          Retuns the SNAP len of the capture file.
 java.lang.String toString()
           
 
Methods inherited from class com.voytechs.jnetstream.io.PacketInputStream
bitsLeft, clear, getCaptureDeviceAddress, getCaptureDeviceArch, getCaptureDeviceFilename, getCaptureDeviceIp, getCaptureDeviceOS, getCaptureTimestamp, getFileFormatName, getFileHeader, getLinkType, getPacketEnd, getPacketLength, getPacketLengthRemaining, getPacketSnaplen, getPacketStart, getPaddingLength, getRecordEnd, getRecordHeader, getRecordHeaderLength, getRecordLength, getRecordStart, goToEndOfRecord, gotoMark, hasForceRead, hex, isCaptureLive, isCompressed, isDebugHeaders, isPacketReady, isReady, isReady, main, nextPacket, pop, position, printStream, push, push, read, setCaptureTimestamp, setCompressed, setDebugHeaders, setForceRead, setIncludePadding, setLinkType, setPacketLength, setPacketSnaplen, setPacketStart, setRecordLength, setRecordStart, skip
 
Methods inherited from class com.voytechs.jnetstream.io.ProtocolDataInputStream
readBits, readBitsLong, readBoolean, readByte, readerUnsignedLongLittleEndian, readFromPacket, readFromPacket, readInt, readIntLittleEndian, readLong, readLongLittleEndian, readShort, readShortLittleEndian, readUnsignedByte, readUnsignedInt, readUnsignedIntLittleEndian, readUnsignedLong, readUnsignedShort, readUnsignedShortLittleEndian, reThrow
 
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, read, read, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SnoopInputStream

public SnoopInputStream(java.io.InputStream snoopFileFormatInputStream)
                 throws java.io.IOException,
                        EOPacketStream,
                        StreamFormatException
Parameters:
-
Throws:
java.io.IOException
EOPacketStream
StreamFormatException

SnoopInputStream

public SnoopInputStream(java.lang.String filename)
                 throws java.io.FileNotFoundException,
                        java.io.IOException,
                        EOPacketStream,
                        StreamFormatException
Opens up the given file and starts processing the data.

Parameters:
filename - Filename of the file in SNOOP fileformat to open.
Throws:
java.io.FileNotFoundException
java.io.IOException
EOPacketStream
StreamFormatException
Method Detail

initPacketStream

protected void initPacketStream()
                         throws java.io.IOException,
                                EOPacketStream,
                                StreamFormatException
Since we know we are dealing with a Snoop-file formatted stream (i.e. FileInputStream("snoop-capturefile.snoop")) we initialize the ProtocolInputStream using values extracted from the snoop stream.

First we extract the "snoop_file_heaer" as specified above.

Overrides:
initPacketStream in class PacketInputStream
Throws:
java.io.IOException
EOPacketStream
StreamFormatException

initRecordHeader

protected void initRecordHeader()
                         throws java.io.IOException,
                                EOPacketStream,
                                StreamFormatException
Read pre-packet header from stream. With basic info about the next packet to follow. this is called for every packet in the stream. Main purpose is to get packet-data length (or length of captured packet) and the capture time of the packet.

Overrides:
initRecordHeader in class PacketInputStream
Throws:
java.io.IOException
EOPacketStream
StreamFormatException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getSnoopMagicNumber

public byte[] getSnoopMagicNumber()
Returns the magic number found at the beginning of the SNOOP file.


getSnoopMajorVer

public long getSnoopMajorVer()
Returns the major version number of the SNOOP file.


snoopSnaplen

public long snoopSnaplen()
Retuns the SNAP len of the capture file. This is the number of bytes that we saved, not captured. i.e. first 128 bytes.


snoopLinktype

public long snoopLinktype()
The link type of the first header in the packet. Normally this is type 2 (ethernet) but any of the others are possible as well.


snoopPacketCaptureSecs

public long snoopPacketCaptureSecs()
Number of raw number of the capture file. JNetStream library multiplies this number by factor of 1000 before returning it.

This value changes from packet to packet.


snoopPacketCaptureNanos

public long snoopPacketCaptureNanos()
Number of naono seconds found in the raw data file. This number is also multiplied by 1000.

This value changes from packet to packet.