MAK RTIspy API Documentation for HLA 1516
netStats.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2012 MaK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 #ifndef netStats_h__
6 #define netStats_h__
7 
8 
9 #include "rtiMsg.h"
10 
11 #include <vlutil/vlString.h>
12 #include <vlutil/vlTime.h>
13 #include <vlutil/vlHashlist.h>
14 
15 #include <rtiAmbAPITypes.h>
16 #include <fedAmbAPITypes.h>
17 
18 #include <map>
19 
20 // The DtMsgStats class packages statistics
21 // data about an individual RTI message type
23 {
24 public:
25 
26  // Default Constructor
27  DtMsgStats() { reset(); }
28 
29  // Set Stats to known state
30  void reset();
31 
32  // Get a printable string of tab-delimited column headers
33  static const DtString header();
34 
35  // Get a printable string of tab-delimited data
36  const DtString string() const;
37 
38 public:
39 
40  unsigned int sentMsgs;
41  unsigned int sentBytes;
42  unsigned int minSentBytes;
43  unsigned int maxSentBytes;
44  double avgSentBytes;
45  double sendTime;
46  double minSendTime;
47  double maxSendTime;
48  double avgSendTime;
49  unsigned int recvdMsgs;
50  unsigned int recvdBytes;
51  unsigned int minRecvdBytes;
52  unsigned int maxRecvdBytes;
53  double avgRecvdBytes;
54  double recvTime;
55  double minRecvTime;
56  double maxRecvTime;
57  double avgRecvTime;
58  unsigned int dataBytes;
59  unsigned int overheadPerMsg;
61 };
62 
64 {
65 public:
66  // Default Constructor
68 
69  // Set Stats to known state
70  void reset();
71 
72  // Get a printable string of tab-delimited column headers
73  static const DtString header();
74 
75  // Get a printable string of tab-delimited data
76  const DtString string() const;
77 
78 public:
79 
80  unsigned int totalCalls;
81  double totalTime;
82  double minCallTime;
83  double maxCallTime;
84  double avgCallTime;
85 
86 };
87 
89 {
90 public:
91  // Default Constructor
92  DtObjIntStats();
93 
94  // Set Stats to known state
95  void reset();
96 
97  // Get a printable string of tab-delimited column headers
98  static const DtString header();
99 
100  // Get a printable string of tab-delimited data
101  const DtString string() const;
102 
103 public:
104 
105  DtString instanceName;
106  DtString className;
107  unsigned int instanceHandle;
108  unsigned int classHandle;
109  unsigned int numRegistered;
110  unsigned int numDiscovered;
111  unsigned int updatesReceived;
112  unsigned int bytesReceived;
113  unsigned int updatesSent;
114  unsigned int bytesSent;
115 };
116 
117 //
118 // The DtTrafficStats class stores statistics data related to
119 // network traffic
120 //
122 {
123 public:
124  // Uses Default Copy Ctor / Dtor / Assignment
125 
126  // Default Constructor ( just resets )
128 
129  // Reset all values to zero
130  void reset();
131 
132  // Resets FOM related maps
133  void resetFomStats();
134 
135  // Get a tab-separated header string for the stats data
136  static const DtString header();
137 
138  // Get a string containing current stats in tab-separated form
139  const DtString string() const;
140 
141  // Print stuff
142  const DtString toDtString() const;
143 
144  // Add a sent message to the tally
145  void msgSent( unsigned int fedId, DtRtiMsgKind msgKind,
146  unsigned int size, double sendTime );
147 
148  // Add a received message to the tally
149  void msgRcvd( unsigned int fedId, DtRtiMsgKind msgKind,
150  unsigned int size, double recvTime );
151 
152  // Add an RTI Amb. API call to the tally
153  void rtiAmbCalled( const DtRtiAmbAPIType callName, double callTime );
154 
155  // Add a Fed. Amb. API call to the tally
156  void fedAmbCalled( const DtFedAmbAPIType callName, double callTime );
157 
158  // Get a pointer to the current message object statistics
159  const DtMsgStats* getMsgStats( DtRtiMsgKind msgKind ) const;
160 
161  // Add a new object
162  void addObject( bool isRegistered, unsigned int objHandle,
163  const DtString& theClassName, const DtString& theObjectName, DtObjectClassHandle theClassHandle );
164 
165  // Add a new interaction
166  void addInteraction( bool isSent, unsigned int interHandle,
167  const DtString& theInterName );
168 
169 
170  // Record statistics about an update or interaction message
171  void recordUpdate( bool isSent, unsigned int msgSize, double time,
172  DtObjectInstanceHandle handle, const DtString& name,
173  DtObjectClassHandle classHandle, const DtString & objectClassName);
174  void recordInteraction( bool isSent, unsigned int msgSize, double time,
175  DtInteractionClassHandle handle, const DtString& name );
176 
177 
178 protected:
179 
180  // Update the statistics calculations
181  void updateMsgStats( bool isSentMsg, DtRtiMsgKind msgKind,
182  unsigned int size, double time );
183 
184  // Check that data is consistent
185  void checkInternalState() const;
186  bool containsObjectInstance(unsigned int objectInstanceHandle);
187  bool containsInteractionClass(unsigned int interactionClassHandle);
188 public:
189 
190  // Statistics Data
191 
192  // Message Counts
193  unsigned int myTotalMsgsReceived; // Count of all received msgs
194  unsigned int myNumAnonMsgs; // Count of all msgs from federate handle 0
195  unsigned int myNumSentMsgs; // Count of all msgs from local federate
196  unsigned int myNumFedMsgs; // Count of all msgs from other federates
197 
198  // Bandwidth Usage
199  unsigned int myTotalBytesReceived; // Total size of all msgs received (includes anon)
200  unsigned int myTotalBytesSent; // Total size of all msgs sent
201  double myAveMsgSize; // Running average size of all msgs
202  unsigned int myMaxMsgSize; // Largest msg sent/received so far
203  unsigned int myMinMsgSize; // Smallest msg sent/received so far
204 
205  // Performance Stats
206  MAKRti::DtClock myCollectionPeriod; // Total time over which stats have been gathered
207  MAKRti::DtTime myTotalSendTime; // Total Time spent in Send
208  MAKRti::DtTime myAveSendTime; // Average Time spent in Send
209  MAKRti::DtTime myMinSendTime; // Minimum Time spent in Send
210  MAKRti::DtTime myMaxSendTime; // Maximum Time spent in Send
211 
212  MAKRti::DtTime myTotalReadTime; // Total Time spent in Read
213  MAKRti::DtTime myAveReadTime; // Average Time spent in Read
214  MAKRti::DtTime myMinReadTime; // Minimum Time spent in Read
215  MAKRti::DtTime myMaxReadTime; // Maximum Time spent in Read
216 
217 
218  // API Stats
219  MAKRti::DtTime myTotalApiTime; // Total Time spent in RTI Amb. calls
220  MAKRti::DtTime myTotalCallbackTime; // Total Time spent in Fed. Amb. callbacks
221 
222  // Per Obj/Inter/Call Data
223  //DtMsgStats myMsgDataByKind[DtInvalidMsgKind]; // Per Message Data
224  std::map< DtRtiMsgKind, DtMsgStats > myMsgDataByKind; // Per Message Data
225  std::map< DtRtiAmbAPIType, DtRtiApiStats > myApiDataByCallName; // Per RTI Amb API Call Data
226  std::map< DtFedAmbAPIType, DtRtiApiStats > myFedDataByCallName; // Per Fed Amb API Call Data
227  std::map< unsigned int, DtObjIntStats > myObjectData; // Per Object stats
228  std::map< unsigned int, DtObjIntStats > myInteractionData; // Per Interaction stats
229  std::set< unsigned int > myObjectInstanceNamesToSend; // Object Instance Handles
230 
231  // FOM Stats
232 
233  // Map where key is object handle and value is the attribute handle
234  // This is populated when there is a transport, order, publish, or subscribe change
237  //std::map< unsigned int, unsigned int > myAttributeHandleByObjectHandleMap;
238 
239  // Map where key is interaction handle and value is the parameter handle
240  // This is populated when there is a transport, order, publish, or subscribe change
241  std::map< unsigned int, unsigned int > myParameterHandleByInteractionHandleMap;
242 
243 };
244 #endif // netStats_h__
245 

Document ID: Generated on Tue May 7 16:26:47 EDT 2013 from SVN revision 126903
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)