diff --git a/src/lte/model/lte-spectrum-value-helper.cc b/src/lte/model/lte-spectrum-value-helper.cc index 317ed4e87..3bd30ef10 100644 --- a/src/lte/model/lte-spectrum-value-helper.cc +++ b/src/lte/model/lte-spectrum-value-helper.cc @@ -332,7 +332,29 @@ LteSpectrumValueHelper::CreateTxPowerSpectralDensity (uint32_t earfcn, uint8_t t return txPsd; } +Ptr +LteSpectrumValueHelper::CreateUlTxPowerSpectralDensity (uint16_t earfcn, uint8_t txBandwidthConfiguration, double powerTx, std::vector activeRbs) +{ + NS_LOG_FUNCTION (earfcn << (uint16_t) txBandwidthConfiguration << powerTx << activeRbs); + Ptr model = GetSpectrumModel (earfcn, txBandwidthConfiguration); + Ptr txPsd = Create (model); + + // powerTx is expressed in dBm. We must convert it into natural unit. + double powerTxW = std::pow (10., (powerTx - 30) / 10); + + double txPowerDensity = (powerTxW / (activeRbs.size() * 180000)); + + for (std::vector ::iterator it = activeRbs.begin (); it != activeRbs.end (); it++) + { + int rbId = (*it); + (*txPsd)[rbId] = txPowerDensity; + } + + NS_LOG_LOGIC (*txPsd); + + return txPsd; +} Ptr LteSpectrumValueHelper::CreateNoisePowerSpectralDensity (uint32_t earfcn, uint8_t txBandwidthConfiguration, double noiseFigure) diff --git a/src/lte/model/lte-spectrum-value-helper.h b/src/lte/model/lte-spectrum-value-helper.h index 2df860e84..044b82359 100644 --- a/src/lte/model/lte-spectrum-value-helper.h +++ b/src/lte/model/lte-spectrum-value-helper.h @@ -152,6 +152,23 @@ public: std::map powerTxMap, std::vector activeRbs); + /** + * create a spectrum value representing the uplink power spectral + * density of a signal to be transmitted. See 3GPP TS 36.101 for + * a definition of most of the parameters described here. + * This function splits the power over the active RBs instead of + * the entire bandwidth + * \param earfcn the carrier frequency (EARFCN) of the transmission + * \param powerTx the total power in dBm over the whole bandwidth + * \param activeRbs the list of Active Resource Blocks (PRBs) + * + * \return a pointer to a newly allocated SpectrumValue representing the TX Power Spectral Density in W/Hz for each Resource Block + */ + static Ptr CreateUlTxPowerSpectralDensity (uint16_t earfcn, + uint8_t bandwidth, + double powerTx, + std::vector activeRbs); + /** * create a SpectrumValue that models the power spectral density of AWGN * diff --git a/src/lte/model/lte-ue-phy.cc b/src/lte/model/lte-ue-phy.cc index 01abf0a79..72ae2977b 100644 --- a/src/lte/model/lte-ue-phy.cc +++ b/src/lte/model/lte-ue-phy.cc @@ -468,7 +468,7 @@ LteUePhy::CreateTxPowerSpectralDensity () { NS_LOG_FUNCTION (this); LteSpectrumValueHelper psdHelper; - Ptr psd = psdHelper.CreateTxPowerSpectralDensity (m_ulEarfcn, m_ulBandwidth, m_txPower, GetSubChannelsForTransmission ()); + Ptr psd = psdHelper.CreateUlTxPowerSpectralDensity (m_ulEarfcn, m_ulBandwidth, m_txPower, GetSubChannelsForTransmission ()); return psd; } diff --git a/src/lte/test/lte-test-frequency-reuse.cc b/src/lte/test/lte-test-frequency-reuse.cc index 93d7bb971..51d6f6176 100644 --- a/src/lte/test/lte-test-frequency-reuse.cc +++ b/src/lte/test/lte-test-frequency-reuse.cc @@ -524,9 +524,28 @@ LteFrAreaTestCase::UlDataRxStart (Ptr spectrumValue) NS_LOG_DEBUG ("UL DATA Power allocation :"); Values::const_iterator it; uint32_t i = 0; + uint32_t numActiveRbs = 0; + + // At the moment I could not find a better way to find total number + // of active RBs. This method is independent of the bandwidth + // configuration done in a test scenario, thus, it requires + // minimum change to the script. for (it = spectrumValue->ConstValuesBegin (); it != spectrumValue->ConstValuesEnd (); it++) { - double power = (*it) * (m_ulBandwidth * 180000); + // Count the RB as active if it is part of + // the expected UL RBs and has Power Spectral Density (PSD) > 0 + if (m_expectedUlRb[numActiveRbs] == true && (*it) > 0) + { + numActiveRbs++; + } + } + NS_LOG_DEBUG ("Total number of active RBs = " << numActiveRbs); + + // The uplink power control and the uplink PSD + // calculation only consider active resource blocks. + for (it = spectrumValue->ConstValuesBegin (); it != spectrumValue->ConstValuesEnd (); it++) + { + double power = (*it) * (numActiveRbs * 180000); NS_LOG_DEBUG ("RB " << i << " POWER: " << power << " expectedUlPower: " << m_expectedUlPower); if (m_expectedUlRb[i] == false && power > 0) {