satellite-gw-helper.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013 Magister Solutions Ltd
4  * Copyright (c) 2018 CNES
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Author: Sami Rantanen <sami.rantanen@magister.fi>
20  * Author: Mathias Ettinger <mettinger@viveris.toulouse.fr>
21  */
22 
23 #include "satellite-gw-helper.h"
24 
25 #include <ns3/boolean.h>
26 #include <ns3/config.h>
27 #include <ns3/double.h>
28 #include <ns3/enum.h>
29 #include <ns3/log.h>
30 #include <ns3/pointer.h>
31 #include <ns3/satellite-channel-estimation-error-container.h>
32 #include <ns3/satellite-channel.h>
33 #include <ns3/satellite-enums.h>
34 #include <ns3/satellite-link-results.h>
35 #include <ns3/satellite-lower-layer-service.h>
36 #include <ns3/satellite-net-device.h>
37 #include <ns3/satellite-orbiter-net-device.h>
38 #include <ns3/satellite-typedefs.h>
39 
40 #include <string>
41 
42 NS_LOG_COMPONENT_DEFINE("SatGwHelper");
43 
44 namespace ns3
45 {
46 
47 NS_OBJECT_ENSURE_REGISTERED(SatGwHelper);
48 
49 TypeId
51 {
52  static TypeId tid =
53  TypeId("ns3::SatGwHelper")
54  .SetParent<Object>()
55  .AddAttribute("DaRtnLinkInterferenceModel",
56  "Return link interference model for dedicated access",
58  MakeEnumAccessor<SatPhyRxCarrierConf::InterferenceModel>(
60  MakeEnumChecker(SatPhyRxCarrierConf::IF_CONSTANT,
61  "Constant",
63  "Trace",
65  "PerPacket",
67  "PerFragment"))
68  .AddAttribute(
69  "RtnLinkErrorModel",
70  "Return link error model for",
71  EnumValue(SatPhyRxCarrierConf::EM_AVI),
72  MakeEnumAccessor<SatPhyRxCarrierConf::ErrorModel>(&SatGwHelper::m_errorModel),
73  MakeEnumChecker(SatPhyRxCarrierConf::EM_NONE,
74  "None",
76  "Constant",
78  "AVI"))
79  .AddAttribute("FwdSchedulingAlgorithm",
80  "The scheduling algorithm used to fill the BBFrames",
81  EnumValue(SatEnums::NO_TIME_SLICING),
82  MakeEnumAccessor<SatEnums::FwdSchedulingAlgorithm_t>(
84  MakeEnumChecker(SatEnums::NO_TIME_SLICING,
85  "NoTimeSlicing",
87  "TimeSlicing"))
88  .AddAttribute("RtnLinkConstantErrorRate",
89  "Constant error rate",
90  DoubleValue(0.01),
91  MakeDoubleAccessor(&SatGwHelper::m_daConstantErrorRate),
92  MakeDoubleChecker<double>())
93  .AddAttribute("EnableChannelEstimationError",
94  "Enable channel estimation error in return link receiver at GW.",
95  BooleanValue(true),
96  MakeBooleanAccessor(&SatGwHelper::m_enableChannelEstimationError),
97  MakeBooleanChecker())
98  .AddTraceSource("Creation",
99  "Creation traces",
100  MakeTraceSourceAccessor(&SatGwHelper::m_creationTrace),
101  "ns3::SatTypedefs::CreationCallback");
102  return tid;
103 }
104 
105 TypeId
107 {
108  return GetTypeId();
109 }
110 
112  : m_rtnLinkCarrierCount(0),
113  m_daInterferenceModel(SatPhyRxCarrierConf::IF_CONSTANT),
114  m_errorModel(SatPhyRxCarrierConf::EM_AVI),
115  m_daConstantErrorRate(0.0),
116  m_symbolRate(0.0),
117  m_enableChannelEstimationError(false),
118  m_raSettings()
119 {
120  // this default constructor should be never called
121  NS_FATAL_ERROR("Default constructor not supported!!!");
122 }
123 
125  uint32_t rtnLinkCarrierCount,
126  Ptr<SatSuperframeSeq> seq,
130  RandomAccessSettings_s randomAccessSettings)
131  : m_carrierBandwidthConverter(carrierBandwidthConverter),
132  m_rtnLinkCarrierCount(rtnLinkCarrierCount),
133  m_superframeSeq(seq),
134  m_readCtrlCb(readCb),
135  m_reserveCtrlCb(reserveCb),
136  m_sendCtrlCb(sendCb),
137  m_daInterferenceModel(SatPhyRxCarrierConf::IF_CONSTANT),
138  m_errorModel(SatPhyRxCarrierConf::EM_AVI),
139  m_daConstantErrorRate(0.0),
140  m_symbolRate(0.0),
141  m_enableChannelEstimationError(false),
142  m_raSettings(randomAccessSettings)
143 {
144  NS_LOG_FUNCTION(this << rtnLinkCarrierCount << seq);
145 
146  m_deviceFactory.SetTypeId("ns3::SatNetDevice");
147  m_channelFactory.SetTypeId("ns3::SatChannel");
148 }
149 
150 void
151 SatGwHelper::Initialize(Ptr<SatLinkResultsRtn> lrRcs2,
152  Ptr<SatLinkResultsFwd> lrFwd,
153  SatEnums::DvbVersion_t dvbVersion,
154  bool useScpc)
155 {
156  NS_LOG_FUNCTION(this);
157 
158  switch (m_fwdSchedulingAlgorithm)
159  {
161  Config::SetDefault("ns3::SatBbFrameConf::PlHeaderInSlots", UintegerValue(1));
162  break;
164  Config::SetDefault("ns3::SatBbFrameConf::PlHeaderInSlots", UintegerValue(2));
165  break;
166  default:
167  NS_FATAL_ERROR("Forward scheduling algorithm is not implemented");
168  }
169 
170  // TODO: Usage of multiple carriers needed to take into account, now only one carrier assumed to
171  // be used.
172  // TODO: Symbol rate needed to check.
173  m_symbolRate =
175 
176  /*
177  * Return channel link results (DVB-RCS2) are created for GWs.
178  */
179  if (lrRcs2 && m_errorModel == SatPhyRxCarrierConf::EM_AVI)
180  {
181  m_linkResults = lrRcs2;
182  }
183  if (useScpc)
184  {
185  m_linkResults = lrFwd;
186  }
187 
188  m_bbFrameConf = CreateObject<SatBbFrameConf>(m_symbolRate, dvbVersion);
189  m_bbFrameConf->InitializeCNoRequirements(lrFwd);
190 
191  // m_bbFrameConf->DumpWaveforms ();
192 }
193 
194 Ptr<SatBbFrameConf>
196 {
197  NS_LOG_FUNCTION(this);
198 
199  return m_bbFrameConf;
200 }
201 
202 void
203 SatGwHelper::SetDeviceAttribute(std::string n1, const AttributeValue& v1)
204 {
205  NS_LOG_FUNCTION(this << n1);
206 
207  m_deviceFactory.Set(n1, v1);
208 }
209 
210 void
211 SatGwHelper::SetChannelAttribute(std::string n1, const AttributeValue& v1)
212 {
213  NS_LOG_FUNCTION(this << n1);
214 
215  m_channelFactory.Set(n1, v1);
216 }
217 
218 void
219 SatGwHelper::SetPhyAttribute(std::string n1, const AttributeValue& v1)
220 {
221  NS_LOG_FUNCTION(this << n1);
222 
223  Config::SetDefault("ns3::SatGwPhy::" + n1, v1);
224 }
225 
226 NetDeviceContainer
227 SatGwHelper::Install(NodeContainer c,
228  uint32_t gwId,
229  uint32_t satId,
230  uint32_t beamId,
231  uint32_t feederSatId,
232  uint32_t feederBeamId,
233  Ptr<SatChannel> fCh,
234  Ptr<SatChannel> rCh,
236  Ptr<SatNcc> ncc,
237  Ptr<SatLowerLayerServiceConf> llsConf)
238 {
239  NS_LOG_FUNCTION(this << gwId << satId << beamId << fCh << rCh << ncc << llsConf);
240 
241  NetDeviceContainer devs;
242 
243  for (NodeContainer::Iterator i = c.Begin(); i != c.End(); i++)
244  {
245  devs.Add(Install(*i,
246  gwId,
247  satId,
248  beamId,
249  feederSatId,
250  feederBeamId,
251  fCh,
252  rCh,
253  cbChannel,
254  ncc,
255  llsConf));
256  }
257 
258  return devs;
259 }
260 
261 void
262 SatGwHelper::EnableCreationTraces(Ptr<OutputStreamWrapper> stream, CallbackBase& cb)
263 {
264  NS_LOG_FUNCTION(this);
265 
266  TraceConnect("Creation", "SatGwHelper", cb);
267 }
268 
269 } // namespace ns3
DvbVersion_t
The scheduling algorithm used to fill the BBFrames.
SatPhy::ErrorModel m_errorModel
ObjectFactory m_channelFactory
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
void Initialize(Ptr< SatLinkResultsRtn > lrRcs2, Ptr< SatLinkResultsFwd > lrFwd, SatEnums::DvbVersion_t dvbVersion, bool useScpc)
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
void SetPhyAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Phy created by the helper.
static TypeId GetTypeId(void)
Get the type ID.
TracedCallback< std::string > m_creationTrace
Trace callback for creation traces.
void EnableCreationTraces(Ptr< OutputStreamWrapper > stream, CallbackBase &cb)
Enables creation traces to be written in given file.
SatEnums::FwdSchedulingAlgorithm_t m_fwdSchedulingAlgorithm
The forward link algorithm used.
bool m_enableChannelEstimationError
Enable channel estimation error modeling at forward link receiver (= UT).
Ptr< SatBbFrameConf > GetBbFrameConf() const
Get BB frame configuration.
ObjectFactory m_deviceFactory
Ptr< SatBbFrameConf > m_bbFrameConf
Ptr< SatLinkResults > m_linkResults
TypeId GetInstanceTypeId(void) const
SatGwHelper()
Default constructor.
SatPhy::InterferenceModel m_daInterferenceModel
SatTypedefs::CarrierBandwidthConverter_t m_carrierBandwidthConverter
NetDeviceContainer Install(NodeContainer c, uint32_t gwId, uint32_t satId, uint32_t beamId, uint32_t feederSatId, uint32_t feederBeamId, Ptr< SatChannel > fCh, Ptr< SatChannel > rCh, SatPhy::ChannelPairGetterCallback cbChannel, Ptr< SatNcc > ncc, Ptr< SatLowerLayerServiceConf > llsConf)
Callback< uint32_t, Ptr< SatControlMessage > > ReserveCtrlMsgCallback
Callback to reserve an id and initially store the control message.
Callback< uint32_t, uint32_t > SendCtrlMsgCallback
Callback to send a control message and allocate a recv ID for it.
Callback< Ptr< SatControlMessage >, uint32_t > ReadCtrlMsgCallback
Callback to read control messages from container storing control messages.
Callback< SatChannelPair::ChannelPair_t, uint32_t, uint32_t > ChannelPairGetterCallback
Callback for retrieving a pair of SatChannel associated to a beam.
Information of beam users liken UTs and their users.
Callback< double, SatEnums::ChannelType_t, uint32_t, SatEnums::CarrierBandwidthType_t > CarrierBandwidthConverter_t
Callback for carrier bandwidths.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.