split wifi example simple-wifi-frame-aggregation.cc into two examples, one for MSDU aggregation and one for MPDU aggregation
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/wireless/simple-mpdu-aggregation.cc Sat Jan 31 17:41:12 2015 -0800
@@ -0,0 +1,166 @@
+/* -*- 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 <sebastien.deronne@gmail.com>
+ */
+
+#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("OfdmRate65MbpsBW20MHz"), "ControlMode", StringValue("OfdmRate6_5MbpsBW20MHz"));
+ 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<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
+
+ 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 (4294967295));
+ 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<UdpServer>(serverApp.Get (0))->GetReceived ();
+ double throughput = totalPacketsThrough*payloadSize*8/(simulationTime*1000000.0);
+ std::cout << "Throughput: " << throughput << " Mbit/s" << '\n';
+
+ return 0;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/wireless/simple-msdu-aggregation.cc Sat Jan 31 17:41:12 2015 -0800
@@ -0,0 +1,160 @@
+/* -*- 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 <mk.banchi@gmail.com>
+ * Sébastien Deronne <sebastien.deronne@gmail.com>
+ */
+#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("OfdmRate65MbpsBW20MHz"), "ControlMode", StringValue("OfdmRate6_5MbpsBW20MHz"));
+ 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<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
+
+ 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 (4294967295));
+ 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<UdpServer>(serverApp.Get (0))->GetReceived ();
+ double throughput = totalPacketsThrough*payloadSize*8/(simulationTime*1000000.0);
+ std::cout << "Throughput: " << throughput << " Mbit/s" << '\n';
+
+ return 0;
+}
--- a/examples/wireless/simple-wifi-frame-aggregation.cc Sat Jan 31 17:36:14 2015 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,149 +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
- *
- * Author: Mirko Banchi <mk.banchi@gmail.com>
- */
-#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 frame aggregation feature (A-MSDU) works.
-//
-//Network topology:
-//
-// Wifi 192.168.1.0
-//
-// AP
-// * * *
-// | | |
-// n1 n2 n3
-//
-//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 ("SimpleWifiFrameAggregation");
-
-int main (int argc, char *argv[])
-{
- //LogComponentEnable ("EdcaTxopN", LOG_LEVEL_DEBUG);
- LogComponentEnable ("MsduAggregator", LOG_LEVEL_INFO);
- LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
- LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
-
- uint32_t nWifi = 1;
- CommandLine cmd;
- cmd.AddValue ("nWifi", "Number of wifi STA devices", nWifi);
- cmd.Parse (argc,argv);
-
- NodeContainer wifiNodes;
- wifiNodes.Create (2);
- NodeContainer wifiApNode;
- wifiApNode.Create (1);
-
- YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
- YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
- phy.SetChannel (channel.Create ());
-
- WifiHelper wifi = WifiHelper::Default ();
- QosWifiMacHelper mac = QosWifiMacHelper::Default ();
- wifi.SetRemoteStationManager ("ns3::AarfWifiManager", "FragmentationThreshold", UintegerValue (2500));
-
- Ssid ssid = Ssid ("ns-3-802.11n");
- mac.SetType ("ns3::StaWifiMac",
- "Ssid", SsidValue (ssid),
- "ActiveProbing", BooleanValue (false));
- mac.SetMsduAggregatorForAc (AC_BE, "ns3::MsduStandardAggregator",
- "MaxAmsduSize", UintegerValue (3839));
-
- NetDeviceContainer staDevices;
- staDevices = wifi.Install (phy, mac, wifiNodes);
-
- mac.SetType ("ns3::ApWifiMac",
- "Ssid", SsidValue (ssid));
- mac.SetMsduAggregatorForAc (AC_BE, "ns3::MsduStandardAggregator",
- "MaxAmsduSize", UintegerValue (7935));
-
- NetDeviceContainer apDevice;
- apDevice = wifi.Install (phy, mac, wifiApNode);
-
- /* Setting mobility model */
- MobilityHelper mobility;
-
- mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
- "MinX", DoubleValue (0.0),
- "MinY", DoubleValue (0.0),
- "DeltaX", DoubleValue (5.0),
- "DeltaY", DoubleValue (10.0),
- "GridWidth", UintegerValue (3),
- "LayoutType", StringValue ("RowFirst"));
-
- mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
- "Bounds", RectangleValue (Rectangle (-50, 50, -50, 50)));
- mobility.Install (wifiNodes);
-
- mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
- mobility.Install (wifiApNode);
-
- /* Internet stack*/
- InternetStackHelper stack;
- stack.Install (wifiApNode);
- stack.Install (wifiNodes);
-
- Ipv4AddressHelper address;
-
- address.SetBase ("192.168.1.0", "255.255.255.0");
- Ipv4InterfaceContainer wifiNodesInterfaces;
- Ipv4InterfaceContainer apNodeInterface;
-
- wifiNodesInterfaces = address.Assign (staDevices);
- apNodeInterface = address.Assign (apDevice);
-
- /* Setting applications */
- UdpEchoServerHelper echoServer (9);
-
- ApplicationContainer serverApps = echoServer.Install (wifiNodes.Get (1));
- serverApps.Start (Seconds (1.0));
- serverApps.Stop (Seconds (10.0));
-
- UdpEchoClientHelper echoClient (wifiNodesInterfaces.GetAddress (1), 9);
- echoClient.SetAttribute ("MaxPackets", UintegerValue (3));
- echoClient.SetAttribute ("Interval", TimeValue (Seconds (0.000001)));
- echoClient.SetAttribute ("PacketSize", UintegerValue (1500));
-
- ApplicationContainer clientApps =
- echoClient.Install (wifiNodes.Get (0));
- clientApps.Start (Seconds (2.0));
- clientApps.Stop (Seconds (10.0));
-
- Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
-
- Simulator::Stop (Seconds (10.0));
-
- phy.EnablePcap ("test-802.11n",
- wifiNodes.Get (nWifi - 1)->GetId (), 0);
-
- Simulator::Run ();
- Simulator::Destroy ();
-
- return 0;
-}
--- a/examples/wireless/wscript Sat Jan 31 17:36:14 2015 -0800
+++ b/examples/wireless/wscript Sat Jan 31 17:41:12 2015 -0800
@@ -22,8 +22,8 @@
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-wifi-frame-aggregation', ['internet', 'mobility', 'wifi', 'applications'])
- obj.source = 'simple-wifi-frame-aggregation.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'
@@ -66,3 +66,6 @@
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'
\ No newline at end of file