20 #include <ns3/command-line.h>
21 #include <ns3/core-module.h>
22 #include <ns3/double.h>
23 #include <ns3/isotropic-antenna-model.h>
24 #include <ns3/mobility-helper.h>
25 #include <ns3/node-container.h>
26 #include <ns3/object-factory.h>
27 #include <ns3/pointer.h>
28 #include <ns3/string.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/two-ray-spectrum-propagation-loss-model.h>
33 #include <ns3/uinteger.h>
34 #include <ns3/uniform-planar-array.h>
50 constexpr
double BW = 200e6;
70 Create<OutputStreamWrapper>(
"two-ray-to-three-gpp-calibration.csv", std::ios::out);
73 LogEndToEndGain(std::string cond, std::string scen,
double fc,
long int seed,
double gain)
89 double f = fc - (numRbs *
RB_WIDTH / 2.0);
93 std::vector<int> rbsId;
94 rbsId.reserve(numRbs);
96 for (uint32_t numrb = 0; numrb < numRbs; ++numrb)
106 rbsId.push_back(numrb);
111 double powerTxW = std::pow(10., (powerTx - 30) / 10);
112 double txPowerDensity = powerTxW /
BW;
114 for (
auto rbId : rbsId)
116 (*txPsd)[rbId] = txPowerDensity;
135 channelConditionModel = CreateObject<AlwaysLosChannelConditionModel>();
137 else if (cond ==
"NLOS")
139 channelConditionModel = CreateObject<NeverLosChannelConditionModel>();
149 CreateObject<ThreeGppSpectrumPropagationLossModel>();
154 threeGppChannelModel->SetAttribute(
"ChannelConditionModel",
163 signalParams->
psd = txPsd;
166 threeGppChannelModel->SetAttribute(
"Frequency",
DoubleValue(fc));
169 threeGppChannelModel->SetAttribute(
"Scenario",
StringValue(scen));
172 threeGppChannelModel->SetAttribute(
"Blockage",
BooleanValue(
false));
178 Vector bPos = bMob->GetPosition();
181 Angles angleBtoA(bPos, aPos);
182 Angles angleAtoB(aPos, bPos);
196 return rxPower / txPower;
200 main(
int argc,
char* argv[])
202 uint32_t numRealizations = 5000;
203 bool enableOutput =
false;
206 cmd.AddValue(
"enableOutput",
"Logs the results of the example", enableOutput);
207 cmd.AddValue(
"numRealizations",
"The number of different realizations", numRealizations);
208 cmd.Parse(argc, argv);
223 Vector aPos(0.0, 0.0, 0.0);
224 Vector bPos(10.0, 0.0, 0.0);
225 positionAlloc->Add(aPos);
226 positionAlloc->Add(bPos);
227 mobility.SetPositionAllocator(positionAlloc);
228 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
233 CreateObjectWithAttributes<UniformPlanarArray>(
"NumColumns",
239 CreateObjectWithAttributes<UniformPlanarArray>(
"NumColumns",
252 for (uint32_t runIdx = 0; runIdx < numRealizations; runIdx++)
double f(double x, void *params)
Class holding the azimuth and inclination angles of spherical coordinates.
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'.
Helper class used to assign positions and mobility models to nodes.
Keep track of the current position and velocity of an object.
Vector GetPosition() const
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.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
std::ostream * GetStream()
Return a pointer to an ostream previously set in the wrapper.
void SetAntennaElement(Ptr< AntennaModel > antennaElement)
Sets the antenna model to be used.
ComplexVector GetBeamformingVector() const
Returns the beamforming vector that is currently being used.
void SetBeamformingVector(const ComplexVector &beamformingVector)
Sets the beamforming vector to be used.
Hold objects of type Ptr<T>.
Hold variables of type string.
Ptr< SpectrumValue > DoCalcRxPowerSpectralDensity(Ptr< const SpectrumSignalParameters > params, Ptr< const MobilityModel > a, Ptr< const MobilityModel > b, Ptr< const PhasedArrayModel > aPhasedArrayModel, Ptr< const PhasedArrayModel > bPhasedArrayModel) const override
Computes the received PSD.
Hold an unsigned integer type.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double Integral(const SpectrumValue &arg)
std::vector< BandInfo > Bands
Container of BandInfo.
The building block of a SpectrumModel.
double fc
center frequency
double fl
lower limit of subband
double fh
upper limit of subband
Ptr< SpectrumValue > psd
The Power Spectral Density of the waveform, in linear units.
void LogEndToEndGain(std::string cond, std::string scen, double fc, long int seed, double gain)
const Ptr< OutputStreamWrapper > g_outStream
const std::vector< std::string > LOS_CONDITIONS
Ptr< SpectrumValue > CreateTxPowerSpectralDensity(double fc)
const std::vector< std::string > THREE_GPP_SCENARIOS
double ComputePowerSpectralDensityOverallPower(Ptr< const SpectrumValue > psd)
double ComputeEndToEndGain(std::string cond, std::string scen, double fc, Ptr< Node > a, Ptr< Node > b, Ptr< PhasedArrayModel > aArray, Ptr< PhasedArrayModel > bArray)
constexpr double RB_WIDTH