Loading...
Searching...
No Matches
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
42NS_LOG_COMPONENT_DEFINE("SatGwHelper");
43
44namespace ns3
45{
46
47NS_OBJECT_ENSURE_REGISTERED(SatGwHelper);
48
49TypeId
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>(
61 "Constant",
63 "Trace",
65 "PerPacket",
67 "PerFragment"))
68 .AddAttribute(
69 "RtnLinkErrorModel",
70 "Return link error model for",
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",
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),
97 MakeBooleanChecker())
98 .AddTraceSource("Creation",
99 "Creation traces",
100 MakeTraceSourceAccessor(&SatGwHelper::m_creationTrace),
101 "ns3::SatTypedefs::CreationCallback");
102 return tid;
103}
104
110 m_symbolRate(0.0),
113{
114 // this default constructor should be never called
115 NS_FATAL_ERROR("Default constructor not supported!!!");
116}
117
119 uint32_t rtnLinkCarrierCount,
120 Ptr<SatSuperframeSeq> seq,
124 RandomAccessSettings_s randomAccessSettings)
125 : m_carrierBandwidthConverter(carrierBandwidthConverter),
126 m_rtnLinkCarrierCount(rtnLinkCarrierCount),
127 m_superframeSeq(seq),
128 m_readCtrlCb(readCb),
129 m_reserveCtrlCb(reserveCb),
130 m_sendCtrlCb(sendCb),
134 m_symbolRate(0.0),
136 m_raSettings(randomAccessSettings)
137{
138 NS_LOG_FUNCTION(this << rtnLinkCarrierCount << seq);
139
140 m_deviceFactory.SetTypeId("ns3::SatNetDevice");
141 m_channelFactory.SetTypeId("ns3::SatChannel");
142}
143
144void
145SatGwHelper::Initialize(Ptr<SatLinkResultsRtn> lrRcs2,
146 Ptr<SatLinkResultsFwd> lrFwd,
147 SatEnums::DvbVersion_t dvbVersion,
148 bool useScpc)
149{
150 NS_LOG_FUNCTION(this);
151
153 {
155 Config::SetDefault("ns3::SatBbFrameConf::PlHeaderInSlots", UintegerValue(1));
156 break;
158 Config::SetDefault("ns3::SatBbFrameConf::PlHeaderInSlots", UintegerValue(2));
159 break;
160 default:
161 NS_FATAL_ERROR("Forward scheduling algorithm is not implemented");
162 }
163
164 // TODO: Usage of multiple carriers needed to take into account, now only one carrier assumed to
165 // be used.
166 // TODO: Symbol rate needed to check.
169
170 /*
171 * Return channel link results (DVB-RCS2) are created for GWs.
172 */
174 {
175 m_linkResults = lrRcs2;
176 }
177 if (useScpc)
178 {
179 m_linkResults = lrFwd;
180 }
181
182 m_bbFrameConf = CreateObject<SatBbFrameConf>(m_symbolRate, dvbVersion);
183 m_bbFrameConf->InitializeCNoRequirements(lrFwd);
184
185 // m_bbFrameConf->DumpWaveforms ();
186}
187
188Ptr<SatBbFrameConf>
190{
191 NS_LOG_FUNCTION(this);
192
193 return m_bbFrameConf;
194}
195
196void
197SatGwHelper::SetDeviceAttribute(std::string n1, const AttributeValue& v1)
198{
199 NS_LOG_FUNCTION(this << n1);
200
201 m_deviceFactory.Set(n1, v1);
202}
203
204void
205SatGwHelper::SetChannelAttribute(std::string n1, const AttributeValue& v1)
206{
207 NS_LOG_FUNCTION(this << n1);
208
209 m_channelFactory.Set(n1, v1);
210}
211
212void
213SatGwHelper::SetPhyAttribute(std::string n1, const AttributeValue& v1)
214{
215 NS_LOG_FUNCTION(this << n1);
216
217 Config::SetDefault("ns3::SatGwPhy::" + n1, v1);
218}
219
220NetDeviceContainer
221SatGwHelper::Install(NodeContainer c,
222 uint32_t gwId,
223 uint32_t satId,
224 uint32_t beamId,
225 uint32_t feederSatId,
226 uint32_t feederBeamId,
227 Ptr<SatChannel> fCh,
228 Ptr<SatChannel> rCh,
230 Ptr<SatNcc> ncc,
231 Ptr<SatLowerLayerServiceConf> llsConf)
232{
233 NS_LOG_FUNCTION(this << gwId << satId << beamId << fCh << rCh << ncc << llsConf);
234
235 NetDeviceContainer devs;
236
237 for (NodeContainer::Iterator i = c.Begin(); i != c.End(); i++)
238 {
239 devs.Add(Install(*i,
240 gwId,
241 satId,
242 beamId,
243 feederSatId,
244 feederBeamId,
245 fCh,
246 rCh,
247 cbChannel,
248 ncc,
249 llsConf));
250 }
251
252 return devs;
253}
254
255void
256SatGwHelper::EnableCreationTraces(Ptr<OutputStreamWrapper> stream, CallbackBase& cb)
257{
258 NS_LOG_FUNCTION(this);
259
260 TraceConnect("Creation", "SatGwHelper", cb);
261}
262
263} // namespace ns3
DvbVersion_t
The scheduling algorithm used to fill the BBFrames.
Creates needed objects for GW nodes like SatOrbiterNetDevice objects.
Ptr< SatSuperframeSeq > m_superframeSeq
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.
SatMac::SendCtrlMsgCallback m_sendCtrlCb
RandomAccessSettings_s m_raSettings
The used random access model settings.
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.
SatMac::ReadCtrlMsgCallback m_readCtrlCb
ObjectFactory m_deviceFactory
Ptr< SatBbFrameConf > m_bbFrameConf
Ptr< SatLinkResults > m_linkResults
SatMac::ReserveCtrlMsgCallback m_reserveCtrlCb
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.