Please help me locate the error in my ns3 code

2,447 views
Skip to first unread message

Vishaka Basnayake

unread,
Apr 26, 2020, 4:39:21 PM4/26/20
to ns-3-users
Hello, 

I recently joined ns3 and I am working on developing a scenario in ns3. 

In the code, I am trying to create a multicast call from one node to several other nodes that are in an out of coverage area.  Since this is out of coverage, I am using the sidelink resource pool in LTE.

Additionally, I use the attributes of the MCPTT service introduced for LTE for fast communications with many people at the same time. To implement MCPTT service in the application layer, network layer and physical layer, I added the necessary configurations according to my understanding. Further, I also added configurations to activate sidelink communication between nodes in the same code. I configured the physical layer attributes of the sidelink.  

Finally, when I run the code I find that it gets stuck at the line simulator:: run(), when  I debug. I think the simulator is finding difficulty in understanding my commands and creating the simulation as ordered. 

Currently, I am finding it difficult to find the error. Therefore, I need your help in order for me to find the issue that is in my code.

Please check my code attached herewith and help me if it is possible. 
Many thanks, 
Vishaka


broadcast_5.cc

Tom Henderson

unread,
Apr 26, 2020, 5:41:43 PM4/26/20
to ns-3-...@googlegroups.com, Vishaka Basnayake
Hi Vishaka, first, I would like to state for any others reading this
that this question pertains to the public safety extensions available as
a special version of ns-3 in the app store:

https://apps.nsnam.org/app/publicsafetylte/

Please also note that version 3 of that repository was published on Friday.

When I run your code on the psc-3.0 release, it seems to run
successfully.  Can you check it there?

- Tom

Vishaka Basnayake

unread,
Apr 27, 2020, 4:48:27 AM4/27/20
to Tom Henderson, ns-3-...@googlegroups.com
Hello Tom, 
thank you so much for the news about psc new version. I used it an still the error occurs when i uncomment the line simulator::run(). In the file i attached earlier it was commented which must be the reason that it worked successfully. 

I hope someone can help me find the problem in my code. I will attach the code once again with the uncommenting the line which brings me the error.i am sorry for the inconvenience caused earlier. 
Thanks 
Vishaka 
broadcast_5_.cc

Vishaka Basnayake

unread,
Apr 27, 2020, 7:28:39 AM4/27/20
to Tom Henderson, ns-3-...@googlegroups.com
I get the error as, 

"assert failed. cond="m_ptr", msg="Attempted to dereference zero pointer", file=./ns3/ptr.h, line=783
terminate called without an active exception"

What does this error mean?
Any help will be appreciated a lot.
Vishaka

Jay Patel

unread,
Apr 27, 2020, 10:49:13 AM4/27/20
to ns-3-users
Hi,

I had run your code on PSC app. It is working fine. 

Check that for more details. 

Jay

Vishaka Basnayake

unread,
Apr 27, 2020, 1:01:40 PM4/27/20
to ns-3-...@googlegroups.com
Please do not check the first code I attached. The second code I attached is having the error. 
Anyway, the code gets stuck and do no proceed. 
I will attach here the code-named "broadcast_5_with_error" which is getting stuck at the line 801. 

Please try again and let me know the reason why the code is not working if possible. 

--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/a37fbbba-1014-4c63-9b52-edbbd82b3b2f%40googlegroups.com.
broadcast_5_with error.cc

Vishaka Basnayake

unread,
Apr 27, 2020, 6:31:47 PM4/27/20
to ns-3-...@googlegroups.com
I think the code is working now. thanks for your help.

aadesh shah

unread,
Jun 2, 2020, 2:16:35 PM6/2/20
to ns-3-users
Hey how did you solve the error?

I am assuming the error is due to the usage of flowmointor.

Let me know how did you come around that?

Regards,
Aadesh Shah
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-...@googlegroups.com.

Vishaka Basnayake

unread,
Jun 7, 2020, 2:54:08 PM6/7/20
to ns-3-...@googlegroups.com
I modified it and this is the code that worked for me. 


Virus-free. www.avast.com

To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/aeecf1ff-cb9c-4db6-8d8f-0be9da352b10%40googlegroups.com.

Virus-free. www.avast.com
broadcast_20_ori.cc

BENMADANI Houssem Eddine

unread,
May 8, 2023, 4:01:48 PM5/8/23
to ns-3-users
Hi aadesh,
Did you mange to solve this problem?
i got the same error when using flowmonitor in my simulation scenario:
assert failed. cond="m_ptr", msg="Attempted to dereference zero pointer", +2.000000000s -1 file=./ns3/ptr.h, line=649
terminate called without an active exception.
Please, let me know if you did.
Best regards.

ufuk bolat

unread,
May 22, 2023, 2:40:05 AM5/22/23
to ns-3-users
hello, 

did you solve the "  cond="m_ptr", msg="Attempted to dereference zero pointer", +2.000000000s -1 file=./ns3/ptr.h, line=649" problem?

thx, br

8 Mayıs 2023 Pazartesi tarihinde saat 23:01:48 UTC+3 itibarıyla BENMADANI Houssem Eddine şunları yazdı:

