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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Authors:
18 * Gary Pei <guangyu.pei@boeing.com>
19 * Tom Henderson <thomas.r.henderson@boeing.com>
20 */
21#ifndef LR_WPAN_HELPER_H
22#define LR_WPAN_HELPER_H
23
24#include <ns3/lr-wpan-mac.h>
25#include <ns3/lr-wpan-phy.h>
26#include <ns3/node-container.h>
27#include <ns3/trace-helper.h>
28
29namespace ns3
30{
31
32class SpectrumChannel;
33class MobilityModel;
34
35/**
36 * \ingroup lr-wpan
37 *
38 * \brief helps to manage and create IEEE 802.15.4 NetDevice objects
39 *
40 * This class can help to create IEEE 802.15.4 NetDevice objects
41 * and to configure their attributes during creation. It also contains
42 * additional helper functions used by client code.
43 *
44 * Only one channel is created, and all devices attached to it. If
45 * multiple channels are needed, multiple helper objects must be used,
46 * or else the channel object must be replaced.
47 */
48
50{
51 public:
52 /**
53 * \brief Create a LrWpan helper in an empty state. By default, a
54 * SingleModelSpectrumChannel is created, with a
55 * LogDistancePropagationLossModel and a ConstantSpeedPropagationDelayModel.
56 *
57 * To change the channel type, loss model, or delay model, the Get/Set
58 * Channel methods may be used.
59 */
61
62 /**
63 * \brief Create a LrWpan helper in an empty state with either a
64 * SingleModelSpectrumChannel or a MultiModelSpectrumChannel.
65 * \param useMultiModelSpectrumChannel use a MultiModelSpectrumChannel if true, a
66 * SingleModelSpectrumChannel otherwise
67 *
68 * A LogDistancePropagationLossModel and a
69 * ConstantSpeedPropagationDelayModel are added to the channel.
70 */
71 LrWpanHelper(bool useMultiModelSpectrumChannel);
72
73 ~LrWpanHelper() override;
74
75 // Delete copy constructor and assignment operator to avoid misuse
76 LrWpanHelper(const LrWpanHelper&) = delete;
78
79 /**
80 * \brief Get the channel associated to this helper
81 * \returns the channel
82 */
84
85 /**
86 * \brief Set the channel associated to this helper
87 * \param channel the channel
88 */
89 void SetChannel(Ptr<SpectrumChannel> channel);
90
91 /**
92 * \brief Set the channel associated to this helper
93 * \param channelName the channel name
94 */
95 void SetChannel(std::string channelName);
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 * \param c a set of nodes
107 * \returns A container holding the added net devices.
108 */
110
111 /**
112 * \brief Creates an PAN with associated nodes and assigned addresses(16 and 64)
113 * from the nodes in the node container.
114 * The first node in the container becomes the PAN coordinator.
115 *
116 * \param c a The node container with the nodes that will form the PAN.
117 * \param panId The PAN identifier.
118 */
119 void CreateAssociatedPan(NetDeviceContainer c, uint16_t panId);
120
121 /**
122 * \brief Set the extended 64 bit addresses (EUI-64) for a group of
123 * LrWpanNetDevices
124 *
125 * \param c The NetDevice container.
126 *
127 */
129
130 /**
131 * Helper to enable all LrWpan log components with one statement
132 */
133 void EnableLogComponents();
134
135 /**
136 * \brief Transform the LrWpanPhyEnumeration enumeration into a printable string.
137 * \param e the LrWpanPhyEnumeration
138 * \return a string
139 */
141
142 /**
143 * \brief Transform the LrWpanMacState enumeration into a printable string.
144 * \param e the LrWpanMacState
145 * \return a string
146 */
147 static std::string LrWpanMacStatePrinter(lrwpan::MacState e);
148
149 /**
150 * Assign a fixed random variable stream number to the random variables
151 * used by this model. Return the number of streams that have been
152 * assigned. The Install() method should have previously been
153 * called by the user.
154 *
155 * \param c NetDeviceContainer of the set of net devices for which the
156 * CsmaNetDevice should be modified to use a fixed stream
157 * \param stream first stream index to use
158 * \return the number of stream indices assigned by this helper
159 */
160 int64_t AssignStreams(NetDeviceContainer c, int64_t stream);
161
162 private:
163 /**
164 * \brief Enable pcap output on the indicated net device.
165 *
166 * NetDevice-specific implementation mechanism for hooking the trace and
167 * writing to the trace file.
168 *
169 * \param prefix Filename prefix to use for pcap files.
170 * \param nd Net device for which you want to enable tracing.
171 * \param promiscuous If true capture all possible packets available at the device.
172 * \param explicitFilename Treat the prefix as an explicit filename if true
173 */
174 void EnablePcapInternal(std::string prefix,
176 bool promiscuous,
177 bool explicitFilename) override;
178
179 /**
180 * \brief Enable ascii trace output on the indicated net device.
181 *
182 * NetDevice-specific implementation mechanism for hooking the trace and
183 * writing to the trace file.
184 *
185 * \param stream The output stream object to use when logging ascii traces.
186 * \param prefix Filename prefix to use for ascii trace files.
187 * \param nd Net device for which you want to enable tracing.
188 * \param explicitFilename Treat the prefix as an explicit filename if true
189 */
191 std::string prefix,
193 bool explicitFilename) override;
194
195 private:
196 Ptr<SpectrumChannel> m_channel; //!< channel to be used for the devices
197};
198
199} // namespace ns3
200
201#endif /* LR_WPAN_HELPER_H */
Base class providing common user-level ascii trace operations for helpers representing net devices.
Definition: trace-helper.h:729
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...
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.
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
Base class providing common user-level pcap operations for helpers representing net devices.
Definition: trace-helper.h:624
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
MacState
MAC states.
Definition: lr-wpan-mac.h:75
PhyEnumeration
IEEE802.15.4-2006 PHY Emumerations Table 18 in section 6.2.3.
Definition: lr-wpan-phy.h:115
Every class exported by the ns3 library is enclosed in the ns3 namespace.