satellite-ut-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-ut-helper.h"
24 
25 #include <ns3/boolean.h>
26 #include <ns3/callback.h>
27 #include <ns3/config.h>
28 #include <ns3/double.h>
29 #include <ns3/enum.h>
30 #include <ns3/log.h>
31 #include <ns3/pointer.h>
32 #include <ns3/satellite-channel-estimation-error-container.h>
33 #include <ns3/satellite-channel.h>
34 #include <ns3/satellite-enums.h>
35 #include <ns3/satellite-net-device.h>
36 #include <ns3/satellite-phy-rx-carrier-conf.h>
37 #include <ns3/satellite-typedefs.h>
38 
39 #include <string>
40 
41 NS_LOG_COMPONENT_DEFINE("SatUtHelper");
42 
43 namespace ns3
44 {
45 
46 NS_OBJECT_ENSURE_REGISTERED(SatUtHelper);
47 
48 TypeId
50 {
51  static TypeId tid =
52  TypeId("ns3::SatUtHelper")
53  .SetParent<Object>()
54  .AddAttribute("DaFwdLinkInterferenceModel",
55  "Forward link interference model for dedicated access",
57  MakeEnumAccessor<SatPhyRxCarrierConf::InterferenceModel>(
59  MakeEnumChecker(SatPhyRxCarrierConf::IF_CONSTANT,
60  "Constant",
62  "Trace",
64  "PerPacket",
66  "PerFragment"))
67  .AddAttribute(
68  "FwdLinkErrorModel",
69  "Forward link error model",
70  EnumValue(SatPhyRxCarrierConf::EM_AVI),
71  MakeEnumAccessor<SatPhyRxCarrierConf::ErrorModel>(&SatUtHelper::m_errorModel),
72  MakeEnumChecker(SatPhyRxCarrierConf::EM_NONE,
73  "None",
75  "Constant",
77  "AVI"))
78  .AddAttribute("FwdLinkConstantErrorRate",
79  "Constant error rate",
80  DoubleValue(0.01),
81  MakeDoubleAccessor(&SatUtHelper::m_daConstantErrorRate),
82  MakeDoubleChecker<double>())
83  .AddAttribute("LowerLayerServiceConf",
84  "Pointer to lower layer service configuration.",
85  PointerValue(),
86  MakePointerAccessor(&SatUtHelper::m_llsConf),
87  MakePointerChecker<SatLowerLayerServiceConf>())
88  .AddAttribute("EnableChannelEstimationError",
89  "Enable channel estimation error in forward link receiver at UT.",
90  BooleanValue(true),
91  MakeBooleanAccessor(&SatUtHelper::m_enableChannelEstimationError),
92  MakeBooleanChecker())
93  .AddAttribute("UseCrdsaOnlyForControlPackets",
94  "CRDSA utilized only for control packets or also for user data.",
95  BooleanValue(false),
96  MakeBooleanAccessor(&SatUtHelper::m_crdsaOnlyForControl),
97  MakeBooleanChecker())
98  .AddAttribute("AsynchronousReturnAccess",
99  "Use asynchronous access methods on the return channel.",
100  BooleanValue(false),
101  MakeBooleanAccessor(&SatUtHelper::m_asyncAccess),
102  MakeBooleanChecker())
103  .AddTraceSource("Creation",
104  "Creation traces",
105  MakeTraceSourceAccessor(&SatUtHelper::m_creationTrace),
106  "ns3::SatTypedefs::CreationCallback");
107  return tid;
108 }
109 
110 TypeId
112 {
113  NS_LOG_FUNCTION(this);
114 
115  return GetTypeId();
116 }
117 
119  : m_carrierBandwidthConverter(),
120  m_fwdLinkCarrierCount(),
121  m_superframeSeq(),
122  m_daInterferenceModel(SatPhyRxCarrierConf::IF_CONSTANT),
123  m_errorModel(SatPhyRxCarrierConf::EM_AVI),
124  m_daConstantErrorRate(0.0),
125  m_linkResults(),
126  m_llsConf(),
127  m_enableChannelEstimationError(false),
128  m_crdsaOnlyForControl(false),
129  m_asyncAccess(false),
130  m_raSettings()
131 {
132  NS_LOG_FUNCTION(this);
133 
134  // this default constructor should be never called
135  NS_FATAL_ERROR("SatUtHelper::SatUtHelper - Constructor not in use");
136 }
137 
139  uint32_t fwdLinkCarrierCount,
140  Ptr<SatSuperframeSeq> seq,
144  RandomAccessSettings_s randomAccessSettings)
145  : m_carrierBandwidthConverter(carrierBandwidthConverter),
146  m_fwdLinkCarrierCount(fwdLinkCarrierCount),
147  m_superframeSeq(seq),
148  m_readCtrlCb(readCb),
149  m_reserveCtrlCb(reserveCb),
150  m_sendCtrlCb(sendCb),
151  m_daInterferenceModel(SatPhyRxCarrierConf::IF_CONSTANT),
152  m_errorModel(SatPhyRxCarrierConf::EM_AVI),
153  m_daConstantErrorRate(0.0),
154  m_linkResults(),
155  m_llsConf(),
156  m_enableChannelEstimationError(false),
157  m_crdsaOnlyForControl(false),
158  m_raSettings(randomAccessSettings)
159 {
160  NS_LOG_FUNCTION(this << fwdLinkCarrierCount << seq);
161  m_deviceFactory.SetTypeId("ns3::SatNetDevice");
162  m_channelFactory.SetTypeId("ns3::SatChannel");
163 
164  m_llsConf = CreateObject<SatLowerLayerServiceConf>();
165 }
166 
167 void
168 SatUtHelper::Initialize(Ptr<SatLinkResultsFwd> lrFwd)
169 {
170  NS_LOG_FUNCTION(this);
171  /*
172  * Forward channel link results (DVB-S2 or DVB-S2X) are created for UTs.
173  */
175  {
176  m_linkResults = lrFwd;
177  }
178 }
179 
180 void
181 SatUtHelper::SetDeviceAttribute(std::string n1, const AttributeValue& v1)
182 {
183  NS_LOG_FUNCTION(this << n1);
184 
185  m_deviceFactory.Set(n1, v1);
186 }
187 
188 void
189 SatUtHelper::SetChannelAttribute(std::string n1, const AttributeValue& v1)
190 {
191  NS_LOG_FUNCTION(this << n1);
192 
193  m_channelFactory.Set(n1, v1);
194 }
195 
196 void
197 SatUtHelper::SetPhyAttribute(std::string n1, const AttributeValue& v1)
198 {
199  NS_LOG_FUNCTION(this << n1);
200 
201  Config::SetDefault("ns3::SatUtPhy::" + n1, v1);
202 }
203 
204 NetDeviceContainer
205 SatUtHelper::Install(NodeContainer c,
206  uint32_t satId,
207  uint32_t beamId,
208  Ptr<SatChannel> fCh,
209  Ptr<SatChannel> rCh,
210  Ptr<SatNetDevice> gwNd,
211  Ptr<SatNcc> ncc,
212  Address satUserAddress,
215 {
216  NS_LOG_FUNCTION(this << satId << beamId << fCh << rCh << gwNd << ncc << satUserAddress);
217 
218  NetDeviceContainer devs;
219 
220  for (NodeContainer::Iterator i = c.Begin(); i != c.End(); i++)
221  {
222  devs.Add(
223  Install(*i, satId, beamId, fCh, rCh, gwNd, ncc, satUserAddress, cbChannel, cbRouting));
224  }
225 
226  return devs;
227 }
228 
229 void
230 SatUtHelper::EnableCreationTraces(Ptr<OutputStreamWrapper> stream, CallbackBase& cb)
231 {
232  NS_LOG_FUNCTION(this);
233 
234  TraceConnect("Creation", "SatUtHelper", cb);
235 }
236 
237 } // namespace ns3
Callback< uint32_t, Ptr< SatControlMessage > > ReserveCtrlMsgCallback
Callback to reserve an id and initially store the control message.
Callback< void, Address, Address > RoutingUpdateCallback
Callback to update routing and ARP tables after handover.
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.
void EnableCreationTraces(Ptr< OutputStreamWrapper > stream, CallbackBase &cb)
Enables creation traces to be written in given file.
SatPhy::ErrorModel m_errorModel
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
SatPhy::InterferenceModel m_daInterferenceModel
bool m_enableChannelEstimationError
Enable channel estimation error modeling at forward link receiver (= UT).
TracedCallback< std::string > m_creationTrace
Trace callback for creation traces.
void SetPhyAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Phy created by the helper.
void Initialize(Ptr< SatLinkResultsFwd > lrFwd)
ObjectFactory m_channelFactory
NetDeviceContainer Install(NodeContainer c, uint32_t satId, uint32_t beamId, Ptr< SatChannel > fCh, Ptr< SatChannel > rCh, Ptr< SatNetDevice > gwNd, Ptr< SatNcc > ncc, Address satUserAddress, SatPhy::ChannelPairGetterCallback cbChannel, SatMac::RoutingUpdateCallback cbRouting)
Ptr< SatLinkResults > m_linkResults
Ptr< SatLowerLayerServiceConf > m_llsConf
Configured lower layer service configuration.
SatUtHelper()
Default constructor.
ObjectFactory m_deviceFactory
bool m_crdsaOnlyForControl
Planned CRDSA usage:
static TypeId GetTypeId(void)
Derived from Object.
TypeId GetInstanceTypeId(void) const
Derived from Object.
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
Define RandomAccessSettings as a struct.