|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
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"
69 Angles completeAngle (bPos,aPos);
70 double hAngleRadian = completeAngle.
GetAzimuth ();
78 double power = 1 / sqrt (totNoArrayElements);
81 for (
int ind = 0; ind < totNoArrayElements; ind++)
84 double phase = -2 * M_PI * (sin (vAngleRadian) * cos (hAngleRadian) * loc.x
85 + sin (vAngleRadian) * sin (hAngleRadian) * loc.y
86 + cos (vAngleRadian) * loc.z);
87 antennaWeights.push_back (exp (std::complex<double> (0, phase)) * power);
107 std::vector<int> activeRbs0 (100);
108 for (
int i = 0; i < 100 ; i++)
114 NS_LOG_DEBUG (
"Average tx power " << 10*log10(
Sum (*txPsd) * 180e3) <<
" dB");
118 NS_LOG_DEBUG (
"Average noise power " << 10*log10 (
Sum (*noisePsd) * 180e3) <<
" dB");
122 NS_LOG_DEBUG (
"Pathloss " << -propagationGainDb <<
" dB");
123 double propagationGainLinear = std::pow (10.0, (propagationGainDb) / 10.0);
124 *(rxPsd) *= propagationGainLinear;
128 NS_LOG_DEBUG (
"Average rx power " << 10*log10 (
Sum (*rxPsd) * 180e3) <<
" dB");
131 NS_LOG_DEBUG (
"Average SNR " << 10 * log10 (
Sum (*rxPsd) /
Sum (*noisePsd)) <<
" dB");
135 f.open (
"snr-trace.txt", std::ios::out | std::ios::app);
141 main (
int argc,
char *argv[])
143 double frequency = 2125.0e6;
145 double noiseFigure = 9.0;
146 double distance = 10.0;
147 uint32_t simTime = 10000;
148 uint32_t timeRes = 10;
149 std::string scenario =
"UMa";
160 if (scenario ==
"RMa")
165 else if (scenario ==
"UMa")
170 else if (scenario ==
"UMi-StreetCanyon")
175 else if (scenario ==
"InH-OfficeOpen")
180 else if (scenario ==
"InH-OfficeMixed")
215 nodes.Get (0)->AddDevice (txDev);
217 nodes.Get (1)->AddDevice (rxDev);
227 nodes.Get (0)->AggregateObject (txMob);
228 nodes.Get (1)->AggregateObject (rxMob);
242 for (
int i = 0; i < floor (simTime / timeRes); i++)
static Vector GetPosition(Ptr< Node > node)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Ptr< SpectrumValue > Copy() const
AttributeValue implementation for Boolean.
double GetInclination(void) const
Getter for inclination angle.
static Ptr< ThreeGppSpectrumPropagationLossModel > m_spectrumLossModel
the SpectrumPropagationLossModel object
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double Sum(const SpectrumValue &x)
void SetBeamformingVector(const ComplexVector &beamformingVector)
Sets the beamforming vector to be used.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
void SetPosition(const Vector &position)
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.
static Ptr< ThreeGppPropagationLossModel > m_propagationLossModel
the PropagationLossModel object
Hold objects of type Ptr<T>.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
static TypeId GetTypeId(void)
Get the type ID.
static Ptr< SpectrumValue > CreateNoisePowerSpectralDensity(uint32_t earfcn, uint16_t bandwidth, double noiseFigure)
create a SpectrumValue that models the power spectral density of AWGN
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
static TypeId GetTypeId(void)
Get the type ID.
static void SetRun(uint64_t run)
Set the run number of simulation.
static void ComputeSnr(Ptr< MobilityModel > txMob, Ptr< MobilityModel > rxMob, double txPow, double noiseFigure)
Compute the average SNR.
static TypeId GetTypeId(void)
Get the type ID.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
static TypeId GetTypeId(void)
Get the type ID.
static TypeId GetTypeId(void)
Get the type ID.
virtual Ptr< Node > GetNode(void) const =0
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Instantiate subclasses of ns3::Object.
static void DoBeamforming(Ptr< NetDevice > thisDevice, Ptr< PhasedArrayModel > thisAntenna, Ptr< NetDevice > otherDevice)
Perform the beamforming using the DFT beamforming method.
static TypeId GetTypeId(void)
Get the type ID.
static void SetSeed(uint32_t seed)
Set the seed.
static void Run(void)
Run the simulation.
Hold variables of type string.
virtual void SetNode(Ptr< Node > node)
static TypeId GetTypeId(void)
Get the type ID.
Class holding the azimuth and inclination angles of spherical coordinates.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
double GetAzimuth(void) const
Getter for azimuth angle.
static TypeId GetTypeId(void)
Get the type ID.
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
double f(double x, void *params)
static TypeId GetTypeId(void)
Get the type ID.
AttributeValue implementation for Time.
Keep track of the current position and velocity of an object.
keep track of a set of node pointers.
virtual Vector GetElementLocation(uint64_t index) const =0
Returns the location of the antenna element with the specified index, normalized with respect to the ...
Base class for the 3GPP propagation models.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Hold an unsigned integer type.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
void SetDefault(std::string name, const AttributeValue &value)
virtual uint64_t GetNumberOfElements(void) const =0
Returns the number of antenna elements.
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.
std::vector< std::complex< double > > ComplexVector
type definition for complex vectors
void SetChannelConditionModel(Ptr< ChannelConditionModel > model)
Set the channel condition model used to determine the channel state (e.g., the LOS/NLOS condition)
Base class for the 3GPP channel condition models.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.