spectrum: Pass SpectrumSignalParameters to CalcRxPowerSpectralDensity
This commit is contained in:
committed by
Sebastien Deronne
parent
575671c389
commit
793042d63f
@@ -45,6 +45,7 @@
|
||||
#include "ns3/three-gpp-spectrum-propagation-loss-model.h"
|
||||
#include "ns3/three-gpp-v2v-propagation-loss-model.h"
|
||||
#include "ns3/three-gpp-channel-model.h"
|
||||
#include "ns3/spectrum-signal-parameters.h"
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
@@ -63,31 +64,10 @@ struct ComputeSnrParams
|
||||
{
|
||||
Ptr<MobilityModel> txMob; //!< the tx mobility model
|
||||
Ptr<MobilityModel> rxMob; //!< the rx mobility model
|
||||
Ptr<SpectrumValue> txPsd; //!< the PSD of the tx signal
|
||||
Ptr<SpectrumSignalParameters> txParams; //!< the params of the tx signal
|
||||
double noiseFigure; //!< the noise figure in dB
|
||||
Ptr<PhasedArrayModel> txAntenna; //!< the tx antenna array
|
||||
Ptr<PhasedArrayModel> rxAntenna; //!< the rx antenna array
|
||||
|
||||
/**
|
||||
* \brief Constructor
|
||||
* \param pTxMob the tx mobility model
|
||||
* \param pRxMob the rx mobility model
|
||||
* \param pTxPsd the PSD of the tx signal
|
||||
* \param pNoiseFigure the noise figure in dB
|
||||
* \param pTxAntenna the tx antenna array
|
||||
* \param pRxAntenna the rx antenna array
|
||||
*/
|
||||
ComputeSnrParams (Ptr<MobilityModel> pTxMob, Ptr<MobilityModel> pRxMob,
|
||||
Ptr<SpectrumValue> pTxPsd, double pNoiseFigure,
|
||||
Ptr<PhasedArrayModel> pTxAntenna, Ptr<PhasedArrayModel> pRxAntenna)
|
||||
{
|
||||
txMob = pTxMob;
|
||||
rxMob = pRxMob;
|
||||
txPsd = pTxPsd;
|
||||
noiseFigure = pNoiseFigure;
|
||||
txAntenna = pTxAntenna;
|
||||
rxAntenna = pRxAntenna;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -117,10 +97,8 @@ DoBeamforming (Ptr<NetDevice> thisDevice, Ptr<PhasedArrayModel> thisAntenna, Ptr
|
||||
* \param params A structure that holds a bunch of parameters needed by ComputSnr function to calculate the average SNR
|
||||
*/
|
||||
static void
|
||||
ComputeSnr (ComputeSnrParams& params)
|
||||
ComputeSnr (const ComputeSnrParams& params)
|
||||
{
|
||||
Ptr<SpectrumValue> rxPsd = params.txPsd->Copy ();
|
||||
|
||||
// check the channel condition
|
||||
Ptr<ChannelCondition> cond = m_condModel->GetChannelCondition (params.txMob, params.rxMob);
|
||||
|
||||
@@ -128,10 +106,10 @@ ComputeSnr (ComputeSnrParams& params)
|
||||
double propagationGainDb = m_propagationLossModel->CalcRxPower (0, params.txMob, params.rxMob);
|
||||
NS_LOG_DEBUG ("Pathloss " << -propagationGainDb << " dB");
|
||||
double propagationGainLinear = std::pow (10.0, (propagationGainDb) / 10.0);
|
||||
*(rxPsd) *= propagationGainLinear;
|
||||
*(params.txParams->psd) *= propagationGainLinear;
|
||||
|
||||
// apply the fast fading and the beamforming gain
|
||||
rxPsd = m_spectrumLossModel->CalcRxPowerSpectralDensity (rxPsd, params.txMob, params.rxMob, params.txAntenna, params.rxAntenna);
|
||||
Ptr<SpectrumValue> rxPsd = m_spectrumLossModel->CalcRxPowerSpectralDensity (params.txParams, params.txMob, params.rxMob, params.txAntenna, params.rxAntenna);
|
||||
NS_LOG_DEBUG ("Average rx power " << 10 * log10 (Sum (*rxPsd) * 180e3) << " dB");
|
||||
|
||||
// create the noise psd
|
||||
@@ -140,7 +118,7 @@ ComputeSnr (ComputeSnrParams& params)
|
||||
double kT_W_Hz = std::pow (10.0, (kT_dBm_Hz - 30) / 10.0);
|
||||
double noiseFigureLinear = std::pow (10.0, params.noiseFigure / 10.0);
|
||||
double noisePowerSpectralDensity = kT_W_Hz * noiseFigureLinear;
|
||||
Ptr<SpectrumValue> noisePsd = Create <SpectrumValue> (params.txPsd->GetSpectrumModel ());
|
||||
Ptr<SpectrumValue> noisePsd = Create <SpectrumValue> (params.txParams->psd->GetSpectrumModel ());
|
||||
(*noisePsd) = noisePowerSpectralDensity;
|
||||
|
||||
// compute the SNR
|
||||
@@ -354,14 +332,17 @@ main (int argc, char *argv[])
|
||||
rbs.push_back (rb);
|
||||
}
|
||||
Ptr<SpectrumModel> spectrumModel = Create<SpectrumModel> (rbs);
|
||||
Ptr<SpectrumValue> txPsd = Create <SpectrumValue> (spectrumModel);
|
||||
Ptr<SpectrumValue> txPsd = Create<SpectrumValue> (spectrumModel);
|
||||
Ptr<SpectrumSignalParameters> txParams = Create<SpectrumSignalParameters> ();
|
||||
double txPow_w = std::pow (10., (txPow_dbm - 30) / 10);
|
||||
double txPowDens = (txPow_w / (numRb * subCarrierSpacing));
|
||||
(*txPsd) = txPowDens;
|
||||
txParams->psd = txPsd->Copy ();
|
||||
|
||||
for (int i = 0; i < simTime / timeRes; i++)
|
||||
{
|
||||
Simulator::Schedule (timeRes * i, &ComputeSnr, ComputeSnrParams (txMob, rxMob, txPsd, noiseFigure, txAntenna, rxAntenna));
|
||||
ComputeSnrParams params{txMob, rxMob, txParams, noiseFigure, txAntenna, rxAntenna};
|
||||
Simulator::Schedule (timeRes * i, &ComputeSnr, params);
|
||||
}
|
||||
|
||||
// initialize the output file
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include "ns3/lte-spectrum-value-helper.h"
|
||||
#include "ns3/channel-condition-model.h"
|
||||
#include "ns3/three-gpp-propagation-loss-model.h"
|
||||
#include "ns3/spectrum-signal-parameters.h"
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("ThreeGppChannelExample");
|
||||
|
||||
@@ -63,26 +64,6 @@ struct ComputeSnrParams
|
||||
double noiseFigure; //!< the noise figure in dB
|
||||
Ptr<PhasedArrayModel> txAntenna; //!< the tx antenna array
|
||||
Ptr<PhasedArrayModel> rxAntenna; //!< the rx antenna array
|
||||
|
||||
/**
|
||||
* \brief Constructor
|
||||
* \param pTxMob the tx mobility model
|
||||
* \param pRxMob the rx mobility model
|
||||
* \param pTxPow the tx power in dBm
|
||||
* \param pNoiseFigure the noise figure in dB
|
||||
* \param pTxAntenna the tx antenna array
|
||||
* \param pRxAntenna the rx antenna array
|
||||
*/
|
||||
ComputeSnrParams (Ptr<MobilityModel> pTxMob, Ptr<MobilityModel> pRxMob, double pTxPow, double pNoiseFigure,
|
||||
Ptr<PhasedArrayModel> pTxAntenna, Ptr<PhasedArrayModel> pRxAntenna)
|
||||
{
|
||||
txMob = pTxMob;
|
||||
rxMob = pRxMob;
|
||||
txPow = pTxPow;
|
||||
noiseFigure = pNoiseFigure;
|
||||
txAntenna = pTxAntenna;
|
||||
rxAntenna = pRxAntenna;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -131,7 +112,7 @@ DoBeamforming (Ptr<NetDevice> thisDevice, Ptr<PhasedArrayModel> thisAntenna, Ptr
|
||||
* \param params A structure that holds the parameters that are needed to perform calculations in ComputeSnr
|
||||
*/
|
||||
static void
|
||||
ComputeSnr (ComputeSnrParams& params)
|
||||
ComputeSnr (const ComputeSnrParams& params)
|
||||
{
|
||||
// Create the tx PSD using the LteSpectrumValueHelper
|
||||
// 100 RBs corresponds to 18 MHz (1 RB = 180 kHz)
|
||||
@@ -142,7 +123,8 @@ ComputeSnr (ComputeSnrParams& params)
|
||||
activeRbs0[i] = i;
|
||||
}
|
||||
Ptr<SpectrumValue> txPsd = LteSpectrumValueHelper::CreateTxPowerSpectralDensity (2100, 100, params.txPow, activeRbs0);
|
||||
Ptr<SpectrumValue> rxPsd = txPsd->Copy ();
|
||||
Ptr<SpectrumSignalParameters> txParams = Create<SpectrumSignalParameters> ();
|
||||
txParams->psd = txPsd->Copy ();
|
||||
NS_LOG_DEBUG ("Average tx power " << 10*log10(Sum (*txPsd) * 180e3) << " dB");
|
||||
|
||||
// create the noise PSD
|
||||
@@ -153,14 +135,14 @@ ComputeSnr (ComputeSnrParams& params)
|
||||
double propagationGainDb = m_propagationLossModel->CalcRxPower (0, params.txMob, params.rxMob);
|
||||
NS_LOG_DEBUG ("Pathloss " << -propagationGainDb << " dB");
|
||||
double propagationGainLinear = std::pow (10.0, (propagationGainDb) / 10.0);
|
||||
*(rxPsd) *= propagationGainLinear;
|
||||
*(txParams->psd) *= propagationGainLinear;
|
||||
|
||||
NS_ASSERT_MSG (params.txAntenna, "params.txAntenna is nullptr!");
|
||||
NS_ASSERT_MSG (params.rxAntenna, "params.rxAntenna is nullptr!");
|
||||
|
||||
// apply the fast fading and the beamforming gain
|
||||
rxPsd = m_spectrumLossModel->CalcRxPowerSpectralDensity (rxPsd, params.txMob, params.rxMob, params.txAntenna, params.rxAntenna);
|
||||
NS_LOG_DEBUG ("Average rx power " << 10 * log10 (Sum (*rxPsd) * 180e3) << " dB");
|
||||
Ptr<SpectrumValue> rxPsd = m_spectrumLossModel->CalcRxPowerSpectralDensity (txParams, params.txMob, params.rxMob, params.txAntenna, params.rxAntenna);
|
||||
NS_LOG_DEBUG ("Average rx power " << 10*log10 (Sum (*rxPsd) * 180e3) << " dB");
|
||||
|
||||
// compute the SNR
|
||||
NS_LOG_DEBUG ("Average SNR " << 10 * log10 (Sum (*rxPsd) / Sum (*noisePsd)) << " dB");
|
||||
@@ -272,7 +254,8 @@ main (int argc, char *argv[])
|
||||
|
||||
for (int i = 0; i < floor (simTime / timeRes); i++)
|
||||
{
|
||||
Simulator::Schedule (MilliSeconds (timeRes*i), &ComputeSnr, ComputeSnrParams (txMob, rxMob, txPow, noiseFigure, txAntenna, rxAntenna));
|
||||
ComputeSnrParams params{txMob, rxMob, txPow, noiseFigure, txAntenna, rxAntenna};
|
||||
Simulator::Schedule (MilliSeconds (timeRes*i), &ComputeSnr, params);
|
||||
}
|
||||
|
||||
Simulator::Run ();
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "ns3/log.h"
|
||||
|
||||
#include "ns3/constant-spectrum-propagation-loss.h"
|
||||
#include "spectrum-signal-parameters.h"
|
||||
#include "ns3/double.h"
|
||||
|
||||
|
||||
@@ -78,13 +79,13 @@ ConstantSpectrumPropagationLossModel::GetLossDb () const
|
||||
|
||||
|
||||
Ptr<SpectrumValue>
|
||||
ConstantSpectrumPropagationLossModel::DoCalcRxPowerSpectralDensity (Ptr<const SpectrumValue> txPsd,
|
||||
ConstantSpectrumPropagationLossModel::DoCalcRxPowerSpectralDensity (Ptr<const SpectrumSignalParameters> params,
|
||||
Ptr<const MobilityModel> a,
|
||||
Ptr<const MobilityModel> b) const
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
|
||||
Ptr<SpectrumValue> rxPsd = Copy<SpectrumValue> (txPsd);
|
||||
Ptr<SpectrumValue> rxPsd = Copy<SpectrumValue> (params->psd);
|
||||
Values::iterator vit = rxPsd->ValuesBegin ();
|
||||
Bands::const_iterator fit = rxPsd->ConstBandsBegin ();
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
*/
|
||||
static TypeId GetTypeId ();
|
||||
|
||||
virtual Ptr<SpectrumValue> DoCalcRxPowerSpectralDensity (Ptr<const SpectrumValue> txPsd,
|
||||
virtual Ptr<SpectrumValue> DoCalcRxPowerSpectralDensity (Ptr<const SpectrumSignalParameters> params,
|
||||
Ptr<const MobilityModel> a,
|
||||
Ptr<const MobilityModel> b) const;
|
||||
/**
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include <ns3/mobility-model.h>
|
||||
#include <ns3/friis-spectrum-propagation-loss.h>
|
||||
#include "spectrum-signal-parameters.h"
|
||||
#include <cmath> // for M_PI
|
||||
|
||||
|
||||
@@ -50,11 +51,11 @@ FriisSpectrumPropagationLossModel::GetTypeId (void)
|
||||
|
||||
|
||||
Ptr<SpectrumValue>
|
||||
FriisSpectrumPropagationLossModel::DoCalcRxPowerSpectralDensity (Ptr<const SpectrumValue> txPsd,
|
||||
FriisSpectrumPropagationLossModel::DoCalcRxPowerSpectralDensity (Ptr<const SpectrumSignalParameters> params,
|
||||
Ptr<const MobilityModel> a,
|
||||
Ptr<const MobilityModel> b) const
|
||||
{
|
||||
Ptr<SpectrumValue> rxPsd = Copy<SpectrumValue> (txPsd);
|
||||
Ptr<SpectrumValue> rxPsd = Copy<SpectrumValue> (params->psd);
|
||||
Values::iterator vit = rxPsd->ValuesBegin ();
|
||||
Bands::const_iterator fit = rxPsd->ConstBandsBegin ();
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
static TypeId GetTypeId ();
|
||||
|
||||
|
||||
virtual Ptr<SpectrumValue> DoCalcRxPowerSpectralDensity (Ptr<const SpectrumValue> txPsd,
|
||||
virtual Ptr<SpectrumValue> DoCalcRxPowerSpectralDensity (Ptr<const SpectrumSignalParameters> params,
|
||||
Ptr<const MobilityModel> a,
|
||||
Ptr<const MobilityModel> b) const;
|
||||
|
||||
|
||||
@@ -339,7 +339,7 @@ MultiModelSpectrumChannel::StartTx (Ptr<SpectrumSignalParameters> txParams)
|
||||
|
||||
if (m_spectrumPropagationLoss)
|
||||
{
|
||||
rxParams->psd = m_spectrumPropagationLoss->CalcRxPowerSpectralDensity (rxParams->psd, txMobility, receiverMobility);
|
||||
rxParams->psd = m_spectrumPropagationLoss->CalcRxPowerSpectralDensity (rxParams, txMobility, receiverMobility);
|
||||
}
|
||||
else if (m_phasedArraySpectrumPropagationLoss)
|
||||
{
|
||||
@@ -348,7 +348,7 @@ MultiModelSpectrumChannel::StartTx (Ptr<SpectrumSignalParameters> txParams)
|
||||
|
||||
NS_ASSERT_MSG (txPhasedArrayModel && rxPhasedArrayModel, "PhasedArrayModel instances should be installed at both TX and RX SpectrumPhy in order to use PhasedArraySpectrumPropagationLoss.");
|
||||
|
||||
rxParams->psd = m_phasedArraySpectrumPropagationLoss->CalcRxPowerSpectralDensity (rxParams->psd, txMobility, receiverMobility, txPhasedArrayModel, rxPhasedArrayModel);
|
||||
rxParams->psd = m_phasedArraySpectrumPropagationLoss->CalcRxPowerSpectralDensity (rxParams, txMobility, receiverMobility, txPhasedArrayModel, rxPhasedArrayModel);
|
||||
}
|
||||
|
||||
if (m_propagationDelay)
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "phased-array-spectrum-propagation-loss-model.h"
|
||||
#include <ns3/log.h>
|
||||
#include <ns3/phased-array-model.h>
|
||||
#include "ns3/spectrum-signal-parameters.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -60,7 +61,7 @@ void PhasedArraySpectrumPropagationLossModel::SetNext (Ptr<PhasedArraySpectrumPr
|
||||
}
|
||||
|
||||
Ptr<SpectrumValue>
|
||||
PhasedArraySpectrumPropagationLossModel::CalcRxPowerSpectralDensity (Ptr<const SpectrumValue> txPsd,
|
||||
PhasedArraySpectrumPropagationLossModel::CalcRxPowerSpectralDensity (Ptr<const SpectrumSignalParameters> params,
|
||||
Ptr<const MobilityModel> a,
|
||||
Ptr<const MobilityModel> b,
|
||||
Ptr<const PhasedArrayModel> aPhasedArrayModel,
|
||||
@@ -69,10 +70,10 @@ PhasedArraySpectrumPropagationLossModel::CalcRxPowerSpectralDensity (Ptr<const S
|
||||
// Here we assume that all the models in the chain of models are of type
|
||||
// PhasedArraySpectrumPropagationLossModel that provides the implementation of
|
||||
// this function, i.e. has phased array model of TX and RX as parameters
|
||||
Ptr<SpectrumValue> rxPsd = DoCalcRxPowerSpectralDensity (txPsd, a, b, aPhasedArrayModel, bPhasedArrayModel);
|
||||
Ptr<SpectrumValue> rxPsd = DoCalcRxPowerSpectralDensity (params, a, b, aPhasedArrayModel, bPhasedArrayModel);
|
||||
if (m_next != 0)
|
||||
{
|
||||
rxPsd = m_next->CalcRxPowerSpectralDensity (rxPsd, a, b, aPhasedArrayModel, bPhasedArrayModel);
|
||||
rxPsd = m_next->CalcRxPowerSpectralDensity (params, a, b, aPhasedArrayModel, bPhasedArrayModel);
|
||||
}
|
||||
return rxPsd;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
struct SpectrumSignalParameters;
|
||||
|
||||
/**
|
||||
* \ingroup spectrum
|
||||
@@ -63,11 +64,7 @@ public:
|
||||
/**
|
||||
* This method is to be called to calculate
|
||||
*
|
||||
* @param txPsd the SpectrumValue representing the power spectral
|
||||
* density of the transmission. Watt units are to be used for radio
|
||||
* communications, and Pascal units for acoustic communications
|
||||
* (e.g., underwater).
|
||||
*
|
||||
* @param params the spectrum signal parameters.
|
||||
* @param a sender mobility
|
||||
* @param b receiver mobility
|
||||
* @param aPhasedArrayModel the instance of the phased antenna array of the sender
|
||||
@@ -76,7 +73,7 @@ public:
|
||||
* @return set of values Vs frequency representing the received
|
||||
* power in the same units used for the txPower parameter.
|
||||
*/
|
||||
Ptr<SpectrumValue> CalcRxPowerSpectralDensity (Ptr<const SpectrumValue> txPsd,
|
||||
Ptr<SpectrumValue> CalcRxPowerSpectralDensity (Ptr<const SpectrumSignalParameters> txPsd,
|
||||
Ptr<const MobilityModel> a,
|
||||
Ptr<const MobilityModel> b,
|
||||
Ptr<const PhasedArrayModel> aPhasedArrayModel,
|
||||
@@ -89,8 +86,7 @@ protected:
|
||||
private:
|
||||
/**
|
||||
*
|
||||
* @param txPsd set of values Vs frequency representing the
|
||||
* transmission power. See SpectrumChannel for details.
|
||||
* @param params the spectrum signal parameters.
|
||||
* @param a sender mobility
|
||||
* @param b receiver mobility
|
||||
* @param aPhasedArrayModel the instance of the phased antenna array of the sender
|
||||
@@ -99,7 +95,7 @@ private:
|
||||
* @return set of values Vs frequency representing the received
|
||||
* power in the same units used for the txPower parameter.
|
||||
*/
|
||||
virtual Ptr<SpectrumValue> DoCalcRxPowerSpectralDensity (Ptr<const SpectrumValue> txPsd,
|
||||
virtual Ptr<SpectrumValue> DoCalcRxPowerSpectralDensity (Ptr<const SpectrumSignalParameters> params,
|
||||
Ptr<const MobilityModel> a,
|
||||
Ptr<const MobilityModel> b,
|
||||
Ptr<const PhasedArrayModel> aPhasedArrayModel,
|
||||
|
||||
@@ -185,7 +185,7 @@ SingleModelSpectrumChannel::StartTx (Ptr<SpectrumSignalParameters> txParams)
|
||||
|
||||
if (m_spectrumPropagationLoss)
|
||||
{
|
||||
rxParams->psd = m_spectrumPropagationLoss->CalcRxPowerSpectralDensity (rxParams->psd, senderMobility, receiverMobility);
|
||||
rxParams->psd = m_spectrumPropagationLoss->CalcRxPowerSpectralDensity (rxParams, senderMobility, receiverMobility);
|
||||
}
|
||||
|
||||
if (m_propagationDelay)
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "spectrum-propagation-loss-model.h"
|
||||
#include <ns3/log.h>
|
||||
#include "spectrum-signal-parameters.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -61,14 +62,14 @@ void SpectrumPropagationLossModel::SetNext (Ptr<SpectrumPropagationLossModel> ne
|
||||
|
||||
|
||||
Ptr<SpectrumValue>
|
||||
SpectrumPropagationLossModel::CalcRxPowerSpectralDensity (Ptr<const SpectrumValue> txPsd,
|
||||
SpectrumPropagationLossModel::CalcRxPowerSpectralDensity (Ptr<const SpectrumSignalParameters> params,
|
||||
Ptr<const MobilityModel> a,
|
||||
Ptr<const MobilityModel> b) const
|
||||
{
|
||||
Ptr<SpectrumValue> rxPsd = DoCalcRxPowerSpectralDensity (txPsd, a, b);
|
||||
Ptr<SpectrumValue> rxPsd = DoCalcRxPowerSpectralDensity (params, a, b);
|
||||
if (m_next != 0)
|
||||
{
|
||||
rxPsd = m_next->CalcRxPowerSpectralDensity (rxPsd, a, b);
|
||||
rxPsd = m_next->CalcRxPowerSpectralDensity (params, a, b);
|
||||
}
|
||||
return rxPsd;
|
||||
}
|
||||
|
||||
@@ -28,8 +28,7 @@
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
|
||||
|
||||
struct SpectrumSignalParameters;
|
||||
|
||||
/**
|
||||
* \ingroup spectrum
|
||||
@@ -63,18 +62,14 @@ public:
|
||||
/**
|
||||
* This method is to be called to calculate
|
||||
*
|
||||
* @param txPsd the SpectrumValue representing the power spectral
|
||||
* density of the transmission. Watt units are to be used for radio
|
||||
* communications, and Pascal units for acoustic communications
|
||||
* (e.g., underwater).
|
||||
*
|
||||
* @param params the spectrum signal parameters.
|
||||
* @param a sender mobility
|
||||
* @param b receiver mobility
|
||||
*
|
||||
* @return set of values Vs frequency representing the received
|
||||
* power in the same units used for the txPower parameter.
|
||||
*/
|
||||
Ptr<SpectrumValue> CalcRxPowerSpectralDensity (Ptr<const SpectrumValue> txPsd,
|
||||
Ptr<SpectrumValue> CalcRxPowerSpectralDensity (Ptr<const SpectrumSignalParameters> params,
|
||||
Ptr<const MobilityModel> a,
|
||||
Ptr<const MobilityModel> b) const;
|
||||
|
||||
@@ -85,15 +80,14 @@ protected:
|
||||
private:
|
||||
/**
|
||||
*
|
||||
* @param txPsd set of values Vs frequency representing the
|
||||
* transmission power. See SpectrumChannel for details.
|
||||
* @param params the spectrum signal parameters.
|
||||
* @param a sender mobility
|
||||
* @param b receiver mobility
|
||||
*
|
||||
* @return set of values Vs frequency representing the received
|
||||
* power in the same units used for the txPower parameter.
|
||||
*/
|
||||
virtual Ptr<SpectrumValue> DoCalcRxPowerSpectralDensity (Ptr<const SpectrumValue> txPsd,
|
||||
virtual Ptr<SpectrumValue> DoCalcRxPowerSpectralDensity (Ptr<const SpectrumSignalParameters> params,
|
||||
Ptr<const MobilityModel> a,
|
||||
Ptr<const MobilityModel> b) const = 0;
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "ns3/log.h"
|
||||
#include "three-gpp-channel-model.h"
|
||||
#include "three-gpp-spectrum-propagation-loss-model.h"
|
||||
#include "spectrum-signal-parameters.h"
|
||||
#include "ns3/net-device.h"
|
||||
#include "ns3/node.h"
|
||||
#include "ns3/double.h"
|
||||
@@ -322,7 +323,7 @@ ThreeGppSpectrumPropagationLossModel::GetLongTerm (Ptr<const MatrixBasedChannelM
|
||||
}
|
||||
|
||||
Ptr<SpectrumValue>
|
||||
ThreeGppSpectrumPropagationLossModel::DoCalcRxPowerSpectralDensity (Ptr<const SpectrumValue> txPsd,
|
||||
ThreeGppSpectrumPropagationLossModel::DoCalcRxPowerSpectralDensity (Ptr<const SpectrumSignalParameters> params,
|
||||
Ptr<const MobilityModel> a,
|
||||
Ptr<const MobilityModel> b,
|
||||
Ptr<const PhasedArrayModel> aPhasedArrayModel,
|
||||
@@ -335,7 +336,7 @@ ThreeGppSpectrumPropagationLossModel::DoCalcRxPowerSpectralDensity (Ptr<const Sp
|
||||
NS_ASSERT (aId != bId);
|
||||
NS_ASSERT_MSG (a->GetDistanceFrom (b) > 0.0, "The position of a and b devices cannot be the same");
|
||||
|
||||
Ptr<SpectrumValue> rxPsd = Copy<SpectrumValue> (txPsd);
|
||||
Ptr<SpectrumValue> rxPsd = Copy<SpectrumValue> (params->psd);
|
||||
|
||||
// retrieve the antenna of device a
|
||||
NS_ASSERT_MSG (aPhasedArrayModel, "Antenna not found for node " << aId);
|
||||
|
||||
@@ -110,14 +110,14 @@ public:
|
||||
* a certain channel is cached and recomputed only when the channel realization
|
||||
* is updated, or when the beamforming vectors change.
|
||||
*
|
||||
* \param txPsd tx PSD
|
||||
* \param params tx parameters
|
||||
* \param a first node mobility model
|
||||
* \param b second node mobility model
|
||||
* \param aPhasedArrayModel the antenna array of the first node
|
||||
* \param bPhasedArrayModel the antenna array of the second node
|
||||
* \return the received PSD
|
||||
*/
|
||||
Ptr<SpectrumValue> DoCalcRxPowerSpectralDensity (Ptr<const SpectrumValue> txPsd,
|
||||
Ptr<SpectrumValue> DoCalcRxPowerSpectralDensity (Ptr<const SpectrumSignalParameters> params,
|
||||
Ptr<const MobilityModel> a,
|
||||
Ptr<const MobilityModel> b,
|
||||
Ptr<const PhasedArrayModel> aPhasedArrayModel,
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "ns3/uinteger.h"
|
||||
#include <fstream>
|
||||
#include <ns3/simulator.h>
|
||||
#include "spectrum-signal-parameters.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -149,11 +150,11 @@ TraceFadingLossModel::LoadTrace ()
|
||||
|
||||
Ptr<SpectrumValue>
|
||||
TraceFadingLossModel::DoCalcRxPowerSpectralDensity (
|
||||
Ptr<const SpectrumValue> txPsd,
|
||||
Ptr<const SpectrumSignalParameters> params,
|
||||
Ptr<const MobilityModel> a,
|
||||
Ptr<const MobilityModel> b) const
|
||||
{
|
||||
NS_LOG_FUNCTION (this << *txPsd << a << b);
|
||||
NS_LOG_FUNCTION (this << *params->psd << a << b);
|
||||
|
||||
std::map <ChannelRealizationId_t, int >::iterator itOff;
|
||||
ChannelRealizationId_t mobilityPair = std::make_pair (a,b);
|
||||
@@ -192,7 +193,7 @@ TraceFadingLossModel::DoCalcRxPowerSpectralDensity (
|
||||
}
|
||||
|
||||
|
||||
Ptr<SpectrumValue> rxPsd = Copy<SpectrumValue> (txPsd);
|
||||
Ptr<SpectrumValue> rxPsd = Copy<SpectrumValue> (params->psd);
|
||||
Values::iterator vit = rxPsd->ValuesBegin ();
|
||||
|
||||
//Vector aSpeedVector = a->GetVelocity ();
|
||||
|
||||
@@ -73,14 +73,13 @@ public:
|
||||
|
||||
private:
|
||||
/**
|
||||
* \param txPsd set of values vs frequency representing the
|
||||
* transmission power. See SpectrumChannel for details.
|
||||
* @param params the spectrum signal parameters.
|
||||
* \param a sender mobility
|
||||
* \param b receiver mobility
|
||||
* \return set of values vs frequency representing the received
|
||||
* power in the same units used for the txPsd parameter.
|
||||
*/
|
||||
Ptr<SpectrumValue> DoCalcRxPowerSpectralDensity (Ptr<const SpectrumValue> txPsd,
|
||||
Ptr<SpectrumValue> DoCalcRxPowerSpectralDensity (Ptr<const SpectrumSignalParameters> params,
|
||||
Ptr<const MobilityModel> a,
|
||||
Ptr<const MobilityModel> b) const;
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "ns3/channel-condition-model.h"
|
||||
#include "ns3/three-gpp-spectrum-propagation-loss-model.h"
|
||||
#include "ns3/wifi-spectrum-value-helper.h"
|
||||
#include "ns3/spectrum-signal-parameters.h"
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
@@ -358,35 +359,12 @@ ThreeGppChannelMatrixUpdateTest::DoRun (void)
|
||||
struct CheckLongTermUpdateParams
|
||||
{
|
||||
Ptr<ThreeGppSpectrumPropagationLossModel> lossModel; //!< the ThreeGppSpectrumPropagationLossModel object used to compute the rx PSD
|
||||
Ptr<SpectrumValue> txPsd; //!< the PSD of the tx signal
|
||||
Ptr<SpectrumSignalParameters> txParams; //!< the params of the tx signal
|
||||
Ptr<MobilityModel> txMob; //!< the mobility model of the tx device
|
||||
Ptr<MobilityModel> rxMob; //!< the mobility model of the rx device
|
||||
Ptr<SpectrumValue> rxPsdOld; //!< the previously received PSD
|
||||
Ptr<PhasedArrayModel> txAntenna; //!< the antenna array of the tx device
|
||||
Ptr<PhasedArrayModel> rxAntenna; //!< the antenna array of the rx device
|
||||
|
||||
/**
|
||||
* \brief Constructor
|
||||
* \param pLossModel the ThreeGppSpectrumPropagationLossModel object used to compute the rx PSD
|
||||
* \param pTxPsd the PSD of the tx signal
|
||||
* \param pTxMob the tx mobility model
|
||||
* \param pRxMob the rx mobility model
|
||||
* \param pRxPsdOld the previously received PSD
|
||||
* \param pTxAntenna the tx antenna array
|
||||
* \param pRxAntenna the rx antenna array
|
||||
*/
|
||||
CheckLongTermUpdateParams (Ptr<ThreeGppSpectrumPropagationLossModel> pLossModel, Ptr<SpectrumValue> pTxPsd,
|
||||
Ptr<MobilityModel> pTxMob, Ptr<MobilityModel> pRxMob, Ptr<SpectrumValue> pRxPsdOld,
|
||||
Ptr<PhasedArrayModel> pTxAntenna, Ptr<PhasedArrayModel> pRxAntenna)
|
||||
{
|
||||
lossModel = pLossModel;
|
||||
txPsd = pTxPsd;
|
||||
txMob = pTxMob;
|
||||
rxMob = pRxMob;
|
||||
rxPsdOld = pRxPsdOld;
|
||||
txAntenna = pTxAntenna;
|
||||
rxAntenna = pRxAntenna;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -432,7 +410,7 @@ private:
|
||||
* matrix is recomputed
|
||||
* \param params a structure that contains the set of parameters needed by CheckLongTermUpdate in order to perform calculations
|
||||
*/
|
||||
void CheckLongTermUpdate (CheckLongTermUpdateParams ¶ms);
|
||||
void CheckLongTermUpdate (const CheckLongTermUpdateParams ¶ms);
|
||||
|
||||
/**
|
||||
* Checks if two PSDs are equal
|
||||
@@ -481,9 +459,9 @@ ThreeGppSpectrumPropagationLossModelTest::ArePsdEqual (Ptr<SpectrumValue> first,
|
||||
}
|
||||
|
||||
void
|
||||
ThreeGppSpectrumPropagationLossModelTest::CheckLongTermUpdate (CheckLongTermUpdateParams ¶ms)
|
||||
ThreeGppSpectrumPropagationLossModelTest::CheckLongTermUpdate (const CheckLongTermUpdateParams ¶ms)
|
||||
{
|
||||
Ptr<SpectrumValue> rxPsdNew = params.lossModel->DoCalcRxPowerSpectralDensity (params.txPsd, params.txMob, params.rxMob, params.txAntenna, params.rxAntenna);
|
||||
Ptr<SpectrumValue> rxPsdNew = params.lossModel->DoCalcRxPowerSpectralDensity (params.txParams, params.txMob, params.rxMob, params.txAntenna, params.rxAntenna);
|
||||
NS_TEST_ASSERT_MSG_EQ (ArePsdEqual (params.rxPsdOld, rxPsdNew), false, "The long term is not updated when the channel matrix is recomputed");
|
||||
}
|
||||
|
||||
@@ -547,13 +525,15 @@ ThreeGppSpectrumPropagationLossModelTest::DoRun ()
|
||||
WifiSpectrumValue5MhzFactory sf;
|
||||
double txPower = 0.1; // Watts
|
||||
uint32_t channelNumber = 1;
|
||||
Ptr<SpectrumValue> txPsd = sf.CreateTxPowerSpectralDensity (txPower, channelNumber);
|
||||
Ptr<SpectrumValue> txPsd = sf.CreateTxPowerSpectralDensity (txPower, channelNumber);
|
||||
Ptr<SpectrumSignalParameters> txParams = Create<SpectrumSignalParameters> ();
|
||||
txParams->psd = txPsd->Copy ();
|
||||
|
||||
// compute the rx psd
|
||||
Ptr<SpectrumValue> rxPsdOld = lossModel->DoCalcRxPowerSpectralDensity (txPsd, txMob, rxMob, txAntenna, rxAntenna);
|
||||
Ptr<SpectrumValue> rxPsdOld = lossModel->DoCalcRxPowerSpectralDensity (txParams, txMob, rxMob, txAntenna, rxAntenna);
|
||||
|
||||
// 1) check that the rx PSD is equal for both the direct and the reverse channel
|
||||
Ptr<SpectrumValue> rxPsdNew = lossModel->DoCalcRxPowerSpectralDensity (txPsd, rxMob, txMob, rxAntenna, txAntenna);
|
||||
Ptr<SpectrumValue> rxPsdNew = lossModel->DoCalcRxPowerSpectralDensity (txParams, rxMob, txMob, rxAntenna, txAntenna);
|
||||
NS_TEST_ASSERT_MSG_EQ (ArePsdEqual (rxPsdOld, rxPsdNew), true, "The long term for the direct and the reverse channel are different");
|
||||
|
||||
// 2) check if the long term is updated when changing the BF vector
|
||||
@@ -563,15 +543,16 @@ ThreeGppSpectrumPropagationLossModelTest::DoRun ()
|
||||
txBfVector [0] = std::complex<double> (0.0, 0.0);
|
||||
txAntenna->SetBeamformingVector (txBfVector);
|
||||
|
||||
rxPsdNew = lossModel->DoCalcRxPowerSpectralDensity (txPsd, rxMob, txMob, rxAntenna, txAntenna);
|
||||
rxPsdNew = lossModel->DoCalcRxPowerSpectralDensity (txParams, rxMob, txMob, rxAntenna, txAntenna);
|
||||
NS_TEST_ASSERT_MSG_EQ (ArePsdEqual (rxPsdOld, rxPsdNew), false, "Changing the BF vectors the rx PSD does not change");
|
||||
|
||||
// update rxPsdOld
|
||||
rxPsdOld = rxPsdNew;
|
||||
|
||||
// 3) check if the long term is updated when the channel matrix is recomputed
|
||||
CheckLongTermUpdateParams params{lossModel, txParams, txMob, rxMob, rxPsdOld, txAntenna, rxAntenna};
|
||||
Simulator::Schedule (MilliSeconds (101), &ThreeGppSpectrumPropagationLossModelTest::CheckLongTermUpdate,
|
||||
this, CheckLongTermUpdateParams (lossModel, txPsd, txMob, rxMob, rxPsdOld, txAntenna, rxAntenna));
|
||||
this, params);
|
||||
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
|
||||
Reference in New Issue
Block a user