A Discrete-Event Network Simulator
API
wifi-mixed-network.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2016 S├ębastien Deronne
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: S├ębastien Deronne <sebastien.deronne@gmail.com>
19  */
20 
21 #include "ns3/command-line.h"
22 #include "ns3/config.h"
23 #include "ns3/string.h"
24 #include "ns3/pointer.h"
25 #include "ns3/log.h"
26 #include "ns3/yans-wifi-helper.h"
27 #include "ns3/ssid.h"
28 #include "ns3/mobility-helper.h"
29 #include "ns3/internet-stack-helper.h"
30 #include "ns3/ipv4-address-helper.h"
31 #include "ns3/udp-client-server-helper.h"
32 #include "ns3/on-off-helper.h"
33 #include "ns3/yans-wifi-channel.h"
34 #include "ns3/wifi-net-device.h"
35 #include "ns3/qos-txop.h"
36 #include "ns3/wifi-mac.h"
37 #include "ns3/packet-sink-helper.h"
38 #include "ns3/packet-sink.h"
39 #include "ns3/ht-configuration.h"
40 
41 // This example shows how to configure mixed networks (i.e. mixed b/g and HT/non-HT) and how are performance in several scenarios.
42 //
43 // The example compares first g only and mixed b/g cases with various configurations depending on the following parameters:
44 // - protection mode that is configured on the AP;
45 // - whether short PLCP is supported by the 802.11b station;
46 // - whether short slot time is supported by both the 802.11g station and the AP.
47 //
48 // The example then compares HT only and mixed HT/non-HT cases with various configurations depending on the following parameters:
49 // - whether HT GF is supported by the AP;
50 // - whether HT GF is supported by all HT stations;
51 // - whether RIFS is enabled on HT stations;
52 // - RIFS mode that is configured on the AP.
53 //
54 // The output results show that the presence of an 802.11b station strongly affects 802.11g performance.
55 // Protection mechanisms ensure that the NAV value of 802.11b stations is set correctly in case of 802.11g transmissions.
56 // In practice, those protection mechanism add a lot of overhead, resulting in reduced performance. CTS-To-Self introduces
57 // less overhead than Rts-Cts, but is not heard by hidden stations (and is thus generally only recommended as a protection
58 // mechanism for access points). Since short slot time is disabled once an 802.11b station enters the network, benefits from
59 // short slot time are only observed in a g only configuration.
60 //
61 // 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
62 // 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
63 // Block ACK together with a TXOP duration of 3008 microseconds have been set.
64 //
65 // The user can also select the payload size and can choose either an UDP or a TCP connection.
66 // Example: ./waf --run "wifi-mixed-network --isUdp=1"
67 
68 using namespace ns3;
69 
70 NS_LOG_COMPONENT_DEFINE ("MixedNetwork");
71 
72 struct Parameters
73 {
74  std::string testName;
76  std::string erpProtectionMode;
82  bool rifsMode;
83  uint32_t nWifiB;
85  uint32_t nWifiG;
89  uint32_t nWifiNGreenfield;
91  bool isUdp;
92  uint32_t payloadSize;
94 };
95 
96 class Experiment
97 {
98 public:
99  Experiment ();
100  double Run (Parameters params);
101 };
102 
104 {
105 }
106 
107 double
109 {
110  std::string apTypeString;
111  if (params.apType == WIFI_PHY_STANDARD_80211g)
112  {
113  apTypeString = "WIFI_PHY_STANDARD_80211g";
114  }
115  else if (params.apType == WIFI_PHY_STANDARD_80211n_2_4GHZ)
116  {
117  apTypeString = "WIFI_PHY_STANDARD_80211n_2_4GHZ";
118  }
119 
120  std::cout << "Run: " << params.testName
121  << "\n\t enableErpProtection=" << params.enableErpProtection
122  << "\n\t erpProtectionMode=" << params.erpProtectionMode
123  << "\n\t enableShortSlotTime=" << params.enableShortSlotTime
124  << "\n\t enableShortPlcpPreamble=" << params.enableShortPlcpPreamble
125  << "\n\t apType=" << apTypeString
126  << "\n\t apSupportsGreenfield=" << params.apSupportsGreenfield
127  << "\n\t rifsSupported=" << params.rifsSupported
128  << "\n\t rifsMode=" << params.rifsMode
129  << "\n\t nWifiB=" << params.nWifiB
130  << "\n\t bHasTraffic=" << params.bHasTraffic
131  << "\n\t nWifiG=" << params.nWifiG
132  << "\n\t gHasTraffic=" << params.gHasTraffic
133  << "\n\t nWifiNNonGreenfield=" << params.nWifiNNonGreenfield
134  << "\n\t nNonGreenfieldHasTraffic=" << params.nNonGreenfieldHasTraffic
135  << "\n\t nWifiNGreenfield=" << params.nWifiNGreenfield
136  << "\n\t nGreenfieldHasTraffic=" << params.nGreenfieldHasTraffic
137  << std::endl;
138 
139  Config::SetDefault ("ns3::WifiRemoteStationManager::ErpProtectionMode", StringValue (params.erpProtectionMode));
140 
141  double throughput = 0;
142  uint32_t nWifiB = params.nWifiB;
143  uint32_t nWifiG = params.nWifiG;
144  uint32_t nWifiNNGF = params.nWifiNNonGreenfield;
145  uint32_t nWifiNGF = params.nWifiNGreenfield;
146  double simulationTime = params.simulationTime;
147  uint32_t payloadSize = params.payloadSize;
148 
149  NodeContainer wifiBStaNodes;
150  wifiBStaNodes.Create (nWifiB);
151  NodeContainer wifiGStaNodes;
152  wifiGStaNodes.Create (nWifiG);
153  NodeContainer wifiNNGFStaNodes;
154  wifiNNGFStaNodes.Create (nWifiNNGF);
155  NodeContainer wifiNGFStaNodes;
156  wifiNGFStaNodes.Create (nWifiNGF);
158  wifiApNode.Create (1);
159 
161  channel.AddPropagationLoss ("ns3::RangePropagationLossModel");
162 
164  phy.SetPcapDataLinkType (WifiPhyHelper::DLT_IEEE802_11_RADIO);
165  phy.SetChannel (channel.Create ());
166 
168  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
169 
170  // 802.11b STA
171  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
172 
174  Ssid ssid = Ssid ("ns-3-ssid");
175 
176  mac.SetType ("ns3::StaWifiMac",
177  "Ssid", SsidValue (ssid),
178  "ShortSlotTimeSupported", BooleanValue (params.enableShortSlotTime));
179 
180  // Configure the PLCP preamble type: long or short
181  phy.Set ("ShortPlcpPreambleSupported", BooleanValue (params.enableShortPlcpPreamble));
182 
183  NetDeviceContainer bStaDevice;
184  bStaDevice = wifi.Install (phy, mac, wifiBStaNodes);
185 
186  // 802.11b/g STA
187  wifi.SetStandard (WIFI_PHY_STANDARD_80211g);
188  NetDeviceContainer gStaDevice;
189  gStaDevice = wifi.Install (phy, mac, wifiGStaNodes);
190 
191  // 802.11b/g/n STA
193  NetDeviceContainer nNGFStaDevice, nGFStaDevice;
194  mac.SetType ("ns3::StaWifiMac",
195  "Ssid", SsidValue (ssid),
196  "BE_BlockAckThreshold", UintegerValue (2),
197  "ShortSlotTimeSupported", BooleanValue (params.enableShortSlotTime));
198  nNGFStaDevice = wifi.Install (phy, mac, wifiNNGFStaNodes);
199  nGFStaDevice = wifi.Install (phy, mac, wifiNGFStaNodes);
200 
201  // AP
202  NetDeviceContainer apDevice;
203  wifi.SetStandard (params.apType);
204  mac.SetType ("ns3::ApWifiMac",
205  "Ssid", SsidValue (ssid),
206  "EnableBeaconJitter", BooleanValue (false),
207  "BE_BlockAckThreshold", UintegerValue (2),
208  "RifsMode", BooleanValue (params.rifsMode),
209  "EnableNonErpProtection", BooleanValue (params.enableErpProtection),
210  "ShortSlotTimeSupported", BooleanValue (params.enableShortSlotTime));
211  apDevice = wifi.Install (phy, mac, wifiApNode);
212 
213  // Set TXOP limit
215  {
216  Ptr<NetDevice> dev = wifiApNode.Get (0)->GetDevice (0);
217  Ptr<WifiNetDevice> wifi_dev = DynamicCast<WifiNetDevice> (dev);
218  Ptr<HtConfiguration> htConfiguration = wifi_dev->GetHtConfiguration ();
219  htConfiguration->SetGreenfieldSupported (params.apSupportsGreenfield);
220  htConfiguration->SetRifsSupported (params.rifsSupported);
221  Ptr<WifiMac> wifi_mac = wifi_dev->GetMac ();
222  PointerValue ptr;
223  wifi_mac->GetAttribute ("BE_Txop", ptr);
224  Ptr<QosTxop> edca = ptr.Get<QosTxop> ();
225  edca->SetTxopLimit (MicroSeconds (3008));
226  }
227  if (nWifiNNGF > 0)
228  {
229  Ptr<NetDevice> dev = wifiNNGFStaNodes.Get (0)->GetDevice (0);
230  Ptr<WifiNetDevice> wifi_dev = DynamicCast<WifiNetDevice> (dev);
231  Ptr<HtConfiguration> htConfiguration = wifi_dev->GetHtConfiguration ();
232  htConfiguration->SetRifsSupported (params.rifsSupported);
233  Ptr<WifiMac> wifi_mac = wifi_dev->GetMac ();
234  PointerValue ptr;
235  wifi_mac->GetAttribute ("BE_Txop", ptr);
236  Ptr<QosTxop> edca = ptr.Get<QosTxop> ();
237  edca->SetTxopLimit (MicroSeconds (3008));
238  }
239  if (nWifiNGF > 0)
240  {
241  Ptr<NetDevice> dev = wifiNGFStaNodes.Get (0)->GetDevice (0);
242  Ptr<WifiNetDevice> wifi_dev = DynamicCast<WifiNetDevice> (dev);
243  Ptr<HtConfiguration> htConfiguration = wifi_dev->GetHtConfiguration ();
244  htConfiguration->SetGreenfieldSupported (true);
245  htConfiguration->SetRifsSupported (params.rifsSupported);
246  Ptr<WifiMac> wifi_mac = wifi_dev->GetMac ();
247  PointerValue ptr;
248  wifi_mac->GetAttribute ("BE_Txop", ptr);
249  Ptr<QosTxop> edca = ptr.Get<QosTxop> ();
250  edca->SetTxopLimit (MicroSeconds (3008));
251  }
252 
253  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/BE_MaxAmpduSize", UintegerValue (0)); //Disable A-MPDU
254 
255  // Define mobility model
257  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
258 
259  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
260  for (uint32_t i = 0; i < nWifiB; i++)
261  {
262  positionAlloc->Add (Vector (5.0, 0.0, 0.0));
263  }
264  for (uint32_t i = 0; i < nWifiG; i++)
265  {
266  positionAlloc->Add (Vector (0.0, 5.0, 0.0));
267  }
268  for (uint32_t i = 0; i < nWifiNNGF; i++)
269  {
270  positionAlloc->Add (Vector (0.0, 0.0, 5.0));
271  }
272  for (uint32_t i = 0; i < nWifiNGF; i++)
273  {
274  positionAlloc->Add (Vector (0.0, 0.0, 5.0));
275  }
276 
277  mobility.SetPositionAllocator (positionAlloc);
278  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
279  mobility.Install (wifiApNode);
280  mobility.Install (wifiBStaNodes);
281  mobility.Install (wifiGStaNodes);
282  mobility.Install (wifiNNGFStaNodes);
283  mobility.Install (wifiNGFStaNodes);
284 
285  // Internet stack
287  stack.Install (wifiApNode);
288  stack.Install (wifiBStaNodes);
289  stack.Install (wifiGStaNodes);
290  stack.Install (wifiNNGFStaNodes);
291  stack.Install (wifiNGFStaNodes);
292 
294  address.SetBase ("192.168.1.0", "255.255.255.0");
295  Ipv4InterfaceContainer bStaInterface;
296  bStaInterface = address.Assign (bStaDevice);
297  Ipv4InterfaceContainer gStaInterface;
298  gStaInterface = address.Assign (gStaDevice);
299  Ipv4InterfaceContainer nNGFStaInterface;
300  nNGFStaInterface = address.Assign (nNGFStaDevice);
301  Ipv4InterfaceContainer nGFStaInterface;
302  nGFStaInterface = address.Assign (nGFStaDevice);
303  Ipv4InterfaceContainer ApInterface;
304  ApInterface = address.Assign (apDevice);
305 
306  // Setting applications
307  if (params.isUdp)
308  {
309  uint16_t port = 9;
310  UdpServerHelper server (port);
311  ApplicationContainer serverApp = server.Install (wifiApNode);
312  serverApp.Start (Seconds (0.0));
313  serverApp.Stop (Seconds (simulationTime + 1));
314 
315  UdpClientHelper client (ApInterface.GetAddress (0), port);
316  client.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
317  client.SetAttribute ("Interval", TimeValue (Time ("0.0002"))); //packets/s
318  client.SetAttribute ("PacketSize", UintegerValue (payloadSize));
319 
321  if (params.bHasTraffic)
322  {
323  clientApps.Add (client.Install (wifiBStaNodes));
324  }
325  if (params.gHasTraffic)
326  {
327  clientApps.Add (client.Install (wifiGStaNodes));
328  }
329  if (params.nNonGreenfieldHasTraffic)
330  {
331  clientApps.Add (client.Install (wifiNNGFStaNodes));
332  }
333  if (params.nGreenfieldHasTraffic)
334  {
335  clientApps.Add (client.Install (wifiNGFStaNodes));
336  }
337  clientApps.Start (Seconds (1.0));
338  clientApps.Stop (Seconds (simulationTime + 1));
339 
340  Simulator::Stop (Seconds (simulationTime + 1));
341  Simulator::Run ();
342 
343  uint64_t totalPacketsThrough = DynamicCast<UdpServer> (serverApp.Get (0))->GetReceived ();
344  throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0);
345  }
346  else
347  {
348  uint16_t port = 50000;
349  Address localAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
350  PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", localAddress);
351 
352  ApplicationContainer serverApp = packetSinkHelper.Install (wifiApNode.Get (0));
353  serverApp.Start (Seconds (0.0));
354  serverApp.Stop (Seconds (simulationTime + 1));
355 
356  OnOffHelper onoff ("ns3::TcpSocketFactory", Ipv4Address::GetAny ());
357  onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
358  onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
359  onoff.SetAttribute ("PacketSize", UintegerValue (payloadSize));
360  onoff.SetAttribute ("DataRate", DataRateValue (150000000)); //bit/s
361 
362  AddressValue remoteAddress (InetSocketAddress (ApInterface.GetAddress (0), port));
363  onoff.SetAttribute ("Remote", remoteAddress);
364 
366  if (params.bHasTraffic)
367  {
368  clientApps.Add (onoff.Install (wifiBStaNodes));
369  }
370  if (params.gHasTraffic)
371  {
372  clientApps.Add (onoff.Install (wifiGStaNodes));
373  }
374  if (params.nNonGreenfieldHasTraffic)
375  {
376  clientApps.Add (onoff.Install (wifiNNGFStaNodes));
377  }
378  if (params.nGreenfieldHasTraffic)
379  {
380  clientApps.Add (onoff.Install (wifiNGFStaNodes));
381  }
382  clientApps.Start (Seconds (1.0));
383  clientApps.Stop (Seconds (simulationTime + 1));
384 
385  Simulator::Stop (Seconds (simulationTime + 1));
386  Simulator::Run ();
387 
388  uint64_t totalPacketsThrough = DynamicCast<PacketSink> (serverApp.Get (0))->GetTotalRx ();
389  throughput += totalPacketsThrough * 8 / (simulationTime * 1000000.0);
390  }
392  return throughput;
393 }
394 
395 int main (int argc, char *argv[])
396 {
397  Parameters params;
398  params.testName = "";
399  params.enableErpProtection = false;
400  params.erpProtectionMode = "Cts-To-Self";
401  params.enableShortSlotTime = false;
402  params.enableShortPlcpPreamble = false;
404  params.apSupportsGreenfield = false;
405  params.rifsSupported = false;
406  params.rifsMode = false;
407  params.nWifiB = 0;
408  params.bHasTraffic = false;
409  params.nWifiG = 1;
410  params.gHasTraffic = true;
411  params.nWifiNNonGreenfield = 0;
412  params.nNonGreenfieldHasTraffic = false;
413  params.nWifiNGreenfield = 0;
414  params.nGreenfieldHasTraffic = false;
415  params.isUdp = true;
416  params.payloadSize = 1472; //bytes
417  params.simulationTime = 10; //seconds
418 
419  bool verifyResults = 0; //used for regression
420 
422  cmd.AddValue ("payloadSize", "Payload size in bytes", params.payloadSize);
423  cmd.AddValue ("simulationTime", "Simulation time in seconds", params.simulationTime);
424  cmd.AddValue ("isUdp", "UDP if set to 1, TCP otherwise", params.isUdp);
425  cmd.AddValue ("verifyResults", "Enable/disable results verification at the end of the simulation", verifyResults);
426  cmd.Parse (argc, argv);
427 
429  double throughput = 0;
430 
431  params.testName = "g only with all g features disabled";
432  throughput = experiment.Run (params);
433  if (verifyResults && (throughput < 22.5 || throughput > 23.5))
434  {
435  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
436  exit (1);
437  }
438  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
439 
440  params.testName = "g only with short slot time enabled";
441  params.enableErpProtection = false;
442  params.enableShortSlotTime = true;
443  params.enableShortPlcpPreamble = false;
444  params.nWifiB = 0;
445  throughput = experiment.Run (params);
446  if (verifyResults && (throughput < 29 || throughput > 30))
447  {
448  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
449  exit (1);
450  }
451  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
452 
453  params.testName = "Mixed b/g with all g features disabled";
454  params.enableErpProtection = false;
455  params.enableShortSlotTime = false;
456  params.enableShortPlcpPreamble = false;
457  params.nWifiB = 1;
458  throughput = experiment.Run (params);
459  if (verifyResults && (throughput < 22.5 || throughput > 23.5))
460  {
461  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
462  exit (1);
463  }
464  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
465 
466  params.testName = "Mixed b/g with short plcp preamble enabled";
467  params.enableErpProtection = false;
468  params.enableShortSlotTime = false;
469  params.enableShortPlcpPreamble = true;
470  params.nWifiB = 1;
471  throughput = experiment.Run (params);
472  if (verifyResults && (throughput < 22.5 || throughput > 23.5))
473  {
474  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
475  exit (1);
476  }
477  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
478 
479  params.testName = "Mixed b/g with short slot time enabled using RTS-CTS protection";
480  params.enableErpProtection = true;
481  params.erpProtectionMode = "Rts-Cts";
482  params.enableShortSlotTime = false;
483  params.enableShortPlcpPreamble = false;
484  params.nWifiB = 1;
485  throughput = experiment.Run (params);
486  if (verifyResults && (throughput < 19 || throughput > 20))
487  {
488  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
489  exit (1);
490  }
491  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
492 
493  params.testName = "Mixed b/g with short plcp preamble enabled using RTS-CTS protection";
494  params.enableErpProtection = true;
495  params.enableShortSlotTime = false;
496  params.enableShortPlcpPreamble = true;
497  params.nWifiB = 1;
498  throughput = experiment.Run (params);
499  if (verifyResults && (throughput < 19 || throughput > 20))
500  {
501  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
502  exit (1);
503  }
504  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
505 
506  params.testName = "Mixed b/g with short slot time enabled using CTS-TO-SELF protection";
507  params.enableErpProtection = true;
508  params.erpProtectionMode = "Cts-To-Self";
509  params.enableShortSlotTime = false;
510  params.enableShortPlcpPreamble = false;
511  params.nWifiB = 1;
512  throughput = experiment.Run (params);
513  if (verifyResults && (throughput < 20.5 || throughput > 21.5))
514  {
515  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
516  exit (1);
517  }
518  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
519 
520  params.testName = "Mixed b/g with short plcp preamble enabled using CTS-TO-SELF protection";
521  params.enableErpProtection = true;
522  params.enableShortSlotTime = false;
523  params.enableShortPlcpPreamble = true;
524  params.nWifiB = 1;
525  throughput = experiment.Run (params);
526  if (verifyResults && (throughput < 20.5 || throughput > 21.5))
527  {
528  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
529  exit (1);
530  }
531  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
532 
533  params.testName = "HT GF not supported";
534  params.enableErpProtection = false;
535  params.enableShortSlotTime = false;
536  params.enableShortPlcpPreamble = false;
538  params.apSupportsGreenfield = false;
539  params.nWifiB = 0;
540  params.bHasTraffic = false;
541  params.nWifiG = 0;
542  params.gHasTraffic = false;
543  params.nWifiNNonGreenfield = 1;
544  params.nNonGreenfieldHasTraffic = true;
545  params.nWifiNGreenfield = 0;
546  params.nGreenfieldHasTraffic = false;
547  throughput = experiment.Run (params);
548  if (verifyResults && (throughput < 43 || throughput > 44))
549  {
550  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
551  exit (1);
552  }
553  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
554 
555  params.testName = "HT only with GF used";
556  params.enableErpProtection = false;
557  params.enableShortSlotTime = false;
558  params.enableShortPlcpPreamble = false;
560  params.apSupportsGreenfield = true;
561  params.nWifiB = 0;
562  params.bHasTraffic = false;
563  params.nWifiG = 0;
564  params.gHasTraffic = false;
565  params.nWifiNNonGreenfield = 0;
566  params.nNonGreenfieldHasTraffic = false;
567  params.nWifiNGreenfield = 1;
568  params.nGreenfieldHasTraffic = true;
569  throughput = experiment.Run (params);
570  if (verifyResults && (throughput < 44 || throughput > 45))
571  {
572  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
573  exit (1);
574  }
575  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
576 
577  params.testName = "HT only with GF allowed but disabled by protection";
578  params.enableErpProtection = false;
579  params.enableShortSlotTime = false;
580  params.enableShortPlcpPreamble = false;
582  params.apSupportsGreenfield = true;
583  params.nWifiB = 0;
584  params.bHasTraffic = false;
585  params.nWifiG = 0;
586  params.gHasTraffic = false;
587  params.nWifiNNonGreenfield = 1;
588  params.nNonGreenfieldHasTraffic = false;
589  params.nWifiNGreenfield = 1;
590  params.nGreenfieldHasTraffic = true;
591  throughput = experiment.Run (params);
592  if (verifyResults && (throughput < 43 || throughput > 44))
593  {
594  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
595  exit (1);
596  }
597  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
598 
599  params.testName = "HT only with GF not supported by the receiver";
600  params.enableErpProtection = false;
601  params.enableShortSlotTime = false;
602  params.enableShortPlcpPreamble = false;
604  params.apSupportsGreenfield = false;
605  params.nWifiB = 0;
606  params.bHasTraffic = false;
607  params.nWifiG = 0;
608  params.gHasTraffic = false;
609  params.nWifiNNonGreenfield = 0;
610  params.nNonGreenfieldHasTraffic = false;
611  params.nWifiNGreenfield = 1;
612  params.nGreenfieldHasTraffic = true;
613  throughput = experiment.Run (params);
614  if (verifyResults && (throughput < 43 || throughput > 44))
615  {
616  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
617  exit (1);
618  }
619  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
620 
621  params.testName = "Mixed HT/non-HT with GF enabled";
622  params.enableErpProtection = false;
623  params.enableShortSlotTime = false;
624  params.enableShortPlcpPreamble = false;
626  params.apSupportsGreenfield = true;
627  params.nWifiB = 0;
628  params.bHasTraffic = false;
629  params.nWifiG = 1;
630  params.gHasTraffic = false;
631  params.nWifiNNonGreenfield = 0;
632  params.nNonGreenfieldHasTraffic = false;
633  params.nWifiNGreenfield = 1;
634  params.nGreenfieldHasTraffic = true;
635  throughput = experiment.Run (params);
636  if (verifyResults && (throughput < 44 || throughput > 45))
637  {
638  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
639  exit (1);
640  }
641  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
642 
643  params.testName = "HT only with RIFS enabled";
644  params.enableErpProtection = false;
645  params.enableShortSlotTime = false;
646  params.enableShortPlcpPreamble = false;
648  params.apSupportsGreenfield = false;
649  params.rifsSupported = true;
650  params.rifsMode = false;
651  params.nWifiB = 0;
652  params.bHasTraffic = false;
653  params.nWifiG = 0;
654  params.gHasTraffic = false;
655  params.nWifiNNonGreenfield = 1;
656  params.nNonGreenfieldHasTraffic = true;
657  params.nWifiNGreenfield = 0;
658  params.nGreenfieldHasTraffic = false;
659  throughput = experiment.Run (params);
660  if (verifyResults && (throughput < 44 || throughput > 45))
661  {
662  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
663  exit (1);
664  }
665  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
666 
667  params.testName = "Mixed HT/non-HT with RIFS enabled but not forbidden";
668  params.enableErpProtection = false;
669  params.enableShortSlotTime = false;
670  params.enableShortPlcpPreamble = false;
672  params.apSupportsGreenfield = false;
673  params.rifsSupported = true;
674  params.rifsMode = false;
675  params.nWifiB = 0;
676  params.bHasTraffic = false;
677  params.nWifiG = 1;
678  params.gHasTraffic = false;
679  params.nWifiNNonGreenfield = 1;
680  params.nNonGreenfieldHasTraffic = true;
681  params.nWifiNGreenfield = 0;
682  params.nGreenfieldHasTraffic = false;
683  throughput = experiment.Run (params);
684  if (verifyResults && (throughput < 44 || throughput > 45))
685  {
686  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
687  exit (1);
688  }
689  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
690 
691  params.testName = "Mixed HT/non-HT with RIFS enabled but forbidden";
692  params.enableErpProtection = false;
693  params.enableShortSlotTime = false;
694  params.enableShortPlcpPreamble = false;
696  params.apSupportsGreenfield = false;
697  params.rifsSupported = true;
698  params.rifsMode = true;
699  params.nWifiB = 0;
700  params.bHasTraffic = false;
701  params.nWifiG = 1;
702  params.gHasTraffic = false;
703  params.nWifiNNonGreenfield = 1;
704  params.nNonGreenfieldHasTraffic = true;
705  params.nWifiNGreenfield = 0;
706  params.nGreenfieldHasTraffic = false;
707  throughput = experiment.Run (params);
708  if (verifyResults && (throughput < 43 || throughput > 44))
709  {
710  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
711  exit (1);
712  }
713  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
714 
715  return 0;
716 }
ERP-OFDM PHY (Clause 19, Section 19.5)
Helper class for UAN CW MAC example.
Definition: wifi-adhoc.cc:40
holds a vector of ns3::Application pointers.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
an Inet address class
static Ipv4Address GetAny(void)
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
std::string testName
AttributeValue implementation for Boolean.
Definition: boolean.h:36
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Hold variables of type string.
Definition: string.h:41
Make it easy to create and manage PHY objects for the yans model.
static YansWifiChannelHelper Default(void)
Create a channel helper in a default working state.
void Set(std::string path, const AttributeValue &value)
Definition: config.cc:805
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Definition: node.cc:142
Handle packet fragmentation and retransmissions for QoS data frames as well as MSDU aggregation (A-MS...
Definition: qos-txop.h:91
static void Run(void)
Run the simulation.
Definition: simulator.cc:170
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:204
ApplicationContainer Install(NodeContainer c) const
Install an ns3::PacketSinkApplication on each node of the input container configured with all the att...
aggregate IP/TCP/UDP functionality to existing Nodes.
uint32_t nWifiNGreenfield
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes...
cmd
Definition: second.py:35
HT PHY for the 2.4 GHz band (clause 20)
WifiPhyStandard apType
static YansWifiPhyHelper Default(void)
Create a phy helper in a default working state.
helps to create WifiNetDevice objects
Definition: wifi-helper.h:299
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
Definition: on-off-helper.h:42
stack
Definition: first.py:34
uint16_t port
Definition: dsdv-manet.cc:45
a polymophic address class
Definition: address.h:90
channel
Definition: third.py:92
mobility
Definition: third.py:108
phy
Definition: third.py:93
WifiPhyStandard
Identifies the PHY specification that a Wifi device is configured to use.
ApplicationContainer Install(NodeContainer c) const
Install an ns3::OnOffApplication on each node of the input container configured with all the attribut...
Create a client application which sends UDP packets carrying a 32bit sequence number and a 64 bit tim...
AttributeValue implementation for Time.
Definition: nstime.h:1124
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
Hold an unsigned integer type.
Definition: uinteger.h:44
ssid
Definition: third.py:100
holds a vector of ns3::NetDevice pointers
mac
Definition: third.py:99
Create a server application which waits for input UDP packets and uses the information carried into t...
uint32_t payloadSize
wifiApNode
Definition: third.py:90
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
Parse command-line arguments.
Definition: command-line.h:213
bool nGreenfieldHasTraffic
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:134
void SetAttribute(std::string name, const AttributeValue &value)
Record an attribute to be set in each Application after it is is created.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
Hold objects of type Ptr<T>.
Definition: pointer.h:36
std::string erpProtectionMode
address
Definition: first.py:37
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18)
manage and create wifi channel objects for the yans model.
create MAC layers for a ns3::WifiNetDevice.
uint32_t nWifiNNonGreenfield
The IEEE 802.11 SSID Information Element.
Definition: ssid.h:35
Gnuplot2dDataset Run(const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, const WifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel)
Definition: wifi-adhoc.cc:119
wifi
Definition: third.py:96
Helper class used to assign positions and mobility models to nodes.
AttributeValue implementation for Address.
Definition: address.h:278
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter...
Ptr< WifiMac > GetMac(void) const
ApplicationContainer Install(NodeContainer c)
Create one UDP server application on each of the Nodes in the NodeContainer.
void experiment(std::string queue_disc_type)
AttributeValue implementation for DataRate.
Definition: data-rate.h:242
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
Definition: txop.cc:276
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:178
bool nNonGreenfieldHasTraffic
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1062
AttributeValue implementation for Ssid.
Definition: ssid.h:110
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:810
Ptr< T > Get(void) const
Definition: pointer.h:194
void Add(Vector v)
Add a position to the list of positions.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
clientApps
Definition: first.py:54
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1078
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition: log.h:256
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< HtConfiguration > GetHtConfiguration(void) const
Include Radiotap link layer information.
Definition: wifi-helper.h:178
void GetAttribute(std::string name, AttributeValue &value) const
Get the value of an attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:223
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
bool enableShortPlcpPreamble