Loading...
Searching...
No Matches
satellite-orbiter-helper-lora.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
24
25#include "satellite-helper.h"
27#include "satellite-lora-conf.h"
28
29#include "ns3/config.h"
30#include "ns3/double.h"
31#include "ns3/enum.h"
32#include "ns3/log.h"
33#include "ns3/lorawan-mac-gateway.h"
34#include "ns3/lorawan-orbiter-mac-gateway.h"
35#include "ns3/names.h"
36#include "ns3/packet.h"
37#include "ns3/pointer.h"
38#include "ns3/satellite-channel-estimation-error-container.h"
39#include "ns3/satellite-const-variables.h"
40#include "ns3/satellite-id-mapper.h"
41#include "ns3/satellite-orbiter-feeder-llc.h"
42#include "ns3/satellite-orbiter-feeder-mac.h"
43#include "ns3/satellite-orbiter-feeder-phy.h"
44#include "ns3/satellite-orbiter-net-device-lora.h"
45#include "ns3/satellite-orbiter-user-llc.h"
46#include "ns3/satellite-orbiter-user-mac.h"
47#include "ns3/satellite-orbiter-user-phy.h"
48#include "ns3/satellite-phy-rx-carrier-conf.h"
49#include "ns3/satellite-phy-rx.h"
50#include "ns3/satellite-phy-tx.h"
51#include "ns3/satellite-topology.h"
52#include "ns3/satellite-typedefs.h"
53#include "ns3/satellite-utils.h"
54#include "ns3/singleton.h"
55#include "ns3/uinteger.h"
56
57#include <algorithm>
58#include <string>
59#include <utility>
60#include <vector>
61
62NS_LOG_COMPONENT_DEFINE("SatOrbiterHelperLora");
63
64namespace ns3
65{
66
67NS_OBJECT_ENSURE_REGISTERED(SatOrbiterHelperLora);
68
69TypeId
71{
72 static TypeId tid = TypeId("ns3::SatOrbiterHelperLora")
73 .SetParent<SatOrbiterHelper>()
74 .AddConstructor<SatOrbiterHelperLora>();
75 return tid;
76}
77
80{
81 NS_LOG_FUNCTION(this);
82
83 // this default constructor should be never called
84 NS_ASSERT(false);
85}
86
89 uint32_t rtnLinkCarrierCount,
90 uint32_t fwdLinkCarrierCount,
91 Ptr<SatSuperframeSeq> seq,
94 RandomAccessSettings_s randomAccessSettings)
95 : SatOrbiterHelper(bandwidthConverterCb,
96 rtnLinkCarrierCount,
97 fwdLinkCarrierCount,
98 seq,
99 fwdReadCb,
100 rtnReadCb,
101 randomAccessSettings)
102{
103 NS_LOG_FUNCTION(this << rtnLinkCarrierCount << fwdLinkCarrierCount);
104
105 m_deviceFactory.SetTypeId("ns3::SatOrbiterNetDeviceLora");
106}
107
108Ptr<SatOrbiterNetDevice>
110{
111 NS_LOG_FUNCTION(this);
112
114}
115
116void
117SatOrbiterHelperLora::AttachChannelsUser(Ptr<SatOrbiterNetDevice> dev,
118 Ptr<SatChannel> uf,
119 Ptr<SatChannel> ur,
120 Ptr<SatAntennaGainPattern> userAgp,
121 Ptr<SatNcc> ncc,
122 uint32_t satId,
123 uint32_t userBeamId)
124{
125 NS_LOG_FUNCTION(this << dev << uf << ur << userAgp << satId << userBeamId);
126
127 NS_ASSERT_MSG(
128 Singleton<SatTopology>::Get()->GetForwardLinkRegenerationMode() ==
129 Singleton<SatTopology>::Get()->GetReturnLinkRegenerationMode(),
130 "Regeneration level must be the same on forward and return in Lora configuration");
131 NS_ASSERT_MSG(
132 Singleton<SatTopology>::Get()->GetForwardLinkRegenerationMode() == SatEnums::TRANSPARENT ||
133 Singleton<SatTopology>::Get()->GetForwardLinkRegenerationMode() ==
135 "Satellite can only be transparent or with network regenration in Lora configuration");
136
138 params.m_satId = satId;
139 params.m_beamId = userBeamId;
140 params.m_device = dev;
141 params.m_standard =
142 Singleton<SatTopology>::Get()->GetForwardLinkRegenerationMode() == SatEnums::TRANSPARENT
145
149 Ptr<SatChannelEstimationErrorContainer> cec =
150 Create<SatSimpleChannelEstimationErrorContainer>();
151
152 SatPhyRxCarrierConf::RxCarrierCreateParams_s parametersUser =
153 SatPhyRxCarrierConf::RxCarrierCreateParams_s();
154 parametersUser.m_errorModel = m_rtnErrorModel;
155 parametersUser.m_daConstantErrorRate = m_rtnDaConstantErrorRate;
156 parametersUser.m_daIfModel = m_daRtnLinkInterferenceModel;
157 parametersUser.m_raIfModel = m_raSettings.m_raRtnInterferenceModel;
158 parametersUser.m_raIfEliminateModel = m_raSettings.m_raInterferenceEliminationModel;
159 parametersUser.m_linkRegenerationMode =
160 Singleton<SatTopology>::Get()->GetReturnLinkRegenerationMode();
161 parametersUser.m_bwConverter = m_carrierBandwidthConverter;
162 parametersUser.m_carrierCount = m_rtnLinkCarrierCount;
163 parametersUser.m_cec = cec;
164 parametersUser.m_raCollisionModel = m_raSettings.m_raCollisionModel;
165 parametersUser.m_randomAccessModel = m_raSettings.m_randomAccessModel;
166
167 params.m_txCh = uf;
168 params.m_rxCh = ur;
169
170 Ptr<SatOrbiterUserPhy> uPhy = CreateObject<SatOrbiterUserPhy>(
171 params,
173 parametersUser,
175
176 // Note, that currently we have only one set of antenna patterns,
177 // which are utilized in both in user link and feeder link, and
178 // in both uplink and downlink directions.
179 uPhy->SetTxAntennaGainPattern(userAgp, dev->GetNode()->GetObject<SatMobilityModel>());
180 uPhy->SetRxAntennaGainPattern(userAgp, dev->GetNode()->GetObject<SatMobilityModel>());
181
182 dev->AddUserPhy(uPhy, userBeamId);
183
184 uPhy->Initialize();
185
186 ncc->SetUseLora(true);
187
188 Mac48Address userAddress;
189
190 // Connect callbacks on forward link
191 switch (Singleton<SatTopology>::Get()->GetForwardLinkRegenerationMode())
192 {
194 // Create layers
195 Ptr<SatOrbiterUserMac> uTransparentMac = CreateObject<SatOrbiterUserMac>(satId, userBeamId);
196
197 Ptr<SatNodeInfo> niPhyUser =
198 Create<SatNodeInfo>(SatEnums::NT_SAT,
199 m_nodeIds[satId],
200 Mac48Address::ConvertFrom(dev->GetAddress()));
201 uPhy->SetNodeInfo(niPhyUser);
202 uTransparentMac->SetNodeInfo(niPhyUser);
203
204 // Return link
206 uPhy->SetAttribute("ReceiveCb", CallbackValue(uCb));
207
208 uTransparentMac->SetReceiveNetDeviceCallback(
209 MakeCallback(&SatOrbiterNetDevice::ReceiveUser, dev));
210
211 Singleton<SatTopology>::Get()->AddOrbiterUserLayersDvb(dev->GetNode(),
212 satId,
213 userBeamId,
214 dev,
215 nullptr,
216 uTransparentMac,
217 uPhy);
218 break;
219 }
221 // Create layers
222 Ptr<LorawanMacGateway> uRegenerationMac =
223 CreateObject<LorawanOrbiterMacGateway>(satId, userBeamId);
224
225 dev->AddUserMac(uRegenerationMac, userBeamId);
226 uRegenerationMac->SetDevice(dev);
227
228 uRegenerationMac->SetReadCtrlCallback(m_rtnReadCtrlCb);
229
230 Ptr<SatLoraConf> satLoraConf = CreateObject<SatLoraConf>();
231 satLoraConf->SetConf(uRegenerationMac);
232
233 // Attach the Mac layer receiver to Phy
234 SatPhy::ReceiveCallback recCb = MakeCallback(&LorawanMac::Receive, uRegenerationMac);
235 uPhy->SetAttribute("ReceiveCb", CallbackValue(recCb));
236
237 // Create a node info to PHY and MAC layers
238 userAddress = Mac48Address::Allocate();
239 Ptr<SatNodeInfo> niUser =
240 Create<SatNodeInfo>(SatEnums::NT_SAT, m_nodeIds[satId], userAddress);
241 uPhy->SetNodeInfo(niUser);
242 uRegenerationMac->SetNodeInfo(niUser);
243
244 dev->AddUserPair(userBeamId, userAddress);
245
246 uRegenerationMac->SetPhy(uPhy);
247
248 Singleton<SatTopology>::Get()->AddOrbiterUserLayersLora(
249 dev->GetNode(),
250 satId,
251 userBeamId,
252 dev,
253 DynamicCast<LorawanOrbiterMacGateway>(uRegenerationMac),
254 uPhy);
255
256 break;
257 }
258 default:
259 NS_FATAL_ERROR("Regeneration mode unknown");
260 }
261
262 if (Singleton<SatTopology>::Get()->GetReturnLinkRegenerationMode() != SatEnums::TRANSPARENT)
263 {
264 uPhy->BeginEndScheduling();
265 uPhy->SetSendControlMsgToFeederCallback(
267 }
268}
269
270} // namespace ns3
virtual void Receive(SatPhy::PacketContainer_t packets, Ptr< SatSignalParameters >)=0
Receive a packet from the lower layer.
Callback< Ptr< SatControlMessage >, uint32_t > ReadCtrlMsgCallback
Callback to read control messages from container storing control messages.
Keep track of the current position and velocity of an object in satellite network.
Ptr< SatLinkResults > m_rtnLinkResults
Return channel link results (DVB-RCS2) are created if ErrorModel is configured to be AVI.
RandomAccessSettings_s m_raSettings
The used random access model settings.
std::vector< uint32_t > m_nodeIds
Satellites node id.
Ptr< SatSuperframeSeq > m_superframeSeq
Superframe sequence.
SatPhy::InterferenceModel m_daRtnLinkInterferenceModel
SatTypedefs::CarrierBandwidthConverter_t m_carrierBandwidthConverter
SatOrbiterHelper()
Default constructor.
SatMac::ReadCtrlMsgCallback m_rtnReadCtrlCb
Control return link messages callback.
Creates needed objects for Satellite node like SatorbiterNetDevice objects.
static TypeId GetTypeId(void)
Get the type ID.
virtual Ptr< SatOrbiterNetDevice > CreateOrbiterNetDevice()
Create a SatOrbiterNetDevice instance, with correct type infered from child classes.
virtual void AttachChannelsUser(Ptr< SatOrbiterNetDevice > dev, Ptr< SatChannel > uf, Ptr< SatChannel > ur, Ptr< SatAntennaGainPattern > userAgp, Ptr< SatNcc > ncc, uint32_t satId, uint32_t userBeamId)
virtual bool SendControlMsgToFeeder(Ptr< SatControlMessage > msg, const Address &dest, Ptr< SatSignalParameters > rxParams)=0
Send a control packet on the feeder link.
void ReceiveUser(SatPhy::PacketContainer_t packets, Ptr< SatSignalParameters > rxParams)
Receive the packet from the lower layers.
SatOrbiterNetDeviceLora to be utilized in geostationary satellite.
Callback< void, PacketContainer_t, Ptr< SatSignalParameters > > ReceiveCallback
Callback< double, SatEnums::ChannelType_t, uint32_t, SatEnums::CarrierBandwidthType_t > CarrierBandwidthConverter_t
Callback for carrier bandwidths.
constexpr uint8_t SUPERFRAME_SEQUENCE
Used superframe sequence in the RTN link.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
Creation parameters for base PHY object.
SatEnums::SatLoraNodeType_t m_standard