EMANE  1.2.1
slotstatustablepublisher.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2016,2018 - Adjacent Link LLC, Bridgewater,
3  * New Jersey
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in
14  * the documentation and/or other materials provided with the
15  * distribution.
16  * * Neither the name of Adjacent Link LLC nor the names of its
17  * contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef EMANEMODELSTDMASLOTSTATUSTABLEPUBLISHER_HEADER_
35 #define EMANEMODELSTDMASLOTSTATUSTABLEPUBLISHER_HEADER_
36 
38 #include <map>
39 #include <tuple>
40 
41 namespace EMANE
42 {
43  namespace Models
44  {
45  namespace TDMA
46  {
57  {
58  public:
59  enum class Status
60  {TX_GOOD,
61  TX_MISSED,
62  TX_TOOBIG,
63  RX_GOOD,
64  RX_MISSED,
65  RX_IDLE,
66  RX_TX,
67  RX_TOOLONG,
69  RX_LOCK};
70 
71  void registerStatistics(StatisticRegistrar & registrar);
72 
73  void update(std::uint32_t u32RelativeIndex,
74  std::uint32_t u32RelativeFrameIndex,
75  std::uint32_t u32RelativeSlotIndex,
76  Status status,
77  double dSlotRemainingRatio);
78 
79  void clear();
80 
81  private:
82  StatisticTable<std::uint32_t> * pTxSlotStatusTable_;
83  StatisticTable<std::uint32_t> * pRxSlotStatusTable_;
84 
85  using TxSlotCounterMap = std::map<std::uint32_t,
86  std::tuple<std::uint64_t, // valid
87  std::uint64_t, // missed
88  std::uint64_t, // too big for slot
89  std::array<std::uint64_t,8> // quantile
90  >>;
91 
92  using RxSlotCounterMap = std::map<std::uint32_t,
93  std::tuple<std::uint64_t, // valid
94  std::uint64_t, // missed
95  std::uint64_t, // rx during idle
96  std::uint64_t, // rx during tx
97  std::uint64_t, // rx too long for slot
98  std::uint64_t, // rx wrong freq for slot
99  std::uint64_t, // rx lock
100  std::array<std::uint64_t,8>>>;
101  TxSlotCounterMap txSlotCounterMap_;
102  RxSlotCounterMap rxSlotCounterMap_;
103 
104  void updateRx(std::uint32_t u32RelativeIndex,
105  std::uint32_t u32RelativeFrameIndex,
106  std::uint32_t u32RelativeSlotIndex,
107  Status status,
108  double dSlotPortionRatio);
109 
110  void updateTx(std::uint32_t u32RelativeIndex,
111  std::uint32_t u32RelativeFrameIndex,
112  std::uint32_t u32RelativeSlotIndex,
113  Status status,
114  double dSlotPortionRatio);
115 
116  };
117  }
118  }
119 }
120 
121 #endif // EMANEMODELSTDMASLOTSTATUSTABLEPUBLISHER_HEADER_
void registerStatistics(StatisticRegistrar &registrar)
The StatisticRegistrar allows NEM layers to register statistics and statistic tables. Statistics and Statistic tables are owned by the emulator framework and a borrowed reference is returned to the registering NEM layer.
void update(std::uint32_t u32RelativeIndex, std::uint32_t u32RelativeFrameIndex, std::uint32_t u32RelativeSlotIndex, Status status, double dSlotRemainingRatio)
Definition: agent.h:43
Slot statistic and statistic table status publisher.