satellite-ut-phy.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@toulouse.viveris.com>
21  */
22 
23 #include "satellite-ut-phy.h"
24 
26 #include "satellite-channel.h"
27 #include "satellite-mac.h"
28 #include "satellite-phy-rx.h"
29 #include "satellite-phy-tx.h"
31 #include "satellite-utils.h"
32 
33 #include <ns3/double.h>
34 #include <ns3/log.h>
35 #include <ns3/pointer.h>
36 #include <ns3/simulator.h>
37 #include <ns3/uinteger.h>
38 
39 NS_LOG_COMPONENT_DEFINE("SatUtPhy");
40 
41 namespace ns3
42 {
43 
44 NS_OBJECT_ENSURE_REGISTERED(SatUtPhy);
45 
46 TypeId
48 {
49  static TypeId tid =
50  TypeId("ns3::SatUtPhy")
51  .SetParent<SatPhy>()
52  .AddConstructor<SatUtPhy>()
53  .AddAttribute("PhyRx",
54  "The PhyRx layer attached to this phy.",
55  PointerValue(),
56  MakePointerAccessor(&SatUtPhy::GetPhyRx, &SatUtPhy::SetPhyRx),
57  MakePointerChecker<SatPhyRx>())
58  .AddAttribute("PhyTx",
59  "The PhyTx layer attached to this phy.",
60  PointerValue(),
61  MakePointerAccessor(&SatUtPhy::GetPhyTx, &SatUtPhy::SetPhyTx),
62  MakePointerChecker<SatPhyTx>())
63  .AddAttribute("RxTemperatureDbk",
64  "RX noise temperature in UT in dBK.",
65  DoubleValue(24.6), // ~290K
66  MakeDoubleAccessor(&SatPhy::GetRxNoiseTemperatureDbk,
68  MakeDoubleChecker<double>())
69  .AddAttribute(
70  "RxMaxAntennaGainDb",
71  "Maximum RX gain in dB",
72  DoubleValue(44.60),
74  MakeDoubleChecker<double_t>())
75  .AddAttribute(
76  "TxMaxAntennaGainDb",
77  "Maximum TX gain in dB",
78  DoubleValue(45.20),
80  MakeDoubleChecker<double_t>())
81  .AddAttribute("TxMaxPowerDbw",
82  "Maximum TX power in dB",
83  DoubleValue(4.00),
85  MakeDoubleChecker<double>())
86  .AddAttribute(
87  "TxOutputLossDb",
88  "TX Output loss in dB",
89  DoubleValue(0.50),
91  MakeDoubleChecker<double>())
92  .AddAttribute(
93  "TxPointingLossDb",
94  "TX Pointing loss in dB",
95  DoubleValue(1.00),
97  MakeDoubleChecker<double>())
98  .AddAttribute("TxOboLossDb",
99  "TX OBO loss in dB",
100  DoubleValue(0.50),
101  MakeDoubleAccessor(&SatPhy::GetTxOboLossDb, &SatPhy::SetTxOboLossDb),
102  MakeDoubleChecker<double>())
103  .AddAttribute(
104  "TxAntennaLossDb",
105  "TX Antenna loss in dB",
106  DoubleValue(1.00),
108  MakeDoubleChecker<double>())
109  .AddAttribute(
110  "RxAntennaLossDb",
111  "RX Antenna loss in dB",
112  DoubleValue(0.00),
114  MakeDoubleChecker<double>())
115  .AddAttribute("DefaultFadingValue",
116  "Default value for fading",
117  DoubleValue(1.00),
118  MakeDoubleAccessor(&SatPhy::GetDefaultFading, &SatPhy::SetDefaultFading),
119  MakeDoubleChecker<double_t>())
120  .AddAttribute("OtherSysIfCOverIDb",
121  "Other system interference, C over I in dB.",
122  DoubleValue(24.7),
123  MakeDoubleAccessor(&SatUtPhy::m_otherSysInterferenceCOverIDb),
124  MakeDoubleChecker<double>())
125  .AddAttribute("AntennaReconfigurationDelay",
126  "Delay of antenna reconfiguration when performing handover",
127  TimeValue(Seconds(0.0)),
128  MakeTimeAccessor(&SatUtPhy::m_antennaReconfigurationDelay),
129  MakeTimeChecker());
130  return tid;
131 }
132 
133 TypeId
135 {
136  NS_LOG_FUNCTION(this);
137  return GetTypeId();
138 }
139 
141  : m_otherSysInterferenceCOverIDb(24.7),
142  m_otherSysInterferenceCOverI(SatUtils::DbToLinear(m_otherSysInterferenceCOverIDb)),
143  m_antennaReconfigurationDelay(Seconds(0.0))
144 {
145  NS_LOG_FUNCTION(this);
146  NS_FATAL_ERROR("SatUtPhy default constructor is not allowed to be used");
147 }
148 
150  Ptr<SatLinkResults> linkResults,
151  SatPhyRxCarrierConf::RxCarrierCreateParams_s parameters,
152  Ptr<SatSuperframeConf> superFrameConf,
153  SatEnums::RegenerationMode_t forwardLinkRegenerationMode)
154  : SatPhy(params),
155  m_antennaReconfigurationDelay(Seconds(0.0))
156 {
157  NS_LOG_FUNCTION(this);
158 
159  ObjectBase::ConstructSelf(AttributeConstructionList());
160 
162 
163  parameters.m_rxTemperatureK = SatUtils::DbToLinear(SatPhy::GetRxNoiseTemperatureDbk());
164  parameters.m_aciIfWrtNoiseFactor = 0.0;
165  parameters.m_extNoiseDensityWhz = 0.0;
166  parameters.m_rxMode = SatPhyRxCarrierConf::NORMAL;
167  parameters.m_linkRegenerationMode = forwardLinkRegenerationMode;
168  parameters.m_chType = SatEnums::FORWARD_USER_CH;
169 
170  Ptr<SatPhyRxCarrierConf> carrierConf = CreateObject<SatPhyRxCarrierConf>(parameters);
171 
172  if (linkResults)
173  {
174  carrierConf->SetLinkResults(linkResults);
175  }
176 
177  carrierConf->SetAdditionalInterferenceCb(
178  MakeCallback(&SatUtPhy::GetAdditionalInterference, this));
179 
180  SatPhy::ConfigureRxCarriers(carrierConf, superFrameConf);
181 }
182 
184 {
185  NS_LOG_FUNCTION(this);
186 }
187 
188 void
190 {
191  NS_LOG_FUNCTION(this);
192  Object::DoDispose();
193 }
194 
195 void
197 {
198  NS_LOG_FUNCTION(this);
199  Object::DoInitialize();
200 }
201 
202 double
204 {
205  NS_LOG_FUNCTION(this);
206 
208 }
209 
210 void
212 {
213  NS_LOG_FUNCTION(this << beamId);
214 
215  // disconnect current SatChannels
217  m_phyTx->ClearChannel();
218  channels.first->RemoveRx(m_phyRx);
219 
220  // perform "physical" beam handover
221  SetBeamId(beamId);
223 }
224 
225 void
227 {
228  NS_LOG_FUNCTION(this);
229 
230  // Fetch channels for current beam
232  Ptr<SatChannel> forwardLink = channels.first;
233  Ptr<SatChannel> returnLink = channels.second;
234 
235  // Assign channels
236  NS_LOG_INFO("Setting new Tx on channel " << returnLink);
237  m_phyTx->SetChannel(returnLink);
238  forwardLink->AddRx(m_phyRx);
239 }
240 
243 {
244  return SatEnums::LD_RETURN;
245 }
246 
249 {
250  return SatEnums::LD_FORWARD;
251 }
252 
253 bool
255 {
256  NS_LOG_FUNCTION(this);
257  return m_phyTx->CanTransmit();
258 }
259 
260 void
261 SatUtPhy::Receive(Ptr<SatSignalParameters> rxParams, bool phyError)
262 {
263  NS_LOG_FUNCTION(this << rxParams << phyError);
264 
265  uint8_t slice = rxParams->m_txInfo.sliceId;
266 
267  if (rxParams->m_txInfo.frameType == SatEnums::DUMMY_FRAME)
268  {
269  NS_LOG_INFO("Dummy frame receive, it is not decoded");
270  }
271  else if ((slice == 0) || (m_slicesSubscribed.count(slice) != 0))
272 
273  {
274  // Slice is zero or is in the subscription list, we decode and forward to upper layers
275  SatPhy::Receive(rxParams, phyError);
276  }
277  else
278  {
279  NS_LOG_INFO("Slice of BBFrame (" << (uint32_t)slice
280  << ") not in list of subscriptions: BBFrame dropped");
281  }
282 }
283 
284 void
286 {
287  if (slice == 0)
288  {
289  m_slicesSubscribed.clear();
290  }
291  else
292  {
293  m_slicesSubscribed.insert(slice);
294  }
295 }
296 
297 } // namespace ns3
std::pair< Ptr< SatChannel >, Ptr< SatChannel > > ChannelPair_t
SatLinkDir_t
Link direction used for packet tracing.
RegenerationMode_t
The regeneration mode used in satellites.
The SatPhy models the basic physical layer of the satellite system.
Definition: satellite-phy.h:61
void SetTxPointingLossDb(double lossDb)
Set the pointing loss of the transmitter in dB.
void SetBeamId(uint32_t beamId)
Set the beamId this PHY is connected with.
void SetRxAntennaGainDb(double gainDb)
Set the maximum antenna gain of the receiver in dB.
void ConfigureRxCarriers(Ptr< SatPhyRxCarrierConf > carrierConf, Ptr< SatSuperframeConf > superFrameConf)
Configure Rx carriers.
virtual Ptr< SatPhyTx > GetPhyTx() const
Get the SatPhyTx pointer.
void SetTxOboLossDb(double lossDb)
Set the OBO loss of the transmitter in dB.
void SetDefaultFading(double fading)
Set the default fading of the PHY.
Ptr< SatPhyRx > m_phyRx
Pointer to internal SatPhyRx instance.
double GetTxOutputLossDb() const
Get the output loss of the transmitter in dB.
uint32_t m_satId
Satellite ID.
double GetTxAntennaGainDb() const
Get the maximum antenna gain of the transmitter in dB.
uint32_t m_beamId
Beam ID.
virtual Ptr< SatPhyRx > GetPhyRx() const
Get the SatPhyRx pointer.
void SetTxOutputLossDb(double lossDb)
Set the output loss of the transmitter in dB.
double GetTxPointingLossDb() const
Get the pointing loss of the transmitter in dB.
double GetDefaultFading() const
Get the default fading of the PHY.
virtual void Receive(Ptr< SatSignalParameters > rxParams, bool phyError)
Receives packets from lower layer.
double GetTxMaxPowerDbw() const
Get the maximum transmit power of the transmitter in dB.
double GetTxOboLossDb() const
Get the OBO loss of the transmitter in dB.
void SetTxMaxPowerDbw(double powerDb)
Set the maximum transmit power of the transmitter in dB.
SatPhy::ChannelPairGetterCallback m_retrieveChannelPair
Callback for retrieving SatChannel pairs by beam.
double GetRxAntennaGainDb() const
Get the maximum antenna gain of the receiver in dB.
virtual void SetPhyTx(Ptr< SatPhyTx > phyTx)
Set the SatPhyTx module.
void SetRxAntennaLossDb(double lossDb)
Set the antenna loss of the receiver in dB.
void SetRxNoiseTemperatureDbk(double temperatureDbk)
Set the noise temperature of the receiver in dbK.
double GetRxNoiseTemperatureDbk() const
Get the noise temperature of the receiver in dbK.
double GetRxAntennaLossDb() const
Get the antenna loss of the receiver in dB.
Ptr< SatPhyTx > m_phyTx
Pointer to internal SatPhyTx instance.
void SetTxAntennaGainDb(double gainDb)
Set the maximum antenna gain of the transmitter in dB.
void SetTxAntennaLossDb(double lossDb)
Set the antenna loss of the transmitter in dB.
virtual void SetPhyRx(Ptr< SatPhyRx > phyRx)
Set the SatPhyRx module.
double GetTxAntennaLossDb() const
Get the antenna loss of the transmitter in dB.
double m_otherSysInterferenceCOverIDb
Configured other system interference in dB.
static TypeId GetTypeId(void)
inherited from Object
virtual ~SatUtPhy()
Destructor.
virtual double GetAdditionalInterference()
Get additional interference, used to compute final SINR at RX.
void PerformHandover(uint32_t beamId)
Change underlying SatChannel to send and receive data from a new beam.
void AssignNewSatChannels()
Update the underlying SatChannel to send and receive data from the current beam (as described in the ...
double m_otherSysInterferenceCOverI
Other system interference in linear.
virtual SatEnums::SatLinkDir_t GetSatLinkRxDir()
Get the link RX direction.
std::set< uint8_t > m_slicesSubscribed
The list of slices subscribed for this UT.
bool IsTxPossible(void) const
Inform whether or not the underlying Tx channel is properly configured for transmission.
void Receive(Ptr< SatSignalParameters > rxParams, bool phyError)
Receives packets from lower layer.
Time m_antennaReconfigurationDelay
Delay of antenna reconfiguration when performing handover.
virtual SatEnums::SatLinkDir_t GetSatLinkTxDir()
Get the link TX direction.
void UpdateSliceSubscription(uint8_t slice)
Updates the slices subscription list.
TypeId GetInstanceTypeId(void) const
virtual void DoInitialize(void)
Initialization of SatUtPhy.
virtual void DoDispose(void)
Dispose of SatUtPhy.
SatUtPhy(void)
Default constructor, which is not used.
SatUtils class is for general conversions used in satellite module.
static T DbToLinear(T db)
Converts decibels to linear.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
Creation parameters for base PHY object.