diff --git a/src/lr-wpan/examples/lr-wpan-error-distance-plot.cc b/src/lr-wpan/examples/lr-wpan-error-distance-plot.cc index 38287b025..474248612 100644 --- a/src/lr-wpan/examples/lr-wpan-error-distance-plot.cc +++ b/src/lr-wpan/examples/lr-wpan-error-distance-plot.cc @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -95,7 +96,7 @@ int main (int argc, char *argv[]) Ptr dev1 = CreateObject (); dev0->SetAddress (Mac16Address ("00:01")); dev1->SetAddress (Mac16Address ("00:02")); - Ptr channel = CreateObject (); + Ptr channel = CreateObject (); Ptr model = CreateObject (); channel->AddPropagationLossModel (model); dev0->SetChannel (channel); diff --git a/src/lr-wpan/helper/lr-wpan-helper.cc b/src/lr-wpan/helper/lr-wpan-helper.cc index f7f539cd7..af7024445 100644 --- a/src/lr-wpan/helper/lr-wpan-helper.cc +++ b/src/lr-wpan/helper/lr-wpan-helper.cc @@ -25,8 +25,11 @@ #include #include #include +#include #include +#include #include +#include "ns3/names.h" namespace ns3 { @@ -63,8 +66,29 @@ AsciiLrWpanMacTransmitSinkWithoutContext ( LrWpanHelper::LrWpanHelper (void) { m_channel = CreateObject (); - Ptr model = CreateObject (); - m_channel->AddPropagationLossModel (model); + + Ptr lossModel = CreateObject (); + m_channel->AddPropagationLossModel (lossModel); + + Ptr delayModel = CreateObject (); + m_channel->SetPropagationDelayModel (delayModel); +} + +LrWpanHelper::LrWpanHelper (bool useMultiModelSpectrumChannel) +{ + if (useMultiModelSpectrumChannel) + { + m_channel = CreateObject (); + } + else + { + m_channel = CreateObject (); + } + Ptr lossModel = CreateObject (); + m_channel->AddPropagationLossModel (lossModel); + + Ptr delayModel = CreateObject (); + m_channel->SetPropagationDelayModel (delayModel); } LrWpanHelper::~LrWpanHelper (void) @@ -167,6 +191,27 @@ LrWpanHelper::Install (NodeContainer c) return devices; } + +Ptr +LrWpanHelper::GetChannel (void) +{ + return m_channel; +} + +void +LrWpanHelper::SetChannel (Ptr channel) +{ + m_channel = channel; +} + +void +LrWpanHelper::SetChannel (std::string channelName) +{ + Ptr channel = Names::Find (channelName); + m_channel = channel; +} + + int64_t LrWpanHelper::AssignStreams (NetDeviceContainer c, int64_t stream) { diff --git a/src/lr-wpan/helper/lr-wpan-helper.h b/src/lr-wpan/helper/lr-wpan-helper.h index 8e3e74947..67a4d8d77 100644 --- a/src/lr-wpan/helper/lr-wpan-helper.h +++ b/src/lr-wpan/helper/lr-wpan-helper.h @@ -29,7 +29,7 @@ namespace ns3 { -class SingleModelSpectrumChannel; +class SpectrumChannel; class MobilityModel; /** @@ -40,6 +40,10 @@ class MobilityModel; * This class can help to create IEEE 802.15.4 NetDevice objects * and to configure their attributes during creation. It also contains * additional helper functions used by client code. + * + * Only one channel is created, and all devices attached to it. If + * multiple channels are needed, multiple helper objects must be used, + * or else the channel object must be replaced. */ class LrWpanHelper : public PcapHelperForDevice, @@ -47,16 +51,50 @@ class LrWpanHelper : public PcapHelperForDevice, { public: /** - * \brief Create a LrWpan helper in an empty state. + * \brief Create a LrWpan helper in an empty state. By default, a + * SingleModelSpectrumChannel is created, with a + * LogDistancePropagationLossModel and a ConstantSpeedPropagationDelayModel. + * + * To change the channel type, loss model, or delay model, the Get/Set + * Channel methods may be used. */ LrWpanHelper (void); + + /** + * \brief Create a LrWpan helper in an empty state with either a + * SingleModelSpectrumChannel or a MultiModelSpectrumChannel. + * \param useMultiModelSpectrumChannel use a MultiModelSpectrumChannel if true, a SingleModelSpectrumChannel otherwise + * + * A LogDistancePropagationLossModel and a + * ConstantSpeedPropagationDelayModel are added to the channel. + */ + LrWpanHelper (bool useMultiModelSpectrumChannel); + virtual ~LrWpanHelper (void); /** - * \brief Add mobility model to a physical device - * \param phy the physical device - * \param m the mobility model - */ + * \brief Get the channel associated to this helper + * \returns the channel + */ + Ptr GetChannel (void); + + /** + * \brief Set the channel associated to this helper + * \param channel the channel + */ + void SetChannel (Ptr channel); + + /** + * \brief Set the channel associated to this helper + * \param channelName the channel name + */ + void SetChannel (std::string channelName); + + /** + * \brief Add mobility model to a physical device + * \param phy the physical device + * \param m the mobility model + */ void AddMobility (Ptr phy, Ptr m); /** @@ -147,7 +185,7 @@ private: bool explicitFilename); private: - Ptr m_channel; //!< channel to be used for the devices + Ptr m_channel; //!< channel to be used for the devices };