Loading...
Searching...
No Matches
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
26
27#include "ns3/collector-map.h"
28#include "ns3/ptr.h"
29
30#include <list>
31#include <map>
32#include <sstream>
33#include <string>
34
35namespace ns3
36{
37
38// BASE CLASS /////////////////////////////////////////////////////////////////
39
40class SatHelper;
41class DataCollectionObject;
42class ScalarCollector;
43
49{
50 public:
55 typedef enum
56 {
61 } UnitType_t;
62
67 static std::string GetUnitTypeName(UnitType_t unitType);
68
69 // inherited from SatStatsHelper base class
70 SatStatsFrameLoadHelper(Ptr<const SatHelper> satHelper);
71
76
80 static TypeId GetTypeId();
81
85 void SetUnitType(UnitType_t unitType);
86
90 UnitType_t GetUnitType() const;
91
92 protected:
93 // inherited from SatStatsHelper base class
94 void DoInstall();
95 std::string GetIdentifierHeading(std::string dataLabel) const;
96
97 private:
104 template <typename P, typename V>
105 bool SetupProbe(Ptr<Object> object,
106 uint32_t identifier,
107 void (SatStatsFrameLoadHelper::*traceSink)(std::string, uint32_t, V));
108
114 void FrameSymbolLoadCallback(std::string context, uint32_t frameId, double loadRatio);
115
121 void FrameUserLoadCallback(std::string context, uint32_t frameId, uint32_t utCount);
122
128 Ptr<ScalarCollector> GetCollector(uint32_t frameId, std::string identifier);
129
131 std::string m_shortLabel;
132 std::string m_longLabel;
135
137 std::list<Ptr<Probe>> m_probes;
138
143 std::map<uint32_t, CollectorMap> m_collectors;
144
146 Ptr<DataCollectionObject> m_aggregator;
147
148}; // end of class SatStatsFrameLoadHelper
149
150template <typename P, typename V>
151bool
153 uint32_t identifier,
154 void (SatStatsFrameLoadHelper::*traceSink)(std::string,
155 uint32_t,
156 V))
157{
158 std::ostringstream oss;
159 oss << identifier;
160
161 Ptr<P> probe = CreateObject<P>();
162 if (!probe->GetInstanceTypeId().IsChildOf(TypeId::LookupByName("ns3::Probe")))
163 {
164 NS_FATAL_ERROR("The specified type is not a probe.");
165 }
166
167 // Connect the object to the probe and then to the callback.
168 if (probe->ConnectByObject(m_objectTraceSourceName, object) &&
169 probe->TraceConnect(m_probeTraceSourceName, oss.str(), MakeCallback(traceSink, this)))
170 {
171 m_probes.push_back(probe->template GetObject<Probe>());
172 return true;
173 }
174 else
175 {
176 return false;
177 }
178}
179
180// IN SYMBOL UNIT /////////////////////////////////////////////////////////////
181
187{
188 public:
189 // inherited from SatStatsHelper base class
190 SatStatsFrameSymbolLoadHelper(Ptr<const SatHelper> satHelper);
191
196
200 static TypeId GetTypeId();
201
202}; // end of class SatStatsFrameSymbolLoadHelper
203
204// IN USER UNIT ///////////////////////////////////////////////////////////////
205
211{
212 public:
213 // inherited from SatStatsHelper base class
214 SatStatsFrameUserLoadHelper(Ptr<const SatHelper> satHelper);
215
220
224 static TypeId GetTypeId();
225
226}; // end of class SatStatsFrameUserLoadHelper
227
228} // end of namespace ns3
229
230#endif /* SATELLITE_STATS_FRAME_LOAD_HELPER_H */
Build a satellite network set with needed objects and configuration.
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)
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsFrameSymbolLoadHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsFrameUserLoadHelper(Ptr< const SatHelper > satHelper)
SatStatsHelper(Ptr< const SatHelper > satHelper)
Creates a new helper instance.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.