wpl::pcap::indexed_file< Bottom > Struct Template Reference

pcap file featuring random packet access. More...

#include <wipal/pcap/stream.hh>

Inheritance diagram for wpl::pcap::indexed_file< Bottom >:
wpl::pcap::file< Bottom > wpl::pcap::istream< Bottom > wpl::pcap::stream< Bottom > wpl::pkt::stream< Bottom > wpl::tool::iterable< Bottom > wpl::tool::static_base< Bottom >

List of all members.

Public Types

enum  { mark_step = 4, junk_len = 4096 }
typedef HIDDEN exact_type
typedef file< exact_typesuper_type
typedef HIDDEN iterator
typedef std::vector
< std::streampos > 
index_type
typedef iterator const_iterator
typedef iterator::value_type packet

Public Member Functions

 indexed_file (const std::string &filename)
 indexed_file (const std::string &filename, const index_type &marks, unsigned size)
template<typename ProgressInfoSetupType , typename ProgressInfoUpdateType >
 indexed_file (const std::string &filename, ProgressInfoSetupType &pi_setup, ProgressInfoUpdateType &pi_update)
iterator operator[] (size_t)
size_t size () const
std::ifstream * stream (bool seek=true) const
std::streampos filesize () const
const std::string & filename () const
std::ostream & print_impl (std::ostream &) const
bool swapped_impl () const
pkt::type type_impl () const
int32_t zone_impl () const
int32_t snaplen_impl () const
int32_t zone () const
int32_t snaplen () const
bool swapped () const
pkt::type type () const
void expect (pkt::type t) const
std::ostream & print (std::ostream &) const
iterator begin () const
iterator end () const
template<class OutputIterator >
void operator() (const OutputIterator &output) const
template<class O >
void operator() (const O &o) const
template<class F >
void for_each (F &f) const
template<class F >
void for_each (const F &f) const

opt::listmeta ()
const opt::listmeta () const
Apply a function/functor to each element

template<class Functor >
void for_each (Functor &f) const
template<class Functor >
void for_each (const Functor &f) const
Downcast methods

const exact_typeexact () const
exact_typeexact ()
const exact_typeexact_ptr () const
exact_typeexact_ptr ()

Protected Member Functions

void warn (const std::streampos &pos, const std::string &msg)
void handle_truncation (const std::string &msg)

Detailed Description

template<class Bottom = tool::bottom>
struct wpl::pcap::indexed_file< Bottom >

pcap file featuring random packet access.

Todo:
FIXME: Document random packet access.

Member Typedef Documentation

template<class Bottom = tool::bottom>
typedef std::vector<std::streampos> wpl::pcap::indexed_file< Bottom >::index_type

Internal index type for random frame access.

Only advanced users need to know about this.

See also:
mark_step.

Member Enumeration Documentation

template<class Bottom = tool::bottom>
anonymous enum
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.

Given a value of 4, with sizeof (std::streampos) == 8 and 100.000.000 packets in a file (which is quite a lot), this gives an index of about 200 MiB.

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

template<class B >
template<typename ProgressInfoSetupType , typename ProgressInfoUpdateType >
wpl::pcap::indexed_file< B >::indexed_file ( const std::string &  filename,
ProgressInfoSetupType &  pi_setup,
ProgressInfoUpdateType &  pi_update 
) [inline]

Construct a file 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

template<class B >
const opt::list & wpl::pkt::stream< B >::meta (  )  const [inline, inherited]

Access to the stream metadata.

Todo:
FIXME: Document.
template<class B >
opt::list & wpl::pkt::stream< B >::meta (  )  [inline, inherited]

Access to the stream metadata.

Todo:
FIXME: Document.
template<class B >
std::ifstream * wpl::pcap::file< B >::stream ( bool  seek = true  )  const [inline, inherited]

Get a fresh std::ifstream object.

If seek is true, the stream is positioned at the beginning of packets.

The stream needs too be delete'ed after use.

template<class B >
bool wpl::pkt::stream< B >::swapped (  )  const [inline, inherited]

Get the stream's endianness w.r.t.

the host system.

Some packet streams might be encoded with a custom endianness by packet sniffers. This should not impact users in theory because it is up to the stream implementation to decode it. However sometimes the capture system's endianness might affect packet bytes (e.g. Prism headers) and nothing can be done at the stream implementation level to fix this. Thus this function.

template<class B >
pkt::type wpl::pkt::stream< B >::type (  )  const [inline, inherited]

Get the stream's link type.

See also:
type.

The documentation for this struct was generated from the following files:

Generated by  doxygen 1.6.2