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

Example demonstrating how to use the Sionna RT channel model in ns-3. More...

#include "pybind11/pybind11.h"
#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/net-device.h"
#include "ns3/node-container.h"
#include "ns3/node.h"
#include "ns3/output-stream-wrapper.h"
#include "ns3/simple-net-device.h"
#include "ns3/sionna-rt-channel-model.h"
#include "ns3/sionna-rt-spectrum-propagation-loss-model.h"
#include "ns3/spectrum-signal-parameters.h"
#include "ns3/three-gpp-antenna-model.h"
#include "ns3/uniform-planar-array.h"
#include <iomanip>
#include <iostream>
Include dependency graph for sionna-rt-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 void ComputeSnr (const ComputeSnrParams &params)
 Compute the average SNR.
static void DoBeamforming (Ptr< NetDevice > thisDevice, Ptr< PhasedArrayModel > thisAntenna, Ptr< NetDevice > otherDevice)
 Perform the beamforming using the DFT beamforming method.
static void PrintPythonExecutable ()
 Print the python executable and version.

Variables

static int g_snrSamples
 number of SNR samples computed
static double g_snrSumDb
 running sum of SNR values in dB
static Ptr< SionnaRtSpectrumPropagationLossModelm_spectrumLossModel
 the SpectrumPropagationLossModel object

Detailed Description

Example demonstrating how to use the Sionna RT channel model in ns-3.

This example shows how to configure and use the Sionna RT channel classes to compute the average SNR between two static/moving nodes in a scene computed using the sionna.rt Python library. The example:

  • Configures a SionnaRtSpectrumPropagationLossModel instance to use the sionna.rt scene and path solver,
  • Creates a simple two-node network (SimpleNetDevice),
  • Configures mobility and uniform planar arrays for antennas on each node,
  • Applies simple DFT-based beamforming to point arrays at the intended peer,
  • Computes average SNR periodically and logs results to the console and a file.

The example uses default 30 GHz operation, 18 MHz equivalent LTE bandwidth (100 RBs), and ThreeGppAntennaModel elements arranged in small planar arrays.

Prerequisites:

  • The sionna.rt Python library must be available and imported properly by the Sionna RT channel model (check PYTHONPATH and environment).

Common command-line options (and defaults):

  • frequency: Operating frequency in Hz (default 30e9)
  • txPow: Tx power in dBm (default 49.0)
  • noiseFigure: Noise figure in dB (default 9.0)
  • distance: Distance between tx and rx in meters (default 50.0)
  • simTime: Simulation time in milliseconds (default 2000)
  • timeRes: Time resolution for periodic SNR compute (ms) (default 10)
  • IsImageRenderedEnabled: Enable rendering of scene images (default true)
  • outputFileName: Output filename prefix for scene images (default "sionna-rt-scene3-")
  • outputFileDirectory: Directory for scene image output (default "sionna-rt-images2")

The example also exposes several Sionna RT path solver configuration parameters:

  • maxDepth: maximum reflection/refraction depth
  • los: include line-of-sight
  • specularReflection: enable specular reflections
  • diffuseReflection: enable diffuse reflections
  • diffraction: enable diffraction
  • edgeDiffraction: enable edge diffraction
  • refraction: enable refractions
  • syntheticArray: use synthetic array processing
  • seed: random seed used by the path solver

The main computed outputs are:

  • Per-iteration SNR
  • Average rx power
  • A log file named "snr-trace.txt" containing time-stamped SNR values
Note
The channel update period is set using the ns-3 attribute: ns3::SionnaRtChannelModel::UpdatePeriod

Definition in file sionna-rt-channel-example.cc.

Function Documentation

◆ 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 172 of file sionna-rt-channel-example.cc.

References ns3::Create(), ns3::LteSpectrumValueHelper::CreateNoisePowerSpectralDensity(), ns3::LteSpectrumValueHelper::CreateTxPowerSpectralDensity(), g_snrSamples, g_snrSumDb, ns3::Time::GetSeconds(), 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< NetDevice > thisDevice,
Ptr< PhasedArrayModel > thisAntenna,
Ptr< NetDevice > otherDevice )
static

Perform the beamforming using the DFT beamforming method.

Parameters
thisDevicethe device performing the beamforming
thisAntennathe antenna object associated to thisDevice
otherDevicethe device towards which point the beam

Definition at line 115 of file sionna-rt-channel-example.cc.

References ns3::Angles::GetAzimuth(), and ns3::Angles::GetInclination().

Here is the call graph for this function:

◆ PrintPythonExecutable()

void PrintPythonExecutable ( )
static

Print the python executable and version.

Definition at line 159 of file sionna-rt-channel-example.cc.

Variable Documentation

◆ g_snrSamples

int g_snrSamples
static

number of SNR samples computed

Definition at line 89 of file sionna-rt-channel-example.cc.

Referenced by ComputeSnr().

◆ g_snrSumDb

double g_snrSumDb
static

running sum of SNR values in dB

Definition at line 90 of file sionna-rt-channel-example.cc.

Referenced by ComputeSnr().

◆ m_spectrumLossModel

Ptr<SionnaRtSpectrumPropagationLossModel> m_spectrumLossModel
static

the SpectrumPropagationLossModel object

Definition at line 88 of file sionna-rt-channel-example.cc.