From 45591fc72e221216270a65e6c0d7e98eeeca1fa4 Mon Sep 17 00:00:00 2001 From: Nicola Baldo Date: Tue, 26 Apr 2011 13:32:27 +0200 Subject: [PATCH] noise figure attribute --- src/lte/helper/lena-helper.cc | 6 ---- src/lte/model/lte-enb-phy.cc | 28 +++++++++++++++++++ src/lte/model/lte-enb-phy.h | 10 +++++++ src/lte/model/lte-phy.cc | 4 +-- src/lte/model/lte-phy.h | 1 + src/lte/model/lte-spectrum-value-helper.cc | 32 ++++++++++------------ src/lte/model/lte-spectrum-value-helper.h | 23 +++++++++++++--- src/lte/model/lte-ue-phy.cc | 28 +++++++++++++++++++ src/lte/model/lte-ue-phy.h | 9 ++++++ 9 files changed, 111 insertions(+), 30 deletions(-) diff --git a/src/lte/helper/lena-helper.cc b/src/lte/helper/lena-helper.cc index eab6bbda1..782d5ab97 100644 --- a/src/lte/helper/lena-helper.cc +++ b/src/lte/helper/lena-helper.cc @@ -140,9 +140,6 @@ LenaHelper::InstallSingleEnbDevice (Ptr n) Ptr phy = CreateObject (dlPhy, ulPhy); - Ptr noisePsd = LteSpectrumValueHelper::CreateUplinkNoisePowerSpectralDensity (); - ulPhy->SetNoisePowerSpectralDensity (noisePsd); - Ptr p = Create (phy->GetObject ()); ulPhy->AddSinrChunkProcessor (p); @@ -195,9 +192,6 @@ LenaHelper::InstallSingleUeDevice (Ptr n) Ptr phy = CreateObject (dlPhy, ulPhy); - Ptr noisePsd = LteSpectrumValueHelper::CreateDownlinkNoisePowerSpectralDensity (); - dlPhy->SetNoisePowerSpectralDensity (noisePsd); - Ptr p = Create (phy->GetObject ()); dlPhy->AddSinrChunkProcessor (p); diff --git a/src/lte/model/lte-enb-phy.cc b/src/lte/model/lte-enb-phy.cc index 7b6f44972..9707fefc4 100644 --- a/src/lte/model/lte-enb-phy.cc +++ b/src/lte/model/lte-enb-phy.cc @@ -128,6 +128,18 @@ LteEnbPhy::GetTypeId (void) MakeDoubleAccessor (&LteEnbPhy::SetTxPower, &LteEnbPhy::GetTxPower), MakeDoubleChecker ()) + .AddAttribute ("NoiseFigure", + "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver." + " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is " + "\"the difference in decibels (dB) between" + " the noise output of the actual receiver to the noise output of an " + " ideal receiver with the same overall gain and bandwidth when the receivers " + " are connected to sources at the standard noise temperature T0.\" " + "In this model, we consider T0 = 290K.", + DoubleValue (5.0), + MakeDoubleAccessor (&LteEnbPhy::SetNoiseFigure, + &LteEnbPhy::GetNoiseFigure), + MakeDoubleChecker ()) ; return tid; } @@ -172,6 +184,22 @@ LteEnbPhy::GetTxPower () const return m_txPower; } +void +LteEnbPhy::SetNoiseFigure (double nf) +{ + NS_LOG_FUNCTION (this << nf); + m_noiseFigure = nf; + Ptr noisePsd = LteSpectrumValueHelper::CreateUplinkNoisePowerSpectralDensity (m_noiseFigure); + m_uplinkSpectrumPhy->SetNoisePowerSpectralDensity (noisePsd); +} + +double +LteEnbPhy::GetNoiseFigure () const +{ + NS_LOG_FUNCTION (this); + return m_noiseFigure; +} + bool LteEnbPhy::AddUePhy (uint8_t rnti, Ptr phy) { diff --git a/src/lte/model/lte-enb-phy.h b/src/lte/model/lte-enb-phy.h index ab127962a..8b0f1af70 100644 --- a/src/lte/model/lte-enb-phy.h +++ b/src/lte/model/lte-enb-phy.h @@ -83,6 +83,16 @@ public: */ double GetTxPower () const; + /** + * \param pw the noise figure in dB + */ + void SetNoiseFigure (double pow); + + /** + * \return the noise figure in dB + */ + double GetNoiseFigure () const; + /** * \brief Queue the MAC PDU to be sent * \param p the MAC PDU to sent diff --git a/src/lte/model/lte-phy.cc b/src/lte/model/lte-phy.cc index d8311b2c2..de3952e91 100644 --- a/src/lte/model/lte-phy.cc +++ b/src/lte/model/lte-phy.cc @@ -42,10 +42,8 @@ LtePhy::LtePhy () } LtePhy::LtePhy (Ptr dlPhy, Ptr ulPhy) - : m_netDevice (0), - m_downlinkSpectrumPhy (dlPhy), + : m_downlinkSpectrumPhy (dlPhy), m_uplinkSpectrumPhy (ulPhy), - m_txPower (43), // dBm m_tti (0.001), m_ulBandwidth (0), m_dlBandwidth (0), diff --git a/src/lte/model/lte-phy.h b/src/lte/model/lte-phy.h index ffcee85c7..7263571ee 100644 --- a/src/lte/model/lte-phy.h +++ b/src/lte/model/lte-phy.h @@ -221,6 +221,7 @@ protected: std::vector m_listOfUplinkSubchannel; double m_txPower; + double m_noiseFigure; double m_tti; uint8_t m_ulBandwidth; diff --git a/src/lte/model/lte-spectrum-value-helper.cc b/src/lte/model/lte-spectrum-value-helper.cc index d7a0aff34..7283cee9f 100644 --- a/src/lte/model/lte-spectrum-value-helper.cc +++ b/src/lte/model/lte-spectrum-value-helper.cc @@ -129,30 +129,28 @@ LteSpectrumValueHelper::CreateUplinkTxPowerSpectralDensity (double powerTx, std: Ptr -LteSpectrumValueHelper::CreateDownlinkNoisePowerSpectralDensity (void) +LteSpectrumValueHelper::CreateDownlinkNoisePowerSpectralDensity (double noiseFigure) { - Ptr txPsd = Create (LteDownlinkSpectrumModel); - - double noise_db = 2.5 + (-174) + (10. * log10 (180000)) - 30; - double noisePowerDensity = (pow (10.,noise_db / 10)) / 180000; - - (*txPsd) = noisePowerDensity; - - return txPsd; + return CreateNoisePowerSpectralDensity (noiseFigure, LteDownlinkSpectrumModel); } +Ptr +LteSpectrumValueHelper::CreateUplinkNoisePowerSpectralDensity (double noiseFigure) +{ + return CreateNoisePowerSpectralDensity (noiseFigure, LteUplinkSpectrumModel); +} Ptr -LteSpectrumValueHelper::CreateUplinkNoisePowerSpectralDensity (void) +LteSpectrumValueHelper::CreateNoisePowerSpectralDensity (double noiseFigureDb, Ptr spectrumModel) { - Ptr txPsd = Create (LteUplinkSpectrumModel); + double noiseFigureLinear = pow (10.0, noiseFigureDb / 10.0); + static const double BOLTZMANN = 1.3803e-23; + static const double ROOM_TEMPERATURE = 290.0; + double noisePowerSpectralDensity = noiseFigureLinear * BOLTZMANN * ROOM_TEMPERATURE; // W/Hz - double noise_db = 2.5 + (-174) + (10. * log10 (180000)) - 30; - double noisePowerDensity = (pow (10.,noise_db / 10)) / 180000; - - (*txPsd) = noisePowerDensity; - - return txPsd; + Ptr noisePsd = Create (spectrumModel); + (*noisePsd) = noisePowerSpectralDensity; + return noisePsd; } } // namespace ns3 diff --git a/src/lte/model/lte-spectrum-value-helper.h b/src/lte/model/lte-spectrum-value-helper.h index 9f0bc2d6d..d08591938 100644 --- a/src/lte/model/lte-spectrum-value-helper.h +++ b/src/lte/model/lte-spectrum-value-helper.h @@ -52,17 +52,32 @@ public: /** - * \brief create spectrum value for noise + * create a SpectrumValue that models the power spectral density of AWGN + * + * \param noiseFigure the noise figure in dB w.r.t. a reference temperature of 290K + * * \return a Ptr to a newly created SpectrumValue instance */ - static Ptr CreateDownlinkNoisePowerSpectralDensity (void); + static Ptr CreateDownlinkNoisePowerSpectralDensity (double noiseFigure); /** - * \brief create spectrum value for noise + * create a SpectrumValue that models the power spectral density of AWGN + * + * \param noiseFigure the noise figure in dB w.r.t. a reference temperature of 290K + * * \return a Ptr to a newly created SpectrumValue instance */ - static Ptr CreateUplinkNoisePowerSpectralDensity (void); + static Ptr CreateUplinkNoisePowerSpectralDensity (double noiseFigure); + /** + * create a SpectrumValue that models the power spectral density of AWGN + * + * \param noiseFigure the noise figure in dB w.r.t. a reference temperature of 290K + * \param spectrumModel the SpectrumModel instance to be used + * + * \return a Ptr to a newly created SpectrumValue instance + */ + static Ptr CreateNoisePowerSpectralDensity (double noiseFigure, Ptr spectrumModel); }; diff --git a/src/lte/model/lte-ue-phy.cc b/src/lte/model/lte-ue-phy.cc index a9c73b24c..a98736cf3 100644 --- a/src/lte/model/lte-ue-phy.cc +++ b/src/lte/model/lte-ue-phy.cc @@ -137,6 +137,18 @@ LteUePhy::GetTypeId (void) MakeDoubleAccessor (&LteUePhy::SetTxPower, &LteUePhy::GetTxPower), MakeDoubleChecker ()) + .AddAttribute ("NoiseFigure", + "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver." + " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is " + "\"the difference in decibels (dB) between" + " the noise output of the actual receiver to the noise output of an " + " ideal receiver with the same overall gain and bandwidth when the receivers " + " are connected to sources at the standard noise temperature T0.\" " + "In this model, we consider T0 = 290K.", + DoubleValue (9.0), + MakeDoubleAccessor (&LteUePhy::SetNoiseFigure, + &LteUePhy::GetNoiseFigure), + MakeDoubleChecker ()) ; return tid; } @@ -156,6 +168,22 @@ LteUePhy::GetLteUePhySapProvider () return (m_uePhySapProvider); } +void +LteUePhy::SetNoiseFigure (double nf) +{ + NS_LOG_FUNCTION (this << nf); + m_noiseFigure = nf; + Ptr noisePsd = LteSpectrumValueHelper::CreateDownlinkNoisePowerSpectralDensity (m_noiseFigure); + m_downlinkSpectrumPhy->SetNoisePowerSpectralDensity (noisePsd); +} + +double +LteUePhy::GetNoiseFigure () const +{ + NS_LOG_FUNCTION (this); + return m_noiseFigure; +} + void LteUePhy::SetTxPower (double pow) { diff --git a/src/lte/model/lte-ue-phy.h b/src/lte/model/lte-ue-phy.h index 73e825d9e..376ca45d5 100644 --- a/src/lte/model/lte-ue-phy.h +++ b/src/lte/model/lte-ue-phy.h @@ -89,6 +89,15 @@ public: * \return the transmission power in dBm */ double GetTxPower () const; + /** + * \param pw the noise figure in dB + */ + void SetNoiseFigure (double pow); + + /** + * \return the noise figure in dB + */ + double GetNoiseFigure () const; /** * \brief Queue the MAC PDU to be sent