nyuwireless-unipd / ns3-mmwave

ns-3 module for simulating mmWave-based cellular systems. See https://ieeexplore.ieee.org/document/8344116/ (open access) as a reference.
GNU General Public License v2.0
292 stars 190 forks source link

Error "Attempted to dereference zero pointer" #236

Closed RahulSinghGulia closed 2 years ago

RahulSinghGulia commented 2 years ago

Hello team,

I am trying to get the SINR heatmaps from the /src/mmwave/examples/mmwave-simple-building-obstacle.cc code using the example shown in /src/lte/examples/lena-rem.cc.

And I am getting the following error.

_Waf: Leaving directory `/home/rahul/Documents/ns3-mmwave-regular/build' Build commands will be stored in build/compile_commands.json 'build' finished successfully (7.790s) assert failed. cond="mptr", msg="Attempted to dereference zero pointer", file=./ns3/ptr.h, line=630 terminate called without an active exception Command ['/home/rahul/Documents/ns3-mmwave-regular/build/scratch/3-rem-mmwave'] terminated with signal SIGIOT. Run it under a debugger to get more information (./waf --run --gdb").

I would really appreciate it if you could suggest to me something about this issue of mine. Please refer to the attached code for reference.


/ -- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -- / /*

include "ns3/core-module.h"

include "ns3/network-module.h"

include "ns3/mobility-module.h"

include "ns3/lte-module.h"

include "ns3/config-store.h"

include "ns3/spectrum-module.h"

include <ns3/buildings-helper.h>

//#include "ns3/gtk-config-store.h"

include <ns3/mmwave-helper.h>

include <ns3/buildings-module.h>

using namespace ns3; using namespace mmwave;

int main (int argc, char *argv[]) {
CommandLine cmd; cmd.Parse (argc, argv);

// to save a template default attribute file run it like this: // ./waf --command-template="%s --ns3::ConfigStore::Filename=input-defaults.txt --ns3::ConfigStore::Mode=Save --ns3::ConfigStore::FileFormat=RawText" --run src/lte/examples/lena-first-sim // // to load a previously created default attribute file // ./waf --command-template="%s --ns3::ConfigStore::Filename=input-defaults.txt --ns3::ConfigStore::Mode=Load --ns3::ConfigStore::FileFormat=RawText" --run src/lte/examples/lena-first-sim

Ptr ptr_mmWave = CreateObject (); ptr_mmWave->SetChannelConditionModelType ("ns3::BuildingsChannelConditionModel");

ConfigStore inputConfig; inputConfig.ConfigureDefaults ();

// Parse again so you can override default values from the command line cmd.Parse (argc, argv);

// Ptr lteHelper = CreateObject ();

// Uncomment to enable logging //lteHelper->EnableLogComponents ();

// Create Nodes: eNodeB and UE NodeContainer enbNodes; NodeContainer ueNodes; enbNodes.Create (1); ueNodes.Create (1);

Ptr < Building > building;
building = Create<Building> ();
building->SetBoundaries (Box (20.0, 40.0,
                             0.0, 20.0,
                             0.0, 20.0));
building->SetBuildingType (Building::Residential);
building->SetExtWallsType (Building::ConcreteWithWindows);
building->SetNFloors (1);
building->SetNRoomsX (1);
building->SetNRoomsY (1);

// Install eNB Mobility Model Ptr enbPositionAlloc = CreateObject (); enbPositionAlloc->Add (Vector (0.0, 0.0, 0.0)); MobilityHelper enbmobility; enbmobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); enbmobility.SetPositionAllocator (enbPositionAlloc); enbmobility.Install (enbNodes); BuildingsHelper::Install (enbNodes);

// Install UE Mobility Model MobilityHelper uemobility; uemobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); uemobility.Install (ueNodes); BuildingsHelper::Install (ueNodes); ueNodes.Get (0)->GetObject ()->SetPosition (Vector (60, -20, 0)); ueNodes.Get (0)->GetObject ()->SetVelocity (Vector (0, 100, 0));

// Create Devices and install them in the Nodes (eNB and UE) NetDeviceContainer enbDevs; NetDeviceContainer ueDevs; enbDevs = ptr_mmWave->InstallEnbDevice (enbNodes); ueDevs = ptr_mmWave->InstallUeDevice (ueNodes);

// Attach a UE to a eNB // lteHelper->Attach (ueDevs, enbDevs.Get (0)); ptr_mmWave->AttachToClosestEnb (enbDevs, ueDevs); ptr_mmWave->EnableTraces ();

// Activate an EPS bearer enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer (q); ptr_mmWave->ActivateDataRadioBearer (ueDevs, bearer);

// Configure Radio Environment Map (REM) output // for LTE-only simulations always use /ChannelList/0 which is the downlink channel Ptr remHelper = CreateObject (); remHelper->SetAttribute ("ChannelPath", StringValue ("/ChannelList/0")); remHelper->SetAttribute ("OutputFile", StringValue ("rem.out")); remHelper->SetAttribute ("XMin", DoubleValue (0.0)); remHelper->SetAttribute ("XMax", DoubleValue (40.0)); remHelper->SetAttribute ("YMin", DoubleValue (0.0)); remHelper->SetAttribute ("YMax", DoubleValue (30.0)); remHelper->SetAttribute ("Z", DoubleValue (0.0)); remHelper->Install ();

// here's a minimal gnuplot script that will plot the above: // // set view map; // set term x11; // set xlabel "X" // set ylabel "Y" // set cblabel "SINR (dB)" // plot "rem.out" using ($1):($2):(10*log10($4)) with image

Simulator::Stop (Seconds (1)); Simulator::Run ();

//GtkConfigStore config; //config.ConfigureAttributes ();

Simulator::Destroy (); return 0; }


Best regards, Rahul Singh Gulia

pagmatt commented 2 years ago

Hi Rahul,

First of all I think the ns-3 documentation can be a valid resource to use in case you have doubts/problems with ns-3. In your case, it seems that you are creating objects without specifying their type. However, you then interpret them as objects of a specific class (for example, PositionAllocatior instances).

Anyway, we do not offer a REM for the mmwave module at the moment. However, you should achieve similar results by deploying a gNB and a UE, periodically updating the position of the latter to a point in the grid of interest and averaging multiple channel realizations for each point!

Best, Matteo

RahulSinghGulia commented 2 years ago

Thank you for your input on my code Matteo. I will try to generate the SINR heatmap via this method.