satellite-stats-frame-load-helper.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014 Magister Solutions
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Budiarto Herman <budiarto.herman@magister.fi>
19  *
20  */
21 
22 #ifndef SATELLITE_STATS_FRAME_LOAD_HELPER_H
23 #define SATELLITE_STATS_FRAME_LOAD_HELPER_H
24 
25 #include <ns3/collector-map.h>
26 #include <ns3/ptr.h>
27 #include <ns3/satellite-stats-helper.h>
28 
29 #include <list>
30 #include <map>
31 #include <sstream>
32 
33 namespace ns3
34 {
35 
36 // BASE CLASS /////////////////////////////////////////////////////////////////
37 
38 class SatHelper;
39 class DataCollectionObject;
40 class ScalarCollector;
41 
47 {
48  public:
53  typedef enum
54  {
59  } UnitType_t;
60 
65  static std::string GetUnitTypeName(UnitType_t unitType);
66 
67  // inherited from SatStatsHelper base class
68  SatStatsFrameLoadHelper(Ptr<const SatHelper> satHelper);
69 
73  virtual ~SatStatsFrameLoadHelper();
74 
78  static TypeId GetTypeId();
79 
83  void SetUnitType(UnitType_t unitType);
84 
88  UnitType_t GetUnitType() const;
89 
90  protected:
91  // inherited from SatStatsHelper base class
92  void DoInstall();
93  std::string GetIdentifierHeading(std::string dataLabel) const;
94 
95  private:
102  template <typename P, typename V>
103  bool SetupProbe(Ptr<Object> object,
104  uint32_t identifier,
105  void (SatStatsFrameLoadHelper::*traceSink)(std::string, uint32_t, V));
106 
112  void FrameSymbolLoadCallback(std::string context, uint32_t frameId, double loadRatio);
113 
119  void FrameUserLoadCallback(std::string context, uint32_t frameId, uint32_t utCount);
120 
126  Ptr<ScalarCollector> GetCollector(uint32_t frameId, std::string identifier);
127 
129  std::string m_shortLabel;
130  std::string m_longLabel;
133 
135  std::list<Ptr<Probe>> m_probes;
136 
141  std::map<uint32_t, CollectorMap> m_collectors;
142 
144  Ptr<DataCollectionObject> m_aggregator;
145 
146 }; // end of class SatStatsFrameLoadHelper
147 
148 template <typename P, typename V>
149 bool
151  uint32_t identifier,
152  void (SatStatsFrameLoadHelper::*traceSink)(std::string,
153  uint32_t,
154  V))
155 {
156  std::ostringstream oss;
157  oss << identifier;
158 
159  Ptr<P> probe = CreateObject<P>();
160  if (!probe->GetInstanceTypeId().IsChildOf(TypeId::LookupByName("ns3::Probe")))
161  {
162  NS_FATAL_ERROR("The specified type is not a probe.");
163  }
164 
165  // Connect the object to the probe and then to the callback.
166  if (probe->ConnectByObject(m_objectTraceSourceName, object) &&
167  probe->TraceConnect(m_probeTraceSourceName, oss.str(), MakeCallback(traceSink, this)))
168  {
169  m_probes.push_back(probe->template GetObject<Probe>());
170  return true;
171  }
172  else
173  {
174  return false;
175  }
176 }
177 
178 // IN SYMBOL UNIT /////////////////////////////////////////////////////////////
179 
185 {
186  public:
187  // inherited from SatStatsHelper base class
188  SatStatsFrameSymbolLoadHelper(Ptr<const SatHelper> satHelper);
189 
194 
198  static TypeId GetTypeId();
199 
200 }; // end of class SatStatsFrameSymbolLoadHelper
201 
202 // IN USER UNIT ///////////////////////////////////////////////////////////////
203 
209 {
210  public:
211  // inherited from SatStatsHelper base class
212  SatStatsFrameUserLoadHelper(Ptr<const SatHelper> satHelper);
213 
218 
222  static TypeId GetTypeId();
223 
224 }; // end of class SatStatsFrameUserLoadHelper
225 
226 } // end of namespace ns3
227 
228 #endif /* SATELLITE_STATS_FRAME_LOAD_HELPER_H */
Helper for frame load statistics.
static TypeId GetTypeId()
inherited from ObjectBase base class
std::map< uint32_t, CollectorMap > m_collectors
Two-dimensional map of collectors, indexed by the frame ID and then by the identifier.
Ptr< ScalarCollector > GetCollector(uint32_t frameId, std::string identifier)
static std::string GetUnitTypeName(UnitType_t unitType)
std::list< Ptr< Probe > > m_probes
Maintains a list of probes created by this helper.
void FrameSymbolLoadCallback(std::string context, uint32_t frameId, double loadRatio)
bool SetupProbe(Ptr< Object > object, uint32_t identifier, void(SatStatsFrameLoadHelper::*traceSink)(std::string, uint32_t, V))
std::string GetIdentifierHeading(std::string dataLabel) const
void DoInstall()
Install the probes, collectors, and aggregators necessary to produce the statistics output.
void FrameUserLoadCallback(std::string context, uint32_t frameId, uint32_t utCount)
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
@ UNIT_USERS
Number of scheduled users (i.e., UT).
@ UNIT_SYMBOLS
Number of allocated symbols over total number of symbols in the frame.
SatStatsFrameLoadHelper(Ptr< const SatHelper > satHelper)
Helper for frame symbol load statistics.
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsFrameSymbolLoadHelper(Ptr< const SatHelper > satHelper)
Helper for frame user load statistics.
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsFrameUserLoadHelper(Ptr< const SatHelper > satHelper)
Parent abstract class of all satellite statistics helpers.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.