diff --git a/src/spectrum/model/three-gpp-channel-model.cc b/src/spectrum/model/three-gpp-channel-model.cc index c05e917bb..dfd47a283 100644 --- a/src/spectrum/model/three-gpp-channel-model.cc +++ b/src/spectrum/model/three-gpp-channel-model.cc @@ -164,6 +164,7 @@ ThreeGppChannelModel::ThreeGppChannelModel () { NS_LOG_FUNCTION (this); m_uniformRv = CreateObject (); + m_uniformRvShuffle = CreateObject (); m_normalRv = CreateObject (); m_normalRv->SetAttribute ("Mean", DoubleValue (0.0)); @@ -978,6 +979,8 @@ ThreeGppChannelModel::GetNewChannel (Vector locUT, bool los, bool o2i, clusterDelay.erase (clusterDelay.begin () + cIndex - 1); } } + + NS_ASSERT(clusterPower.size () < UINT8_MAX); uint8_t numReducedCluster = clusterPower.size (); channelParams->m_numCluster = numReducedCluster; @@ -1032,7 +1035,7 @@ ThreeGppChannelModel::GetNewChannel (Vector locUT, bool los, bool o2i, C_NLOS = 1.289; break; default: - NS_FATAL_ERROR ("Invalide cluster number"); + NS_FATAL_ERROR ("Invalid cluster number"); } if (los) @@ -1069,7 +1072,7 @@ ThreeGppChannelModel::GetNewChannel (Vector locUT, bool los, bool o2i, C_NLOS = 1.178; break; default: - NS_FATAL_ERROR ("Invalide cluster number"); + NS_FATAL_ERROR ("Invalid cluster number"); } if (los) @@ -1290,10 +1293,10 @@ ThreeGppChannelModel::GetNewChannel (Vector locUT, bool los, bool o2i, //shuffle all the arrays to perform random coupling for (uint8_t cIndex = 0; cIndex < numReducedCluster; cIndex++) { - std::shuffle (&rayAod_radian[cIndex][0],&rayAod_radian[cIndex][raysPerCluster],std::default_random_engine (cIndex * 1000 + 100)); - std::shuffle (&rayAoa_radian[cIndex][0],&rayAoa_radian[cIndex][raysPerCluster],std::default_random_engine (cIndex * 1000 + 200)); - std::shuffle (&rayZod_radian[cIndex][0],&rayZod_radian[cIndex][raysPerCluster],std::default_random_engine (cIndex * 1000 + 300)); - std::shuffle (&rayZoa_radian[cIndex][0],&rayZoa_radian[cIndex][raysPerCluster],std::default_random_engine (cIndex * 1000 + 400)); + Shuffle (&rayAod_radian[cIndex][0], &rayAod_radian[cIndex][raysPerCluster]); + Shuffle (&rayAoa_radian[cIndex][0], &rayAoa_radian[cIndex][raysPerCluster]); + Shuffle (&rayZod_radian[cIndex][0], &rayZod_radian[cIndex][raysPerCluster]); + Shuffle (&rayZoa_radian[cIndex][0], &rayZoa_radian[cIndex][raysPerCluster]); } //Step 9: Generate the cross polarization power ratios @@ -1806,13 +1809,24 @@ ThreeGppChannelModel::CalcAttenuationOfBlockage (Ptr 0; --i) + { + std::swap (first[i], first[m_uniformRvShuffle->GetInteger (0, i)]); + } +} + int64_t ThreeGppChannelModel::AssignStreams (int64_t stream) { NS_LOG_FUNCTION (this << stream); m_normalRv->SetStream (stream); m_uniformRv->SetStream (stream + 1); - return 2; + m_uniformRvShuffle->SetStream (stream + 2); + return 3; } } // namespace ns3 diff --git a/src/spectrum/model/three-gpp-channel-model.h b/src/spectrum/model/three-gpp-channel-model.h index be6ba509a..a34c2b468 100644 --- a/src/spectrum/model/three-gpp-channel-model.h +++ b/src/spectrum/model/three-gpp-channel-model.h @@ -129,6 +129,12 @@ public: int64_t AssignStreams (int64_t stream); private: + /** + * \brief Shuffle the elements of a simple sequence container of type double + * \param first Pointer to the first element among the elements to be shuffled + * \param last Pointer to the last element among the elements to be shuffled + */ + void Shuffle (double * first, double * last) const; /** * Extends the struct ChannelMatrix by including information that are used * within the class ThreeGppChannelModel @@ -245,6 +251,7 @@ private: Ptr m_channelConditionModel; //!< the channel condition model Ptr m_uniformRv; //!< uniform random variable Ptr m_normalRv; //!< normal random variable + Ptr m_uniformRvShuffle; //!< uniform random variable used to shuffle array in GetNewChannel // parameters for the blockage model bool m_blockage; //!< enables the blockage model A