A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tv-trans-regional-example.cc
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#include "ns3/core-module.h"
10#include "ns3/mobility-module.h"
11#include "ns3/spectrum-analyzer-helper.h"
12#include "ns3/spectrum-helper.h"
13#include "ns3/tv-spectrum-transmitter-helper.h"
14
15#include <iostream>
16#include <stdlib.h>
17
18using namespace ns3;
19
20/**
21 * This example uses the TvSpectrumTransmitterHelper class to generate a random
22 * number of COFDM TV transmitters within a 250 km radius around latitude
23 * 48.86 degrees and longitude 2.35 degrees (Paris, France). The transmitters'
24 * frequencies and bandwidths correspond to the European TV channel allocations.
25 * These TV transmitters model the digital DVB-T standard.
26 *
27 * A spectrum analyzer is used to measure the transmitted spectra from the
28 * TV transmitters. The file "spectrum-analyzer-tv-sim-regional-0-0.tr" contains
29 * its output post simulation (and can be plotted with Gnuplot or MATLAB).
30 */
31int
32main(int argc, char** argv)
33{
35 cmd.Parse(argc, argv);
36
37 /* random seed and run number; adjust these to change random draws */
40
41 /* nodes and positions */
46 Vector coordinates =
48 2.35,
49 0,
51 nodePositionList->Add(coordinates); // spectrum analyzer
52 mobility.SetPositionAllocator(nodePositionList);
53 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
55
56 /* channel and propagation */
58 channelHelper.SetChannel("ns3::MultiModelSpectrumChannel");
60
61 /* TV transmitter setup */
64 tvTransHelper.SetAttribute("StartingTime", TimeValue(Seconds(0.1)));
65 tvTransHelper.SetAttribute("TransmitDuration", TimeValue(Seconds(0.1)));
66 // 7.96 dBm/Hz from 50 kW ERP transmit power, flat 8 MHz PSD spectrum assumed for this
67 // approximation
68 tvTransHelper.SetAttribute("BasePsd", DoubleValue(7.96));
70 tvTransHelper.SetAttribute("Antenna", StringValue("ns3::IsotropicAntennaModel"));
71
72 tvTransHelper.AssignStreams(300);
75 48.86,
76 2.35,
77 0,
78 250000);
79
80 /* frequency range for spectrum analyzer */
81 std::vector<double> freqs;
82 for (int i = 0; i < 6860; i = i + 5)
83 {
84 freqs.push_back((i + 1740) * 1e5);
85 }
87
88 /* spectrum analyzer setup */
92 spectrumAnalyzerHelper.SetPhyAttribute("NoisePowerSpectralDensity",
93 DoubleValue(4.14e-21)); // approx -174 dBm/Hz
94 spectrumAnalyzerHelper.EnableAsciiAll("spectrum-analyzer-tv-sim-regional");
97
99
101
103
104 std::cout << "simulation done!" << std::endl;
105 std::cout << "see spectrum analyzer output file" << std::endl;
106
107 return 0;
108}
Parse command-line arguments.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
Hold variables of type enum.
Definition enum.h:52
static Vector GeographicToCartesianCoordinates(double latitude, double longitude, double altitude, EarthSpheroidType sphType)
Converts earth geographic/geodetic coordinates (latitude and longitude in degrees) with a given altit...
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:66
static void SetRun(uint64_t run)
Set the run number of simulation.
static void SetSeed(uint32_t seed)
Set the seed.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
static void Run()
Run the simulation.
Definition simulator.cc:167
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition simulator.cc:175
Class to allow the Spectrum Analysis.
void SetChannel(Ptr< SpectrumChannel > channel)
Set the SpectrumChannel that will be used by SpectrumPhy instances created by this helper.
Setup a SpectrumChannel.
static SpectrumChannelHelper Default()
Setup a default SpectrumChannel.
Hold variables of type string.
Definition string.h:45
AttributeValue implementation for Time.
Definition nstime.h:1431
Helper class which uses TvSpectrumTransmitter class to create customizable TV transmitter(s) that tra...
void SetChannel(Ptr< SpectrumChannel > c)
Set the spectrum channel for the device(s) to transmit on.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1344
Every class exported by the ns3 library is enclosed in the ns3 namespace.
channel
Definition third.py:77
mobility
Definition third.py:92