A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lr-wpan-helper.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 The Boeing Company
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors:
7 * Gary Pei <guangyu.pei@boeing.com>
8 * Tom Henderson <thomas.r.henderson@boeing.com>
9 */
10#ifndef LR_WPAN_HELPER_H
11#define LR_WPAN_HELPER_H
12
13#include <ns3/lr-wpan-mac.h>
14#include <ns3/lr-wpan-phy.h>
15#include <ns3/node-container.h>
16#include <ns3/trace-helper.h>
17
18namespace ns3
19{
20
21class SpectrumChannel;
22class MobilityModel;
23
24/**
25 * @ingroup lr-wpan
26 *
27 * @brief helps to manage and create IEEE 802.15.4 NetDevice objects
28 *
29 * This class can help to create IEEE 802.15.4 NetDevice objects
30 * and to configure their attributes during creation. It also contains
31 * additional helper functions used by client code.
32 *
33 * Only one channel is created, and all devices attached to it. If
34 * multiple channels are needed, multiple helper objects must be used,
35 * or else the channel object must be replaced.
36 */
37
39{
40 public:
41 /**
42 * @brief Create a LrWpan helper in an empty state.
43 */
45
46 /**
47 * @brief Create a LrWpan helper in an empty state.
48 * @param useMultiModelSpectrumChannel use a MultiModelSpectrumChannel if true, a
49 * SingleModelSpectrumChannel otherwise
50 */
51 LrWpanHelper(bool useMultiModelSpectrumChannel);
52
53 ~LrWpanHelper() override;
54
55 // Delete copy constructor and assignment operator to avoid misuse
56 LrWpanHelper(const LrWpanHelper&) = delete;
58
59 /**
60 * @brief Get the channel associated to this helper
61 * @returns the channel
62 */
64
65 /**
66 * @brief Set the channel associated to this helper
67 * @param channel the channel
68 */
69 void SetChannel(Ptr<SpectrumChannel> channel);
70
71 /**
72 * @brief Set the channel associated to this helper
73 * @param channelName the channel name
74 */
75 void SetChannel(std::string channelName);
76
77 /**
78 * @tparam Ts \deduced Argument types
79 * @param name the name of the model to set
80 * @param [in] args Name and AttributeValue pairs to set.
81 *
82 * Add a propagation loss model to the set of currently-configured loss models.
83 */
84 template <typename... Ts>
85 void AddPropagationLossModel(std::string name, Ts&&... args);
86
87 /**
88 * @tparam Ts \deduced Argument types
89 * @param name the name of the model to set
90 * @param [in] args Name and AttributeValue pairs to set.
91 *
92 * Configure a propagation delay for this channel.
93 */
94 template <typename... Ts>
95 void SetPropagationDelayModel(std::string name, Ts&&... args);
96
97 /**
98 * @brief Add mobility model to a physical device
99 * @param phy the physical device
100 * @param m the mobility model
101 */
103
104 /**
105 * @brief Install a LrWpanNetDevice and the associated structures (e.g., channel) in the nodes.
106 *
107 * If the channel is not already initialized, it will be created as either a
108 * SingleModelSpectrumChannel or a MultiModelSpectrumChannel, depending on the
109 * useMultiModelSpectrumChannel flag. Additionally, a ConstantSpeedPropagationDelayModel will be
110 * set as the default delay model if no delay model is specified, and a
111 * LogDistancePropagationLossModel will be added to the channel if no propagation loss models
112 * are defined.
113 *
114 * If the channel is already initialized but lacks either a PropagationDelayModel or a
115 * PropagationLossModel, an error will be raised.
116 * @param c a set of nodes
117 * @returns A container holding the added net devices.
118 */
120
121 /**
122 * @brief Creates an PAN with associated nodes and assigned addresses(16 and 64)
123 * from the nodes in the node container.
124 * The first node in the container becomes the PAN coordinator.
125 *
126 * @param c a The node container with the nodes that will form the PAN.
127 * @param panId The PAN identifier.
128 */
129 void CreateAssociatedPan(NetDeviceContainer c, uint16_t panId);
130
131 /**
132 * @brief Set the extended 64 bit addresses (EUI-64) for a group of
133 * LrWpanNetDevices
134 *
135 * @param c The NetDevice container.
136 *
137 */
139
140 /**
141 * Helper to enable all LrWpan log components with one statement
142 */
143 void EnableLogComponents();
144
145 /**
146 * @brief Transform the LrWpanPhyEnumeration enumeration into a printable string.
147 * @param e the LrWpanPhyEnumeration
148 * @return a string
149 */
151
152 /**
153 * @brief Transform the LrWpanMacState enumeration into a printable string.
154 * @param e the LrWpanMacState
155 * @return a string
156 */
157 static std::string LrWpanMacStatePrinter(lrwpan::MacState e);
158
159 /**
160 * Assign a fixed random variable stream number to the random variables
161 * used by this model. Return the number of streams that have been
162 * assigned. The Install() method should have previously been
163 * called by the user.
164 *
165 * @param c NetDeviceContainer of the set of net devices for which the
166 * CsmaNetDevice should be modified to use a fixed stream
167 * @param stream first stream index to use
168 * @return the number of stream indices assigned by this helper
169 */
170 int64_t AssignStreams(NetDeviceContainer c, int64_t stream);
171
172 private:
173 /**
174 * @brief Enable pcap output on the indicated net device.
175 *
176 * NetDevice-specific implementation mechanism for hooking the trace and
177 * writing to the trace file.
178 *
179 * @param prefix Filename prefix to use for pcap files.
180 * @param nd Net device for which you want to enable tracing.
181 * @param promiscuous If true capture all possible packets available at the device.
182 * @param explicitFilename Treat the prefix as an explicit filename if true
183 */
184 void EnablePcapInternal(std::string prefix,
186 bool promiscuous,
187 bool explicitFilename) override;
188
189 /**
190 * @brief Enable ascii trace output on the indicated net device.
191 *
192 * NetDevice-specific implementation mechanism for hooking the trace and
193 * writing to the trace file.
194 *
195 * @param stream The output stream object to use when logging ascii traces.
196 * @param prefix Filename prefix to use for ascii trace files.
197 * @param nd Net device for which you want to enable tracing.
198 * @param explicitFilename Treat the prefix as an explicit filename if true
199 */
201 std::string prefix,
203 bool explicitFilename) override;
204
205 private:
206 Ptr<SpectrumChannel> m_channel; //!< channel to be used for the devices
207 bool m_useMultiModelSpectrumChannel; //!< indicates whether a MultiModelSpectrumChannel is used
208 std::vector<ObjectFactory> m_propagationLoss; ///< vector of propagation loss models
209 ObjectFactory m_propagationDelay; ///< propagation delay model
210};
211
212/***************************************************************
213 * Implementation of the templates declared above.
214 ***************************************************************/
215
216template <typename... Ts>
217void
218LrWpanHelper::AddPropagationLossModel(std::string name, Ts&&... args)
219{
220 m_propagationLoss.push_back(ObjectFactory(name, std::forward<Ts>(args)...));
221}
222
223template <typename... Ts>
224void
225LrWpanHelper::SetPropagationDelayModel(std::string name, Ts&&... args)
226{
227 m_propagationDelay = ObjectFactory(name, std::forward<Ts>(args)...);
228}
229
230} // namespace ns3
231
232#endif /* LR_WPAN_HELPER_H */
Base class providing common user-level ascii trace operations for helpers representing net devices.
helps to manage and create IEEE 802.15.4 NetDevice objects
Ptr< SpectrumChannel > GetChannel()
Get the channel associated to this helper.
Ptr< SpectrumChannel > m_channel
channel to be used for the devices
void SetChannel(Ptr< SpectrumChannel > channel)
Set the channel associated to this helper.
void AddMobility(Ptr< lrwpan::LrWpanPhy > phy, Ptr< MobilityModel > m)
Add mobility model to a physical device.
void EnablePcapInternal(std::string prefix, Ptr< NetDevice > nd, bool promiscuous, bool explicitFilename) override
Enable pcap output on the indicated net device.
void CreateAssociatedPan(NetDeviceContainer c, uint16_t panId)
Creates an PAN with associated nodes and assigned addresses(16 and 64) from the nodes in the node con...
std::vector< ObjectFactory > m_propagationLoss
vector of propagation loss models
bool m_useMultiModelSpectrumChannel
indicates whether a MultiModelSpectrumChannel is used
LrWpanHelper(const LrWpanHelper &)=delete
void SetExtendedAddresses(NetDeviceContainer c)
Set the extended 64 bit addresses (EUI-64) for a group of LrWpanNetDevices.
void EnableLogComponents()
Helper to enable all LrWpan log components with one statement.
static std::string LrWpanMacStatePrinter(lrwpan::MacState e)
Transform the LrWpanMacState enumeration into a printable string.
LrWpanHelper & operator=(const LrWpanHelper &)=delete
~LrWpanHelper() override
NetDeviceContainer Install(NodeContainer c)
Install a LrWpanNetDevice and the associated structures (e.g., channel) in the nodes.
void EnableAsciiInternal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename) override
Enable ascii trace output on the indicated net device.
static std::string LrWpanPhyEnumerationPrinter(lrwpan::PhyEnumeration e)
Transform the LrWpanPhyEnumeration enumeration into a printable string.
LrWpanHelper()
Create a LrWpan helper in an empty state.
ObjectFactory m_propagationDelay
propagation delay model
void SetPropagationDelayModel(std::string name, Ts &&... args)
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
void AddPropagationLossModel(std::string name, Ts &&... args)
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
Instantiate subclasses of ns3::Object.
Base class providing common user-level pcap operations for helpers representing net devices.
Smart pointer class similar to boost::intrusive_ptr.
MacState
MAC states.
Definition lr-wpan-mac.h:64
PhyEnumeration
IEEE802.15.4-2006 PHY Emumerations Table 18 in section 6.2.3.
Every class exported by the ns3 library is enclosed in the ns3 namespace.