Gabriel Ferreira

unread,
May 22, 2023, 4:27:33 PM5/22/23
to ns-3-users
Try running with valgrind or with sanitizers. It might point out the source of the issue.

ufuk bolat

unread,
May 26, 2023, 4:06:38 PM5/26/23
to ns-3-users
Hello again,

first of all I would like to thank you for your attention Gabriel.

Please let me explain my problem briefly.

https://www.youtube.com/watch?v=BjU3mdujoXg&t=900s I've watched this video. My only goal is to get result file which is exist in this video. I created my sumo file on webwizard and then did necessary steps such as vanettrace.xml and ".tcl" file. 

After that I've add performance calculations and updated m_scenario=2 according to my use case. 

The youtube video says that I need to use ./waf run but I learned that ./ns3 is the new version of it. 

I'm really new on NS3 and I just need to get these results. But every time I'm getting  following error:

Routing Setup for OLSR
assert failed. cond="m_ptr", msg="Attempted to dereference zero pointer", +0.000000000s -1 file=/home/ufukbolat/Desktop/ms-van3t/ns-3-dev/build/include/ns3/ptr.h, line=649

terminate called without an active exception
Command 'build/scratch/ns3-dev-vanet-routing-compare-default --protocol=1 --scenario=2' died with <Signals.SIGABRT: 6>.

my command is:

/Desktop/ms-van3t/ns-3-dev$ ./ns3 run "scratch/vanet-routing-compare --protocol=1 --scenario=2"

Could you help me, please? Because almost 2 weeks I'm trying to solve this problem and I am really new not only NS3 but also C language.

Thanks again.
BR,
Ufuk
22 Mayıs 2023 Pazartesi tarihinde saat 23:27:33 UTC+3 itibarıyla Gabriel Ferreira şunları yazdı:

Tommaso Pecorella

unread,
May 26, 2023, 4:08:38 PM5/26/23
to ns-3-users
No script, no help.

ufuk bolat

unread,
May 26, 2023, 4:19:10 PM5/26/23
to ns-3-users
Hello Tommaso,

I hope you will use soft&calm voice to me because I've read your other comment on this issue and it was really scary:)

I've attached the files below. As i said before I'm new on these topics so I dont know how to fix it, but I tried to do that.

I think the problem is stem from flowman but I couldnt figure it out.

Thanks & BR,
Ufuk



26 Mayıs 2023 Cuma tarihinde saat 23:08:38 UTC+3 itibarıyla Tommaso Pecorella şunları yazdı:
vanet-routing-compare.cc
vanetmobility.tcl

Tommaso Pecorella

unread,
May 26, 2023, 5:34:19 PM5/26/23
to ns-3-users
Mmm.... nice bug. No wonder we're going to kill wave (yes, we'll remove wave from the codebase).

Still, in THIS case it's not exactly wave - it's the example. And the problem wasn't even that simple to spot.
Well, it WAS easy to spot, the problem was to find out WHY it was happening. That example is a bit... convoluted. Plus, one never expects the Spanish Inquisitions. Or this kind of problems.
You would expect that the script would throw a nice error message if the user uses impossible values, right? Because crashing with an obscure memory assert isn't exactly user-friendly!
Well, wrong expectation: it does.

The long story is: the program crashes in this loop around line 623:
    for (uint32_t i = 0; i < m_nSinks; i++)
    {
        // protocol == 0 means no routing data, WAVE BSM only
        // so do not set up sink
        if (m_protocol != 0)
        {
            Ptr<Socket> sink = SetupRoutingPacketReceive(adhocTxInterfaces.GetAddress(i), c.Get(i));
        }

        AddressValue remoteAddress(InetSocketAddress(adhocTxInterfaces.GetAddress(i), m_port));
        onoff1.SetAttribute("Remote", remoteAddress);

        ApplicationContainer temp = onoff1.Install(c.Get(i + m_nSinks));
        temp.Start(Seconds(var->GetValue(1.0, 2.0)));
        temp.Stop(Seconds(m_TotalSimTime));
    }

