diff --git a/examples/energy/energy-model-example.cc b/examples/energy/energy-model-example.cc index 0fc180b15..07fd0bbd1 100644 --- a/examples/energy/energy-model-example.cc +++ b/examples/energy/energy-model-example.cc @@ -189,8 +189,8 @@ main (int argc, char *argv[]) wifiPhy.SetChannel (wifiChannelPtr); /** MAC layer **/ - // Add a non-QoS upper MAC, and disable rate control - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + // Add a MAC and disable rate control + WifiMacHelper wifiMac; wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue (phyMode), "ControlMode", StringValue (phyMode)); diff --git a/examples/energy/energy-model-with-harvesting-example.cc b/examples/energy/energy-model-with-harvesting-example.cc index 03c0ba697..c0b35223d 100644 --- a/examples/energy/energy-model-with-harvesting-example.cc +++ b/examples/energy/energy-model-with-harvesting-example.cc @@ -241,8 +241,8 @@ main (int argc, char *argv[]) wifiPhy.SetChannel (wifiChannelPtr); /** MAC layer **/ - // Add a non-QoS upper MAC, and disable rate control - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + // Add a MAC and disable rate control + WifiMacHelper wifiMac; wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue (phyMode), "ControlMode", StringValue (phyMode)); diff --git a/examples/routing/manet-routing-compare.cc b/examples/routing/manet-routing-compare.cc index 3a2f68e8f..500c59780 100644 --- a/examples/routing/manet-routing-compare.cc +++ b/examples/routing/manet-routing-compare.cc @@ -257,8 +257,8 @@ RoutingExperiment::Run (int nSinks, double txp, std::string CSVfileName) wifiChannel.AddPropagationLoss ("ns3::FriisPropagationLossModel"); wifiPhy.SetChannel (wifiChannel.Create ()); - // Add a non-QoS upper mac, and disable rate control - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + // Add a mac and disable rate control + WifiMacHelper wifiMac; wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode",StringValue (phyMode), "ControlMode",StringValue (phyMode)); diff --git a/examples/stats/wifi-example-sim.cc b/examples/stats/wifi-example-sim.cc index 3b724b404..9dd8c62e0 100644 --- a/examples/stats/wifi-example-sim.cc +++ b/examples/stats/wifi-example-sim.cc @@ -122,8 +122,8 @@ int main (int argc, char *argv[]) { nodes.Create (2); NS_LOG_INFO ("Installing WiFi and Internet stack."); - WifiHelper wifi = WifiHelper::Default (); - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + WifiHelper wifi; + WifiMacHelper wifiMac; wifiMac.SetType ("ns3::AdhocWifiMac"); YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); diff --git a/examples/tutorial/third.cc b/examples/tutorial/third.cc index abb2bd376..a5f928a0b 100644 --- a/examples/tutorial/third.cc +++ b/examples/tutorial/third.cc @@ -102,11 +102,10 @@ main (int argc, char *argv[]) YansWifiPhyHelper phy = YansWifiPhyHelper::Default (); phy.SetChannel (channel.Create ()); - WifiHelper wifi = WifiHelper::Default (); + WifiHelper wifi; wifi.SetRemoteStationManager ("ns3::AarfWifiManager"); - NqosWifiMacHelper mac = NqosWifiMacHelper::Default (); - + WifiMacHelper mac; Ssid ssid = Ssid ("ns-3-ssid"); mac.SetType ("ns3::StaWifiMac", "Ssid", SsidValue (ssid), diff --git a/examples/wireless/ht-wifi-network.cc b/examples/wireless/ht-wifi-network.cc index e25781eba..b2bbb7a0b 100644 --- a/examples/wireless/ht-wifi-network.cc +++ b/examples/wireless/ht-wifi-network.cc @@ -92,7 +92,8 @@ int main (int argc, char *argv[]) // Set guard interval phy.Set ("ShortGuardEnabled", BooleanValue (k)); - WifiHelper wifi = WifiHelper::Default (); + WifiMacHelper mac; + WifiHelper wifi; if (frequency == 5.0) { wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ); @@ -108,10 +109,10 @@ int main (int argc, char *argv[]) return 0; } - HtWifiMacHelper mac = HtWifiMacHelper::Default (); - StringValue DataRate = HtWifiMacHelper::DataRateForMcs (i); - wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager","DataMode", DataRate, - "ControlMode", DataRate); + std::ostringstream oss; + oss << "HtMcs" << i; + wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager","DataMode", StringValue (oss.str ()), + "ControlMode", StringValue (oss.str ())); Ssid ssid = Ssid ("ns3-80211n"); diff --git a/examples/wireless/mixed-wireless.cc b/examples/wireless/mixed-wireless.cc index 02a321653..81240880e 100644 --- a/examples/wireless/mixed-wireless.cc +++ b/examples/wireless/mixed-wireless.cc @@ -149,7 +149,7 @@ main (int argc, char *argv[]) // our container // WifiHelper wifi; - NqosWifiMacHelper mac = NqosWifiMacHelper::Default (); + WifiMacHelper mac; mac.SetType ("ns3::AdhocWifiMac"); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("OfdmRate54Mbps")); @@ -283,8 +283,8 @@ main (int argc, char *argv[]) // // Create an infrastructure network // - WifiHelper wifiInfra = WifiHelper::Default (); - NqosWifiMacHelper macInfra = NqosWifiMacHelper::Default (); + WifiHelper wifiInfra; + WifiMacHelper macInfra; wifiPhy.SetChannel (wifiChannel.Create ()); // Create unique ssids for these networks std::string ssidString ("wifi-infra"); diff --git a/examples/wireless/multirate.cc b/examples/wireless/multirate.cc index 97e44b368..3d13a56fa 100644 --- a/examples/wireless/multirate.cc +++ b/examples/wireless/multirate.cc @@ -75,7 +75,7 @@ public: Experiment (); Experiment (std::string name); Gnuplot2dDataset Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, - const NqosWifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel, const MobilityHelper &mobility); + const WifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel, const MobilityHelper &mobility); bool CommandSetup (int argc, char **argv); bool IsRouting () { return (enableRouting == 1) ? 1 : 0; } @@ -371,7 +371,7 @@ Experiment::ApplicationSetup (Ptr client, Ptr server, double start, Gnuplot2dDataset Experiment::Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, - const NqosWifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel, const MobilityHelper &mobility) + const WifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel, const MobilityHelper &mobility) { @@ -382,7 +382,7 @@ Experiment::Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, YansWifiPhyHelper phy = wifiPhy; phy.SetChannel (wifiChannel.Create ()); - NqosWifiMacHelper mac = wifiMac; + WifiMacHelper mac = wifiMac; NetDeviceContainer devices = wifi.Install (phy, mac, c); @@ -576,8 +576,8 @@ int main (int argc, char *argv[]) Gnuplot gnuplot; Gnuplot2dDataset dataset; - WifiHelper wifi = WifiHelper::Default (); - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + WifiHelper wifi; + WifiMacHelper wifiMac; YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); Ssid ssid = Ssid ("Testbed"); diff --git a/examples/wireless/power-adaptation-distance.cc b/examples/wireless/power-adaptation-distance.cc index 9c958e8cd..2a2fb33cf 100644 --- a/examples/wireless/power-adaptation-distance.cc +++ b/examples/wireless/power-adaptation-distance.cc @@ -343,9 +343,9 @@ int main (int argc, char *argv[]) NodeContainer wifiStaNodes; wifiStaNodes.Create (1); - WifiHelper wifi = WifiHelper::Default (); + WifiHelper wifi; wifi.SetStandard (WIFI_PHY_STANDARD_80211a); - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + WifiMacHelper wifiMac; YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); diff --git a/examples/wireless/power-adaptation-interference.cc b/examples/wireless/power-adaptation-interference.cc index 6e701f540..30fbf91d0 100644 --- a/examples/wireless/power-adaptation-interference.cc +++ b/examples/wireless/power-adaptation-interference.cc @@ -381,9 +381,9 @@ int main (int argc, char *argv[]) NodeContainer wifiStaNodes; wifiStaNodes.Create (2); - WifiHelper wifi = WifiHelper::Default (); + WifiHelper wifi; wifi.SetStandard (WIFI_PHY_STANDARD_80211a); - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + WifiMacHelper wifiMac; YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); diff --git a/examples/wireless/rate-adaptation-distance.cc b/examples/wireless/rate-adaptation-distance.cc index 3b15eb68a..ec7a38ce4 100644 --- a/examples/wireless/rate-adaptation-distance.cc +++ b/examples/wireless/rate-adaptation-distance.cc @@ -175,9 +175,9 @@ int main (int argc, char *argv[]) NodeContainer wifiStaNodes; wifiStaNodes.Create (1); - WifiHelper wifi = WifiHelper::Default (); + WifiHelper wifi; wifi.SetStandard (WIFI_PHY_STANDARD_80211a); - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + WifiMacHelper wifiMac; YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); diff --git a/examples/wireless/simple-ht-hidden-stations.cc b/examples/wireless/simple-ht-hidden-stations.cc index 6fd97a318..7018648d2 100644 --- a/examples/wireless/simple-ht-hidden-stations.cc +++ b/examples/wireless/simple-ht-hidden-stations.cc @@ -52,6 +52,7 @@ int main (int argc, char *argv[]) uint32_t payloadSize = 1472; //bytes uint64_t simulationTime = 10; //seconds uint32_t nMpdus = 1; + uint32_t maxAmpduSize = 0; bool enableRts = 0; CommandLine cmd; @@ -72,6 +73,9 @@ int main (int argc, char *argv[]) Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("990000")); + //Set the maximum size for A-MPDU with regards to the payload size + maxAmpduSize = nMpdus * (payloadSize + 200); + // Set the maximum wireless range to 5 meters in order to reproduce a hidden nodes scenario, i.e. the distance between hidden stations is larger than 5 meters Config::SetDefault ("ns3::RangePropagationLossModel::MaxRange", DoubleValue (5)); @@ -87,24 +91,16 @@ int main (int argc, char *argv[]) phy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO); phy.SetChannel (channel.Create ()); - WifiHelper wifi = WifiHelper::Default (); + WifiHelper wifi; wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("HtMcs7"), "ControlMode", StringValue ("HtMcs0")); - HtWifiMacHelper mac = HtWifiMacHelper::Default (); + WifiMacHelper mac; Ssid ssid = Ssid ("simple-mpdu-aggregation"); mac.SetType ("ns3::StaWifiMac", "Ssid", SsidValue (ssid), - "ActiveProbing", BooleanValue (false)); - - if (nMpdus > 1) - { - mac.SetBlockAckThresholdForAc (AC_BE, 2); //enable Block ACK when A-MPDU is enabled - - } - mac.SetMpduAggregatorForAc (AC_BE,"ns3::MpduStandardAggregator", - "MaxAmpduSize", UintegerValue (nMpdus * (payloadSize + 100))); //enable MPDU aggregation for AC_BE with a maximum aggregated size of nMpdus*(payloadSize+100) bytes, - //i.e. nMpdus aggregated packets in an A-MPDU + "ActiveProbing", BooleanValue (false), + "BE_MaxAmpduSize", UintegerValue (maxAmpduSize)); NetDeviceContainer staDevices; staDevices = wifi.Install (phy, mac, wifiStaNodes); @@ -112,16 +108,8 @@ int main (int argc, char *argv[]) mac.SetType ("ns3::ApWifiMac", "Ssid", SsidValue (ssid), "BeaconInterval", TimeValue (MicroSeconds (102400)), - "BeaconGeneration", BooleanValue (true)); - - if (nMpdus > 1) - { - mac.SetBlockAckThresholdForAc (AC_BE, 2); //enable Block ACK when A-MPDU is enabled - - } - mac.SetMpduAggregatorForAc (AC_BE,"ns3::MpduStandardAggregator", - "MaxAmpduSize", UintegerValue (nMpdus * (payloadSize + 100))); //enable MPDU aggregation for AC_BE with a maximum aggregated size of nMpdus*(payloadSize+100) bytes, - //i.e. nMpdus aggregated packets in an A-MPDU + "BeaconGeneration", BooleanValue (true), + "BE_MaxAmpduSize", UintegerValue (maxAmpduSize)); NetDeviceContainer apDevice; apDevice = wifi.Install (phy, mac, wifiApNode); diff --git a/examples/wireless/simple-mpdu-aggregation.cc b/examples/wireless/simple-mpdu-aggregation.cc deleted file mode 100644 index e915c9681..000000000 --- a/examples/wireless/simple-mpdu-aggregation.cc +++ /dev/null @@ -1,176 +0,0 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2015 Sébastien Deronne - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Sébastien Deronne - */ - -#include "ns3/core-module.h" -#include "ns3/network-module.h" -#include "ns3/applications-module.h" -#include "ns3/wifi-module.h" -#include "ns3/mobility-module.h" -#include "ns3/ipv4-global-routing-helper.h" -#include "ns3/internet-module.h" - -// This is a simple example in order to show how 802.11n MPDU aggregation feature works. -// The throughput is obtained for a given number of aggregated MPDUs. -// -// The number of aggregated MPDUs can be chosen by the user through the nMpdus attibute. -// A value of 1 means that no MPDU aggregation is performed. -// -// Example: ./waf --run "simple-mpdu-aggregation --nMpdus=64" -// -// Network topology: -// -// Wifi 192.168.1.0 -// -// AP -// * * -// | | -// n1 n2 -// -// Packets in this simulation aren't marked with a QosTag so they are considered -// belonging to BestEffort Access Class (AC_BE). - -using namespace ns3; - -NS_LOG_COMPONENT_DEFINE ("SimpleMpduAggregation"); - -int main (int argc, char *argv[]) -{ - uint32_t payloadSize = 1472; //bytes - uint64_t simulationTime = 10; //seconds - uint32_t nMpdus = 1; - bool enableRts = 0; - - CommandLine cmd; - cmd.AddValue ("nMpdus", "Number of aggregated MPDUs", nMpdus); //number of aggregated MPDUs specified by the user - cmd.AddValue ("payloadSize", "Payload size in bytes", payloadSize); - cmd.AddValue ("enableRts", "Enable RTS/CTS", enableRts); - cmd.AddValue ("simulationTime", "Simulation time in seconds", simulationTime); - cmd.Parse (argc, argv); - - if (!enableRts) - { - Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("999999")); - } - else - { - Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("0")); - } - - Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("990000")); - - NodeContainer wifiStaNode; - wifiStaNode.Create (1); - NodeContainer wifiApNode; - wifiApNode.Create (1); - - YansWifiChannelHelper channel = YansWifiChannelHelper::Default (); - YansWifiPhyHelper phy = YansWifiPhyHelper::Default (); - phy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO); - phy.SetChannel (channel.Create ()); - - WifiHelper wifi = WifiHelper::Default (); - wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ); - wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("HtMcs7"), "ControlMode", StringValue ("HtMcs0")); - HtWifiMacHelper mac = HtWifiMacHelper::Default (); - - Ssid ssid = Ssid ("simple-mpdu-aggregation"); - mac.SetType ("ns3::StaWifiMac", - "Ssid", SsidValue (ssid), - "ActiveProbing", BooleanValue (false)); - - if (nMpdus > 1) - { - mac.SetBlockAckThresholdForAc (AC_BE, 2); //enable Block ACK when A-MPDU is enabled (i.e. nMpdus > 1) - - } - mac.SetMpduAggregatorForAc (AC_BE,"ns3::MpduStandardAggregator", - "MaxAmpduSize", UintegerValue (nMpdus * (payloadSize + 100))); //enable MPDU aggregation for AC_BE with a maximum aggregated size of nMpdus*(payloadSize+100) bytes, i.e. nMpdus aggregated packets in an A-MPDU - - NetDeviceContainer staDevice; - staDevice = wifi.Install (phy, mac, wifiStaNode); - - mac.SetType ("ns3::ApWifiMac", - "Ssid", SsidValue (ssid), - "BeaconInterval", TimeValue (MicroSeconds (102400)), - "BeaconGeneration", BooleanValue (true)); - - if (nMpdus > 1) - { - mac.SetBlockAckThresholdForAc (AC_BE, 2); //enable Block ACK when A-MPDU is enabled (i.e. nMpdus > 1) - - } - mac.SetMpduAggregatorForAc (AC_BE,"ns3::MpduStandardAggregator", - "MaxAmpduSize", UintegerValue (nMpdus * (payloadSize + 100))); //enable MPDU aggregation for AC_BE with a maximum aggregated size of nMpdus*(payloadSize+100) bytes, i.e. nMpdus aggregated packets in an A-MPDU - - NetDeviceContainer apDevice; - apDevice = wifi.Install (phy, mac, wifiApNode); - - /* Setting mobility model */ - MobilityHelper mobility; - Ptr positionAlloc = CreateObject (); - - positionAlloc->Add (Vector (0.0, 0.0, 0.0)); - positionAlloc->Add (Vector (1.0, 0.0, 0.0)); - mobility.SetPositionAllocator (positionAlloc); - - mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); - - mobility.Install (wifiApNode); - mobility.Install (wifiStaNode); - - /* Internet stack*/ - InternetStackHelper stack; - stack.Install (wifiApNode); - stack.Install (wifiStaNode); - - Ipv4AddressHelper address; - - address.SetBase ("192.168.1.0", "255.255.255.0"); - Ipv4InterfaceContainer StaInterface; - StaInterface = address.Assign (staDevice); - Ipv4InterfaceContainer ApInterface; - ApInterface = address.Assign (apDevice); - - /* Setting applications */ - UdpServerHelper myServer (9); - ApplicationContainer serverApp = myServer.Install (wifiStaNode.Get (0)); - serverApp.Start (Seconds (0.0)); - serverApp.Stop (Seconds (simulationTime + 1)); - - UdpClientHelper myClient (StaInterface.GetAddress (0), 9); - myClient.SetAttribute ("MaxPackets", UintegerValue (4294967295u)); - myClient.SetAttribute ("Interval", TimeValue (Time ("0.00002"))); //packets/s - myClient.SetAttribute ("PacketSize", UintegerValue (payloadSize)); - - ApplicationContainer clientApp = myClient.Install (wifiApNode.Get (0)); - clientApp.Start (Seconds (1.0)); - clientApp.Stop (Seconds (simulationTime + 1)); - - Simulator::Stop (Seconds (simulationTime + 1)); - - Simulator::Run (); - Simulator::Destroy (); - - uint32_t totalPacketsThrough = DynamicCast (serverApp.Get (0))->GetReceived (); - double throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0); - std::cout << "Throughput: " << throughput << " Mbit/s" << '\n'; - - return 0; -} diff --git a/examples/wireless/simple-msdu-aggregation.cc b/examples/wireless/simple-msdu-aggregation.cc deleted file mode 100644 index 3f65be655..000000000 --- a/examples/wireless/simple-msdu-aggregation.cc +++ /dev/null @@ -1,164 +0,0 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2009 MIRKO BANCHI - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Authors: Mirko Banchi - * Sébastien Deronne - */ -#include "ns3/core-module.h" -#include "ns3/network-module.h" -#include "ns3/applications-module.h" -#include "ns3/wifi-module.h" -#include "ns3/mobility-module.h" -#include "ns3/ipv4-global-routing-helper.h" -#include "ns3/internet-module.h" - -// This is a simple example in order to show how 802.11n MSDU aggregation feature works. -// The throughput is obtained for a given number of aggregated MSDUs. -// -// The number of aggregated MSDUs can be chosen by the user through the nMsdus attibute. -// A value of 1 means that no MSDU aggregation is performed. -// -// Example: ./waf --run "simple-msdu-aggregation --nMsdus=5" -// -// Network topology: -// -// Wifi 192.168.1.0 -// -// AP -// * * -// | | -// n1 n2 -// -// Packets in this simulation aren't marked with a QosTag so they are considered -// belonging to BestEffort Access Class (AC_BE). - -using namespace ns3; - -NS_LOG_COMPONENT_DEFINE ("SimpleMsduAggregation"); - -int main (int argc, char *argv[]) -{ - uint32_t payloadSize = 1472; //bytes - uint64_t simulationTime = 10; //seconds - uint32_t nMsdus = 1; - bool enableRts = 0; - - CommandLine cmd; - cmd.AddValue ("nMsdus", "Number of aggregated MSDUs", nMsdus); //number of aggregated MSDUs specified by the user - cmd.AddValue ("payloadSize", "Payload size in bytes", payloadSize); - cmd.AddValue ("enableRts", "Enable RTS/CTS", enableRts); - cmd.AddValue ("simulationTime", "Simulation time in seconds", simulationTime); - cmd.Parse (argc, argv); - - if (!enableRts) - { - Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("999999")); - } - else - { - Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("0")); - } - - Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("990000")); - - NodeContainer wifiStaNode; - wifiStaNode.Create (1); - NodeContainer wifiApNode; - wifiApNode.Create (1); - - YansWifiChannelHelper channel = YansWifiChannelHelper::Default (); - YansWifiPhyHelper phy = YansWifiPhyHelper::Default (); - phy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO); - phy.SetChannel (channel.Create ()); - - WifiHelper wifi = WifiHelper::Default (); - wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ); - wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("HtMcs7"), "ControlMode", StringValue ("HtMcs0")); - HtWifiMacHelper mac = HtWifiMacHelper::Default (); - - Ssid ssid = Ssid ("simple-msdu-aggregation"); - mac.SetType ("ns3::StaWifiMac", - "Ssid", SsidValue (ssid), - "ActiveProbing", BooleanValue (false)); - - mac.SetMsduAggregatorForAc (AC_BE, "ns3::MsduStandardAggregator", - "MaxAmsduSize", UintegerValue (nMsdus * (payloadSize + 100))); //enable MSDU aggregation for AC_BE with a maximum aggregated size of nMsdus*(payloadSize+100) bytes, i.e. nMsdus aggregated packets in an A-MSDU - - NetDeviceContainer staDevice; - staDevice = wifi.Install (phy, mac, wifiStaNode); - - mac.SetType ("ns3::ApWifiMac", - "Ssid", SsidValue (ssid)); - - mac.SetMsduAggregatorForAc (AC_BE, "ns3::MsduStandardAggregator", - "MaxAmsduSize", UintegerValue (nMsdus * (payloadSize + 100))); //enable MSDU aggregation for AC_BE with a maximum aggregated size of nMsdus*(payloadSize+100) bytes, i.e. nMsdus aggregated packets in an A-MSDU - - NetDeviceContainer apDevice; - apDevice = wifi.Install (phy, mac, wifiApNode); - - /* Setting mobility model */ - MobilityHelper mobility; - Ptr positionAlloc = CreateObject (); - - positionAlloc->Add (Vector (0.0, 0.0, 0.0)); - positionAlloc->Add (Vector (1.0, 0.0, 0.0)); - mobility.SetPositionAllocator (positionAlloc); - - mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); - - mobility.Install (wifiApNode); - mobility.Install (wifiStaNode); - - /* Internet stack*/ - InternetStackHelper stack; - stack.Install (wifiApNode); - stack.Install (wifiStaNode); - - Ipv4AddressHelper address; - - address.SetBase ("192.168.1.0", "255.255.255.0"); - Ipv4InterfaceContainer StaInterface; - StaInterface = address.Assign (staDevice); - Ipv4InterfaceContainer ApInterface; - ApInterface = address.Assign (apDevice); - - /* Setting applications */ - UdpServerHelper myServer (9); - ApplicationContainer serverApp = myServer.Install (wifiStaNode.Get (0)); - serverApp.Start (Seconds (0.0)); - serverApp.Stop (Seconds (simulationTime + 1)); - - UdpClientHelper myClient (StaInterface.GetAddress (0), 9); - myClient.SetAttribute ("MaxPackets", UintegerValue (4294967295u)); - myClient.SetAttribute ("Interval", TimeValue (Time ("0.00002"))); //packets/s - myClient.SetAttribute ("PacketSize", UintegerValue (payloadSize)); - - ApplicationContainer clientApp = myClient.Install (wifiApNode.Get (0)); - clientApp.Start (Seconds (1.0)); - clientApp.Stop (Seconds (simulationTime + 1)); - - Simulator::Stop (Seconds (simulationTime + 1)); - - Simulator::Run (); - Simulator::Destroy (); - - uint32_t totalPacketsThrough = DynamicCast (serverApp.Get (0))->GetReceived (); - double throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0); - std::cout << "Throughput: " << throughput << " Mbit/s" << '\n'; - - return 0; -} diff --git a/examples/wireless/simple-two-level-aggregation.cc b/examples/wireless/simple-two-level-aggregation.cc deleted file mode 100644 index 5f7c90eb8..000000000 --- a/examples/wireless/simple-two-level-aggregation.cc +++ /dev/null @@ -1,214 +0,0 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2015 Sébastien Deronne - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Sébastien Deronne - */ - -#include "ns3/core-module.h" -#include "ns3/network-module.h" -#include "ns3/applications-module.h" -#include "ns3/wifi-module.h" -#include "ns3/mobility-module.h" -#include "ns3/ipv4-global-routing-helper.h" -#include "ns3/internet-module.h" - -// This is a simple example in order to show how 802.11n two-level aggregation feature works. -// Two-level aggregation is the simultaneous use of MSDU and MPDU aggregation schemes (known as one-level aggregation techniques). -// -// The throughput is obtained for a given number of aggregated MSDUs and MPDUs. -// The number of aggregated MSDUs and MPDUs can be chosen by the user through the nMsdus and nMpdus attibutes, respectively. -// -// Example: ./waf --run "simple-two-level-aggregation --nMsdus=3 --nMpdus=8" -// -// Network topology: -// -// Wifi 192.168.1.0 -// -// AP -// * * -// | | -// n1 n2 -// -// Packets in this simulation aren't marked with a QosTag so they are considered -// belonging to BestEffort Access Class (AC_BE). -// -// Throughput gets higher as either nMsdus or nMpdus is increased (one-level aggregation), -// or when both nMsdus and nMpdus are increases (two-level aggregation). -// MSDU aggregation offers a better header reduction compare to MPDU aggregation, -// while MPDU aggregation is more robust against transmission errors than MSDU aggregation. -// The good setting of nMsdu and nMpdus will depends on various factors (payload size, channel conditions, ...). -// Since this example considers an ideal channel, the highest throughput is obtained with the largest values for nMsdus and nMpdus parameters. -// Users should nevertheless take care that the standard rules limit the maximum MSDU size to 7935 bytes and the MPDU size to 65535 bytes. -// Consequently, more packets should be aggregated if their payload is small with standard-compliant parameters. -// Users should also note that the maximum duration of the frame is limited by the standard. -// As a result, higher values for nMsdus and nMpdus may not always provide throughput improvements. - -using namespace ns3; - -NS_LOG_COMPONENT_DEFINE ("SimpleTwoLevelAggregation"); - -int main (int argc, char *argv[]) -{ - uint32_t payloadSize = 1472; //bytes - uint64_t simulationTime = 10; //seconds - uint32_t nMsdus = 1; - uint32_t nMpdus = 1; - bool enableRts = 0; - - CommandLine cmd; - cmd.AddValue ("nMsdus", "Number of aggregated MSDUs", nMsdus); //number of aggregated MSDUs specified by the user - cmd.AddValue ("nMpdus", "Number of aggregated MPDUs", nMpdus); //number of aggregated MPDUs specified by the user - cmd.AddValue ("payloadSize", "Payload size in bytes", payloadSize); - cmd.AddValue ("enableRts", "Enable RTS/CTS", enableRts); - cmd.AddValue ("simulationTime", "Simulation time in seconds", simulationTime); - cmd.Parse (argc, argv); - - if (!enableRts) - { - Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("999999")); - } - else - { - Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("0")); - } - - Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("990000")); - - NodeContainer wifiStaNode; - wifiStaNode.Create (1); - NodeContainer wifiApNode; - wifiApNode.Create (1); - - YansWifiChannelHelper channel = YansWifiChannelHelper::Default (); - YansWifiPhyHelper phy = YansWifiPhyHelper::Default (); - phy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO); - phy.SetChannel (channel.Create ()); - - WifiHelper wifi = WifiHelper::Default (); - wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ); - //We consider a constant bitrate since HT rate adaptation algorithms are not supported yet in the simulator - wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", - "DataMode", StringValue ("HtMcs7"), - "ControlMode", StringValue ("HtMcs0")); - HtWifiMacHelper mac = HtWifiMacHelper::Default (); - - Ssid ssid = Ssid ("simple-two-level-aggregation"); - mac.SetType ("ns3::StaWifiMac", - "Ssid", SsidValue (ssid), - "ActiveProbing", BooleanValue (false)); - - - //Enable aggregation at the station side - if (nMpdus > 1) - { - mac.SetBlockAckThresholdForAc (AC_BE, 2); //enable BlockAck when A-MPDU is used - } - if (nMsdus > 0) - { - mac.SetMpduAggregatorForAc (AC_BE,"ns3::MpduStandardAggregator", - "MaxAmpduSize", UintegerValue (nMpdus * (nMsdus * (payloadSize + 100)))); //Set the maximum size for A-MPDU with regards to the payload size and the number of MSDUs expected in each MPDU. - } - else //MPDU aggregation only (one-level aggregation) - { - mac.SetMpduAggregatorForAc (AC_BE,"ns3::MpduStandardAggregator", - "MaxAmpduSize", UintegerValue (nMpdus * (payloadSize + 200))); //Set the maximum size for A-MPDU with regards to the payload size - } - mac.SetMsduAggregatorForAc (AC_BE,"ns3::MsduStandardAggregator", - "MaxAmsduSize", UintegerValue (nMsdus * (payloadSize + 100))); //Set the maximum size for A-MSDU with regards to the payload size - - - NetDeviceContainer staDevice; - staDevice = wifi.Install (phy, mac, wifiStaNode); - - mac.SetType ("ns3::ApWifiMac", - "Ssid", SsidValue (ssid), - "BeaconInterval", TimeValue (MicroSeconds (102400)), - "BeaconGeneration", BooleanValue (true)); - - //Enable aggregation at the AP side - if (nMpdus > 1) - { - mac.SetBlockAckThresholdForAc (AC_BE, 2); //enable BlockAck when A-MPDU is used - } - if (nMsdus > 0) - { - mac.SetMpduAggregatorForAc (AC_BE,"ns3::MpduStandardAggregator", - "MaxAmpduSize", UintegerValue (nMpdus * (nMsdus * (payloadSize + 100)))); //Set the maximum size for A-MPDU according to the payload size and the number of MSDUs expected in each MPDU. - } - else //MPDU aggregation only (one-level aggregation) - { - mac.SetMpduAggregatorForAc (AC_BE,"ns3::MpduStandardAggregator", - "MaxAmpduSize", UintegerValue (nMpdus * (payloadSize + 200))); //Set the maximum size for A-MPDU with regards to the payload size - } - mac.SetMsduAggregatorForAc (AC_BE,"ns3::MsduStandardAggregator", - "MaxAmsduSize", UintegerValue (nMsdus * (payloadSize + 100))); //Set the maximum size for A-MSDU with regards to the payload size - - NetDeviceContainer apDevice; - apDevice = wifi.Install (phy, mac, wifiApNode); - - /* Setting mobility model */ - MobilityHelper mobility; - Ptr positionAlloc = CreateObject (); - - positionAlloc->Add (Vector (0.0, 0.0, 0.0)); - positionAlloc->Add (Vector (1.0, 0.0, 0.0)); - mobility.SetPositionAllocator (positionAlloc); - - mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); - - mobility.Install (wifiApNode); - mobility.Install (wifiStaNode); - - /* Internet stack*/ - InternetStackHelper stack; - stack.Install (wifiApNode); - stack.Install (wifiStaNode); - - Ipv4AddressHelper address; - - address.SetBase ("192.168.1.0", "255.255.255.0"); - Ipv4InterfaceContainer StaInterface; - StaInterface = address.Assign (staDevice); - Ipv4InterfaceContainer ApInterface; - ApInterface = address.Assign (apDevice); - - /* Setting applications */ - UdpServerHelper myServer (9); - ApplicationContainer serverApp = myServer.Install (wifiStaNode.Get (0)); - serverApp.Start (Seconds (0.0)); - serverApp.Stop (Seconds (simulationTime + 1)); - - UdpClientHelper myClient (StaInterface.GetAddress (0), 9); - myClient.SetAttribute ("MaxPackets", UintegerValue (4294967295u)); - myClient.SetAttribute ("Interval", TimeValue (Time ("0.00002"))); //packets/s - myClient.SetAttribute ("PacketSize", UintegerValue (payloadSize)); - - ApplicationContainer clientApp = myClient.Install (wifiApNode.Get (0)); - clientApp.Start (Seconds (1.0)); - clientApp.Stop (Seconds (simulationTime + 1)); - - Simulator::Stop (Seconds (simulationTime + 1)); - - Simulator::Run (); - Simulator::Destroy (); - - uint32_t totalPacketsThrough = DynamicCast (serverApp.Get (0))->GetReceived (); - double throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0); - std::cout << "Throughput: " << throughput << " Mbit/s" << '\n'; - - return 0; -} diff --git a/examples/wireless/vht-wifi-network.cc b/examples/wireless/vht-wifi-network.cc index 3defe1025..8bda771ff 100644 --- a/examples/wireless/vht-wifi-network.cc +++ b/examples/wireless/vht-wifi-network.cc @@ -94,13 +94,14 @@ int main (int argc, char *argv[]) // Set guard interval phy.Set ("ShortGuardEnabled", BooleanValue (k)); - WifiHelper wifi = WifiHelper::Default (); + WifiHelper wifi; wifi.SetStandard (WIFI_PHY_STANDARD_80211ac); - VhtWifiMacHelper mac = VhtWifiMacHelper::Default (); + WifiMacHelper mac; - StringValue DataRate = VhtWifiMacHelper::DataRateForMcs (i); - wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager","DataMode", DataRate, - "ControlMode", DataRate); + std::ostringstream oss; + oss << "VhtMcs" << i; + wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager","DataMode", StringValue (oss.str ()), + "ControlMode", StringValue (oss.str ())); Ssid ssid = Ssid ("ns3-80211ac"); diff --git a/examples/wireless/wifi-adhoc.cc b/examples/wireless/wifi-adhoc.cc index 7e5535732..81c8bf7f5 100644 --- a/examples/wireless/wifi-adhoc.cc +++ b/examples/wireless/wifi-adhoc.cc @@ -37,7 +37,7 @@ public: Experiment (); Experiment (std::string name); Gnuplot2dDataset Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, - const NqosWifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel); + const WifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel); private: void ReceivePacket (Ptr socket); void SetPosition (Ptr node, Vector position); @@ -112,7 +112,7 @@ Experiment::SetupPacketReceive (Ptr node) Gnuplot2dDataset Experiment::Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, - const NqosWifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel) + const WifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel) { m_bytesTotal = 0; @@ -125,7 +125,7 @@ Experiment::Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, YansWifiPhyHelper phy = wifiPhy; phy.SetChannel (wifiChannel.Create ()); - NqosWifiMacHelper mac = wifiMac; + WifiMacHelper mac = wifiMac; NetDeviceContainer devices = wifi.Install (phy, mac, c); MobilityHelper mobility; @@ -172,9 +172,9 @@ int main (int argc, char *argv[]) Gnuplot gnuplot = Gnuplot ("reference-rates.png"); Experiment experiment; - WifiHelper wifi = WifiHelper::Default (); + WifiHelper wifi; wifi.SetStandard (WIFI_PHY_STANDARD_80211a); - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + WifiMacHelper wifiMac; YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); Gnuplot2dDataset dataset; diff --git a/examples/wireless/wifi-aggregation.cc b/examples/wireless/wifi-aggregation.cc new file mode 100644 index 000000000..dfcf2d571 --- /dev/null +++ b/examples/wireless/wifi-aggregation.cc @@ -0,0 +1,307 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2016 Sébastien Deronne + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Sébastien Deronne + */ + +#include "ns3/core-module.h" +#include "ns3/network-module.h" +#include "ns3/applications-module.h" +#include "ns3/wifi-module.h" +#include "ns3/mobility-module.h" +#include "ns3/ipv4-global-routing-helper.h" +#include "ns3/internet-module.h" + +// This is an example that illustrates how 802.11n aggregation is configured. +// It defines 4 independant Wi-Fi networks (working on different channels). +// Each network contains one access point and one station. Each station +// continously transmits data packets to its respective AP. +// +// Network topology (numbers in parentheses are channel numbers): +// +// Network A (36) Network B (40) Network C (44) Network D (48) +// * * * * * * * * +// | | | | | | | | +// AP A STA A AP B STA B AP C STA C AP D STA D +// +// The aggregation parameters are configured differently on the 4 stations: +// - station A uses default aggregation parameter values (A-MSDU disabled, A-MPDU enabled with maximum size of 65 kB); +// - station B doesn't use aggregation (both A-MPDU and A-MSDU are disabled); +// - station C enables A-MSDU (with maximum size of 8 kB) but disables A-MPDU; +// - station C uses two-level aggregation (A-MPDU with maximum size of 32 kB and A-MSDU with maximum size of 4 kB). +// +// Packets in this simulation aren't marked with a QosTag so they +// are considered belonging to BestEffort Access Class (AC_BE). +// +// The user can select the distance between the stations and the APs and can enable/disable the RTS/CTS mechanism. +// Example: ./waf --run "wifi-aggregation --distance=10 --enableRts=0 --simulationTime=20" +// +// The output prints the throughput measured for the 4 cases/networks decribed above. When default aggregation parameters are enabled, the +// maximum A-MPDU size is 65 kB and the throughput is maximal. When aggregation is disabled, the thoughput is about the half of the +// physical bitrate as in legacy wifi networks. When only A-MSDU is enabled, the throughput is increased but is not maximal, since the maximum +// A-MSDU size is limited to 7935 bytes (whereas the maximum A-MPDU size is limited to 65535 bytes). When A-MSDU and A-MPDU are both enabled +// (= two-level aggregation), the throughput is slightly smaller than the first scenario since we set a smaller maximum A-MPDU size. +// +// When the distance is increased, the frame error rate gets higher, and the output shows how it affects the throughput for the 4 networks. +// Even through A-MSDU has less overheads than A-MPDU, A-MSDU is less robust against transmission errors than A-MPDU. When the distance is +// augmented, the throughput for the third scenario is more affected than the throughput obtained in other networks. + +using namespace ns3; + +NS_LOG_COMPONENT_DEFINE ("SimpleMpduAggregation"); + +int main (int argc, char *argv[]) +{ + uint32_t payloadSize = 1472; //bytes + uint64_t simulationTime = 10; //seconds + double distance = 5; //meters + bool enablePcap = 0; + + CommandLine cmd; + cmd.AddValue ("payloadSize", "Payload size in bytes", payloadSize); + cmd.AddValue ("simulationTime", "Simulation time in seconds", simulationTime); + cmd.AddValue ("distance", "Distance in meters between the station and the access point", distance); + cmd.AddValue ("enablePcap", "Enable/disable pcap file generation", enablePcap); + cmd.Parse (argc, argv); + + NodeContainer wifiStaNode; + wifiStaNode.Create (4); + NodeContainer wifiApNode; + wifiApNode.Create (4); + + YansWifiChannelHelper channel = YansWifiChannelHelper::Default (); + YansWifiPhyHelper phy = YansWifiPhyHelper::Default (); + phy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO); + phy.SetChannel (channel.Create ()); + + WifiHelper wifi; + wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ); + wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("HtMcs7"), "ControlMode", StringValue ("HtMcs0")); + WifiMacHelper mac; + + NetDeviceContainer staDeviceA, staDeviceB, staDeviceC, staDeviceD, apDeviceA, apDeviceB, apDeviceC, apDeviceD; + Ssid ssid; + + //Network A + ssid = Ssid ("network-A"); + phy.Set ("ChannelNumber", UintegerValue(36)); + mac.SetType ("ns3::StaWifiMac", + "Ssid", SsidValue (ssid), + "ActiveProbing", BooleanValue (false)); + staDeviceA = wifi.Install (phy, mac, wifiStaNode.Get(0)); + + mac.SetType ("ns3::ApWifiMac", + "Ssid", SsidValue (ssid), + "BeaconInterval", TimeValue (MicroSeconds (102400)), + "BeaconGeneration", BooleanValue (true)); + apDeviceA = wifi.Install (phy, mac, wifiApNode.Get(0)); + + //Network B + ssid = Ssid ("network-B"); + phy.Set ("ChannelNumber", UintegerValue(40)); + mac.SetType ("ns3::StaWifiMac", + "Ssid", SsidValue (ssid), + "ActiveProbing", BooleanValue (false), + "BE_MaxAmpduSize", UintegerValue (0)); //Disable A-MPDU + + staDeviceB = wifi.Install (phy, mac, wifiStaNode.Get(1)); + + mac.SetType ("ns3::ApWifiMac", + "Ssid", SsidValue (ssid), + "BeaconInterval", TimeValue (MicroSeconds (102400)), + "BeaconGeneration", BooleanValue (true)); + apDeviceB = wifi.Install (phy, mac, wifiApNode.Get(1)); + + //Network C + ssid = Ssid ("network-C"); + phy.Set ("ChannelNumber", UintegerValue(44)); + mac.SetType ("ns3::StaWifiMac", + "Ssid", SsidValue (ssid), + "ActiveProbing", BooleanValue (false), + "BE_MaxAmpduSize", UintegerValue (0), //Disable A-MPDU + "BE_MaxAmsduSize", UintegerValue (7935)); //Enable A-MSDU with the highest maximum size allowed by the standard (7935 bytes) + + staDeviceC = wifi.Install (phy, mac, wifiStaNode.Get(2)); + + mac.SetType ("ns3::ApWifiMac", + "Ssid", SsidValue (ssid), + "BeaconInterval", TimeValue (MicroSeconds (102400)), + "BeaconGeneration", BooleanValue (true)); + apDeviceC = wifi.Install (phy, mac, wifiApNode.Get(2)); + + //Network D + ssid = Ssid ("network-D"); + phy.Set ("ChannelNumber", UintegerValue(48)); + mac.SetType ("ns3::StaWifiMac", + "Ssid", SsidValue (ssid), + "ActiveProbing", BooleanValue (false), + "BE_MaxAmpduSize", UintegerValue (32768), //Enable A-MPDU with a smaller size than the default one + "BE_MaxAmsduSize", UintegerValue (3839)); //Enable A-MSDU with the smallest maximum size allowed by the standard (3839 bytes) + + staDeviceD = wifi.Install (phy, mac, wifiStaNode.Get(3)); + + mac.SetType ("ns3::ApWifiMac", + "Ssid", SsidValue (ssid), + "BeaconInterval", TimeValue (MicroSeconds (102400)), + "BeaconGeneration", BooleanValue (true)); + apDeviceD = wifi.Install (phy, mac, wifiApNode.Get(3)); + + /* Setting mobility model */ + MobilityHelper mobility; + Ptr positionAlloc = CreateObject (); + mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); + + //Set position for APs + positionAlloc->Add (Vector (0.0, 0.0, 0.0)); + positionAlloc->Add (Vector (10.0, 0.0, 0.0)); + positionAlloc->Add (Vector (20.0, 0.0, 0.0)); + positionAlloc->Add (Vector (30.0, 0.0, 0.0)); + //Set position for STAs + positionAlloc->Add (Vector (distance, 0.0, 0.0)); + positionAlloc->Add (Vector (10 + distance, 0.0, 0.0)); + positionAlloc->Add (Vector (20 + distance, 0.0, 0.0)); + positionAlloc->Add (Vector (30 + distance, 0.0, 0.0)); + //Remark: while we set these positions 10 meters apart, the networks do not interact + //and the only variable that affects transmission performance is the distance. + + mobility.SetPositionAllocator (positionAlloc); + mobility.Install (wifiApNode); + mobility.Install (wifiStaNode); + + /* Internet stack */ + InternetStackHelper stack; + stack.Install (wifiApNode); + stack.Install (wifiStaNode); + + Ipv4AddressHelper address; + + address.SetBase ("192.168.1.0", "255.255.255.0"); + Ipv4InterfaceContainer StaInterfaceA; + StaInterfaceA = address.Assign (staDeviceA); + Ipv4InterfaceContainer ApInterfaceA; + ApInterfaceA = address.Assign (apDeviceA); + + address.SetBase ("192.168.2.0", "255.255.255.0"); + Ipv4InterfaceContainer StaInterfaceB; + StaInterfaceB = address.Assign (staDeviceB); + Ipv4InterfaceContainer ApInterfaceB; + ApInterfaceB = address.Assign (apDeviceB); + + address.SetBase ("192.168.3.0", "255.255.255.0"); + Ipv4InterfaceContainer StaInterfaceC; + StaInterfaceC = address.Assign (staDeviceC); + Ipv4InterfaceContainer ApInterfaceC; + ApInterfaceC = address.Assign (apDeviceC); + + address.SetBase ("192.168.4.0", "255.255.255.0"); + Ipv4InterfaceContainer StaInterfaceD; + StaInterfaceD = address.Assign (staDeviceD); + Ipv4InterfaceContainer ApInterfaceD; + ApInterfaceD = address.Assign (apDeviceD); + + /* Setting applications */ + UdpServerHelper myServerA (9); + ApplicationContainer serverAppA = myServerA.Install (wifiStaNode.Get (0)); + serverAppA.Start (Seconds (0.0)); + serverAppA.Stop (Seconds (simulationTime + 1)); + + UdpClientHelper myClientA (StaInterfaceA.GetAddress (0), 9); + myClientA.SetAttribute ("MaxPackets", UintegerValue (4294967295u)); + myClientA.SetAttribute ("Interval", TimeValue (Time ("0.00002"))); //packets/s + myClientA.SetAttribute ("PacketSize", UintegerValue (payloadSize)); + + ApplicationContainer clientAppA = myClientA.Install (wifiApNode.Get (0)); + clientAppA.Start (Seconds (1.0)); + clientAppA.Stop (Seconds (simulationTime + 1)); + + UdpServerHelper myServerB (9); + ApplicationContainer serverAppB = myServerB.Install (wifiStaNode.Get (1)); + serverAppB.Start (Seconds (0.0)); + serverAppB.Stop (Seconds (simulationTime + 1)); + + UdpClientHelper myClientB (StaInterfaceB.GetAddress (0), 9); + myClientB.SetAttribute ("MaxPackets", UintegerValue (4294967295u)); + myClientB.SetAttribute ("Interval", TimeValue (Time ("0.00002"))); //packets/s + myClientB.SetAttribute ("PacketSize", UintegerValue (payloadSize)); + + ApplicationContainer clientAppB = myClientB.Install (wifiApNode.Get (1)); + clientAppB.Start (Seconds (1.0)); + clientAppB.Stop (Seconds (simulationTime + 1)); + + UdpServerHelper myServerC (9); + ApplicationContainer serverAppC = myServerC.Install (wifiStaNode.Get (2)); + serverAppC.Start (Seconds (0.0)); + serverAppC.Stop (Seconds (simulationTime + 1)); + + UdpClientHelper myClientC (StaInterfaceC.GetAddress (0), 9); + myClientC.SetAttribute ("MaxPackets", UintegerValue (4294967295u)); + myClientC.SetAttribute ("Interval", TimeValue (Time ("0.00002"))); //packets/s + myClientC.SetAttribute ("PacketSize", UintegerValue (payloadSize)); + + ApplicationContainer clientAppC = myClientC.Install (wifiApNode.Get (2)); + clientAppC.Start (Seconds (1.0)); + clientAppC.Stop (Seconds (simulationTime + 1)); + + UdpServerHelper myServerD (9); + ApplicationContainer serverAppD = myServerD.Install (wifiStaNode.Get (3)); + serverAppD.Start (Seconds (0.0)); + serverAppD.Stop (Seconds (simulationTime + 1)); + + UdpClientHelper myClientD (StaInterfaceD.GetAddress (0), 9); + myClientD.SetAttribute ("MaxPackets", UintegerValue (4294967295u)); + myClientD.SetAttribute ("Interval", TimeValue (Time ("0.00002"))); //packets/s + myClientD.SetAttribute ("PacketSize", UintegerValue (payloadSize)); + + ApplicationContainer clientAppD = myClientD.Install (wifiApNode.Get (3)); + clientAppD.Start (Seconds (1.0)); + clientAppD.Stop (Seconds (simulationTime + 1)); + + if (enablePcap) + { + phy.EnablePcap ("AP_A", apDeviceA.Get (0)); + phy.EnablePcap ("STA_A", staDeviceA.Get (0)); + phy.EnablePcap ("AP_B", apDeviceB.Get (0)); + phy.EnablePcap ("STA_B", staDeviceB.Get (0)); + phy.EnablePcap ("AP_C", apDeviceC.Get (0)); + phy.EnablePcap ("STA_C", staDeviceC.Get (0)); + phy.EnablePcap ("AP_D", apDeviceD.Get (0)); + phy.EnablePcap ("STA_D", staDeviceD.Get (0)); + } + + Simulator::Stop (Seconds (simulationTime + 1)); + Simulator::Run (); + Simulator::Destroy (); + + /* Show results */ + uint32_t totalPacketsThrough = DynamicCast (serverAppA.Get (0))->GetReceived (); + double throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0); + std::cout << "Throughput with default configuration (A-MPDU aggregation enabled, 65kB): " << throughput << " Mbit/s" << '\n'; + + totalPacketsThrough = DynamicCast (serverAppB.Get (0))->GetReceived (); + throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0); + std::cout << "Throughput with aggregation disabled: " << throughput << " Mbit/s" << '\n'; + + totalPacketsThrough = DynamicCast (serverAppC.Get (0))->GetReceived (); + throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0); + std::cout << "Throughput with A-MPDU disabled and A-MSDU enabled (8kB): " << throughput << " Mbit/s" << '\n'; + + totalPacketsThrough = DynamicCast (serverAppD.Get (0))->GetReceived (); + throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0); + std::cout << "Throughput with A-MPDU enabled (32kB) and A-MSDU enabled (4kB): " << throughput << " Mbit/s" << '\n'; + + return 0; +} diff --git a/examples/wireless/wifi-ap.cc b/examples/wireless/wifi-ap.cc index 0317400b7..2454cd670 100644 --- a/examples/wireless/wifi-ap.cc +++ b/examples/wireless/wifi-ap.cc @@ -128,7 +128,7 @@ int main (int argc, char *argv[]) // disable fragmentation Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200")); - WifiHelper wifi = WifiHelper::Default (); + WifiHelper wifi; MobilityHelper mobility; NodeContainer stas; NodeContainer ap; @@ -142,7 +142,7 @@ int main (int argc, char *argv[]) packetSocket.Install (stas); packetSocket.Install (ap); - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + WifiMacHelper wifiMac; YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); wifiPhy.SetChannel (wifiChannel.Create ()); diff --git a/examples/wireless/wifi-blockack.cc b/examples/wireless/wifi-blockack.cc index 62ae61c31..0028342b1 100644 --- a/examples/wireless/wifi-blockack.cc +++ b/examples/wireless/wifi-blockack.cc @@ -19,7 +19,7 @@ */ /** - * This is a simple example in order to show how 802.11n compressed block ack mechanism could be used. + * This is a simple example in order to show how 802.11e compressed block ack mechanism could be used. * * Network topology: * @@ -62,25 +62,27 @@ int main (int argc, char const* argv[]) YansWifiPhyHelper phy = YansWifiPhyHelper::Default (); phy.SetChannel (channel.Create ()); - WifiHelper wifi = WifiHelper::Default (); - QosWifiMacHelper mac = QosWifiMacHelper::Default (); + WifiHelper wifi; + WifiMacHelper mac; /* disable fragmentation */ wifi.SetRemoteStationManager ("ns3::AarfWifiManager", "FragmentationThreshold", UintegerValue (2500)); Ssid ssid ("My-network"); mac.SetType ("ns3::StaWifiMac", + "QosSupported", BooleanValue (true), "Ssid", SsidValue (ssid), - "ActiveProbing", BooleanValue (false)); + "ActiveProbing", BooleanValue (false), /* setting blockack threshold for sta's BE queue */ - mac.SetBlockAckThresholdForAc (AC_BE, 2); - /* setting block inactivity timeout to 3*1024 = 3072 microseconds */ - //mac.SetBlockAckInactivityTimeoutForAc (AC_BE, 3); + "BE_BlockAckThreshold", UintegerValue (2), + /* setting block inactivity timeout to 3*1024 = 3072 microseconds */ + "BE_BlockAckInactivityTimeout", UintegerValue (3)); NetDeviceContainer staDevice = wifi.Install (phy, mac, sta); mac.SetType ("ns3::ApWifiMac", - "Ssid", SsidValue (ssid)); - mac.SetBlockAckThresholdForAc (AC_BE, 0); + "QosSupported", BooleanValue (true), + "Ssid", SsidValue (ssid), + "BE_BlockAckThreshold", UintegerValue (0)); NetDeviceContainer apDevice = wifi.Install (phy, mac, ap); /* Setting mobility model */ diff --git a/examples/wireless/wifi-clear-channel-cmu.cc b/examples/wireless/wifi-clear-channel-cmu.cc index ae6443a8c..e54751380 100644 --- a/examples/wireless/wifi-clear-channel-cmu.cc +++ b/examples/wireless/wifi-clear-channel-cmu.cc @@ -40,7 +40,7 @@ public: Experiment (); Experiment (std::string name); uint32_t Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, - const NqosWifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel); + const WifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel); private: void ReceivePacket (Ptr socket); void SetPosition (Ptr node, Vector position); @@ -116,7 +116,7 @@ Experiment::GenerateTraffic (Ptr socket, uint32_t pktSize, uint32_t Experiment::Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, - const NqosWifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel) + const WifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel) { m_pktsTotal = 0; @@ -129,7 +129,7 @@ Experiment::Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, YansWifiPhyHelper phy = wifiPhy; phy.SetChannel (wifiChannel.Create ()); - NqosWifiMacHelper mac = wifiMac; + WifiMacHelper mac = wifiMac; NetDeviceContainer devices = wifi.Install (phy, mac, c); MobilityHelper mobility; @@ -194,7 +194,7 @@ int main (int argc, char *argv[]) WifiHelper wifi; wifi.SetStandard (WIFI_PHY_STANDARD_80211b); - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + WifiMacHelper wifiMac; Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode", StringValue (modes[i])); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", diff --git a/examples/wireless/wifi-hidden-terminal.cc b/examples/wireless/wifi-hidden-terminal.cc index 5c68059a4..9b23ded09 100644 --- a/examples/wireless/wifi-hidden-terminal.cc +++ b/examples/wireless/wifi-hidden-terminal.cc @@ -76,7 +76,7 @@ void experiment (bool enableCtsRts) "ControlMode",StringValue ("DsssRate1Mbps")); YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); wifiPhy.SetChannel (wifiChannel); - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + WifiMacHelper wifiMac; wifiMac.SetType ("ns3::AdhocWifiMac"); // use ad-hoc MAC NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, nodes); diff --git a/examples/wireless/wifi-simple-adhoc-grid.cc b/examples/wireless/wifi-simple-adhoc-grid.cc index 7dbcb3024..742ecce89 100644 --- a/examples/wireless/wifi-simple-adhoc-grid.cc +++ b/examples/wireless/wifi-simple-adhoc-grid.cc @@ -171,8 +171,8 @@ int main (int argc, char *argv[]) wifiChannel.AddPropagationLoss ("ns3::FriisPropagationLossModel"); wifiPhy.SetChannel (wifiChannel.Create ()); - // Add a non-QoS upper mac, and disable rate control - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + // Add an upper mac and disable rate control + WifiMacHelper wifiMac; wifi.SetStandard (WIFI_PHY_STANDARD_80211b); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode",StringValue (phyMode), diff --git a/examples/wireless/wifi-simple-adhoc.cc b/examples/wireless/wifi-simple-adhoc.cc index 6f7e208b6..26c9b1bbc 100644 --- a/examples/wireless/wifi-simple-adhoc.cc +++ b/examples/wireless/wifi-simple-adhoc.cc @@ -146,8 +146,8 @@ int main (int argc, char *argv[]) wifiChannel.AddPropagationLoss ("ns3::FixedRssLossModel","Rss",DoubleValue (rss)); wifiPhy.SetChannel (wifiChannel.Create ()); - // Add a non-QoS upper mac, and disable rate control - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + // Add a mac and disable rate control + WifiMacHelper wifiMac; wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode",StringValue (phyMode), "ControlMode",StringValue (phyMode)); diff --git a/examples/wireless/wifi-simple-infra.cc b/examples/wireless/wifi-simple-infra.cc index 601db4801..c5ed3593c 100644 --- a/examples/wireless/wifi-simple-infra.cc +++ b/examples/wireless/wifi-simple-infra.cc @@ -147,13 +147,13 @@ int main (int argc, char *argv[]) wifiChannel.AddPropagationLoss ("ns3::FixedRssLossModel","Rss",DoubleValue (rss)); wifiPhy.SetChannel (wifiChannel.Create ()); - // Add a non-QoS upper mac, and disable rate control - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + // Add a mac and disable rate control + WifiMacHelper wifiMac; wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode",StringValue (phyMode), "ControlMode",StringValue (phyMode)); - // Setup the rest of the upper mac + // Setup the rest of the mac Ssid ssid = Ssid ("wifi-default"); // setup sta. wifiMac.SetType ("ns3::StaWifiMac", diff --git a/examples/wireless/wifi-simple-interference.cc b/examples/wireless/wifi-simple-interference.cc index 86aab9576..a907ed5f9 100644 --- a/examples/wireless/wifi-simple-interference.cc +++ b/examples/wireless/wifi-simple-interference.cc @@ -200,8 +200,8 @@ int main (int argc, char *argv[]) wifiChannel.AddPropagationLoss ("ns3::LogDistancePropagationLossModel"); wifiPhy.SetChannel (wifiChannel.Create ()); - // Add a non-QoS upper mac, and disable rate control - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + // Add a mac and disable rate control + WifiMacHelper wifiMac; wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode",StringValue (phyMode), "ControlMode",StringValue (phyMode)); diff --git a/examples/wireless/wifi-sleep.cc b/examples/wireless/wifi-sleep.cc index 55cb2dff4..897a6dd94 100644 --- a/examples/wireless/wifi-sleep.cc +++ b/examples/wireless/wifi-sleep.cc @@ -146,8 +146,8 @@ int main (int argc, char *argv[]) YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); wifiPhy.SetChannel (wifiChannel.Create ()); - // Add a non-QoS upper mac, and set the selected tx power level - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + // Add a mac and set the selected tx power level + WifiMacHelper wifiMac; wifi.SetRemoteStationManager ("ns3::ArfWifiManager", "DefaultTxPowerLevel", UintegerValue (txPowerLevel)); // Set it to adhoc mode wifiMac.SetType ("ns3::AdhocWifiMac"); diff --git a/examples/wireless/wifi-timing-attributes.cc b/examples/wireless/wifi-timing-attributes.cc index 85d77149d..2388c1e38 100644 --- a/examples/wireless/wifi-timing-attributes.cc +++ b/examples/wireless/wifi-timing-attributes.cc @@ -82,12 +82,12 @@ int main (int argc, char *argv[]) phy.SetChannel (channel.Create ()); //Default IEEE 802.11n (2.4 GHz) - WifiHelper wifi = WifiHelper::Default (); + WifiHelper wifi; wifi.SetStandard (WIFI_PHY_STANDARD_80211n_2_4GHZ); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue("OfdmRate65MbpsBW20MHz"), "ControlMode", StringValue("OfdmRate6_5MbpsBW20MHz")); - HtWifiMacHelper mac = HtWifiMacHelper::Default (); + WifiMacHelper mac; //Install PHY and MAC Ssid ssid = Ssid ("ns3-wifi"); diff --git a/examples/wireless/wifi-wired-bridging.cc b/examples/wireless/wifi-wired-bridging.cc index f2d426c94..14dc67f66 100644 --- a/examples/wireless/wifi-wired-bridging.cc +++ b/examples/wireless/wifi-wired-bridging.cc @@ -110,8 +110,8 @@ int main (int argc, char *argv[]) Ipv4InterfaceContainer apInterface; MobilityHelper mobility; BridgeHelper bridge; - WifiHelper wifi = WifiHelper::Default (); - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + WifiHelper wifi; + WifiMacHelper wifiMac; YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); wifiPhy.SetChannel (wifiChannel.Create ()); diff --git a/examples/wireless/wscript b/examples/wireless/wscript index 1336e414c..3d55c0f8f 100644 --- a/examples/wireless/wscript +++ b/examples/wireless/wscript @@ -22,9 +22,6 @@ def build(bld): obj = bld.create_ns3_program('wifi-wired-bridging', ['internet', 'mobility', 'wifi', 'csma', 'bridge', 'applications']) obj.source = 'wifi-wired-bridging.cc' - obj = bld.create_ns3_program('simple-msdu-aggregation', ['internet', 'mobility', 'wifi', 'applications']) - obj.source = 'simple-msdu-aggregation.cc' - obj = bld.create_ns3_program('multirate', ['internet', 'mobility', 'wifi', 'stats', 'flow-monitor', 'olsr', 'applications', 'point-to-point']) obj.source = 'multirate.cc' @@ -76,11 +73,8 @@ def build(bld): obj = bld.create_ns3_program('rate-adaptation-distance', ['core', 'mobility', 'wifi', 'applications', 'flow-monitor']) obj.source = 'rate-adaptation-distance.cc' - obj = bld.create_ns3_program('simple-mpdu-aggregation', ['internet', 'mobility', 'wifi', 'applications']) - obj.source = 'simple-mpdu-aggregation.cc' - - obj = bld.create_ns3_program('simple-two-level-aggregation', ['internet', 'mobility', 'wifi', 'applications']) - obj.source = 'simple-two-level-aggregation.cc' + obj = bld.create_ns3_program('wifi-aggregation', ['internet', 'mobility', 'wifi', 'applications']) + obj.source = 'wifi-aggregation.cc' obj = bld.create_ns3_program('simple-ht-hidden-stations', ['internet', 'mobility', 'wifi', 'applications']) obj.source = 'simple-ht-hidden-stations.cc' diff --git a/src/aodv/examples/aodv.cc b/src/aodv/examples/aodv.cc index d900b98d7..e17c1a94c 100644 --- a/src/aodv/examples/aodv.cc +++ b/src/aodv/examples/aodv.cc @@ -168,12 +168,12 @@ AodvExample::CreateNodes () void AodvExample::CreateDevices () { - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + WifiMacHelper wifiMac; wifiMac.SetType ("ns3::AdhocWifiMac"); YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); wifiPhy.SetChannel (wifiChannel.Create ()); - WifiHelper wifi = WifiHelper::Default (); + WifiHelper wifi; wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("OfdmRate6Mbps"), "RtsCtsThreshold", UintegerValue (0)); devices = wifi.Install (wifiPhy, wifiMac, nodes); diff --git a/src/aodv/test/aodv-regression.cc b/src/aodv/test/aodv-regression.cc index 80d9eb529..087889dfb 100644 --- a/src/aodv/test/aodv-regression.cc +++ b/src/aodv/test/aodv-regression.cc @@ -34,7 +34,7 @@ #include "ns3/mobility-model.h" #include "ns3/pcap-file.h" #include "ns3/aodv-helper.h" -#include "ns3/nqos-wifi-mac-helper.h" +#include "ns3/default-mac-helper.h" #include "ns3/config.h" #include "ns3/pcap-test.h" #include "ns3/rng-seed-manager.h" @@ -159,7 +159,7 @@ ChainRegressionTest::CreateDevices () { // 1. Setup WiFi int64_t streamsUsed = 0; - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + WifiMacHelper wifiMac; wifiMac.SetType ("ns3::AdhocWifiMac"); YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); @@ -167,7 +167,7 @@ ChainRegressionTest::CreateDevices () wifiPhy.SetChannel (chan); // This test suite output was originally based on YansErrorRateModel wifiPhy.SetErrorRateModel ("ns3::YansErrorRateModel"); - WifiHelper wifi = WifiHelper::Default (); + WifiHelper wifi; wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("OfdmRate6Mbps"), "RtsCtsThreshold", StringValue ("2200")); NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, *m_nodes); diff --git a/src/aodv/test/bug-772.cc b/src/aodv/test/bug-772.cc index 9966f8fff..59255c7ba 100644 --- a/src/aodv/test/bug-772.cc +++ b/src/aodv/test/bug-772.cc @@ -37,7 +37,7 @@ #include "ns3/pcap-file.h" #include "ns3/aodv-helper.h" #include "ns3/v4ping-helper.h" -#include "ns3/nqos-wifi-mac-helper.h" +#include "ns3/default-mac-helper.h" #include "ns3/config.h" #include "ns3/inet-socket-address.h" #include "ns3/data-rate.h" @@ -116,7 +116,7 @@ Bug772ChainTest::CreateDevices () { int64_t streamsUsed = 0; // 1. Setup WiFi - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + WifiMacHelper wifiMac; wifiMac.SetType ("ns3::AdhocWifiMac"); YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); // This test suite output was originally based on YansErrorRateModel @@ -124,7 +124,7 @@ Bug772ChainTest::CreateDevices () YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); Ptr chan = wifiChannel.Create (); wifiPhy.SetChannel (chan); - WifiHelper wifi = WifiHelper::Default (); + WifiHelper wifi; wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("OfdmRate6Mbps"), "RtsCtsThreshold", StringValue ("2200")); NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, *m_nodes); diff --git a/src/aodv/test/loopback.cc b/src/aodv/test/loopback.cc index ebdd99710..5ecaac6d5 100644 --- a/src/aodv/test/loopback.cc +++ b/src/aodv/test/loopback.cc @@ -36,7 +36,7 @@ #include "ns3/pcap-file.h" #include "ns3/aodv-helper.h" #include "ns3/v4ping.h" -#include "ns3/nqos-wifi-mac-helper.h" +#include "ns3/default-mac-helper.h" #include "ns3/config.h" #include "ns3/constant-position-mobility-model.h" #include "ns3/names.h" @@ -118,12 +118,12 @@ LoopbackTestCase::DoRun () m->SetPosition (Vector (0, 0, 0)); nodes.Get (0)->AggregateObject (m); // Setup WiFi - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + WifiMacHelper wifiMac; wifiMac.SetType ("ns3::AdhocWifiMac"); YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); wifiPhy.SetChannel (wifiChannel.Create ()); - WifiHelper wifi = WifiHelper::Default (); + WifiHelper wifi; wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("OfdmRate6Mbps"), "RtsCtsThreshold", StringValue ("2200")); NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, nodes); diff --git a/src/click/examples/nsclick-raw-wlan.cc b/src/click/examples/nsclick-raw-wlan.cc index 410a013e5..cdca8f649 100644 --- a/src/click/examples/nsclick-raw-wlan.cc +++ b/src/click/examples/nsclick-raw-wlan.cc @@ -79,8 +79,8 @@ int main (int argc, char *argv[]) wifiChannel.AddPropagationLoss ("ns3::FixedRssLossModel","Rss",DoubleValue (rss)); wifiPhy.SetChannel (wifiChannel.Create ()); - // Add a non-QoS upper mac, and disable rate control - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + // Add an upper mac and disable rate control + WifiMacHelper wifiMac = WifiMacHelper::Default (); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode",StringValue (phyMode), "ControlMode",StringValue (phyMode)); diff --git a/src/click/examples/nsclick-udp-client-server-wifi.cc b/src/click/examples/nsclick-udp-client-server-wifi.cc index d4029f0b5..42970c6d2 100644 --- a/src/click/examples/nsclick-udp-client-server-wifi.cc +++ b/src/click/examples/nsclick-udp-client-server-wifi.cc @@ -115,8 +115,8 @@ main (int argc, char *argv[]) wifiChannel.AddPropagationLoss ("ns3::FixedRssLossModel","Rss",DoubleValue (-80)); wifiPhy.SetChannel (wifiChannel.Create ()); - // Add a non-QoS upper mac, and disable rate control - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + // Add an upper mac and disable rate control + WifiMacHelper wifiMac = WifiMacHelper::Default (); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode",StringValue (phyMode), "ControlMode",StringValue (phyMode)); diff --git a/src/dsdv/examples/dsdv-manet.cc b/src/dsdv/examples/dsdv-manet.cc index 773555335..0254754bc 100644 --- a/src/dsdv/examples/dsdv-manet.cc +++ b/src/dsdv/examples/dsdv-manet.cc @@ -265,7 +265,7 @@ DsdvManetExample::SetupMobility () void DsdvManetExample::CreateDevices (std::string tr_name) { - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + WifiMacHelper wifiMac; wifiMac.SetType ("ns3::AdhocWifiMac"); YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); YansWifiChannelHelper wifiChannel; diff --git a/src/dsr/examples/dsr.cc b/src/dsr/examples/dsr.cc index 37147059d..907de2139 100644 --- a/src/dsr/examples/dsr.cc +++ b/src/dsr/examples/dsr.cc @@ -127,8 +127,8 @@ main (int argc, char *argv[]) wifiChannel.AddPropagationLoss ("ns3::RangePropagationLossModel", "MaxRange", DoubleValue (txpDistance)); wifiPhy.SetChannel (wifiChannel.Create ()); - // Add a non-QoS upper mac, and disable rate control - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + // Add a mac and disable rate control + WifiMacHelper wifiMac; wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue (dataMode), "ControlMode", StringValue (phyMode)); diff --git a/src/energy/examples/basic-energy-model-test.cc b/src/energy/examples/basic-energy-model-test.cc index 1722b4af1..3565635ed 100644 --- a/src/energy/examples/basic-energy-model-test.cc +++ b/src/energy/examples/basic-energy-model-test.cc @@ -31,7 +31,7 @@ #include "ns3/config.h" #include "ns3/string.h" #include "ns3/yans-wifi-helper.h" -#include "ns3/nqos-wifi-mac-helper.h" +#include "ns3/default-mac-helper.h" #include using namespace ns3; @@ -376,8 +376,8 @@ BasicEnergyDepletionTest::DepletionTestCase (double simTimeS, wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel"); wifiPhy.SetChannel (wifiChannel.Create ()); - // Add a non-QoS upper MAC, and disable rate control - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + // Add a MAC and disable rate control + WifiMacHelper wifiMac; wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue (phyMode), "ControlMode", StringValue (phyMode)); diff --git a/src/energy/examples/rv-battery-model-test.cc b/src/energy/examples/rv-battery-model-test.cc index 518b80281..59edf6e8d 100644 --- a/src/energy/examples/rv-battery-model-test.cc +++ b/src/energy/examples/rv-battery-model-test.cc @@ -31,7 +31,7 @@ #include "ns3/config.h" #include "ns3/string.h" #include "ns3/yans-wifi-helper.h" -#include "ns3/nqos-wifi-mac-helper.h" +#include "ns3/default-mac-helper.h" #include using namespace ns3; @@ -744,8 +744,8 @@ BatteryLifetimeTest::ConstantLoadTest (double load, Time expLifetime) wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel"); wifiPhy.SetChannel (wifiChannel.Create ()); - // Add a non-QoS upper MAC, and disable rate control - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + // Add a MAC and disable rate control + WifiMacHelper wifiMac; wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue (phyMode), "ControlMode", StringValue (phyMode)); @@ -831,8 +831,8 @@ BatteryLifetimeTest::VariableLoadTest (std::vector loads, wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel"); wifiPhy.SetChannel (wifiChannel.Create ()); - // Add a non-QoS upper MAC, and disable rate control - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + // Add a MAC and disable rate control + WifiMacHelper wifiMac; wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue (phyMode), "ControlMode", StringValue (phyMode)); diff --git a/src/flow-monitor/examples/wifi-olsr-flowmon.py b/src/flow-monitor/examples/wifi-olsr-flowmon.py index b2a94e298..1f3ee69fa 100644 --- a/src/flow-monitor/examples/wifi-olsr-flowmon.py +++ b/src/flow-monitor/examples/wifi-olsr-flowmon.py @@ -50,7 +50,7 @@ def main(argv): cmd.Parse(argv) wifi = ns.wifi.WifiHelper.Default() - wifiMac = ns.wifi.NqosWifiMacHelper.Default() + wifiMac = ns.wifi.DefaultWifiMacHelper.Default() wifiPhy = ns.wifi.YansWifiPhyHelper.Default() wifiChannel = ns.wifi.YansWifiChannelHelper.Default() wifiPhy.SetChannel(wifiChannel.Create()) diff --git a/src/mpi/examples/third-distributed.cc b/src/mpi/examples/third-distributed.cc index 17950b4fb..57b31771a 100644 --- a/src/mpi/examples/third-distributed.cc +++ b/src/mpi/examples/third-distributed.cc @@ -150,11 +150,10 @@ main (int argc, char *argv[]) YansWifiPhyHelper phy = YansWifiPhyHelper::Default (); phy.SetChannel (channel.Create ()); - WifiHelper wifi = WifiHelper::Default (); + WifiHelper wifi; wifi.SetRemoteStationManager ("ns3::AarfWifiManager"); - NqosWifiMacHelper mac = NqosWifiMacHelper::Default (); - + WifiMacHelper mac; Ssid ssid = Ssid ("ns-3-ssid"); mac.SetType ("ns3::StaWifiMac", "Ssid", SsidValue (ssid), diff --git a/src/netanim/examples/wireless-animation.cc b/src/netanim/examples/wireless-animation.cc index 02745242e..de5cf993e 100644 --- a/src/netanim/examples/wireless-animation.cc +++ b/src/netanim/examples/wireless-animation.cc @@ -56,11 +56,10 @@ main (int argc, char *argv[]) YansWifiPhyHelper phy = YansWifiPhyHelper::Default (); phy.SetChannel (channel.Create ()); - WifiHelper wifi = WifiHelper::Default (); + WifiHelper wifi; wifi.SetRemoteStationManager ("ns3::AarfWifiManager"); - NqosWifiMacHelper mac = NqosWifiMacHelper::Default (); - + WifiMacHelper mac; Ssid ssid = Ssid ("ns-3-ssid"); mac.SetType ("ns3::StaWifiMac", "Ssid", SsidValue (ssid), diff --git a/src/olsr/examples/olsr-hna.cc b/src/olsr/examples/olsr-hna.cc index 0de926cb2..2af05e2a3 100644 --- a/src/olsr/examples/olsr-hna.cc +++ b/src/olsr/examples/olsr-hna.cc @@ -152,8 +152,8 @@ int main (int argc, char *argv[]) wifiChannel.AddPropagationLoss ("ns3::FixedRssLossModel","Rss",DoubleValue (rss)); wifiPhy.SetChannel (wifiChannel.Create ()); - // Add a non-QoS upper mac, and disable rate control - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + // Add a mac and disable rate control + WifiMacHelper wifiMac; wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode",StringValue (phyMode), "ControlMode",StringValue (phyMode)); diff --git a/src/tap-bridge/examples/tap-wifi-dumbbell.cc b/src/tap-bridge/examples/tap-wifi-dumbbell.cc index 34e439e38..a215bc769 100644 --- a/src/tap-bridge/examples/tap-wifi-dumbbell.cc +++ b/src/tap-bridge/examples/tap-wifi-dumbbell.cc @@ -140,8 +140,8 @@ main (int argc, char *argv[]) wifiPhy.SetChannel (wifiChannel.Create ()); Ssid ssid = Ssid ("left"); - WifiHelper wifi = WifiHelper::Default (); - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + WifiHelper wifi; + WifiMacHelper wifiMac = WifiMacHelper::Default (); wifi.SetRemoteStationManager ("ns3::ArfWifiManager"); wifiMac.SetType ("ns3::ApWifiMac", diff --git a/src/tap-bridge/examples/tap-wifi-virtual-machine.cc b/src/tap-bridge/examples/tap-wifi-virtual-machine.cc index e0657f9fd..d9e84fed2 100644 --- a/src/tap-bridge/examples/tap-wifi-virtual-machine.cc +++ b/src/tap-bridge/examples/tap-wifi-virtual-machine.cc @@ -104,14 +104,14 @@ main (int argc, char *argv[]) // // We're going to use 802.11 A so set up a wifi helper to reflect that. // - WifiHelper wifi = WifiHelper::Default (); + WifiHelper wifi; wifi.SetStandard (WIFI_PHY_STANDARD_80211a); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("OfdmRate54Mbps")); // // No reason for pesky access points, so we'll use an ad-hoc network. // - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + WifiMacHelper wifiMac = WifiMacHelper::Default (); wifiMac.SetType ("ns3::AdhocWifiMac"); // diff --git a/src/tap-bridge/examples/tap-wifi-virtual-machine.py b/src/tap-bridge/examples/tap-wifi-virtual-machine.py index 045a7a16e..ee7af0d00 100644 --- a/src/tap-bridge/examples/tap-wifi-virtual-machine.py +++ b/src/tap-bridge/examples/tap-wifi-virtual-machine.py @@ -51,7 +51,7 @@ def main(argv): # # No reason for pesky access points, so we'll use an ad-hoc network. # - wifiMac = ns.wifi.NqosWifiMacHelper.Default() + wifiMac = ns.wifi.DefaultWifiMacHelper.Default() wifiMac.SetType ("ns3::AdhocWifiMac"); # diff --git a/src/test/ns3wifi/wifi-interference-test-suite.cc b/src/test/ns3wifi/wifi-interference-test-suite.cc index eaf32a674..cda1e5026 100644 --- a/src/test/ns3wifi/wifi-interference-test-suite.cc +++ b/src/test/ns3wifi/wifi-interference-test-suite.cc @@ -30,6 +30,7 @@ #include "ns3/string.h" #include "ns3/uinteger.h" #include "ns3/double.h" +#include "ns3/boolean.h" #include "ns3/data-rate.h" #include "ns3/inet-socket-address.h" #include "ns3/internet-stack-helper.h" @@ -43,7 +44,7 @@ #include "ns3/wifi-net-device.h" #include "ns3/mobility-helper.h" #include "ns3/constant-position-mobility-model.h" -#include "ns3/nqos-wifi-mac-helper.h" +#include "ns3/default-mac-helper.h" #include "ns3/simulator.h" using namespace ns3; @@ -168,14 +169,26 @@ WifiInterferenceTestCase::WifiSimpleInterference (std::string phyMode,double Prs wifiChannel.AddPropagationLoss ("ns3::LogDistancePropagationLossModel"); wifiPhy.SetChannel (wifiChannel.Create ()); - // Add a non-QoS upper mac, and disable rate control - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + // Add a mac and disable rate control + WifiMacHelper wifiMac; wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode",StringValue (phyMode), "ControlMode",StringValue (phyMode)); - // Set it to adhoc mode - wifiMac.SetType ("ns3::AdhocWifiMac"); + + // Set it to adhoc mode (and enable QOS for HT/VHT stations) + if (wifiStandard == WIFI_PHY_STANDARD_80211n_2_4GHZ + || wifiStandard == WIFI_PHY_STANDARD_80211n_5GHZ + || wifiStandard == WIFI_PHY_STANDARD_80211ac) + { + wifiMac.SetType ("ns3::AdhocWifiMac", + "QosSupported", BooleanValue (true)); + } + else + { + wifiMac.SetType ("ns3::AdhocWifiMac"); + } NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c.Get (0)); + // This will disable these sending devices from detecting a signal // so that they do not backoff wifiPhy.Set ("EnergyDetectionThreshold", DoubleValue (0.0) ); @@ -274,7 +287,7 @@ WifiInterferenceTestCase::DoRun (void) NS_TEST_ASSERT_MSG_EQ (PERDiff1, PERDiff2, "The PER difference due to 1 microsecond difference in arrival shouldn't depend on absolute arrival"); //Now rerun for 11n - wifiStandard=WIFI_PHY_STANDARD_80211n_2_4GHZ; + wifiStandard = WIFI_PHY_STANDARD_80211n_2_4GHZ; // Compute the packet error rate (PER) when delta=0 microseconds. This // means that the interferer arrives at exactly the same time as the // intended packet diff --git a/src/test/ns3wifi/wifi-msdu-aggregator-test-suite.cc b/src/test/ns3wifi/wifi-msdu-aggregator-test-suite.cc index cfd1e5898..85df19a30 100644 --- a/src/test/ns3wifi/wifi-msdu-aggregator-test-suite.cc +++ b/src/test/ns3wifi/wifi-msdu-aggregator-test-suite.cc @@ -17,21 +17,20 @@ * * Author: Dean Armstrong */ + #include "ns3/test.h" #include "ns3/simulator.h" #include "ns3/log.h" - +#include "ns3/uinteger.h" #include "ns3/boolean.h" #include "ns3/string.h" #include "ns3/double.h" - #include "ns3/ssid.h" #include "ns3/data-rate.h" #include "ns3/inet-socket-address.h" #include "ns3/packet-sink.h" - #include "ns3/wifi-helper.h" -#include "ns3/qos-wifi-mac-helper.h" +#include "ns3/default-mac-helper.h" #include "ns3/yans-wifi-helper.h" #include "ns3/mobility-helper.h" #include "ns3/internet-stack-helper.h" @@ -62,9 +61,9 @@ WifiMsduAggregatorThroughputTest::WifiMsduAggregatorThroughputTest () void WifiMsduAggregatorThroughputTest::DoRun (void) { - WifiHelper wifi = WifiHelper::Default (); + WifiHelper wifi; - QosWifiMacHelper wifiMac = QosWifiMacHelper::Default (); + WifiMacHelper wifiMac; YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); wifiPhy.SetChannel (wifiChannel.Create ()); @@ -85,17 +84,19 @@ WifiMsduAggregatorThroughputTest::DoRun (void) NodeContainer ap; ap.Create (1); wifiMac.SetType ("ns3::ApWifiMac", + "QosSupported", BooleanValue (true), "Ssid", SsidValue (ssid), "BeaconGeneration", BooleanValue (true), - "BeaconInterval", TimeValue (MicroSeconds (102400))); - wifiMac.SetMsduAggregatorForAc (AC_BE, "ns3::MsduStandardAggregator", - "MaxAmsduSize", UintegerValue (4000)); + "BeaconInterval", TimeValue (MicroSeconds (102400)), + "BE_MaxAmsduSize", UintegerValue (4000)); + NetDeviceContainer apDev = wifi.Install (wifiPhy, wifiMac, ap); // Setup one STA, which will be the sink for traffic in this test. NodeContainer sta; sta.Create (1); wifiMac.SetType ("ns3::StaWifiMac", + "QosSupported", BooleanValue (true), "Ssid", SsidValue (ssid), "ActiveProbing", BooleanValue (false)); NetDeviceContainer staDev = wifi.Install (wifiPhy, wifiMac, sta); diff --git a/src/wave/examples/vanet-routing-compare.cc b/src/wave/examples/vanet-routing-compare.cc index f98c21e2a..b416cb828 100644 --- a/src/wave/examples/vanet-routing-compare.cc +++ b/src/wave/examples/vanet-routing-compare.cc @@ -2280,8 +2280,8 @@ VanetRoutingExperiment::SetupAdhocDevices () wavePhy.Set ("TxPowerStart",DoubleValue (m_txp)); wavePhy.Set ("TxPowerEnd", DoubleValue (m_txp)); - // Add a non-QoS upper mac, and disable rate control - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + // Add an upper mac and disable rate control + WifiMacHelper wifiMac; wifiMac.SetType ("ns3::AdhocWifiMac"); QosWaveMacHelper waveMac = QosWaveMacHelper::Default (); diff --git a/src/wave/helper/wave-mac-helper.cc b/src/wave/helper/wave-mac-helper.cc index 404748833..a582a5e7d 100644 --- a/src/wave/helper/wave-mac-helper.cc +++ b/src/wave/helper/wave-mac-helper.cc @@ -54,13 +54,16 @@ NqosWaveMacHelper::SetType (std::string type, std::string n4, const AttributeValue &v4, std::string n5, const AttributeValue &v5, std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7) + std::string n7, const AttributeValue &v7, + std::string n8, const AttributeValue &v8, + std::string n9, const AttributeValue &v9, + std::string n10, const AttributeValue &v10) { if (type.compare ("ns3::OcbWifiMac") != 0) { NS_FATAL_ERROR ("QosWaveMacHelper shall set OcbWifiMac"); } - NqosWifiMacHelper::SetType ("ns3::OcbWifiMac", + WifiMacHelper::SetType ("ns3::OcbWifiMac", n0, v0, n1, v1, n2, v2, @@ -68,7 +71,10 @@ NqosWaveMacHelper::SetType (std::string type, n4, v4, n5, v5, n6, v6, - n7, v7); + n7, v7, + n8, v8, + n9, v9, + n10, v10); } /********** QosWifi80211pMacHelper *********/ @@ -100,13 +106,16 @@ QosWaveMacHelper::SetType (std::string type, std::string n4, const AttributeValue &v4, std::string n5, const AttributeValue &v5, std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7) + std::string n7, const AttributeValue &v7, + std::string n8, const AttributeValue &v8, + std::string n9, const AttributeValue &v9, + std::string n10, const AttributeValue &v10) { if (type.compare ("ns3::OcbWifiMac") != 0) { NS_FATAL_ERROR ("QosWaveMacHelper shall set OcbWifiMac"); } - QosWifiMacHelper::SetType ("ns3::OcbWifiMac", + WifiMacHelper::SetType ("ns3::OcbWifiMac", n0, v0, n1, v1, n2, v2, @@ -114,7 +123,10 @@ QosWaveMacHelper::SetType (std::string type, n4, v4, n5, v5, n6, v6, - n7, v7); + n7, v7, + n8, v8, + n9, v9, + n10, v10); } } // namespace ns3 diff --git a/src/wave/helper/wave-mac-helper.h b/src/wave/helper/wave-mac-helper.h index 8cf699a35..71622266b 100644 --- a/src/wave/helper/wave-mac-helper.h +++ b/src/wave/helper/wave-mac-helper.h @@ -23,12 +23,11 @@ */ #ifndef WAVE_MAC_HELPER_H #define WAVE_MAC_HELPER_H -#include "ns3/qos-wifi-mac-helper.h" -#include "ns3/nqos-wifi-mac-helper.h" +#include "ns3/default-mac-helper.h" namespace ns3 { -class NqosWaveMacHelper : public NqosWifiMacHelper +class NqosWaveMacHelper : public WifiMacHelper { public: /** @@ -64,6 +63,12 @@ public: * \param v6 the value of the attribute to set * \param n7 the name of the attribute to set * \param v7 the value of the attribute to set + * \param n8 the value of the attribute to set + * \param v8 the value of the attribute to set + * \param n9 the value of the attribute to set + * \param v9 the value of the attribute to set + * \param n10 the value of the attribute to set + * \param v10 the value of the attribute to set * * All the attributes specified in this method should exist * in the requested mac. @@ -79,10 +84,13 @@ public: std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue (), + std::string n8 = "", const AttributeValue &v8 = EmptyAttributeValue (), + std::string n9 = "", const AttributeValue &v9 = EmptyAttributeValue (), + std::string n10 = "", const AttributeValue &v10 = EmptyAttributeValue ()); }; -class QosWaveMacHelper : public QosWifiMacHelper +class QosWaveMacHelper : public WifiMacHelper { public: /** @@ -119,6 +127,12 @@ public: * \param v6 the value of the attribute to set * \param n7 the name of the attribute to set * \param v7 the value of the attribute to set + * \param n8 the value of the attribute to set + * \param v8 the value of the attribute to set + * \param n9 the value of the attribute to set + * \param v9 the value of the attribute to set + * \param n10 the value of the attribute to set + * \param v10 the value of the attribute to set * * All the attributes specified in this method should exist * in the requested mac. @@ -134,7 +148,10 @@ public: std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue (), + std::string n8 = "", const AttributeValue &v8 = EmptyAttributeValue (), + std::string n9 = "", const AttributeValue &v9 = EmptyAttributeValue (), + std::string n10 = "", const AttributeValue &v10 = EmptyAttributeValue ()); }; } diff --git a/src/wave/test/ocb-test-suite.cc b/src/wave/test/ocb-test-suite.cc index 4fd28c336..e9ef2ddf0 100644 --- a/src/wave/test/ocb-test-suite.cc +++ b/src/wave/test/ocb-test-suite.cc @@ -30,7 +30,7 @@ #include "ns3/position-allocator.h" #include "ns3/packet-socket-helper.h" #include "ns3/mobility-helper.h" -#include "ns3/nqos-wifi-mac-helper.h" +#include "ns3/default-mac-helper.h" #include "ns3/wifi-net-device.h" #include "ns3/packet-socket-server.h" #include "ns3/packet-socket-client.h" @@ -198,12 +198,12 @@ OcbWifiMacTestCase::ConfigureApStaMode (Ptr static_node, Ptr mobile_ wifiPhy.SetChannel (wifiChannel.Create ()); Ssid ssid = Ssid ("wifi-default"); - NqosWifiMacHelper wifiStaMac = NqosWifiMacHelper::Default (); + WifiMacHelper wifiStaMac; wifiStaMac.SetType ("ns3::StaWifiMac", "Ssid", SsidValue (ssid)); - NqosWifiMacHelper wifiApMac = NqosWifiMacHelper::Default (); + WifiMacHelper wifiApMac; wifiApMac.SetType ("ns3::ApWifiMac","Ssid", SsidValue (ssid)); - WifiHelper wifi = WifiHelper::Default (); + WifiHelper wifi; wifi.SetStandard (WIFI_PHY_STANDARD_80211_10MHZ); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("OfdmRate6MbpsBW10MHz"), @@ -219,10 +219,10 @@ OcbWifiMacTestCase::ConfigureAdhocMode (Ptr static_node, Ptr mobile_ YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); wifiPhy.SetChannel (wifiChannel.Create ()); - NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + WifiMacHelper wifiMac; wifiMac.SetType ("ns3::AdhocWifiMac"); - WifiHelper wifi = WifiHelper::Default (); + WifiHelper wifi; wifi.SetStandard (WIFI_PHY_STANDARD_80211_10MHZ); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("OfdmRate6MbpsBW10MHz"), diff --git a/src/wifi/helper/ht-wifi-mac-helper.h b/src/wifi/helper/ht-wifi-mac-helper.h index 965bab7e0..2823f6661 100644 --- a/src/wifi/helper/ht-wifi-mac-helper.h +++ b/src/wifi/helper/ht-wifi-mac-helper.h @@ -27,6 +27,10 @@ #include "qos-wifi-mac-helper.h" #include +/** + * (Deprecated) ns3::HtWifiMacHelper declaration. + */ + namespace ns3 { /** diff --git a/src/wifi/helper/nqos-wifi-mac-helper.cc b/src/wifi/helper/nqos-wifi-mac-helper.cc index 7f3d47696..096ccaef0 100644 --- a/src/wifi/helper/nqos-wifi-mac-helper.cc +++ b/src/wifi/helper/nqos-wifi-mac-helper.cc @@ -55,7 +55,10 @@ NqosWifiMacHelper::SetType (std::string type, std::string n4, const AttributeValue &v4, std::string n5, const AttributeValue &v5, std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7) + std::string n7, const AttributeValue &v7, + std::string n8, const AttributeValue &v8, + std::string n9, const AttributeValue &v9, + std::string n10, const AttributeValue &v10) { m_mac.SetTypeId (type); m_mac.Set (n0, v0); @@ -66,6 +69,9 @@ NqosWifiMacHelper::SetType (std::string type, m_mac.Set (n5, v5); m_mac.Set (n6, v6); m_mac.Set (n7, v7); + m_mac.Set (n8, v8); + m_mac.Set (n9, v9); + m_mac.Set (n10, v10); } Ptr diff --git a/src/wifi/helper/nqos-wifi-mac-helper.h b/src/wifi/helper/nqos-wifi-mac-helper.h index fae02ca0c..02d80942b 100644 --- a/src/wifi/helper/nqos-wifi-mac-helper.h +++ b/src/wifi/helper/nqos-wifi-mac-helper.h @@ -23,6 +23,10 @@ #include "wifi-helper.h" +/** + * (Deprecated) ns3::NonQosWifiMacHelper declaration. + */ + namespace ns3 { /** @@ -68,6 +72,12 @@ public: * \param v6 the value of the attribute to set * \param n7 the name of the attribute to set * \param v7 the value of the attribute to set + * \param n8 the name of the attribute to set + * \param v8 the value of the attribute to set + * \param n9 the name of the attribute to set + * \param v9 the value of the attribute to set + * \param n10 the name of the attribute to set + * \param v10 the value of the attribute to set * * All the attributes specified in this method should exist * in the requested mac. @@ -80,7 +90,10 @@ public: std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue (), + std::string n8 = "", const AttributeValue &v8 = EmptyAttributeValue (), + std::string n9 = "", const AttributeValue &v9 = EmptyAttributeValue (), + std::string n10 = "", const AttributeValue &v10 = EmptyAttributeValue ()); protected: ObjectFactory m_mac; private: diff --git a/src/wifi/helper/qos-wifi-mac-helper.cc b/src/wifi/helper/qos-wifi-mac-helper.cc index 7170a1a60..8e1e0c0c3 100644 --- a/src/wifi/helper/qos-wifi-mac-helper.cc +++ b/src/wifi/helper/qos-wifi-mac-helper.cc @@ -20,12 +20,12 @@ #include "qos-wifi-mac-helper.h" #include "ns3/msdu-aggregator.h" +#include "ns3/mpdu-aggregator.h" #include "ns3/wifi-mac.h" #include "ns3/edca-txop-n.h" #include "ns3/pointer.h" #include "ns3/boolean.h" #include "ns3/uinteger.h" -#include "ns3/mpdu-aggregator.h" #include "ns3/mac-low.h" namespace ns3 { @@ -61,7 +61,10 @@ QosWifiMacHelper::SetType (std::string type, std::string n4, const AttributeValue &v4, std::string n5, const AttributeValue &v5, std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7) + std::string n7, const AttributeValue &v7, + std::string n8, const AttributeValue &v8, + std::string n9, const AttributeValue &v9, + std::string n10, const AttributeValue &v10) { m_mac.SetTypeId (type); m_mac.Set (n0, v0); @@ -72,6 +75,9 @@ QosWifiMacHelper::SetType (std::string type, m_mac.Set (n5, v5); m_mac.Set (n6, v6); m_mac.Set (n7, v7); + m_mac.Set (n8, v8); + m_mac.Set (n9, v9); + m_mac.Set (n10, v10); } void @@ -81,8 +87,8 @@ QosWifiMacHelper::SetMsduAggregatorForAc (AcIndex ac, std::string type, std::string n2, const AttributeValue &v2, std::string n3, const AttributeValue &v3) { - std::map::iterator it = m_aggregators.find (ac); - if (it != m_aggregators.end ()) + std::map::iterator it = m_msduAggregators.find (ac); + if (it != m_msduAggregators.end ()) { it->second.SetTypeId (type); it->second.Set (n0, v0); @@ -98,23 +104,36 @@ QosWifiMacHelper::SetMsduAggregatorForAc (AcIndex ac, std::string type, factory.Set (n1, v1); factory.Set (n2, v2); factory.Set (n3, v3); - m_aggregators.insert (std::make_pair (ac, factory)); + m_msduAggregators.insert (std::make_pair (ac, factory)); } } void -QosWifiMacHelper::SetMpduAggregatorForAc (enum AcIndex ac, std::string name, +QosWifiMacHelper::SetMpduAggregatorForAc (enum AcIndex ac, std::string type, std::string n0, const AttributeValue &v0, std::string n1, const AttributeValue &v1, std::string n2, const AttributeValue &v2, std::string n3, const AttributeValue &v3) { - m_mpduAggregator = ObjectFactory (); - m_mpduAggregator.SetTypeId (name); - m_mpduAggregator.Set (n0, v0); - m_mpduAggregator.Set (n1, v1); - m_mpduAggregator.Set (n2, v2); - m_mpduAggregator.Set (n3, v3); + std::map::iterator it = m_mpduAggregators.find (ac); + if (it != m_mpduAggregators.end ()) + { + it->second.SetTypeId (type); + it->second.Set (n0, v0); + it->second.Set (n1, v1); + it->second.Set (n2, v2); + it->second.Set (n3, v3); + } + else + { + ObjectFactory factory; + factory.SetTypeId (type); + factory.Set (n0, v0); + factory.Set (n1, v1); + factory.Set (n2, v2); + factory.Set (n3, v3); + m_mpduAggregators.insert (std::make_pair (ac, factory)); + } } void @@ -132,27 +151,31 @@ QosWifiMacHelper::SetBlockAckInactivityTimeoutForAc (enum AcIndex ac, uint16_t t void QosWifiMacHelper::Setup (Ptr mac, enum AcIndex ac, std::string dcaAttrName) const { - std::map::const_iterator it = m_aggregators.find (ac); PointerValue ptr; mac->GetAttribute (dcaAttrName, ptr); Ptr edca = ptr.Get (); - if (m_mpduAggregator.GetTypeId ().GetUid () != 0) + std::map::const_iterator it_msdu = m_msduAggregators.find (ac); + if (it_msdu != m_msduAggregators.end ()) { - Ptr mpduaggregator = m_mpduAggregator.Create (); - Ptr low = edca->Low (); - low->SetMpduAggregator (mpduaggregator); + ObjectFactory factory = it_msdu->second; + Ptr msduAggregator = factory.Create (); + edca->SetMsduAggregator (msduAggregator); } - if (it != m_aggregators.end ()) + + std::map::const_iterator it_mpdu = m_mpduAggregators.find (ac); + if (it_mpdu != m_mpduAggregators.end ()) { - ObjectFactory factory = it->second; - Ptr aggregator = factory.Create (); - edca->SetMsduAggregator (aggregator); + ObjectFactory factory = it_mpdu->second; + Ptr mpduAggregator = factory.Create (); + edca->SetMpduAggregator (mpduAggregator); } + if (m_bAckThresholds.find (ac) != m_bAckThresholds.end ()) { edca->SetBlockAckThreshold (m_bAckThresholds.find (ac)->second); } + if (m_bAckInactivityTimeouts.find (ac) != m_bAckInactivityTimeouts.end ()) { edca->SetBlockAckInactivityTimeout (m_bAckInactivityTimeouts.find (ac)->second); diff --git a/src/wifi/helper/qos-wifi-mac-helper.h b/src/wifi/helper/qos-wifi-mac-helper.h index b5aaf0c17..8fec68e44 100644 --- a/src/wifi/helper/qos-wifi-mac-helper.h +++ b/src/wifi/helper/qos-wifi-mac-helper.h @@ -26,6 +26,10 @@ #include +/** + * (Deprecated) ns3::QosWifiMacHelper declaration. + */ + namespace ns3 { /** @@ -73,6 +77,12 @@ public: * \param v6 the value of the attribute to set * \param n7 the name of the attribute to set * \param v7 the value of the attribute to set + * \param n8 the name of the attribute to set + * \param v8 the value of the attribute to set + * \param n9 the name of the attribute to set + * \param v9 the value of the attribute to set + * \param n10 the name of the attribute to set + * \param v10 the value of the attribute to set * * All the attributes specified in this method should exist * in the requested mac. @@ -85,7 +95,10 @@ public: std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue (), + std::string n8 = "", const AttributeValue &v8 = EmptyAttributeValue (), + std::string n9 = "", const AttributeValue &v9 = EmptyAttributeValue (), + std::string n10 = "", const AttributeValue &v10 = EmptyAttributeValue ()); /** * Set the class, type and attributes for the Msdu aggregator * @@ -169,8 +182,8 @@ private: virtual Ptr Create (void) const; void Setup (Ptr mac, enum AcIndex ac, std::string dcaAttrName) const; - std::map m_aggregators; - ObjectFactory m_mpduAggregator; + std::map m_msduAggregators; + std::map m_mpduAggregators; /* * Next maps contain, for every access category, the values for * block ack threshold and block ack inactivity timeout. diff --git a/src/wifi/helper/vht-wifi-mac-helper.h b/src/wifi/helper/vht-wifi-mac-helper.h index 449dca90f..7ed34a1cb 100644 --- a/src/wifi/helper/vht-wifi-mac-helper.h +++ b/src/wifi/helper/vht-wifi-mac-helper.h @@ -27,6 +27,10 @@ #include "qos-wifi-mac-helper.h" #include +/** + * (Deprecated) ns3::VhtWifiMacHelper declaration. + */ + namespace ns3 { /** diff --git a/src/wifi/helper/wifi-helper.cc b/src/wifi/helper/wifi-helper.cc index a69a4917d..00e0d7634 100644 --- a/src/wifi/helper/wifi-helper.cc +++ b/src/wifi/helper/wifi-helper.cc @@ -49,10 +49,6 @@ WifiPhyHelper::~WifiPhyHelper () { } -WifiMacHelper::~WifiMacHelper () -{ -} - WifiHelper::~WifiHelper () { } @@ -60,6 +56,7 @@ WifiHelper::~WifiHelper () WifiHelper::WifiHelper () : m_standard (WIFI_PHY_STANDARD_80211a) { + SetRemoteStationManager ("ns3::ArfWifiManager"); } WifiHelper diff --git a/src/wifi/helper/wifi-helper.h b/src/wifi/helper/wifi-helper.h index e6fa0946f..1aa668dcb 100644 --- a/src/wifi/helper/wifi-helper.h +++ b/src/wifi/helper/wifi-helper.h @@ -30,11 +30,11 @@ #include "ns3/net-device-container.h" #include "ns3/wifi-phy-standard.h" #include "ns3/trace-helper.h" +#include "ns3/wifi-mac-helper.h" namespace ns3 { class WifiPhy; -class WifiMac; class WifiNetDevice; class Node; @@ -66,26 +66,6 @@ public: }; -/** - * \brief create MAC objects - * - * This base class must be implemented by new MAC implementation which wish to integrate - * with the \ref ns3::WifiHelper class. - */ -class WifiMacHelper -{ -public: - virtual ~WifiMacHelper (); - /** - * \returns a new MAC object. - * - * Subclasses must implement this method to allow the ns3::WifiHelper class - * to create MAC objects from ns3::WifiHelper::Install. - */ - virtual Ptr Create (void) const = 0; -}; - - /** * \brief helps to create WifiNetDevice objects * @@ -101,6 +81,10 @@ public: /** * Create a Wifi helper in an empty state: all its parameters * must be set before calling ns3::WifiHelper::Install + * + * The default state is defined as being an Adhoc MAC layer with an ARF rate control algorithm + * and both objects using their default attribute values. + * By default, configure MAC and PHY for 802.11a. */ WifiHelper (); @@ -110,8 +94,11 @@ public: * The default state is defined as being an Adhoc MAC layer with an ARF rate control algorithm * and both objects using their default attribute values. By default, configure MAC and PHY * for 802.11a. + * + * \deprecated This method will go away in future versions of ns-3. + * The constructor of the class is now performing the same job, which makes this function useless. */ - static WifiHelper Default (void); + static WifiHelper Default (void) NS_DEPRECATED; /** * \param type the type of ns3::WifiRemoteStationManager to create. diff --git a/src/wifi/helper/wifi-mac-helper.cc b/src/wifi/helper/wifi-mac-helper.cc new file mode 100644 index 000000000..aef70e1ad --- /dev/null +++ b/src/wifi/helper/wifi-mac-helper.cc @@ -0,0 +1,75 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2016 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Sébastien Deronne + */ + +#include "wifi-mac-helper.h" +#include "ns3/wifi-mac.h" +#include "ns3/pointer.h" +#include "ns3/boolean.h" +#include "ns3/dca-txop.h" + +namespace ns3 { + +WifiMacHelper::WifiMacHelper () +{ + //By default, we create an AdHoc MAC layer without QoS. + SetType ("ns3::AdhocWifiMac", + "QosSupported", BooleanValue (false)); +} + +WifiMacHelper::~WifiMacHelper () +{ +} + +void +WifiMacHelper::SetType (std::string type, + std::string n0, const AttributeValue &v0, + std::string n1, const AttributeValue &v1, + std::string n2, const AttributeValue &v2, + std::string n3, const AttributeValue &v3, + std::string n4, const AttributeValue &v4, + std::string n5, const AttributeValue &v5, + std::string n6, const AttributeValue &v6, + std::string n7, const AttributeValue &v7, + std::string n8, const AttributeValue &v8, + std::string n9, const AttributeValue &v9, + std::string n10, const AttributeValue &v10) +{ + m_mac.SetTypeId (type); + m_mac.Set (n0, v0); + m_mac.Set (n1, v1); + m_mac.Set (n2, v2); + m_mac.Set (n3, v3); + m_mac.Set (n4, v4); + m_mac.Set (n5, v5); + m_mac.Set (n6, v6); + m_mac.Set (n7, v7); + m_mac.Set (n8, v8); + m_mac.Set (n9, v9); + m_mac.Set (n10, v10); +} + +Ptr +WifiMacHelper::Create (void) const +{ + Ptr mac = m_mac.Create (); + return mac; +} + +} //namespace ns3 diff --git a/src/wifi/helper/wifi-mac-helper.h b/src/wifi/helper/wifi-mac-helper.h new file mode 100644 index 000000000..afe318649 --- /dev/null +++ b/src/wifi/helper/wifi-mac-helper.h @@ -0,0 +1,121 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2016 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Sébastien Deronne + */ + +#ifndef WIFI_MAC_HELPER_H +#define WIFI_MAC_HELPER_H + +#include +#include "ns3/attribute.h" +#include "ns3/object-factory.h" + +namespace ns3 { + +class WifiMac; + +/** + * \brief create MAC layers for a ns3::WifiNetDevice. + * + * This class can create MACs of type ns3::ApWifiMac, ns3::StaWifiMac and ns3::AdhocWifiMac. + * Its purpose is to allow a WifiHelper to configure and install WifiMac objects on a collection + * of nodes. The WifiMac objects themselves are mainly composed of TxMiddle, RxMiddle, DcfManager, + * MacLow, WifiRemoteStationManager, MpduAggregator and MsduAggregartor objects, so this helper + * offers the opportunity to configure attribute values away from their default values, on a + * per-NodeContainer basis. By default, it creates an Adhoc MAC layer without QoS. Typically, + * it is used to set type and attribute values, then hand this object over to the WifiHelper that + * finishes the job of installing. + * + * This class is a merge of two previous helpers (ns3::NqosWifiMacHelper and ns::3 QosWifiMacHelper) + * that Mirko Banchi (mk.banchi@gmail.com) originally contributed. + * It should now be used instead of those two deprecated helpers. + * + * This class may be further subclassed (WaveMacHelper is an example of this). + * + */ +class WifiMacHelper +{ +public: + /** + * Create a WifiMacHelper to make life easier for people who want to + * work with Wifi MAC layers. + */ + WifiMacHelper (); + /** + * Destroy a WifiMacHelper. + */ + virtual ~WifiMacHelper (); + + /** + * \param type the type of ns3::WifiMac to create. + * Valid values of the type field must be a type subclassed from WifiMac. + * + * \param n0 the name of the attribute to set + * \param v0 the value of the attribute to set + * \param n1 the name of the attribute to set + * \param v1 the value of the attribute to set + * \param n2 the name of the attribute to set + * \param v2 the value of the attribute to set + * \param n3 the name of the attribute to set + * \param v3 the value of the attribute to set + * \param n4 the name of the attribute to set + * \param v4 the value of the attribute to set + * \param n5 the name of the attribute to set + * \param v5 the value of the attribute to set + * \param n6 the name of the attribute to set + * \param v6 the value of the attribute to set + * \param n7 the name of the attribute to set + * \param v7 the value of the attribute to set + * \param n8 the name of the attribute to set + * \param v8 the value of the attribute to set + * \param n9 the name of the attribute to set + * \param v9 the value of the attribute to set + * \param n10 the name of the attribute to set + * \param v10 the value of the attribute to set + * + * All the attributes specified in this method should exist + * in the requested mac. + */ + virtual void SetType (std::string type, + std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), + std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), + std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), + std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), + std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), + std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), + std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), + std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue (), + std::string n8 = "", const AttributeValue &v8 = EmptyAttributeValue (), + std::string n9 = "", const AttributeValue &v9 = EmptyAttributeValue (), + std::string n10 = "", const AttributeValue &v10 = EmptyAttributeValue ()); + + /** + * \returns a new MAC object. + * + * This allows the ns3::WifiHelper class to create MAC objects from ns3::WifiHelper::Install. + */ + virtual Ptr Create (void) const; + + +protected: + ObjectFactory m_mac; +}; + +} // namespace ns3 + +#endif /* WIFI_MAC_HELPER_H */ diff --git a/src/wifi/model/edca-txop-n.cc b/src/wifi/model/edca-txop-n.cc index 08aad37d9..09a33b3c2 100644 --- a/src/wifi/model/edca-txop-n.cc +++ b/src/wifi/model/edca-txop-n.cc @@ -32,6 +32,7 @@ #include "random-stream.h" #include "wifi-mac-queue.h" #include "msdu-aggregator.h" +#include "mpdu-aggregator.h" #include "mgt-headers.h" #include "qos-blocked-destinations.h" @@ -203,6 +204,10 @@ public: { return m_txop->GetMsduAggregator (); } + virtual Ptr GetMpduAggregator (void) const + { + return m_txop->GetMpduAggregator (); + } virtual Mac48Address GetSrcAddressForAggregation (const WifiMacHeader &hdr) { return m_txop->MapSrcAddressForAggregation (hdr); @@ -225,21 +230,6 @@ EdcaTxopN::GetTypeId (void) .SetParent () .SetGroupName ("Wifi") .AddConstructor () - .AddAttribute ("BlockAckThreshold", - "If number of packets in this queue reaches this value, " - "block ack mechanism is used. If this value is 0, block ack is never used.", - UintegerValue (0), - MakeUintegerAccessor (&EdcaTxopN::SetBlockAckThreshold, - &EdcaTxopN::GetBlockAckThreshold), - MakeUintegerChecker (0, 64)) - .AddAttribute ("BlockAckInactivityTimeout", - "Represents max time (blocks of 1024 micro seconds) allowed for block ack" - "inactivity. If this value isn't equal to 0 a timer start after that a" - "block ack setup is completed and will be reset every time that a block" - "ack frame is received. If this value is 0, block ack inactivity timeout won't be used.", - UintegerValue (0), - MakeUintegerAccessor (&EdcaTxopN::SetBlockAckInactivityTimeout), - MakeUintegerChecker ()) .AddAttribute ("Queue", "The WifiMacQueue object", PointerValue (), @@ -252,7 +242,8 @@ EdcaTxopN::GetTypeId (void) EdcaTxopN::EdcaTxopN () : m_manager (0), m_currentPacket (0), - m_aggregator (0), + m_msduAggregator (0), + m_mpduAggregator (0), m_typeOfStation (STA), m_blockAckType (COMPRESSED_BLOCK_ACK), m_ampduExist (false) @@ -299,7 +290,8 @@ EdcaTxopN::DoDispose (void) m_baManager = 0; m_blockAckListener = 0; m_txMiddle = 0; - m_aggregator = 0; + m_msduAggregator = 0; + m_mpduAggregator = 0; } bool @@ -495,7 +487,6 @@ EdcaTxopN::NotifyAccessGranted (void) return; } if (m_currentHdr.IsQosData () && !m_currentHdr.GetAddr1 ().IsBroadcast () - && m_blockAckThreshold > 0 && !m_baManager->ExistsAgreement (m_currentHdr.GetAddr1 (), m_currentHdr.GetQosTid ()) && SetupBlockAckIfNeeded ()) { @@ -578,11 +569,11 @@ EdcaTxopN::NotifyAccessGranted (void) && m_queue->PeekByTidAndAddress (&peekedHdr, m_currentHdr.GetQosTid (), WifiMacHeader::ADDR1, m_currentHdr.GetAddr1 (), &tstamp) && !m_currentHdr.GetAddr1 ().IsBroadcast () - && m_aggregator != 0 && !m_currentHdr.IsRetry ()) + && m_msduAggregator != 0 && !m_currentHdr.IsRetry ()) { /* here is performed aggregation */ Ptr currentAggregatedPacket = Create (); - m_aggregator->Aggregate (m_currentPacket, currentAggregatedPacket, + m_msduAggregator->Aggregate (m_currentPacket, currentAggregatedPacket, MapSrcAddressForAggregation (peekedHdr), MapDestAddressForAggregation (peekedHdr)); bool aggregated = false; @@ -592,7 +583,7 @@ EdcaTxopN::NotifyAccessGranted (void) m_currentHdr.GetAddr1 (), &tstamp); while (peekedPacket != 0) { - aggregated = m_aggregator->Aggregate (peekedPacket, currentAggregatedPacket, + aggregated = m_msduAggregator->Aggregate (peekedPacket, currentAggregatedPacket, MapSrcAddressForAggregation (peekedHdr), MapDestAddressForAggregation (peekedHdr)); if (aggregated) @@ -944,7 +935,13 @@ EdcaTxopN::MissedBlockAck (void) Ptr EdcaTxopN::GetMsduAggregator (void) const { - return m_aggregator; + return m_msduAggregator; +} + +Ptr +EdcaTxopN::GetMpduAggregator (void) const +{ + return m_mpduAggregator; } void @@ -1168,7 +1165,14 @@ void EdcaTxopN::SetMsduAggregator (Ptr aggr) { NS_LOG_FUNCTION (this << aggr); - m_aggregator = aggr; + m_msduAggregator = aggr; +} + +void +EdcaTxopN::SetMpduAggregator (Ptr aggr) +{ + NS_LOG_FUNCTION (this << aggr); + m_mpduAggregator = aggr; } void @@ -1240,7 +1244,7 @@ EdcaTxopN::VerifyBlockAck (void) { m_baManager->SwitchToBlockAckIfNeeded (recipient, tid, sequence); } - if ((m_baManager->ExistsAgreementInState (recipient, tid, OriginatorBlockAckAgreement::ESTABLISHED)) && (m_low->GetMpduAggregator () == 0)) + if ((m_baManager->ExistsAgreementInState (recipient, tid, OriginatorBlockAckAgreement::ESTABLISHED)) && (GetMpduAggregator () == 0)) { m_currentHdr.SetQosAckPolicy (WifiMacHeader::BLOCK_ACK); } @@ -1291,7 +1295,7 @@ EdcaTxopN::SetupBlockAckIfNeeded () uint32_t packets = m_queue->GetNPacketsByTidAndAddress (tid, WifiMacHeader::ADDR1, recipient); - if (packets >= m_blockAckThreshold) + if ((m_blockAckThreshold > 0 && packets >= m_blockAckThreshold) || (packets > 1 && m_mpduAggregator != 0) || m_stationManager->HasVhtSupported ()) { /* Block ack setup */ uint16_t startingSequence = m_txMiddle->GetNextSeqNumberByTidAndAddress (tid, recipient); diff --git a/src/wifi/model/edca-txop-n.h b/src/wifi/model/edca-txop-n.h index f6072c1ff..b5bb3191e 100644 --- a/src/wifi/model/edca-txop-n.h +++ b/src/wifi/model/edca-txop-n.h @@ -47,6 +47,7 @@ class WifiMacQueue; class RandomStream; class QosBlockedDestinations; class MsduAggregator; +class MpduAggregator; class MgtAddBaResponseHeader; class BlockAckManager; class MgtDelBaHeader; @@ -161,6 +162,8 @@ public: Ptr Low (void); Ptr GetMsduAggregator (void) const; + Ptr GetMpduAggregator (void) const; + /** * \param recipient address of the peer station * \param tid traffic ID. @@ -372,6 +375,7 @@ public: void Queue (Ptr packet, const WifiMacHeader &hdr); void SetMsduAggregator (Ptr aggr); + void SetMpduAggregator (Ptr aggr); /** * \param packet packet to send @@ -536,7 +540,8 @@ private: Ptr m_currentPacket; WifiMacHeader m_currentHdr; - Ptr m_aggregator; + Ptr m_msduAggregator; + Ptr m_mpduAggregator; TypeOfStation m_typeOfStation; QosBlockedDestinations *m_qosBlockedDestinations; BlockAckManager *m_baManager; diff --git a/src/wifi/model/mac-low.cc b/src/wifi/model/mac-low.cc index 450ee9cc3..326df31c2 100644 --- a/src/wifi/model/mac-low.cc +++ b/src/wifi/model/mac-low.cc @@ -36,7 +36,6 @@ #include "yans-wifi-phy.h" #include "ampdu-tag.h" #include "wifi-mac-queue.h" -#include "mpdu-standard-aggregator.h" #undef NS_LOG_APPEND_CONTEXT #define NS_LOG_APPEND_CONTEXT std::clog << "[mac=" << m_self << "] " @@ -117,6 +116,11 @@ MacLowAggregationCapableTransmissionListener::GetMsduAggregator (void) const { return 0; } +Ptr +MacLowAggregationCapableTransmissionListener::GetMpduAggregator (void) const +{ + return 0; +} Mac48Address MacLowAggregationCapableTransmissionListener::GetSrcAddressForAggregation (const WifiMacHeader &hdr) { @@ -360,7 +364,6 @@ MacLow::MacLow () m_sendDataEvent (), m_waitSifsEvent (), m_endTxNoAckEvent (), - m_mpduAggregator (0), m_currentPacket (0), m_listener (0), m_phyMacLowListener (0), @@ -434,7 +437,6 @@ MacLow::DoDispose (void) delete m_phyMacLowListener; m_phyMacLowListener = 0; } - m_mpduAggregator = 0; m_sentMpdus = 0; m_aggregateQueue = 0; m_ampdu = false; @@ -1640,7 +1642,11 @@ MacLow::ForwardDown (Ptr packet, const WifiMacHeader* hdr, last = true; mpdutype = LAST_MPDU_IN_AGGREGATE; } - m_mpduAggregator->AddHeaderAndPad (newPacket, last, vhtSingleMpdu); + + uint8_t tid = GetTid (packet, *hdr); + AcIndex ac = QosUtilsMapTidToAc (tid); + std::map::const_iterator listenerIt = m_edcaListeners.find (ac); + listenerIt->second->GetMpduAggregator ()->AddHeaderAndPad (newPacket, last, vhtSingleMpdu); if (hdr->IsBlockAckReq ()) { @@ -2725,18 +2731,6 @@ MacLow::RegisterBlockAckListenerForAc (enum AcIndex ac, MacLowAggregationCapable m_edcaListeners.insert (std::make_pair (ac, listener)); } -void -MacLow::SetMpduAggregator (Ptr aggregator) -{ - m_mpduAggregator = aggregator; -} - -Ptr -MacLow::GetMpduAggregator (void) -{ - return m_mpduAggregator; -} - void MacLow::DeaggregateAmpduAndReceive (Ptr aggregatedPacket, double rxSnr, WifiTxVector txVector, WifiPreamble preamble) { @@ -2826,6 +2820,11 @@ MacLow::StopMpduAggregation (Ptr peekedPacket, WifiMacHeader peeke { WifiPreamble preamble; WifiTxVector dataTxVector = GetDataTxVector (m_currentPacket, &m_currentHdr); + + uint8_t tid = GetTid (peekedPacket, peekedHdr); + AcIndex ac = QosUtilsMapTidToAc (tid); + std::map::const_iterator listenerIt = m_edcaListeners.find (ac); + if (dataTxVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_VHT) { preamble = WIFI_PREAMBLE_VHT; @@ -2860,7 +2859,7 @@ MacLow::StopMpduAggregation (Ptr peekedPacket, WifiMacHeader peeke return true; } - if (!m_mpduAggregator->CanBeAggregated (peekedPacket->GetSize () + peekedHdr.GetSize () + WIFI_MAC_FCS_LENGTH, aggregatedPacket, size)) + if (!listenerIt->second->GetMpduAggregator ()->CanBeAggregated (peekedPacket->GetSize () + peekedHdr.GetSize () + WIFI_MAC_FCS_LENGTH, aggregatedPacket, size)) { NS_LOG_DEBUG ("no more packets can be aggregated because the maximum A-MPDU size has been reached"); return true; @@ -2890,7 +2889,7 @@ MacLow::AggregateToAmpdu (Ptr packet, const WifiMacHeader hdr) NS_ASSERT (listenerIt != m_edcaListeners.end ()); queue = listenerIt->second->GetQueue (); - if (!hdr.GetAddr1 ().IsBroadcast () && m_mpduAggregator != 0) + if (!hdr.GetAddr1 ().IsBroadcast () && listenerIt->second->GetMpduAggregator () != 0) { //Have to make sure that their exist a block Ack agreement before sending an AMPDU (BlockAck Manager) if (listenerIt->second->GetBlockAckAgreementExists (hdr.GetAddr1 (), tid)) @@ -2919,7 +2918,7 @@ MacLow::AggregateToAmpdu (Ptr packet, const WifiMacHeader hdr) WifiMacTrailer fcs; newPacket->AddTrailer (fcs); - aggregated = m_mpduAggregator->Aggregate (newPacket, currentAggregatedPacket); + aggregated = listenerIt->second->GetMpduAggregator ()->Aggregate (newPacket, currentAggregatedPacket); if (aggregated) { @@ -2990,7 +2989,7 @@ MacLow::AggregateToAmpdu (Ptr packet, const WifiMacHeader hdr) newPacket->AddHeader (peekedHdr); WifiMacTrailer fcs; newPacket->AddTrailer (fcs); - aggregated = m_mpduAggregator->Aggregate (newPacket, currentAggregatedPacket); + aggregated = listenerIt->second->GetMpduAggregator ()->Aggregate (newPacket, currentAggregatedPacket); if (aggregated) { m_aggregateQueue->Enqueue (aggPacket, peekedHdr); @@ -3092,7 +3091,7 @@ MacLow::AggregateToAmpdu (Ptr packet, const WifiMacHeader hdr) newPacket->AddHeader (peekedHdr); WifiMacTrailer fcs; newPacket->AddTrailer (fcs); - m_mpduAggregator->Aggregate (newPacket, currentAggregatedPacket); + listenerIt->second->GetMpduAggregator ()->Aggregate (newPacket, currentAggregatedPacket); } if (qosPolicy == 0) { @@ -3126,7 +3125,7 @@ MacLow::AggregateToAmpdu (Ptr packet, const WifiMacHeader hdr) peekedHdr.SetQosAckPolicy (WifiMacHeader::NORMAL_ACK); currentAggregatedPacket = Create (); - m_mpduAggregator->AggregateVhtSingleMpdu (packet, currentAggregatedPacket); + listenerIt->second->GetMpduAggregator ()->AggregateVhtSingleMpdu (packet, currentAggregatedPacket); m_aggregateQueue->Enqueue (packet, peekedHdr); m_sentMpdus = 1; diff --git a/src/wifi/model/mac-low.h b/src/wifi/model/mac-low.h index 84ec1300d..c06c4d4a4 100644 --- a/src/wifi/model/mac-low.h +++ b/src/wifi/model/mac-low.h @@ -278,6 +278,9 @@ public: /** */ virtual Ptr GetMsduAggregator (void) const; + /** + */ + virtual Ptr GetMpduAggregator (void) const; /** */ virtual Mac48Address GetSrcAddressForAggregation (const WifiMacHeader &hdr); @@ -524,17 +527,6 @@ public: * \param manager WifiRemoteStationManager associated with this MacLow */ void SetWifiRemoteStationManager (Ptr manager); - /** - * Set up MpduAggregator associated with this MacLow. - * - * \param aggregator MpduAggregator associated with this MacLow - */ - void SetMpduAggregator (Ptr aggregator); - /** - * - * \return the attached MpduAggregator - */ - Ptr GetMpduAggregator (void); /** * Set MAC address of this MacLow. * diff --git a/src/wifi/model/mpdu-aggregator.h b/src/wifi/model/mpdu-aggregator.h index 9029caa2f..25844a4e9 100644 --- a/src/wifi/model/mpdu-aggregator.h +++ b/src/wifi/model/mpdu-aggregator.h @@ -48,6 +48,9 @@ public: typedef std::list, AmpduSubframeHeader> >::const_iterator DeaggregatedMpdusCI; static TypeId GetTypeId (void); + + virtual void SetMaxAmpduSize (uint32_t maxSize) = 0; + virtual uint32_t GetMaxAmpduSize (void) const = 0; /** * \param packet Packet we have to insert into aggregatedPacket. * \param aggregatedPacket Packet that will contain packet, if aggregation is possible. diff --git a/src/wifi/model/mpdu-standard-aggregator.cc b/src/wifi/model/mpdu-standard-aggregator.cc index c64260b7e..a4400945b 100644 --- a/src/wifi/model/mpdu-standard-aggregator.cc +++ b/src/wifi/model/mpdu-standard-aggregator.cc @@ -36,7 +36,7 @@ MpduStandardAggregator::GetTypeId (void) .SetParent () .SetGroupName ("Wifi") .AddConstructor () - .AddAttribute ("MaxAmpduSize", "Max length in bytes of an A-MPDU", + .AddAttribute ("MaxAmpduSize", "Max length in bytes of an A-MPDU (Deprecated!)", UintegerValue (65535), MakeUintegerAccessor (&MpduStandardAggregator::m_maxAmpduLength), MakeUintegerChecker ()) @@ -52,6 +52,18 @@ MpduStandardAggregator::~MpduStandardAggregator () { } +void +MpduStandardAggregator::SetMaxAmpduSize (uint32_t maxSize) +{ + m_maxAmpduLength = maxSize; +} + +uint32_t +MpduStandardAggregator::GetMaxAmpduSize (void) const +{ + return m_maxAmpduLength; +} + bool MpduStandardAggregator::Aggregate (Ptr packet, Ptr aggregatedPacket) { diff --git a/src/wifi/model/mpdu-standard-aggregator.h b/src/wifi/model/mpdu-standard-aggregator.h index a0928785b..5480807e0 100644 --- a/src/wifi/model/mpdu-standard-aggregator.h +++ b/src/wifi/model/mpdu-standard-aggregator.h @@ -36,6 +36,9 @@ public: static TypeId GetTypeId (void); MpduStandardAggregator (); ~MpduStandardAggregator (); + + virtual void SetMaxAmpduSize (uint32_t maxSize); + virtual uint32_t GetMaxAmpduSize (void) const; /** * \param packet packet we have to insert into aggregatedPacket. * \param aggregatedPacket packet that will contain packet, if aggregation is possible. diff --git a/src/wifi/model/msdu-aggregator.h b/src/wifi/model/msdu-aggregator.h index 102718ce8..524b6336c 100644 --- a/src/wifi/model/msdu-aggregator.h +++ b/src/wifi/model/msdu-aggregator.h @@ -42,6 +42,10 @@ public: typedef std::list, AmsduSubframeHeader> >::const_iterator DeaggregatedMsdusCI; static TypeId GetTypeId (void); + + virtual void SetMaxAmsduSize (uint32_t maxSize) = 0; + virtual uint32_t GetMaxAmsduSize (void) const = 0; + /* Adds packet to aggregatedPacket. In concrete aggregator's implementation is * specified how and if packet can be added to aggregatedPacket. If packet * can be added returns true, false otherwise. diff --git a/src/wifi/model/msdu-standard-aggregator.cc b/src/wifi/model/msdu-standard-aggregator.cc index 5af479f3c..630681513 100644 --- a/src/wifi/model/msdu-standard-aggregator.cc +++ b/src/wifi/model/msdu-standard-aggregator.cc @@ -36,7 +36,7 @@ MsduStandardAggregator::GetTypeId (void) .SetParent () .SetGroupName ("Wifi") .AddConstructor () - .AddAttribute ("MaxAmsduSize", "Max length in byte of an A-MSDU", + .AddAttribute ("MaxAmsduSize", "Max length in byte of an A-MSDU (Deprecated!)", UintegerValue (7935), MakeUintegerAccessor (&MsduStandardAggregator::m_maxAmsduLength), MakeUintegerChecker ()) @@ -52,6 +52,18 @@ MsduStandardAggregator::~MsduStandardAggregator () { } +void +MsduStandardAggregator::SetMaxAmsduSize (uint32_t maxSize) +{ + m_maxAmsduLength = maxSize; +} + +uint32_t +MsduStandardAggregator::GetMaxAmsduSize (void) const +{ + return m_maxAmsduLength; +} + bool MsduStandardAggregator::Aggregate (Ptr packet, Ptr aggregatedPacket, Mac48Address src, Mac48Address dest) diff --git a/src/wifi/model/msdu-standard-aggregator.h b/src/wifi/model/msdu-standard-aggregator.h index 852e83b60..bb99b381b 100644 --- a/src/wifi/model/msdu-standard-aggregator.h +++ b/src/wifi/model/msdu-standard-aggregator.h @@ -36,6 +36,9 @@ public: static TypeId GetTypeId (void); MsduStandardAggregator (); ~MsduStandardAggregator (); + + virtual void SetMaxAmsduSize (uint32_t maxSize); + virtual uint32_t GetMaxAmsduSize (void) const; /** * \param packet Packet we have to insert into aggregatedPacket. * \param aggregatedPacket Packet that will contain packet, if aggregation is possible, diff --git a/src/wifi/model/regular-wifi-mac.cc b/src/wifi/model/regular-wifi-mac.cc index a028a62ab..27bb9430b 100644 --- a/src/wifi/model/regular-wifi-mac.cc +++ b/src/wifi/model/regular-wifi-mac.cc @@ -30,7 +30,8 @@ #include "dcf.h" #include "dcf-manager.h" #include "wifi-phy.h" -#include "msdu-aggregator.h" +#include "msdu-standard-aggregator.h" +#include "mpdu-standard-aggregator.h" namespace ns3 { @@ -136,6 +137,126 @@ RegularWifiMac::GetWifiRemoteStationManager () const return m_stationManager; } +void +RegularWifiMac::SetVoMaxAmsduSize (uint32_t size) +{ + NS_LOG_FUNCTION (this << size); + m_voMaxAmsduSize = size; + ConfigureAggregation (); +} + +void +RegularWifiMac::SetViMaxAmsduSize (uint32_t size) +{ + NS_LOG_FUNCTION (this << size); + m_viMaxAmsduSize = size; + ConfigureAggregation (); +} + +void +RegularWifiMac::SetBeMaxAmsduSize (uint32_t size) +{ + NS_LOG_FUNCTION (this << size); + m_beMaxAmsduSize = size; + ConfigureAggregation (); +} + +void +RegularWifiMac::SetBkMaxAmsduSize (uint32_t size) +{ + NS_LOG_FUNCTION (this << size); + m_bkMaxAmsduSize = size; + ConfigureAggregation (); +} + +void +RegularWifiMac::SetVoMaxAmpduSize (uint32_t size) +{ + NS_LOG_FUNCTION (this << size); + m_voMaxAmpduSize = size; + ConfigureAggregation (); +} + +void +RegularWifiMac::SetViMaxAmpduSize (uint32_t size) +{ + NS_LOG_FUNCTION (this << size); + m_viMaxAmpduSize = size; + ConfigureAggregation (); +} + +void +RegularWifiMac::SetBeMaxAmpduSize (uint32_t size) +{ + NS_LOG_FUNCTION (this << size); + m_beMaxAmpduSize = size; + ConfigureAggregation (); +} + +void +RegularWifiMac::SetBkMaxAmpduSize (uint32_t size) +{ + NS_LOG_FUNCTION (this << size); + m_bkMaxAmpduSize = size; + ConfigureAggregation (); +} + +void +RegularWifiMac::SetVoBlockAckThreshold (uint8_t threshold) +{ + NS_LOG_FUNCTION (this << threshold); + GetVOQueue ()->SetBlockAckThreshold (threshold); +} + +void +RegularWifiMac::SetViBlockAckThreshold (uint8_t threshold) +{ + NS_LOG_FUNCTION (this << threshold); + GetVIQueue ()->SetBlockAckThreshold (threshold); +} + +void +RegularWifiMac::SetBeBlockAckThreshold (uint8_t threshold) +{ + NS_LOG_FUNCTION (this << threshold); + GetBEQueue ()->SetBlockAckThreshold (threshold); +} + +void +RegularWifiMac::SetBkBlockAckThreshold (uint8_t threshold) +{ + NS_LOG_FUNCTION (this << threshold); + GetBKQueue ()->SetBlockAckThreshold (threshold); +} + +void +RegularWifiMac::SetVoBlockAckInactivityTimeout (uint16_t timeout) +{ + NS_LOG_FUNCTION (this << timeout); + GetVOQueue ()->SetBlockAckInactivityTimeout (timeout); +} + +void +RegularWifiMac::SetViBlockAckInactivityTimeout (uint16_t timeout) +{ + NS_LOG_FUNCTION (this << timeout); + GetVIQueue ()->SetBlockAckInactivityTimeout (timeout); +} + +void +RegularWifiMac::SetBeBlockAckInactivityTimeout (uint16_t timeout) +{ + NS_LOG_FUNCTION (this << timeout); + GetBEQueue ()->SetBlockAckInactivityTimeout (timeout); +} + +void +RegularWifiMac::SetBkBlockAckInactivityTimeout (uint16_t timeout) +{ + NS_LOG_FUNCTION (this << timeout); + GetBKQueue ()->SetBlockAckInactivityTimeout (timeout); +} + void RegularWifiMac::SetupEdcaQueue (enum AcIndex ac) { @@ -153,6 +274,7 @@ RegularWifiMac::SetupEdcaQueue (enum AcIndex ac) edca->SetTxFailedCallback (MakeCallback (&RegularWifiMac::TxFailed, this)); edca->SetAccessCategory (ac); edca->CompleteConfig (); + m_edca.insert (std::make_pair (ac, edca)); } @@ -245,7 +367,7 @@ RegularWifiMac::SetLinkDownCallback (Callback linkDown) void RegularWifiMac::SetQosSupported (bool enable) { - NS_LOG_FUNCTION (this); + NS_LOG_FUNCTION (this << enable); m_qosSupported = enable; } @@ -258,8 +380,20 @@ RegularWifiMac::GetQosSupported () const void RegularWifiMac::SetHtSupported (bool enable) { - NS_LOG_FUNCTION (this); + NS_LOG_FUNCTION (this << enable); m_htSupported = enable; + if (enable) + { + SetQosSupported (true); + } + if (!enable && !m_vhtSupported) + { + DisableAggregation (); + } + else + { + EnableAggregation (); + } } bool @@ -271,8 +405,20 @@ RegularWifiMac::GetVhtSupported () const void RegularWifiMac::SetVhtSupported (bool enable) { - NS_LOG_FUNCTION (this); + NS_LOG_FUNCTION (this << enable); m_vhtSupported = enable; + if (enable) + { + SetQosSupported (true); + } + if (!enable && !m_htSupported) + { + DisableAggregation (); + } + else + { + EnableAggregation (); + } } bool @@ -684,6 +830,102 @@ RegularWifiMac::GetTypeId (void) MakeBooleanAccessor (&RegularWifiMac::SetCtsToSelfSupported, &RegularWifiMac::GetCtsToSelfSupported), MakeBooleanChecker ()) + .AddAttribute ("VO_MaxAmsduSize", + "Maximum length in bytes of an A-MSDU for AC_VO access class", + UintegerValue (0), + MakeUintegerAccessor (&RegularWifiMac::SetVoMaxAmsduSize), + MakeUintegerChecker ()) + .AddAttribute ("VI_MaxAmsduSize", + "Maximum length in bytes of an A-MSDU for AC_VI access class", + UintegerValue (0), + MakeUintegerAccessor (&RegularWifiMac::SetViMaxAmsduSize), + MakeUintegerChecker ()) + .AddAttribute ("BE_MaxAmsduSize", + "Maximum length in bytes of an A-MSDU for AC_BE access class", + UintegerValue (0), + MakeUintegerAccessor (&RegularWifiMac::SetBeMaxAmsduSize), + MakeUintegerChecker ()) + .AddAttribute ("BK_MaxAmsduSize", + "Maximum length in bytes of an A-MSDU for AC_BK access class", + UintegerValue (0), + MakeUintegerAccessor (&RegularWifiMac::SetBkMaxAmsduSize), + MakeUintegerChecker ()) + .AddAttribute ("VO_MaxAmpduSize", + "Maximum length in bytes of an A-MPDU for AC_VO access class", + UintegerValue (0), + MakeUintegerAccessor (&RegularWifiMac::SetVoMaxAmpduSize), + MakeUintegerChecker ()) + .AddAttribute ("VI_MaxAmpduSize", + "Maximum length in bytes of an A-MPDU for AC_VI access class", + UintegerValue (65535), + MakeUintegerAccessor (&RegularWifiMac::SetViMaxAmpduSize), + MakeUintegerChecker ()) + .AddAttribute ("BE_MaxAmpduSize", + "Maximum length in bytes of an A-MPDU for AC_BE access class", + UintegerValue (65535), + MakeUintegerAccessor (&RegularWifiMac::SetBeMaxAmpduSize), + MakeUintegerChecker ()) + .AddAttribute ("BK_MaxAmpduSize", + "Maximum length in bytes of an A-MPDU for AC_BK access class", + UintegerValue (0), + MakeUintegerAccessor (&RegularWifiMac::SetBkMaxAmpduSize), + MakeUintegerChecker ()) + .AddAttribute ("VO_BlockAckThreshold", + "If number of packets in VO queue reaches this value, " + "block ack mechanism is used. If this value is 0, block ack is never used.", + UintegerValue (0), + MakeUintegerAccessor (&RegularWifiMac::SetVoBlockAckThreshold), + MakeUintegerChecker (0, 64)) + .AddAttribute ("VI_BlockAckThreshold", + "If number of packets in VI queue reaches this value, " + "block ack mechanism is used. If this value is 0, block ack is never used.", + UintegerValue (0), + MakeUintegerAccessor (&RegularWifiMac::SetViBlockAckThreshold), + MakeUintegerChecker (0, 64)) + .AddAttribute ("BE_BlockAckThreshold", + "If number of packets in BE queue reaches this value, " + "block ack mechanism is used. If this value is 0, block ack is never used.", + UintegerValue (0), + MakeUintegerAccessor (&RegularWifiMac::SetBeBlockAckThreshold), + MakeUintegerChecker (0, 64)) + .AddAttribute ("BK_BlockAckThreshold", + "If number of packets in BK queue reaches this value, " + "block ack mechanism is used. If this value is 0, block ack is never used.", + UintegerValue (0), + MakeUintegerAccessor (&RegularWifiMac::SetBkBlockAckThreshold), + MakeUintegerChecker (0, 64)) + .AddAttribute ("VO_BlockAckInactivityTimeout", + "Represents max time (blocks of 1024 micro seconds) allowed for block ack" + "inactivity for AC_VO. If this value isn't equal to 0 a timer start after that a" + "block ack setup is completed and will be reset every time that a block ack" + "frame is received. If this value is 0, block ack inactivity timeout won't be used.", + UintegerValue (0), + MakeUintegerAccessor (&RegularWifiMac::SetVoBlockAckInactivityTimeout), + MakeUintegerChecker ()) + .AddAttribute ("VI_BlockAckInactivityTimeout", + "Represents max time (blocks of 1024 micro seconds) allowed for block ack" + "inactivity for AC_VI. If this value isn't equal to 0 a timer start after that a" + "block ack setup is completed and will be reset every time that a block ack" + "frame is received. If this value is 0, block ack inactivity timeout won't be used.", + UintegerValue (0), + MakeUintegerAccessor (&RegularWifiMac::SetViBlockAckInactivityTimeout), + MakeUintegerChecker ()) + .AddAttribute ("BE_BlockAckInactivityTimeout", + "Represents max time (blocks of 1024 micro seconds) allowed for block ack" + "inactivity for AC_BE. If this value isn't equal to 0 a timer start after that a" + "block ack setup is completed and will be reset every time that a block ack" + "frame is received. If this value is 0, block ack inactivity timeout won't be used.", + UintegerValue (0), + MakeUintegerAccessor (&RegularWifiMac::SetBeBlockAckInactivityTimeout), + MakeUintegerChecker ()) + .AddAttribute ("BK_BlockAckInactivityTimeout", + "Represents max time (blocks of 1024 micro seconds) allowed for block ack" + "inactivity for AC_BK. If this value isn't equal to 0 a timer start after that a" + "block ack setup is completed and will be reset every time that a block ack" + "frame is received. If this value is 0, block ack inactivity timeout won't be used.", + UintegerValue (0), + MakeUintegerAccessor (&RegularWifiMac::SetBkBlockAckInactivityTimeout), + MakeUintegerChecker ()) .AddAttribute ("DcaTxop", "The DcaTxop object", PointerValue (), MakePointerAccessor (&RegularWifiMac::GetDcaTxop), @@ -723,19 +965,21 @@ RegularWifiMac::GetTypeId (void) void RegularWifiMac::FinishConfigureStandard (enum WifiPhyStandard standard) { - uint32_t cwmin; - uint32_t cwmax; - + NS_LOG_FUNCTION (this << standard); + uint32_t cwmin = 0; + uint32_t cwmax = 0; switch (standard) { + case WIFI_PHY_STANDARD_80211ac: + SetVhtSupported (true); + case WIFI_PHY_STANDARD_80211n_5GHZ: + case WIFI_PHY_STANDARD_80211n_2_4GHZ: + SetHtSupported (true); case WIFI_PHY_STANDARD_holland: case WIFI_PHY_STANDARD_80211a: case WIFI_PHY_STANDARD_80211g: case WIFI_PHY_STANDARD_80211_10MHZ: case WIFI_PHY_STANDARD_80211_5MHZ: - case WIFI_PHY_STANDARD_80211n_5GHZ: - case WIFI_PHY_STANDARD_80211n_2_4GHZ: - case WIFI_PHY_STANDARD_80211ac: cwmin = 15; cwmax = 1023; break; @@ -772,4 +1016,73 @@ RegularWifiMac::TxFailed (const WifiMacHeader &hdr) m_txErrCallback (hdr); } +void +RegularWifiMac::ConfigureAggregation (void) +{ + NS_LOG_FUNCTION (this); + if (GetVOQueue ()->GetMsduAggregator () != 0) + { + GetVOQueue ()->GetMsduAggregator ()->SetMaxAmsduSize (m_voMaxAmsduSize); + } + if (GetVIQueue ()->GetMsduAggregator () != 0) + { + GetVIQueue ()->GetMsduAggregator ()->SetMaxAmsduSize (m_viMaxAmsduSize); + } + if (GetBEQueue ()->GetMsduAggregator () != 0) + { + GetBEQueue ()->GetMsduAggregator ()->SetMaxAmsduSize (m_beMaxAmsduSize); + } + if (GetBKQueue ()->GetMsduAggregator () != 0) + { + GetBKQueue ()->GetMsduAggregator ()->SetMaxAmsduSize (m_bkMaxAmsduSize); + } + if (GetVOQueue ()->GetMpduAggregator () != 0) + { + GetVOQueue ()->GetMpduAggregator ()->SetMaxAmpduSize (m_voMaxAmpduSize); + } + if (GetVIQueue ()->GetMpduAggregator () != 0) + { + GetVIQueue ()->GetMpduAggregator ()->SetMaxAmpduSize (m_viMaxAmpduSize); + } + if (GetBEQueue ()->GetMpduAggregator () != 0) + { + GetBEQueue ()->GetMpduAggregator ()->SetMaxAmpduSize (m_beMaxAmpduSize); + } + if (GetBKQueue ()->GetMpduAggregator () != 0) + { + GetBKQueue ()->GetMpduAggregator ()->SetMaxAmpduSize (m_bkMaxAmpduSize); + } +} + +void +RegularWifiMac::EnableAggregation (void) +{ + NS_LOG_FUNCTION (this); + for (EdcaQueues::iterator i = m_edca.begin (); i != m_edca.end (); ++i) + { + if (i->second->GetMsduAggregator () == 0) + { + Ptr msduAggregator = CreateObject (); + i->second->SetMsduAggregator (msduAggregator); + } + if (i->second->GetMpduAggregator () == 0) + { + Ptr mpduAggregator = CreateObject (); + i->second->SetMpduAggregator (mpduAggregator); + } + } + ConfigureAggregation (); +} + +void +RegularWifiMac::DisableAggregation (void) +{ + NS_LOG_FUNCTION (this); + for (EdcaQueues::iterator i = m_edca.begin (); i != m_edca.end (); ++i) + { + i->second->SetMsduAggregator (0); + i->second->SetMpduAggregator (0); + } +} + } //namespace ns3 diff --git a/src/wifi/model/regular-wifi-mac.h b/src/wifi/model/regular-wifi-mac.h index a1724e601..170434faf 100644 --- a/src/wifi/model/regular-wifi-mac.h +++ b/src/wifi/model/regular-wifi-mac.h @@ -469,6 +469,40 @@ private: */ void SetupEdcaQueue (enum AcIndex ac); + void SetVoMaxAmsduSize (uint32_t size); + void SetViMaxAmsduSize (uint32_t size); + void SetBeMaxAmsduSize (uint32_t size); + void SetBkMaxAmsduSize (uint32_t size); + + void SetVoMaxAmpduSize (uint32_t size); + void SetViMaxAmpduSize (uint32_t size); + void SetBeMaxAmpduSize (uint32_t size); + void SetBkMaxAmpduSize (uint32_t size); + + void SetVoBlockAckThreshold (uint8_t threshold); + void SetViBlockAckThreshold (uint8_t threshold); + void SetBeBlockAckThreshold (uint8_t threshold); + void SetBkBlockAckThreshold (uint8_t threshold); + + void SetVoBlockAckInactivityTimeout (uint16_t timeout); + void SetViBlockAckInactivityTimeout (uint16_t timeout); + void SetBeBlockAckInactivityTimeout (uint16_t timeout); + void SetBkBlockAckInactivityTimeout (uint16_t timeout); + + void ConfigureAggregation (void); + void EnableAggregation (void); + void DisableAggregation (void); + + uint32_t m_voMaxAmsduSize; + uint32_t m_viMaxAmsduSize; + uint32_t m_beMaxAmsduSize; + uint32_t m_bkMaxAmsduSize; + + uint32_t m_voMaxAmpduSize; + uint32_t m_viMaxAmpduSize; + uint32_t m_beMaxAmpduSize; + uint32_t m_bkMaxAmpduSize; + TracedCallback m_txOkCallback; TracedCallback m_txErrCallback; }; diff --git a/src/wifi/test/wifi-aggregation-test.cc b/src/wifi/test/wifi-aggregation-test.cc index 3e301d2d1..1f468fb7d 100644 --- a/src/wifi/test/wifi-aggregation-test.cc +++ b/src/wifi/test/wifi-aggregation-test.cc @@ -26,6 +26,8 @@ #include "ns3/mac-low.h" #include "ns3/edca-txop-n.h" #include "ns3/yans-wifi-phy.h" +#include "ns3/msdu-standard-aggregator.h" +#include "ns3/mpdu-standard-aggregator.h" using namespace ns3; @@ -41,8 +43,8 @@ private: Ptr m_edca; Ptr m_manager; ObjectFactory m_factory; - Ptr m_mpduAggregator; - Ptr m_msduAggregator; + Ptr msduAggregator; + Ptr mpduAggregator; }; TwoLevelAggregationTest::TwoLevelAggregationTest () @@ -84,17 +86,14 @@ TwoLevelAggregationTest::DoRun (void) /* * Configure aggregation. */ - m_factory = ObjectFactory (); - m_factory.SetTypeId ("ns3::MsduStandardAggregator"); - m_factory.Set ("MaxAmsduSize", UintegerValue (4095)); - m_msduAggregator = m_factory.Create (); - m_edca->SetMsduAggregator (m_msduAggregator); + msduAggregator = CreateObject (); + mpduAggregator = CreateObject (); + + msduAggregator->SetMaxAmsduSize (4095); + mpduAggregator->SetMaxAmpduSize (65535); - m_factory = ObjectFactory (); - m_factory.SetTypeId ("ns3::MpduStandardAggregator"); - m_factory.Set ("MaxAmpduSize", UintegerValue (65535)); - m_mpduAggregator = m_factory.Create (); - m_low->SetMpduAggregator (m_mpduAggregator); + m_edca->SetMsduAggregator (msduAggregator); + m_edca->SetMpduAggregator (mpduAggregator); /* * Create dummy packets of 1500 bytes and fill mac header fields that will be used for the tests. @@ -141,11 +140,11 @@ TwoLevelAggregationTest::DoRun (void) * It checks whether MSDU aggregation has been rejected because the maximum MPDU size is set to 0 (returned packet should be equal to 0). * This test is needed to ensure that no packets are removed from the queue in MacLow::PerformMsduAggregation, since aggregation will no occur in MacLow::AggregateToAmpdu. */ - m_factory = ObjectFactory (); + /*m_factory = ObjectFactory (); m_factory.SetTypeId ("ns3::MpduStandardAggregator"); m_factory.Set ("MaxAmpduSize", UintegerValue (0)); m_mpduAggregator = m_factory.Create (); - m_low->SetMpduAggregator (m_mpduAggregator); + m_low->SetMpduAggregator (m_mpduAggregator);*/ m_edca->GetEdcaQueue ()->Enqueue (pkt, hdr); packet = m_low->PerformMsduAggregation (peekedPacket, &peekedHdr, &tstamp, currentAggregatedPacket, 0); @@ -160,11 +159,7 @@ TwoLevelAggregationTest::DoRun (void) * It checks whether MSDU aggregation has been rejected because there is no packets ready in the queue (returned packet should be equal to 0). * This test is needed to ensure that there is no issue when the queue is empty. */ - m_factory = ObjectFactory (); - m_factory.SetTypeId ("ns3::MpduStandardAggregator"); - m_factory.Set ("MaxAmpduSize", UintegerValue (4095)); - m_mpduAggregator = m_factory.Create (); - m_low->SetMpduAggregator (m_mpduAggregator); + mpduAggregator->SetMaxAmpduSize (4095); m_edca->GetEdcaQueue ()->Remove (pkt); m_edca->GetEdcaQueue ()->Remove (pkt); diff --git a/src/wifi/test/wifi-test.cc b/src/wifi/test/wifi-test.cc index eed3ae4ae..e4ce08c0e 100644 --- a/src/wifi/test/wifi-test.cc +++ b/src/wifi/test/wifi-test.cc @@ -21,7 +21,7 @@ * Sébastien Deronne (Case for bug 730) */ -#include "ns3/nqos-wifi-mac-helper.h" +#include "ns3/default-mac-helper.h" #include "ns3/yans-wifi-helper.h" #include "ns3/mobility-helper.h" #include "ns3/wifi-net-device.h" @@ -547,13 +547,13 @@ Bug730TestCase::DoRun (void) YansWifiPhyHelper phy = YansWifiPhyHelper::Default (); phy.SetChannel (channel.Create ()); - WifiHelper wifi = WifiHelper::Default (); + WifiHelper wifi; wifi.SetStandard (WIFI_PHY_STANDARD_80211b); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("DsssRate1Mbps"), "ControlMode", StringValue ("DsssRate1Mbps")); - NqosWifiMacHelper mac = NqosWifiMacHelper::Default (); + WifiMacHelper mac; Ssid ssid = Ssid ("ns-3-ssid"); mac.SetType ("ns3::StaWifiMac", "Ssid", SsidValue (ssid), diff --git a/src/wifi/wscript b/src/wifi/wscript index b0d00a36a..01ed6292a 100644 --- a/src/wifi/wscript +++ b/src/wifi/wscript @@ -71,7 +71,7 @@ def build(bld): 'model/ampdu-tag.cc', 'model/wifi-radio-energy-model.cc', 'model/wifi-tx-current-model.cc', - 'model/vht-capabilities.cc', + 'model/vht-capabilities.cc', 'helper/wifi-radio-energy-model-helper.cc', 'helper/vht-wifi-mac-helper.cc', 'helper/ht-wifi-mac-helper.cc', @@ -80,6 +80,7 @@ def build(bld): 'helper/yans-wifi-helper.cc', 'helper/nqos-wifi-mac-helper.cc', 'helper/qos-wifi-mac-helper.cc', + 'helper/wifi-mac-helper.cc', ] obj_test = bld.create_ns3_module_test_library('wifi') @@ -138,6 +139,7 @@ def build(bld): 'model/edca-txop-n.h', 'model/msdu-aggregator.h', 'model/amsdu-subframe-header.h', + 'model/msdu-standard-aggregator.h', 'model/qos-tag.h', 'model/mgt-headers.h', 'model/status-code.h', @@ -163,7 +165,7 @@ def build(bld): 'model/ampdu-tag.h', 'model/wifi-radio-energy-model.h', 'model/wifi-tx-current-model.h', - 'model/vht-capabilities.h', + 'model/vht-capabilities.h', 'helper/wifi-radio-energy-model-helper.h', 'helper/vht-wifi-mac-helper.h', 'helper/ht-wifi-mac-helper.h', @@ -172,6 +174,7 @@ def build(bld): 'helper/yans-wifi-helper.h', 'helper/nqos-wifi-mac-helper.h', 'helper/qos-wifi-mac-helper.h', + 'helper/wifi-mac-helper.h', ] if bld.env['ENABLE_GSL']: