diff --git a/src/antenna/model/three-gpp-antenna-model.cc b/src/antenna/model/three-gpp-antenna-model.cc index d1a02f8eff..250242482a 100644 --- a/src/antenna/model/three-gpp-antenna-model.cc +++ b/src/antenna/model/three-gpp-antenna-model.cc @@ -9,6 +9,7 @@ #include "antenna-model.h" #include +#include #include #include @@ -23,20 +24,34 @@ NS_OBJECT_ENSURE_REGISTERED(ThreeGppAntennaModel); TypeId ThreeGppAntennaModel::GetTypeId() { - static TypeId tid = TypeId("ns3::ThreeGppAntennaModel") - .SetParent() - .SetGroupName("Antenna") - .AddConstructor(); + static TypeId tid = + TypeId("ns3::ThreeGppAntennaModel") + .SetParent() + .SetGroupName("Antenna") + .AddConstructor() + .AddAttribute( + "RadiationPattern", + "Radiation pattern of 3GPP antenna model", + EnumValue(RadiationPattern::OUTDOOR), + MakeEnumAccessor(&ThreeGppAntennaModel::SetRadiationPattern, + &ThreeGppAntennaModel::GetRadiationPattern), + MakeEnumChecker(RadiationPattern::OUTDOOR, + "Outdoor", + RadiationPattern::INDOOR, + "Indoor")); return tid; } ThreeGppAntennaModel::ThreeGppAntennaModel() - : m_verticalBeamwidthDegrees{65}, - m_horizontalBeamwidthDegrees{65}, - m_aMax{30}, - m_slaV{30}, - m_geMax{8.0} { + SetRadiationPattern(RadiationPattern::OUTDOOR); +} + +void +ThreeGppAntennaModel::DoInitialize() +{ + NS_LOG_FUNCTION(this); + SetRadiationPattern(m_radiationPattern); } ThreeGppAntennaModel::~ThreeGppAntennaModel() @@ -55,6 +70,49 @@ ThreeGppAntennaModel::GetHorizontalBeamwidth() const return m_horizontalBeamwidthDegrees; } +void +ThreeGppAntennaModel::SetRadiationPattern(RadiationPattern pattern) +{ + m_radiationPattern = pattern; + switch (pattern) + { + case RadiationPattern::OUTDOOR: + SetOutdoorAntennaPattern(); + break; + case RadiationPattern::INDOOR: + SetIndoorAntennaPattern(); + break; + default: + NS_ABORT_MSG("Unknown radiation pattern"); + } +} + +ThreeGppAntennaModel::RadiationPattern +ThreeGppAntennaModel::GetRadiationPattern() const +{ + return m_radiationPattern; +} + +void +ThreeGppAntennaModel::SetOutdoorAntennaPattern() +{ + m_verticalBeamwidthDegrees = 65; + m_horizontalBeamwidthDegrees = 65; + m_aMax = 30; + m_slaV = 30; + m_geMax = 8; +} + +void +ThreeGppAntennaModel::SetIndoorAntennaPattern() +{ + m_verticalBeamwidthDegrees = 90; + m_horizontalBeamwidthDegrees = 90; + m_aMax = 25; + m_slaV = 25; + m_geMax = 5; +} + double ThreeGppAntennaModel::GetSlaV() const { diff --git a/src/antenna/model/three-gpp-antenna-model.h b/src/antenna/model/three-gpp-antenna-model.h index c29fddb9fa..b26aa013bb 100644 --- a/src/antenna/model/three-gpp-antenna-model.h +++ b/src/antenna/model/three-gpp-antenna-model.h @@ -22,6 +22,15 @@ namespace ns3 class ThreeGppAntennaModel : public AntennaModel { public: + /** + * The different antenna radiation patterns defined in ITU-R M.2412. + */ + enum class RadiationPattern + { + OUTDOOR, + INDOOR + }; + ThreeGppAntennaModel(); ~ThreeGppAntennaModel() override; @@ -46,6 +55,18 @@ class ThreeGppAntennaModel : public AntennaModel */ double GetHorizontalBeamwidth() const; + /** + * Set the antenna radiation pattern + * @param pattern the antenna radiation pattern to used + */ + void SetRadiationPattern(RadiationPattern pattern); + + /** + * Get the antenna radiation pattern + * @return the radiation pattern of the antenna + */ + RadiationPattern GetRadiationPattern() const; + /** * Get the side-lobe attenuation in the vertical direction of the antenna element. * @return side-lobe attenuation in the vertical direction in dB @@ -65,6 +86,21 @@ class ThreeGppAntennaModel : public AntennaModel double GetAntennaElementGain() const; private: + // Inherited from Object. + // Waits for the attribute values to be set before setting the radiation pattern values + void DoInitialize() override; + + /** + * Set the radiation pattern Dense Urban – eMBB, Rural – eMBB, Urban Macro – mMTC, and Urban + * Macro - URLLC, Table 8-6 in Report ITU-R M.2412 + */ + void SetOutdoorAntennaPattern(); + + /** + * Set the radiation pattern for Indoor Hotspot - eMBB, Table 8-7 in Report ITU-R M.2412 + */ + void SetIndoorAntennaPattern(); + double m_verticalBeamwidthDegrees; //!< beamwidth in the vertical direction \f$(\theta_{3dB})\f$ //!< [deg] double m_horizontalBeamwidthDegrees; //!< beamwidth in the horizontal direction @@ -72,6 +108,7 @@ class ThreeGppAntennaModel : public AntennaModel double m_aMax; //!< maximum attenuation (A_{max}) [dB] double m_slaV; //!< side-lobe attenuation in the vertical direction (SLA_V) [dB] double m_geMax; //!< maximum directional gain of the antenna element (G_{E,max}) [dBi] + RadiationPattern m_radiationPattern; //!< current antenna radiation pattern }; } // namespace ns3