Skip to content

Commit 9b53226

Browse files
propagation: Add a prologue function to ThreeGppPropagationLossModel
Allows for wraparound models to replace txMobilityModel via a custom function
1 parent 461547b commit 9b53226

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

src/propagation/model/three-gpp-propagation-loss-model.cc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,9 @@ NS_LOG_COMPONENT_DEFINE("ThreeGppPropagationLossModel");
263263

264264
NS_OBJECT_ENSURE_REGISTERED(ThreeGppPropagationLossModel);
265265

266+
std::function<Ptr<MobilityModel>(Ptr<const MobilityModel>, Ptr<const MobilityModel>)>
267+
ThreeGppPropagationLossModel::m_doCalcRxPowerPrologueFunction;
268+
266269
TypeId
267270
ThreeGppPropagationLossModel::GetTypeId()
268271
{
@@ -375,11 +378,19 @@ ThreeGppPropagationLossModel::IsO2iLowPenetrationLoss(Ptr<const ChannelCondition
375378

376379
double
377380
ThreeGppPropagationLossModel::DoCalcRxPower(double txPowerDbm,
378-
Ptr<MobilityModel> a,
381+
Ptr<MobilityModel> c,
379382
Ptr<MobilityModel> b) const
380383
{
381384
NS_LOG_FUNCTION(this);
382385

386+
// if there is a prologue function installed, call it and replace the transmitter mobility model
387+
auto a = m_doCalcRxPowerPrologueFunction ? m_doCalcRxPowerPrologueFunction(b, c) : c;
388+
if (a->GetPosition() != c->GetPosition())
389+
{
390+
NS_LOG_DEBUG("Prologue function replaced source position "
391+
<< c->GetPosition() << " with position " << a->GetPosition());
392+
}
393+
383394
// check if the model is initialized
384395
NS_ASSERT_MSG(m_frequency != 0.0, "First set the centre frequency");
385396

src/propagation/model/three-gpp-propagation-loss-model.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,26 @@ class ThreeGppPropagationLossModel : public PropagationLossModel
7575
*/
7676
bool IsO2iLowPenetrationLoss(Ptr<const ChannelCondition> cond) const;
7777

78+
/**
79+
* @brief Stop-gap solution for wraparound model
80+
*
81+
* Stop-gap solution for support of wraparound model in the 5G NR module. This
82+
* method was introduced for ns-3.45 but will be removed in a future release once
83+
* a more general solution is added elsewhere (most likely in the spectrum channel). The
84+
* callback method registered here will be executed at the beginning of DoCalcRxPower, and the
85+
* returned pointer to a mobility model will be subsequently used as the (replacement) source
86+
* mobility model for the rest of DoCalcRxPower() processing.
87+
*
88+
* @param prologueFunction Function that receives two mobility models and compute a third, based
89+
* on the wrapped position of the second model in respect to the first
90+
*/
91+
static void InstallDoCalcRxPowerPrologueFunction(
92+
std::function<Ptr<MobilityModel>(Ptr<const MobilityModel>, Ptr<const MobilityModel>)>
93+
prologueFunction)
94+
{
95+
m_doCalcRxPowerPrologueFunction = prologueFunction;
96+
}
97+
7898
private:
7999
/**
80100
* Computes the received power by applying the pathloss model described in
@@ -300,6 +320,10 @@ class ThreeGppPropagationLossModel : public PropagationLossModel
300320
Ptr<NormalRandomVariable>
301321
m_normalO2iHighLossVar; //!< a normal random variable for the calculation of 02i high loss,
302322
//!< see TR38.901 Table 7.4.3-2
323+
324+
/// Optional prologue function that can be used to implement wraparound models
325+
static std::function<Ptr<MobilityModel>(Ptr<const MobilityModel>, Ptr<const MobilityModel>)>
326+
m_doCalcRxPowerPrologueFunction;
303327
};
304328

305329
/**

0 commit comments

Comments
 (0)