+static void zoneCreation_cb(simgrid::s4u::NetZone const& zone)
+{
+ simgrid::kernel::routing::WifiZone* wifizone = dynamic_cast<simgrid::kernel::routing::WifiZone*>(zone.get_impl());
+ if (wifizone == nullptr)
+ return;
+
+#if NS3_MINOR_VERSION < 32
+ wifi.SetStandard(ns3::WIFI_PHY_STANDARD_80211n_5GHZ);
+#else
+ wifi.SetStandard(ns3::WIFI_STANDARD_80211n_5GHZ);
+#endif
+
+ std::string ssid = wifizone->get_name();
+ const char* mcs = wifizone->get_property("mcs");
+ const char* nss = wifizone->get_property("nss");
+ int mcs_value = mcs ? atoi(mcs) : 3;
+ int nss_value = nss ? atoi(nss) : 1;
+#if NS3_MINOR_VERSION < 30
+ xbt_assert(nss_value == 1 + (mcs_value / 8),
+ "On NS3 < 3.30, NSS value has to satisfy NSS == 1+(MCS/8) constraint. Bailing out");
+#endif
+ wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager", "ControlMode", ns3::StringValue("HtMcs0"), "DataMode",
+ ns3::StringValue("HtMcs" + std::to_string(mcs_value)));
+ wifiPhy.SetChannel(wifiChannel.Create());
+ wifiPhy.Set("Antennas", ns3::UintegerValue(nss_value));
+ wifiPhy.Set("MaxSupportedTxSpatialStreams", ns3::UintegerValue(nss_value));
+ wifiPhy.Set("MaxSupportedRxSpatialStreams", ns3::UintegerValue(nss_value));
+ wifiMac.SetType("ns3::ApWifiMac", "Ssid", ns3::SsidValue(ssid));
+
+ mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
+ ns3::Ptr<ns3::ListPositionAllocator> positionAllocS = ns3::CreateObject<ns3::ListPositionAllocator>();
+ positionAllocS->Add(ns3::Vector(0, 0, 255 * 100 * number_of_networks + 100 * number_of_links));
+
+ ns3::NetDeviceContainer netDevices;
+ NetPointNs3* access_point_netpoint_ns3 = wifizone->get_access_point()->extension<NetPointNs3>();
+
+ ns3::Ptr<ns3::Node> access_point_ns3_node = access_point_netpoint_ns3->ns3_node_;
+ ns3::NodeContainer nodes = {access_point_ns3_node};
+ std::vector<NetPointNs3*> hosts_netpoints = {access_point_netpoint_ns3};
+ netDevices.Add(wifi.Install(wifiPhy, wifiMac, access_point_ns3_node));
+
+ wifiMac.SetType("ns3::StaWifiMac", "Ssid", ns3::SsidValue(ssid), "ActiveProbing", ns3::BooleanValue(false));
+
+ NetPointNs3* station_netpoint_ns3 = nullptr;
+ ns3::Ptr<ns3::Node> station_ns3_node = nullptr;
+ double distance;
+ double angle = 0;
+ int nb_stations = wifizone->get_all_hosts().size() - 1;
+ double step = 2 * M_PI / nb_stations;
+ for (auto station_host : wifizone->get_all_hosts()) {
+ station_netpoint_ns3 = station_host->get_netpoint()->extension<NetPointNs3>();
+ if (station_netpoint_ns3 == access_point_netpoint_ns3)
+ continue;
+ hosts_netpoints.push_back(station_netpoint_ns3);
+ distance = station_host->get_property("wifi_distance") ? atof(station_host->get_property("wifi_distance")) : 10.0;
+ positionAllocS->Add(ns3::Vector(distance * std::cos(angle), distance * std::sin(angle),
+ 255 * 100 * number_of_networks + 100 * number_of_links));
+ angle += step;
+ station_ns3_node = station_netpoint_ns3->ns3_node_;
+ nodes.Add(station_ns3_node);
+ netDevices.Add(wifi.Install(wifiPhy, wifiMac, station_ns3_node));
+ }
+
+ const char* start_time = wifizone->get_property("start_time");
+ int start_time_value = start_time ? atoi(start_time) : 0;
+ for (uint32_t i = 0; i < netDevices.GetN(); i++) {
+ ns3::Ptr<ns3::WifiNetDevice> device = ns3::StaticCast<ns3::WifiNetDevice>(netDevices.Get(i));
+ device->GetPhy()->SetOffMode();
+ ns3::Simulator::Schedule(ns3::Seconds(start_time_value), &resumeWifiDevice, device);
+ }
+
+ ns3::Config::Set("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/ChannelWidth", ns3::UintegerValue(40));
+
+ mobility.SetPositionAllocator(positionAllocS);
+ mobility.Install(nodes);
+
+ ns3::Ipv4AddressHelper address;
+ std::string addr = simgrid::xbt::string_printf("%d.%d.0.0", number_of_networks, number_of_links);
+ address.SetBase(addr.c_str(), "255.255.0.0");
+ XBT_DEBUG("\tInterface stack '%s'", addr.c_str());
+ ns3::Ipv4InterfaceContainer addresses = address.Assign(netDevices);
+ for (unsigned int i = 0; i < hosts_netpoints.size(); i++) {
+ hosts_netpoints[i]->ipv4_address_ = transformIpv4Address(addresses.GetAddress(i));
+ }
+
+ if (number_of_links == 255) {
+ xbt_assert(number_of_networks < 255, "Number of links and networks exceed 255*255");
+ number_of_links = 1;
+ number_of_networks++;
+ } else {
+ number_of_links++;
+ }
+}
+