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