This example shows how to configure the 3GPP channel model classes to compute the SNR between two nodes. More...
#include "ns3/channel-condition-model.h"#include "ns3/constant-position-mobility-model.h"#include "ns3/constant-velocity-mobility-model.h"#include "ns3/core-module.h"#include "ns3/lte-spectrum-value-helper.h"#include "ns3/mobility-model.h"#include "ns3/node-container.h"#include "ns3/node.h"#include "ns3/spectrum-signal-parameters.h"#include "ns3/three-gpp-channel-model.h"#include "ns3/three-gpp-propagation-loss-model.h"#include "ns3/three-gpp-spectrum-propagation-loss-model.h"#include "ns3/uniform-planar-array.h"#include <fstream>Go to the source code of this file.
Classes | |
| struct | ComputeSnrParams |
| A structure that holds the parameters for the ComputeSnr function. More... | |
Functions | |
| static ns3::PhasedArrayModel::ComplexVector | BuildRxMatchedFilterOverAllClusters (ns3::Ptr< const ns3::MatrixBasedChannelModel::ChannelMatrix > params, ns3::Ptr< const ns3::PhasedArrayModel > txAntenna, ns3::Ptr< const ns3::PhasedArrayModel > rxAntenna, const ns3::PhasedArrayModel::ComplexVector &wTx) |
| Build the RX matched-filter (maximum-ratio) combining vector by aggregating the contributions of all clusters and normalizing the result: | |
| static void | ComputeSnr (const ComputeSnrParams ¶ms) |
| Compute the average SNR. | |
| static void | DoBeamforming (Ptr< MobilityModel > txMob, Ptr< PhasedArrayModel > thisAntenna, Ptr< MobilityModel > rxMob, double sign) |
| Perform a simple (DFT/steering) beamforming toward the other node. | |
Variables | |
| static Ptr< ThreeGppPropagationLossModel > | m_propagationLossModel |
| the PropagationLossModel object | |
| static Ptr< ThreeGppSpectrumPropagationLossModel > | m_spectrumLossModel |
| the SpectrumPropagationLossModel object | |
This example shows how to configure the 3GPP channel model classes to compute the SNR between two nodes.
The simulation involves two static nodes which are placed at a certain distance from each other and communicate through a wireless channel at 2 GHz with a bandwidth of 18 MHz. The default propagation environment is 3D-urban macro (UMa), and it can be configured changing the value of the string "scenario". Each node hosts has an antenna array with 4 antenna elements.
The example writes its main results to the file snr-trace.txt. Each row contains: (i) the simulation time (s), (ii) the SNR obtained with steering vectors (DoBeamforming), (iii) the SNR obtained with matched-filter combining, and (iv) the propagation gain.
$ ./ns3 run "three-gpp-channel-example [Program Options]"
--frequency --txPow --noiseFigure --distance --simTime --timeRes --scenario Definition in file three-gpp-channel-example.cc.
|
static |
Build the RX matched-filter (maximum-ratio) combining vector by aggregating the contributions of all clusters and normalizing the result:
![\[\mathbf{g} = \sum_{c} \mathbf{H}_{c}\mathbf{w}_{\rm tx}, \qquad
\mathbf{w}_{\rm rx} = \frac{\mathbf{g}}{\|\mathbf{g}\|}
\]](../../form_213.png)
The per-cluster channel matrix 
| params | Channel parameters containing the per-cluster channel matrix. |
| txAntenna | TX phased-array model. |
| rxAntenna | RX phased-array model. |
| wTx | Unit-norm TX beamforming/precoding vector (size must match txAntenna->GetNumElems()). |
Definition at line 178 of file three-gpp-channel-example.cc.
References ns3::ValArray< T >::GetSize(), NS_ASSERT_MSG, and u.
Referenced by ComputeSnr().
|
static |
Compute the average SNR.
| params | A structure that holds the parameters that are needed to perform calculations in ComputeSnr |
Definition at line 232 of file three-gpp-channel-example.cc.
References BuildRxMatchedFilterOverAllClusters(), ns3::Create(), ns3::LteSpectrumValueHelper::CreateNoisePowerSpectralDensity(), ns3::LteSpectrumValueHelper::CreateTxPowerSpectralDensity(), DoBeamforming(), ns3::DynamicCast(), ns3::Time::GetSeconds(), m_propagationLossModel, m_spectrumLossModel, ns3::Simulator::Now(), NS_ASSERT_MSG, NS_LOG_DEBUG, and ns3::Sum().
|
static |
Perform a simple (DFT/steering) beamforming toward the other node.
This function builds a per-element complex weight vector based on the geometric direction between two nodes and the antenna element locations returned by PhasedArrayModel::GetElementLocation(). The weights are unit-norm (equal power across elements) and have the form:
w[i] = exp(j * phase_i) / sqrt(N), phase_i = sign * 2*pi * ( u · r_i )
where u is the unit direction corresponding to the azimuth/inclination angles of the line-of-sight vector between the nodes, r_i is the location of element i in the array coordinate system, and N is the number of antenna elements.
Sign convention and how to use this function:
The 3GPP channel coefficients are constructed using spatial phase terms of the form exp(+j*2*pi*(u·r)) (see ThreeGppChannelModel::GetNewChannel()), i.e., the array response/steering vector toward a direction is proportional to:
a(theta)[i] = exp(+j*2*pi*(u·r_i)).
In standard array processing, a transmit precoder that steers energy toward that direction uses the complex conjugate of the response, therefore sign = -1 (phase = -2*pi*(u·r_i)).
For receive combining, the effective scalar channel is computed using the Hermitian inner product:
h_eff = w_rx^H * H * w_tx .
To obtain matched-filter (maximum-ratio) receive combining toward the same direction, the stored receive weight vector should be proportional to the response a(theta), so that w_rx^H applies the conjugation at combining time sign = +1 (phase = +2*pi*(u·r_i)).
Therefore, when this function is used to set beamforming vectors explicitly in this example:
| txMob | The mobility model of the node for which the weights are generated. |
| thisAntenna | The antenna array on which the beamforming vector is set. |
| rxMob | The mobility model of the peer node toward/from which the beam is steered. |
| sign | Phase progression sign: typically -1 for TX weights and +1 for RX weights. |
Definition at line 115 of file three-gpp-channel-example.cc.
References ns3::Angles::GetAzimuth(), and ns3::Angles::GetInclination().
Referenced by ComputeSnr().
|
static |
the PropagationLossModel object
Definition at line 46 of file three-gpp-channel-example.cc.
|
static |
the SpectrumPropagationLossModel object
Definition at line 48 of file three-gpp-channel-example.cc.