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>
50constexpr double BW = 200e6;
70 Create<OutputStreamWrapper>(
"two-ray-to-three-gpp-calibration.csv", std::ios::out);
73LogEndToEndGain(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>();
153 threeGppSpectrumLossModel->SetAttribute(
"ChannelModel",
PointerValue(threeGppChannelModel));
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));
177 Vector aPos = aMob->GetPosition();
178 Vector bPos = bMob->GetPosition();
181 Angles angleBtoA(bPos, aPos);
182 Angles angleAtoB(aPos, bPos);
185 aArray->SetBeamformingVector(aArray->GetBeamformingVector(angleBtoA));
186 bArray->SetBeamformingVector(bArray->GetBeamformingVector(angleAtoB));
189 auto rxPsd = threeGppSpectrumLossModel->DoCalcRxPowerSpectralDensity(signalParams,
196 return rxPower / txPower;
200main(
int argc,
char* argv[])
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",
237 aPhasedArray->SetAntennaElement(
PointerValue(CreateObject<IsotropicAntennaModel>()));
239 CreateObjectWithAttributes<UniformPlanarArray>(
"NumColumns",
243 bPhasedArray->SetAntennaElement(
PointerValue(CreateObject<IsotropicAntennaModel>()));
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.
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.
std::ostream * GetStream()
Return a pointer to an ostream previously set in the wrapper.
Hold objects of type Ptr<T>.
Smart pointer class similar to boost::intrusive_ptr.
Hold variables of type string.
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
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
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)
Ptr< SpectrumValue > CreateTxPowerSpectralDensity(double fc)
constexpr double RB_WIDTH