31#include "ns3/core-module.h"
32#include "ns3/three-gpp-channel-model.h"
33#include "ns3/uniform-planar-array.h"
35#include "ns3/three-gpp-spectrum-propagation-loss-model.h"
36#include "ns3/net-device.h"
37#include "ns3/simple-net-device.h"
39#include "ns3/node-container.h"
40#include "ns3/mobility-model.h"
41#include "ns3/constant-position-mobility-model.h"
42#include "ns3/lte-spectrum-value-helper.h"
43#include "ns3/channel-condition-model.h"
44#include "ns3/three-gpp-propagation-loss-model.h"
104 Angles completeAngle (bPos,aPos);
105 double hAngleRadian = completeAngle.
GetAzimuth ();
113 double power = 1 / sqrt (totNoArrayElements);
116 for (
int ind = 0; ind < totNoArrayElements; ind++)
119 double phase = -2 * M_PI * (sin (vAngleRadian) * cos (hAngleRadian) * loc.x
120 + sin (vAngleRadian) * sin (hAngleRadian) * loc.y
121 + cos (vAngleRadian) * loc.z);
122 antennaWeights.push_back (exp (std::complex<double> (0, phase)) * power);
139 std::vector<int> activeRbs0 (100);
140 for (
int i = 0; i < 100 ; i++)
144 Ptr<SpectrumValue> txPsd = LteSpectrumValueHelper::CreateTxPowerSpectralDensity (2100, 100, params.
txPow, activeRbs0);
146 NS_LOG_DEBUG (
"Average tx power " << 10*log10(
Sum (*txPsd) * 180e3) <<
" dB");
150 NS_LOG_DEBUG (
"Average noise power " << 10*log10 (
Sum (*noisePsd) * 180e3) <<
" dB");
154 NS_LOG_DEBUG (
"Pathloss " << -propagationGainDb <<
" dB");
155 double propagationGainLinear = std::pow (10.0, (propagationGainDb) / 10.0);
156 *(rxPsd) *= propagationGainLinear;
163 NS_LOG_DEBUG (
"Average rx power " << 10 * log10 (
Sum (*rxPsd) * 180e3) <<
" dB");
166 NS_LOG_DEBUG (
"Average SNR " << 10 * log10 (
Sum (*rxPsd) /
Sum (*noisePsd)) <<
" dB");
170 f.open (
"snr-trace.txt", std::ios::out | std::ios::app);
176main (
int argc,
char *argv[])
178 double frequency = 2125.0e6;
180 double noiseFigure = 9.0;
181 double distance = 10.0;
184 std::string scenario =
"UMa";
189 RngSeedManager::SetSeed(1);
190 RngSeedManager::SetRun(1);
195 if (scenario ==
"RMa")
197 propagationLossModelFactory.
SetTypeId (ThreeGppRmaPropagationLossModel::GetTypeId ());
198 channelConditionModelFactory.
SetTypeId (ThreeGppRmaChannelConditionModel::GetTypeId ());
200 else if (scenario ==
"UMa")
202 propagationLossModelFactory.
SetTypeId (ThreeGppUmaPropagationLossModel::GetTypeId ());
203 channelConditionModelFactory.
SetTypeId (ThreeGppUmaChannelConditionModel::GetTypeId ());
205 else if (scenario ==
"UMi-StreetCanyon")
207 propagationLossModelFactory.
SetTypeId (ThreeGppUmiStreetCanyonPropagationLossModel::GetTypeId ());
208 channelConditionModelFactory.
SetTypeId (ThreeGppUmiStreetCanyonChannelConditionModel::GetTypeId ());
210 else if (scenario ==
"InH-OfficeOpen")
212 propagationLossModelFactory.
SetTypeId (ThreeGppIndoorOfficePropagationLossModel::GetTypeId ());
213 channelConditionModelFactory.
SetTypeId (ThreeGppIndoorOpenOfficeChannelConditionModel::GetTypeId ());
215 else if (scenario ==
"InH-OfficeMixed")
217 propagationLossModelFactory.
SetTypeId (ThreeGppIndoorOfficePropagationLossModel::GetTypeId ());
218 channelConditionModelFactory.
SetTypeId (ThreeGppIndoorMixedOfficeChannelConditionModel::GetTypeId ());
250 nodes.Get (0)->AddDevice (txDev);
251 txDev->SetNode (
nodes.Get (0));
252 nodes.Get (1)->AddDevice (rxDev);
253 rxDev->SetNode (
nodes.Get (1));
262 nodes.Get (0)->AggregateObject (txMob);
263 nodes.Get (1)->AggregateObject (rxMob);
273 for (
int i = 0; i < floor (simTime / timeRes); i++)
279 Simulator::Destroy ();
double f(double x, void *params)
Class holding the azimuth and inclination angles of spherical coordinates.
double GetInclination(void) const
Getter for inclination angle.
double GetAzimuth(void) const
Getter for azimuth angle.
AttributeValue implementation for Boolean.
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.
void SetPosition(const Vector &position)
virtual Ptr< Node > GetNode(void) const =0
keep track of a set of node pointers.
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(void) 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.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
virtual Vector GetElementLocation(uint64_t index) const =0
Returns the location of the antenna element with the specified index, normalized with respect to the ...
virtual uint64_t GetNumberOfElements(void) const =0
Returns the number of antenna elements.
void SetBeamformingVector(const ComplexVector &beamformingVector)
Sets the beamforming vector to be used.
std::vector< std::complex< double > > ComplexVector
type definition for complex vectors
Ptr< SpectrumValue > CalcRxPowerSpectralDensity(Ptr< const SpectrumValue > 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.
Hold objects of type Ptr<T>.
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.
Ptr< SpectrumValue > Copy() const
Hold variables of type string.
Base class for the 3GPP channel condition models.
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(void) const
Get an approximation of the time stored in this instance in the indicated unit.
AttributeValue implementation for Time.
Hold an unsigned integer type.
Vector3D Vector
Vector alias typedef for compatibility with mobility models.
#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 Now(void)
create an ns3::Time instance which contains the current simulation time.
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)
A structure that holds the parameters for the ComputeSnr function.
Ptr< PhasedArrayModel > txAntenna
the tx antenna array
Ptr< MobilityModel > rxMob
the rx mobility model
ComputeSnrParams(Ptr< MobilityModel > pTxMob, Ptr< MobilityModel > pRxMob, double pTxPow, double pNoiseFigure, Ptr< PhasedArrayModel > pTxAntenna, Ptr< PhasedArrayModel > pRxAntenna)
Constructor.
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(ComputeSnrParams ¶ms)
Compute the average SNR.
static Ptr< ThreeGppSpectrumPropagationLossModel > m_spectrumLossModel
the SpectrumPropagationLossModel object
static Vector GetPosition(Ptr< Node > node)