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