forest-net
an overlay networks for large-scale virtual worlds
|
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... | |
PacketFilter & | getFilter (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 | |
EventStruct * | evec |
int | eventCount |
count of # of events recorded | |
int | firstEvent |
oldest event in evec | |
int | lastEvent |
newest event in evec | |
PacketFilter * | fvec |
table of filters | |
ListPair * | filters |
in-use/free filter indexes | |
PacketStore * | ps |
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 | |
Definition at line 24 of file PacketLog.h.
int forest::PacketLog::addFilter | ( | ) |
Add a new filter to the table of filters.
The filter is disabled initially
Definition at line 179 of file PacketLog.cpp.
void forest::PacketLog::dropFilter | ( | fltx | f) |
Remves a filter from the table.
Definition at line 187 of file PacketLog.cpp.
|
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.
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.
maxLen | is the maximum number of characters to return |
s | is a reference to a string in which result is returned |
Definition at line 146 of file PacketLog.cpp.
|
inline |
Get a reference to a packet filter.
f | is the index of some valid filter |
Definition at line 112 of file PacketLog.h.
void forest::PacketLog::log | ( | int | px, |
int | lnk, | ||
bool | sendFlag, | ||
uint64_t | now | ||
) |
Log a packet if it matches a stored filter.
p | is the number of the packet to be logged |
lnk | is the link the packet is being sent on (or was received from) |
sendFlag | is true if the packet is being sent; else it is false |
now | is 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.
|
inline |
Enable or disable logging of packets.
Whenever logging is enabled, purge any left-over packets.
Definition at line 117 of file PacketLog.h.
void forest::PacketLog::write | ( | ostream & | out) |
Write all logged packets.
out | is an open output stream |
Definition at line 93 of file PacketLog.cpp.