wscout::pcap::Trace Struct Reference

PCAP trace file designed for fast random access. More...

#include <wscout_pcap_trace.hh>

List of all members.

Public Types

enum  link_type {
  LOOP = 0, EN10MB = 1, EN3MB = 2, AX25 = 3,
  PRONET = 4, CHAOS = 5, IEEE802 = 6, ARCNET = 7,
  SLIP = 8, PPP = 9, FDDI = 10, IEEE802_11 = 105,
  PRISM_HEADER = 119
}
typedef PacketIterator iterator

Public Member Functions

 Trace (const std::string &)
template<typename ProgressInfoSetupType, typename ProgressInfoUpdateType>
 Trace (const std::string &filename, ProgressInfoSetupType &pi_setup, ProgressInfoUpdateType &pi_update)
PacketIterator operator[] (size_t)
PacketIterator end_of_trace ()
size_t size () const
link_type linktype () const
std::streampos file_size () const
const std::string & file_name () const

Protected Types

enum  { mark_step = 512, junk_len = 4096 }

Classes

struct  interrupted
 A callback asked the trace construction to stop. More...
struct  invalid_operation
 A file operation (open, seek, etc.) reported an error. More...
struct  PacketIterator
 Iterator over PCAP packets. More...
struct  pcap_file_header
 PCAP file format internal header. More...
struct  pcap_packet_header
 PCAP file format representation of a packet header. More...


Detailed Description

PCAP trace file designed for fast random access.

Member Typedef Documentation

typedef PacketIterator wscout::pcap::Trace::iterator

PCAP packet iterator.


Member Enumeration Documentation

enum wscout::pcap::Trace::link_type

PCAP file link types.

Enumerator:
LOOP  BSD loopback encapsulation.
EN10MB  Ethernet (10Mb).
EN3MB  Experimental Ethernet (3Mb).
AX25  Amateur Radio AX.25.
PRONET  Proteon ProNET Token Ring.
CHAOS  Chaos.
IEEE802  IEEE 802 Networks.
ARCNET  ARCNET, with BSD-style header.
SLIP  Serial Line IP.
PPP  Point-to-point Protocol.
FDDI  FDDI.
IEEE802_11  IEEE 802.11 wireless.
PRISM_HEADER  Prism PHY-layer information.

anonymous enum [protected]

Enumerator:
mark_step  Register a mark every mark_step packets.

A mark is an offset in the trace file. Marks are stored in a vector at regular intervals, so fast access to random packets is possible.

This is a trade-off: more marks allows faster access, but fewer marks uses less memory.

junk_len  When loading traces, read packet data with steps of junk_len bytes.

The more the better, but one must be careful not to grow the stack too much. We use reads here instead of seeks not to break the underlying C++ buffering. Tests showed this is faster.


Constructor & Destructor Documentation

wscout::pcap::Trace::Trace ( const std::string &  filename  )  [inline]

Construct a trace from a file name.

template<typename ProgressInfoSetupType, typename ProgressInfoUpdateType>
wscout::pcap::Trace::Trace ( const std::string &  filename,
ProgressInfoSetupType &  pi_setup,
ProgressInfoUpdateType &  pi_update 
) [inline]

Construct a trace from a file name, with progress indicator callbacks.

Parameters:
[in] filename The file's name.
[in] pi_setup Called before reading packets with two arguments. The first one is the first packet's offset, the last one is the file size.
[in] pi_update Called periodically when reading packets. The current offset in the file is passed as argument. Returns either 0 (continue) or a pointer to a string (stop and throws interrupted(string) ).


Member Function Documentation

Trace::PacketIterator wscout::pcap::Trace::operator[] ( size_t  i  ) 

Get an iterator pointing to a specific packet.

Trace::PacketIterator wscout::pcap::Trace::end_of_trace (  ) 

Get an iterator to the end of trace.

size_t wscout::pcap::Trace::size (  )  const

Get the number of packets in the trace.

Trace::link_type wscout::pcap::Trace::linktype (  )  const

Get the trace's link type.

std::streampos wscout::pcap::Trace::file_size (  )  const

Get the trace size in bytes.

const std::string & wscout::pcap::Trace::file_name (  )  const

Get the trace's name.


The documentation for this struct was generated from the following files:
Generated on Wed Sep 12 16:02:50 2007 for WScout by  doxygen 1.5.3