CTR Pia  4.11.3
Game Communication Engine
transport_PacketAnalysisData.h
1 /*---------------------------------------------------------------------------*
2  Project: Pia
3  File: transport_PacketAnalysisData.h
4 
5  Copyright Nintendo. All rights reserved.
6 
7  These coded instructions, statements, and computer programs contain
8  proprietary information of Nintendo of America Inc. and/or Nintendo
9  Company Ltd., and are protected by Federal copyright law. They may
10  not be disclosed to third parties or copied or duplicated in any form,
11  in whole or in part, without the prior written consent of Nintendo.
12  *---------------------------------------------------------------------------*/
13 
14 
15 #pragma once
16 
17 #include <pia/transport/transport_definitions.h>
18 
19 #include <pia/transport/transport_ProtocolId.h>
20 
21 #include <pia/common/common_Time.h>
22 
23 
24 namespace nn
25 {
26 namespace pia
27 {
28 namespace transport
29 {
30 
31 
32 /*!
33 @brief Stores information required for tabulating the results of an analysis of the data in sent and received packets.
34 
35 @date 2013-12-10 Corrected an inaccurate description of <tt>passedMilliSec</tt>.
36 @date 2013-12-02 The increases in the number of sent packets, sent protocol messages, and sent data due to multicasting are now also included in the calculation.
37 @date 2013-11-21 The total packet size is now calculated using the size of packets in the network layer (for example, packets that include IPv4 or UDP headers).
38 @date 2013-11-14 Added a member variable that maintains the count from the point at which measurement starts.
39 @date 2013-10-17 Revised specifications.
40 @date 2013-10-15 Initial version.
41 */
43 {
44  static const size_t MAX_ENTRIES = 32; //!< Specifies the maximum entries.
45  static const size_t MAX_NAME_LEN = 32; //!< Specifies the longest name that can be assigned to this object.
46 
47 
48 /*!
49 @brief Contains information required for tabulating analysis results for each <tt>ProtocolId</tt>.
50 */
51  struct Entry
52  {
53  ProtocolId protocolId; //!< ProtocolId
54  size_t totalNum; //!< Specifies the number of protocol messages that correspond to <tt>ProtocolId</tt>.
55  size_t totalDataSize; //!< Specifies the total amount of data, in bytes, corresponding to <tt>ProtocolId</tt>.
56  size_t sumTotalNum; //!< Specifies the number of protocol messages that correspond to <tt>ProtocolId</tt>. This value is not cleared by the <tt>ClearCounters</tt> function.
57  u64 sumTotalDataSize; //!< Specifies the total amount of data, in bytes, corresponding to <tt>ProtocolId</tt>. This value is not cleared by the <tt>ClearCounters</tt> function.
58  };
59 
60  struct Entry entry[MAX_ENTRIES]; //!< Specifies an array of entries.
61  size_t nowEntryNum; //!< Specifies the current number of entries.
62  s32 passedMilliSec; //!< Specifies the elapsed time, in milliseconds, since the execution of the <tt>PiaTransport</tt> startup process.
63  char name[MAX_NAME_LEN]; //!< Specifies the name to attach to the instance. The string must be terminated with <tt>\0</tt>.
64  size_t totalPacketNum; //!< Specifies the number of packets analyzed.
65  size_t totalPacketSize; //!< Specifies the total size of the packets analyzed.
66 
67  size_t sumTotalPacketNum; //!< Specifies the number of packets counted since analysis started. This value is not cleared by the <tt>ClearCounters</tt> function.
68  u64 sumTotalPacketSize; //!< Specifies the total size of the packets counted since analysis started. This value is not cleared by the <tt>ClearCounters</tt> function.
69 
70 /*!
71 @brief Clears all members except <tt>name</tt>.
72 */
73  void ClearExceptName();
74 
75 
76 /*!
77 @brief Clears the <tt>totalNum</tt>, <tt>totalDataSize</tt>, <tt>passedMilliSec</tt>, <tt>totalPacketNum</tt>, and <tt>totalPacketSize</tt> members.
78 */
79  void ClearCounters();
80 
81 
82 /*!
83 @brief Prints the data.
84 
85 @param[in] bDetail Specify <tt>true</tt> to get verbose output.
86 */
87  void Print(bool bDetail) const;
88 
89 
90 /*!
91 @brief Prints information that is useful for debugging.
92 
93 @param[in] flag Specifies the bitwise OR of trace flags. For more information, see the <tt>@ref TraceFlag</tt> type.
94 */
95  void Trace(u64 flag) const;
96 
97 
98  static const size_t INVALID_IDX = 0xffffffff; // Represents an invalid subscript.
99  size_t GetIndex(ProtocolId id) const; // Returns the entry that matches <tt>id</tt> if one exists; otherwise returns <tt>INVALID_IDX</tt>.
100  size_t CreateIndex(ProtocolId id); // Returns <tt>INVALID_IDX</tt> if the entry is full and a new subscript cannot be allocated.
101 };
102 }
103 }
104 } // end of namespace nn::pia::transport
char name[MAX_NAME_LEN]
Specifies the name to attach to the instance. The string must be terminated with \0.
Definition: transport_PacketAnalysisData.h:63
size_t totalDataSize
Specifies the total amount of data, in bytes, corresponding to ProtocolId.
Definition: transport_PacketAnalysisData.h:55
Definition: assert.h:115
ProtocolId protocolId
ProtocolId.
Definition: transport_PacketAnalysisData.h:53
void ClearExceptName()
Clears all members except name.
void Trace(u64 flag) const
Prints information that is useful for debugging.
struct Entry entry[MAX_ENTRIES]
Specifies an array of entries.
Definition: transport_PacketAnalysisData.h:60
static const size_t MAX_ENTRIES
Specifies the maximum entries.
Definition: transport_PacketAnalysisData.h:44
Stores information required for tabulating the results of an analysis of the data in sent and receive...
Definition: transport_PacketAnalysisData.h:42
void Print(bool bDetail) const
Prints the data.
static const size_t MAX_NAME_LEN
Specifies the longest name that can be assigned to this object.
Definition: transport_PacketAnalysisData.h:45
size_t totalPacketSize
Specifies the total size of the packets analyzed.
Definition: transport_PacketAnalysisData.h:65
size_t totalPacketNum
Specifies the number of packets analyzed.
Definition: transport_PacketAnalysisData.h:64
Contains information required for tabulating analysis results for each ProtocolId.
Definition: transport_PacketAnalysisData.h:51
size_t sumTotalPacketNum
Specifies the number of packets counted since analysis started. This value is not cleared by the Clea...
Definition: transport_PacketAnalysisData.h:67
u64 sumTotalDataSize
Specifies the total amount of data, in bytes, corresponding to ProtocolId. This value is not cleared ...
Definition: transport_PacketAnalysisData.h:57
size_t sumTotalNum
Specifies the number of protocol messages that correspond to ProtocolId. This value is not cleared by...
Definition: transport_PacketAnalysisData.h:56
size_t nowEntryNum
Specifies the current number of entries.
Definition: transport_PacketAnalysisData.h:61
void ClearCounters()
Clears the totalNum, totalDataSize, passedMilliSec, totalPacketNum, and totalPacketSize members...
u64 sumTotalPacketSize
Specifies the total size of the packets counted since analysis started. This value is not cleared by ...
Definition: transport_PacketAnalysisData.h:68
size_t totalNum
Specifies the number of protocol messages that correspond to ProtocolId.
Definition: transport_PacketAnalysisData.h:54
s32 passedMilliSec
Specifies the elapsed time, in milliseconds, since the execution of the PiaTransport startup process...
Definition: transport_PacketAnalysisData.h:62