A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
three-gpp-channel-example.cc File Reference

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>
Include dependency graph for three-gpp-channel-example.cc:

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 &params)
 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< ThreeGppPropagationLossModelm_propagationLossModel
 the PropagationLossModel object
static Ptr< ThreeGppSpectrumPropagationLossModelm_spectrumLossModel
 the SpectrumPropagationLossModel object

Detailed Description

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.

Usage

$ ./ns3 run "three-gpp-channel-example [Program Options]"

Program Options

--frequency
Operating frequency in Hz [2.125e+09]
--txPow
TX power in dBm [49]
--noiseFigure
Noise figure in dB [9]
--distance
Distance between TX and RX nodes in meters [10]
--simTime
Simulation time in milliseconds [1000]
--timeRes
Time resolution in milliseconds [10]
--scenario
3GPP propagation scenario [UMa]

Definition in file three-gpp-channel-example.cc.

Function Documentation

◆ BuildRxMatchedFilterOverAllClusters()

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 )
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}\|}
\‍]

The per-cluster channel matrix $\mathbf{H}_{c}$ is obtained from params->m_channel(u, s, c) (u: RX element index, s: TX element index, c: cluster index).

Parameters
paramsChannel parameters containing the per-cluster channel matrix.
txAntennaTX phased-array model.
rxAntennaRX phased-array model.
wTxUnit-norm TX beamforming/precoding vector (size must match txAntenna->GetNumElems()).
Returns
The RX combining vector (size rxAntenna->GetNumElems()), normalized to unit norm (unless the channel is all-zero, in which case a zero vector is returned).

Definition at line 178 of file three-gpp-channel-example.cc.

References ns3::ValArray< T >::GetSize(), NS_ASSERT_MSG, and u.

Referenced by ComputeSnr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ComputeSnr()

void ComputeSnr ( const ComputeSnrParams & params)
static

Compute the average SNR.

Parameters
paramsA 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().

Here is the call graph for this function:

◆ DoBeamforming()

void DoBeamforming ( Ptr< MobilityModel > txMob,
Ptr< PhasedArrayModel > thisAntenna,
Ptr< MobilityModel > rxMob,
double sign )
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:

  • Use sign = -1 when generating TX weights (precoding).
  • Use sign = +1 when generating RX weights (so that Hermitian combining applies the conjugation).
Parameters
txMobThe mobility model of the node for which the weights are generated.
thisAntennaThe antenna array on which the beamforming vector is set.
rxMobThe mobility model of the peer node toward/from which the beam is steered.
signPhase 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().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ m_propagationLossModel

Ptr<ThreeGppPropagationLossModel> m_propagationLossModel
static

the PropagationLossModel object

Definition at line 46 of file three-gpp-channel-example.cc.

◆ m_spectrumLossModel

Ptr<ThreeGppSpectrumPropagationLossModel> m_spectrumLossModel
static

the SpectrumPropagationLossModel object

Definition at line 48 of file three-gpp-channel-example.cc.