I'm using Ubuntu version 22.04, and trying to run a script using ns-3 3.38 that set ups a mesh wireless network. However I get errors after running it.
error: 'Default' is not a member of 'ns3: YansiWifiHelper'
error: 'WIFI_PHY_STANDARD_80211N_5GHZ' was not declared in this scope
I will provide the script without the header files. I have two errors, and I will mark the lines.
using namespace ns3;
NS_LOG_COMPONENT_DEFINE("SimpleMeshNetwork");
int main(int argc, char *argv[]) {
LogComponentEnable("SimpleMeshNetwork", LOG_LEVEL_INFO);
NodeContainer nodes;
nodes.Create(4);
MobilityHelper mobility;
mobility.SetPositionAllocator("ns3::GridPositionAllocator",
"MinX", DoubleValue(0.0),
"MinY", DoubleValue(0.0),
"DeltaX", DoubleValue(100.0),
"DeltaY", DoubleValue(100.0),
"GridWidth", UintegerValue(2),
"LayoutType", StringValue("RowFirst"));
mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
mobility.Install(nodes);
WifiHelper wifi;
wifi.SetStandard(WIFI_PHY_STANDARD_80211s);
wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager",
"DataMode", StringValue("OfdmRate6Mbps"));
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default();
wifiPhy.Set("ChannelNumber", UintegerValue(7));
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default();
wifiPhy.SetChannel(wifiChannel.Create());
MeshHelper mesh = MeshHelper::Default();
mesh.SetStackInstaller("ns3::Dot11sStack");
mesh.SetSpreadInterfaceChannels(MeshHelper::SPREAD_CHANNELS);
mesh.SetMacType("RandomStart", TimeValue(Seconds(0.1)));
NetDeviceContainer meshDevices = mesh.Install(wifiPhy, nodes);
InternetStackHelper internet;
internet.Install(nodes);
Ipv4AddressHelper address;
address.SetBase("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer interfaces = address.Assign(meshDevices);
Simulator::Stop(Seconds(10.0));
for (uint32_t i = 0; i < nodes.GetN(); ++i) {
Ptr<Node> node = nodes.Get(i);
Ptr<Ipv4> ipv4 = node->GetObject<Ipv4>();
Ipv4InterfaceAddress iaddr = ipv4->GetAddress(1, 0);
Ipv4Address addr = iaddr.GetLocal();
NS_LOG_INFO("Node " << i << " has IP address " << addr);
}
Simulator::Run();
Simulator::Destroy();
return 0;
}
How to solve such errors?