Jenkins Software


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()

/// 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

/// 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.

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

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

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

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

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;
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);

See Also