Hi,
In my simulation scenario, I'm creating 50 nodes, where 10 nodes are sources (called producers in the code) and 10 are sinks (called sinks in the code), as follows. Then I use those containers to install the applications.
main(int argc, char* argv[])
{
uint32_t m_nNodes = 50;
uint32_t noConsumers = 10;
uint32_t noProducers = 10;
NodeContainer c;
c.Create(m_nNodes);
// configure wifi, mac, phy, etc
NetDeviceContainer wifiNetDevices = wifi.Install(wifiPhyHelper, wifiMacHelper, c);
// Create Node Container for Consumer nodes
NodeContainer consumers;
for (uint32_t i = 0; i < noConsumers; i++) {
consumers.Add(c.Get(i));
std::cerr << "Consumer Node: " << consumers.Get (i) << std::endl;
}
std::cerr << "Number of consumers is: " << consumers.GetN() << std::endl;
// Create Node Container for Producer nodes
NodeContainer producers;
for (uint32_t i = noConsumers; i < (noConsumers + noProducers); i++) {
producers.Add(c.Get(i));
std::cerr << "Producer Node: " << producers.Get (i) << std::endl;
}
std::cerr << "Number of producers is: " << producers.GetN() << std::endl;
// Create Node Container for AllOtherNodes (routers)
NodeContainer routers;
for (uint32_t i = (noConsumers + noProducers); i < m_nNodes; i++) {
routers.Add(c.Get(i));
//std::cerr << "Router Node: " << routers.Get (i) << std::endl;
}
std::cerr << "Number of routers is: " << routers.GetN() << std::endl;
// Install applications
The code prints the pointers to the consumer nodes, but crashes when prints the producer nodes. I ran the debugger:
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Number of nodes is: 50
Consumer Node: 0x699780
Consumer Node: 0x699b30
Consumer Node: 0x699c30
Consumer Node: 0x699d20
Consumer Node: 0x699e10
Consumer Node: 0x699ef0
Consumer Node: 0x699ff0
Consumer Node: 0x69a110
Consumer Node: 0x69a230
Consumer Node: 0x69a470
Number of consumers is: 10
Producer Node: 0
Producer Node: 0
Producer Node: 0
Producer Node: 0
Program received signal SIGSEGV, Segmentation fault.
0x0000000000414ff5 in ns3::SimpleRefCount<ns3::Object, ns3::ObjectBase, ns3::ObjectDeleter>::Ref (this=0x3a352944000) at ./ns3/simple-ref-count.h:102
102 NS_ASSERT (m_count < std::numeric_limits<uint32_t>::max());
I can't see what's wrong with the code. If I remove the prints or use less producers it works.
Can you assist please?
Thank you