wifi: mobility initialization and caching in WifiPhy
This commit is contained in:
@@ -363,6 +363,31 @@ WifiPhy::~WifiPhy()
|
||||
NS_LOG_FUNCTION(this);
|
||||
}
|
||||
|
||||
void
|
||||
WifiPhy::DoInitialize()
|
||||
{
|
||||
NS_LOG_FUNCTION(this);
|
||||
|
||||
// This method ensures that the local mobility model pointer holds
|
||||
// a pointer to the Node's aggregated mobility model (if one exists)
|
||||
// in the case that the user has not directly called SetMobility()
|
||||
// on this WifiPhy during simulation setup. If the mobility model
|
||||
// needs to be added or changed during simulation runtime, users must
|
||||
// call SetMobility() on this object.
|
||||
|
||||
if (!m_mobility)
|
||||
{
|
||||
NS_ABORT_MSG_UNLESS(m_device && m_device->GetNode(),
|
||||
"Either install a MobilityModel on this object or ensure that this "
|
||||
"object is part of a Node and NetDevice");
|
||||
m_mobility = m_device->GetNode()->GetObject<MobilityModel>();
|
||||
if (!m_mobility)
|
||||
{
|
||||
NS_LOG_WARN("Mobility not found, propagation models might not work properly");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WifiPhy::DoDispose()
|
||||
{
|
||||
@@ -592,14 +617,7 @@ WifiPhy::SetMobility(const Ptr<MobilityModel> mobility)
|
||||
Ptr<MobilityModel>
|
||||
WifiPhy::GetMobility() const
|
||||
{
|
||||
if (m_mobility)
|
||||
{
|
||||
return m_mobility;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_device->GetNode()->GetObject<MobilityModel>();
|
||||
}
|
||||
return m_mobility;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -1132,6 +1132,7 @@ class WifiPhy : public Object
|
||||
virtual WifiSpectrumBand GetBand(uint16_t bandWidth, uint8_t bandIndex = 0);
|
||||
|
||||
protected:
|
||||
void DoInitialize() override;
|
||||
void DoDispose() override;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user