5#ifndef NR_SPECTRUM_PHY_H
6#define NR_SPECTRUM_PHY_H
8#include "beam-manager.h"
9#include "nr-chunk-processor.h"
10#include "nr-control-messages.h"
11#include "nr-harq-phy.h"
12#include "nr-interference.h"
14#include "nr-spectrum-signal-parameters.h"
16#include "ns3/matrix-based-channel-model.h"
17#include "ns3/net-device.h"
18#include "ns3/random-variable-stream.h"
19#include "ns3/spectrum-channel.h"
20#include "ns3/traced-callback.h"
27class UniformPlanarArray;
112 typedef std::function<void(
const std::list<Ptr<NrControlMessage>>&, uint8_t)>
161 void SetDevice(Ptr<NetDevice> d)
override;
162 Ptr<NetDevice> GetDevice()
const override;
163 void SetMobility(Ptr<MobilityModel> m)
override;
164 Ptr<MobilityModel> GetMobility()
const override;
165 void SetChannel(Ptr<SpectrumChannel> c)
override;
166 Ptr<const SpectrumModel> GetRxSpectrumModel()
const override;
171 void SetBeamManager(Ptr<BeamManager> b);
194 uint8_t panelIndex)
const;
199 Ptr<BeamManager> GetBeamManager();
207 void SetErrorModel(Ptr<NrErrorModel> em);
213 Ptr<NrErrorModel> GetErrorModel()
const;
219 Ptr<NrPhy> GetNrPhy()
const;
225 Time GetFirstRxStart()
const;
231 void SetFirstRxStart(Time startTime);
237 Time GetFirstRxDuration()
const;
243 void SetFirstRxDuration(Time duration);
271 void EnableDlDataPathlossTrace();
276 void EnableDlCtrlPathlossTrace();
283 void StartRx(Ptr<SpectrumSignalParameters> params)
override;
339 Ptr<const SpectrumValue> GetTxPowerSpectralDensity();
348 const std::list<Ptr<NrControlMessage>>& ctrlMsgList,
349 const std::shared_ptr<DciInfoElementTdma> dci,
350 const Time& duration);
362 const Time& duration);
377 const Time& duration);
393 void AddSrsSinrChunkProcessor(
const Ptr<NrChunkProcessor>& p);
439 Ptr<NrPhy> GetPhy()
const;
452 void AddPanel(
const Ptr<Object> antenna);
493 Ptr<const SpectrumValue> v,
498 void AddExpectedSrsRnti(uint16_t rnti);
509 typedef Callback<void, uint16_t, uint16_t, double> SrsSinrReportCallback;
510 typedef Callback<void, uint16_t, uint16_t, double> SrsSnrReportCallback;
546 const uint16_t cellId,
637 Ptr<const SpectrumValue> spectrumValue,
638 const Time& duration,
640 uint16_t cellId)
const;
655 std::vector<MimoSinrChunk>
663 void StartRxData(
const Ptr<NrSpectrumSignalParametersDataFrame>& params);
668 void StartRxDlCtrl(
const Ptr<NrSpectrumSignalParametersDlCtrlFrame>& params);
673 void StartRxUlCtrl(
const Ptr<NrSpectrumSignalParametersUlCtrlFrame>& params);
678 void StartRxCsiRs(
const Ptr<NrSpectrumSignalParametersCsiRs>& csiRsParams);
684 void StartRxSrs(
const Ptr<NrSpectrumSignalParametersUlCtrlFrame>& params);
690 void CheckIfCsiImNeeded(
const Ptr<NrSpectrumSignalParametersCsiRs>& csiRsParams);
697 std::vector<MimoSinrChunk> GetMimoSinrForRnti(uint16_t rnti, uint8_t rank);
709 void ScheduleCsiIm(Ptr<SpectrumSignalParameters> csiRsParams)
const;
713 bool IsUeScheduled()
const;
737 void CheckIfStillBusy();
745 bool IsOnlySrs(
const std::list<Ptr<NrControlMessage>>& ctrlMsgList);
754 Ptr<MatrixBasedChannelModel::Complex3DVector> CreateSpectrumChannelMatrix(
755 const Ptr<SpectrumSignalParameters> params)
const;
760 void CheckTransportBlockCorruptionStatus();
768 void ProcessReceivedPacketBurst();
786 TypeId m_errorModelType{
787 Object::GetTypeId()};
788 bool m_dataErrorModelEnabled{
790 double m_ccaMode1ThresholdW{0};
793 bool m_unlicensedMode{
798 Ptr<SpectrumChannel> m_channel{
801 Ptr<const SpectrumModel> m_rxSpectrumModel{
803 std::vector<Ptr<BeamManager>> m_beamManagers;
805 Ptr<MobilityModel> m_mobility{
807 Ptr<NetDevice> m_device{
nullptr};
808 Ptr<NrPhy> m_phy{
nullptr};
809 Ptr<NrErrorModel> m_errorModel{
nullptr};
810 std::vector<Ptr<Object>>
813 Ptr<NrInterference> m_interferenceData{
nullptr};
815 Ptr<NrInterference> m_interferenceCtrl{
nullptr};
817 Ptr<NrInterference> m_interferenceSrs{
820 Ptr<NrInterference> m_interferenceCsiRs{
822 Ptr<NrInterference> m_interferenceCsiIm{
825 Ptr<SpectrumValue> m_txPsd{
nullptr};
826 Ptr<UniformRandomVariable> m_random{
nullptr};
828 NrHarqPhy m_harqPhyModule;
830 std::unordered_map<uint16_t, TransportBlockInfo>
833 std::list<Ptr<PacketBurst>> m_rxPacketBurstList;
834 std::list<Ptr<NrControlMessage>>
835 m_rxControlMessageList;
839 Time m_firstRxDuration{Seconds(0)};
841 SpectrumValue m_sinrPerceived;
845 bool m_hasRnti{
false};
846 uint16_t m_activeTransmissions{0};
849 std::list<SrsSinrReportCallback> m_srsSinrReportCallback;
850 std::list<SrsSnrReportCallback> m_srsSnrReportCallback;
851 uint16_t m_currentSrsRnti{0};
853 EventId m_checkIfIsIdleEvent;
860 m_phyRxCtrlEndOkCallback;
862 m_phyRxDataEndOkCallback;
865 m_phyDlHarqFeedbackCallback;
868 m_phyUlHarqFeedbackCallback;
874 TracedCallback<Time> m_txDataTrace;
876 TracedCallback<Time> m_txCtrlTrace;
878 TracedCallback<RxPacketTraceParams>
880 TracedCallback<RxPacketTraceParams>
882 TracedCallback<GnbPhyPacketCountParameter>
884 TracedCallback<const SfnSf&, Ptr<const SpectrumValue>,
const Time&, uint16_t, uint16_t>
886 TracedCallback<
const SfnSf,
897 typedef TracedCallback<uint16_t, uint8_t, uint32_t, double> DlPathlossTrace;
898 DlPathlossTrace m_dlCtrlPathlossTrace;
899 bool m_enableDlCtrlPathlossTrace =
912 typedef TracedCallback<uint16_t, uint8_t, uint32_t, double, uint8_t> DlDataPathlossTrace;
913 DlDataPathlossTrace m_dlDataPathlossTrace;
914 bool m_enableDlDataPathlossTrace =
916 double m_dlDataPathloss = 0;
918 bool m_isGnb =
false;
919 uint8_t m_numPanels{1};
920 uint8_t m_activePanelIndex{0};
Interface between the physical layer and the channel.
double CircularBearingAnglesForPanels(double firstPanelBearingAngleRad, uint8_t panelIndex) const
initialize the bearing angles of panels in to cover 360 Degree
void SetUnlicensedMode(bool unlicensedMode)
Sets whether to perform in unlicensed mode in which the channel monitoring is enabled.
void SetErrorModelType(TypeId errorModelType)
Sets the error model type.
void IncrementActiveTransmissions()
Increase the counter of active transmissions.
void NotifyTxCtrlTrace(Time duration) const
call TxCtrlTrace from subclass
void(* DataSnrTracedCallback)(const SfnSf &sfnSf, const uint16_t cellId, const uint8_t bwpId, const uint64_t imsi, const double snr)
void NotifyRxDataTrace(const SfnSf &sfn, Ptr< const SpectrumValue > spectrumValue, const Time &duration, uint16_t bwpId, uint16_t cellId) const
call RxDataTrace from subclass
Ptr< Object > GetPanelByIndex(const uint8_t index) const
Interface enable to access all panels using proper index.
void AddCsiRsMimoChunkProcessor(const Ptr< NrMimoChunkProcessor > &p)
Connect CSI-RS chunk processor with the corresponding CSI-RS interference object.
void UpdateSrsSnrPerceived(const double srsSnr)
SpectrumPhy that will be called when the SNR for the received SRS at gNB is being calculated.
void ReportWbDlDataSnrPerceived(const double dlDataSnr)
Report wideband perceived downlink data SNR.
void UpdateSinrPerceived(const SpectrumValue &sinr)
SpectrumPhy that will be called when the SINR for the received DATA is being calculated by the interf...
NrSpectrumPhy()
NrSpectrumPhy constructor.
void SetPhyRxCtrlEndOkCallback(const NrPhyRxCtrlEndOkCallback &c)
Sets the callback to be called when CTRL is received successfully.
static TypeId GetTypeId()
Get the object TypeId.
void StartTxUlControlFrames(const std::list< Ptr< NrControlMessage > > &ctrlMsgList, const Time &duration)
Start transmission of UL CTRL.
~NrSpectrumPhy() override
~NrSpectrumPhy
std::function< void(const std::list< Ptr< NrControlMessage > > &, uint8_t)> NrPhyRxCtrlEndOkCallback
This callback method type is used to notify that CTRL is received.
Ptr< UniformRandomVariable > GetErrorModelRv() const
Get pointer to error model random variable.
void AddSrsSnrReportCallback(SrsSnrReportCallback callback)
It adds callback to the list of callbacks that will be notified once SRS is being received.
void AddExpectedTb(ExpectedTb expectedTb)
Instruct the Spectrum Model of a incoming transmission.
void SetPhyDlHarqFeedbackCallback(const NrPhyDlHarqFeedbackCallback &c)
Sets the callback to be called when DL HARQ feedback is generated.
void AddBeamManager(Ptr< BeamManager > b)
Adds the beam manager of corresponds spectrum phy of antenna panel, and that beam manager is responsi...
void AddDataPowerChunkProcessor(const Ptr< NrChunkProcessor > &p)
Adds the chunk processor that will process the power for the data.
Ptr< NrInterference > GetNrInterference() const
void SetNumPanels(const uint8_t numPanel)
Set the number of panels in this NrSpectrumPhy.
uint8_t GetNumPanels() const
Get the number of panels in this NrSpectrumPhy.
void DoDispose() override
DoDispose method inherited from Object.
void UpdateSrsSinrPerceived(const SpectrumValue &srsSinr)
SpectrumPhy that will be called when the SINR for the received SRS at gNB is being calculated by the ...
Callback< void, const UlHarqInfo & > NrPhyUlHarqFeedbackCallback
virtual void SetNoisePowerSpectralDensity(const Ptr< const SpectrumValue > &noisePsd)
Sets noise power spectral density to be used by this device.
void SetCcaMode1Threshold(double thresholdDBm)
Set clear channel assessment (CCA) threshold.
void StartTxDlControlFrames(const std::list< Ptr< NrControlMessage > > &ctrlMsgList, const Time &duration)
Starts transmission of DL CTRL.
void InstallPhy(const Ptr< NrPhy > &phyModel)
Set NrPhy of this spectrum phy in order to be able to obtain information such as cellId,...
void SetRnti(uint16_t rnti)
void UpdateMimoSinrPerceived(const std::vector< MimoSinrChunk > &sinr)
Store the SINR chunks for all received signals at end of interference calculations.
bool IsTransmitting()
Return true if the current Phy State is TX.
void AddPanel(const Ptr< Object > antenna)
Add the antenna panel to this NrSpectrumPhy, currently in NR module it is expected to be of type Unif...
double GetCcaMode1Threshold() const
Callback< void, const DlHarqInfo & > NrPhyDlHarqFeedbackCallback
void AddCsiImMimoChunkProcessor(const Ptr< NrMimoChunkProcessor > &p)
Connect CSI-IM chunk processor with the corresponding CSI-IM interference object.
State GetState() const
Get current state.
void SetIsGnb(bool isGnb)
Set whether this spectrum PHY belongs to Gnb or UE TODO NrHelper should be declared as friend and thi...
void EndTx()
Function that is called when the transmission has ended. It is used to update spectrum phy state.
void AddDlCtrlSinrChunkProcessor(const Ptr< NrChunkProcessor > &p)
Adds the chunk processor that will process the received power.
Ptr< SpectrumChannel > GetChannel() const
Get pointer to SpectrumChannel.
int64_t AssignStreams(int64_t stream)
Ptr< SpectrumChannel > GetSpectrumChannel() const
Returns spectrum channel object to which is attached this spectrum phy instance.
void ConfigPanelsBearingAngles()
Either initialize the bearing angles of panels in install step or update all bearing angles based on ...
uint16_t GetCellId() const
void StartTxCsiRs(uint16_t rnti, uint16_t beamId)
Callback< void, uint16_t, const Ptr< SpectrumValue > & > NrPhyRxPssCallback
void SetDataErrorModelEnabled(bool dataErrorModelEnabled)
Enables or disabled data error model.
void SetPhyRxDataEndOkCallback(const NrPhyRxDataEndOkCallback &c)
Sets the callback to be called when DATA is received successfully.
void ReportDlCtrlSinr(const SpectrumValue &sinr)
Called when DlCtrlSinr is fired.
void AddExpectedDlCtrlEnd(Time ctrlEndTime)
Keeps track of when DL CTRL should finish. Needed for CSI-RS and CSI-IM implementation to be able to ...
void SetTxPowerSpectralDensity(const Ptr< SpectrumValue > &txPsd)
Sets transmit power spectral density.
void SetPhyUlHarqFeedbackCallback(const NrPhyUlHarqFeedbackCallback &c)
Sets the callback to be called when UL HARQ feedback is generated.
void SetAntenna(Ptr< Object > antenna)
Sets the antenna of this NrSpectrumPhy instance, currently in NR module it is expected to be of type ...
void AddDataSinrChunkProcessor(const Ptr< NrChunkProcessor > &p)
Adds the chunk processor that will process the interference.
void AddSrsSinrReportCallback(SrsSinrReportCallback callback)
It adds callback to the list of callbacks that will be notified once SRS is being received.
void StartTxDataFrames(const Ptr< PacketBurst > &pb, const std::list< Ptr< NrControlMessage > > &ctrlMsgList, const std::shared_ptr< DciInfoElementTdma > dci, const Time &duration)
Starts transmission of data frames on connected spectrum channel object.
void(* RxDataTracedCallback)(const SfnSf &sfnSf, Ptr< const SpectrumValue > v, const Time &t, uint16_t bwpId, uint16_t cellId)
TracedCallback signature for RB statistics.
void AddDataMimoChunkProcessor(const Ptr< NrMimoChunkProcessor > &p)
Connect DATA chunk processor with the corresponding DATA interference object.
Callback< void, const Ptr< Packet > & > NrPhyRxDataEndOkCallback
This callback method type is used to notify that DATA is received.
State
Enum that defines possible states of the spectrum phy.
@ TX
Transmitting state (data or ctrl)
@ RX_UL_SRS
Receiving SRS.
@ CCA_BUSY
BUSY state (channel occupied by another entity)
@ RX_UL_CTRL
Receiving UL CTRL.
@ RX_DL_CTRL
Receiving DL CTRL.
@ IDLE
IDLE state (no action in progress)
void AddRsPowerChunkProcessor(const Ptr< NrChunkProcessor > &p)
Adds the chunk processor that will process the received power.
void SetActivePanel(const uint8_t panelIndex)
Set the active antenna panel to this NrSpectrumPhy,.
uint16_t GetBwpId() const
void StartRx(Ptr< SpectrumSignalParameters > params) override
Inherited from SpectrumPhy. When this function is called this spectrum phy starts receiving a signal ...
void ChangeState(State newState, Time duration)
Update the state of the spectrum phy. The states are: IDLE, TX, RX_DATA, RX_DL_CTRL,...
void NotifyTxDataTrace(Time duration) const
call TxDataTrace from subclass
Ptr< Object > GetAntenna() const override
Inherited from SpectrumPhy Note: Implements GetRxAntenna function from SpectrumPhy.
void SetPhyRxPssCallback(const NrPhyRxPssCallback &c)
A struct that contains info for the DL HARQ.
Information about the expected transport block at a certain point in the slot.