A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
uan-helper.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 University of Washington
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 * Author: Leonard Tracy <lentracy@u.washington.edu>
18 */
19
20#ifndef UAN_HELPER_H
21#define UAN_HELPER_H
22
23#include "ns3/attribute.h"
24#include "ns3/net-device-container.h"
25#include "ns3/node-container.h"
26#include "ns3/object-factory.h"
27#include "ns3/uan-net-device.h"
28
29#include <string>
30
31namespace ns3
32{
33
34class UanChannel;
35
36/**
37 * \ingroup uan
38 *
39 * UAN configuration helper.
40 */
42{
43 public:
44 UanHelper(); //!< Default constructor.
45 virtual ~UanHelper(); //!< Destructor.
46
47 /**
48 * Set MAC attributes.
49 *
50 * \tparam Ts \deduced Argument types
51 * \param type The type of ns3::UanMac to create.
52 * \param [in] args Name and AttributeValue pairs to set.
53 *
54 * All the attributes specified in this method should exist
55 * in the requested mac.
56 */
57 template <typename... Ts>
58 void SetMac(std::string type, Ts&&... args);
59
60 /**
61 * Set PHY attributes.
62 *
63 * \tparam Ts \deduced Argument types
64 * \param phyType The type of ns3::UanPhy to create.
65 * \param [in] args Name and AttributeValue pairs to set.
66 *
67 * All the attributes specified in this method should exist
68 * in the requested Phy.
69 */
70 template <typename... Ts>
71 void SetPhy(std::string phyType, Ts&&... args);
72
73 /**
74 * Set the transducer attributes.
75 *
76 * \tparam Ts \deduced Argument types
77 * \param type The type of ns3::Transducer to create.
78 * \param [in] args Name and AttributeValue pairs to set.
79 *
80 * All the attributes specified in this method should exist
81 * in the requested transducer.
82 */
83 template <typename... Ts>
84 void SetTransducer(std::string type, Ts&&... args);
85 /**
86 * Enable ascii output on the specified deviceid within the
87 * specified nodeid if it is of type ns3::UanNetDevice and dump
88 * that to the specified stdc++ output stream.
89 *
90 * \param os Output stream.
91 * \param nodeid The id of the node to generate ascii output for.
92 * \param deviceid The id of the device to generate ascii output for.
93 */
94 static void EnableAscii(std::ostream& os, uint32_t nodeid, uint32_t deviceid);
95 /**
96 * Enable ascii output on each device which is of the
97 * ns3::UanNetDevice type and which is located in the input
98 * device container and dump that to the specified
99 * stdc++ output stream.
100 *
101 * \param os Output stream.
102 * \param d Device container.
103 */
104 static void EnableAscii(std::ostream& os, NetDeviceContainer d);
105 /**
106 * Enable ascii output on each device which is of the
107 * ns3::UanNetDevice type and which is located in one
108 * of the input node and dump that to the specified
109 * stdc++ output stream.
110 *
111 * \param os Output stream.
112 * \param n Node container.
113 */
114 static void EnableAscii(std::ostream& os, NodeContainer n);
115 /**
116 * Enable ascii output on each device which is of the
117 * ns3::UanNetDevice type and dump that to the specified
118 * stdc++ output stream.
119 *
120 * \param os Output stream.
121 */
122 static void EnableAsciiAll(std::ostream& os);
123
124 /**
125 * This method creates a simple ns3::UanChannel (with a default
126 * ns3::UanNoiseModelDefault and ns3::UanPropModelIdeal) and
127 * creates, for each of the input nodes, a new ns3::UanNetDevice
128 * attached to this shared channel. Each ns3::UanNetDevice is also
129 * configured with an ns3::UanTransducerHd, ns3::UanMac, and,
130 * ns3::UanPhy, all of which are created based on the user-specified
131 * attributes specified in UanHelper::SetTransducer,
132 * UanHelper::SetMac, and, UanHelper::SetPhy.
133 *
134 * \param c A set of nodes.
135 * \return The installed netdevices.
136 */
138
139 /**
140 * For each of the input nodes, a new ns3::UanNetDevice is attached
141 * to the shared input channel. Each ns3::UanNetDevice is also
142 * configured with an ns3::UanTransducerHd, a ns3::UanMac, and ns3::UanPhy,
143 * all of which are created based on the user-specified attributes
144 * specified in UanHelper::SetTransducer, UanHelper::SetMac, and
145 * UanHelper::SetPhy.
146 *
147 * \param c A set of nodes.
148 * \param channel A channel to use.
149 * \return The installed netdevices.
150 */
152
153 /**
154 * Create a default an stack.
155 *
156 * The stack includes:
157 * - default channel, ideal propagation and default noise model.
158 * - default physical layer, with UanPhyGen.
159 * - default transducer, half duplex acoustic modem with UanTransducerHd.
160 * - default MAC layer, with UanMacAloha.
161 *
162 * Channel, physical layer, transducer and mac layer are added to the
163 * UanNetDevice and then added to the node.
164 *
165 * \param node A node where to install the uan components.
166 * \param channel A channel to use.
167 * \return The installed UanNetDevice.
168 */
170
171 /**
172 * Assign a fixed random variable stream number to the random variables
173 * used by this model. Return the number of streams (possibly zero) that
174 * have been assigned. The Install() method should have previously been
175 * called by the user.
176 *
177 * \param c NetDeviceContainer of the set of net devices for which the
178 * UanNetDevice should be modified to use a fixed stream.
179 * \param stream First stream index to use.
180 * \return The number of stream indices assigned by this helper.
181 */
182 int64_t AssignStreams(NetDeviceContainer c, int64_t stream);
183
184 private:
185 ObjectFactory m_device; //!< The device.
186 ObjectFactory m_mac; //!< The MAC layer.
187 ObjectFactory m_phy; //!< The PHY layer.
188 ObjectFactory m_transducer; //!< The transducer.
189};
190
191/***************************************************************
192 * Implementation of the templates declared above.
193 ***************************************************************/
194
195template <typename... Ts>
196void
197UanHelper::SetMac(std::string type, Ts&&... args)
198{
199 m_mac = ObjectFactory(type, std::forward<Ts>(args)...);
200}
201
202template <typename... Ts>
203void
204UanHelper::SetPhy(std::string phyType, Ts&&... args)
205{
206 m_phy = ObjectFactory(phyType, std::forward<Ts>(args)...);
207}
208
209template <typename... Ts>
210void
211UanHelper::SetTransducer(std::string type, Ts&&... args)
212{
213 m_transducer = ObjectFactory(type, std::forward<Ts>(args)...);
214}
215
216} // end namespace ns3
217
218#endif /* UAN_HELPER_H */
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
Instantiate subclasses of ns3::Object.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
UAN configuration helper.
Definition: uan-helper.h:42
ObjectFactory m_device
The device.
Definition: uan-helper.h:185
void SetPhy(std::string phyType, Ts &&... args)
Set PHY attributes.
Definition: uan-helper.h:204
void SetTransducer(std::string type, Ts &&... args)
Set the transducer attributes.
Definition: uan-helper.h:211
void SetMac(std::string type, Ts &&... args)
Set MAC attributes.
Definition: uan-helper.h:197
ObjectFactory m_phy
The PHY layer.
Definition: uan-helper.h:187
ObjectFactory m_transducer
The transducer.
Definition: uan-helper.h:188
static void EnableAscii(std::ostream &os, uint32_t nodeid, uint32_t deviceid)
Enable ascii output on the specified deviceid within the specified nodeid if it is of type ns3::UanNe...
Definition: uan-helper.cc:99
ObjectFactory m_mac
The MAC layer.
Definition: uan-helper.h:186
NetDeviceContainer Install(NodeContainer c) const
This method creates a simple ns3::UanChannel (with a default ns3::UanNoiseModelDefault and ns3::UanPr...
Definition: uan-helper.cc:145
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition: uan-helper.cc:192
static void EnableAsciiAll(std::ostream &os)
Enable ascii output on each device which is of the ns3::UanNetDevice type and dump that to the specif...
Definition: uan-helper.cc:139
UanHelper()
Default constructor.
Definition: uan-helper.cc:87
virtual ~UanHelper()
Destructor.
Definition: uan-helper.cc:94
Every class exported by the ns3 library is enclosed in the ns3 namespace.