28#include "ns3/buildings-module.h"
29#include "ns3/core-module.h"
30#include "ns3/mobility-module.h"
31#include "ns3/network-module.h"
32#include "ns3/spectrum-signal-parameters.h"
33#include "ns3/three-gpp-channel-model.h"
34#include "ns3/three-gpp-spectrum-propagation-loss-model.h"
35#include "ns3/three-gpp-v2v-propagation-loss-model.h"
36#include "ns3/uniform-planar-array.h"
76 Angles completeAngle(rxMob->GetPosition(), txMob->GetPosition());
78 thisAntenna->SetBeamformingVector(bf);
93 NS_LOG_DEBUG(
"Pathloss " << -propagationGainDb <<
" dB");
94 double propagationGainLinear = std::pow(10.0, (propagationGainDb) / 10.0);
95 *(params.txParams->psd) *= propagationGainLinear;
103 params.txAntenna->GetBeamformingVector(),
104 params.rxAntenna->GetBeamformingVector());
106 NS_LOG_DEBUG(
"Average rx power " << 10 * log10(
Sum(*rxPsd) * 180e3) <<
" dB");
110 const double kT_dBm_Hz = -174.0;
111 double kT_W_Hz = std::pow(10.0, (kT_dBm_Hz - 30) / 10.0);
112 double noiseFigureLinear = std::pow(10.0, params.noiseFigure / 10.0);
113 double noisePowerSpectralDensity = kT_W_Hz * noiseFigureLinear;
115 (*noisePsd) = noisePowerSpectralDensity;
120 f.open(
"three-gpp-v2v-channel-example-output.txt", std::ios::out | std::ios::app);
122 << params.txMob->GetPosition().x <<
" " << params.txMob->GetPosition().y <<
" "
123 << params.rxMob->GetPosition().x <<
" " << params.rxMob->GetPosition().y <<
" "
124 << cond->GetLosCondition() <<
" "
125 << 10 * log10(
Sum(*rxPsd) /
Sum(*noisePsd)) <<
" "
126 << -propagationGainDb << std::endl;
138 std::ofstream outFile;
139 outFile.open(filename, std::ios_base::out | std::ios_base::trunc);
140 if (!outFile.is_open())
147 Box box = (*it)->GetBoundaries();
148 outFile << box.
xMin <<
" " << box.
yMin <<
" " << box.
xMax <<
" " << box.
yMax << std::endl;
153main(
int argc,
char* argv[])
155 double frequency = 28.0e9;
156 double txPow_dbm = 30.0;
157 double noiseFigure = 9.0;
160 std::string scenario =
"V2V-Urban";
162 double subCarrierSpacing = 60e3;
167 cmd.AddValue(
"frequency",
"operating frequency in Hz", frequency);
168 cmd.AddValue(
"txPow",
"tx power in dBm", txPow_dbm);
169 cmd.AddValue(
"noiseFigure",
"noise figure in dB", noiseFigure);
170 cmd.AddValue(
"scenario",
"3GPP propagation scenario, V2V-Urban or V2V-Highway", scenario);
171 cmd.AddValue(
"updatePeriodMs",
"the channel update period", updatePeriodMs);
172 cmd.Parse(argc, argv);
196 if (scenario ==
"V2V-Urban")
202 double buildingSizeX = 250 - 3.5 * 2 - 3;
203 double buildingSizeY = 433 - 3.5 * 2 - 3;
204 double streetWidth = 20;
205 double buildingHeight = 10;
208 double maxAxisX = (buildingSizeX + streetWidth) * numBuildingsX;
209 double maxAxisY = (buildingSizeY + streetWidth) * numBuildingsY;
211 std::vector<Ptr<Building>> buildingVector;
212 for (
uint32_t buildingIdX = 0; buildingIdX < numBuildingsX; ++buildingIdX)
214 for (
uint32_t buildingIdY = 0; buildingIdY < numBuildingsY; ++buildingIdY)
219 building->SetBoundaries(
220 Box(buildingIdX * (buildingSizeX + streetWidth),
221 buildingIdX * (buildingSizeX + streetWidth) + buildingSizeX,
222 buildingIdY * (buildingSizeY + streetWidth),
223 buildingIdY * (buildingSizeY + streetWidth) + buildingSizeY,
226 building->SetNRoomsX(1);
227 building->SetNRoomsY(1);
228 building->SetNFloors(1);
229 buildingVector.push_back(building);
235 double vRx = vScatt / 2;
240 Waypoint(nextWaypoint, Vector(maxAxisX / 2 - streetWidth / 2, 1.0, 1.5)));
241 nextWaypoint +=
Seconds((maxAxisY - streetWidth) / 2 / vTx);
244 Vector(maxAxisX / 2 - streetWidth / 2, maxAxisY / 2 - streetWidth / 2, 1.5)));
245 nextWaypoint +=
Seconds((maxAxisX - streetWidth) / 2 / vTx);
247 Waypoint(nextWaypoint, Vector(0.0, maxAxisY / 2 - streetWidth / 2, 1.5)));
250 Waypoint(nextWaypoint, Vector(maxAxisX / 2 - streetWidth / 2, 0.0, 1.5)));
251 nextWaypoint +=
Seconds(maxAxisY / vRx);
253 Waypoint(nextWaypoint, Vector(maxAxisX / 2 - streetWidth / 2, maxAxisY, 1.5)));
255 nodes.Get(0)->AggregateObject(txMob);
256 nodes.Get(1)->AggregateObject(rxMob);
264 else if (scenario ==
"V2V-Highway")
272 double vRx = vScatt / 2;
281 nodes.Get(0)->AggregateObject(txMob);
282 nodes.Get(1)->AggregateObject(rxMob);
303 channelModel->SetAttribute(
"Scenario",
StringValue(scenario));
304 channelModel->SetAttribute(
"Frequency",
DoubleValue(frequency));
306 channelModel->SetAttribute(
"vScatt",
DoubleValue(vScatt));
322 double freqSubBand = frequency;
323 for (
uint32_t n = 0; n < numRb; ++n)
327 freqSubBand += (subCarrierSpacing * 12) / 2;
329 freqSubBand += (subCarrierSpacing * 12) / 2;
336 double txPow_w = std::pow(10., (txPow_dbm - 30) / 10);
337 double txPowDens = (txPow_w / (numRb * subCarrierSpacing * 12));
338 (*txPsd) = txPowDens;
339 txParams->psd = txPsd->Copy();
341 for (
int i = 0; i < simTime / timeRes; i++)
349 f.open(
"three-gpp-v2v-channel-example-output.txt", std::ios::out);
350 f <<
"Time[s] TxPosX[m] TxPosY[m] RxPosX[m] RxPosY[m] ChannelState SNR[dB] Pathloss[dB]"
Class holding the azimuth and inclination angles of spherical coordinates.
double yMax
The y coordinate of the top bound of the box.
double xMin
The x coordinate of the left bound of the box.
double yMin
The y coordinate of the bottom bound of the box.
double xMax
The x coordinate of the right bound of the box.
static void Install(Ptr< Node > node)
Install the MobilityBuildingInfo to a node.
Parse command-line arguments.
Mobility model for which the current speed does not change once it has been set and until it is set a...
This class can be used to hold variables of floating point type such as 'double' or 'float'.
keep track of a set of node pointers.
ComplexMatrixArray ComplexVector
the underlying Valarray
AttributeValue implementation for Pointer.
Smart pointer class similar to boost::intrusive_ptr.
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.
Simulation virtual time values and global simulation resolution.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Hold an unsigned integer type.
Waypoint-based mobility model.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#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 Seconds(double value)
Construct a Time in the indicated unit.
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.
std::vector< BandInfo > Bands
Container of BandInfo.
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.
ComputeSnrParams(Ptr< MobilityModel > pTxMob, Ptr< MobilityModel > pRxMob, double pTxPow, double pNoiseFigure, Ptr< PhasedArrayModel > pTxAntenna, Ptr< PhasedArrayModel > pRxAntenna, double pFrequency, double pBandwidth, double pResourceBlockBandwidth)
Constructor.
Ptr< PhasedArrayModel > txAntenna
the tx antenna array
Ptr< MobilityModel > rxMob
the rx mobility model
Ptr< SpectrumSignalParameters > txParams
the params of the tx signal
double noiseFigure
the noise figure in dB
Ptr< PhasedArrayModel > rxAntenna
the rx antenna array
Ptr< MobilityModel > txMob
the tx mobility model
The building block of a SpectrumModel.
double fc
center frequency
double fl
lower limit of subband
double fh
upper limit of subband
static Ptr< ChannelConditionModel > m_condModel
the ChannelConditionModel object
static Ptr< ThreeGppPropagationLossModel > m_propagationLossModel
the log component
static void ComputeSnr(const ComputeSnrParams ¶ms)
Compute the average SNR.
static void DoBeamforming(Ptr< MobilityModel > txMob, Ptr< PhasedArrayModel > thisAntenna, Ptr< MobilityModel > rxMob)
Perform the beamforming using the DFT beamforming method.
void PrintGnuplottableBuildingListToFile(std::string filename)
Generates a GNU-plottable file representing the buildings deployed in the scenario.
static Ptr< ThreeGppSpectrumPropagationLossModel > m_spectrumLossModel
the SpectrumPropagationLossModel object