#include "ns3/core-module.
h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/wifi-module.h"
#include "ns3/mobility-module.h"
#include "ns3/applications-module.h"
using namespace ns3;
int main (int argc, char *argv[])
{
// Créer un nœud
Ptr<Node> apNode = CreateObject<Node> ();
// Installer la pile Internet sur le nœud
InternetStackHelper internet;
internet.Install (apNode);
// Configurer les paramètres du Wi-Fi pour la bande 2.4 GHz
WifiHelper wifi2_4GHz;
wifi2_4GHz.SetStandard (WIFI_STANDARD_80211n_2_4GHZ);
wifi2_4GHz.SetRemoteStationManager ("ns3::ArfWifiManager");
// Configurer le canal Wi-Fi pour la bande 2.4 GHz avec les canaux 1, 6, 11
YansWifiChannelHelper channel2_4GHz;
channel2_4GHz.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
channel2_4GHz.AddPropagationLoss ("ns3::FixedRssLossModel", "Rss", DoubleValue (-
30.0));
channel2_4GHz.SetChannelNumber (1);
wifi2_4GHz.SetChannel (channel2_4GHz.Create (), 0);
channel2_4GHz.SetChannelNumber (6);
wifi2_4GHz.SetChannel (channel2_4GHz.Create (), 1);
channel2_4GHz.SetChannelNumber (11);
wifi2_4GHz.SetChannel (channel2_4GHz.Create (), 2);
// Configurer le modèle de propagation pour la bande 2.4 GHz
wifi2_4GHz.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
"DataMode", StringValue ("HtMcs0"),
"ControlMode", StringValue ("HtMcs0"));
// Configurer le modèle de MAC
wifi2_4GHz.SetMac ("ns3::ApWifiMac",
"Ssid", SsidValue ("ns-3-ssid"));
// Installer le périphérique Wi-Fi pour la bande 2.4 GHz
NetDeviceContainer devices2_4GHz = wifi2_4GHz.Install (apNode);
// Configurer les paramètres du Wi-Fi pour la bande 5 GHz
WifiHelper wifi5GHz;
wifi5GHz.SetStandard (WIFI_STANDARD_80211n_5GHZ);
wifi5GHz.SetRemoteStationManager ("ns3::ArfWifiManager");
// Configurer le canal Wi-Fi pour la bande 5 GHz avec les canaux 36, 40, 45
YansWifiChannelHelper channel5GHz;
channel5GHz.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
channel5GHz.AddPropagationLoss ("ns3::FixedRssLossModel", "Rss", DoubleValue (-
30.0));
channel5GHz.SetChannelNumber (36);
wifi5GHz.SetChannel (channel5GHz.Create (), 0);
channel5GHz.SetChannelNumber (40);
wifi5GHz.SetChannel (channel5GHz.Create (), 1);
channel5GHz.SetChannelNumber (45);
wifi5GHz.SetChannel (channel5GHz.Create (), 2);
// Configurer le modèle de propagation pour la bande 5 GHz
wifi5GHz.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
"DataMode", StringValue ("HtMcs0"),
"ControlMode", StringValue ("HtMcs0"));
// Configurer le modèle de MAC
wifi5GHz.SetMac ("ns3::ApWifiMac",
"Ssid", SsidValue ("ns-3-ssid"));
// Installer le périphérique Wi-Fi pour la bande 5 GHz
NetDeviceContainer devices5GHz = wifi5GHz.Install (apNode);
// Configurer la position du nœud
apNode->AggregateObject (CreateObject<MobilityModel> ());
// Configurer l'adresse IP
Ipv4AddressHelper ipv4;
ipv4.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer interface2_4GHz = ipv4.Assign (devices2_4GHz);
Ipv4InterfaceContainer interface5GHz = ipv4.Assign (devices5GHz);
// Configurer l'application OnOff pour générer du trafic
OnOffHelper onoff ("ns3::UdpSocketFactory",
Address (InetSocketAddress (interface2_4GHz.GetAddress (1),
9)));
onoff.SetAttribute ("OnTime", StringValue
("ns3::ConstantRandomVariable[Constant=1]"));
onoff.SetAttribute ("OffTime", StringValue
("ns3::ConstantRandomVariable[Constant=0]"));
onoff.SetAttribute ("DataRate", StringValue ("5Mbps"));
onoff.SetAttribute ("PacketSize", UintegerValue (1024));
ApplicationContainer apps = onoff.Install (apNode);
apps.Start (Seconds (1.0));
apps.Stop (Seconds (10.0));
// Configurer la simulation
Simulator::Stop (Seconds (10.0));
// Lancer la simulation
Simulator::Run ();
Simulator::Destroy ();
return 0;
}