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-topology.h"
32 #include "satellite-utils.h"
33 
34 #include <ns3/double.h>
35 #include <ns3/log.h>
36 #include <ns3/pointer.h>
37 #include <ns3/simulator.h>
38 #include <ns3/singleton.h>
39 #include <ns3/uinteger.h>
40 
41 NS_LOG_COMPONENT_DEFINE("SatUtPhy");
42 
43 namespace ns3
44 {
45 
46 NS_OBJECT_ENSURE_REGISTERED(SatUtPhy);
47 
48 TypeId
50 {
51  static TypeId tid =
52  TypeId("ns3::SatUtPhy")
53  .SetParent<SatPhy>()
54  .AddConstructor<SatUtPhy>()
55  .AddAttribute("PhyRx",
56  "The PhyRx layer attached to this phy.",
57  PointerValue(),
58  MakePointerAccessor(&SatUtPhy::GetPhyRx, &SatUtPhy::SetPhyRx),
59  MakePointerChecker<SatPhyRx>())
60  .AddAttribute("PhyTx",
61  "The PhyTx layer attached to this phy.",
62  PointerValue(),
63  MakePointerAccessor(&SatUtPhy::GetPhyTx, &SatUtPhy::SetPhyTx),
64  MakePointerChecker<SatPhyTx>())
65  .AddAttribute("RxTemperatureDbk",
66  "RX noise temperature in UT in dBK.",
67  DoubleValue(24.6), // ~290K
68  MakeDoubleAccessor(&SatPhy::GetRxNoiseTemperatureDbk,
70  MakeDoubleChecker<double>())
71  .AddAttribute(
72  "RxMaxAntennaGainDb",
73  "Maximum RX gain in dB",
74  DoubleValue(44.60),
76  MakeDoubleChecker<double_t>())
77  .AddAttribute(
78  "TxMaxAntennaGainDb",
79  "Maximum TX gain in dB",
80  DoubleValue(45.20),
82  MakeDoubleChecker<double_t>())
83  .AddAttribute("TxMaxPowerDbw",
84  "Maximum TX power in dB",
85  DoubleValue(4.00),
87  MakeDoubleChecker<double>())
88  .AddAttribute(
89  "TxOutputLossDb",
90  "TX Output loss in dB",
91  DoubleValue(0.50),
93  MakeDoubleChecker<double>())
94  .AddAttribute(
95  "TxPointingLossDb",
96  "TX Pointing loss in dB",
97  DoubleValue(1.00),
99  MakeDoubleChecker<double>())
100  .AddAttribute("TxOboLossDb",
101  "TX OBO loss in dB",
102  DoubleValue(0.50),
103  MakeDoubleAccessor(&SatPhy::GetTxOboLossDb, &SatPhy::SetTxOboLossDb),
104  MakeDoubleChecker<double>())
105  .AddAttribute(
106  "TxAntennaLossDb",
107  "TX Antenna loss in dB",
108  DoubleValue(1.00),
110  MakeDoubleChecker<double>())
111  .AddAttribute(
112  "RxAntennaLossDb",
113  "RX Antenna loss in dB",
114  DoubleValue(0.00),
116  MakeDoubleChecker<double>())
117  .AddAttribute("DefaultFadingValue",
118  "Default value for fading",
119  DoubleValue(1.00),
120  MakeDoubleAccessor(&SatPhy::GetDefaultFading, &SatPhy::SetDefaultFading),
121  MakeDoubleChecker<double_t>())
122  .AddAttribute("OtherSysIfCOverIDb",
123  "Other system interference, C over I in dB.",
124  DoubleValue(24.7),
125  MakeDoubleAccessor(&SatUtPhy::m_otherSysInterferenceCOverIDb),
126  MakeDoubleChecker<double>())
127  .AddAttribute("AntennaReconfigurationDelay",
128  "Delay of antenna reconfiguration when performing handover",
129  TimeValue(Seconds(0.0)),
130  MakeTimeAccessor(&SatUtPhy::m_antennaReconfigurationDelay),
131  MakeTimeChecker());
132  return tid;
133 }
134 
135 TypeId
137 {
138  NS_LOG_FUNCTION(this);
139  return GetTypeId();
140 }
141 
143  : m_otherSysInterferenceCOverIDb(24.7),
144  m_otherSysInterferenceCOverI(SatUtils::DbToLinear(m_otherSysInterferenceCOverIDb)),
145  m_antennaReconfigurationDelay(Seconds(0.0))
146 {
147  NS_LOG_FUNCTION(this);
148  NS_FATAL_ERROR("SatUtPhy default constructor is not allowed to be used");
149 }
150 
152  Ptr<SatLinkResults> linkResults,
153  SatPhyRxCarrierConf::RxCarrierCreateParams_s parameters,
154  Ptr<SatSuperframeConf> superFrameConf)
155  : SatPhy(params),
156  m_antennaReconfigurationDelay(Seconds(0.0))
157 {
158  NS_LOG_FUNCTION(this);
159 
160  ObjectBase::ConstructSelf(AttributeConstructionList());
161 
163 
164  parameters.m_rxTemperatureK = SatUtils::DbToLinear(SatPhy::GetRxNoiseTemperatureDbk());
165  parameters.m_aciIfWrtNoiseFactor = 0.0;
166  parameters.m_extNoiseDensityWhz = 0.0;
167  parameters.m_rxMode = SatPhyRxCarrierConf::NORMAL;
168  parameters.m_linkRegenerationMode =
169  Singleton<SatTopology>::Get()->GetForwardLinkRegenerationMode();
170  parameters.m_chType = SatEnums::FORWARD_USER_CH;
171 
172  Ptr<SatPhyRxCarrierConf> carrierConf = CreateObject<SatPhyRxCarrierConf>(parameters);
173 
174  if (linkResults)
175  {
176  carrierConf->SetLinkResults(linkResults);
177  }
178 
179  carrierConf->SetAdditionalInterferenceCb(
180  MakeCallback(&SatUtPhy::GetAdditionalInterference, this));
181 
182  SatPhy::ConfigureRxCarriers(carrierConf, superFrameConf);
183 }
184 
186 {
187  NS_LOG_FUNCTION(this);
188 }
189 
190 void
192 {
193  NS_LOG_FUNCTION(this);
194  Object::DoDispose();
195 }
196 
197 void
199 {
200  NS_LOG_FUNCTION(this);
201  Object::DoInitialize();
202 }
203 
204 double
206 {
207  NS_LOG_FUNCTION(this);
208 
210 }
211 
212 void
213 SatUtPhy::PerformHandover(uint32_t satId, uint32_t beamId)
214 {
215  NS_LOG_FUNCTION(this << beamId);
216 
217  // disconnect current SatChannels
219  m_phyTx->ClearChannel();
220  channels.first->RemoveRx(m_phyRx);
221 
222  // perform "physical" beam handover
223  SetSatId(satId);
224  SetBeamId(beamId);
226 }
227 
228 void
230 {
231  NS_LOG_FUNCTION(this);
232 
233  // Fetch channels for current beam
235  Ptr<SatChannel> forwardLink = channels.first;
236  Ptr<SatChannel> returnLink = channels.second;
237 
238  // Assign channels
239  NS_LOG_INFO("Setting new Tx on channel " << returnLink);
240  m_phyTx->SetChannel(returnLink);
241  forwardLink->AddRx(m_phyRx);
242 }
243 
246 {
247  return SatEnums::LD_RETURN;
248 }
249 
252 {
253  return SatEnums::LD_FORWARD;
254 }
255 
256 bool
258 {
259  NS_LOG_FUNCTION(this);
260  return m_phyTx->CanTransmit();
261 }
262 
263 void
264 SatUtPhy::Receive(Ptr<SatSignalParameters> rxParams, bool phyError)
265 {
266  NS_LOG_FUNCTION(this << rxParams << phyError);
267 
268  uint8_t slice = rxParams->m_txInfo.sliceId;
269 
270  if (rxParams->m_txInfo.frameType == SatEnums::DUMMY_FRAME)
271  {
272  NS_LOG_INFO("Dummy frame receive, it is not decoded");
273  }
274  else if ((slice == 0) || (m_slicesSubscribed.count(slice) != 0))
275 
276  {
277  // Slice is zero or is in the subscription list, we decode and forward to upper layers
278  SatPhy::Receive(rxParams, phyError);
279  }
280  else
281  {
282  NS_LOG_INFO("Slice of BBFrame (" << (uint32_t)slice
283  << ") not in list of subscriptions: BBFrame dropped");
284  }
285 }
286 
287 void
289 {
290  if (slice == 0)
291  {
292  m_slicesSubscribed.clear();
293  }
294  else
295  {
296  m_slicesSubscribed.insert(slice);
297  }
298 }
299 
300 } // namespace ns3
std::pair< Ptr< SatChannel >, Ptr< SatChannel > > ChannelPair_t
SatLinkDir_t
Link direction used for packet tracing.
The SatPhy models the basic physical layer of the satellite system.
Definition: satellite-phy.h:62
void SetTxPointingLossDb(double lossDb)
Set the pointing loss of the transmitter in dB.
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 SetSatId(uint32_t satId)
Set the satId this PHY is connected with.
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.
bool SetBeamId(uint32_t beamId)
Set the beamId this PHY is connected with.
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 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.
void PerformHandover(uint32_t satId, uint32_t beamId)
Change underlying SatChannel to send and receive data from a new satellite and beam.
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.