diff --git a/src/wifi/helper/spectrum-wifi-helper.cc b/src/wifi/helper/spectrum-wifi-helper.cc index 858786fa5..3499b5d86 100644 --- a/src/wifi/helper/spectrum-wifi-helper.cc +++ b/src/wifi/helper/spectrum-wifi-helper.cc @@ -24,6 +24,7 @@ #include "ns3/spectrum-wifi-phy.h" #include "ns3/error-rate-model.h" #include "ns3/frame-capture-model.h" +#include "ns3/preamble-detection-model.h" #include "ns3/mobility-model.h" #include "spectrum-wifi-helper.h" @@ -70,6 +71,11 @@ SpectrumWifiPhyHelper::Create (Ptr node, Ptr device) const Ptr capture = m_frameCaptureModel.Create (); phy->SetFrameCaptureModel (capture); } + if (m_preambleDetectionModel.GetTypeId ().GetUid ()) + { + Ptr capture = m_preambleDetectionModel.Create (); + phy->SetPreambleDetectionModel (capture); + } phy->SetChannel (m_channel); phy->SetDevice (device); phy->SetMobility (node->GetObject ()); diff --git a/src/wifi/helper/wifi-helper.cc b/src/wifi/helper/wifi-helper.cc index d62b00442..8de1142cf 100644 --- a/src/wifi/helper/wifi-helper.cc +++ b/src/wifi/helper/wifi-helper.cc @@ -188,6 +188,29 @@ WifiPhyHelper::SetFrameCaptureModel (std::string name, m_frameCaptureModel.Set (n7, v7); } +void +WifiPhyHelper::SetPreambleDetectionModel (std::string name, + std::string n0, const AttributeValue &v0, + std::string n1, const AttributeValue &v1, + std::string n2, const AttributeValue &v2, + std::string n3, const AttributeValue &v3, + std::string n4, const AttributeValue &v4, + std::string n5, const AttributeValue &v5, + std::string n6, const AttributeValue &v6, + std::string n7, const AttributeValue &v7) +{ + m_preambleDetectionModel = ObjectFactory (); + m_preambleDetectionModel.SetTypeId (name); + m_preambleDetectionModel.Set (n0, v0); + m_preambleDetectionModel.Set (n1, v1); + m_preambleDetectionModel.Set (n2, v2); + m_preambleDetectionModel.Set (n3, v3); + m_preambleDetectionModel.Set (n4, v4); + m_preambleDetectionModel.Set (n5, v5); + m_preambleDetectionModel.Set (n6, v6); + m_preambleDetectionModel.Set (n7, v7); +} + void WifiPhyHelper::PcapSniffTxEvent ( Ptr file, diff --git a/src/wifi/helper/wifi-helper.h b/src/wifi/helper/wifi-helper.h index f4b2db4aa..742e33d71 100644 --- a/src/wifi/helper/wifi-helper.h +++ b/src/wifi/helper/wifi-helper.h @@ -101,7 +101,7 @@ public: std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); /** - * \param name the name of the error rate model to set. + * \param name the name of the frame capture model to set. * \param n0 the name of the attribute to set * \param v0 the value of the attribute to set * \param n1 the name of the attribute to set @@ -130,6 +130,36 @@ public: std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + /** + * \param name the name of the preamble detection model to set. + * \param n0 the name of the attribute to set + * \param v0 the value of the attribute to set + * \param n1 the name of the attribute to set + * \param v1 the value of the attribute to set + * \param n2 the name of the attribute to set + * \param v2 the value of the attribute to set + * \param n3 the name of the attribute to set + * \param v3 the value of the attribute to set + * \param n4 the name of the attribute to set + * \param v4 the value of the attribute to set + * \param n5 the name of the attribute to set + * \param v5 the value of the attribute to set + * \param n6 the name of the attribute to set + * \param v6 the value of the attribute to set + * \param n7 the name of the attribute to set + * \param v7 the value of the attribute to set + * + * Set the preamble detection model and its attributes to use when Install is called. + */ + void SetPreambleDetectionModel (std::string name, + std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), + std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), + std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), + std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), + std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), + std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), + std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), + std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); /** * An enumeration of the pcap data link types (DLTs) which this helper @@ -199,6 +229,7 @@ protected: ObjectFactory m_phy; ///< PHY object ObjectFactory m_errorRateModel; ///< error rate model ObjectFactory m_frameCaptureModel; ///< frame capture model + ObjectFactory m_preambleDetectionModel; ///< preamble detection model private: diff --git a/src/wifi/helper/yans-wifi-helper.cc b/src/wifi/helper/yans-wifi-helper.cc index 72f0bbccd..bb4ae1767 100644 --- a/src/wifi/helper/yans-wifi-helper.cc +++ b/src/wifi/helper/yans-wifi-helper.cc @@ -25,6 +25,7 @@ #include "ns3/propagation-delay-model.h" #include "ns3/error-rate-model.h" #include "ns3/frame-capture-model.h" +#include "ns3/preamble-detection-model.h" #include "ns3/yans-wifi-phy.h" #include "yans-wifi-helper.h" @@ -160,6 +161,11 @@ YansWifiPhyHelper::Create (Ptr node, Ptr device) const Ptr capture = m_frameCaptureModel.Create (); phy->SetFrameCaptureModel (capture); } + if (m_preambleDetectionModel.GetTypeId ().GetUid ()) + { + Ptr capture = m_preambleDetectionModel.Create (); + phy->SetPreambleDetectionModel (capture); + } phy->SetChannel (m_channel); phy->SetDevice (device); return phy;