Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 31.16 KB | None | 0 0
  1. /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
  2.     2 /*
  3.     3  * Copyright (c) 2016 Sébastien Deronne
  4.     4  *
  5.     5  * This program is free software; you can redistribute it and/or modify
  6.     6  * it under the terms of the GNU General Public License version 2 as
  7.     7  * published by the Free Software Foundation;
  8.     8  *
  9.     9  * This program is distributed in the hope that it will be useful,
  10.    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    12  * GNU General Public License for more details.
  13.    13  *
  14.    14  * You should have received a copy of the GNU General Public License
  15.    15  * along with this program; if not, write to the Free Software
  16.    16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  17.    17  *
  18.    18  * Author: Sébastien Deronne <sebastien.deronne@gmail.com>
  19.    19  */
  20.    20
  21.    21 #include "ns3/command-line.h"
  22.    22 #include "ns3/config.h"
  23.    23 #include "ns3/string.h"
  24.    24 #include "ns3/pointer.h"
  25.    25 #include "ns3/log.h"
  26.    26 #include "ns3/yans-wifi-helper.h"
  27.    27 #include "ns3/ssid.h"
  28.    28 #include "ns3/mobility-helper.h"
  29.    29 #include "ns3/internet-stack-helper.h"
  30.    30 #include "ns3/ipv4-address-helper.h"
  31.    31 #include "ns3/udp-client-server-helper.h"
  32.    32 #include "ns3/on-off-helper.h"
  33.    33 #include "ns3/yans-wifi-channel.h"
  34.    34 #include "ns3/wifi-net-device.h"
  35.    35 #include "ns3/qos-txop.h"
  36.    36 #include "ns3/wifi-mac.h"
  37.    37 #include "ns3/packet-sink-helper.h"
  38.    38 #include "ns3/packet-sink.h"
  39.    39
  40.    40 // This example shows how to configure mixed networks (i.e. mixed b/g and HT/non-HT) and how are performance in several scenarios.
  41.    41 //
  42.    42 // The example compares first g only and mixed b/g cases with various configurations depending on the following parameters:
  43.    43 // - protection mode that is configured on the AP;
  44.    44 // - whether short PLCP is supported by the 802.11b station;
  45.    45 // - whether short slot time is supported by both the 802.11g station and the AP.
  46.    46 //
  47.    47 // The example then compares HT only and mixed HT/non-HT cases with various configurations depending on the following parameters:
  48.    48 // - whether HT GF is supported by the AP;
  49.    49 // - whether HT GF is supported by all HT stations;
  50.    50 // - whether RIFS is enabled on HT stations;
  51.    51 // - RIFS mode that is configured on the AP.
  52.    52 //
  53.    53 // The output results show that the presence of an 802.11b station strongly affects 802.11g performance.
  54.    54 // Protection mechanisms ensure that the NAV value of 802.11b stations is set correctly in case of 802.11g transmissions.
  55.    55 // In practice, those protection mechanism add a lot of overhead, resulting in reduced performance. CTS-To-Self introduces
  56.    56 // less overhead than Rts-Cts, but is not heard by hidden stations (and is thus generally only recommended as a protection
  57.    57 // mechanism for access points). Since short slot time is disabled once an 802.11b station enters the network, benefits from
  58.    58 // short slot time are only observed in a g only configuration.
  59.    59 //
  60.    60 // HT and mixed-HT results show that HT GF permits to slightly increase performance when all HT stations support GF mode, and RIFS also permits
  61.    61 // such a small improvement when no non-HT station is present. In order to show the benefit offered by RIFS, aggregation has been disabled and
  62.    62 // Block ACK together with a TXOP duration of 3008 microseconds have been set.
  63.    63 //
  64.    64 // The user can also select the payload size and can choose either an UDP or a TCP connection.
  65.    65 // Example: ./waf --run "mixed-network --isUdp=1"
  66.    66
  67.    67 using namespace ns3;
  68.    68
  69.    69 NS_LOG_COMPONENT_DEFINE ("MixedNetwork");
  70.    70
  71.    71 struct Parameters
  72.    72 {
  73.    73   std::string testName;
  74.    74   bool enableErpProtection;
  75.    75   std::string erpProtectionMode;
  76.    76   bool enableShortSlotTime;
  77.    77   bool enableShortPlcpPreamble;
  78.    78   WifiPhyStandard apType;
  79.    79   bool apSupportsGreenfield;
  80.    80   bool rifsSupported;
  81.    81   bool rifsMode;
  82.    82   uint32_t nWifiB;
  83.    83   bool bHasTraffic;
  84.    84   uint32_t nWifiG;
  85.    85   bool gHasTraffic;
  86.    86   uint32_t nWifiNNonGreenfield;
  87.    87   bool nNonGreenfieldHasTraffic;
  88.    88   uint32_t nWifiNGreenfield;
  89.    89   bool nGreenfieldHasTraffic;
  90.    90   bool isUdp;
  91.    91   uint32_t payloadSize;
  92.    92   double simulationTime;
  93.    93 };
  94.    94
  95.    95 class Experiment
  96.    96 {
  97.    97 public:
  98.    98   Experiment ();
  99.    99   double Run (Parameters params);
  100.   100 };
  101.   101
  102.   102 Experiment::Experiment ()
  103.   103 {
  104.   104 }
  105.   105
  106.   106 double
  107.   107 Experiment::Run (Parameters params)
  108.   108 {
  109.   109   std::string apTypeString;
  110.   110   if (params.apType == WIFI_PHY_STANDARD_80211g)
  111.   111     {
  112.   112       apTypeString = "WIFI_PHY_STANDARD_80211g";
  113.   113     }
  114.   114   else if (params.apType == WIFI_PHY_STANDARD_80211n_2_4GHZ)
  115.   115     {
  116.   116       apTypeString = "WIFI_PHY_STANDARD_80211n_2_4GHZ";
  117.   117     }
  118.   118
  119.   119   std::cout << "Run: " << params.testName
  120.   120             << "\n\t enableErpProtection=" << params.enableErpProtection
  121.   121             << "\n\t erpProtectionMode=" << params.erpProtectionMode
  122.   122             << "\n\t enableShortSlotTime=" << params.enableShortSlotTime
  123.   123             << "\n\t enableShortPlcpPreamble=" << params.enableShortPlcpPreamble
  124.   124             << "\n\t apType=" << apTypeString
  125.   125             << "\n\t apSupportsGreenfield=" << params.apSupportsGreenfield
  126.   126             << "\n\t rifsSupported=" << params.rifsSupported
  127.   127             << "\n\t rifsMode=" << params.rifsMode
  128.   128             << "\n\t nWifiB=" << params.nWifiB
  129.   129             << "\n\t bHasTraffic=" << params.bHasTraffic
  130.   130             << "\n\t nWifiG=" << params.nWifiG
  131.   131             << "\n\t gHasTraffic=" << params.gHasTraffic
  132.   132             << "\n\t nWifiNNonGreenfield=" << params.nWifiNNonGreenfield
  133.   133             << "\n\t nNonGreenfieldHasTraffic=" << params.nNonGreenfieldHasTraffic
  134.   134             << "\n\t nWifiNGreenfield=" << params.nWifiNGreenfield
  135.   135             << "\n\t nGreenfieldHasTraffic=" << params.nGreenfieldHasTraffic
  136.   136             << std::endl;
  137.   137
  138.   138   Config::SetDefault ("ns3::WifiRemoteStationManager::ErpProtectionMode", StringValue (params.erpProtectionMode));
  139.   139
  140.   140   double throughput = 0;
  141.   141   uint32_t nWifiB = params.nWifiB;
  142.   142   uint32_t nWifiG = params.nWifiG;
  143.   143   uint32_t nWifiNNGF = params.nWifiNNonGreenfield;
  144.   144   uint32_t nWifiNGF = params.nWifiNGreenfield;
  145.   145   double simulationTime = params.simulationTime;
  146.   146   uint32_t payloadSize = params.payloadSize;
  147.   147
  148.   148   NodeContainer wifiBStaNodes;
  149.   149   wifiBStaNodes.Create (nWifiB);
  150.   150   NodeContainer wifiGStaNodes;
  151.   151   wifiGStaNodes.Create (nWifiG);
  152.   152   NodeContainer wifiNNGFStaNodes;
  153.   153   wifiNNGFStaNodes.Create (nWifiNNGF);
  154.   154   NodeContainer wifiNGFStaNodes;
  155.   155   wifiNGFStaNodes.Create (nWifiNGF);
  156.   156   NodeContainer wifiApNode;
  157.   157   wifiApNode.Create (1);
  158.   158
  159.   159   YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
  160.   160   channel.AddPropagationLoss ("ns3::RangePropagationLossModel");
  161.   161
  162.   162   YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
  163.   163   phy.SetPcapDataLinkType (WifiPhyHelper::DLT_IEEE802_11_RADIO);
  164.   164   phy.SetChannel (channel.Create ());
  165.   165
  166.   166   WifiHelper wifi;
  167.   167   wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
  168.   168
  169.   169   // 802.11b STA
  170.   170   wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
  171.   171
  172.   172   WifiMacHelper mac;
  173.   173   Ssid ssid = Ssid ("ns-3-ssid");
  174.   174
  175.   175   mac.SetType ("ns3::StaWifiMac",
  176.   176                "Ssid", SsidValue (ssid),
  177.   177                "ShortSlotTimeSupported", BooleanValue (params.enableShortSlotTime));
  178.   178
  179.   179   // Configure the PLCP preamble type: long or short
  180.   180   phy.Set ("ShortPlcpPreambleSupported", BooleanValue (params.enableShortPlcpPreamble));
  181.   181
  182.   182   NetDeviceContainer bStaDevice;
  183.   183   bStaDevice = wifi.Install (phy, mac, wifiBStaNodes);
  184.   184
  185.   185   // 802.11b/g STA
  186.   186   wifi.SetStandard (WIFI_PHY_STANDARD_80211g);
  187.   187   NetDeviceContainer gStaDevice;
  188.   188   gStaDevice = wifi.Install (phy, mac, wifiGStaNodes);
  189.   189
  190.   190   // 802.11b/g/n STA
  191.   191   wifi.SetStandard (WIFI_PHY_STANDARD_80211n_2_4GHZ);
  192.   192   NetDeviceContainer nNGFStaDevice, nGFStaDevice;
  193.   193   mac.SetType ("ns3::StaWifiMac",
  194.   194                "RifsSupported", BooleanValue (params.rifsSupported),
  195.   195                "Ssid", SsidValue (ssid),
  196.   196                "BE_MaxAmpduSize", UintegerValue (0),
  197.   197                "BE_BlockAckThreshold", UintegerValue (2),
  198.   198                "ShortSlotTimeSupported", BooleanValue (params.enableShortSlotTime));
  199.   199   phy.Set ("GreenfieldEnabled", BooleanValue (false));
  200.   200   nNGFStaDevice = wifi.Install (phy, mac, wifiNNGFStaNodes);
  201.   201   phy.Set ("GreenfieldEnabled", BooleanValue (true));
  202.   202   nGFStaDevice = wifi.Install (phy, mac, wifiNGFStaNodes);
  203.   203
  204.   204   // AP
  205.   205   NetDeviceContainer apDevice;
  206.   206   wifi.SetStandard (params.apType);
  207.   207   mac.SetType ("ns3::ApWifiMac",
  208.   208                "Ssid", SsidValue (ssid),
  209.   209                "EnableBeaconJitter", BooleanValue (false),
  210.   210                "BE_MaxAmpduSize", UintegerValue (0),
  211.   211                "BE_BlockAckThreshold", UintegerValue (2),
  212.   212                "RifsSupported", BooleanValue (params.rifsSupported),
  213.   213                "RifsMode", BooleanValue (params.rifsMode),
  214.   214                "EnableNonErpProtection", BooleanValue (params.enableErpProtection),
  215.   215                "ShortSlotTimeSupported", BooleanValue (params.enableShortSlotTime));
  216.   216   phy.Set ("GreenfieldEnabled", BooleanValue (params.apSupportsGreenfield));
  217.   217   apDevice = wifi.Install (phy, mac, wifiApNode);
  218.   218
  219.   219   // Set TXOP limit
  220.   220   if (params.apType == WIFI_PHY_STANDARD_80211n_2_4GHZ)
  221.   221     {
  222.   222       Ptr<NetDevice> dev = wifiApNode.Get (0)->GetDevice (0);
  223.   223       Ptr<WifiNetDevice> wifi_dev = DynamicCast<WifiNetDevice> (dev);
  224.   224       Ptr<WifiMac> wifi_mac = wifi_dev->GetMac ();
  225.   225       PointerValue ptr;
  226.   226       wifi_mac->GetAttribute ("BE_Txop", ptr);
  227.   227       Ptr<QosTxop> edca = ptr.Get<QosTxop> ();
  228.   228       edca->SetTxopLimit (MicroSeconds (3008));
  229.   229     }
  230.   230   if (nWifiNNGF > 0)
  231.   231     {
  232.   232       Ptr<NetDevice> dev = wifiNNGFStaNodes.Get (0)->GetDevice (0);
  233.   233       Ptr<WifiNetDevice> wifi_dev = DynamicCast<WifiNetDevice> (dev);
  234.   234       Ptr<WifiMac> wifi_mac = wifi_dev->GetMac ();
  235.   235       PointerValue ptr;
  236.   236       wifi_mac->GetAttribute ("BE_Txop", ptr);
  237.   237       Ptr<QosTxop> edca = ptr.Get<QosTxop> ();
  238.   238       edca->SetTxopLimit (MicroSeconds (3008));
  239.   239     }
  240.   240   if (nWifiNGF > 0)
  241.   241     {
  242.   242       Ptr<NetDevice> dev = wifiNGFStaNodes.Get (0)->GetDevice (0);
  243.   243       Ptr<WifiNetDevice> wifi_dev = DynamicCast<WifiNetDevice> (dev);
  244.   244       Ptr<WifiMac> wifi_mac = wifi_dev->GetMac ();
  245.   245       PointerValue ptr;
  246.   246       wifi_mac->GetAttribute ("BE_Txop", ptr);
  247.   247       Ptr<QosTxop> edca = ptr.Get<QosTxop> ();
  248.   248       edca->SetTxopLimit (MicroSeconds (3008));
  249.   249     }
  250.   250
  251.   251   // Define mobility model
  252.   252   MobilityHelper mobility;
  253.   253   Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
  254.   254
  255.   255   positionAlloc->Add (Vector (0.0, 0.0, 0.0));
  256.   256   for (uint32_t i = 0; i < nWifiB; i++)
  257.   257     {
  258.   258       positionAlloc->Add (Vector (5.0, 0.0, 0.0));
  259.   259     }
  260.   260   for (uint32_t i = 0; i < nWifiG; i++)
  261.   261     {
  262.   262       positionAlloc->Add (Vector (0.0, 5.0, 0.0));
  263.   263     }
  264.   264   for (uint32_t i = 0; i < nWifiNNGF; i++)
  265.   265     {
  266.   266       positionAlloc->Add (Vector (0.0, 0.0, 5.0));
  267.   267     }
  268.   268   for (uint32_t i = 0; i < nWifiNGF; i++)
  269.   269     {
  270.   270       positionAlloc->Add (Vector (0.0, 0.0, 5.0));
  271.   271     }
  272.   272
  273.   273   mobility.SetPositionAllocator (positionAlloc);
  274.   274   mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
  275.   275   mobility.Install (wifiApNode);
  276.   276   mobility.Install (wifiBStaNodes);
  277.   277   mobility.Install (wifiGStaNodes);
  278.   278   mobility.Install (wifiNNGFStaNodes);
  279.   279   mobility.Install (wifiNGFStaNodes);
  280.   280
  281.   281   // Internet stack
  282.   282   InternetStackHelper stack;
  283.   283   stack.Install (wifiApNode);
  284.   284   stack.Install (wifiBStaNodes);
  285.   285   stack.Install (wifiGStaNodes);
  286.   286   stack.Install (wifiNNGFStaNodes);
  287.   287   stack.Install (wifiNGFStaNodes);
  288.   288
  289.   289   Ipv4AddressHelper address;
  290.   290   address.SetBase ("192.168.1.0", "255.255.255.0");
  291.   291   Ipv4InterfaceContainer bStaInterface;
  292.   292   bStaInterface = address.Assign (bStaDevice);
  293.   293   Ipv4InterfaceContainer gStaInterface;
  294.   294   gStaInterface = address.Assign (gStaDevice);
  295.   295   Ipv4InterfaceContainer nNGFStaInterface;
  296.   296   nNGFStaInterface = address.Assign (nNGFStaDevice);
  297.   297   Ipv4InterfaceContainer nGFStaInterface;
  298.   298   nGFStaInterface = address.Assign (nGFStaDevice);
  299.   299   Ipv4InterfaceContainer ApInterface;
  300.   300   ApInterface = address.Assign (apDevice);
  301.   301
  302.   302   // Setting applications
  303.   303   if (params.isUdp)
  304.   304     {
  305.   305       uint16_t port = 9;
  306.   306       UdpServerHelper server (port);
  307.   307       ApplicationContainer serverApp = server.Install (wifiApNode);
  308.   308       serverApp.Start (Seconds (0.0));
  309.   309       serverApp.Stop (Seconds (simulationTime + 1));
  310.   310
  311.   311       UdpClientHelper client (ApInterface.GetAddress (0), port);
  312.   312       client.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
  313.   313       client.SetAttribute ("Interval", TimeValue (Time ("0.0002"))); //packets/s
  314.   314       client.SetAttribute ("PacketSize", UintegerValue (payloadSize));
  315.   315
  316.   316       ApplicationContainer clientApps;
  317.   317       if (params.bHasTraffic)
  318.   318         {
  319.   319           clientApps.Add (client.Install (wifiBStaNodes));
  320.   320         }
  321.   321       if (params.gHasTraffic)
  322.   322         {
  323.   323           clientApps.Add (client.Install (wifiGStaNodes));
  324.   324         }
  325.   325       if (params.nNonGreenfieldHasTraffic)
  326.   326         {
  327.   327           clientApps.Add (client.Install (wifiNNGFStaNodes));
  328.   328         }
  329.   329       if (params.nGreenfieldHasTraffic)
  330.   330         {
  331.   331           clientApps.Add (client.Install (wifiNGFStaNodes));
  332.   332         }
  333.   333       clientApps.Start (Seconds (1.0));
  334.   334       clientApps.Stop (Seconds (simulationTime + 1));
  335.   335
  336.   336       Simulator::Stop (Seconds (simulationTime + 1));
  337.   337       Simulator::Run ();
  338.   338       Simulator::Destroy ();
  339.   339
  340.   340       uint64_t totalPacketsThrough = DynamicCast<UdpServer> (serverApp.Get (0))->GetReceived ();
  341.   341       throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0);
  342.   342     }
  343.   343   else
  344.   344     {
  345.   345       uint16_t port = 50000;
  346.   346       Address localAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
  347.   347       PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", localAddress);
  348.   348
  349.   349       ApplicationContainer serverApp = packetSinkHelper.Install (wifiApNode.Get (0));
  350.   350       serverApp.Start (Seconds (0.0));
  351.   351       serverApp.Stop (Seconds (simulationTime + 1));
  352.   352
  353.   353       OnOffHelper onoff ("ns3::TcpSocketFactory", Ipv4Address::GetAny ());
  354.   354       onoff.SetAttribute ("OnTime",  StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
  355.   355       onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
  356.   356       onoff.SetAttribute ("PacketSize", UintegerValue (payloadSize));
  357.   357       onoff.SetAttribute ("DataRate", DataRateValue (150000000)); //bit/s
  358.   358
  359.   359       AddressValue remoteAddress (InetSocketAddress (ApInterface.GetAddress (0), port));
  360.   360       onoff.SetAttribute ("Remote", remoteAddress);
  361.   361
  362.   362       ApplicationContainer clientApps;
  363.   363       if (params.bHasTraffic)
  364.   364         {
  365.   365           clientApps.Add (onoff.Install (wifiBStaNodes));
  366.   366         }
  367.   367       if (params.gHasTraffic)
  368.   368         {
  369.   369           clientApps.Add (onoff.Install (wifiGStaNodes));
  370.   370         }
  371.   371       if (params.nNonGreenfieldHasTraffic)
  372.   372         {
  373.   373           clientApps.Add (onoff.Install (wifiNNGFStaNodes));
  374.   374         }
  375.   375       if (params.nGreenfieldHasTraffic)
  376.   376         {
  377.   377           clientApps.Add (onoff.Install (wifiNGFStaNodes));
  378.   378         }
  379.   379       clientApps.Start (Seconds (1.0));
  380.   380       clientApps.Stop (Seconds (simulationTime + 1));
  381.   381
  382.   382       Simulator::Stop (Seconds (simulationTime + 1));
  383.   383       Simulator::Run ();
  384.   384       Simulator::Destroy ();
  385.   385
  386.   386       uint64_t totalPacketsThrough = DynamicCast<PacketSink> (serverApp.Get (0))->GetTotalRx ();
  387.   387       throughput += totalPacketsThrough * 8 / (simulationTime * 1000000.0);
  388.   388     }
  389.   389   return throughput;
  390.   390 }
  391.   391
  392.   392 int main (int argc, char *argv[])
  393.   393 {
  394.   394   Parameters params;
  395.   395   params.testName = "";
  396.   396   params.enableErpProtection = false;
  397.   397   params.erpProtectionMode = "Cts-To-Self";
  398.   398   params.enableShortSlotTime = false;
  399.   399   params.enableShortPlcpPreamble = false;
  400.   400   params.apType = WIFI_PHY_STANDARD_80211g;
  401.   401   params.apSupportsGreenfield = false;
  402.   402   params.rifsSupported = false;
  403.   403   params.rifsMode = false;
  404.   404   params.nWifiB = 0;
  405.   405   params.bHasTraffic = false;
  406.   406   params.nWifiG = 1;
  407.   407   params.gHasTraffic = true;
  408.   408   params.nWifiNNonGreenfield = 0;
  409.   409   params.nNonGreenfieldHasTraffic = false;
  410.   410   params.nWifiNGreenfield = 0;
  411.   411   params.nGreenfieldHasTraffic = false;
  412.   412   params.isUdp = true;
  413.   413   params.payloadSize = 1472; //bytes
  414.   414   params.simulationTime = 10; //seconds
  415.   415
  416.   416   bool verifyResults = 0; //used for regression
  417.   417
  418.   418   CommandLine cmd;
  419.   419   cmd.AddValue ("payloadSize", "Payload size in bytes", params.payloadSize);
  420.   420   cmd.AddValue ("simulationTime", "Simulation time in seconds", params.simulationTime);
  421.   421   cmd.AddValue ("isUdp", "UDP if set to 1, TCP otherwise", params.isUdp);
  422.   422   cmd.AddValue ("verifyResults", "Enable/disable results verification at the end of the simulation", verifyResults);
  423.   423   cmd.Parse (argc, argv);
  424.   424
  425.   425   Experiment experiment;
  426.   426   double throughput = 0;
  427.   427
  428.   428   params.testName = "g only with all g features disabled";
  429.   429   throughput = experiment.Run (params);
  430.   430   if (verifyResults && (throughput < 22.5 || throughput > 23.5))
  431.   431     {
  432.   432       NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
  433.   433       exit (1);
  434.   434     }
  435.   435   std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
  436.   436
  437.   437   params.testName = "g only with short slot time enabled";
  438.   438   params.enableErpProtection = false;
  439.   439   params.enableShortSlotTime = true;
  440.   440   params.enableShortPlcpPreamble = false;
  441.   441   params.nWifiB = 0;
  442.   442   throughput = experiment.Run (params);
  443.   443   if (verifyResults && (throughput < 29 || throughput > 30))
  444.   444     {
  445.   445       NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
  446.   446       exit (1);
  447.   447     }
  448.   448   std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
  449.   449
  450.   450   params.testName = "Mixed b/g with all g features disabled";
  451.   451   params.enableErpProtection = false;
  452.   452   params.enableShortSlotTime = false;
  453.   453   params.enableShortPlcpPreamble = false;
  454.   454   params.nWifiB = 1;
  455.   455   throughput = experiment.Run (params);
  456.   456   if (verifyResults && (throughput < 22.5 || throughput > 23.5))
  457.   457     {
  458.   458       NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
  459.   459       exit (1);
  460.   460     }
  461.   461   std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
  462.   462
  463.   463   params.testName = "Mixed b/g with short plcp preamble enabled";
  464.   464   params.enableErpProtection = false;
  465.   465   params.enableShortSlotTime = false;
  466.   466   params.enableShortPlcpPreamble = true;
  467.   467   params.nWifiB = 1;
  468.   468   throughput = experiment.Run (params);
  469.   469   if (verifyResults && (throughput < 22.5 || throughput > 23.5))
  470.   470     {
  471.   471       NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
  472.   472       exit (1);
  473.   473     }
  474.   474   std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
  475.   475
  476.   476   params.testName = "Mixed b/g with short slot time enabled using RTS-CTS protection";
  477.   477   params.enableErpProtection = true;
  478.   478   params.erpProtectionMode = "Rts-Cts";
  479.   479   params.enableShortSlotTime = false;
  480.   480   params.enableShortPlcpPreamble = false;
  481.   481   params.nWifiB = 1;
  482.   482   throughput = experiment.Run (params);
  483.   483   if (verifyResults && (throughput < 19 || throughput > 20))
  484.   484     {
  485.   485       NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
  486.   486       exit (1);
  487.   487     }
  488.   488   std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
  489.   489
  490.   490   params.testName = "Mixed b/g with short plcp preamble enabled using RTS-CTS protection";
  491.   491   params.enableErpProtection = true;
  492.   492   params.enableShortSlotTime = false;
  493.   493   params.enableShortPlcpPreamble = true;
  494.   494   params.nWifiB = 1;
  495.   495   throughput = experiment.Run (params);
  496.   496   if (verifyResults && (throughput < 19 || throughput > 20))
  497.   497     {
  498.   498       NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
  499.   499       exit (1);
  500.   500     }
  501.   501   std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
  502.   502
  503.   503   params.testName = "Mixed b/g with short slot time enabled using CTS-TO-SELF protection";
  504.   504   params.enableErpProtection = true;
  505.   505   params.erpProtectionMode = "Cts-To-Self";
  506.   506   params.enableShortSlotTime = false;
  507.   507   params.enableShortPlcpPreamble = false;
  508.   508   params.nWifiB = 1;
  509.   509   throughput = experiment.Run (params);
  510.   510   if (verifyResults && (throughput < 20.5 || throughput > 21.5))
  511.   511     {
  512.   512       NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
  513.   513       exit (1);
  514.   514     }
  515.   515   std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
  516.   516
  517.   517   params.testName = "Mixed b/g with short plcp preamble enabled using CTS-TO-SELF protection";
  518.   518   params.enableErpProtection = true;
  519.   519   params.enableShortSlotTime = false;
  520.   520   params.enableShortPlcpPreamble = true;
  521.   521   params.nWifiB = 1;
  522.   522   throughput = experiment.Run (params);
  523.   523   if (verifyResults && (throughput < 20.5 || throughput > 21.5))
  524.   524     {
  525.   525       NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
  526.   526       exit (1);
  527.   527     }
  528.   528   std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
  529.   529
  530.   530   params.testName = "HT GF not supported";
  531.   531   params.enableErpProtection = false;
  532.   532   params.enableShortSlotTime = false;
  533.   533   params.enableShortPlcpPreamble = false;
  534.   534   params.apType = WIFI_PHY_STANDARD_80211n_2_4GHZ;
  535.   535   params.apSupportsGreenfield = false;
  536.   536   params.nWifiB = 0;
  537.   537   params.bHasTraffic = false;
  538.   538   params.nWifiG = 0;
  539.   539   params.gHasTraffic = false;
  540.   540   params.nWifiNNonGreenfield = 1;
  541.   541   params.nNonGreenfieldHasTraffic = true;
  542.   542   params.nWifiNGreenfield = 0;
  543.   543   params.nGreenfieldHasTraffic = false;
  544.   544   throughput = experiment.Run (params);
  545.   545   if (verifyResults && (throughput < 43 || throughput > 44))
  546.   546     {
  547.   547       NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
  548.   548       exit (1);
  549.   549     }
  550.   550   std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
  551.   551
  552.   552   params.testName = "HT only with GF used";
  553.   553   params.enableErpProtection = false;
  554.   554   params.enableShortSlotTime = false;
  555.   555   params.enableShortPlcpPreamble = false;
  556.   556   params.apType = WIFI_PHY_STANDARD_80211n_2_4GHZ;
  557.   557   params.apSupportsGreenfield = true;
  558.   558   params.nWifiB = 0;
  559.   559   params.bHasTraffic = false;
  560.   560   params.nWifiG = 0;
  561.   561   params.gHasTraffic = false;
  562.   562   params.nWifiNNonGreenfield = 0;
  563.   563   params.nNonGreenfieldHasTraffic = false;
  564.   564   params.nWifiNGreenfield = 1;
  565.   565   params.nGreenfieldHasTraffic = true;
  566.   566   throughput = experiment.Run (params);
  567.   567   if (verifyResults && (throughput < 44 || throughput > 45))
  568.   568     {
  569.   569       NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
  570.   570       exit (1);
  571.   571     }
  572.   572   std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
  573.   573
  574.   574   params.testName = "HT only with GF allowed but disabled by protection";
  575.   575   params.enableErpProtection = false;
  576.   576   params.enableShortSlotTime = false;
  577.   577   params.enableShortPlcpPreamble = false;
  578.   578   params.apType = WIFI_PHY_STANDARD_80211n_2_4GHZ;
  579.   579   params.apSupportsGreenfield = true;
  580.   580   params.nWifiB = 0;
  581.   581   params.bHasTraffic = false;
  582.   582   params.nWifiG = 0;
  583.   583   params.gHasTraffic = false;
  584.   584   params.nWifiNNonGreenfield = 1;
  585.   585   params.nNonGreenfieldHasTraffic = false;
  586.   586   params.nWifiNGreenfield = 1;
  587.   587   params.nGreenfieldHasTraffic = true;
  588.   588   throughput = experiment.Run (params);
  589.   589   if (verifyResults && (throughput < 43 || throughput > 44))
  590.   590     {
  591.   591       NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
  592.   592       exit (1);
  593.   593     }
  594.   594   std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
  595.   595
  596.   596   params.testName = "HT only with GF not supported by the receiver";
  597.   597   params.enableErpProtection = false;
  598.   598   params.enableShortSlotTime = false;
  599.   599   params.enableShortPlcpPreamble = false;
  600.   600   params.apType = WIFI_PHY_STANDARD_80211n_2_4GHZ;
  601.   601   params.apSupportsGreenfield = false;
  602.   602   params.nWifiB = 0;
  603.   603   params.bHasTraffic = false;
  604.   604   params.nWifiG = 0;
  605.   605   params.gHasTraffic = false;
  606.   606   params.nWifiNNonGreenfield = 0;
  607.   607   params.nNonGreenfieldHasTraffic = false;
  608.   608   params.nWifiNGreenfield = 1;
  609.   609   params.nGreenfieldHasTraffic = true;
  610.   610   throughput = experiment.Run (params);
  611.   611   if (verifyResults && (throughput < 43 || throughput > 44))
  612.   612     {
  613.   613       NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
  614.   614       exit (1);
  615.   615     }
  616.   616   std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
  617.   617
  618.   618   params.testName = "Mixed HT/non-HT with GF enabled";
  619.   619   params.enableErpProtection = false;
  620.   620   params.enableShortSlotTime = false;
  621.   621   params.enableShortPlcpPreamble = false;
  622.   622   params.apType = WIFI_PHY_STANDARD_80211n_2_4GHZ;
  623.   623   params.apSupportsGreenfield = true;
  624.   624   params.nWifiB = 0;
  625.   625   params.bHasTraffic = false;
  626.   626   params.nWifiG = 1;
  627.   627   params.gHasTraffic = false;
  628.   628   params.nWifiNNonGreenfield = 0;
  629.   629   params.nNonGreenfieldHasTraffic = false;
  630.   630   params.nWifiNGreenfield = 1;
  631.   631   params.nGreenfieldHasTraffic = true;
  632.   632   throughput = experiment.Run (params);
  633.   633   if (verifyResults && (throughput < 44 || throughput > 45))
  634.   634     {
  635.   635       NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
  636.   636       exit (1);
  637.   637     }
  638.   638   std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
  639.   639
  640.   640   params.testName = "HT only with RIFS enabled";
  641.   641   params.enableErpProtection = false;
  642.   642   params.enableShortSlotTime = false;
  643.   643   params.enableShortPlcpPreamble = false;
  644.   644   params.apType = WIFI_PHY_STANDARD_80211n_2_4GHZ;
  645.   645   params.apSupportsGreenfield = false;
  646.   646   params.rifsSupported = true;
  647.   647   params.rifsMode = false;
  648.   648   params.nWifiB = 0;
  649.   649   params.bHasTraffic = false;
  650.   650   params.nWifiG = 0;
  651.   651   params.gHasTraffic = false;
  652.   652   params.nWifiNNonGreenfield = 1;
  653.   653   params.nNonGreenfieldHasTraffic = true;
  654.   654   params.nWifiNGreenfield = 0;
  655.   655   params.nGreenfieldHasTraffic = false;
  656.   656   throughput = experiment.Run (params);
  657.   657   if (verifyResults && (throughput < 44 || throughput > 45))
  658.   658     {
  659.   659       NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
  660.   660       exit (1);
  661.   661     }
  662.   662   std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
  663.   663
  664.   664   params.testName = "Mixed HT/non-HT with RIFS enabled but not forbidden";
  665.   665   params.enableErpProtection = false;
  666.   666   params.enableShortSlotTime = false;
  667.   667   params.enableShortPlcpPreamble = false;
  668.   668   params.apType = WIFI_PHY_STANDARD_80211n_2_4GHZ;
  669.   669   params.apSupportsGreenfield = false;
  670.   670   params.rifsSupported = true;
  671.   671   params.rifsMode = false;
  672.   672   params.nWifiB = 0;
  673.   673   params.bHasTraffic = false;
  674.   674   params.nWifiG = 1;
  675.   675   params.gHasTraffic = false;
  676.   676   params.nWifiNNonGreenfield = 1;
  677.   677   params.nNonGreenfieldHasTraffic = true;
  678.   678   params.nWifiNGreenfield = 0;
  679.   679   params.nGreenfieldHasTraffic = false;
  680.   680   throughput = experiment.Run (params);
  681.   681   if (verifyResults && (throughput < 44 || throughput > 45))
  682.   682     {
  683.   683       NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
  684.   684       exit (1);
  685.   685     }
  686.   686   std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
  687.   687
  688.   688   params.testName = "Mixed HT/non-HT with RIFS enabled but forbidden";
  689.   689   params.enableErpProtection = false;
  690.   690   params.enableShortSlotTime = false;
  691.   691   params.enableShortPlcpPreamble = false;
  692.   692   params.apType = WIFI_PHY_STANDARD_80211n_2_4GHZ;
  693.   693   params.apSupportsGreenfield = false;
  694.   694   params.rifsSupported = true;
  695.   695   params.rifsMode = true;
  696.   696   params.nWifiB = 0;
  697.   697   params.bHasTraffic = false;
  698.   698   params.nWifiG = 1;
  699.   699   params.gHasTraffic = false;
  700.   700   params.nWifiNNonGreenfield = 1;
  701.   701   params.nNonGreenfieldHasTraffic = true;
  702.   702   params.nWifiNGreenfield = 0;
  703.   703   params.nGreenfieldHasTraffic = false;
  704.   704   throughput = experiment.Run (params);
  705.   705   if (verifyResults && (throughput < 43 || throughput > 44))
  706.   706     {
  707.   707       NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
  708.   708       exit (1);
  709.   709     }
  710.   710   std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
  711.   711
  712.   712   return 0;
  713.   713 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement