Loading...
Searching...
No Matches
satellite-phy-rx.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: Jani Puttonen <jani.puttonen@magister.fi>
20 * Author: Mathias Ettinger <mettinger@toulouse.viveris.fr>
21 */
22
23#include "satellite-phy-rx.h"
24
34#include "satellite-phy.h"
36#include "satellite-utils.h"
37
38#include "ns3/antenna-model.h"
39#include "ns3/log.h"
40#include "ns3/object-factory.h"
41#include "ns3/object-vector.h"
42
43#include <vector>
44
45NS_LOG_COMPONENT_DEFINE("SatPhyRx");
46
47namespace ns3
48{
49
50NS_OBJECT_ENSURE_REGISTERED(SatPhyRx);
51
53 : m_beamId(),
57{
58 NS_LOG_FUNCTION(this);
59}
60
62{
63 NS_LOG_FUNCTION(this);
64}
65
66void
68{
69 NS_LOG_FUNCTION(this);
70 m_mobility = 0;
71 m_device = 0;
73 m_rxCarriers.clear();
74 Object::DoDispose();
75}
76
77TypeId
79{
80 static TypeId tid = TypeId("ns3::SatPhyRx")
81 .SetParent<Object>()
82 .AddAttribute("RxCarrierList",
83 "The list of RX carriers associated to this Phy RX.",
84 ObjectVectorValue(),
85 MakeObjectVectorAccessor(&SatPhyRx::m_rxCarriers),
86 MakeObjectVectorChecker<SatPhyRxCarrier>());
87 return tid;
88}
89
90Ptr<NetDevice>
92{
93 NS_LOG_FUNCTION(this);
94 NS_ASSERT(m_device != nullptr);
95
96 return m_device;
97}
98
99void
100SatPhyRx::SetDevice(Ptr<NetDevice> d)
101{
102 NS_LOG_FUNCTION(this << d);
103 NS_ASSERT(m_device == nullptr);
104
105 m_device = d;
106}
107
108void
110{
111 NS_LOG_FUNCTION(this << gain_Db);
112
114}
115
116double
117SatPhyRx::GetAntennaGain(Ptr<MobilityModel> mobility)
118{
119 NS_LOG_FUNCTION(this);
120
121 double gain_W(m_maxAntennaGain);
122
123 // Get the receive antenna gain at the transmitter position.
124 // E.g. UT transmits to the satellite receiver.
126 {
127 Ptr<SatMobilityModel> m = DynamicCast<SatMobilityModel>(mobility);
128 gain_W = m_antennaGainPattern->GetAntennaGain_lin(m->GetGeoPosition(), m_satMobility);
129 }
130
135
136 return gain_W;
137}
138
139void
141{
142 NS_LOG_FUNCTION(this << fadingValue);
143 m_defaultFadingValue = fadingValue;
144}
145
146double
147SatPhyRx::GetFadingValue(Address macAddress, SatEnums::ChannelType_t channelType)
148{
149 NS_LOG_FUNCTION(this << macAddress << channelType);
150
151 double fadingValue = m_defaultFadingValue;
152
154 {
155 fadingValue = m_fadingContainer->GetFading(macAddress, channelType);
156 }
157 // Returns value 1 if fading is not set, as fading value is used as multiplier
158 return fadingValue;
159}
160
161void
162SatPhyRx::SetFadingContainer(Ptr<SatBaseFading> fadingContainer)
163{
164 NS_LOG_FUNCTION(this);
165 NS_ASSERT(m_fadingContainer == nullptr);
166
167 m_fadingContainer = fadingContainer;
168}
169
170void
172{
173 NS_LOG_FUNCTION(this << gain_Db);
174
176}
177
178double
180{
181 NS_LOG_FUNCTION(this);
182
183 return m_antennaLoss;
184}
185
186Mac48Address
188{
189 NS_LOG_FUNCTION(this);
190
191 return m_macAddress;
192}
193
194void
195SatPhyRx::SetNodeInfo(const Ptr<SatNodeInfo> nodeInfo)
196{
197 NS_LOG_FUNCTION(this << nodeInfo->GetNodeId());
198
199 m_macAddress = nodeInfo->GetMacAddress();
200
201 for (std::vector<Ptr<SatPhyRxCarrier>>::iterator it = m_rxCarriers.begin();
202 it != m_rxCarriers.end();
203 ++it)
204 {
205 (*it)->SetNodeInfo(nodeInfo);
206 }
207}
208
209void
211{
212 NS_LOG_FUNCTION(this);
213
214 for (std::vector<Ptr<SatPhyRxCarrier>>::iterator it = m_rxCarriers.begin();
215 it != m_rxCarriers.end();
216 ++it)
217 {
218 (*it)->BeginEndScheduling();
219 }
220}
221
222void
224{
225 NS_LOG_FUNCTION(this);
226 NS_ASSERT(!m_rxCarriers.empty());
227
228 for (std::vector<Ptr<SatPhyRxCarrier>>::iterator it = m_rxCarriers.begin();
229 it != m_rxCarriers.end();
230 ++it)
231 {
232 (*it)->SetReceiveCb(cb);
233 }
234}
235
236void
238{
239 NS_LOG_FUNCTION(this << &cb);
240 NS_ASSERT(!m_rxCarriers.empty());
241
242 for (std::vector<Ptr<SatPhyRxCarrier>>::iterator it = m_rxCarriers.begin();
243 it != m_rxCarriers.end();
244 ++it)
245 {
246 (*it)->SetCnoCb(cb);
247 }
248}
249
250void
252{
253 NS_LOG_FUNCTION(this << &cb);
254 NS_ASSERT(!m_rxCarriers.empty());
255
256 for (std::vector<Ptr<SatPhyRxCarrier>>::iterator it = m_rxCarriers.begin();
257 it != m_rxCarriers.end();
258 ++it)
259 {
260 (*it)->SetAverageNormalizedOfferedLoadCallback(cb);
261 }
262}
263
264Ptr<MobilityModel>
266{
267 NS_LOG_FUNCTION(this);
268 NS_ASSERT(m_mobility != nullptr);
269
270 return m_mobility;
271}
272
273void
274SatPhyRx::SetMobility(Ptr<MobilityModel> m)
275{
276 NS_LOG_FUNCTION(this << m);
277 m_mobility = m;
278}
279
280void
281SatPhyRx::SetAntennaGainPattern(Ptr<SatAntennaGainPattern> agp, Ptr<SatMobilityModel> mobility)
282{
283 NS_LOG_FUNCTION(this << agp);
284 NS_ASSERT(m_antennaGainPattern == nullptr);
285
287 m_satMobility = mobility;
288}
289
290void
291SatPhyRx::ConfigurePhyRxCarriers(Ptr<SatPhyRxCarrierConf> carrierConf,
292 Ptr<SatSuperframeConf> superFrameConf)
293{
294 NS_LOG_FUNCTION(this);
295 NS_ASSERT(m_rxCarriers.empty());
296
297 Ptr<SatPhyRxCarrier> rxc(nullptr);
298 bool isRandomAccessCarrier(false);
299
300 SatEnums::RandomAccessModel_t raModel = carrierConf->GetRandomAccessModel();
301 SatEnums::RegenerationMode_t regenerationMode = carrierConf->GetLinkRegenerationMode();
302
303 for (uint32_t i = 0; i < carrierConf->GetCarrierCount(); ++i)
304 {
305 NS_LOG_INFO(this << " Create carrier: " << i);
306 Ptr<SatWaveformConf> waveformConf =
307 superFrameConf->GetCarrierFrameConf(i)->GetWaveformConf();
308
309 if (regenerationMode == SatEnums::TRANSPARENT)
310 {
311 switch (carrierConf->GetChannelType())
312 {
314 // Satellite is the receiver in feeder uplink
315 rxc = CreateObject<SatPhyRxCarrierUplink>(i, carrierConf, waveformConf, false);
316 break;
317 }
319 // UT has only per slot non-random access carriers
320 rxc = CreateObject<SatPhyRxCarrierPerSlot>(i, carrierConf, waveformConf, false);
321 break;
322 }
324 isRandomAccessCarrier = superFrameConf->IsRandomAccessCarrier(i);
325
326 // Satellite is the receiver in either user or feeder uplink
327 rxc = CreateObject<SatPhyRxCarrierUplink>(i,
328 carrierConf,
329 waveformConf,
330 isRandomAccessCarrier);
331 break;
332 }
334 isRandomAccessCarrier = superFrameConf->IsRandomAccessCarrier(i);
335
336 // DA carrier
337 if (!isRandomAccessCarrier)
338 {
339 rxc = CreateObject<SatPhyRxCarrierPerSlot>(i, carrierConf, waveformConf, false);
340 }
341 // RA slotted aloha
342 else if (raModel == SatEnums::RA_MODEL_SLOTTED_ALOHA)
343 {
344 rxc = CreateObject<SatPhyRxCarrierPerSlot>(i, carrierConf, waveformConf, true);
345 DynamicCast<SatPhyRxCarrierPerSlot>(rxc)->SetRandomAccessAllocationChannelId(
346 superFrameConf->GetRaChannel(i));
347 }
348 // Note, that random access model of DVB-RCS2 specification may be configured
349 // to be either slotted ALOHA and CRDSA (wit no of unique payloads attribute).
350 // Here we make a short-cut such that the RCS2_SPECIFICATION random access
351 // always uses the CRDSA frame type receiver.
352 else if (raModel == SatEnums::RA_MODEL_CRDSA ||
354 {
355 rxc = CreateObject<SatPhyRxCarrierPerFrame>(i, carrierConf, waveformConf, true);
356 DynamicCast<SatPhyRxCarrierPerSlot>(rxc)->SetRandomAccessAllocationChannelId(
357 superFrameConf->GetRaChannel(i));
358 }
359 else if (raModel == SatEnums::RA_MODEL_MARSALA)
360 {
361 rxc = CreateObject<SatPhyRxCarrierMarsala>(i, carrierConf, waveformConf, true);
362 DynamicCast<SatPhyRxCarrierPerSlot>(rxc)->SetRandomAccessAllocationChannelId(
363 superFrameConf->GetRaChannel(i));
364 }
365 else if (raModel == SatEnums::RA_MODEL_ESSA)
366 {
367 rxc =
368 CreateObject<SatPhyRxCarrierPerWindow>(i, carrierConf, waveformConf, true);
369 DynamicCast<SatPhyRxCarrierPerSlot>(rxc)->SetRandomAccessAllocationChannelId(
370 superFrameConf->GetRaChannel(i));
371 }
372 break;
373 }
375 default: {
376 NS_FATAL_ERROR("SatPhyRx::ConfigurePhyRxCarriers - Invalid channel type!");
377 }
378 }
379 }
380 else if (regenerationMode == SatEnums::REGENERATION_PHY ||
381 regenerationMode == SatEnums::REGENERATION_LINK ||
382 regenerationMode == SatEnums::REGENERATION_NETWORK)
383 {
384 switch (carrierConf->GetChannelType())
385 {
387 // Satellite is the receiver in feeder uplink
388 rxc = CreateObject<SatPhyRxCarrierPerSlot>(i, carrierConf, waveformConf, false);
389 break;
390 }
392 // UT has only per slot non-random access carriers
393 rxc = CreateObject<SatPhyRxCarrierPerSlot>(i, carrierConf, waveformConf, false);
394 break;
395 }
397 isRandomAccessCarrier = superFrameConf->IsRandomAccessCarrier(i);
398
399 // DA carrier
400 if (!isRandomAccessCarrier)
401 {
402 rxc = CreateObject<SatPhyRxCarrierPerSlot>(i, carrierConf, waveformConf, false);
403 }
404 // RA slotted aloha
405 else if (raModel == SatEnums::RA_MODEL_SLOTTED_ALOHA)
406 {
407 rxc = CreateObject<SatPhyRxCarrierPerSlot>(i, carrierConf, waveformConf, true);
408 DynamicCast<SatPhyRxCarrierPerSlot>(rxc)->SetRandomAccessAllocationChannelId(
409 superFrameConf->GetRaChannel(i));
410 }
411 // Note, that random access model of DVB-RCS2 specification may be configured
412 // to be either slotted ALOHA and CRDSA (wit no of unique payloads attribute).
413 // Here we make a short-cut such that the RCS2_SPECIFICATION random access
414 // always uses the CRDSA frame type receiver.
415 else if (raModel == SatEnums::RA_MODEL_CRDSA ||
417 {
418 rxc = CreateObject<SatPhyRxCarrierPerFrame>(i, carrierConf, waveformConf, true);
419 DynamicCast<SatPhyRxCarrierPerSlot>(rxc)->SetRandomAccessAllocationChannelId(
420 superFrameConf->GetRaChannel(i));
421 }
422 else if (raModel == SatEnums::RA_MODEL_MARSALA)
423 {
424 rxc = CreateObject<SatPhyRxCarrierMarsala>(i, carrierConf, waveformConf, true);
425 DynamicCast<SatPhyRxCarrierPerSlot>(rxc)->SetRandomAccessAllocationChannelId(
426 superFrameConf->GetRaChannel(i));
427 }
428 else if (raModel == SatEnums::RA_MODEL_ESSA)
429 {
430 rxc =
431 CreateObject<SatPhyRxCarrierPerWindow>(i, carrierConf, waveformConf, true);
432 DynamicCast<SatPhyRxCarrierPerSlot>(rxc)->SetRandomAccessAllocationChannelId(
433 superFrameConf->GetRaChannel(i));
434 }
435 break;
436 }
438 rxc = CreateObject<SatPhyRxCarrierPerSlot>(i, carrierConf, waveformConf, false);
439 break;
440 }
442 default: {
443 NS_FATAL_ERROR("SatPhyRx::ConfigurePhyRxCarriers - Invalid channel type!");
444 }
445 }
446 }
447 else
448 {
449 NS_FATAL_ERROR("SatPhyRx::ConfigurePhyRxCarriers - Unknown RX mode!");
450 }
451
452 NS_LOG_INFO(this << " added carrier " << rxc << " on channel "
453 << carrierConf->GetChannelType() << " being random access "
454 << superFrameConf->IsRandomAccessCarrier(i));
455 m_rxCarriers.push_back(rxc);
456 }
457}
458
459void
460SatPhyRx::SetSatId(uint32_t satId)
461{
462 NS_LOG_FUNCTION(this << satId);
463 NS_ASSERT(satId >= 0);
464 NS_ASSERT(!m_rxCarriers.empty());
465
466 m_satId = satId;
467
468 for (std::vector<Ptr<SatPhyRxCarrier>>::iterator it = m_rxCarriers.begin();
469 it != m_rxCarriers.end();
470 ++it)
471 {
472 (*it)->SetSatId(satId);
473 }
474}
475
476uint32_t
478{
479 NS_LOG_FUNCTION(this);
480
481 return m_satId;
482}
483
484void
485SatPhyRx::SetBeamId(uint32_t beamId)
486{
487 NS_LOG_FUNCTION(this << beamId);
488 NS_ASSERT(beamId >= 0);
489 NS_ASSERT(!m_rxCarriers.empty());
490
491 m_beamId = beamId;
492
493 for (std::vector<Ptr<SatPhyRxCarrier>>::iterator it = m_rxCarriers.begin();
494 it != m_rxCarriers.end();
495 ++it)
496 {
497 (*it)->SetBeamId(beamId);
498 }
499}
500
501uint32_t
503{
504 NS_LOG_FUNCTION(this);
505
506 return m_beamId;
507}
508
509double
510SatPhyRx::GetRxTemperatureK(Ptr<SatSignalParameters> rxParams)
511{
512 NS_LOG_FUNCTION(this << rxParams);
513
514 uint32_t cId = rxParams->m_carrierId;
515
516 if (cId >= m_rxCarriers.size())
517 {
518 NS_FATAL_ERROR("SatPhyRx::GetRxTemperatureK - unvalid carrier id: " << cId);
519 }
520
521 return m_rxCarriers[cId]->GetRxTemperatureK();
522}
523
524void
525SatPhyRx::StartRx(Ptr<SatSignalParameters> rxParams)
526{
527 NS_LOG_FUNCTION(this << rxParams);
528
529 uint32_t cId = rxParams->m_carrierId;
530
531 if (cId >= m_rxCarriers.size())
532 {
533 NS_FATAL_ERROR("SatPhyRx::StartRx - unvalid carrier id: " << cId);
534 }
535
536 m_rxCarriers[cId]->StartRx(rxParams);
537}
538
539} // namespace ns3
ChannelType_t
Types of channel.
RandomAccessModel_t
The defined random access models.
RegenerationMode_t
The regeneration mode used in satellites.
The SatPhyRx models the physical layer receiver of satellite system.
void ConfigurePhyRxCarriers(Ptr< SatPhyRxCarrierConf > carrierConf, Ptr< SatSuperframeConf > superFrameConf)
uint32_t GetSatId() const
Get satellite id of this receiver.
Ptr< SatAntennaGainPattern > m_antennaGainPattern
virtual void DoDispose()
Dispose of this class instance.
SatPhyRx()
Default constructor.
void SetFadingContainer(Ptr< SatBaseFading > fadingContainer)
Set fading container.
void SetAntennaLoss_Db(double loss_Db)
Set the Antenna loss in Db.
void SetAntennaGainPattern(Ptr< SatAntennaGainPattern > agp, Ptr< SatMobilityModel > mobility)
void SetMaxAntennaGain_Db(double gain_Db)
Set the maximum Antenna gain in Db.
void SetDevice(Ptr< NetDevice > d)
Callback< void, uint32_t, uint32_t, Address, Address, double, bool > CnoCallback
virtual ~SatPhyRx()
Destructor for SatPhyRx.
double GetFadingValue(Address macAddress, SatEnums::ChannelType_t channelType)
Get fading value.
double GetRxTemperatureK(Ptr< SatSignalParameters > rxParams)
Method for querying the temperature of the chosen carrier.
void BeginEndScheduling()
Begin frame/window end scheduling for processes utilizing frame length as interval.
double m_maxAntennaGain
Configured maximum antenna gain in linear.
void SetSatId(uint32_t satId)
Set the satellite id for all the transmissions from this SatPhyTx.
void SetMobility(Ptr< MobilityModel > m)
Mac48Address m_macAddress
Mac48Address GetAddress() const
Get MAC address of this PHY/MAC.
void SetAverageNormalizedOfferedLoadCallback(SatPhyRx::AverageNormalizedOfferedLoadCallback cb)
Set average normalized offered load callback.
void SetCnoCallback(SatPhyRx::CnoCallback cb)
Set C/N0 receiver.
std::vector< Ptr< SatPhyRxCarrier > > m_rxCarriers
void SetDefaultFadingValue(double fadingValue)
Function for setting the default fading value.
double GetAntennaGain(Ptr< MobilityModel > mobility)
Get antenna gain based on position or in case that antenna pattern is not configured,...
Ptr< NetDevice > m_device
double m_defaultFadingValue
Default fading value.
Ptr< MobilityModel > m_mobility
Callback< void, Ptr< SatSignalParameters >, bool > ReceiveCallback
void SetReceiveCallback(SatPhyRx::ReceiveCallback cb)
Set the upper layer receive callback.
virtual void StartRx(Ptr< SatSignalParameters > rxParams)
Start packet reception from the SatChannel.
double GetLosses()
Get configures RX losses, currently only antenna loss used.
Ptr< MobilityModel > GetMobility()
void SetBeamId(uint32_t beamId)
Set the beam id for all the transmissions from this SatPhyTx.
Ptr< SatBaseFading > m_fadingContainer
Fading container for fading model.
void SetNodeInfo(const Ptr< SatNodeInfo > nodeInfo)
Set the node info class.
double m_antennaLoss
Configured antenna loss in linear.
Callback< void, uint32_t, uint32_t, uint32_t, uint8_t, double > AverageNormalizedOfferedLoadCallback
Ptr< SatMobilityModel > m_satMobility
uint32_t GetBeamId() const
Get beam id of this receiver.
Ptr< NetDevice > GetDevice()
static TypeId GetTypeId(void)
inherited from Object
static T DbWToW(T dbw)
Converts Decibel Watts to Watts.
static T DbToLinear(T db)
Converts decibels to linear.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.