From 84768dcbbe80002c4b495c02ce67ca07dda53dbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Sun, 30 Dec 2018 11:55:33 +0100 Subject: [PATCH] wifi: Extend helper to set frame capture model --- src/wifi/helper/spectrum-wifi-helper.cc | 6 +++++ src/wifi/helper/wifi-helper.cc | 23 ++++++++++++++++++ src/wifi/helper/wifi-helper.h | 31 +++++++++++++++++++++++++ src/wifi/helper/yans-wifi-helper.cc | 6 +++++ 4 files changed, 66 insertions(+) diff --git a/src/wifi/helper/spectrum-wifi-helper.cc b/src/wifi/helper/spectrum-wifi-helper.cc index 5d3ec4778..858786fa5 100644 --- a/src/wifi/helper/spectrum-wifi-helper.cc +++ b/src/wifi/helper/spectrum-wifi-helper.cc @@ -23,6 +23,7 @@ #include "ns3/names.h" #include "ns3/spectrum-wifi-phy.h" #include "ns3/error-rate-model.h" +#include "ns3/frame-capture-model.h" #include "ns3/mobility-model.h" #include "spectrum-wifi-helper.h" @@ -64,6 +65,11 @@ SpectrumWifiPhyHelper::Create (Ptr node, Ptr device) const phy->CreateWifiSpectrumPhyInterface (device); Ptr error = m_errorRateModel.Create (); phy->SetErrorRateModel (error); + if (m_frameCaptureModel.GetTypeId ().GetUid ()) + { + Ptr capture = m_frameCaptureModel.Create (); + phy->SetFrameCaptureModel (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 223984b7d..1ed91e739 100644 --- a/src/wifi/helper/wifi-helper.cc +++ b/src/wifi/helper/wifi-helper.cc @@ -165,6 +165,29 @@ WifiPhyHelper::SetErrorRateModel (std::string name, m_errorRateModel.Set (n7, v7); } +void +WifiPhyHelper::SetFrameCaptureModel (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_frameCaptureModel = ObjectFactory (); + m_frameCaptureModel.SetTypeId (name); + m_frameCaptureModel.Set (n0, v0); + m_frameCaptureModel.Set (n1, v1); + m_frameCaptureModel.Set (n2, v2); + m_frameCaptureModel.Set (n3, v3); + m_frameCaptureModel.Set (n4, v4); + m_frameCaptureModel.Set (n5, v5); + m_frameCaptureModel.Set (n6, v6); + m_frameCaptureModel.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 55e621c83..f4b2db4aa 100644 --- a/src/wifi/helper/wifi-helper.h +++ b/src/wifi/helper/wifi-helper.h @@ -100,6 +100,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 error rate 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 frame capture model and its attributes to use when Install is called. + */ + void SetFrameCaptureModel (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 @@ -168,6 +198,7 @@ protected: ObjectFactory m_phy; ///< PHY object ObjectFactory m_errorRateModel; ///< error rate model + ObjectFactory m_frameCaptureModel; ///< frame capture model private: diff --git a/src/wifi/helper/yans-wifi-helper.cc b/src/wifi/helper/yans-wifi-helper.cc index f342e9654..72f0bbccd 100644 --- a/src/wifi/helper/yans-wifi-helper.cc +++ b/src/wifi/helper/yans-wifi-helper.cc @@ -24,6 +24,7 @@ #include "ns3/propagation-loss-model.h" #include "ns3/propagation-delay-model.h" #include "ns3/error-rate-model.h" +#include "ns3/frame-capture-model.h" #include "ns3/yans-wifi-phy.h" #include "yans-wifi-helper.h" @@ -154,6 +155,11 @@ YansWifiPhyHelper::Create (Ptr node, Ptr device) const Ptr phy = m_phy.Create (); Ptr error = m_errorRateModel.Create (); phy->SetErrorRateModel (error); + if (m_frameCaptureModel.GetTypeId ().GetUid ()) + { + Ptr capture = m_frameCaptureModel.Create (); + phy->SetFrameCaptureModel (capture); + } phy->SetChannel (m_channel); phy->SetDevice (device); return phy;