34#include "ns3/channel-condition-model.h"
35#include "ns3/constant-position-mobility-model.h"
36#include "ns3/core-module.h"
37#include "ns3/geocentric-constant-position-mobility-model.h"
38#include "ns3/isotropic-antenna-model.h"
39#include "ns3/mobility-model.h"
40#include "ns3/net-device.h"
41#include "ns3/node-container.h"
43#include "ns3/parabolic-antenna-model.h"
44#include "ns3/simple-net-device.h"
45#include "ns3/spectrum-signal-parameters.h"
46#include "ns3/three-gpp-channel-model.h"
47#include "ns3/three-gpp-propagation-loss-model.h"
48#include "ns3/three-gpp-spectrum-propagation-loss-model.h"
49#include "ns3/uniform-planar-array.h"
50#include <ns3/antenna-model.h>
76 unsigned int numRbs = std::floor(bwHz / rbWidthHz);
77 double f = fcHz - (numRbs * rbWidthHz / 2.0);
78 double powerTx = pwrDbm;
81 for (
uint32_t numrb = 0; numrb < numRbs; ++numrb)
95 double powerTxW = std::pow(10., (powerTx - 30) / 10);
96 double txPowerDensity = (powerTxW / bwHz);
98 for (
auto psd = txPsd->ValuesBegin(); psd != txPsd->ValuesEnd(); ++psd)
100 *psd = txPowerDensity;
119 unsigned int numRbs = std::floor(bwHz / rbWidthHz);
120 double f = fcHz - (numRbs * rbWidthHz / 2.0);
123 std::vector<int> rbsId;
124 for (
uint32_t numrb = 0; numrb < numRbs; ++numrb)
134 rbsId.push_back(numrb);
141 const double ktDbmHz = -174.0;
142 double ktWHz = std::pow(10.0, (ktDbmHz - 30) / 10.0);
143 double noiseFigureLinear = std::pow(10.0, noiseFigureDb / 10.0);
145 double noisePowerSpectralDensity = ktWHz * noiseFigureLinear;
147 for (
auto rbId : rbsId)
149 (*txPsd)[rbId] = noisePowerSpectralDensity;
192 double pResourceBlockBandwidth)
218 Vector aPos = thisDevice->GetNode()->GetObject<
MobilityModel>()->GetPosition();
219 Vector bPos = otherDevice->GetNode()->GetObject<
MobilityModel>()->GetPosition();
222 Angles completeAngle(bPos, aPos);
223 double hAngleRadian = completeAngle.
GetAzimuth();
227 uint64_t totNoArrayElements = thisAntenna->GetNumElems();
231 double power = 1.0 / sqrt(totNoArrayElements);
234 const double sinVAngleRadian = sin(vAngleRadian);
235 const double cosVAngleRadian = cos(vAngleRadian);
236 const double sinHAngleRadian = sin(hAngleRadian);
237 const double cosHAngleRadian = cos(hAngleRadian);
239 for (uint64_t ind = 0; ind < totNoArrayElements; ind++)
241 Vector loc = thisAntenna->GetElementLocation(ind);
242 double phase = -2 * M_PI *
243 (sinVAngleRadian * cosHAngleRadian * loc.x +
244 sinVAngleRadian * sinHAngleRadian * loc.y + cosVAngleRadian * loc.z);
245 antennaWeights[ind] = exp(std::complex<double>(0, phase)) * power;
249 thisAntenna->SetBeamformingVector(antennaWeights);
263 params.resourceBlockBandwidth);
265 NS_LOG_DEBUG(
"Average tx power " << 10 * log10(
Sum(*txPsd) * params.resourceBlockBandwidth)
272 params.resourceBlockBandwidth);
274 << 10 * log10(
Sum(*noisePsd) * params.resourceBlockBandwidth) <<
" dB");
278 NS_LOG_DEBUG(
"Pathloss " << -propagationGainDb <<
" dB");
279 double propagationGainLinear = std::pow(10.0, (propagationGainDb) / 10.0);
280 *(rxPsd) *= propagationGainLinear;
282 NS_ASSERT_MSG(params.txAntenna,
"params.txAntenna is nullptr!");
283 NS_ASSERT_MSG(params.rxAntenna,
"params.rxAntenna is nullptr!");
288 ConstCast<AntennaModel, const AntennaModel>(params.txAntenna->GetAntennaElement());
296 NS_LOG_DEBUG(
"Average rx power " << 10 * log10(
Sum(*rxSsp->psd) * params.bandwidth) <<
" dB");
299 NS_LOG_DEBUG(
"Average SNR " << 10 * log10(
Sum(*rxSsp->psd) /
Sum(*noisePsd)) <<
" dB");
303 f.open(
"ntn-snr-trace.txt", std::ios::out | std::ios::app);
305 <<
" " << propagationGainDb << std::endl;
310main(
int argc,
char* argv[])
318 std::string scenario =
"NTN-Suburban";
321 double frequencyHz = 20e9;
322 double bandwidthHz = 400e6;
323 double RbBandwidthHz = 120e3;
326 double satEIRPDensity = 40;
327 double satAntennaGainDb = 58.5;
330 double vsatAntennaGainDb = 39.7;
331 double vsatAntennaNoiseFigureDb = 1.2;
336 cmd.AddValue(
"scenario",
337 "The 3GPP NTN scenario to use. Valid options are: "
338 "NTN-DenseUrban, NTN-Urban, NTN-Suburban, and NTN-Rural",
340 cmd.AddValue(
"frequencyHz",
"The carrier frequency in Hz", frequencyHz);
341 cmd.AddValue(
"bandwidthHz",
"The bandwidth in Hz", bandwidthHz);
342 cmd.AddValue(
"satEIRPDensity",
"The satellite EIRP density in dBW/MHz", satEIRPDensity);
343 cmd.AddValue(
"satAntennaGainDb",
"The satellite antenna gain in dB", satAntennaGainDb);
344 cmd.AddValue(
"vsatAntennaGainDb",
"The UE VSAT antenna gain in dB", vsatAntennaGainDb);
345 cmd.AddValue(
"vsatAntennaNoiseFigureDb",
346 "The UE VSAT antenna noise figure in dB",
347 vsatAntennaNoiseFigureDb);
348 cmd.Parse(argc, argv);
352 double txPowDbm = (satEIRPDensity + 10 * log10(bandwidthHz / 1e6) - satAntennaGainDb) + 30;
354 NS_LOG_DEBUG(
"Transmitting power: " << txPowDbm <<
"dBm, (" << pow(10., (txPowDbm - 30) / 10)
370 if (scenario ==
"NTN-DenseUrban")
377 else if (scenario ==
"NTN-Urban")
382 else if (scenario ==
"NTN-Suburban")
388 else if (scenario ==
"NTN-Rural")
434 CreateObject<GeocentricConstantPositionMobilityModel>();
436 CreateObject<GeocentricConstantPositionMobilityModel>();
438 txMob->SetGeographicPosition(Vector(45.40869, 11.89448, 35786000));
439 rxMob->SetGeographicPosition(Vector(45.40869, 11.89448, 14.0));
443 txMob->SetCoordinateTranslationReferencePoint(
444 Vector(45.40869, 11.89448, 0.0));
445 rxMob->SetCoordinateTranslationReferencePoint(
446 Vector(45.40869, 11.89448, 0.0));
467 CreateObjectWithAttributes<IsotropicAntennaModel>(
"Gain",
477 CreateObjectWithAttributes<IsotropicAntennaModel>(
"Gain",
485 for (
int i = 0; i < floor(simTimeMs / timeResMs); i++)
492 vsatAntennaNoiseFigureDb,
Class holding the azimuth and inclination angles of spherical coordinates.
double GetInclination() const
Getter for inclination angle.
double GetAzimuth() const
Getter for azimuth angle.
AttributeValue implementation for Boolean.
Parse command-line arguments.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Keep track of the current position and velocity of an object.
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.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Instantiate subclasses of ns3::Object.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Ptr< SpectrumSignalParameters > CalcRxPowerSpectralDensity(Ptr< const SpectrumSignalParameters > txPsd, Ptr< const MobilityModel > a, Ptr< const MobilityModel > b, Ptr< const PhasedArrayModel > aPhasedArrayModel, Ptr< const PhasedArrayModel > bPhasedArrayModel) const
This method is to be called to calculate.
AttributeValue implementation for Pointer.
double CalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Returns the Rx Power taking into account all the PropagationLossModel(s) chained to the current one.
Smart pointer class similar to boost::intrusive_ptr.
static void SetRun(uint64_t run)
Set the run number of simulation.
static void SetSeed(uint32_t seed)
Set the seed.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
Hold variables of type string.
Base class for the 3GPP channel condition models.
static TypeId GetTypeId()
Register this type.
static TypeId GetTypeId()
Get the type ID.
static TypeId GetTypeId()
Register this type.
static TypeId GetTypeId()
Get the type ID.
static TypeId GetTypeId()
Register this type.
static TypeId GetTypeId()
Get the type ID.
static TypeId GetTypeId()
Register this type.
static TypeId GetTypeId()
Get the type ID.
Base class for the 3GPP propagation models.
void SetChannelConditionModel(Ptr< ChannelConditionModel > model)
Set the channel condition model used to determine the channel state (e.g., the LOS/NLOS condition)
void SetChannelModelAttribute(const std::string &name, const AttributeValue &value)
Sets the value of an attribute belonging to the associated MatrixBasedChannelModel instance.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
AttributeValue implementation for Time.
Hold an unsigned integer type.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
void SetDefault(std::string name, const AttributeValue &value)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::vector< BandInfo > Bands
Container of BandInfo.
double Sum(const SpectrumValue &x)
A structure that holds the parameters for the ComputeSnr function.
ComputeSnrParams(Ptr< MobilityModel > pTxMob, Ptr< MobilityModel > pRxMob, double pTxPow, double pNoiseFigure, Ptr< PhasedArrayModel > pTxAntenna, Ptr< PhasedArrayModel > pRxAntenna, double pFrequency, double pBandwidth, double pResourceBlockBandwidth)
Constructor.
Ptr< PhasedArrayModel > txAntenna
the tx antenna array
Ptr< MobilityModel > rxMob
the rx mobility model
double bandwidth
the total bandwidth in Hz
double noiseFigure
the noise figure in dB
double resourceBlockBandwidth
the Resource Block bandwidth in Hz
double txPow
the tx power in dBm
double frequency
the carrier frequency in Hz
Ptr< PhasedArrayModel > rxAntenna
the rx antenna array
Ptr< MobilityModel > txMob
the tx mobility model
The building block of a SpectrumModel.
double fc
center frequency
double fl
lower limit of subband
double fh
upper limit of subband
static Ptr< ThreeGppPropagationLossModel > m_propagationLossModel
the PropagationLossModel object
static void DoBeamforming(Ptr< NetDevice > thisDevice, Ptr< PhasedArrayModel > thisAntenna, Ptr< NetDevice > otherDevice)
Perform the beamforming using the DFT beamforming method.
Ptr< SpectrumValue > CreateNoisePowerSpectralDensity(double fcHz, double noiseFigureDb, double bwHz, double rbWidthHz)
Create the noise PSD for the.
static void ComputeSnr(ComputeSnrParams ¶ms)
Compute the average SNR.
static Ptr< ThreeGppSpectrumPropagationLossModel > m_spectrumLossModel
the SpectrumPropagationLossModel object
Ptr< SpectrumValue > CreateTxPowerSpectralDensity(double fcHz, double pwrDbm, double bwHz, double rbWidthHz)
Create the PSD for the TX.