Hello everyone,
I am getting below warning message when I run the below code and use netanim command. Please help.
#include "ns3/core-module.h"
#include "ns3/mobility-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/applications-module.h"
#include "ns3/netanim-module.h"
#include "ns3/aodv-module.h"
#include "ns3/wifi-module.h"
using namespace ns3;
int main (int argc, char *argv[])
{
// Create nodes
NodeContainer groundNodes;
groundNodes.Create(6); // 6 mobile ground nodes
NodeContainer uavNode;
uavNode.Create(1); // 1 UAV node (server)
// Install mobility models
MobilityHelper mobility;
// Set initial positions for ground nodes
for (uint32_t i = 0; i < 6; ++i) {
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
positionAlloc->Add(Vector(i * 10.0, 0.0, 0.0)); // Initial positions with a separation of 20 meters
mobility.SetPositionAllocator(positionAlloc);
mobility.SetMobilityModel("ns3::ConstantVelocityMobilityModel");
mobility.Install(groundNodes.Get(i));
}
// Set initial position for UAV
Ptr<ListPositionAllocator> uavPositionAlloc = CreateObject<ListPositionAllocator>();
uavPositionAlloc->Add(Vector(0.0, 100.0, 10.0)); // Initial position for UAV
mobility.SetPositionAllocator(uavPositionAlloc);
mobility.SetMobilityModel("ns3::ConstantVelocityMobilityModel");
mobility.Install(uavNode);
// Install AODV routing
AodvHelper aodv;
Ipv4ListRoutingHelper list;
list.Add(aodv, 0);
InternetStackHelper internet;
internet.SetRoutingHelper(list);
internet.Install(groundNodes);
internet.Install(uavNode);
// Create the wireless channel
YansWifiChannelHelper channel = YansWifiChannelHelper::Default();
// YansWifiPhyHelper phy = YansWifiPhyHelper::Default();
YansWifiPhyHelper phy;
phy.SetChannel(channel.Create());
// Set up the Wi-Fi stack
WifiHelper wifi;
wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager",
"DataMode", StringValue("OfdmRate54Mbps"));
wifi.SetStandard(WIFI_STANDARD_80211b);
// Set up MAC layer
WifiMacHelper mac;
Ssid ssid = Ssid("network-1");
mac.SetType("ns3::StaWifiMac",
"Ssid", SsidValue(ssid),
"ActiveProbing", BooleanValue(true));
NetDeviceContainer staDevices = wifi.Install(phy, mac, groundNodes);
// Set up MAC and PHY for the UAV
mac.SetType("ns3::ApWifiMac", "Ssid", SsidValue(ssid));
NetDeviceContainer apDevice = wifi.Install(phy, mac, uavNode);
// Assign IP addresses
Ipv4AddressHelper ipv4;
ipv4.SetBase ("192.168.1.0", "255.255.255.0");
Ipv4InterfaceContainer groundInterfaces = ipv4.Assign (staDevices);
Ipv4InterfaceContainer uavInterface = ipv4.Assign (apDevice);
// Create a simple UDP application
uint16_t port = 9; // Discard port (RFC 863)
UdpServerHelper server(port);
ApplicationContainer serverApp = server.Install(uavNode.Get(0));
serverApp.Start(Seconds(1.0));
serverApp.Stop(Seconds(10.0));
UdpClientHelper client(uavInterface.GetAddress(0), port);
client.SetAttribute("MaxPackets", UintegerValue(200));
client.SetAttribute("Interval", TimeValue(Seconds(1.0)));
client.SetAttribute("PacketSize", UintegerValue(1024));
ApplicationContainer clientApp = client.Install(groundNodes);
clientApp.Start(Seconds(2.0));
clientApp.Stop(Seconds(10.0));
phy.EnablePcapAll ("C5"); //Packet Capture
// Enable NetAnim animation
AnimationInterface anim("simulation_C5.xml");
anim.SetMaxPktsPerTraceFile(999999999);
// Run the simulation
Simulator::Stop (Seconds (10.0));
Simulator::Run();
Simulator::Destroy();
return 0;
}