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>    41   82e6, 174e6, 180e6, 186e6, 192e6, 198e6, 204e6, 210e6, 470e6, 476e6, 482e6, 
    42   488e6, 494e6, 500e6, 506e6, 512e6, 518e6, 524e6, 530e6, 536e6, 542e6, 548e6, 
    43   554e6, 560e6, 566e6, 572e6, 578e6, 584e6, 590e6, 596e6, 602e6, 608e6, 614e6, 
    44   620e6, 626e6, 632e6, 638e6, 644e6, 650e6, 656e6, 662e6, 668e6, 674e6, 680e6, 
    45   686e6, 692e6, 698e6, 704e6, 710e6, 716e6, 722e6, 728e6, 734e6, 740e6, 746e6, 
    46   752e6, 758e6, 764e6, 770e6, 776e6, 782e6, 788e6, 794e6, 800e6, 806e6, 812e6, 
    47   818e6, 824e6, 830e6, 836e6, 842e6, 848e6, 854e6, 860e6, 866e6, 872e6, 878e6, 
    51   88e6, 180e6, 186e6, 192e6, 198e6, 204e6, 210e6, 216e6, 476e6, 482e6, 488e6, 
    52   494e6, 500e6, 506e6, 512e6, 518e6, 524e6, 530e6, 536e6, 542e6, 548e6, 554e6, 
    53   560e6, 566e6, 572e6, 578e6, 584e6, 590e6, 596e6, 602e6, 608e6, 614e6, 620e6, 
    54   626e6, 632e6, 638e6, 644e6, 650e6, 656e6, 662e6, 668e6, 674e6, 680e6, 686e6, 
    55   692e6, 698e6, 704e6, 710e6, 716e6, 722e6, 728e6, 734e6, 740e6, 746e6, 752e6, 
    56   758e6, 764e6, 770e6, 776e6, 782e6, 788e6, 794e6, 800e6, 806e6, 812e6, 818e6, 
    57   824e6, 830e6, 836e6, 842e6, 848e6, 854e6, 860e6, 866e6, 872e6, 878e6, 884e6, 
    64   195e6, 202e6, 209e6, 216e6, 223e6, 0, 0, 0, 0, 0, 0, 0, 0, 470e6, 478e6, 
    65   486e6, 494e6, 502e6, 510e6, 518e6, 526e6, 534e6, 542e6, 550e6, 558e6, 566e6, 
    66   574e6, 582e6, 590e6, 598e6, 606e6, 614e6, 622e6, 630e6, 638e6, 646e6, 654e6, 
    67   662e6, 670e6, 678e6, 686e6, 694e6, 702e6, 710e6, 718e6, 726e6, 734e6, 742e6, 
    68   750e6, 758e6, 766e6, 774e6, 782e6, 790e6, 798e6, 806e6, 814e6, 822e6, 830e6, 
    72   202e6, 209e6, 216e6, 223e6, 230e6, 0, 0, 0, 0, 0, 0, 0, 0, 478e6, 486e6, 
    73   494e6, 502e6, 510e6, 518e6, 526e6, 534e6, 542e6, 550e6, 558e6, 566e6, 574e6, 
    74   582e6, 590e6, 598e6, 606e6, 614e6, 622e6, 630e6, 638e6, 646e6, 654e6, 662e6, 
    75   670e6, 678e6, 686e6, 694e6, 702e6, 710e6, 718e6, 726e6, 734e6, 742e6, 750e6, 
    76   758e6, 766e6, 774e6, 782e6, 790e6, 798e6, 806e6, 814e6, 822e6, 830e6, 838e6, 
    83   182e6, 188e6, 192e6, 198e6, 204e6, 210e6, 216e6, 470e6, 476e6, 482e6, 488e6, 
    84   494e6, 500e6, 506e6, 512e6, 518e6, 524e6, 530e6, 536e6, 542e6, 548e6, 554e6, 
    85   560e6, 566e6, 572e6, 578e6, 584e6, 590e6, 596e6, 602e6, 608e6, 614e6, 620e6, 
    86   626e6, 632e6, 638e6, 644e6, 650e6, 656e6, 662e6, 668e6, 674e6, 680e6, 686e6, 
    87   692e6, 698e6, 704e6, 710e6, 716e6, 722e6, 728e6, 734e6, 740e6, 746e6, 752e6, 
    91   188e6, 194e6, 198e6, 204e6, 210e6, 216e6, 222e6, 476e6, 482e6, 488e6, 494e6, 
    92   500e6, 506e6, 512e6, 518e6, 524e6, 530e6, 536e6, 542e6, 548e6, 554e6, 560e6, 
    93   566e6, 572e6, 578e6, 584e6, 590e6, 596e6, 602e6, 608e6, 614e6, 620e6, 626e6, 
    94   632e6, 638e6, 644e6, 650e6, 656e6, 662e6, 668e6, 674e6, 680e6, 686e6, 692e6, 
    95   698e6, 704e6, 710e6, 716e6, 722e6, 728e6, 734e6, 740e6, 746e6, 752e6, 758e6, 
   144       phy->SetDevice (dev);
   159                                       uint16_t channelNumber)
   163   double startFrequency;
   164   double channelBandwidth;
   168                      "channel number " << channelNumber <<
   169                      " does not exist for this region");
   171                      "channel number " << channelNumber <<
   172                      " does not exist for this region");
   180                      "channel number " << channelNumber <<
   181                      " does not exist for this region");
   183                      "channel number " << channelNumber <<
   184                      " does not exist for this region");
   192                      "channel number " << channelNumber <<
   193                      " does not exist for this region");
   195                      "channel number " << channelNumber <<
   196                      " does not exist for this region");
   206       phy->SetAttribute (
"StartFrequency", 
DoubleValue (startFrequency));
   207       phy->SetAttribute (
"ChannelBandwidth", 
DoubleValue (channelBandwidth));
   215       phy->SetDevice (dev);
   240       phy->GetAttribute (
"StartFrequency", startFrequency);
   241       phy->GetAttribute (
"ChannelBandwidth", channelBandwidth);
   243                          (index * channelBandwidth.
Get ())));
   251       phy->SetDevice (dev);
   267                                               uint16_t channelNumber)
   271   double startFrequency;
   272   double channelBandwidth;
   273   uint16_t currChannelNumber;
   278       currChannelNumber = channelNumber + index;
   282                          "channel number " << currChannelNumber <<
   283                          " does not exist for this region");
   285                          "channel number " << currChannelNumber <<
   286                          " does not exist for this region");
   294                          "channel number " << currChannelNumber <<
   295                          " does not exist for this region");
   297                          "channel number " << currChannelNumber <<
   298                          " does not exist for this region");
   306                          "channel number " << currChannelNumber <<
   307                          " does not exist for this region");
   309                          "channel number " << currChannelNumber <<
   310                          " does not exist for this region");
   317       phy->SetAttribute (
"StartFrequency", 
DoubleValue (startFrequency));
   318       phy->SetAttribute (
"ChannelBandwidth", 
DoubleValue (channelBandwidth));
   326       phy->SetDevice (dev);
   350                                                            double originLatitude, 
   351                                                            double originLongitude,
   356   std::list<int> transmitterIndicesToCreate;
   378   std::list<Vector> tvTransmitterLocations = 
   382                                                                    transmitterIndicesToCreate.size(), 
   386                                      transmitterIndicesToCreate, 
   387                                      tvTransmitterLocations);
   393                                                                  const int startFrequenciesLength, 
   396   std::vector<double> startFreqVector; 
   397   for (
int i = 0; i < startFrequenciesLength; i++)
   399       double element = startFrequencies[i];
   401       if (element != 0) startFreqVector.push_back(element);
   405   uint32_t freqVectorSize = startFreqVector.size();
   409   std::vector<double> transmitterStartFreqsToCreate; 
   410   for (
int i = 0; i < randNumTransmitters; i++)
   415       transmitterStartFreqsToCreate.push_back(startFreqVector[randIndex]); 
   417       startFreqVector.erase(startFreqVector.begin() + randIndex); 
   422   std::list<int> transmitterIndicesToCreate;
   423   for (
int i = 0; i < (int)transmitterStartFreqsToCreate.size(); i++)
   425       for (
int channelNumberIndex = 0; 
   426            channelNumberIndex < startFrequenciesLength; channelNumberIndex++)
   428           if (startFrequencies[channelNumberIndex] == transmitterStartFreqsToCreate[i])
   430               transmitterIndicesToCreate.push_back(channelNumberIndex);
   435   return transmitterIndicesToCreate;
   441                                                        uint32_t numChannels)
   450       numTransmitters = 
