11#include <ns3/double.h>
12#include <ns3/geographic-positions.h>
13#include <ns3/isotropic-antenna-model.h>
15#include <ns3/mobility-helper.h>
16#include <ns3/position-allocator.h>
17#include <ns3/uinteger.h>
32 0, 0, 54e6, 60e6, 66e6, 76e6, 82e6, 174e6, 180e6, 186e6, 192e6, 198e6,
33 204e6, 210e6, 470e6, 476e6, 482e6, 488e6, 494e6, 500e6, 506e6, 512e6, 518e6, 524e6,
34 530e6, 536e6, 542e6, 548e6, 554e6, 560e6, 566e6, 572e6, 578e6, 584e6, 590e6, 596e6,
35 602e6, 608e6, 614e6, 620e6, 626e6, 632e6, 638e6, 644e6, 650e6, 656e6, 662e6, 668e6,
36 674e6, 680e6, 686e6, 692e6, 698e6, 704e6, 710e6, 716e6, 722e6, 728e6, 734e6, 740e6,
37 746e6, 752e6, 758e6, 764e6, 770e6, 776e6, 782e6, 788e6, 794e6, 800e6, 806e6, 812e6,
38 818e6, 824e6, 830e6, 836e6, 842e6, 848e6, 854e6, 860e6, 866e6, 872e6, 878e6, 884e6,
42 0, 0, 60e6, 66e6, 72e6, 82e6, 88e6, 180e6, 186e6, 192e6, 198e6, 204e6,
43 210e6, 216e6, 476e6, 482e6, 488e6, 494e6, 500e6, 506e6, 512e6, 518e6, 524e6, 530e6,
44 536e6, 542e6, 548e6, 554e6, 560e6, 566e6, 572e6, 578e6, 584e6, 590e6, 596e6, 602e6,
45 608e6, 614e6, 620e6, 626e6, 632e6, 638e6, 644e6, 650e6, 656e6, 662e6, 668e6, 674e6,
46 680e6, 686e6, 692e6, 698e6, 704e6, 710e6, 716e6, 722e6, 728e6, 734e6, 740e6, 746e6,
47 752e6, 758e6, 764e6, 770e6, 776e6, 782e6, 788e6, 794e6, 800e6, 806e6, 812e6, 818e6,
48 824e6, 830e6, 836e6, 842e6, 848e6, 854e6, 860e6, 866e6, 872e6, 878e6, 884e6, 890e6,
55 0, 0, 0, 0, 0, 174e6, 181e6, 188e6, 195e6, 202e6, 209e6, 216e6,
56 223e6, 0, 0, 0, 0, 0, 0, 0, 0, 470e6, 478e6, 486e6,
57 494e6, 502e6, 510e6, 518e6, 526e6, 534e6, 542e6, 550e6, 558e6, 566e6, 574e6, 582e6,
58 590e6, 598e6, 606e6, 614e6, 622e6, 630e6, 638e6, 646e6, 654e6, 662e6, 670e6, 678e6,
59 686e6, 694e6, 702e6, 710e6, 718e6, 726e6, 734e6, 742e6, 750e6, 758e6, 766e6, 774e6,
60 782e6, 790e6, 798e6, 806e6, 814e6, 822e6, 830e6, 838e6, 846e6, 854e6,
64 0, 0, 0, 0, 0, 181e6, 188e6, 195e6, 202e6, 209e6, 216e6, 223e6,
65 230e6, 0, 0, 0, 0, 0, 0, 0, 0, 478e6, 486e6, 494e6,
66 502e6, 510e6, 518e6, 526e6, 534e6, 542e6, 550e6, 558e6, 566e6, 574e6, 582e6, 590e6,
67 598e6, 606e6, 614e6, 622e6, 630e6, 638e6, 646e6, 654e6, 662e6, 670e6, 678e6, 686e6,
68 694e6, 702e6, 710e6, 718e6, 726e6, 734e6, 742e6, 750e6, 758e6, 766e6, 774e6, 782e6,
69 790e6, 798e6, 806e6, 814e6, 822e6, 830e6, 838e6, 846e6, 854e6, 862e6,
76 0, 90e6, 96e6, 102e6, 170e6, 176e6, 182e6, 188e6, 192e6, 198e6, 204e6, 210e6, 216e6,
77 470e6, 476e6, 482e6, 488e6, 494e6, 500e6, 506e6, 512e6, 518e6, 524e6, 530e6, 536e6, 542e6,
78 548e6, 554e6, 560e6, 566e6, 572e6, 578e6, 584e6, 590e6, 596e6, 602e6, 608e6, 614e6, 620e6,
79 626e6, 632e6, 638e6, 644e6, 650e6, 656e6, 662e6, 668e6, 674e6, 680e6, 686e6, 692e6, 698e6,
80 704e6, 710e6, 716e6, 722e6, 728e6, 734e6, 740e6, 746e6, 752e6, 758e6, 764e6,
84 0, 96e6, 102e6, 108e6, 176e6, 182e6, 188e6, 194e6, 198e6, 204e6, 210e6, 216e6, 222e6,
85 476e6, 482e6, 488e6, 494e6, 500e6, 506e6, 512e6, 518e6, 524e6, 530e6, 536e6, 542e6, 548e6,
86 554e6, 560e6, 566e6, 572e6, 578e6, 584e6, 590e6, 596e6, 602e6, 608e6, 614e6, 620e6, 626e6,
87 632e6, 638e6, 644e6, 650e6, 656e6, 662e6, 668e6, 674e6, 680e6, 686e6, 692e6, 698e6, 704e6,
88 710e6, 716e6, 722e6, 728e6, 734e6, 740e6, 746e6, 752e6, 758e6, 764e6, 770e6,
125 for (
auto i = nodeCont.
Begin(); i != nodeCont.
End(); ++i)
140 node->AddDevice(dev);
152 double startFrequency;
153 double channelBandwidth;
157 "channel number " << channelNumber <<
" does not exist for this region");
159 "channel number " << channelNumber <<
" does not exist for this region");
167 "channel number " << channelNumber <<
" does not exist for this region");
169 "channel number " << channelNumber <<
" does not exist for this region");
177 "channel number " << channelNumber <<
" does not exist for this region");
179 "channel number " << channelNumber <<
" does not exist for this region");
185 for (
auto i = nodeCont.
Begin(); i != nodeCont.
End(); ++i)
189 phy->SetAttribute(
"StartFrequency",
DoubleValue(startFrequency));
190 phy->SetAttribute(
"ChannelBandwidth",
DoubleValue(channelBandwidth));
202 node->AddDevice(dev);
218 for (
auto i = nodeCont.
Begin(); i != nodeCont.
End(); ++i)
222 phy->GetAttribute(
"StartFrequency", startFrequency);
223 phy->GetAttribute(
"ChannelBandwidth", channelBandwidth);
224 phy->SetAttribute(
"StartFrequency",
237 node->AddDevice(dev);
248 uint16_t channelNumber)
252 double startFrequency;
253 double channelBandwidth;
254 uint16_t currChannelNumber;
257 for (
auto i = nodeCont.
Begin(); i != nodeCont.
End(); ++i)
259 currChannelNumber = channelNumber + index;
263 "channel number " << currChannelNumber
264 <<
" does not exist for this region");
266 "channel number " << currChannelNumber
267 <<
" does not exist for this region");
275 "channel number " << currChannelNumber
276 <<
" does not exist for this region");
278 "channel number " << currChannelNumber
279 <<
" does not exist for this region");
287 "channel number " << currChannelNumber
288 <<
" does not exist for this region");
290 "channel number " << currChannelNumber
291 <<
" does not exist for this region");
298 phy->SetAttribute(
"StartFrequency",
DoubleValue(startFrequency));
299 phy->SetAttribute(
"ChannelBandwidth",
DoubleValue(channelBandwidth));
311 node->AddDevice(dev);
329 double originLatitude,
330 double originLongitude,
335 std::list<int> transmitterIndicesToCreate;
338 transmitterIndicesToCreate =
345 transmitterIndicesToCreate =
350 transmitterIndicesToCreate =
353 std::list<Vector> tvTransmitterLocations =
358 transmitterIndicesToCreate.size(),
366 const int startFrequenciesLength,
369 std::vector<double> startFreqVector;
370 for (
int i = 0; i < startFrequenciesLength; i++)
372 double element = startFrequencies[i];
376 startFreqVector.push_back(element);
381 uint32_t freqVectorSize = startFreqVector.size();
385 std::vector<double> transmitterStartFreqsToCreate;
386 for (
int i = 0; i < randNumTransmitters; i++)
391 transmitterStartFreqsToCreate.push_back(startFreqVector[randIndex]);
393 startFreqVector.erase(startFreqVector.begin() + randIndex);
398 std::list<int> transmitterIndicesToCreate;
399 for (
int i = 0; i < (int)transmitterStartFreqsToCreate.size(); i++)
401 for (
int channelNumberIndex = 0; channelNumberIndex < startFrequenciesLength;
402 channelNumberIndex++)
404 if (startFrequencies[channelNumberIndex] == transmitterStartFreqsToCreate[i])
406 transmitterIndicesToCreate.push_back(channelNumberIndex);
411 return transmitterIndicesToCreate;
420 numTransmitters =
m_uniRand->GetInteger(1, ceil(0.33 * numChannels));
425 m_uniRand->GetInteger(ceil(0.33 * numChannels) + 1, ceil(0.66 * numChannels));
429 numTransmitters =
m_uniRand->GetInteger(ceil(0.66 * numChannels) + 1, numChannels);
431 return numTransmitters;
437 std::list<int> transmitterIndicesToCreate,
438 std::list<Vector> transmitterLocations)
440 int numTransmitters = (int)transmitterIndicesToCreate.size();
441 for (
int transNum = 0; transNum < numTransmitters; transNum++)
445 nodePosition->Add(transmitterLocations.front());
447 mobility.SetPositionAllocator(nodePosition);
448 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
451 mobility.Install(tvNode);
453 auto channelNumber = (uint16_t)transmitterIndicesToCreate.front();
454 Install(tvNode, region, channelNumber);
455 transmitterLocations.pop_front();
456 transmitterIndicesToCreate.pop_front();
Hold a value for an Attribute.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
static std::list< Vector > RandCartesianPointsAroundGeographicPoint(double originLatitude, double originLongitude, double maxAltitude, int numPoints, double maxDistFromOrigin, Ptr< UniformRandomVariable > uniRand)
Generates uniformly distributed random points (in ECEF Cartesian coordinates) within a given altitude...
Helper class used to assign positions and mobility models to nodes.
Keep track of the current position and velocity of an object.
holds a vector of ns3::NetDevice pointers
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
keep track of a set of node pointers.
Iterator End() const
Get an iterator which indicates past-the-last Node in the container.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Iterator Begin() const
Get an iterator which refers to the first Node in the container.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Smart pointer class similar to boost::intrusive_ptr.
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...
TvSpectrumTransmitterHelper()
Default constructor.
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...
virtual ~TvSpectrumTransmitterHelper()
Destructor.
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.
SpectrumPhy implementation that creates a customizable TV transmitter which transmits a PSD spectrum ...
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
const double northAmericaEndFrequencies[84]
NORTH AMERICA end frequencies.
const int japanArrayLength
JAPAN: 63 elements (index 0 - 62); valid channels = 1 - 62.
const double europeEndFrequencies[70]
EUROPE end frequencies.
const int northAmericaArrayLength
NORTH AMERICA: 84 elements (index 0 - 83); valid channels = 2 - 83.
const double japanStartFrequencies[63]
JAPAN start frequencies.
const double europeStartFrequencies[70]
EUROPE start frequencies.
const double japanEndFrequencies[63]
JAPAN end frequencies.
const double northAmericaStartFrequencies[84]
NORTH AMERICA start frequencies.
const int europeArrayLength
EUROPE: 70 elements (index 0 - 69); valid channels = 5 - 12, 21 - 69.