Loading...
Searching...
No Matches
satellite-stats-backlogged-request-helper.cc
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
23
24#include "ns3/data-collection-object.h"
25#include "ns3/fatal-error.h"
26#include "ns3/log.h"
27#include "ns3/multi-file-aggregator.h"
28#include "ns3/satellite-beam-helper.h"
29#include "ns3/satellite-beam-scheduler.h"
30#include "ns3/satellite-helper.h"
31#include "ns3/satellite-ncc.h"
32#include "ns3/string.h"
33
34#include <list>
35#include <sstream>
36#include <string>
37#include <utility>
38
39NS_LOG_COMPONENT_DEFINE("SatStatsBackloggedRequestHelper");
40
41namespace ns3
42{
43
44NS_OBJECT_ENSURE_REGISTERED(SatStatsBackloggedRequestHelper);
45
47 : SatStatsHelper(satHelper)
48{
49 NS_LOG_FUNCTION(this << satHelper);
50}
51
56
57TypeId // static
59{
60 static TypeId tid = TypeId("ns3::SatStatsBackloggedRequestHelper").SetParent<SatStatsHelper>();
61 return tid;
62}
63
64void
66{
67 NS_LOG_FUNCTION(this);
68
70 {
71 NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
72 << " is not a valid output type for this statistics.");
73 }
74
77 {
79 << " is not a valid identifier type for this statistics.");
80 }
81
82 // Setup aggregator.
83 m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
84 "OutputFileName",
85 StringValue(GetOutputFileName()),
86 "GeneralHeading",
87 StringValue("% time_sec, beam_id, ut_id, type, requests"));
88 Ptr<MultiFileAggregator> multiFileAggregator = m_aggregator->GetObject<MultiFileAggregator>();
89 NS_ASSERT(multiFileAggregator != nullptr);
90 Callback<void, std::string, std::string> aggregatorSink =
91 MakeCallback(&MultiFileAggregator::WriteString, multiFileAggregator);
92
93 // Setup probes.
94 Ptr<SatBeamHelper> beamHelper = GetSatHelper()->GetBeamHelper();
95 NS_ASSERT(beamHelper != nullptr);
96 Ptr<SatNcc> ncc = beamHelper->GetNcc();
97 NS_ASSERT(ncc != nullptr);
98 std::list<std::pair<uint32_t, uint32_t>> beams = beamHelper->GetBeams();
99
100 for (std::list<std::pair<uint32_t, uint32_t>>::const_iterator it = beams.begin();
101 it != beams.end();
102 ++it)
103 {
104 std::ostringstream context;
105 switch (GetIdentifierType())
106 {
108 context << "0";
109 break;
111 context << GetIdentifierForBeam(it->first, it->second);
112 break;
114 context << GetIdentifierForBeam(it->first, it->second);
115 break;
116 default:
117 NS_FATAL_ERROR("SatStatsBackloggedRequestHelper - Invalid identifier type");
118 break;
119 }
120
121 Ptr<SatBeamScheduler> s = ncc->GetBeamScheduler(it->first, it->second);
122 NS_ASSERT_MSG(s != nullptr, "Error finding beam " << it->second);
123 const bool ret = s->TraceConnect("BacklogRequestsTrace", context.str(), aggregatorSink);
124 NS_ASSERT_MSG(ret, "Error connecting to BacklogRequestsTrace of beam " << it->second);
125 NS_LOG_INFO(this << " successfully connected" << " with beam " << it->second);
126 }
127
128} // end of `void DoInstall ();`
129
130} // end of namespace ns3
static TypeId GetTypeId()
inherited from ObjectBase base class
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
void DoInstall()
Install the probes, collectors, and aggregators necessary to produce the statistics output.
uint32_t GetIdentifierForBeam(uint32_t satId, uint32_t beamId) const
Ptr< const SatHelper > GetSatHelper() const
IdentifierType_t GetIdentifierType() const
static std::string GetOutputTypeName(OutputType_t outputType)
SatStatsHelper(Ptr< const SatHelper > satHelper)
Creates a new helper instance.
static std::string GetIdentifierTypeName(IdentifierType_t identifierType)
Ptr< DataCollectionObject > CreateAggregator(std::string aggregatorTypeId, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue())
Create the aggregator according to the output type.
virtual std::string GetOutputFileName() const
Compute the path and file name where statistics output should be written to.
OutputType_t GetOutputType() const
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.