satellite-gw-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  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Sami Rantanen <sami.rantanen@magister.fi>
19  */
20 
21 #include "satellite-gw-phy.h"
22 
24 #include "satellite-channel.h"
25 #include "satellite-mac.h"
26 #include "satellite-phy-rx.h"
27 #include "satellite-phy-tx.h"
29 #include "satellite-topology.h"
30 #include "satellite-utils.h"
31 
32 #include <ns3/double.h>
33 #include <ns3/log.h>
34 #include <ns3/pointer.h>
35 #include <ns3/simulator.h>
36 #include <ns3/singleton.h>
37 #include <ns3/uinteger.h>
38 
39 NS_LOG_COMPONENT_DEFINE("SatGwPhy");
40 
41 namespace ns3
42 {
43 
44 NS_OBJECT_ENSURE_REGISTERED(SatGwPhy);
45 
46 TypeId
48 {
49  static TypeId tid =
50  TypeId("ns3::SatGwPhy")
51  .SetParent<SatPhy>()
52  .AddConstructor<SatGwPhy>()
53  .AddAttribute("PhyRx",
54  "The PhyRx layer attached to this phy.",
55  PointerValue(),
56  MakePointerAccessor(&SatPhy::GetPhyRx, &SatPhy::SetPhyRx),
57  MakePointerChecker<SatPhyRx>())
58  .AddAttribute("PhyTx",
59  "The PhyTx layer attached to this phy.",
60  PointerValue(),
61  MakePointerAccessor(&SatPhy::GetPhyTx, &SatPhy::SetPhyTx),
62  MakePointerChecker<SatPhyTx>())
63  .AddAttribute("RxTemperatureDbk",
64  "RX noise temperature in GW in dBK.",
65  DoubleValue(24.62), // ~290K
66  MakeDoubleAccessor(&SatPhy::GetRxNoiseTemperatureDbk,
68  MakeDoubleChecker<double>())
69  .AddAttribute(
70  "RxMaxAntennaGainDb",
71  "Maximum RX gain in dB",
72  DoubleValue(61.50),
74  MakeDoubleChecker<double_t>())
75  .AddAttribute(
76  "TxMaxAntennaGainDb",
77  "Maximum TX gain in dB",
78  DoubleValue(65.20),
80  MakeDoubleChecker<double_t>())
81  .AddAttribute("TxMaxPowerDbw",
82  "Maximum TX power in dB",
83  DoubleValue(8.97),
85  MakeDoubleChecker<double>())
86  .AddAttribute(
87  "TxOutputLossDb",
88  "TX Output loss in dB",
89  DoubleValue(2.00),
91  MakeDoubleChecker<double>())
92  .AddAttribute(
93  "TxPointingLossDb",
94  "TX Pointing loss in dB",
95  DoubleValue(1.10),
97  MakeDoubleChecker<double>())
98  .AddAttribute("TxOboLossDb",
99  "TX OBO loss in dB",
100  DoubleValue(6.00),
101  MakeDoubleAccessor(&SatPhy::GetTxOboLossDb, &SatPhy::SetTxOboLossDb),
102  MakeDoubleChecker<double>())
103  .AddAttribute(
104  "TxAntennaLossDb",
105  "TX Antenna loss in dB",
106  DoubleValue(0.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("ImIfCOverIDb",
121  "Intermodulation interference, C over I in dB.",
122  DoubleValue(22.0),
123  MakeDoubleAccessor(&SatGwPhy::m_imInterferenceCOverIDb),
124  MakeDoubleChecker<double>())
125  .AddAttribute("AciIfWrtNoisePercent",
126  "Adjacent channel interference wrt white noise in percents.",
127  DoubleValue(10.0),
128  MakeDoubleAccessor(&SatGwPhy::m_aciIfWrtNoisePercent),
129  MakeDoubleChecker<double>(0, 100))
130  .AddAttribute("AntennaReconfigurationDelay",
131  "Delay of antenna reconfiguration when performing handover",
132  TimeValue(Seconds(0.0)),
133  MakeTimeAccessor(&SatGwPhy::m_antennaReconfigurationDelay),
134  MakeTimeChecker());
135  return tid;
136 }
137 
138 TypeId
140 {
141  NS_LOG_FUNCTION(this);
142 
143  return GetTypeId();
144 }
145 
147  : m_aciIfWrtNoisePercent(10.0),
148  m_imInterferenceCOverIDb(22.0),
149  m_imInterferenceCOverI(SatUtils::DbToLinear(m_imInterferenceCOverIDb)),
150  m_antennaReconfigurationDelay(Seconds(0.0))
151 {
152  NS_LOG_FUNCTION(this);
153  NS_FATAL_ERROR("SatGwPhy default constructor is not allowed to use");
154 }
155 
157  Ptr<SatLinkResults> linkResults,
158  SatPhyRxCarrierConf::RxCarrierCreateParams_s parameters,
159  Ptr<SatSuperframeConf> superFrameConf)
160  : SatPhy(params),
161  m_aciIfWrtNoisePercent(10.0),
162  m_imInterferenceCOverIDb(22.0),
163  m_imInterferenceCOverI(SatUtils::DbToLinear(m_imInterferenceCOverIDb)),
164  m_antennaReconfigurationDelay(Seconds(0.0))
165 {
166  NS_LOG_FUNCTION(this);
167 
168  ObjectBase::ConstructSelf(AttributeConstructionList());
169 
171 
172  parameters.m_rxTemperatureK = SatUtils::DbToLinear(SatPhy::GetRxNoiseTemperatureDbk());
173  parameters.m_aciIfWrtNoiseFactor = m_aciIfWrtNoisePercent / 100.0;
174  parameters.m_extNoiseDensityWhz = 0.0;
175  parameters.m_rxMode = SatPhyRxCarrierConf::NORMAL;
176  parameters.m_linkRegenerationMode =
177  Singleton<SatTopology>::Get()->GetReturnLinkRegenerationMode();
178  parameters.m_chType = SatEnums::RETURN_FEEDER_CH;
179 
180  Ptr<SatPhyRxCarrierConf> carrierConf = CreateObject<SatPhyRxCarrierConf>(parameters);
181 
182  if (linkResults)
183  {
184  carrierConf->SetLinkResults(linkResults);
185  }
186 
187  carrierConf->SetAdditionalInterferenceCb(
188  MakeCallback(&SatGwPhy::GetAdditionalInterference, this));
189 
190  SatPhy::ConfigureRxCarriers(carrierConf, superFrameConf);
191 }
192 
194 {
195  NS_LOG_FUNCTION(this);
196 }
197 
198 void
200 {
201  NS_LOG_FUNCTION(this);
203 }
204 
205 void
207 {
208  NS_LOG_FUNCTION(this);
210 }
211 
212 double
214 {
215  NS_LOG_FUNCTION(this);
216 
217  return m_imInterferenceCOverI;
218 }
219 
222 {
223  return SatEnums::LD_FORWARD;
224 }
225 
228 {
229  return SatEnums::LD_RETURN;
230 }
231 
232 void
233 SatGwPhy::PerformHandover(uint32_t satId, uint32_t beamId)
234 {
235  NS_LOG_FUNCTION(this << satId << beamId);
236 
237  // disconnect current SatChannels
239  Ptr<SatChannel> returnLink = channels.second;
240  m_phyTx->ClearChannel();
241  returnLink->RemoveRx(m_phyRx);
242 
243  // perform "physical" beam handover
244  SetSatId(satId);
245  SetBeamId(beamId);
247 }
248 
249 void
251 {
252  NS_LOG_FUNCTION(this);
253 
254  // Fetch channels for current beam
256  Ptr<SatChannel> forwardLink = channels.first;
257  Ptr<SatChannel> returnLink = channels.second;
258 
259  // Assign channels
260  NS_LOG_INFO("Setting new Tx on channel " << forwardLink);
261  m_phyTx->SetChannel(forwardLink);
262  returnLink->AddRx(m_phyRx);
263 }
264 
265 } // namespace ns3
std::pair< Ptr< SatChannel >, Ptr< SatChannel > > ChannelPair_t
SatLinkDir_t
Link direction used for packet tracing.
TypeId GetInstanceTypeId(void) const
virtual double GetAdditionalInterference()
Get additional interference, used to compute final SINR at RX.
double m_imInterferenceCOverI
Intermodulation interference in linear.
SatGwPhy(void)
Default constructor.
virtual void DoInitialize(void)
Initialization of SatPhy.
double m_aciIfWrtNoisePercent
Configured adjacent channel interference wrt noise (percent).
virtual void DoDispose(void)
Dispose of this class instance.
void PerformHandover(uint32_t satId, uint32_t beamId)
Change underlying SatChannel to send and receive data from a new satellite and beam.
virtual ~SatGwPhy()
Destructor for SatGwPhy.
void AssignNewSatChannels()
Update the underlying SatChannel to send and receive data from the current beam (as described in the ...
double m_imInterferenceCOverIDb
Configured intermodulation interference in dB.
Time m_antennaReconfigurationDelay
Delay of antenna reconfiguration when performing handover.
virtual SatEnums::SatLinkDir_t GetSatLinkTxDir()
Get the link TX direction.
virtual SatEnums::SatLinkDir_t GetSatLinkRxDir()
Get the link RX direction.
static TypeId GetTypeId(void)
inherited from Object
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.
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.
virtual void DoDispose(void)
Dispose of SatPhy.
void SetTxAntennaLossDb(double lossDb)
Set the antenna loss of the transmitter in dB.
virtual void SetPhyRx(Ptr< SatPhyRx > phyRx)
Set the SatPhyRx module.
virtual void DoInitialize(void)
Initialization of SatPhy.
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.
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.