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 PPDU format 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 //
52 // The output results show that the presence of an 802.11b station strongly affects 802.11g performance.
53 // Protection mechanisms ensure that the NAV value of 802.11b stations is set correctly in case of 802.11g transmissions.
54 // In practice, those protection mechanism add a lot of overhead, resulting in reduced performance. CTS-To-Self introduces
55 // less overhead than Rts-Cts, but is not heard by hidden stations (and is thus generally only recommended as a protection
56 // mechanism for access points). Since short slot time is disabled once an 802.11b station enters the network, benefits from
57 // short slot time are only observed in a g only configuration.
58 //
59 // HT and mixed-HT results show that HT GF permits to slightly increase performance when all HT stations support GF mode
60 //
61 // The user can also select the payload size and can choose either an UDP or a TCP connection.
62 // Example: ./waf --run "wifi-mixed-network --isUdp=1"
63 
64 using namespace ns3;
65 
66 NS_LOG_COMPONENT_DEFINE ("MixedNetwork");
67 
68 struct Parameters
69 {
70  std::string testName;
72  std::string erpProtectionMode;
77  uint32_t nWifiB;
79  uint32_t nWifiG;
83  uint32_t nWifiNGreenfield;
85  bool isUdp;
86  uint32_t payloadSize;
88 };
89 
90 class Experiment
91 {
92 public:
93  Experiment ();
94  double Run (Parameters params);
95 };
96 
98 {
99 }
100 
101 double
103 {
104  std::string apTypeString;
105  if (params.apType == WIFI_STANDARD_80211g)
106  {
107  apTypeString = "WIFI_STANDARD_80211g";
108  }
109  else if (params.apType == WIFI_STANDARD_80211n_2_4GHZ)
110  {
111  apTypeString = "WIFI_STANDARD_80211n_2_4GHZ";
112  }
113 
114  std::cout << "Run: " << params.testName
115  << "\n\t enableErpProtection=" << params.enableErpProtection
116  << "\n\t erpProtectionMode=" << params.erpProtectionMode
117  << "\n\t enableShortSlotTime=" << params.enableShortSlotTime
118  << "\n\t enableShortPhyPreamble=" << params.enableShortPhyPreamble
119  << "\n\t apType=" << apTypeString
120  << "\n\t apSupportsGreenfield=" << params.apSupportsGreenfield
121  << "\n\t nWifiB=" << params.nWifiB
122  << "\n\t bHasTraffic=" << params.bHasTraffic
123  << "\n\t nWifiG=" << params.nWifiG
124  << "\n\t gHasTraffic=" << params.gHasTraffic
125  << "\n\t nWifiNNonGreenfield=" << params.nWifiNNonGreenfield
126  << "\n\t nNonGreenfieldHasTraffic=" << params.nNonGreenfieldHasTraffic
127  << "\n\t nWifiNGreenfield=" << params.nWifiNGreenfield
128  << "\n\t nGreenfieldHasTraffic=" << params.nGreenfieldHasTraffic
129  << std::endl;
130 
131  Config::SetDefault ("ns3::WifiRemoteStationManager::ErpProtectionMode", StringValue (params.erpProtectionMode));
132 
133  double throughput = 0;
134  uint32_t nWifiB = params.nWifiB;
135  uint32_t nWifiG = params.nWifiG;
136  uint32_t nWifiNNGF = params.nWifiNNonGreenfield;
137  uint32_t nWifiNGF = params.nWifiNGreenfield;
138  double simulationTime = params.simulationTime;
139  uint32_t payloadSize = params.payloadSize;
140 
141  NodeContainer wifiBStaNodes;
142  wifiBStaNodes.Create (nWifiB);
143  NodeContainer wifiGStaNodes;
144  wifiGStaNodes.Create (nWifiG);
145  NodeContainer wifiNNGFStaNodes;
146  wifiNNGFStaNodes.Create (nWifiNNGF);
147  NodeContainer wifiNGFStaNodes;
148  wifiNGFStaNodes.Create (nWifiNGF);
150  wifiApNode.Create (1);
151 
153  channel.AddPropagationLoss ("ns3::RangePropagationLossModel");
154 
156  phy.SetPcapDataLinkType (WifiPhyHelper::DLT_IEEE802_11_RADIO);
157  phy.SetChannel (channel.Create ());
158 
160  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
161 
162  // 802.11b STA
163  wifi.SetStandard (WIFI_STANDARD_80211b);
164 
166  Ssid ssid = Ssid ("ns-3-ssid");
167 
168  mac.SetType ("ns3::StaWifiMac",
169  "Ssid", SsidValue (ssid),
170  "ShortSlotTimeSupported", BooleanValue (params.enableShortSlotTime));
171 
172  // Configure the PHY preamble type: long or short
173  phy.Set ("ShortPlcpPreambleSupported", BooleanValue (params.enableShortPhyPreamble));
174 
175  NetDeviceContainer bStaDevice;
176  bStaDevice = wifi.Install (phy, mac, wifiBStaNodes);
177 
178  // 802.11b/g STA
179  wifi.SetStandard (WIFI_STANDARD_80211g);
180  NetDeviceContainer gStaDevice;
181  gStaDevice = wifi.Install (phy, mac, wifiGStaNodes);
182 
183  // 802.11b/g/n STA
184  wifi.SetStandard (WIFI_STANDARD_80211n_2_4GHZ);
185  NetDeviceContainer nNGFStaDevice, nGFStaDevice;
186  mac.SetType ("ns3::StaWifiMac",
187  "Ssid", SsidValue (ssid),
188  "BE_BlockAckThreshold", UintegerValue (2),
189  "ShortSlotTimeSupported", BooleanValue (params.enableShortSlotTime));
190  nNGFStaDevice = wifi.Install (phy, mac, wifiNNGFStaNodes);
191  nGFStaDevice = wifi.Install (phy, mac, wifiNGFStaNodes);
192 
193  // AP
194  NetDeviceContainer apDevice;
195  wifi.SetStandard (params.apType);
196  mac.SetType ("ns3::ApWifiMac",
197  "Ssid", SsidValue (ssid),
198  "EnableBeaconJitter", BooleanValue (false),
199  "BE_BlockAckThreshold", UintegerValue (2),
200  "EnableNonErpProtection", BooleanValue (params.enableErpProtection),
201  "ShortSlotTimeSupported", BooleanValue (params.enableShortSlotTime));
202  apDevice = wifi.Install (phy, mac, wifiApNode);
203 
204  // Set TXOP limit
205  if (params.apType == WIFI_STANDARD_80211n_2_4GHZ)
206  {
207  Ptr<NetDevice> dev = wifiApNode.Get (0)->GetDevice (0);
208  Ptr<WifiNetDevice> wifi_dev = DynamicCast<WifiNetDevice> (dev);
209  Ptr<HtConfiguration> htConfiguration = wifi_dev->GetHtConfiguration ();
210  htConfiguration->SetGreenfieldSupported (params.apSupportsGreenfield);
211  Ptr<WifiMac> wifi_mac = wifi_dev->GetMac ();
212  PointerValue ptr;
213  wifi_mac->GetAttribute ("BE_Txop", ptr);
214  Ptr<QosTxop> edca = ptr.Get<QosTxop> ();
215  edca->SetTxopLimit (MicroSeconds (3008));
216  }
217  if (nWifiNNGF > 0)
218  {
219  Ptr<NetDevice> dev = wifiNNGFStaNodes.Get (0)->GetDevice (0);
220  Ptr<WifiNetDevice> wifi_dev = DynamicCast<WifiNetDevice> (dev);
221  Ptr<HtConfiguration> htConfiguration = wifi_dev->GetHtConfiguration ();
222  Ptr<WifiMac> wifi_mac = wifi_dev->GetMac ();
223  PointerValue ptr;
224  wifi_mac->GetAttribute ("BE_Txop", ptr);
225  Ptr<QosTxop> edca = ptr.Get<QosTxop> ();
226  edca->SetTxopLimit (MicroSeconds (3008));
227  }
228  if (nWifiNGF > 0)
229  {
230  Ptr<NetDevice> dev = wifiNGFStaNodes.Get (0)->GetDevice (0);
231  Ptr<WifiNetDevice> wifi_dev = DynamicCast<WifiNetDevice> (dev);
232  Ptr<HtConfiguration> htConfiguration = wifi_dev->GetHtConfiguration ();
233  htConfiguration->SetGreenfieldSupported (true);
234  Ptr<WifiMac> wifi_mac = wifi_dev->GetMac ();
235  PointerValue ptr;
236  wifi_mac->GetAttribute ("BE_Txop", ptr);
237  Ptr<QosTxop> edca = ptr.Get<QosTxop> ();
238  edca->SetTxopLimit (MicroSeconds (3008));
239  }
240 
241  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/BE_MaxAmpduSize", UintegerValue (0)); //Disable A-MPDU
242 
243  // Define mobility model
245  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
246 
247  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
248  for (uint32_t i = 0; i < nWifiB; i++)
249  {
250  positionAlloc->Add (Vector (5.0, 0.0, 0.0));
251  }
252  for (uint32_t i = 0; i < nWifiG; i++)
253  {
254  positionAlloc->Add (Vector (0.0, 5.0, 0.0));
255  }
256  for (uint32_t i = 0; i < nWifiNNGF; i++)
257  {
258  positionAlloc->Add (Vector (0.0, 0.0, 5.0));
259  }
260  for (uint32_t i = 0; i < nWifiNGF; i++)
261  {
262  positionAlloc->Add (Vector (0.0, 0.0, 5.0));
263  }
264 
265  mobility.SetPositionAllocator (positionAlloc);
266  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
267  mobility.Install (wifiApNode);
268  mobility.Install (wifiBStaNodes);
269  mobility.Install (wifiGStaNodes);
270  mobility.Install (wifiNNGFStaNodes);
271  mobility.Install (wifiNGFStaNodes);
272 
273  // Internet stack
275  stack.Install (wifiApNode);
276  stack.Install (wifiBStaNodes);
277  stack.Install (wifiGStaNodes);
278  stack.Install (wifiNNGFStaNodes);
279  stack.Install (wifiNGFStaNodes);
280 
282  address.SetBase ("192.168.1.0", "255.255.255.0");
283  Ipv4InterfaceContainer bStaInterface;
284  bStaInterface = address.Assign (bStaDevice);
285  Ipv4InterfaceContainer gStaInterface;
286  gStaInterface = address.Assign (gStaDevice);
287  Ipv4InterfaceContainer nNGFStaInterface;
288  nNGFStaInterface = address.Assign (nNGFStaDevice);
289  Ipv4InterfaceContainer nGFStaInterface;
290  nGFStaInterface = address.Assign (nGFStaDevice);
291  Ipv4InterfaceContainer ApInterface;
292  ApInterface = address.Assign (apDevice);
293 
294  // Setting applications
295  if (params.isUdp)
296  {
297  uint16_t port = 9;
298  UdpServerHelper server (port);
299  ApplicationContainer serverApp = server.Install (wifiApNode);
300  serverApp.Start (Seconds (0.0));
301  serverApp.Stop (Seconds (simulationTime + 1));
302 
303  UdpClientHelper client (ApInterface.GetAddress (0), port);
304  client.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
305  client.SetAttribute ("Interval", TimeValue (Time ("0.0002"))); //packets/s
306  client.SetAttribute ("PacketSize", UintegerValue (payloadSize));
307 
309  if (params.bHasTraffic)
310  {
311  clientApps.Add (client.Install (wifiBStaNodes));
312  }
313  if (params.gHasTraffic)
314  {
315  clientApps.Add (client.Install (wifiGStaNodes));
316  }
317  if (params.nNonGreenfieldHasTraffic)
318  {
319  clientApps.Add (client.Install (wifiNNGFStaNodes));
320  }
321  if (params.nGreenfieldHasTraffic)
322  {
323  clientApps.Add (client.Install (wifiNGFStaNodes));
324  }
325  clientApps.Start (Seconds (1.0));
326  clientApps.Stop (Seconds (simulationTime + 1));
327 
328  Simulator::Stop (Seconds (simulationTime + 1));
329  Simulator::Run ();
330 
331  uint64_t totalPacketsThrough = DynamicCast<UdpServer> (serverApp.Get (0))->GetReceived ();
332  throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0);
333  }
334  else
335  {
336  uint16_t port = 50000;
337  Address localAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
338  PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", localAddress);
339 
340  ApplicationContainer serverApp = packetSinkHelper.Install (wifiApNode.Get (0));
341  serverApp.Start (Seconds (0.0));
342  serverApp.Stop (Seconds (simulationTime + 1));
343 
344  OnOffHelper onoff ("ns3::TcpSocketFactory", Ipv4Address::GetAny ());
345  onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
346  onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
347  onoff.SetAttribute ("PacketSize", UintegerValue (payloadSize));
348  onoff.SetAttribute ("DataRate", DataRateValue (150000000)); //bit/s
349 
350  AddressValue remoteAddress (InetSocketAddress (ApInterface.GetAddress (0), port));
351  onoff.SetAttribute ("Remote", remoteAddress);
352 
354  if (params.bHasTraffic)
355  {
356  clientApps.Add (onoff.Install (wifiBStaNodes));
357  }
358  if (params.gHasTraffic)
359  {
360  clientApps.Add (onoff.Install (wifiGStaNodes));
361  }
362  if (params.nNonGreenfieldHasTraffic)
363  {
364  clientApps.Add (onoff.Install (wifiNNGFStaNodes));
365  }
366  if (params.nGreenfieldHasTraffic)
367  {
368  clientApps.Add (onoff.Install (wifiNGFStaNodes));
369  }
370  clientApps.Start (Seconds (1.0));
371  clientApps.Stop (Seconds (simulationTime + 1));
372 
373  Simulator::Stop (Seconds (simulationTime + 1));
374  Simulator::Run ();
375 
376  uint64_t totalPacketsThrough = DynamicCast<PacketSink> (serverApp.Get (0))->GetTotalRx ();
377  throughput += totalPacketsThrough * 8 / (simulationTime * 1000000.0);
378  }
380  return throughput;
381 }
382 
383 int main (int argc, char *argv[])
384 {
385  Parameters params;
386  params.testName = "";
387  params.enableErpProtection = false;
388  params.erpProtectionMode = "Cts-To-Self";
389  params.enableShortSlotTime = false;
390  params.enableShortPhyPreamble = false;
391  params.apType = WIFI_STANDARD_80211g;
392  params.apSupportsGreenfield = false;
393  params.nWifiB = 0;
394  params.bHasTraffic = false;
395  params.nWifiG = 1;
396  params.gHasTraffic = true;
397  params.nWifiNNonGreenfield = 0;
398  params.nNonGreenfieldHasTraffic = false;
399  params.nWifiNGreenfield = 0;
400  params.nGreenfieldHasTraffic = false;
401  params.isUdp = true;
402  params.payloadSize = 1472; //bytes
403  params.simulationTime = 10; //seconds
404 
405  bool verifyResults = 0; //used for regression
406 
407  CommandLine cmd (__FILE__);
408  cmd.AddValue ("payloadSize", "Payload size in bytes", params.payloadSize);
409  cmd.AddValue ("simulationTime", "Simulation time in seconds", params.simulationTime);
410  cmd.AddValue ("isUdp", "UDP if set to 1, TCP otherwise", params.isUdp);
411  cmd.AddValue ("verifyResults", "Enable/disable results verification at the end of the simulation", verifyResults);
412  cmd.Parse (argc, argv);
413 
415  double throughput = 0;
416 
417  params.testName = "g only with all g features disabled";
418  throughput = experiment.Run (params);
419  if (verifyResults && (throughput < 22.5 || throughput > 23.5))
420  {
421  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
422  exit (1);
423  }
424  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
425 
426  params.testName = "g only with short slot time enabled";
427  params.enableErpProtection = false;
428  params.enableShortSlotTime = true;
429  params.enableShortPhyPreamble = false;
430  params.nWifiB = 0;
431  throughput = experiment.Run (params);
432  if (verifyResults && (throughput < 29 || throughput > 30))
433  {
434  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
435  exit (1);
436  }
437  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
438 
439  params.testName = "Mixed b/g with all g features disabled";
440  params.enableErpProtection = false;
441  params.enableShortSlotTime = false;
442  params.enableShortPhyPreamble = false;
443  params.nWifiB = 1;
444  throughput = experiment.Run (params);
445  if (verifyResults && (throughput < 22.5 || throughput > 23.5))
446  {
447  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
448  exit (1);
449  }
450  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
451 
452  params.testName = "Mixed b/g with short plcp preamble enabled";
453  params.enableErpProtection = false;
454  params.enableShortSlotTime = false;
455  params.enableShortPhyPreamble = true;
456  params.nWifiB = 1;
457  throughput = experiment.Run (params);
458  if (verifyResults && (throughput < 22.5 || throughput > 23.5))
459  {
460  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
461  exit (1);
462  }
463  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
464 
465  params.testName = "Mixed b/g with short slot time enabled using RTS-CTS protection";
466  params.enableErpProtection = true;
467  params.erpProtectionMode = "Rts-Cts";
468  params.enableShortSlotTime = false;
469  params.enableShortPhyPreamble = false;
470  params.nWifiB = 1;
471  throughput = experiment.Run (params);
472  if (verifyResults && (throughput < 19 || throughput > 20))
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 plcp preamble enabled using RTS-CTS protection";
480  params.enableErpProtection = true;
481  params.enableShortSlotTime = false;
482  params.enableShortPhyPreamble = true;
483  params.nWifiB = 1;
484  throughput = experiment.Run (params);
485  if (verifyResults && (throughput < 19 || throughput > 20))
486  {
487  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
488  exit (1);
489  }
490  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
491 
492  params.testName = "Mixed b/g with short slot time enabled using CTS-TO-SELF protection";
493  params.enableErpProtection = true;
494  params.erpProtectionMode = "Cts-To-Self";
495  params.enableShortSlotTime = false;
496  params.enableShortPhyPreamble = false;
497  params.nWifiB = 1;
498  throughput = experiment.Run (params);
499  if (verifyResults && (throughput < 20.5 || throughput > 21.5))
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 plcp preamble enabled using CTS-TO-SELF protection";
507  params.enableErpProtection = true;
508  params.enableShortSlotTime = false;
509  params.enableShortPhyPreamble = true;
510  params.nWifiB = 1;
511  throughput = experiment.Run (params);
512  if (verifyResults && (throughput < 20.5 || throughput > 21.5))
513  {
514  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
515  exit (1);
516  }
517  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
518 
519  params.testName = "HT GF not supported";
520  params.enableErpProtection = false;
521  params.enableShortSlotTime = false;
522  params.enableShortPhyPreamble = false;
524  params.apSupportsGreenfield = false;
525  params.nWifiB = 0;
526  params.bHasTraffic = false;
527  params.nWifiG = 0;
528  params.gHasTraffic = false;
529  params.nWifiNNonGreenfield = 1;
530  params.nNonGreenfieldHasTraffic = true;
531  params.nWifiNGreenfield = 0;
532  params.nGreenfieldHasTraffic = false;
533  throughput = experiment.Run (params);
534  if (verifyResults && (throughput < 43 || throughput > 44))
535  {
536  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
537  exit (1);
538  }
539  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
540 
541  params.testName = "HT only with GF used";
542  params.enableErpProtection = false;
543  params.enableShortSlotTime = false;
544  params.enableShortPhyPreamble = false;
546  params.apSupportsGreenfield = true;
547  params.nWifiB = 0;
548  params.bHasTraffic = false;
549  params.nWifiG = 0;
550  params.gHasTraffic = false;
551  params.nWifiNNonGreenfield = 0;
552  params.nNonGreenfieldHasTraffic = false;
553  params.nWifiNGreenfield = 1;
554  params.nGreenfieldHasTraffic = true;
555  throughput = experiment.Run (params);
556  if (verifyResults && (throughput < 44 || throughput > 45))
557  {
558  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
559  exit (1);
560  }
561  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
562 
563  params.testName = "HT only with GF allowed but disabled by protection";
564  params.enableErpProtection = false;
565  params.enableShortSlotTime = false;
566  params.enableShortPhyPreamble = false;
568  params.apSupportsGreenfield = true;
569  params.nWifiB = 0;
570  params.bHasTraffic = false;
571  params.nWifiG = 0;
572  params.gHasTraffic = false;
573  params.nWifiNNonGreenfield = 1;
574  params.nNonGreenfieldHasTraffic = false;
575  params.nWifiNGreenfield = 1;
576  params.nGreenfieldHasTraffic = true;
577  throughput = experiment.Run (params);
578  if (verifyResults && (throughput < 43 || throughput > 44))
579  {
580  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
581  exit (1);
582  }
583  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
584 
585  params.testName = "HT only with GF not supported by the receiver";
586  params.enableErpProtection = false;
587  params.enableShortSlotTime = false;
588  params.enableShortPhyPreamble = false;
590  params.apSupportsGreenfield = false;
591  params.nWifiB = 0;
592  params.bHasTraffic = false;
593  params.nWifiG = 0;
594  params.gHasTraffic = false;
595  params.nWifiNNonGreenfield = 0;
596  params.nNonGreenfieldHasTraffic = false;
597  params.nWifiNGreenfield = 1;
598  params.nGreenfieldHasTraffic = true;
599  throughput = experiment.Run (params);
600  if (verifyResults && (throughput < 43 || throughput > 44))
601  {
602  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
603  exit (1);
604  }
605  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
606 
607  params.testName = "Mixed HT/non-HT with GF enabled";
608  params.enableErpProtection = false;
609  params.enableShortSlotTime = false;
610  params.enableShortPhyPreamble = false;
612  params.apSupportsGreenfield = true;
613  params.nWifiB = 0;
614  params.bHasTraffic = false;
615  params.nWifiG = 1;
616  params.gHasTraffic = false;
617  params.nWifiNNonGreenfield = 0;
618  params.nNonGreenfieldHasTraffic = false;
619  params.nWifiNGreenfield = 1;
620  params.nGreenfieldHasTraffic = true;
621  throughput = experiment.Run (params);
622  if (verifyResults && (throughput < 44 || throughput > 45))
623  {
624  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
625  exit (1);
626  }
627  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
628 
629  params.testName = "HT only";
630  params.enableErpProtection = false;
631  params.enableShortSlotTime = false;
632  params.enableShortPhyPreamble = false;
634  params.apSupportsGreenfield = false;
635  params.nWifiB = 0;
636  params.bHasTraffic = false;
637  params.nWifiG = 0;
638  params.gHasTraffic = false;
639  params.nWifiNNonGreenfield = 1;
640  params.nNonGreenfieldHasTraffic = true;
641  params.nWifiNGreenfield = 0;
642  params.nGreenfieldHasTraffic = false;
643  throughput = experiment.Run (params);
644  if (verifyResults && (throughput < 44 || throughput > 45))
645  {
646  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
647  exit (1);
648  }
649  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
650 
651  params.testName = "Mixed HT/non-HT";
652  params.enableErpProtection = false;
653  params.enableShortSlotTime = false;
654  params.enableShortPhyPreamble = false;
656  params.apSupportsGreenfield = false;
657  params.nWifiB = 0;
658  params.bHasTraffic = false;
659  params.nWifiG = 1;
660  params.gHasTraffic = false;
661  params.nWifiNNonGreenfield = 1;
662  params.nNonGreenfieldHasTraffic = true;
663  params.nWifiNGreenfield = 0;
664  params.nGreenfieldHasTraffic = false;
665  throughput = experiment.Run (params);
666  if (verifyResults && (throughput < 44 || throughput > 45))
667  {
668  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
669  exit (1);
670  }
671  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
672 
673  return 0;
674 }
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:103
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
Ptr< T > Get(void) const
Definition: pointer.h:201
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:839
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Definition: node.cc:144
Handle packet fragmentation and retransmissions for QoS data frames as well as MSDU aggregation (A-MS...
Definition: qos-txop.h:92
static void Run(void)
Run the simulation.
Definition: simulator.cc:172
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
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
static YansWifiPhyHelper Default(void)
Create a PHY helper in a default working state.
helps to create WifiNetDevice objects
Definition: wifi-helper.h:318
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:41
uint16_t port
Definition: dsdv-manet.cc:45
a polymophic address class
Definition: address.h:90
WifiStandard apType
channel
Definition: third.py:92
mobility
Definition: third.py:108
phy
Definition: third.py:93
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:1342
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:226
bool nGreenfieldHasTraffic
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:136
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.
WifiStandard
Identifies the allowed configurations that a Wifi device is configured to use.
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:44
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:229
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
Definition: txop.cc:277
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:180
bool nNonGreenfieldHasTraffic
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1278
AttributeValue implementation for Ssid.
Definition: ssid.h:105
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:849
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.
bool enableShortPhyPreamble
clientApps
Definition: first.py:61
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:1294
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition: log.h:257
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:180
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.