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" 63 static TypeId tid =
TypeId (
"ns3::ThreeGppSpectrumPropagationLossModel")
65 .SetGroupName (
"Spectrum")
67 .AddAttribute(
"ChannelModel",
68 "The channel model. It needs to implement the MatrixBasedChannelModel interface",
72 MakePointerChecker<MatrixBasedChannelModel> ())
123 uint16_t sAntenna =
static_cast<uint16_t
> (sW.size ());
124 uint16_t uAntenna =
static_cast<uint16_t
> (uW.size ());
126 NS_LOG_DEBUG (
"CalcLongTerm with sAntenna " << sAntenna <<
" uAntenna " << uAntenna);
130 uint8_t numCluster =
static_cast<uint8_t
> (params->m_channel[0][0].size ());
132 for (uint8_t cIndex = 0; cIndex < numCluster; cIndex++)
134 std::complex<double> txSum (0,0);
135 for (uint16_t sIndex = 0; sIndex < sAntenna; sIndex++)
137 std::complex<double> rxSum (0,0);
138 for (uint16_t uIndex = 0; uIndex < uAntenna; uIndex++)
140 rxSum = rxSum + uW[uIndex] * params->m_channel[uIndex][sIndex][cIndex];
142 txSum = txSum + sW[sIndex] * rxSum;
144 longTerm.push_back (txSum);
153 const ns3::Vector &sSpeed,
const ns3::Vector &uSpeed)
const 160 uint8_t numCluster =
static_cast<uint8_t
> (params->m_channel[0][0].size ());
167 for (uint8_t cIndex = 0; cIndex < numCluster; cIndex++)
178 doppler.push_back (exp (std::complex<double> (0, temp_doppler)));
187 std::complex<double> subsbandGain (0.0,0.0);
190 double fsb = (*sbit).fc;
191 for (uint8_t cIndex = 0; cIndex < numCluster; cIndex++)
193 double delay = -2 * M_PI * fsb * (params->m_delay[cIndex]);
194 subsbandGain = subsbandGain + longTerm[cIndex] * doppler[cIndex] * exp (std::complex<double> (0, delay));
196 *vit = (*vit) * (
norm (subsbandGain));
215 if (!channelMatrix->IsReverse (aId, bId))
232 bool notFound =
false;
237 NS_LOG_DEBUG (
"found the long term component in the map");
243 update = (
m_longTermMap[longTermId]->m_channel->m_generatedTime != channelMatrix->m_generatedTime
254 if (update || notFound)
264 longTermItem->
m_sW = sW;
265 longTermItem->
m_uW = uW;
279 uint32_t aId = a->GetObject<
Node> ()->GetId ();
280 uint32_t bId = b->GetObject<
Node> ()->GetId ();
283 NS_ASSERT_MSG (a->GetDistanceFrom (b) > 0.0,
"The position of a and b devices cannot be the same");
290 NS_LOG_DEBUG (
"a node " << a->GetObject<
Node> () <<
" antenna " << aAntenna);
295 NS_LOG_DEBUG (
"b node " << bId <<
" antenna " << bAntenna);
297 if (aAntenna->IsOmniTx () || bAntenna->IsOmniTx () )
313 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.
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
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.
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.
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
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.
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