25 #include "ns3/net-device.h" 26 #include "ns3/three-gpp-antenna-array-model.h" 28 #include "ns3/channel-condition-model.h" 29 #include "ns3/double.h" 30 #include "ns3/string.h" 31 #include "ns3/simulator.h" 32 #include "ns3/pointer.h" 44 m_uniformRv = CreateObject<UniformRandomVariable> ();
64 static TypeId tid =
TypeId (
"ns3::ThreeGppSpectrumPropagationLossModel")
66 .SetGroupName (
"Spectrum")
68 .AddAttribute(
"ChannelModel",
69 "The channel model. It needs to implement the MatrixBasedChannelModel interface",
73 MakePointerChecker<MatrixBasedChannelModel> ())
74 .AddAttribute (
"vScatt",
75 "Maximum speed of the vehicle in the layout (see 3GPP TR 37.885 v15.3.0, Sec. 6.2.3)." 76 "Used to compute the additional contribution for the Doppler of" 77 "delayed (reflected) paths",
80 MakeDoubleChecker<double> (0.0))
131 uint16_t sAntenna =
static_cast<uint16_t
> (sW.size ());
132 uint16_t uAntenna =
static_cast<uint16_t
> (uW.size ());
134 NS_LOG_DEBUG (
"CalcLongTerm with sAntenna " << sAntenna <<
" uAntenna " << uAntenna);
138 uint8_t numCluster =
static_cast<uint8_t
> (params->m_channel[0][0].size ());
140 for (uint8_t cIndex = 0; cIndex < numCluster; cIndex++)
142 std::complex<double> txSum (0,0);
143 for (uint16_t sIndex = 0; sIndex < sAntenna; sIndex++)
145 std::complex<double> rxSum (0,0);
146 for (uint16_t uIndex = 0; uIndex < uAntenna; uIndex++)
148 rxSum = rxSum + uW[uIndex] * params->m_channel[uIndex][sIndex][cIndex];
150 txSum = txSum + sW[sIndex] * rxSum;
152 longTerm.push_back (txSum);
161 const ns3::Vector &sSpeed,
const ns3::Vector &uSpeed)
const 168 uint8_t numCluster =
static_cast<uint8_t
> (params->m_channel[0][0].size ());
175 for (uint8_t cIndex = 0; cIndex < numCluster; cIndex++)
203 doppler.push_back (exp (std::complex<double> (0, temp_doppler)));
212 std::complex<double> subsbandGain (0.0,0.0);
215 double fsb = (*sbit).fc;
216 for (uint8_t cIndex = 0; cIndex < numCluster; cIndex++)
218 double delay = -2 * M_PI * fsb * (params->m_delay[cIndex]);
219 subsbandGain = subsbandGain + longTerm[cIndex] * doppler[cIndex] * exp (std::complex<double> (0, delay));
221 *vit = (*vit) * (
norm (subsbandGain));
240 if (!channelMatrix->IsReverse (aId, bId))
257 bool notFound =
false;
262 NS_LOG_DEBUG (
"found the long term component in the map");
268 update = (
m_longTermMap[longTermId]->m_channel->m_generatedTime != channelMatrix->m_generatedTime
279 if (update || notFound)
289 longTermItem->
m_sW = sW;
290 longTermItem->
m_uW = uW;
304 uint32_t aId = a->GetObject<
Node> ()->GetId ();
305 uint32_t bId = b->GetObject<
Node> ()->GetId ();
308 NS_ASSERT_MSG (a->GetDistanceFrom (b) > 0.0,
"The position of a and b devices cannot be the same");
315 NS_LOG_DEBUG (
"a node " << a->GetObject<
Node> () <<
" antenna " << aAntenna);
320 NS_LOG_DEBUG (
"b node " << bId <<
" antenna " << bAntenna);
322 if (aAntenna->IsOmniTx () || bAntenna->IsOmniTx () )
338 rxPsd =
CalcBeamformingGain (rxPsd, longTerm, channelMatrix, a->GetVelocity (), b->GetVelocity ());
void SetChannelModel(Ptr< MatrixBasedChannelModel > channel)
Set the channel model object.
Smart pointer class similar to boost::intrusive_ptr.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
std::unordered_map< uint32_t, Ptr< const LongTerm > > m_longTermMap
map containing the long term components
std::vector< std::complex< double > > ComplexVector
type definition for complex vectors
ThreeGppAntennaArrayModel::ComplexVector CalcLongTerm(Ptr< const MatrixBasedChannelModel::ChannelMatrix > channelMatrix, const ThreeGppAntennaArrayModel::ComplexVector &sW, const ThreeGppAntennaArrayModel::ComplexVector &uW) const
Computes the long term component.
~ThreeGppSpectrumPropagationLossModel()
Destructor.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Hold variables of type string.
Hold a value for an Attribute.
ThreeGppAntennaArrayModel::ComplexVector GetLongTerm(uint32_t aId, uint32_t bId, Ptr< const MatrixBasedChannelModel::ChannelMatrix > channelMatrix, const ThreeGppAntennaArrayModel::ComplexVector &aW, const ThreeGppAntennaArrayModel::ComplexVector &bW) const
Looks for the long term component in m_longTermMap.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
ThreeGppAntennaArrayModel::ComplexVector m_sW
the beamforming vector for the node s used to compute the long term
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
void DoDispose() override
Destructor implementation.
Values::iterator ValuesEnd()
ThreeGppAntennaArrayModel::ComplexVector m_uW
the beamforming vector for the node u used to compute the long term
static const uint8_t AOD_INDEX
index of the AOD value in the m_angle array
3GPP Spectrum Propagation Loss Model
static TypeId GetTypeId()
Get the type ID.
std::unordered_map< uint32_t, Ptr< const ThreeGppAntennaArrayModel > > m_deviceAntennaMap
map containig the <node, antenna> associations
Ptr< MatrixBasedChannelModel > GetChannelModel() const
Get the channel model object.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Ptr< SpectrumValue > CalcBeamformingGain(Ptr< SpectrumValue > txPsd, ThreeGppAntennaArrayModel::ComplexVector longTerm, Ptr< const MatrixBasedChannelModel::ChannelMatrix > params, const Vector &sSpeed, const Vector &uSpeed) const
Computes the beamforming gain and applies it to the tx PSD.
void AddDevice(Ptr< NetDevice > n, Ptr< const ThreeGppAntennaArrayModel > a)
Add a device-antenna pair.
double GetFrequency() const
Get the operating frequency.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
static const uint8_t ZOA_INDEX
index of the ZOA value in the m_angle array
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ThreeGppAntennaArrayModel::ComplexVector m_longTerm
vector containing the long term component for each cluster
static constexpr uint32_t GetKey(uint32_t x1, uint32_t x2)
Calculate the channel key using the Cantor function.
static Time Now(void)
Return the current simulation virtual time.
ThreeGppSpectrumPropagationLossModel()
Constructor.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
double m_vScatt
value used to compute the additional Doppler contribution for the delayed paths
Values::iterator ValuesBegin()
Ptr< const MatrixBasedChannelModel::ChannelMatrix > m_channel
pointer to the channel matrix used to compute the long term
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Ptr< UniformRandomVariable > m_uniformRv
uniform random variable, used to compute the additional Doppler contribution
static const uint8_t AOA_INDEX
index of the AOA value in the m_angle array
const double norm
Normalization to obtain randoms on [0,1).
Ptr< MatrixBasedChannelModel > m_channelModel
the model to generate the channel matrix
void GetChannelModelAttribute(const std::string &name, AttributeValue &value) const
Returns the value of an attribute belonging to the associated MatrixBasedChannelModel instance...
Ptr< SpectrumValue > DoCalcRxPowerSpectralDensity(Ptr< const SpectrumValue > txPsd, Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Computes the received PSD.
spectrum-aware propagation loss model
This class can be used to hold variables of floating point type such as 'double' or 'float'...
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
void SetChannelModelAttribute(const std::string &name, const AttributeValue &value)
Sets the value of an attribute belonging to the associated MatrixBasedChannelModel instance...
Bands::const_iterator ConstBandsBegin() const
static const uint8_t ZOD_INDEX
index of the ZOD value in the m_angle array