Hello Team,
When I am running the program which I have made in ns3 version 3.40
I get this error:
┌─[neha@parrot]─[~/Desktop/ns-allinone-3.40/ns-3.40]
└──╼ $./ns3 run scratch/project
[ 0%] Building CXX object scratch/CMakeFiles/scratch_project.dir/project.cc.o
[ 0%] Linking CXX executable /home/neha/Desktop/ns-allinone-3.40/ns-3.40/build/scratch/ns3.40-project-default
NS_ASSERT failed, cond="uid <= m_information.size() && uid != 0", +0.000000000s -1 file=/home/neha/Desktop/ns-allinone-3.40/ns-3.40/src/core/model/type-id.cc, line=459
NS_FATAL, terminating
terminate called without an active exception
Command 'build/scratch/ns3.40-project-default' died with <Signals.SIGABRT: 6>.
Program is:
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/mobility-model.h"
#include "ns3/mobility-helper.h"
#include "ns3/olsr-helper.h"
#include "ns3/internet-module.h"
#include "ns3/yans-wifi-channel.h"
#include "ns3/yans-wifi-helper.h"
#include "ns3/netanim-module.h"
#include "ns3/flow-monitor-module.h"
#include "ns3/applications-module.h"
using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("FANETExample");
int main (int argc, char *argv[])
{
CommandLine cmd;
cmd.Parse (argc, argv);
NodeContainer nodes;
nodes.Create (10);
// Set up Wi-Fi devices and channels
WifiHelper wifi;
wifi.SetStandard (WIFI_STANDARD_80211a);
YansWifiPhyHelper wifiPhy;
YansWifiChannelHelper wifiChannel;
wifiPhy.SetChannel (wifiChannel.Create ());
WifiMacHelper wifiMac;
wifiMac.SetType ("ns3::AdhocWifiMac");
NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, nodes);
// Set mobility model for 3D movement
MobilityHelper mobility;
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
for (uint32_t i = 0; i < 10; ++i)
{
positionAlloc->Add (Vector (i * 100, i * 100, i * 10)); // Adjust as needed for 3D positioning
}
mobility.SetPositionAllocator (positionAlloc);
mobility.SetMobilityModel ("ns3::RandomWaypointMobilityModel",
"Speed", StringValue ("ns3::UniformRandomVariable[Min=0|Max=100]"),
"Pause", StringValue ("ns3::ConstantRandomVariable[Constant=2]"),
"PositionAllocator", PointerValue (positionAlloc));
mobility.Install (nodes);
// Install Internet stack with OLSR routing protocol
OlsrHelper olsr;
InternetStackHelper stack;
stack.SetRoutingHelper (olsr);
stack.Install (nodes);
Ipv4AddressHelper address;
address.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer interfaces = address.Assign (devices);
// Set up applications
uint16_t port = 9;
UdpEchoServerHelper server (port);
ApplicationContainer serverApp = server.Install (nodes.Get (9));
serverApp.Start (Seconds (1.0));
serverApp.Stop (Seconds (10.0));
UdpEchoClientHelper client (interfaces.GetAddress (9), port);
client.SetAttribute ("MaxPackets", UintegerValue (1));
client.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
client.SetAttribute ("PacketSize", UintegerValue (1024));
ApplicationContainer clientApp = client.Install (nodes.Get (0));
clientApp.Start (Seconds (2.0));
clientApp.Stop (Seconds (10.0));
// Enable NetAnim
AnimationInterface anim ("fanet-animation.xml");
anim.EnablePacketMetadata (true);
// Enable FlowMonitor
FlowMonitorHelper flowmon;
Ptr<FlowMonitor> monitor = flowmon.InstallAll ();
Simulator::Stop (Seconds (10.0));
Simulator::Run ();
// Print per flow statistics
monitor->SerializeToXmlFile("fanet-flowmon.xml", true, true);
Simulator::Destroy ();
return 0;
}
Please help me to resolve this problem