Jenkins Software

Statistics

How to read and interpret RakNet's statistical data

Statistical data is important for an online game because it lets you see where your traffic bottlenecks are.

RakPeerInterface provides the structure RakNetStatistics which is returned by the GetStatistics() function present in RakPeerInterface. This structure is defined in Source/RakNetStatistics.h. The function StatisticsToString is also provided which will convert these statistics to a formatted buffer.

A running total is kept for the following enumerations

/// How many bytes per pushed via a call to RakPeerInterface::Send()
USER_MESSAGE_BYTES_PUSHED,

/// How many user message bytes were sent via a call to RakPeerInterface::Send(). This is less than or equal to USER_MESSAGE_BYTES_PUSHED.
/// A message would be pushed, but not yet sent, due to congestion control
USER_MESSAGE_BYTES_SENT,

/// How many user message bytes were resent. A message is resent if it is marked as reliable, and either the message didn't arrive or the message ack didn't arrive.
USER_MESSAGE_BYTES_RESENT,

/// How many user message bytes were received, and returned to the user successfully.
USER_MESSAGE_BYTES_RECEIVED_PROCESSED,

/// How many user message bytes were received, but ignored due to data format errors. This will usually be 0.
USER_MESSAGE_BYTES_RECEIVED_IGNORED,

/// How many actual bytes were sent, including per-message and per-datagram overhead, and reliable message acks
ACTUAL_BYTES_SENT,

/// How many actual bytes were received, including overead and acks.
ACTUAL_BYTES_RECEIVED,

If you want to track statistics over time, we also provide Source/StatisticsHistoryPlugin.h, used by the sample StatisticsHistoryTest. It tracks values for some user-defined amount of time and does various calculations on the data set. RakPeerInterface::GetStatistics() is read automatically. Here is sample code that tracks a sin and cos wave.

DataStructures::Queue<StatisticsHistory::TimeAndValue> histogram;
StatisticsHistory::TimeAndValueQueue *tav;
StatisticsHistory::TimeAndValueQueue tavInst;
StatisticsHistory statisticsHistory;
statisticsHistory.SetDefaultTimeToTrack(10000);
statisticsHistory.AddObject(StatisticsHistory::TrackedObjectData(HO_SIN_WAVE,0,0));
statisticsHistory.AddObject(StatisticsHistory::TrackedObjectData(HO_COS_WAVE,0,0));
while (1) {
double f = (double) ((double)GetTime() / (double)1000);
statisticsHistory.AddValueByObjectID(HO_SIN_WAVE,"Waveform",sin(f),GetTime(), false);
statisticsHistory.AddValueByObjectID(HO_COS_WAVE,"Waveform",cos(f),GetTime(), false);
RakSleep(30);
}

See Also
Index