forest-net
an overlay networks for large-scale virtual worlds
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
forest::PacketLog Class Reference
Collaboration diagram for forest::PacketLog:

Classes

struct  EventStruct
 

Public Member Functions

 PacketLog (PacketStore *)
 Constructor for PacketLog, allocates space and initializes private data.
 
 ~PacketLog ()
 Destructor for PacketLog, deletes allocated space.
 
fltx firstFilter () const
 
fltx nextFilter (fltx) const
 
bool validFilter (fltx) const
 
bool match (fltx, pktx, int, bool) const
 
void enable (fltx)
 
void disable (fltx)
 
fltx addFilter ()
 Add a new filter to the table of filters. More...
 
void dropFilter (fltx)
 Remves a filter from the table. More...
 
PacketFiltergetFilter (fltx)
 Get a reference to a packet filter. More...
 
void turnOnLogging (bool)
 Enable or disable logging of packets. More...
 
void enableLocalLog (bool)
 Enable or disable local logging of packets. More...
 
int size () const
 
void log (int, int, bool, uint64_t)
 Log a packet if it matches a stored filter. More...
 
int extract (int, string &)
 Extract event records from the log for delivery to remote client. More...
 
void write (ostream &)
 Write all logged packets. More...
 
void purge ()
 Purge all logged packets.
 

Private Attributes

bool logOn
 turns on capture of packets
 
bool logLocal
 if true, dump events to cout
 
uint64_t dumpTime
 next time to dump events to cout
 
int numOut
 number of packets sent to cout
 
int numDataOut
 number of data packets sent to cout
 
EventStructevec
 
int eventCount
 count of # of events recorded
 
int firstEvent
 oldest event in evec
 
int lastEvent
 newest event in evec
 
PacketFilterfvec
 table of filters
 
ListPair * filters
 in-use/free filter indexes
 
PacketStoreps
 

Static Private Attributes

static const int MAX_EVENTS =10000
 max # of event records
 
static const int MAX_FILTERS =100
 max # of filters
 
static const int OUT_LIMIT = 50000
 max # pkt records to cout
 
static const int DATA_OUT_LIMIT = 10000
 max # data pkts to cout
 

Detailed Description

Definition at line 24 of file PacketLog.h.

Member Function Documentation

int forest::PacketLog::addFilter ( )

Add a new filter to the table of filters.

The filter is disabled initially

Returns
the filter number of the new filter or 0, if could not add

Definition at line 179 of file PacketLog.cpp.

Here is the caller graph for this function:

void forest::PacketLog::dropFilter ( fltx  f)

Remves a filter from the table.

Definition at line 187 of file PacketLog.cpp.

void forest::PacketLog::enableLocalLog ( bool  on)
inline

Enable or disable local logging of packets.

Whenever local logging is enabled, clear counts of packets sent to cout, allowing a new batch of records to be logged to a file.

Definition at line 125 of file PacketLog.h.

Here is the caller graph for this function:

int forest::PacketLog::extract ( int  maxLen,
string &  s 
)

Extract event records from the log for delivery to remote client.

Remote logging requires at least one filter to be defined. It also disables local logging, as we cannot do both at the same time.

Parameters
maxLenis the maximum number of characters to return
sis a reference to a string in which result is returned
Returns
the number of log events in the returned string. Events that are copied to buf are removed from the log.

Definition at line 146 of file PacketLog.cpp.

Here is the call graph for this function:

PacketFilter & forest::PacketLog::getFilter ( fltx  f)
inline

Get a reference to a packet filter.

Parameters
fis the index of some valid filter
Returns
a reference to the PacketFilter object for f

Definition at line 112 of file PacketLog.h.

Here is the caller graph for this function:

void forest::PacketLog::log ( int  px,
int  lnk,
bool  sendFlag,
uint64_t  now 
)

Log a packet if it matches a stored filter.

Parameters
pis the number of the packet to be logged
lnkis the link the packet is being sent on (or was received from)
sendFlagis true if the packet is being sent; else it is false
nowis the time at which the packet is being sent/received Received packet is compared to all enabled filters. If it matches any filter, a copy is made and saved in the log. If the packet can't be saved, we record a "gap" in the log. If several packets in a row cannot be logged, the number of missing packets is recorded as part of the gap record. If no filters are defined, we log every packet.

Definition at line 44 of file PacketLog.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void forest::PacketLog::turnOnLogging ( bool  on)
inline

Enable or disable logging of packets.

Whenever logging is enabled, purge any left-over packets.

Definition at line 117 of file PacketLog.h.

Here is the call graph for this function:

Here is the caller graph for this function:

void forest::PacketLog::write ( ostream &  out)

Write all logged packets.

Parameters
outis an open output stream

Definition at line 93 of file PacketLog.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:


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