statistics.html 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <HTML>
  2. <HEAD>
  3. <TITLE>Statistics</TITLE>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  5. </HEAD>
  6. <link href="RaknetManual.css" rel="stylesheet" type="text/css">
  7. <meta name="title" content="RakNet - Advanced multiplayer game networking API">
  8. </HEAD>
  9. <BODY BGCOLOR="#ffffff" LINK="#003399" vlink="#003399" alink="#003399" LEFTMARGIN="0" TOPMARGIN="0" MARGINWIDTH="0" MARGINHEIGHT="0"">
  10. <span style="background-color: rgb(255, 255, 255);"><img src="RakNet_Icon_Final-copy.jpg" alt="Oculus VR, Inc." width="150" height="150"></span><BR>
  11. <BR>
  12. <table width="100%" border="0"><tr><td bgcolor="#2c5d92" class="RakNetWhiteHeader">
  13. <img src="spacer.gif" width="8" height="1">Statistics</td>
  14. </tr></table>
  15. <TABLE BORDER="0" CELLPADDING="10" CELLSPACING="0" WIDTH="100%"><TR><TD>
  16. <p><span class="RakNetBlueHeader">How to read and interpret RakNet's statistical data
  17. </span><BR>
  18. <BR>
  19. Statistical data is important for an online game because it lets you see where your traffic bottlenecks are.</p>
  20. <p> RakPeerInterface provides the structure RakNetStatistics which is returned by the GetStatistics() function present in RakPeerInterface. This structure is defined in <I>Source/RakNetStatistics.h</I>. The function StatisticsToString is also provided which will convert these statistics to a formatted buffer.</p>
  21. <p>A running total is kept for the following enumerations</p>
  22. <p class="RakNetCode">/// How many bytes per pushed via a call to RakPeerInterface::Send()<br>
  23. USER_MESSAGE_BYTES_PUSHED,</p>
  24. <p class="RakNetCode"> /// How many user message bytes were sent via a call to RakPeerInterface::Send(). This is less than or equal to USER_MESSAGE_BYTES_PUSHED.<br>
  25. /// A message would be pushed, but not yet sent, due to congestion control<br>
  26. USER_MESSAGE_BYTES_SENT,</p>
  27. <p class="RakNetCode"> /// 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.<br>
  28. USER_MESSAGE_BYTES_RESENT,</p>
  29. <p class="RakNetCode"> /// How many user message bytes were received, and returned to the user successfully.<br>
  30. USER_MESSAGE_BYTES_RECEIVED_PROCESSED,</p>
  31. <p class="RakNetCode"> /// How many user message bytes were received, but ignored due to data format errors. This will usually be 0.<br>
  32. USER_MESSAGE_BYTES_RECEIVED_IGNORED,</p>
  33. <p class="RakNetCode"> /// How many actual bytes were sent, including per-message and per-datagram overhead, and reliable message acks<br>
  34. ACTUAL_BYTES_SENT,</p>
  35. <p class="RakNetCode"> /// How many actual bytes were received, including overead and acks.<br>
  36. ACTUAL_BYTES_RECEIVED,</p>
  37. <p>If you want to track statistics over time, we also provide <em>Source/StatisticsHistoryPlugin.h, </em>used by the sample<em> StatisticsHistoryTest</em>. 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.</p>
  38. <p class="RakNetCode">DataStructures::Queue&lt;StatisticsHistory::TimeAndValue&gt; histogram;<br>
  39. StatisticsHistory::TimeAndValueQueue *tav;<br>
  40. StatisticsHistory::TimeAndValueQueue tavInst;<br>
  41. StatisticsHistory statisticsHistory;<br>
  42. statisticsHistory.SetDefaultTimeToTrack(10000);<br>
  43. statisticsHistory.AddObject(StatisticsHistory::TrackedObjectData(HO_SIN_WAVE,0,0));<br>
  44. statisticsHistory.AddObject(StatisticsHistory::TrackedObjectData(HO_COS_WAVE,0,0));<br>
  45. while (1) {
  46. <br>
  47. double f = (double) ((double)GetTime() / (double)1000);<br>
  48. statisticsHistory.AddValueByObjectID(HO_SIN_WAVE,&quot;Waveform&quot;,sin(f),GetTime(), false);<br>
  49. statisticsHistory.AddValueByObjectID(HO_COS_WAVE,&quot;Waveform&quot;,cos(f),GetTime(), false);<br>
  50. RakSleep(30);<br>
  51. }
  52. <BR>
  53. </p></TD>
  54. </TR></TABLE>
  55. <table width="100%" border="0"><tr><td bgcolor="#2c5d92" class="RakNetWhiteHeader">
  56. <img src="spacer.gif" width="8" height="1">See Also</td>
  57. </tr></table>
  58. <TABLE BORDER="0" CELLPADDING="10" CELLSPACING="0" WIDTH="100%"><TR><TD>
  59. <A HREF="index.html">Index</A><BR>
  60. </TD></TR></TABLE>
  61. </BODY>
  62. </HTML>
粤ICP备19079148号