net.clackrouter.jpcap
Class RawPacket

java.lang.Object
  extended by net.clackrouter.jpcap.RawPacket
All Implemented Interfaces:
java.io.Serializable

public class RawPacket
extends java.lang.Object
implements java.io.Serializable

A captured packet containing raw data.

Encapsulation for data captured on a network device by PacketCapture's raw capture interface.

See Also:
Serialized Form

Constructor Summary
RawPacket(Timeval timeval, byte[] bytes, int droplen)
          Create a new raw packet.
 
Method Summary
 byte[] getData()
          Fetch the raw packet data.
 int getDroplen()
          Fetch the number of bytes dropped (if any) when the packet was captured.
 Timeval getTimeval()
          Fetch the timeval containing the time the packet arrived on the device where it was captured.
 java.lang.String toString()
          Convert this packet to a readable string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RawPacket

public RawPacket(Timeval timeval,
                 byte[] bytes,
                 int droplen)
Create a new raw packet.

Parameters:
timeval - the time the packet arrived on the device where it was captured.
bytes - the raw packet data, including headers.
droplen - the number of bytes dropped (if any) when the packet was captured.
Method Detail

getTimeval

public Timeval getTimeval()
Fetch the timeval containing the time the packet arrived on the device where it was captured.


getData

public byte[] getData()
Fetch the raw packet data.


getDroplen

public int getDroplen()
Fetch the number of bytes dropped (if any) when the packet was captured.

Bytes are dropped when the snapshot length (a ceiling on the number of bytes per packet to capture) is smaller than the actual number of bytes in the packet on the wire. In other words, when caplen exceeds snaplen, bytes are dropped and droplen will be nonzero. Otherwise, all the packet bytes were captured and droplen is zero.


toString

public java.lang.String toString()
Convert this packet to a readable string.

Overrides:
toString in class java.lang.Object