Loading...
Searching...
No Matches
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
41NS_LOG_COMPONENT_DEFINE("SatUtPhy");
42
43namespace ns3
44{
45
46NS_OBJECT_ENSURE_REGISTERED(SatUtPhy);
47
48TypeId
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),
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)),
131 MakeTimeChecker());
132 return tid;
133}
134
139{
140 NS_LOG_FUNCTION(this);
141 NS_FATAL_ERROR("SatUtPhy default constructor is not allowed to be used");
142}
143
145 Ptr<SatLinkResults> linkResults,
146 SatPhyRxCarrierConf::RxCarrierCreateParams_s parameters,
147 Ptr<SatSuperframeConf> superFrameConf)
148 : SatPhy(params),
149 m_linkResults(linkResults),
150 m_parameters(parameters),
151 m_superFrameConf(superFrameConf),
153{
154 NS_LOG_FUNCTION(this << linkResults << superFrameConf);
155}
156
157void
159{
160 NS_LOG_FUNCTION(this);
161
163
165
167 m_parameters.m_aciIfWrtNoiseFactor = 0.0;
168 m_parameters.m_extNoiseDensityWhz = 0.0;
170 m_parameters.m_linkRegenerationMode =
171 Singleton<SatTopology>::Get()->GetForwardLinkRegenerationMode();
173
174 Ptr<SatPhyRxCarrierConf> carrierConf = CreateObject<SatPhyRxCarrierConf>(m_parameters);
175
176 if (m_linkResults)
177 {
178 carrierConf->SetLinkResults(m_linkResults);
179 }
180
181 carrierConf->SetAdditionalInterferenceCb(
182 MakeCallback(&SatUtPhy::GetAdditionalInterference, this));
183
185}
186
188{
189 NS_LOG_FUNCTION(this);
190}
191
192void
194{
195 NS_LOG_FUNCTION(this);
196 Object::DoDispose();
197}
198
199void
201{
202 NS_LOG_FUNCTION(this);
203 Object::DoInitialize();
204}
205
206double
208{
209 NS_LOG_FUNCTION(this);
210
212}
213
214void
215SatUtPhy::PerformHandover(uint32_t satId, uint32_t beamId)
216{
217 NS_LOG_FUNCTION(this << beamId);
218
219 // disconnect current SatChannels
221 m_phyTx->ClearChannel();
222 channels.first->RemoveRx(m_phyRx);
223
224 // perform "physical" beam handover
225 SetSatId(satId);
226 SetBeamId(beamId);
228}
229
230void
232{
233 NS_LOG_FUNCTION(this);
234
235 // Fetch channels for current beam
237 Ptr<SatChannel> forwardLink = channels.first;
238 Ptr<SatChannel> returnLink = channels.second;
239
240 // Assign channels
241 NS_LOG_INFO("Setting new Tx on channel " << returnLink);
242 m_phyTx->SetChannel(returnLink);
243 forwardLink->AddRx(m_phyRx);
244}
245
251
257
258bool
260{
261 NS_LOG_FUNCTION(this);
262 return m_phyTx->CanTransmit();
263}
264
265void
266SatUtPhy::Receive(Ptr<SatSignalParameters> rxParams, bool phyError)
267{
268 NS_LOG_FUNCTION(this << rxParams << phyError);
269
270 uint8_t slice = rxParams->m_txInfo.sliceId;
271
272 if (rxParams->m_txInfo.frameType == SatEnums::DUMMY_FRAME)
273 {
274 NS_LOG_INFO("Dummy frame receive, it is not decoded");
275 }
276 else if ((slice == 0) || (m_slicesSubscribed.count(slice) != 0))
277
278 {
279 // Slice is zero or is in the subscription list, we decode and forward to upper layers
280 SatPhy::Receive(rxParams, phyError);
281 }
282 else
283 {
284 NS_LOG_INFO("Slice of BBFrame (" << (uint32_t)slice
285 << ") not in list of subscriptions: BBFrame dropped");
286 }
287}
288
289void
291{
292 if (slice == 0)
293 {
294 m_slicesSubscribed.clear();
295 }
296 else
297 {
298 m_slicesSubscribed.insert(slice);
299 }
300}
301
302} // namespace ns3
std::pair< Ptr< SatChannel >, Ptr< SatChannel > > ChannelPair_t
SatLinkDir_t
Link direction used for packet tracing.
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.
virtual void NotifyConstructionCompleted() override
Notifier called once the ObjectBase is fully constructed.
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.
SatPhy(void)
Default constructor.
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.
The SatUtPhy models the physical layer of the User Terminal of the satellite system.
SatPhyRxCarrierConf::RxCarrierCreateParams_s m_parameters
RX carrier configuration parameters.
double m_otherSysInterferenceCOverIDb
Configured other system interference in dB.
virtual void NotifyConstructionCompleted() override
Notifier called once the ObjectBase is fully constructed.
static TypeId GetTypeId(void)
inherited from Object
virtual ~SatUtPhy()
Destructor.
virtual double GetAdditionalInterference()
Get additional interference, used to compute final SINR at RX.
Ptr< SatSuperframeConf > m_superFrameConf
Super frame cofiguration.
Ptr< SatLinkResults > m_linkResults
Link results used for this physical layer.
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.
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.