Loading...
Searching...
No Matches
satellite-stats-capacity-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/node-container.h"
29#include "ns3/satellite-helper.h"
30#include "ns3/satellite-net-device.h"
31#include "ns3/satellite-request-manager.h"
32#include "ns3/satellite-topology.h"
33#include "ns3/satellite-ut-llc.h"
34#include "ns3/singleton.h"
35#include "ns3/string.h"
36
37#include <sstream>
38#include <string>
39
40NS_LOG_COMPONENT_DEFINE("SatStatsCapacityRequestHelper");
41
42namespace ns3
43{
44
45NS_OBJECT_ENSURE_REGISTERED(SatStatsCapacityRequestHelper);
46
48 : SatStatsHelper(satHelper)
49{
50 NS_LOG_FUNCTION(this << satHelper);
51}
52
57
58TypeId // static
60{
61 static TypeId tid = TypeId("ns3::SatStatsCapacityRequestHelper").SetParent<SatStatsHelper>();
62 return tid;
63}
64
65void
67{
68 NS_LOG_FUNCTION(this);
69
71 {
72 NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
73 << " is not a valid output type for this statistics.");
74 }
75
77 {
79 << " is not a valid identifier type for this statistics.");
80 }
81
82 // Setup aggregator.
84 "ns3::MultiFileAggregator",
85 "OutputFileName",
86 StringValue(GetOutputFileName()),
87 "GeneralHeading",
88 StringValue("% time_sec, node_id, rc_id, type, kbps / bytes, queue_bytes"));
89 Ptr<MultiFileAggregator> multiFileAggregator = m_aggregator->GetObject<MultiFileAggregator>();
90 NS_ASSERT(multiFileAggregator != nullptr);
91 Callback<void, std::string, std::string> aggregatorSink =
92 MakeCallback(&MultiFileAggregator::WriteString, multiFileAggregator);
93
94 // Setup probes.
95 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
96 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
97 {
98 std::ostringstream context;
99 switch (GetIdentifierType())
100 {
102 context << "0";
103 break;
105 context << GetIdentifierForUt(*it);
106 break;
108 context << GetIdentifierForUt(*it);
109 break;
111 context << GetIdentifierForUt(*it);
112 break;
114 context << GetIdentifierForUt(*it);
115 break;
116 default:
117 NS_FATAL_ERROR("SatStatsCapacityRequestHelper - Invalid identifier type");
118 break;
119 }
120
121 Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
122 Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
123 NS_ASSERT(satDev != nullptr);
124 Ptr<SatLlc> satLlc = satDev->GetLlc();
125 NS_ASSERT(satLlc != nullptr);
126 Ptr<SatUtLlc> utLlc = satLlc->GetObject<SatUtLlc>();
127 NS_ASSERT(utLlc != nullptr);
128 Ptr<SatRequestManager> requestManager = utLlc->GetRequestManager();
129
130 const bool ret = requestManager->TraceConnect("CrTraceLog", context.str(), aggregatorSink);
131 NS_ASSERT_MSG(ret, "Error connecting to CrTraceLog of node " << (*it)->GetId());
132 NS_LOG_INFO(this << " successfully connected" << " with node ID " << (*it)->GetId());
133
134 } // end of `for (NodeContainer::Iterator it = uts.Begin () -> uts.End ())`
135
136} // end of `void DoInstall ();`
137
138} // end of namespace ns3
SatNetDevice to be utilized in the UT and GW nodes.
Produce capacity request statistics of Random Access Slotted ALOHA from a satellite module simulation...
SatStatsCapacityRequestHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
void DoInstall()
Install the probes, collectors, and aggregators necessary to produce the statistics output.
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
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.
static Ptr< NetDevice > GetUtSatNetDevice(Ptr< Node > utNode)
OutputType_t GetOutputType() const
uint32_t GetIdentifierForUt(Ptr< Node > utNode) const
SatUtLlc holds the UT implementation of LLC layer.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.