25 #include <ns3/uinteger.h>
26 #include <ns3/double.h>
27 #include <ns3/isotropic-antenna-model.h>
28 #include <ns3/mobility-helper.h>
29 #include <ns3/position-allocator.h>
30 #include <ns3/geographic-positions.h>
40 82e6, 174e6, 180e6, 186e6, 192e6, 198e6, 204e6, 210e6, 470e6, 476e6, 482e6,
41 488e6, 494e6, 500e6, 506e6, 512e6, 518e6, 524e6, 530e6, 536e6, 542e6, 548e6,
42 554e6, 560e6, 566e6, 572e6, 578e6, 584e6, 590e6, 596e6, 602e6, 608e6, 614e6,
43 620e6, 626e6, 632e6, 638e6, 644e6, 650e6, 656e6, 662e6, 668e6, 674e6, 680e6,
44 686e6, 692e6, 698e6, 704e6, 710e6, 716e6, 722e6, 728e6, 734e6, 740e6, 746e6,
45 752e6, 758e6, 764e6, 770e6, 776e6, 782e6, 788e6, 794e6, 800e6, 806e6, 812e6,
46 818e6, 824e6, 830e6, 836e6, 842e6, 848e6, 854e6, 860e6, 866e6, 872e6, 878e6,
49 88e6, 180e6, 186e6, 192e6, 198e6, 204e6, 210e6, 216e6, 476e6, 482e6, 488e6,
50 494e6, 500e6, 506e6, 512e6, 518e6, 524e6, 530e6, 536e6, 542e6, 548e6, 554e6,
51 560e6, 566e6, 572e6, 578e6, 584e6, 590e6, 596e6, 602e6, 608e6, 614e6, 620e6,
52 626e6, 632e6, 638e6, 644e6, 650e6, 656e6, 662e6, 668e6, 674e6, 680e6, 686e6,
53 692e6, 698e6, 704e6, 710e6, 716e6, 722e6, 728e6, 734e6, 740e6, 746e6, 752e6,
54 758e6, 764e6, 770e6, 776e6, 782e6, 788e6, 794e6, 800e6, 806e6, 812e6, 818e6,
55 824e6, 830e6, 836e6, 842e6, 848e6, 854e6, 860e6, 866e6, 872e6, 878e6, 884e6,
61 195e6, 202e6, 209e6, 216e6, 223e6, 0, 0, 0, 0, 0, 0, 0, 0, 470e6, 478e6,
62 486e6, 494e6, 502e6, 510e6, 518e6, 526e6, 534e6, 542e6, 550e6, 558e6, 566e6,
63 574e6, 582e6, 590e6, 598e6, 606e6, 614e6, 622e6, 630e6, 638e6, 646e6, 654e6,
64 662e6, 670e6, 678e6, 686e6, 694e6, 702e6, 710e6, 718e6, 726e6, 734e6, 742e6,
65 750e6, 758e6, 766e6, 774e6, 782e6, 790e6, 798e6, 806e6, 814e6, 822e6, 830e6,
68 202e6, 209e6, 216e6, 223e6, 230e6, 0, 0, 0, 0, 0, 0, 0, 0, 478e6, 486e6,
69 494e6, 502e6, 510e6, 518e6, 526e6, 534e6, 542e6, 550e6, 558e6, 566e6, 574e6,
70 582e6, 590e6, 598e6, 606e6, 614e6, 622e6, 630e6, 638e6, 646e6, 654e6, 662e6,
71 670e6, 678e6, 686e6, 694e6, 702e6, 710e6, 718e6, 726e6, 734e6, 742e6, 750e6,
72 758e6, 766e6, 774e6, 782e6, 790e6, 798e6, 806e6, 814e6, 822e6, 830e6, 838e6,
78 182e6, 188e6, 192e6, 198e6, 204e6, 210e6, 216e6, 470e6, 476e6, 482e6, 488e6,
79 494e6, 500e6, 506e6, 512e6, 518e6, 524e6, 530e6, 536e6, 542e6, 548e6, 554e6,
80 560e6, 566e6, 572e6, 578e6, 584e6, 590e6, 596e6, 602e6, 608e6, 614e6, 620e6,
81 626e6, 632e6, 638e6, 644e6, 650e6, 656e6, 662e6, 668e6, 674e6, 680e6, 686e6,
82 692e6, 698e6, 704e6, 710e6, 716e6, 722e6, 728e6, 734e6, 740e6, 746e6, 752e6,
85 188e6, 194e6, 198e6, 204e6, 210e6, 216e6, 222e6, 476e6, 482e6, 488e6, 494e6,
86 500e6, 506e6, 512e6, 518e6, 524e6, 530e6, 536e6, 542e6, 548e6, 554e6, 560e6,
87 566e6, 572e6, 578e6, 584e6, 590e6, 596e6, 602e6, 608e6, 614e6, 620e6, 626e6,
88 632e6, 638e6, 644e6, 650e6, 656e6, 662e6, 668e6, 674e6, 680e6, 686e6, 692e6,
89 698e6, 704e6, 710e6, 716e6, 722e6, 728e6, 734e6, 740e6, 746e6, 752e6, 758e6,
138 phy->SetDevice (dev);
153 uint16_t channelNumber)
157 double startFrequency;
158 double channelBandwidth;
162 "channel number " << channelNumber <<
163 " does not exist for this region");
164 NS_ASSERT_MSG (northAmericaStartFrequencies[channelNumber] != 0,
165 "channel number " << channelNumber <<
166 " does not exist for this region");
167 startFrequency = northAmericaStartFrequencies[channelNumber];
168 channelBandwidth = northAmericaEndFrequencies[channelNumber] -
169 northAmericaStartFrequencies[channelNumber];
174 "channel number " << channelNumber <<
175 " does not exist for this region");
177 "channel number " << channelNumber <<
178 " does not exist for this region");
179 startFrequency = europeStartFrequencies[channelNumber];
180 channelBandwidth = europeEndFrequencies[channelNumber] -
181 europeStartFrequencies[channelNumber];
186 "channel number " << channelNumber <<
187 " does not exist for this region");
189 "channel number " << channelNumber <<
190 " does not exist for this region");
191 startFrequency = japanStartFrequencies[channelNumber];
192 channelBandwidth = japanEndFrequencies[channelNumber] -
193 japanStartFrequencies[channelNumber];
200 phy->SetAttribute (
"StartFrequency",
DoubleValue (startFrequency));
201 phy->SetAttribute (
"ChannelBandwidth",
DoubleValue (channelBandwidth));
209 phy->SetDevice (dev);
234 phy->GetAttribute (
"StartFrequency", startFrequency);
235 phy->GetAttribute (
"ChannelBandwidth", channelBandwidth);
236 phy->SetAttribute (
"StartFrequency",
DoubleValue (startFrequency.
Get () +
237 (index * channelBandwidth.
Get ())));
245 phy->SetDevice (dev);
261 uint16_t channelNumber)
265 double startFrequency;
266 double channelBandwidth;
267 uint16_t currChannelNumber;
272 currChannelNumber = channelNumber + index;
276 "channel number " << currChannelNumber <<
277 " does not exist for this region");
278 NS_ASSERT_MSG (northAmericaStartFrequencies[currChannelNumber] != 0,
279 "channel number " << currChannelNumber <<
280 " does not exist for this region");
281 startFrequency = northAmericaStartFrequencies[currChannelNumber];
282 channelBandwidth = northAmericaEndFrequencies[currChannelNumber]
283 - northAmericaStartFrequencies[currChannelNumber];
288 "channel number " << currChannelNumber <<
289 " does not exist for this region");
290 NS_ASSERT_MSG (europeStartFrequencies[currChannelNumber] != 0,
291 "channel number " << currChannelNumber <<
292 " does not exist for this region");
293 startFrequency = europeStartFrequencies[currChannelNumber];
294 channelBandwidth = europeEndFrequencies[currChannelNumber] -
295 europeStartFrequencies[currChannelNumber];
300 "channel number " << currChannelNumber <<
301 " does not exist for this region");
302 NS_ASSERT_MSG (japanStartFrequencies[currChannelNumber] != 0,
303 "channel number " << currChannelNumber <<
304 " does not exist for this region");
305 startFrequency = japanStartFrequencies[currChannelNumber];
306 channelBandwidth = japanEndFrequencies[currChannelNumber] -
307 japanStartFrequencies[currChannelNumber];
311 phy->SetAttribute (
"StartFrequency",
DoubleValue (startFrequency));
312 phy->SetAttribute (
"ChannelBandwidth",
DoubleValue (channelBandwidth));
320 phy->SetDevice (dev);
344 double originLatitude,
345 double originLongitude,
350 std::list<int> transmitterIndicesToCreate;
354 (northAmericaStartFrequencies,
355 northAmericaArrayLength,
361 (europeStartFrequencies,
368 (japanStartFrequencies,
372 std::list<Vector> tvTransmitterLocations =
376 transmitterIndicesToCreate.size(),
380 transmitterIndicesToCreate,
381 tvTransmitterLocations);
387 const int startFrequenciesLength,
390 std::vector<double> startFreqVector;
391 for (
int i = 0; i < startFrequenciesLength; i++)
393 double element = startFrequencies[i];
395 if (element != 0) startFreqVector.push_back(element);
399 uint32_t freqVectorSize = startFreqVector.size();
403 std::vector<double> transmitterStartFreqsToCreate;
404 for (
int i = 0; i < randNumTransmitters; i++)
409 transmitterStartFreqsToCreate.push_back(startFreqVector[randIndex]);
411 startFreqVector.erase(startFreqVector.begin() + randIndex);
416 std::list<int> transmitterIndicesToCreate;
417 for (
int i = 0; i < (int)transmitterStartFreqsToCreate.size(); i++)
419 for (
int channelNumberIndex = 0;
420 channelNumberIndex < startFrequenciesLength; channelNumberIndex++)
422 if (startFrequencies[channelNumberIndex] == transmitterStartFreqsToCreate[i])
424 transmitterIndicesToCreate.push_back(channelNumberIndex);
429 return transmitterIndicesToCreate;
435 uint32_t numChannels)
444 numTransmitters =
m_uniRand->
GetInteger (ceil (0.33 * numChannels) + 1, ceil (0.66 * numChannels));
450 return numTransmitters;
456 std::list<int> transmitterIndicesToCreate,
457 std::list<Vector> transmitterLocations)
459 int numTransmitters = (int)transmitterIndicesToCreate.size();
460 for (
int transNum = 0; transNum < numTransmitters; transNum++)
464 nodePosition->Add (transmitterLocations.front());
472 uint16_t channelNumber = (uint16_t) transmitterIndicesToCreate.front();
473 Install (tvNode, region, channelNumber);
474 transmitterLocations.pop_front();
475 transmitterIndicesToCreate.pop_front();
Ptr< UniformRandomVariable > m_uniRand
Object to generate uniform random numbers.
Smart pointer class similar to boost::intrusive_ptr.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
ObjectFactory m_factory
Object factory for attribute setting.
Hold a value for an Attribute.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
const double europeEndFrequencies[70]
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
const double northAmericaStartFrequencies[84]
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
const double europeStartFrequencies[70]
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 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...
Region
geographical region that TV transmitters are being set up in
TvSpectrumTransmitterHelper()
Default constructor.
Keep track of the current position and velocity of an object.
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
NetDeviceContainer Install(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
const int japanArrayLength
const int northAmericaArrayLength
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
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...
holds a vector of ns3::NetDevice pointers
Ptr< SpectrumChannel > m_channel
Pointer to spectrum channel object.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
const double northAmericaEndFrequencies[84]
const double japanStartFrequencies[63]
int64_t AssignStreams(int64_t streamNum)
Assigns the stream number for the uniform random number generator to use.
void SetMobilityModel(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
SpectrumPhy implementation that creates a customizable TV transmitter which transmits a PSD spectrum ...
void Set(std::string name, const AttributeValue &value)
Set an attribute to be set during construction.
NetDeviceContainer InstallAdjacent(NodeContainer nodes)
Set up and start the TV Transmitter's transmission on the spectrum channel.
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...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Helper class used to assign positions and mobility models to nodes.
void InstallRandomRegionalTransmitters(Region region, std::list< int > transmitterIndicesToCreate, std::list< Vector > transmitterLocations)
Installs each randomly generated regional TV transmitter.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
virtual ~TvSpectrumTransmitterHelper()
Destructor.
const double japanEndFrequencies[63]
Ptr< T > CreateObject(void)
Create an object by type, with varying number of constructor parameters.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
const int europeArrayLength
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
void SetAttribute(std::string name, const AttributeValue &val)
Set attribute for each TvSpectrumTransmitter instance to be created.
void SetChannel(Ptr< SpectrumChannel > c)
Set the spectrum channel for the device(s) to transmit on.