A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tv-spectrum-transmitter-helper.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014 University of Washington
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Benjamin Cizdziel <ben.cizdziel@gmail.com>
7 */
8
9#ifndef TV_SPECTRUM_TRANSMITTER_HELPER_H
10#define TV_SPECTRUM_TRANSMITTER_HELPER_H
11
12#include "ns3/object-factory.h"
13#include <ns3/antenna-model.h>
14#include <ns3/mobility-model.h>
15#include <ns3/net-device-container.h>
16#include <ns3/net-device.h>
17#include <ns3/node-container.h>
18#include <ns3/non-communicating-net-device.h>
19#include <ns3/random-variable-stream.h>
20#include <ns3/spectrum-channel.h>
21#include <ns3/spectrum-phy.h>
22#include <ns3/spectrum-signal-parameters.h>
23#include <ns3/spectrum-value.h>
24#include <ns3/tv-spectrum-transmitter.h>
25
27
28namespace ns3
29{
30
31/**
32 * \ingroup spectrum
33 *
34 * Helper class which uses TvSpectrumTransmitter class to create customizable
35 * TV transmitter(s) that transmit PSD spectrum specified by user-set attributes.
36 * Has functionality to create TV transmitter(s) with actual frequencies of
37 * specific geographic regions.
38 * Provides method to create a random set of transmitters within a given region
39 * and location.
40 *
41 * Here is an example of how to use this class:
42 * \code
43 TvSpectrumTransmitterHelper tvTransHelper;
44 tvTransHelper.SetChannel (channel); // provided that user has a Ptr<SpectrumChannel> ready.
45 tvTransHelper.SetAttribute ("StartFrequency", DoubleValue (524e6));
46 tvTransHelper.SetAttribute ("ChannelBandwidth", DoubleValue (6e6));
47 tvTransHelper.SetAttribute ("StartingTime", TimeValue (Seconds (0)));
48 tvTransHelper.SetAttribute ("TransmitDuration", TimeValue (Seconds (0.2)));
49 tvTransHelper.SetAttribute ("BasePsd", DoubleValue (22.22));
50 tvTransHelper.SetAttribute ("TvType", EnumValue (TvSpectrumTransmitter::TVTYPE_8VSB));
51 tvTransHelper.SetAttribute ("Antenna", StringValue ("ns3::IsotropicAntennaModel"));
52 tvTransHelper.Install (tvTransmitterNode); // provided that user has a NodeContainer ready.
53 \endcode
54 */
56{
57 public:
58 friend class ::TvHelperDistributionTestCase;
59
60 /**
61 * geographical region that TV transmitters are being set up in
62 */
69
70 /**
71 * density of location that TV transmitters are being set up in
72 */
79
80 TvSpectrumTransmitterHelper(); //!< Default constructor
81 virtual ~TvSpectrumTransmitterHelper(); //!< Destructor
82
83 /**
84 * Set the spectrum channel for the device(s) to transmit on
85 *
86 * @param c a pointer to the spectrum channel
87 */
89
90 /**
91 * Set attribute for each TvSpectrumTransmitter instance to be created
92 *
93 * @param name the name of the attribute to set
94 * @param val the value of the attribute to set
95 */
96 void SetAttribute(std::string name, const AttributeValue& val);
97
98 /**
99 * Set up and start the TV Transmitter's transmission on the spectrum channel.
100 * Creates one TV Transmitter for each node given as an input, with settings
101 * selected from attributes.
102 * Use SetAttribute() to select settings for the TV Transmitter(s).
103 * If multiple transmitters created, all will have same settings (frequency,
104 * PSD, etc.) except for position/location, which depends on the positions
105 * in the input NodeContainer.
106 *
107 * @param nodes a container containing the node(s) which the TV
108 * transmitter(s) will be attached to
109 *
110 * @return a device container which contains all the devices created by this
111 * method
112 */
114
115 /**
116 * Set up and start the TV Transmitter's transmission on the spectrum channel.
117 * Creates one TV Transmitter for each node given as an input, with settings
118 * selected from attributes.
119 * Use SetAttribute() to select settings for the TV Transmitter(s).
120 * Transmitter(s) will be created with frequencies corresponding to the
121 * user-selected channel number of the user-selected region.
122 * If multiple transmitters created, all will have same settings (frequency,
123 * PSD, etc.) except for position/location, which depends on the positions
124 * in the input NodeContainer.
125 *
126 * @param nodes a container containing the node(s) which the TV
127 * transmitter(s) will be attached to
128 * @param region the region of which the transmitter(s) will be characterized
129 * @param channelNumber the TV channel number in the selected region that the
130 * transmitter frequencies will be modeled after
131 *
132 * @return a device container which contains all the devices created by this
133 * method
134 */
135 NetDeviceContainer Install(NodeContainer nodes, Region region, uint16_t channelNumber);
136
137 /**
138 * Set up and start the TV Transmitter's transmission on the spectrum channel.
139 * Consecutively created transmitters (consecutive in input NodeContainer)
140 * will have adjacent channels, i.e. a transmitter's frequency spectrum will
141 * border (but not overlap) the frequency spectrum of the transmitter created
142 * directly before it and the transmitter created directly after it.
143 * Creates one TV Transmitter for each node given as an input, with settings
144 * selected from attributes.
145 * Use SetAttribute() to select settings for the TV Transmitter(s).
146 * If multiple transmitters created, they will have same settings except for
147 * frequency and position/location.
148 * For each node, start frequency will be incremented by the channel bandwidth
149 * that is set.
150 * For example, if two nodes are given as inputs to InstallAdjacent with
151 * start frequency set to 500 MHz and channel bandwidth set to 6 MHz, the
152 * first node will be a transmitter ranging from 500 MHz to 506 MHz and the
153 * second node will be a transmitter ranging from 506 MHz to 512 MHz.
154 *
155 * @param nodes a container containing the node(s) which the TV
156 * transmitter(s) will be attached to
157 *
158 * @return a device container which contains all the devices created by this
159 * method
160 */
162
163 /**
164 * Set up and start the TV Transmitter's transmission on the spectrum channel.
165 * Consecutively created transmitters (consecutive in input NodeContainer)
166 * will have adjacent channels, with the frequency spectrum and bandwidth of
167 * each channel determined by the user-selected region.
168 * Creates one TV Transmitter for each node given as an input, with settings
169 * selected from attributes.
170 * Use SetAttribute() to select settings for the TV Transmitter(s).
171 * The first created transmitter will have frequencies corresponding to the
172 * user-selected channel number of the user-selected region.
173 * Each subsequently created transmitter will have its frequencies modeled
174 * after the channel number (of the user-selected region) following the
175 * previous one; for example if the first created transmitter is modeled after
176 * channel 1, the next one created will be modeled after channel 2, and the
177 * following one will be modeled after channel 3.
178 * If multiple transmitters created, they will have same settings except for
179 * frequency and position/location.
180 *
181 * @param nodes a container containing the node(s) which the TV
182 * transmitter(s) will be attached to
183 * @param region the region of which the transmitter(s) will be characterized
184 * @param channelNumber the TV channel number in the selected region that the
185 * first created transmitter's frequencies will be modeled after
186 *
187 * @return a device container which contains all the devices created by this
188 * method
189 */
190 NetDeviceContainer InstallAdjacent(NodeContainer nodes, Region region, uint16_t channelNumber);
191
192 /**
193 * Assigns the stream number for the uniform random number generator to use
194 *
195 * @param streamNum first stream index to use
196 * @return the number of stream indices assigned by this helper
197 */
198 int64_t AssignStreams(int64_t streamNum);
199
200 /**
201 * Generates and installs (starts transmission on the spectrum channel) a
202 * random number of TV transmitters with channel frequencies corresponding
203 * to the given region at random locations on or above earth.
204 * The generated transmitters are located at randomly selected points within a
205 * given altitude above earth's surface centered around a given origin point
206 * (on earth's surface) within a given distance radius, corresponding to a
207 * uniform distribution.
208 * Distance radius is measured as if all points are on earth's surface
209 * (with altitude = 0).
210 * Assumes earth is a perfect sphere.
211 * The given region's channel numbers that the generated TV transmitters'
212 * frequency spectra are modeled after are uniformly selected at random.
213 * These channel numbers are never repeated.
214 * The number of transmitters generated is uniformly random based on given
215 * density.
216 * Each transmitter has BasePsd and TvType set from SetAttribute(), which
217 * should be set before calling this method.
218 *
219 * @param region the region that the transmitters are in
220 * @param density the density (high, medium, or low) of the location being
221 * simulated, which determines how many transmitters are created and how many
222 * channels are occupied. Low density will generate between one and one third
223 * of the number of TV channels in the given region, medium density will
224 * generate between one third and two thirds, and high density will generate
225 * between two thirds and all of the channels.
226 * @param originLatitude origin point latitude in degrees
227 * @param originLongitude origin point longitude in degrees
228 * @param maxAltitude maximum altitude in meters above earth's surface with
229 * which random points can be generated
230 * @param maxRadius max distance in meters from origin with which random
231 * transmitters can be generated (all transmitters are less than or equal to
232 * this distance from the origin, relative to points being on earth's surface)
233 */
235 Density density,
236 double originLatitude,
237 double originLongitude,
238 double maxAltitude,
239 double maxRadius);
240
241 private:
242 Ptr<SpectrumChannel> m_channel; //!< Pointer to spectrum channel object
243
244 /**
245 * Generates random indices of given region frequency array (ignoring indices
246 * referring to invalid channels).
247 * Number of indices generated (which is number of TV transmitters to be
248 * created) is random based on given density.
249 * Indices generated refer to frequencies that TV transmitters will be
250 * created with.
251 *
252 * @param startFrequencies array containing all channel start frequencies for
253 * a particular region
254 * @param startFrequenciesLength number of elements in startFrequencies array
255 * @param density the density (high, medium, or low) of the location being
256 * simulated, which determines how many transmitters are created
257 *
258 * @return a list containing the indices in startFrequencies that transmitters
259 * will be created for
260 */
261 std::list<int> GenerateRegionalTransmitterIndices(const double startFrequencies[],
262 const int startFrequenciesLength,
263 Density density);
264
265 /**
266 * Randomly generates the number of TV transmitters to be created based on
267 * given density and number of possible TV channels.
268 * Low density will generate a transmitter for between one (a single
269 * transmitter) and one third of the number of possible channels, medium
270 * density will generate a transmitter for between one third and two thirds,
271 * and high density will generate a transmitter for between two thirds and all
272 * of the possible channels.
273 * These ratios are approximated in the implementation, but there is no
274 * overlap possible in the number of transmitters generated between adjacent
275 * densities.
276 * For example, given 60 possible channels, for low density between 1 and 20
277 * transmitters can be created, for medium density between 21 and 40
278 * transmitters can be created, and for high density between 41 and 60
279 * transmitters can be created (all inclusive).
280 *
281 * @param density the density (high, medium, or low) of the location being
282 * simulated
283 * @param numChannels the number of possible TV channels in the region being
284 * simulated
285 *
286 * @return the number of TV transmitters that will be created
287 */
288 int GetRandomNumTransmitters(Density density, uint32_t numChannels);
289
290 /**
291 * Installs each randomly generated regional TV transmitter
292 *
293 * @param region the region that the transmitters are in
294 * @param transmitterIndicesToCreate a list containing the channel number
295 * indices (for region's start frequencies array) that transmitters will be
296 * created for; this is returned from GenerateRegionalTransmitterIndices()
297 * @param transmitterLocations a list containing the vectors
298 * (x, y, z location) of each TV transmitter to be generated; this is
299 * returned from RandGeographicCoordsAroundPoint()
300 */
302 std::list<int> transmitterIndicesToCreate,
303 std::list<Vector> transmitterLocations);
304
305 ObjectFactory m_factory; //!< Object factory for attribute setting
306 Ptr<UniformRandomVariable> m_uniRand; //!< Object to generate uniform random numbers
307};
308
309} // namespace ns3
310
311#endif /* TV_SPECTRUM_TRANSMITTER_HELPER_H */
This test verifies the accuracy of the private GetRandomNumTransmitters() method in the TvSpectrumTra...
Hold a value for an Attribute.
Definition attribute.h:59
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.
Helper class which uses TvSpectrumTransmitter class to create customizable TV transmitter(s) that tra...
std::list< int > GenerateRegionalTransmitterIndices(const double startFrequencies[], const int startFrequenciesLength, Density density)
Generates random indices of given region frequency array (ignoring indices referring to invalid chann...
void SetChannel(Ptr< SpectrumChannel > c)
Set the spectrum channel for the device(s) to transmit on.
NetDeviceContainer InstallAdjacent(NodeContainer nodes)
Set up and start the TV Transmitter's transmission on the spectrum channel.
Density
density of location that TV transmitters are being set up in
void InstallRandomRegionalTransmitters(Region region, std::list< int > transmitterIndicesToCreate, std::list< Vector > transmitterLocations)
Installs each randomly generated regional TV transmitter.
Region
geographical region that TV transmitters are being set up in
int GetRandomNumTransmitters(Density density, uint32_t numChannels)
Randomly generates the number of TV transmitters to be created based on given density and number of p...
Ptr< UniformRandomVariable > m_uniRand
Object to generate uniform random numbers.
int64_t AssignStreams(int64_t streamNum)
Assigns the stream number for the uniform random number generator to use.
ObjectFactory m_factory
Object factory for attribute setting.
void CreateRegionalTvTransmitters(Region region, Density density, double originLatitude, double originLongitude, double maxAltitude, double maxRadius)
Generates and installs (starts transmission on the spectrum channel) a random number of TV transmitte...
void SetAttribute(std::string name, const AttributeValue &val)
Set attribute for each TvSpectrumTransmitter instance to be created.
NetDeviceContainer Install(NodeContainer nodes)
Set up and start the TV Transmitter's transmission on the spectrum channel.
Ptr< SpectrumChannel > m_channel
Pointer to spectrum channel object.
NodeContainer nodes
Every class exported by the ns3 library is enclosed in the ns3 namespace.