satellite-phy-rx-carrier.h
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 #ifndef SATELLITE_PHY_RX_CARRIER_H
24 #define SATELLITE_PHY_RX_CARRIER_H
25 
26 #include "satellite-enums.h"
28 #include "satellite-interference.h"
30 #include "satellite-phy-rx.h"
31 #include "satellite-phy.h"
32 #include "satellite-utils.h"
34 
35 #include <ns3/mac48-address.h>
36 #include <ns3/object.h>
37 #include <ns3/ptr.h>
38 #include <ns3/traced-callback.h>
39 
40 #include <deque>
41 #include <list>
42 #include <map>
43 #include <vector>
44 
45 namespace ns3
46 {
47 
48 class Address;
49 class SatPhy;
50 class SatSignalParameters;
51 class SatLinkResults;
52 class SatChannelEstimationErrorContainer;
53 class SatNodeInfo;
54 
60 class SatPhyRxCarrier : public Object
61 {
62  public:
66  typedef struct
67  {
68  Ptr<SatSignalParameters> rxParams;
69  Mac48Address destAddress;
70  Mac48Address sourceAddress;
71  Mac48Address finalDestAddress;
72  Mac48Address finalSourceAddress;
73  Ptr<SatInterference::InterferenceChangeEvent> interferenceEvent;
74  } rxParams_s;
75 
84  typedef void (*LinkBudgetTraceCallback)(Ptr<SatSignalParameters> rxParams,
85  Mac48Address receiverAddress,
86  Mac48Address destinationAddress,
87  double interference,
88  double sinr);
89 
95  typedef void (*RxPowerTraceCallback)(double rxPower, const Address& utAddress);
96 
102  typedef void (*LinkSinrTraceCallback)(double sinr, const Address& utAddress);
103 
111  typedef void (*PhyRxErrorCallback)(uint32_t nPackets, const Address& utAddress, bool isError);
112 
120  typedef void (*PhyRxCollisionCallback)(uint32_t nPackets,
121  const Address& utAddress,
122  bool isCollided);
123 
131  SatPhyRxCarrier(uint32_t carrierId,
132  Ptr<SatPhyRxCarrierConf> carrierConf,
133  Ptr<SatWaveformConf> waveformConf,
134  bool isRandomAccessEnabled);
135 
139  virtual ~SatPhyRxCarrier();
140 
144  enum State
145  {
147  RX
148  };
149 
154  {
159  RA_ESSA
160  };
161 
166  static TypeId GetTypeId(void);
167 
172  void SetPhy(Ptr<SatPhy> phy);
173 
178  inline void SetSatId(uint32_t satId)
179  {
180  m_satId = satId;
181  }
182 
187  inline uint32_t GetSatId()
188  {
189  return m_satId;
190  }
191 
196  inline void SetBeamId(uint32_t beamId)
197  {
198  m_beamId = beamId;
199  }
200 
205  inline uint32_t GetBeamId()
206  {
207  return m_beamId;
208  }
209 
214  void SetNodeInfo(const Ptr<SatNodeInfo> nodeInfo);
215 
221  virtual bool StartRx(Ptr<SatSignalParameters> rxParams);
222 
226  inline virtual CarrierType GetCarrierType()
227  {
228  return BASE;
229  }
230 
234  virtual void BeginEndScheduling();
235 
237 
243 
249 
256 
261  {
262  return m_rxTemperatureK;
263  }
264 
265  protected:
271  inline virtual const bool GetDefaultReceiveMode()
272  {
273  return false;
274  }
275 
281  {
283  }
284 
289  inline Ptr<SatInterference> GetInterferenceModel()
290  {
291  return m_satInterference;
292  }
293 
298  inline Ptr<SatInterferenceElimination> GetInterferenceEliminationModel()
299  {
301  }
302 
309  virtual Ptr<SatInterference::InterferenceChangeEvent> CreateInterference(
310  Ptr<SatSignalParameters> rxParams,
311  Address rxAddress) = 0;
312 
323  std::pair<bool, SatPhyRxCarrier::rxParams_s> GetReceiveParams(
324  Ptr<SatSignalParameters> rxParams);
325 
327  inline rxParams_s GetStoredRxParams(uint32_t key)
328  {
329  return m_rxParamsMap[key];
330  }
331 
333  inline void StoreRxParams(uint32_t key, rxParams_s rxParams)
334  {
335  m_rxParamsMap[key] = rxParams;
336  }
337 
339  inline void RemoveStoredRxParams(uint32_t key)
340  {
341  m_rxParamsMap.erase(key);
342  }
343 
348  inline Mac48Address GetOwnAddress()
349  {
350  return m_ownAddress;
351  }
352 
357  inline Ptr<SatNodeInfo> GetNodeInfo()
358  {
359  return m_nodeInfo;
360  }
361 
366  void DoCompositeSinrOutputTrace(double cSinr);
367 
375  virtual void DoCreateInterferenceModel(Ptr<SatPhyRxCarrierConf> carrierConf,
376  uint32_t carrierId,
377  double rxBandwidthHz);
378 
385  virtual void DoCreateInterferenceEliminationModel(Ptr<SatPhyRxCarrierConf> carrierConf,
386  uint32_t carrierId,
387  Ptr<SatWaveformConf> waveformConf);
388 
395  {
396  return m_channelType;
397  }
398 
403  inline void SetChannelType(SatEnums::ChannelType_t channelType)
404  {
405  m_channelType = channelType;
406  }
407 
413  {
414  return m_linkRegenerationMode;
415  }
416 
421  inline void SetLinkRegenerationMode(SatEnums::RegenerationMode_t linkRegenerationMode)
422  {
423  m_linkRegenerationMode = linkRegenerationMode;
424  }
425 
430  void ChangeState(State newState);
431 
436  inline State GetState()
437  {
438  return m_state;
439  }
440 
447  bool CheckAgainstLinkResults(double cSinr, Ptr<SatSignalParameters> rxParams);
448 
453  virtual void EndRxData(uint32_t key) = 0;
454 
459 
463  virtual void DoDispose();
464 
475  double CalculateSinr(double rxPowerW,
476  double ifPowerW,
477  double rxNoisePowerW,
478  double rxAciIfPowerW,
479  double rxExtNoisePowerW,
480  double otherInterference);
481 
490  double CalculateSinr(double sinr, double otherInterference);
491 
498  double CalculateCompositeSinr(double sinr1, double sinr2);
499 
506  double GetWorstSinr(double sinr1, double sinr2);
507 
513 
519 
523  void CheckRxStateSanity();
524 
529  inline uint32_t GetCarrierId() const
530  {
531  return m_carrierId;
532  }
533 
539  inline Ptr<SatLinkResults> GetLinkResults()
540  {
541  return m_linkResults;
542  }
543 
548  inline Ptr<SatWaveformConf> GetWaveformConf()
549  {
550  return m_waveformConf;
551  }
552 
557  inline Ptr<SatChannelEstimationErrorContainer> GetChannelEstimationErrorContainer()
558  {
560  }
561 
566  {
568  }
569 
576  inline double GetUniformRandomValue(double min, double max)
577  {
578  return m_uniformVariable->GetValue(min, max);
579  }
580 
582 
586 
591 
596 
601 
606 
611 
613 
618  TracedCallback<Ptr<SatSignalParameters>, // RX signalling parameters
619  Mac48Address, // receiver address
620  Mac48Address, // packet destination address
621  double, // interference power
622  double // composite SINR
623  >
625 
630  TracedCallback<double, const Address&> m_rxPowerTrace;
631 
639  TracedCallback<double, const Address&> m_sinrTrace;
640 
645  TracedCallback<double, const Address&> m_linkSinrTrace;
646 
648 
659  TracedCallback<uint32_t, const Address&, bool> m_daRxTrace;
660 
661  TracedCallback<uint32_t, const Address&> m_daRxCarrierIdTrace;
662 
667 
672 
677 
682 
683  private:
690  bool CheckAgainstLinkResultsErrorModelAvi(double cSinr, Ptr<SatSignalParameters> rxParams);
691 
692  State m_state; //< Current state of the carrier
693  uint32_t m_satId; //< Satellite ID
694  uint32_t m_beamId; //< Beam ID
695  uint32_t m_carrierId; //< Carrier ID
696  bool m_receivingDedicatedAccess; //< Is the carrier receiving a dedicated access packet
697  Ptr<SatInterference> m_satInterference; //< Interference model
698  Ptr<SatInterferenceElimination> m_satInterferenceElimination; //< Interference model
699  bool m_enableCompositeSinrOutputTrace; //< Enable composite SINR output tracing
700 
705 
710 
711  std::map<uint32_t, rxParams_s> m_rxParamsMap; //< Storage for Rx parameters by ID
712  Mac48Address m_ownAddress; //< Carrier address
713  Ptr<SatNodeInfo> m_nodeInfo; //< NodeInfo of the node where carrier is attached
715  Ptr<SatLinkResults> m_linkResults; //< Link results from the carrier configuration
716  Ptr<SatWaveformConf> m_waveformConf; //< Waveform configuration
717  Ptr<UniformRandomVariable> m_uniformVariable; //< Uniform helper random variable
719  double m_constantErrorRate; //< Error rate for constant error model
720 
724  Ptr<SatChannelEstimationErrorContainer> m_channelEstimationError;
725 };
726 
727 } // namespace ns3
728 
729 #endif /* SATELLITE_PHY_RX_CARRIER_H */
ChannelType_t
Types of channel.
PacketType_t
Packet types.
RegenerationMode_t
The regeneration mode used in satellites.
Callback< void, uint32_t, uint32_t, Address, Address, double, bool > CnoCallback
Definition: satellite-phy.h:93
Callback< void, uint32_t, uint32_t, uint32_t, uint8_t, double > AverageNormalizedOfferedLoadCallback
Callback< double > AdditionalInterferenceCallback
Callback to get additional interference from PHY layer.
Base class for all SatPhyRxCarriers.
void SetPhy(Ptr< SatPhy > phy)
Function for setting the SatPhy module.
SatPhy::AverageNormalizedOfferedLoadCallback m_avgNormalizedOfferedLoadCallback
Average normalized offered load callback.
void SetNodeInfo(const Ptr< SatNodeInfo > nodeInfo)
Function for setting the node info class.
Ptr< SatInterference > GetInterferenceModel()
Get pointer to the current interference model.
void DoCompositeSinrOutputTrace(double cSinr)
Function for composite SINR output tracing.
void RemoveStoredRxParams(uint32_t key)
Remove stored rxParams under a key.
double m_rxExtNoisePowerW
External noise power system RX noise.
void SetLinkRegenerationMode(SatEnums::RegenerationMode_t linkRegenerationMode)
Set the link regeneration mode.
void CheckRxStateSanity()
Function for checking the Rx state sanity.
void SetCnoCb(SatPhyRx::CnoCallback cb)
Function for settign the C/NO callback.
TracedCallback< double, const Address & > m_linkSinrTrace
A callback for link specific SINR in dB.
Ptr< SatInterferenceElimination > m_satInterferenceElimination
static TypeId GetTypeId(void)
Function for gettign the NS-3 type ID.
TracedCallback< uint32_t, const Address & > m_daRxCarrierIdTrace
TracedCallback< Ptr< SatSignalParameters >, Mac48Address, Mac48Address, double, double > m_linkBudgetTrace
The trace source on packet receptiong.
void SetAverageNormalizedOfferedLoadCallback(SatPhyRx::AverageNormalizedOfferedLoadCallback callback)
Function for setting the AverageNormalizedOfferedLoadCallback callback.
Ptr< SatNodeInfo > GetNodeInfo()
Get the satellite node info.
SatPhyRxCarrierConf::AdditionalInterferenceCallback m_additionalInterferenceCallback
Callback to get additional interference.
TracedCallback< double, const Address & > m_rxPowerTrace
A callback for received signal power in dBW.
uint32_t GetCarrierId() const
Get the ID of the carrier.
void DecreaseNumOfRxState(SatEnums::PacketType_t packetType)
Function for decreasing the number of ongoing transmissions.
virtual SatEnums::RegenerationMode_t GetLinkRegenerationMode()
Get the link regeneration mode.
void SetBeamId(uint32_t beamId)
Function for setting the beam id for all the transmissions from this SatPhyTx.
Ptr< SatWaveformConf > m_waveformConf
CarrierType
Possible carrier types.
virtual Ptr< SatInterference::InterferenceChangeEvent > CreateInterference(Ptr< SatSignalParameters > rxParams, Address rxAddress)=0
Create an interference event based on Rx parameters and address.
Ptr< SatLinkResults > m_linkResults
virtual SatEnums::ChannelType_t GetChannelType()
Get the channel type.
bool IsCompositeSinrOutputTraceEnabled() const
Check if composite SINR output trace is enabled.
uint32_t GetBeamId()
Get ID the ID of the beam this carrier is attached to.
virtual void DoCreateInterferenceEliminationModel(Ptr< SatPhyRxCarrierConf > carrierConf, uint32_t carrierId, Ptr< SatWaveformConf > waveformConf)
Create an interference cancelation model for this carrier.
std::map< uint32_t, rxParams_s > m_rxParamsMap
double CalculateSinr(double rxPowerW, double ifPowerW, double rxNoisePowerW, double rxAciIfPowerW, double rxExtNoisePowerW, double otherInterference)
Function for calculating the SINR.
SatPhyRx::ReceiveCallback m_rxCallback
The upper layer package receive callback.
TracedCallback< uint32_t, const Address &, bool > m_daRxTrace
DaRx trace source.
double m_rxAciIfPowerW
RX Adjacent channel interference.
void(* RxPowerTraceCallback)(double rxPower, const Address &utAddress)
Callback signature for RxPowerTrace trace source.
virtual bool StartRx(Ptr< SatSignalParameters > rxParams)
Function for starting packet reception from the SatChannel.
TracedCallback< double, const Address & > m_sinrTrace
A callback for transmission composite SINR at UT (BBFrame) or GW (time slot).
void(* PhyRxCollisionCallback)(uint32_t nPackets, const Address &utAddress, bool isCollided)
Common callback signature for trace sources related to packets reception by PHY and its collision.
Ptr< SatChannelEstimationErrorContainer > m_channelEstimationError
Channel estimation error container.
rxParams_s GetStoredRxParams(uint32_t key)
Get stored rxParams under a key.
bool IsReceivingDedicatedAccess()
Check if the carrier is receiving a dedicated access packet.
Ptr< SatChannelEstimationErrorContainer > GetChannelEstimationErrorContainer()
Get a pointer to the channel estimation error container of the carrier.
void SetReceiveCb(SatPhyRx::ReceiveCallback cb)
Function for setting the receive callback.
bool CheckAgainstLinkResults(double cSinr, Ptr< SatSignalParameters > rxParams)
Function for checking the SINR against the link results.
SatPhy::CnoCallback m_cnoCallback
The upper layer C/N0 receive callback.
bool CheckAgainstLinkResultsErrorModelAvi(double cSinr, Ptr< SatSignalParameters > rxParams)
Function for checking the SINR against the link results.
virtual void DoCreateInterferenceModel(Ptr< SatPhyRxCarrierConf > carrierConf, uint32_t carrierId, double rxBandwidthHz)
Create an interference model for this carrier.
double CalculateCompositeSinr(double sinr1, double sinr2)
Function for calculating the composite SINR.
double GetWorstSinr(double sinr1, double sinr2)
Function for calculating the worst sinr between uplink and downlink.
SatPhyRxCarrierConf::ErrorModel m_errorModel
uint32_t m_numOfOngoingRx
Contains information about how many ongoing Rx events there are.
const bool m_randomAccessEnabled
Is random access enabled for this carrier.
virtual void BeginEndScheduling()
Function for initializing the frame/window end scheduling.
Ptr< SatInterferenceElimination > GetInterferenceEliminationModel()
Get pointer to the current interference elimination model.
virtual void DoDispose()
Dispose.
double GetUniformRandomValue(double min, double max)
A helper method for getting values form a uniform random variable in child classes.
void(* LinkBudgetTraceCallback)(Ptr< SatSignalParameters > rxParams, Mac48Address receiverAddress, Mac48Address destinationAddress, double interference, double sinr)
Callback signature for LinkBudgetTrace trace source.
void ChangeState(State newState)
Function for changing the receiver state.
SatPhyRxCarrier(uint32_t carrierId, Ptr< SatPhyRxCarrierConf > carrierConf, Ptr< SatWaveformConf > waveformConf, bool isRandomAccessEnabled)
Constructor.
void SetChannelType(SatEnums::ChannelType_t channelType)
Set the channel type for the carrier.
void SetSatId(uint32_t satId)
Function for setting the satellite id for all the transmissions from this SatPhyTx.
virtual CarrierType GetCarrierType()
Method for querying the type of the carrier.
Ptr< UniformRandomVariable > m_uniformVariable
Ptr< SatInterference > m_satInterference
SatEnums::RegenerationMode_t m_linkRegenerationMode
Link regeneration mode.
virtual const bool GetDefaultReceiveMode()
Get the default receive mode for the carrier.
std::pair< bool, SatPhyRxCarrier::rxParams_s > GetReceiveParams(Ptr< SatSignalParameters > rxParams)
Rx parameter storage methods.
Ptr< SatWaveformConf > GetWaveformConf()
Get pointer to the waveform configuration.
Ptr< SatLinkResults > GetLinkResults()
Get pointer to the link results given by the carrier creation configuration.
virtual void EndRxData(uint32_t key)=0
Function for ending the packet reception from the SatChannel.
void IncreaseNumOfRxState(SatEnums::PacketType_t packetType)
Function for increasing the number of ongoing transmissions.
uint32_t m_rxPacketCounter
Running counter for received packets.
virtual ~SatPhyRxCarrier()
Destructor.
double GetRxTemperatureK()
Method for querying the temperature of the carrier.
uint32_t GetSatId()
Get ID the ID of the satellite this carrier is attached to.
SatEnums::ChannelType_t m_channelType
void(* PhyRxErrorCallback)(uint32_t nPackets, const Address &utAddress, bool isError)
Common callback signature for trace sources related to packets reception by PHY and its error.
double m_rxBandwidthHz
RX Bandwidth in Hz.
State GetState()
Get the state of the carrier.
void(* LinkSinrTraceCallback)(double sinr, const Address &utAddress)
Callback signature for LinkSinrTrace trace source.
void StoreRxParams(uint32_t key, rxParams_s rxParams)
Store rxParams under a key.
Mac48Address GetOwnAddress()
Get the MAC address of the carrier.
double m_rxTemperatureK
RX noise temperature in K.
Callback< void, uint32_t, uint32_t, Address, Address, double, bool > CnoCallback
Callback< void, Ptr< SatSignalParameters >, bool > ReceiveCallback
Callback< void, uint32_t, uint32_t, uint32_t, uint8_t, double > AverageNormalizedOfferedLoadCallback
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
Struct for storing the packet specific Rx parameters.
Ptr< SatInterference::InterferenceChangeEvent > interferenceEvent