The (rather obscure) code just installs OnOff applications in some nodes, but "m_nSinks" is equal to 10, and the container "c" contains 10 nodes (it's a coincidence, that did throw me off for a bit).

Now, "m_nSinks" is 10 because nobody did change it, and by default it is set to 10. The container contains 10 nodes because you did modify this piece of code:
    else if (m_scenario == 2)
    {
        // Realistic vehicular trace in 4.6 km x 3.0 km suburban Zurich
        // "low density, 10 total vehicles"
        m_traceFile = "vanetmobility.tcl";
        m_logFile = "vanet.log";
        m_mobility = 1;
        m_nNodes = 10;
        m_TotalSimTime = 70.01;
        m_nodeSpeed = 0;
        m_nodePause = 0;
        m_CSVfileName = "ufuk26.csv";
        m_CSVfileName = "ufuk26_2.csv";
    }


Note: your trace contains 11 nodes: 0, 1, 2, 10 <- they're 11.
Anyway, originally m_nNodes was set to 99, and m_nNodes must be larger than (or equal to) 2*m_nSinks. If it's less than 2*m_nSinks... Yes Rico, Kaboom.

This one works: ./ns3 run "scratch/vanet-routing-compare --protocol=1 --scenario=2 --sinks=5" - or better: it doesn't crash. If it works as intended... no idea.

ufuk bolat

unread,
May 27, 2023, 6:07:51 PM5/27/23
to ns-3-users
Hello again,

I've never focused on m_nSinks section because I didn't realize it. 

It also worked on my computer and now I'm trying to analyze the results.

I am really grateful Tommaso, thank you so much. Best Regards

27 Mayıs 2023 Cumartesi tarihinde saat 00:34:19 UTC+3 itibarıyla Tommaso Pecorella şunları yazdı:

Praghur

unread,
May 29, 2023, 5:45:52 PM5/29/23
to ns-3-users
Hi all.

I am very new to ns3 and using ns3.38 version. I am trying out a simple LTE simulation without EPC as shown below.

#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/netanim-module.h"


//Flow Monitor Headers

#include "ns3/flow-monitor-module.h"

#include "ns3/flow-monitor-helper.h"


using namespace ns3;

using namespace std;


int main(int argc, char *argv[])

{

CommandLine cmd(__FILE__);

cmd.Parse(argc, argv);

ConfigStore inputConfig;

inputConfig.ConfigureDefaults();

////parse again so you can override default values from the command line

cmd.Parse(argc, argv);

Ptr<LteHelper> lteHelper = CreateObject<LteHelper>();

NodeContainer enbNodes;

enbNodes.Create(1);

NodeContainer ueNodes;

ueNodes.Create(1);

NodeContainer allNodes = NodeContainer(enbNodes,ueNodes);

Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();

positionAlloc->Add (Vector (0.0, 0.0, 0.0)); // eNB1

positionAlloc->Add (Vector (0.0, 20.0, 0.0)); // UE1

MobilityHelper mobility;

mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");

mobility.SetPositionAllocator(positionAlloc);

mobility.Install(allNodes);


NetDeviceContainer enbDevs;

enbDevs = lteHelper->InstallEnbDevice(enbNodes);

NetDeviceContainer ueDevs;

ueDevs = lteHelper->InstallUeDevice(ueNodes);


lteHelper->Attach(ueDevs, enbDevs.Get(0)); /*No cell selection process since UE and eNB is fixed. EPS bearer is default */

enum EpsBearer::Qci q = EpsBearer::GBR_MC_PUSH_TO_TALK ;

EpsBearer bearer(q);

lteHelper->ActivateDataRadioBearer(ueDevs, bearer);


// Flowmonitor

Ptr<FlowMonitor> flowMonitor;

FlowMonitorHelper flowHelper;

flowMonitor = flowHelper.Install(ueNodes);


Simulator::Stop(Seconds(0.02));

Simulator::Run();

flowMonitor->SerializeToXmlFile("LTEOut.xml", true, true);


Simulator::Destroy();

return 0;


When I run the above program, I get the following error. Does the Flowmonitor only run when there is a EPC?

NS_ASSERT failed, cond="m_ptr", msg="Attempted to dereference zero pointer", +0.020000000s -1 file=/home/priya/ns-3-dev/src/core/model/ptr.h, line=752
NS_FATAL, terminating

terminate called without an active exception
Command 'build/scratch/ns3-dev-UE-default --ns3::ConfigStore::Filename=input-defaults.txt --ns3::ConfigStore::Mode=Load --ns3::ConfigStore::FileFormat=RawText' died with <Signals.SIGABRT: 6>.

Anybody else is facing this? My inputs-default is same as shown in ns3 documentation.

default ns3::LteHelper::Scheduler "ns3::PfFfMacScheduler"
default ns3::LteHelper::PathlossModel "ns3::FriisSpectrumPropagationLossModel"
default ns3::LteEnbNetDevice::UlBandwidth "25"
default ns3::LteEnbNetDevice::DlBandwidth "25"
default ns3::LteEnbNetDevice::DlEarfcn "100"
default ns3::LteEnbNetDevice::UlEarfcn "18100"
default ns3::LteUePhy::TxPower "10"
default ns3::LteUePhy::NoiseFigure "9"
default ns3::LteEnbPhy::TxPower "30"
default ns3::LteEnbPhy::NoiseFigure "5"

Can anyone please help? Thanks a lot in advance.

Tommaso Pecorella

unread,
Jun 2, 2023, 5:20:19 AM6/2/23
to ns-3-users
You din't install the IP stack on the nodes, and they have no addresses. Hence, FlowMonitor fails to install.

Raouane Dehimi

unread,
Sep 16, 2023, 3:54:38 PM9/16/23
to ns-3-users
did you solve the problem because ;i m facing the same error now

On Monday, 29 May 2023 at 23:45:52 UTC+2 Praghur wrote:

Praghur

unread,
Dec 7, 2023, 10:23:45 AM12/7/23
to ns-3-users
The error went away when I changed the type of EPS bearer to NGBR_LOW_LAT_EMBB and GBR_CONV_VOICE
Reply all
Reply to author
Forward
0 new messages