m_uniRand->
GetInteger (ceil (0.33 * numChannels) + 1, ceil (0.66 * numChannels));
   456   return numTransmitters;
   462                                                                 std::list<int> transmitterIndicesToCreate, 
   463                                                                 std::list<Vector> transmitterLocations)
   465   int numTransmitters = (int)transmitterIndicesToCreate.size();
   466   for (
int transNum = 0; transNum < numTransmitters; transNum++)
   470       nodePosition->Add (transmitterLocations.front()); 
   472       mobility.SetPositionAllocator (nodePosition);
   473       mobility.SetMobilityModel (
"ns3::ConstantPositionMobilityModel");
   478       uint16_t channelNumber = (uint16_t) transmitterIndicesToCreate.front(); 
   479       Install (tvNode, region, channelNumber); 
   480       transmitterLocations.pop_front(); 
   481       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 the RngStream. 
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator. 
ObjectFactory m_factory
Object factory for attribute setting. 
Hold a value for an Attribute. 
Region
geographical region that TV transmitters are being set up in 
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction. 
#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]
EUROPE end frequencies. 
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name. 
const double northAmericaStartFrequencies[84]
NORTH AMERICA start frequencies. 
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory. 
const double europeStartFrequencies[70]
EUROPE start frequencies. 
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container. 
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...
TvSpectrumTransmitterHelper()
Default constructor. 
Keep track of the current position and velocity of an object. 
NetDeviceContainer Install(NodeContainer nodes)
Set up and start the TV Transmitter's transmission on the spectrum channel. 
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId. 
const int japanArrayLength
JAPAN: 63 elements (index 0 - 62); valid channels = 1 - 62. 
const int northAmericaArrayLength
NORTH AMERICA: 84 elements (index 0 - 83); valid channels = 2 - 83. 
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. 
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object. 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
keep track of a set of node pointers. 
const double northAmericaEndFrequencies[84]
NORTH AMERICA end frequencies. 
const double japanStartFrequencies[63]
JAPAN start frequencies. 
int64_t AssignStreams(int64_t streamNum)
Assigns the stream number for the uniform random number generator to use. 
SpectrumPhy implementation that creates a customizable TV transmitter which transmits a PSD spectrum ...
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. 
Density
density of location that TV transmitters are being set up in 
virtual ~TvSpectrumTransmitterHelper()
Destructor. 
const double japanEndFrequencies[63]
JAPAN end frequencies. 
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer. 
const int europeArrayLength
EUROPE: 70 elements (index 0 - 69); valid channels = 5 - 12, 21 - 69. 
This class can be used to hold variables of floating point type such as 'double' or 'float'...
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. 
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters. 
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.