19#include "ns3/channel-condition-model.h"
20#include "ns3/constant-position-mobility-model.h"
21#include "ns3/core-module.h"
22#include "ns3/lte-spectrum-value-helper.h"
23#include "ns3/mobility-model.h"
24#include "ns3/net-device.h"
25#include "ns3/node-container.h"
27#include "ns3/simple-net-device.h"
28#include "ns3/spectrum-signal-parameters.h"
29#include "ns3/three-gpp-channel-model.h"
30#include "ns3/three-gpp-propagation-loss-model.h"
31#include "ns3/three-gpp-spectrum-propagation-loss-model.h"
32#include "ns3/uniform-planar-array.h"
72 Vector aPos = thisDevice->GetNode()->GetObject<
MobilityModel>()->GetPosition();
73 Vector bPos = otherDevice->GetNode()->GetObject<
MobilityModel>()->GetPosition();
76 Angles completeAngle(bPos, aPos);
77 double hAngleRadian = completeAngle.
GetAzimuth();
82 uint64_t totNoArrayElements = thisAntenna->GetNumElems();
86 double power = 1.0 / sqrt(totNoArrayElements);
89 const double sinVAngleRadian = sin(vAngleRadian);
90 const double cosVAngleRadian = cos(vAngleRadian);
91 const double sinHAngleRadian = sin(hAngleRadian);
92 const double cosHAngleRadian = cos(hAngleRadian);
94 for (uint64_t ind = 0; ind < totNoArrayElements; ind++)
96 Vector loc = thisAntenna->GetElementLocation(ind);
97 double phase = -2 * M_PI *
98 (sinVAngleRadian * cosHAngleRadian * loc.x +
99 sinVAngleRadian * sinHAngleRadian * loc.y + cosVAngleRadian * loc.z);
100 antennaWeights[ind] = exp(std::complex<double>(0, phase)) * power;
104 thisAntenna->SetBeamformingVector(antennaWeights);
118 std::vector<int> activeRbs0(100);
119 for (
int i = 0; i < 100; i++)
126 txParams->psd = txPsd->Copy();
127 NS_LOG_DEBUG(
"Average tx power " << 10 * log10(
Sum(*txPsd) * 180e3) <<
" dB");
132 NS_LOG_DEBUG(
"Average noise power " << 10 * log10(
Sum(*noisePsd) * 180e3) <<
" dB");
136 NS_LOG_DEBUG(
"Pathloss " << -propagationGainDb <<
" dB");
137 double propagationGainLinear = std::pow(10.0, (propagationGainDb) / 10.0);
138 *(txParams->psd) *= propagationGainLinear;
140 NS_ASSERT_MSG(params.txAntenna,
"params.txAntenna is nullptr!");
141 NS_ASSERT_MSG(params.rxAntenna,
"params.rxAntenna is nullptr!");
149 auto rxPsd = rxParams->psd;
150 NS_LOG_DEBUG(
"Average rx power " << 10 * log10(
Sum(*rxPsd) * 180e3) <<
" dB");
157 f.open(
"snr-trace.txt", std::ios::out | std::ios::app);
159 << propagationGainDb << std::endl;
164main(
int argc,
char* argv[])
166 double frequency = 2125.0e6;
168 double noiseFigure = 9.0;
169 double distance = 10.0;
172 std::string scenario =
"UMa";
185 if (scenario ==
"RMa")
190 else if (scenario ==
"UMa")
195 else if (scenario ==
"UMi-StreetCanyon")
202 else if (scenario ==
"InH-OfficeOpen")
209 else if (scenario ==
"InH-OfficeMixed")
254 txMob->SetPosition(Vector(0.0, 0.0, 10.0));
256 rxMob->SetPosition(Vector(distance, 0.0, 1.6));
278 for (
int i = 0; i < floor(simTime / timeRes); i++)
Class holding the azimuth and inclination angles of spherical coordinates.
double GetInclination() const
Getter for inclination angle.
double GetAzimuth() const
Getter for azimuth angle.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
static Ptr< SpectrumValue > CreateNoisePowerSpectralDensity(uint32_t earfcn, uint16_t bandwidth, double noiseFigure)
create a SpectrumValue that models the power spectral density of AWGN
static Ptr< SpectrumValue > CreateTxPowerSpectralDensity(uint32_t earfcn, uint16_t bandwidth, double powerTx, std::vector< int > activeRbs)
create a spectrum value representing the power spectral density of a signal to be transmitted.
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.
AttributeValue implementation for Pointer.
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()
Get the type ID.
static TypeId GetTypeId()
Get the type ID.
static TypeId GetTypeId()
Get the type ID.
Base class for the 3GPP propagation models.
static TypeId GetTypeId()
Get the type ID.
static TypeId GetTypeId()
Get the type ID.
static TypeId GetTypeId()
Get the type ID.
static TypeId GetTypeId()
Get the type ID.
static TypeId GetTypeId()
Get the type ID.
static TypeId GetTypeId()
Get the type ID.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
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.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > CreateObjectWithAttributes(Args... args)
Allocate an Object on the heap and initialize with a set of attributes.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
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.
double Sum(const SpectrumValue &x)
params
Fit Fluctuating Two Ray model to the 3GPP TR 38.901 using the Anderson-Darling goodness-of-fit ##.
A structure that holds the parameters for the ComputeSnr function.
Ptr< PhasedArrayModel > txAntenna
the tx antenna array
Ptr< MobilityModel > rxMob
the rx mobility model
double noiseFigure
the noise figure in dB
double txPow
the tx power in dBm
Ptr< PhasedArrayModel > rxAntenna
the rx antenna array
Ptr< MobilityModel > txMob
the tx mobility model
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.
static void ComputeSnr(const ComputeSnrParams ¶ms)
Compute the average SNR.
static Ptr< ThreeGppSpectrumPropagationLossModel > m_spectrumLossModel
the SpectrumPropagationLossModel object