MAK RTIspy API Documentation for HLA Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  bool statsUpdated; //Should be set to true whenever any of the above are changed.
116 };
117 
118 //
119 // The DtTrafficStats class stores statistics data related to
120 // network traffic
121 //
123 {
124 public:
125  // Uses Default Copy Ctor / Dtor / Assignment
126 
127  // Default Constructor ( just resets )
129 
130  // Reset all values to zero
131  void reset();
132 
133  // Resets FOM related maps
134  void resetFomStats();
135 
136  // Reset Object and Interaction Updated Stats Flags
137  void resetStatsUpdatedFlags();
138 
139  // Get a tab-separated header string for the stats data
140  static const DtString header();
141 
142  // Get a string containing current stats in tab-separated form
143  const DtString string() const;
144 
145  // Print stuff
146  const DtString toDtString() const;
147 
148  // Add a sent message to the tally
149  void msgSent( unsigned int fedId, DtRtiMsgKind msgKind,
150  unsigned int size, double sendTime );
151 
152  // Add a received message to the tally
153  void msgRcvd( unsigned int fedId, DtRtiMsgKind msgKind,
154  unsigned int size, double recvTime );
155 
156  // Add an RTI Amb. API call to the tally
157  void rtiAmbCalled( const DtRtiAmbAPIType callName, double callTime );
158 
159  // Add a Fed. Amb. API call to the tally
160  void fedAmbCalled( const DtFedAmbAPIType callName, double callTime );
161 
162  // Get a pointer to the current message object statistics
163  const DtMsgStats* getMsgStats( DtRtiMsgKind msgKind ) const;
164 
165  // Add a new object
166  void addObject( bool isRegistered, unsigned int objHandle,
167  const DtString& theClassName, const DtString& theObjectName, DtObjectClassHandle theClassHandle );
168 
169  // Add a new interaction
170  void addInteraction( bool isSent, unsigned int interHandle,
171  const DtString& theInterName );
172 
173 
174  // Record statistics about an update or interaction message
175  void recordUpdate( bool isSent, unsigned int msgSize, double time,
176  DtObjectInstanceHandle handle, const DtString& name,
177  DtObjectClassHandle classHandle, const DtString & objectClassName);
178  void recordInteraction( bool isSent, unsigned int msgSize, double time,
179  DtInteractionClassHandle handle, const DtString& name );
180 
181 
182 protected:
183 
184  // Update the statistics calculations
185  void updateMsgStats( bool isSentMsg, DtRtiMsgKind msgKind,
186  unsigned int size, double time );
187 
188  // Check that data is consistent
189  void checkInternalState() const;
190  bool containsObjectInstance(unsigned int objectInstanceHandle);
191  bool containsInteractionClass(unsigned int interactionClassHandle);
192 public:
193 
194  // Statistics Data
195 
196  // Message Counts
197  unsigned int myTotalMsgsReceived; // Count of all received msgs
198  unsigned int myNumAnonMsgs; // Count of all msgs from federate handle 0
199  unsigned int myNumSentMsgs; // Count of all msgs from local federate
200  unsigned int myNumFedMsgs; // Count of all msgs from other federates
201 
202  // Bandwidth Usage
203  unsigned int myTotalBytesReceived; // Total size of all msgs received (includes anon)
204  unsigned int myTotalBytesSent; // Total size of all msgs sent
205  double myAveMsgSize; // Running average size of all msgs
206  unsigned int myMaxMsgSize; // Largest msg sent/received so far
207  unsigned int myMinMsgSize; // Smallest msg sent/received so far
208 
209  // Performance Stats
210  MAKRti::DtClock myCollectionPeriod; // Total time over which stats have been gathered
211  MAKRti::DtTime myTotalSendTime; // Total Time spent in Send
212  MAKRti::DtTime myAveSendTime; // Average Time spent in Send
213  MAKRti::DtTime myMinSendTime; // Minimum Time spent in Send
214  MAKRti::DtTime myMaxSendTime; // Maximum Time spent in Send
215 
216  MAKRti::DtTime myTotalReadTime; // Total Time spent in Read
217  MAKRti::DtTime myAveReadTime; // Average Time spent in Read
218  MAKRti::DtTime myMinReadTime; // Minimum Time spent in Read
219  MAKRti::DtTime myMaxReadTime; // Maximum Time spent in Read
220 
221 
222  // API Stats
223  MAKRti::DtTime myTotalApiTime; // Total Time spent in RTI Amb. calls
224  MAKRti::DtTime myTotalCallbackTime; // Total Time spent in Fed. Amb. callbacks
225 
226  // Per Obj/Inter/Call Data
227  //DtMsgStats myMsgDataByKind[DtInvalidMsgKind]; // Per Message Data
228  std::map< DtRtiMsgKind, DtMsgStats > myMsgDataByKind; // Per Message Data
229  std::map< DtRtiAmbAPIType, DtRtiApiStats > myApiDataByCallName; // Per RTI Amb API Call Data
230  std::map< DtFedAmbAPIType, DtRtiApiStats > myFedDataByCallName; // Per Fed Amb API Call Data
231  std::map< unsigned int, DtObjIntStats > myObjectData; // Per Object stats
232  std::map< unsigned int, DtObjIntStats > myInteractionData; // Per Interaction stats
233  std::set< unsigned int > myObjectInstanceNamesToSend; // Object Instance Handles
234 
235  // FOM Stats
236 
237  // Map where key is object handle and value is the attribute handle
238  // This is populated when there is a transport, order, publish, or subscribe change
241  //std::map< unsigned int, unsigned int > myAttributeHandleByObjectHandleMap;
242 
243  // Map where key is interaction handle and value is the parameter handle
244  // This is populated when there is a transport, order, publish, or subscribe change
245  std::map< unsigned int, unsigned int > myParameterHandleByInteractionHandleMap;
246 
247 };
248 #endif // netStats_h__
249 

Document ID: Generated on Wed Mar 11 20:26:49 EDT 2015 from SVN revision 150939
Copyright © 2005-2015 VT MÄK Inc. All Rights Reserved (www.mak.com)