A Discrete-Event Network Simulator
API
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 
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 //
42 // The example compares first g only and mixed b/g cases with various configurations depending on the following parameters:
43 // - protection mode that is configured on the AP;
44 // - whether short PLCP is supported by the 802.11b station;
45 // - whether short slot time is supported by both the 802.11g station and the AP.
46 //
47 // The example then compares HT only and mixed HT/non-HT cases with various configurations depending on the following parameters:
48 // - whether HT GF is supported by the AP;
49 // - whether HT GF is supported by all HT stations;
50 // - whether RIFS is enabled on HT stations;
51 // - RIFS mode that is configured on the AP.
52 //
53 // The output results show that the presence of an 802.11b station strongly affects 802.11g performance.
54 // Protection mechanisms ensure that the NAV value of 802.11b stations is set correctly in case of 802.11g transmissions.
55 // In practice, those protection mechanism add a lot of overhead, resulting in reduced performance. CTS-To-Self introduces
56 // less overhead than Rts-Cts, but is not heard by hidden stations (and is thus generally only recommended as a protection
57 // mechanism for access points). Since short slot time is disabled once an 802.11b station enters the network, benefits from
58 // short slot time are only observed in a g only configuration.
59 //
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 // 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 // Block ACK together with a TXOP duration of 3008 microseconds have been set.
63 //
64 // The user can also select the payload size and can choose either an UDP or a TCP connection.
65 // Example: ./waf --run "mixed-network --isUdp=1"
66 
67 using namespace ns3;
68 
69 NS_LOG_COMPONENT_DEFINE ("MixedNetwork");
70 
71 struct Parameters
72 {
73  std::string testName;
75  std::string erpProtectionMode;
81  bool rifsMode;
82  uint32_t nWifiB;
84  uint32_t nWifiG;
88  uint32_t nWifiNGreenfield;
90  bool isUdp;
91  uint32_t payloadSize;
93 };
94 
96 {
97 public:
98  Experiment ();
99  double Run (Parameters params);
100 };
101 
103 {
104 }
105 
106 double
108 {
109  std::string apTypeString;
110  if (params.apType == WIFI_PHY_STANDARD_80211g)
111  {
112  apTypeString = "WIFI_PHY_STANDARD_80211g";
113  }
114  else if (params.apType == WIFI_PHY_STANDARD_80211n_2_4GHZ)
115  {
116  apTypeString = "WIFI_PHY_STANDARD_80211n_2_4GHZ";
117  }
118 
119  std::cout << "Run: " << params.testName
120  << "\n\t enableErpProtection=" << params.enableErpProtection
121  << "\n\t erpProtectionMode=" << params.erpProtectionMode
122  << "\n\t enableShortSlotTime=" << params.enableShortSlotTime
123  << "\n\t enableShortPlcpPreamble=" << params.enableShortPlcpPreamble
124  << "\n\t apType=" << apTypeString
125  << "\n\t apSupportsGreenfield=" << params.apSupportsGreenfield
126  << "\n\t rifsSupported=" << params.rifsSupported
127  << "\n\t rifsMode=" << params.rifsMode
128  << "\n\t nWifiB=" << params.nWifiB
129  << "\n\t bHasTraffic=" << params.bHasTraffic
130  << "\n\t nWifiG=" << params.nWifiG
131  << "\n\t gHasTraffic=" << params.gHasTraffic
132  << "\n\t nWifiNNonGreenfield=" << params.nWifiNNonGreenfield
133  << "\n\t nNonGreenfieldHasTraffic=" << params.nNonGreenfieldHasTraffic
134  << "\n\t nWifiNGreenfield=" << params.nWifiNGreenfield
135  << "\n\t nGreenfieldHasTraffic=" << params.nGreenfieldHasTraffic
136  << std::endl;
137 
138  Config::SetDefault ("ns3::WifiRemoteStationManager::ErpProtectionMode", StringValue (params.erpProtectionMode));
139 
140  double throughput = 0;
141  uint32_t nWifiB = params.nWifiB;
142  uint32_t nWifiG = params.nWifiG;
143  uint32_t nWifiNNGF = params.nWifiNNonGreenfield;
144  uint32_t nWifiNGF = params.nWifiNGreenfield;
145  double simulationTime = params.simulationTime;
146  uint32_t payloadSize = params.payloadSize;
147 
148  NodeContainer wifiBStaNodes;
149  wifiBStaNodes.Create (nWifiB);
150  NodeContainer wifiGStaNodes;
151  wifiGStaNodes.Create (nWifiG);
152  NodeContainer wifiNNGFStaNodes;
153  wifiNNGFStaNodes.Create (nWifiNNGF);
154  NodeContainer wifiNGFStaNodes;
155  wifiNGFStaNodes.Create (nWifiNGF);
157  wifiApNode.Create (1);
158 
160  channel.AddPropagationLoss ("ns3::RangePropagationLossModel");
161 
163  phy.SetPcapDataLinkType (WifiPhyHelper::DLT_IEEE802_11_RADIO);
164  phy.SetChannel (channel.Create ());
165 
167  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
168 
169  // 802.11b STA
170  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
171 
173  Ssid ssid = Ssid ("ns-3-ssid");
174 
175  mac.SetType ("ns3::StaWifiMac",
176  "Ssid", SsidValue (ssid),
177  "ShortSlotTimeSupported", BooleanValue (params.enableShortSlotTime));
178 
179  // Configure the PLCP preamble type: long or short
180  phy.Set ("ShortPlcpPreambleSupported", BooleanValue (params.enableShortPlcpPreamble));
181 
182  NetDeviceContainer bStaDevice;
183  bStaDevice = wifi.Install (phy, mac, wifiBStaNodes);
184 
185  // 802.11b/g STA
186  wifi.SetStandard (WIFI_PHY_STANDARD_80211g);
187  NetDeviceContainer gStaDevice;
188  gStaDevice = wifi.Install (phy, mac, wifiGStaNodes);
189 
190  // 802.11b/g/n STA
192  NetDeviceContainer nNGFStaDevice, nGFStaDevice;
193  mac.SetType ("ns3::StaWifiMac",
194  "RifsSupported", BooleanValue (params.rifsSupported),
195  "Ssid", SsidValue (ssid),
196  "BE_MaxAmpduSize", UintegerValue (0),
197  "BE_BlockAckThreshold", UintegerValue (2),
198  "ShortSlotTimeSupported", BooleanValue (params.enableShortSlotTime));
199  phy.Set ("GreenfieldEnabled", BooleanValue (false));
200  nNGFStaDevice = wifi.Install (phy, mac, wifiNNGFStaNodes);
201  phy.Set ("GreenfieldEnabled", BooleanValue (true));
202  nGFStaDevice = wifi.Install (phy, mac, wifiNGFStaNodes);
203 
204  // AP
205  NetDeviceContainer apDevice;
206  wifi.SetStandard (params.apType);
207  mac.SetType ("ns3::ApWifiMac",
208  "Ssid", SsidValue (ssid),
209  "EnableBeaconJitter", BooleanValue (false),
210  "BE_MaxAmpduSize", UintegerValue (0),
211  "BE_BlockAckThreshold", UintegerValue (2),
212  "RifsSupported", BooleanValue (params.rifsSupported),
213  "RifsMode", BooleanValue (params.rifsMode),
214  "EnableNonErpProtection", BooleanValue (params.enableErpProtection),
215  "ShortSlotTimeSupported", BooleanValue (params.enableShortSlotTime));
216  phy.Set ("GreenfieldEnabled", BooleanValue (params.apSupportsGreenfield));
217  apDevice = wifi.Install (phy, mac, wifiApNode);
218 
219  // Set TXOP limit
221  {
222  Ptr<NetDevice> dev = wifiApNode.Get (0)->GetDevice (0);
223  Ptr<WifiNetDevice> wifi_dev = DynamicCast<WifiNetDevice> (dev);
224  Ptr<WifiMac> wifi_mac = wifi_dev->GetMac ();
225  PointerValue ptr;
226  wifi_mac->GetAttribute ("BE_Txop", ptr);
227  Ptr<QosTxop> edca = ptr.Get<QosTxop> ();
228  edca->SetTxopLimit (MicroSeconds (3008));
229  }
230  if (nWifiNNGF > 0)
231  {
232  Ptr<NetDevice> dev = wifiNNGFStaNodes.Get (0)->GetDevice (0);
233  Ptr<WifiNetDevice> wifi_dev = DynamicCast<WifiNetDevice> (dev);
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  if (nWifiNGF > 0)
241  {
242  Ptr<NetDevice> dev = wifiNGFStaNodes.Get (0)->GetDevice (0);
243  Ptr<WifiNetDevice> wifi_dev = DynamicCast<WifiNetDevice> (dev);
244  Ptr<WifiMac> wifi_mac = wifi_dev->GetMac ();
245  PointerValue ptr;
246  wifi_mac->GetAttribute ("BE_Txop", ptr);
247  Ptr<QosTxop> edca = ptr.Get<QosTxop> ();
248  edca->SetTxopLimit (MicroSeconds (3008));
249  }
250 
251  // Define mobility model
253  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
254 
255  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
256  for (uint32_t i = 0; i < nWifiB; i++)
257  {
258  positionAlloc->Add (Vector (5.0, 0.0, 0.0));
259  }
260  for (uint32_t i = 0; i < nWifiG; i++)
261  {
262  positionAlloc->Add (Vector (0.0, 5.0, 0.0));
263  }
264  for (uint32_t i = 0; i < nWifiNNGF; i++)
265  {
266  positionAlloc->Add (Vector (0.0, 0.0, 5.0));
267  }
268  for (uint32_t i = 0; i < nWifiNGF; i++)
269  {
270  positionAlloc->Add (Vector (0.0, 0.0, 5.0));
271  }
272 
273  mobility.SetPositionAllocator (positionAlloc);
274  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
275  mobility.Install (wifiApNode);
276  mobility.Install (wifiBStaNodes);
277  mobility.Install (wifiGStaNodes);
278  mobility.Install (wifiNNGFStaNodes);
279  mobility.Install (wifiNGFStaNodes);
280 
281  // Internet stack
283  stack.Install (wifiApNode);
284  stack.Install (wifiBStaNodes);
285  stack.Install (wifiGStaNodes);
286  stack.Install (wifiNNGFStaNodes);
287  stack.Install (wifiNGFStaNodes);
288 
290  address.SetBase ("192.168.1.0", "255.255.255.0");
291  Ipv4InterfaceContainer bStaInterface;
292  bStaInterface = address.Assign (bStaDevice);
293  Ipv4InterfaceContainer gStaInterface;
294  gStaInterface = address.Assign (gStaDevice);
295  Ipv4InterfaceContainer nNGFStaInterface;
296  nNGFStaInterface = address.Assign (nNGFStaDevice);
297  Ipv4InterfaceContainer nGFStaInterface;
298  nGFStaInterface = address.Assign (nGFStaDevice);
299  Ipv4InterfaceContainer ApInterface;
300  ApInterface = address.Assign (apDevice);
301 
302  // Setting applications
303  if (params.isUdp)
304  {
305  uint16_t port = 9;
306  UdpServerHelper server (port);
307  ApplicationContainer serverApp = server.Install (wifiApNode);
308  serverApp.Start (Seconds (0.0));
309  serverApp.Stop (Seconds (simulationTime + 1));
310 
311  UdpClientHelper client (ApInterface.GetAddress (0), port);
312  client.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
313  client.SetAttribute ("Interval", TimeValue (Time ("0.0002"))); //packets/s
314  client.SetAttribute ("PacketSize", UintegerValue (payloadSize));
315 
317  if (params.bHasTraffic)
318  {
319  clientApps.Add (client.Install (wifiBStaNodes));
320  }
321  if (params.gHasTraffic)
322  {
323  clientApps.Add (client.Install (wifiGStaNodes));
324  }
325  if (params.nNonGreenfieldHasTraffic)
326  {
327  clientApps.Add (client.Install (wifiNNGFStaNodes));
328  }
329  if (params.nGreenfieldHasTraffic)
330  {
331  clientApps.Add (client.Install (wifiNGFStaNodes));
332  }
333  clientApps.Start (Seconds (1.0));
334  clientApps.Stop (Seconds (simulationTime + 1));
335 
336  Simulator::Stop (Seconds (simulationTime + 1));
337  Simulator::Run ();
338 
339  uint64_t totalPacketsThrough = DynamicCast<UdpServer> (serverApp.Get (0))->GetReceived ();
340  throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0);
341  }
342  else
343  {
344  uint16_t port = 50000;
345  Address localAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
346  PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", localAddress);
347 
348  ApplicationContainer serverApp = packetSinkHelper.Install (wifiApNode.Get (0));
349  serverApp.Start (Seconds (0.0));
350  serverApp.Stop (Seconds (simulationTime + 1));
351 
352  OnOffHelper onoff ("ns3::TcpSocketFactory", Ipv4Address::GetAny ());
353  onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
354  onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
355  onoff.SetAttribute ("PacketSize", UintegerValue (payloadSize));
356  onoff.SetAttribute ("DataRate", DataRateValue (150000000)); //bit/s
357 
358  AddressValue remoteAddress (InetSocketAddress (ApInterface.GetAddress (0), port));
359  onoff.SetAttribute ("Remote", remoteAddress);
360 
362  if (params.bHasTraffic)
363  {
364  clientApps.Add (onoff.Install (wifiBStaNodes));
365  }
366  if (params.gHasTraffic)
367  {
368  clientApps.Add (onoff.Install (wifiGStaNodes));
369  }
370  if (params.nNonGreenfieldHasTraffic)
371  {
372  clientApps.Add (onoff.Install (wifiNNGFStaNodes));
373  }
374  if (params.nGreenfieldHasTraffic)
375  {
376  clientApps.Add (onoff.Install (wifiNGFStaNodes));
377  }
378  clientApps.Start (Seconds (1.0));
379  clientApps.Stop (Seconds (simulationTime + 1));
380 
381  Simulator::Stop (Seconds (simulationTime + 1));
382  Simulator::Run ();
383 
384  uint64_t totalPacketsThrough = DynamicCast<PacketSink> (serverApp.Get (0))->GetTotalRx ();
385  throughput += totalPacketsThrough * 8 / (simulationTime * 1000000.0);
386  }
388  return throughput;
389 }
390 
391 int main (int argc, char *argv[])
392 {
393  Parameters params;
394  params.testName = "";
395  params.enableErpProtection = false;
396  params.erpProtectionMode = "Cts-To-Self";
397  params.enableShortSlotTime = false;
398  params.enableShortPlcpPreamble = false;
400  params.apSupportsGreenfield = false;
401  params.rifsSupported = false;
402  params.rifsMode = false;
403  params.nWifiB = 0;
404  params.bHasTraffic = false;
405  params.nWifiG = 1;
406  params.gHasTraffic = true;
407  params.nWifiNNonGreenfield = 0;
408  params.nNonGreenfieldHasTraffic = false;
409  params.nWifiNGreenfield = 0;
410  params.nGreenfieldHasTraffic = false;
411  params.isUdp = true;
412  params.payloadSize = 1472; //bytes
413  params.simulationTime = 10; //seconds
414 
415  bool verifyResults = 0; //used for regression
416 
418  cmd.AddValue ("payloadSize", "Payload size in bytes", params.payloadSize);
419  cmd.AddValue ("simulationTime", "Simulation time in seconds", params.simulationTime);
420  cmd.AddValue ("isUdp", "UDP if set to 1, TCP otherwise", params.isUdp);
421  cmd.AddValue ("verifyResults", "Enable/disable results verification at the end of the simulation", verifyResults);
422  cmd.Parse (argc, argv);
423 
425  double throughput = 0;
426 
427  params.testName = "g only with all g features disabled";
428  throughput = experiment.Run (params);
429  if (verifyResults && (throughput < 22.5 || throughput > 23.5))
430  {
431  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
432  exit (1);
433  }
434  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
435 
436  params.testName = "g only with short slot time enabled";
437  params.enableErpProtection = false;
438  params.enableShortSlotTime = true;
439  params.enableShortPlcpPreamble = false;
440  params.nWifiB = 0;
441  throughput = experiment.Run (params);
442  if (verifyResults && (throughput < 29 || throughput > 30))
443  {
444  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
445  exit (1);
446  }
447  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
448 
449  params.testName = "Mixed b/g with all g features disabled";
450  params.enableErpProtection = false;
451  params.enableShortSlotTime = false;
452  params.enableShortPlcpPreamble = false;
453  params.nWifiB = 1;
454  throughput = experiment.Run (params);
455  if (verifyResults && (throughput < 22.5 || throughput > 23.5))
456  {
457  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
458  exit (1);
459  }
460  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
461 
462  params.testName = "Mixed b/g with short plcp preamble enabled";
463  params.enableErpProtection = false;
464  params.enableShortSlotTime = false;
465  params.enableShortPlcpPreamble = true;
466  params.nWifiB = 1;
467  throughput = experiment.Run (params);
468  if (verifyResults && (throughput < 22.5 || throughput > 23.5))
469  {
470  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
471  exit (1);
472  }
473  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
474 
475  params.testName = "Mixed b/g with short slot time enabled using RTS-CTS protection";
476  params.enableErpProtection = true;
477  params.erpProtectionMode = "Rts-Cts";
478  params.enableShortSlotTime = false;
479  params.enableShortPlcpPreamble = false;
480  params.nWifiB = 1;
481  throughput = experiment.Run (params);
482  if (verifyResults && (throughput < 19 || throughput > 20))
483  {
484  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
485  exit (1);
486  }
487  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
488 
489  params.testName = "Mixed b/g with short plcp preamble enabled using RTS-CTS protection";
490  params.enableErpProtection = true;
491  params.enableShortSlotTime = false;
492  params.enableShortPlcpPreamble = true;
493  params.nWifiB = 1;
494  throughput = experiment.Run (params);
495  if (verifyResults && (throughput < 19 || throughput > 20))
496  {
497  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
498  exit (1);
499  }
500  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
501 
502  params.testName = "Mixed b/g with short slot time enabled using CTS-TO-SELF protection";
503  params.enableErpProtection = true;
504  params.erpProtectionMode = "Cts-To-Self";
505  params.enableShortSlotTime = false;
506  params.enableShortPlcpPreamble = false;
507  params.nWifiB = 1;
508  throughput = experiment.Run (params);
509  if (verifyResults && (throughput < 20.5 || throughput > 21.5))
510  {
511  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
512  exit (1);
513  }
514  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
515 
516  params.testName = "Mixed b/g with short plcp preamble enabled using CTS-TO-SELF protection";
517  params.enableErpProtection = true;
518  params.enableShortSlotTime = false;
519  params.enableShortPlcpPreamble = true;
520  params.nWifiB = 1;
521  throughput = experiment.Run (params);
522  if (verifyResults && (throughput < 20.5 || throughput > 21.5))
523  {
524  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
525  exit (1);
526  }
527  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
528 
529  params.testName = "HT GF not supported";
530  params.enableErpProtection = false;
531  params.enableShortSlotTime = false;
532  params.enableShortPlcpPreamble = false;
534  params.apSupportsGreenfield = false;
535  params.nWifiB = 0;
536  params.bHasTraffic = false;
537  params.nWifiG = 0;
538  params.gHasTraffic = false;
539  params.nWifiNNonGreenfield = 1;
540  params.nNonGreenfieldHasTraffic = true;
541  params.nWifiNGreenfield = 0;
542  params.nGreenfieldHasTraffic = false;
543  throughput = experiment.Run (params);
544  if (verifyResults && (throughput < 43 || throughput > 44))
545  {
546  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
547  exit (1);
548  }
549  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
550 
551  params.testName = "HT only with GF used";
552  params.enableErpProtection = false;
553  params.enableShortSlotTime = false;
554  params.enableShortPlcpPreamble = false;
556  params.apSupportsGreenfield = true;
557  params.nWifiB = 0;
558  params.bHasTraffic = false;
559  params.nWifiG = 0;
560  params.gHasTraffic = false;
561  params.nWifiNNonGreenfield = 0;
562  params.nNonGreenfieldHasTraffic = false;
563  params.nWifiNGreenfield = 1;
564  params.nGreenfieldHasTraffic = true;
565  throughput = experiment.Run (params);
566  if (verifyResults && (throughput < 44 || throughput > 45))
567  {
568  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
569  exit (1);
570  }
571  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
572 
573  params.testName = "HT only with GF allowed but disabled by protection";
574  params.enableErpProtection = false;
575  params.enableShortSlotTime = false;
576  params.enableShortPlcpPreamble = false;
578  params.apSupportsGreenfield = true;
579  params.nWifiB = 0;
580  params.bHasTraffic = false;
581  params.nWifiG = 0;
582  params.gHasTraffic = false;
583  params.nWifiNNonGreenfield = 1;
584  params.nNonGreenfieldHasTraffic = false;
585  params.nWifiNGreenfield = 1;
586  params.nGreenfieldHasTraffic = true;
587  throughput = experiment.Run (params);
588  if (verifyResults && (throughput < 43 || throughput > 44))
589  {
590  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
591  exit (1);
592  }
593  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
594 
595  params.testName = "HT only with GF not supported by the receiver";
596  params.enableErpProtection = false;
597  params.enableShortSlotTime = false;
598  params.enableShortPlcpPreamble = false;
600  params.apSupportsGreenfield = false;
601  params.nWifiB = 0;
602  params.bHasTraffic = false;
603  params.nWifiG = 0;
604  params.gHasTraffic = false;
605  params.nWifiNNonGreenfield = 0;
606  params.nNonGreenfieldHasTraffic = false;
607  params.nWifiNGreenfield = 1;
608  params.nGreenfieldHasTraffic = true;
609  throughput = experiment.Run (params);
610  if (verifyResults && (throughput < 43 || throughput > 44))
611  {
612  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
613  exit (1);
614  }
615  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
616 
617  params.testName = "Mixed HT/non-HT with GF enabled";
618  params.enableErpProtection = false;
619  params.enableShortSlotTime = false;
620  params.enableShortPlcpPreamble = false;
622  params.apSupportsGreenfield = true;
623  params.nWifiB = 0;
624  params.bHasTraffic = false;
625  params.nWifiG = 1;
626  params.gHasTraffic = false;
627  params.nWifiNNonGreenfield = 0;
628  params.nNonGreenfieldHasTraffic = false;
629  params.nWifiNGreenfield = 1;
630  params.nGreenfieldHasTraffic = true;
631  throughput = experiment.Run (params);
632  if (verifyResults && (throughput < 44 || throughput > 45))
633  {
634  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
635  exit (1);
636  }
637  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
638 
639  params.testName = "HT only with RIFS enabled";
640  params.enableErpProtection = false;
641  params.enableShortSlotTime = false;
642  params.enableShortPlcpPreamble = false;
644  params.apSupportsGreenfield = false;
645  params.rifsSupported = true;
646  params.rifsMode = false;
647  params.nWifiB = 0;
648  params.bHasTraffic = false;
649  params.nWifiG = 0;
650  params.gHasTraffic = false;
651  params.nWifiNNonGreenfield = 1;
652  params.nNonGreenfieldHasTraffic = true;
653  params.nWifiNGreenfield = 0;
654  params.nGreenfieldHasTraffic = false;
655  throughput = experiment.Run (params);
656  if (verifyResults && (throughput < 44 || throughput > 45))
657  {
658  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
659  exit (1);
660  }
661  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
662 
663  params.testName = "Mixed HT/non-HT with RIFS enabled but not forbidden";
664  params.enableErpProtection = false;
665  params.enableShortSlotTime = false;
666  params.enableShortPlcpPreamble = false;
668  params.apSupportsGreenfield = false;
669  params.rifsSupported = true;
670  params.rifsMode = false;
671  params.nWifiB = 0;
672  params.bHasTraffic = false;
673  params.nWifiG = 1;
674  params.gHasTraffic = false;
675  params.nWifiNNonGreenfield = 1;
676  params.nNonGreenfieldHasTraffic = true;
677  params.nWifiNGreenfield = 0;
678  params.nGreenfieldHasTraffic = false;
679  throughput = experiment.Run (params);
680  if (verifyResults && (throughput < 44 || throughput > 45))
681  {
682  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
683  exit (1);
684  }
685  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
686 
687  params.testName = "Mixed HT/non-HT with RIFS enabled but forbidden";
688  params.enableErpProtection = false;
689  params.enableShortSlotTime = false;
690  params.enableShortPlcpPreamble = false;
692  params.apSupportsGreenfield = false;
693  params.rifsSupported = true;
694  params.rifsMode = true;
695  params.nWifiB = 0;
696  params.bHasTraffic = false;
697  params.nWifiG = 1;
698  params.gHasTraffic = false;
699  params.nWifiNNonGreenfield = 1;
700  params.nNonGreenfieldHasTraffic = true;
701  params.nWifiNGreenfield = 0;
702  params.nGreenfieldHasTraffic = false;
703  throughput = experiment.Run (params);
704  if (verifyResults && (throughput < 43 || throughput > 44))
705  {
706  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
707  exit (1);
708  }
709  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
710 
711  return 0;
712 }
ERP-OFDM PHY (Clause 19, Section 19.5)
Helper class for UAN CW MAC example.
holds a vector of ns3::Application pointers.
double simulationTime
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.
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:90
bool enableShortSlotTime
static void Run(void)
Run the simulation.
Definition: simulator.cc:226
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
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.
bool bHasTraffic
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:230
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:85
mobility
Definition: third.py:101
phy
Definition: third.py:86
uint32_t nWifiB
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...
double Run(Parameters params)
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:1076
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
Hold an unsigned integer type.
Definition: uinteger.h:44
ssid
Definition: third.py:93
holds a vector of ns3::NetDevice pointers
mac
Definition: third.py:92
Create a server application which waits for input UDP packets and uses the information carried into t...
uint32_t payloadSize
wifiApNode
Definition: third.py:83
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:190
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
bool enableErpProtection
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 nWifiG
uint32_t nWifiNNonGreenfield
The IEEE 802.11 SSID Information Element.
Definition: ssid.h:35
wifi
Definition: third.py:89
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.
bool rifsSupported
AttributeValue implementation for DataRate.
Definition: data-rate.h:242
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
Definition: txop.cc:264
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:234
bool nNonGreenfieldHasTraffic
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1014
AttributeValue implementation for Ssid.
Definition: ssid.h:110
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:782
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:1030
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition: log.h:254
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Include Radiotap link layer information.
Definition: wifi-helper.h:111
bool apSupportsGreenfield
bool gHasTraffic
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
void experiment(bool enableCtsRts, std::string wifiManager)
Run single 10 seconds experiment.