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/core-module.h"
22 #include "ns3/applications-module.h"
23 #include "ns3/wifi-module.h"
24 #include "ns3/mobility-module.h"
25 #include "ns3/internet-module.h"
26 
27 // This example shows how to configure mixed networks (i.e. mixed b/g and HT/non-HT) and how are performance in several scenarios.
28 //
29 // The example compares first g only and mixed b/g cases with various configurations depending on the following parameters:
30 // - protection mode that is configured on the AP;
31 // - whether short PLCP is supported by the 802.11b station;
32 // - whether short slot time is supported by both the 802.11g station and the AP.
33 //
34 // The example then compares HT only and mixed HT/non-HT cases with various configurations depending on the following parameters:
35 // - whether HT GF is supported by the AP;
36 // - whether HT GF is supported by all HT stations;
37 // - whether RIFS is enabled on HT stations;
38 // - RIFS mode that is configured on the AP.
39 //
40 // The output results show that the presence of an 802.11b station strongly affects 802.11g performance.
41 // Protection mechanisms ensure that the NAV value of 802.11b stations is set correctly in case of 802.11g transmissions.
42 // In practice, those protection mechanism add a lot of overhead, resulting in reduced performance. CTS-To-Self introduces
43 // less overhead than Rts-Cts, but is not heard by hidden stations (and is thus generally only recommended as a protection
44 // mechanism for access points). Since short slot time is disabled once an 802.11b station enters the network, benefits from
45 // short slot time are only observed in a g only configuration.
46 //
47 // 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
48 // 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
49 // Block ACK together with a TXOP duration of 3008 microseconds have been set.
50 //
51 // The user can also select the payload size and can choose either an UDP or a TCP connection.
52 // Example: ./waf --run "mixed-network --isUdp=1"
53 
54 using namespace ns3;
55 
56 NS_LOG_COMPONENT_DEFINE ("MixedNetwork");
57 
58 struct Parameters
59 {
60  std::string testName;
62  std::string erpProtectionMode;
68  bool rifsMode;
69  uint32_t nWifiB;
71  uint32_t nWifiG;
75  uint32_t nWifiNGreenfield;
77  bool isUdp;
78  uint32_t payloadSize;
79  uint32_t simulationTime;
80 };
81 
83 {
84 public:
85  Experiment ();
86  double Run (Parameters params);
87 };
88 
90 {
91 }
92 
93 double
95 {
96  std::string apTypeString;
97  if (params.apType == WIFI_PHY_STANDARD_80211g)
98  {
99  apTypeString = "WIFI_PHY_STANDARD_80211g";
100  }
101  else if (params.apType == WIFI_PHY_STANDARD_80211n_2_4GHZ)
102  {
103  apTypeString = "WIFI_PHY_STANDARD_80211n_2_4GHZ";
104  }
105 
106  std::cout << "Run: " << params.testName
107  << "\n\t enableErpProtection=" << params.enableErpProtection
108  << "\n\t erpProtectionMode=" << params.erpProtectionMode
109  << "\n\t enableShortSlotTime=" << params.enableShortSlotTime
110  << "\n\t enableShortPlcpPreamble=" << params.enableShortPlcpPreamble
111  << "\n\t apType=" << apTypeString
112  << "\n\t apSupportsGreenfield=" << params.apSupportsGreenfield
113  << "\n\t rifsSupported=" << params.rifsSupported
114  << "\n\t rifsMode=" << params.rifsMode
115  << "\n\t nWifiB=" << params.nWifiB
116  << "\n\t bHasTraffic=" << params.bHasTraffic
117  << "\n\t nWifiG=" << params.nWifiG
118  << "\n\t gHasTraffic=" << params.gHasTraffic
119  << "\n\t nWifiNNonGreenfield=" << params.nWifiNNonGreenfield
120  << "\n\t nNonGreenfieldHasTraffic=" << params.nNonGreenfieldHasTraffic
121  << "\n\t nWifiNGreenfield=" << params.nWifiNGreenfield
122  << "\n\t nGreenfieldHasTraffic=" << params.nGreenfieldHasTraffic
123  << std::endl;
124 
125  Config::SetDefault ("ns3::WifiRemoteStationManager::ErpProtectionMode", StringValue (params.erpProtectionMode));
126 
127  double throughput = 0;
128  uint32_t nWifiB = params.nWifiB;
129  uint32_t nWifiG = params.nWifiG;
130  uint32_t nWifiNNGF = params.nWifiNNonGreenfield;
131  uint32_t nWifiNGF = params.nWifiNGreenfield;
132  uint32_t simulationTime = params.simulationTime;
133  uint32_t payloadSize = params.payloadSize;
134 
135  NodeContainer wifiBStaNodes;
136  wifiBStaNodes.Create (nWifiB);
137  NodeContainer wifiGStaNodes;
138  wifiGStaNodes.Create (nWifiG);
139  NodeContainer wifiNNGFStaNodes;
140  wifiNNGFStaNodes.Create (nWifiNNGF);
141  NodeContainer wifiNGFStaNodes;
142  wifiNGFStaNodes.Create (nWifiNGF);
144  wifiApNode.Create (1);
145 
147  channel.AddPropagationLoss ("ns3::RangePropagationLossModel");
148 
151  phy.SetChannel (channel.Create ());
152 
154  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
155 
156  // 802.11b STA
158 
160  Ssid ssid = Ssid ("ns-3-ssid");
161 
162  mac.SetType ("ns3::StaWifiMac",
163  "Ssid", SsidValue (ssid),
164  "ShortSlotTimeSupported", BooleanValue (params.enableShortSlotTime));
165 
166  // Configure the PLCP preamble type: long or short
167  phy.Set ("ShortPlcpPreambleSupported", BooleanValue (params.enableShortPlcpPreamble));
168 
169  NetDeviceContainer bStaDevice;
170  bStaDevice = wifi.Install (phy, mac, wifiBStaNodes);
171 
172  // 802.11b/g STA
174  NetDeviceContainer gStaDevice;
175  gStaDevice = wifi.Install (phy, mac, wifiGStaNodes);
176 
177  // 802.11b/g/n STA
179  NetDeviceContainer nNGFStaDevice, nGFStaDevice;
180  mac.SetType ("ns3::StaWifiMac",
181  "RifsSupported", BooleanValue (params.rifsSupported),
182  "Ssid", SsidValue (ssid),
183  "BE_MaxAmpduSize", UintegerValue (0),
184  "BE_BlockAckThreshold", UintegerValue (2),
185  "ShortSlotTimeSupported", BooleanValue (params.enableShortSlotTime));
186  phy.Set ("GreenfieldEnabled", BooleanValue (false));
187  nNGFStaDevice = wifi.Install (phy, mac, wifiNNGFStaNodes);
188  phy.Set ("GreenfieldEnabled", BooleanValue (true));
189  nGFStaDevice = wifi.Install (phy, mac, wifiNGFStaNodes);
190 
191  // AP
192  NetDeviceContainer apDevice;
193  wifi.SetStandard (params.apType);
194  mac.SetType ("ns3::ApWifiMac",
195  "Ssid", SsidValue (ssid),
196  "EnableBeaconJitter", BooleanValue (false),
197  "BE_MaxAmpduSize", UintegerValue (0),
198  "BE_BlockAckThreshold", UintegerValue (2),
199  "RifsSupported", BooleanValue (params.rifsSupported),
200  "RifsMode", BooleanValue (params.rifsMode),
201  "EnableNonErpProtection", BooleanValue (params.enableErpProtection),
202  "ShortSlotTimeSupported", BooleanValue (params.enableShortSlotTime));
203  phy.Set ("GreenfieldEnabled", BooleanValue (params.apSupportsGreenfield));
204  apDevice = wifi.Install (phy, mac, wifiApNode);
205 
206  // Set TXOP limit
208  {
209  Ptr<NetDevice> dev = wifiApNode.Get (0)->GetDevice (0);
210  Ptr<WifiNetDevice> wifi_dev = DynamicCast<WifiNetDevice> (dev);
211  Ptr<WifiMac> wifi_mac = wifi_dev->GetMac ();
212  PointerValue ptr;
213  wifi_mac->GetAttribute ("BE_EdcaTxopN", ptr);
214  Ptr<EdcaTxopN> edca = ptr.Get<EdcaTxopN> ();
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<WifiMac> wifi_mac = wifi_dev->GetMac ();
222  PointerValue ptr;
223  wifi_mac->GetAttribute ("BE_EdcaTxopN", ptr);
224  Ptr<EdcaTxopN> edca = ptr.Get<EdcaTxopN> ();
225  edca->SetTxopLimit (MicroSeconds (3008));
226  }
227  if (nWifiNGF > 0)
228  {
229  Ptr<NetDevice> dev = wifiNGFStaNodes.Get (0)->GetDevice (0);
230  Ptr<WifiNetDevice> wifi_dev = DynamicCast<WifiNetDevice> (dev);
231  Ptr<WifiMac> wifi_mac = wifi_dev->GetMac ();
232  PointerValue ptr;
233  wifi_mac->GetAttribute ("BE_EdcaTxopN", ptr);
234  Ptr<EdcaTxopN> edca = ptr.Get<EdcaTxopN> ();
235  edca->SetTxopLimit (MicroSeconds (3008));
236  }
237 
238  // Define mobility model
240  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
241 
242  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
243  for (uint32_t i = 0; i < nWifiB; i++)
244  {
245  positionAlloc->Add (Vector (5.0, 0.0, 0.0));
246  }
247  for (uint32_t i = 0; i < nWifiG; i++)
248  {
249  positionAlloc->Add (Vector (0.0, 5.0, 0.0));
250  }
251  for (uint32_t i = 0; i < nWifiNNGF; i++)
252  {
253  positionAlloc->Add (Vector (0.0, 0.0, 5.0));
254  }
255  for (uint32_t i = 0; i < nWifiNGF; i++)
256  {
257  positionAlloc->Add (Vector (0.0, 0.0, 5.0));
258  }
259 
260  mobility.SetPositionAllocator (positionAlloc);
261  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
262  mobility.Install (wifiApNode);
263  mobility.Install (wifiBStaNodes);
264  mobility.Install (wifiGStaNodes);
265  mobility.Install (wifiNNGFStaNodes);
266  mobility.Install (wifiNGFStaNodes);
267 
268  // Internet stack
270  stack.Install (wifiApNode);
271  stack.Install (wifiBStaNodes);
272  stack.Install (wifiGStaNodes);
273  stack.Install (wifiNNGFStaNodes);
274  stack.Install (wifiNGFStaNodes);
275 
277  address.SetBase ("192.168.1.0", "255.255.255.0");
278  Ipv4InterfaceContainer bStaInterface;
279  bStaInterface = address.Assign (bStaDevice);
280  Ipv4InterfaceContainer gStaInterface;
281  gStaInterface = address.Assign (gStaDevice);
282  Ipv4InterfaceContainer nNGFStaInterface;
283  nNGFStaInterface = address.Assign (nNGFStaDevice);
284  Ipv4InterfaceContainer nGFStaInterface;
285  nGFStaInterface = address.Assign (nGFStaDevice);
286  Ipv4InterfaceContainer ApInterface;
287  ApInterface = address.Assign (apDevice);
288 
289  // Setting applications
290  if (params.isUdp)
291  {
292  uint16_t port = 9;
293  UdpServerHelper server (port);
294  ApplicationContainer serverApp = server.Install (wifiApNode);
295  serverApp.Start (Seconds (0.0));
296  serverApp.Stop (Seconds (simulationTime + 1));
297 
298  UdpClientHelper client (ApInterface.GetAddress (0), port);
299  client.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
300  client.SetAttribute ("Interval", TimeValue (Time ("0.0002"))); //packets/s
301  client.SetAttribute ("PacketSize", UintegerValue (payloadSize));
302 
304  if (params.bHasTraffic)
305  {
306  clientApps.Add (client.Install (wifiBStaNodes));
307  }
308  if (params.gHasTraffic)
309  {
310  clientApps.Add (client.Install (wifiGStaNodes));
311  }
312  if (params.nNonGreenfieldHasTraffic)
313  {
314  clientApps.Add (client.Install (wifiNNGFStaNodes));
315  }
316  if (params.nGreenfieldHasTraffic)
317  {
318  clientApps.Add (client.Install (wifiNGFStaNodes));
319  }
320  clientApps.Start (Seconds (1.0));
321  clientApps.Stop (Seconds (simulationTime + 1));
322 
323  Simulator::Stop (Seconds (simulationTime + 1));
324  Simulator::Run ();
326 
327  uint64_t totalPacketsThrough = DynamicCast<UdpServer> (serverApp.Get (0))->GetReceived ();
328  throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0);
329  }
330  else
331  {
332  uint16_t port = 50000;
333  Address localAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
334  PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", localAddress);
335 
336  ApplicationContainer serverApp = packetSinkHelper.Install (wifiApNode.Get (0));
337  serverApp.Start (Seconds (0.0));
338  serverApp.Stop (Seconds (simulationTime + 1));
339 
340  OnOffHelper onoff ("ns3::TcpSocketFactory", Ipv4Address::GetAny ());
341  onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
342  onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
343  onoff.SetAttribute ("PacketSize", UintegerValue (payloadSize));
344  onoff.SetAttribute ("DataRate", DataRateValue (150000000)); //bit/s
345 
346  AddressValue remoteAddress (InetSocketAddress (ApInterface.GetAddress (0), port));
347  onoff.SetAttribute ("Remote", remoteAddress);
348 
350  if (params.bHasTraffic)
351  {
352  clientApps.Add (onoff.Install (wifiBStaNodes));
353  }
354  if (params.gHasTraffic)
355  {
356  clientApps.Add (onoff.Install (wifiGStaNodes));
357  }
358  if (params.nNonGreenfieldHasTraffic)
359  {
360  clientApps.Add (onoff.Install (wifiNNGFStaNodes));
361  }
362  if (params.nGreenfieldHasTraffic)
363  {
364  clientApps.Add (onoff.Install (wifiNGFStaNodes));
365  }
366  clientApps.Start (Seconds (1.0));
367  clientApps.Stop (Seconds (simulationTime + 1));
368 
369  Simulator::Stop (Seconds (simulationTime + 1));
370  Simulator::Run ();
372 
373  uint64_t totalPacketsThrough = DynamicCast<PacketSink> (serverApp.Get (0))->GetTotalRx ();
374  throughput += totalPacketsThrough * 8 / (simulationTime * 1000000.0);
375  }
376  return throughput;
377 }
378 
379 int main (int argc, char *argv[])
380 {
381  Parameters params;
382  params.testName = "";
383  params.enableErpProtection = false;
384  params.erpProtectionMode = "Cts-To-Self";
385  params.enableShortSlotTime = false;
386  params.enableShortPlcpPreamble = false;
388  params.apSupportsGreenfield = false;
389  params.rifsSupported = false;
390  params.rifsMode = false;
391  params.nWifiB = 0;
392  params.bHasTraffic = false;
393  params.nWifiG = 1;
394  params.gHasTraffic = true;
395  params.nWifiNNonGreenfield = 0;
396  params.nNonGreenfieldHasTraffic = false;
397  params.nWifiNGreenfield = 0;
398  params.nGreenfieldHasTraffic = false;
399  params.isUdp = true;
400  params.payloadSize = 1472; //bytes
401  params.simulationTime = 10; //seconds
402 
403  bool verifyResults = 0; //used for regression
404 
406  cmd.AddValue ("payloadSize", "Payload size in bytes", params.payloadSize);
407  cmd.AddValue ("simulationTime", "Simulation time in seconds", params.simulationTime);
408  cmd.AddValue ("isUdp", "UDP if set to 1, TCP otherwise", params.isUdp);
409  cmd.AddValue ("verifyResults", "Enable/disable results verification at the end of the simulation", verifyResults);
410  cmd.Parse (argc, argv);
411 
413  double throughput = 0;
414 
415  params.testName = "g only with all g features disabled";
416  throughput = experiment.Run (params);
417  if (verifyResults && (throughput < 22.5 || throughput > 23.5))
418  {
419  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
420  exit (1);
421  }
422  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
423 
424  params.testName = "g only with short slot time enabled";
425  params.enableErpProtection = false;
426  params.enableShortSlotTime = true;
427  params.enableShortPlcpPreamble = false;
428  params.nWifiB = 0;
429  throughput = experiment.Run (params);
430  if (verifyResults && (throughput < 29 || throughput > 30))
431  {
432  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
433  exit (1);
434  }
435  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
436 
437  params.testName = "Mixed b/g with all g features disabled";
438  params.enableErpProtection = false;
439  params.enableShortSlotTime = false;
440  params.enableShortPlcpPreamble = false;
441  params.nWifiB = 1;
442  throughput = experiment.Run (params);
443  if (verifyResults && (throughput < 22.5 || throughput > 23.5))
444  {
445  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
446  exit (1);
447  }
448  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
449 
450  params.testName = "Mixed b/g with short plcp preamble enabled";
451  params.enableErpProtection = false;
452  params.enableShortSlotTime = false;
453  params.enableShortPlcpPreamble = true;
454  params.nWifiB = 1;
455  throughput = experiment.Run (params);
456  if (verifyResults && (throughput < 22.5 || throughput > 23.5))
457  {
458  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
459  exit (1);
460  }
461  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
462 
463  params.testName = "Mixed b/g with short slot time enabled using RTS-CTS protection";
464  params.enableErpProtection = true;
465  params.erpProtectionMode = "Rts-Cts";
466  params.enableShortSlotTime = false;
467  params.enableShortPlcpPreamble = false;
468  params.nWifiB = 1;
469  throughput = experiment.Run (params);
470  if (verifyResults && (throughput < 19 || throughput > 20))
471  {
472  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
473  exit (1);
474  }
475  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
476 
477  params.testName = "Mixed b/g with short plcp preamble enabled using RTS-CTS protection";
478  params.enableErpProtection = true;
479  params.enableShortSlotTime = false;
480  params.enableShortPlcpPreamble = true;
481  params.nWifiB = 1;
482  throughput = experiment.Run (params);
483  if (verifyResults && (throughput < 19 || throughput > 20))
484  {
485  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
486  exit (1);
487  }
488  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
489 
490  params.testName = "Mixed b/g with short slot time enabled using CTS-TO-SELF protection";
491  params.enableErpProtection = true;
492  params.erpProtectionMode = "Cts-To-Self";
493  params.enableShortSlotTime = false;
494  params.enableShortPlcpPreamble = false;
495  params.nWifiB = 1;
496  throughput = experiment.Run (params);
497  if (verifyResults && (throughput < 20.5 || throughput > 21.5))
498  {
499  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
500  exit (1);
501  }
502  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
503 
504  params.testName = "Mixed b/g with short plcp preamble enabled using CTS-TO-SELF protection";
505  params.enableErpProtection = true;
506  params.enableShortSlotTime = false;
507  params.enableShortPlcpPreamble = true;
508  params.nWifiB = 1;
509  throughput = experiment.Run (params);
510  if (verifyResults && (throughput < 20.5 || throughput > 21.5))
511  {
512  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
513  exit (1);
514  }
515  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
516 
517  params.testName = "HT GF not supported";
518  params.enableErpProtection = false;
519  params.enableShortSlotTime = false;
520  params.enableShortPlcpPreamble = false;
522  params.apSupportsGreenfield = false;
523  params.nWifiB = 0;
524  params.bHasTraffic = false;
525  params.nWifiG = 0;
526  params.gHasTraffic = false;
527  params.nWifiNNonGreenfield = 1;
528  params.nNonGreenfieldHasTraffic = true;
529  params.nWifiNGreenfield = 0;
530  params.nGreenfieldHasTraffic = false;
531  throughput = experiment.Run (params);
532  if (verifyResults && (throughput < 43 || throughput > 44))
533  {
534  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
535  exit (1);
536  }
537  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
538 
539  params.testName = "HT only with GF used";
540  params.enableErpProtection = false;
541  params.enableShortSlotTime = false;
542  params.enableShortPlcpPreamble = false;
544  params.apSupportsGreenfield = true;
545  params.nWifiB = 0;
546  params.bHasTraffic = false;
547  params.nWifiG = 0;
548  params.gHasTraffic = false;
549  params.nWifiNNonGreenfield = 0;
550  params.nNonGreenfieldHasTraffic = false;
551  params.nWifiNGreenfield = 1;
552  params.nGreenfieldHasTraffic = true;
553  throughput = experiment.Run (params);
554  if (verifyResults && (throughput < 44 || throughput > 45))
555  {
556  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
557  exit (1);
558  }
559  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
560 
561  params.testName = "HT only with GF allowed but disabled by protection";
562  params.enableErpProtection = false;
563  params.enableShortSlotTime = false;
564  params.enableShortPlcpPreamble = false;
566  params.apSupportsGreenfield = true;
567  params.nWifiB = 0;
568  params.bHasTraffic = false;
569  params.nWifiG = 0;
570  params.gHasTraffic = false;
571  params.nWifiNNonGreenfield = 1;
572  params.nNonGreenfieldHasTraffic = false;
573  params.nWifiNGreenfield = 1;
574  params.nGreenfieldHasTraffic = true;
575  throughput = experiment.Run (params);
576  if (verifyResults && (throughput < 43 || throughput > 44))
577  {
578  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
579  exit (1);
580  }
581  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
582 
583  params.testName = "HT only with GF not supported by the receiver";
584  params.enableErpProtection = false;
585  params.enableShortSlotTime = false;
586  params.enableShortPlcpPreamble = false;
588  params.apSupportsGreenfield = false;
589  params.nWifiB = 0;
590  params.bHasTraffic = false;
591  params.nWifiG = 0;
592  params.gHasTraffic = false;
593  params.nWifiNNonGreenfield = 0;
594  params.nNonGreenfieldHasTraffic = false;
595  params.nWifiNGreenfield = 1;
596  params.nGreenfieldHasTraffic = true;
597  throughput = experiment.Run (params);
598  if (verifyResults && (throughput < 43 || throughput > 44))
599  {
600  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
601  exit (1);
602  }
603  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
604 
605  params.testName = "Mixed HT/non-HT with GF enabled";
606  params.enableErpProtection = false;
607  params.enableShortSlotTime = false;
608  params.enableShortPlcpPreamble = false;
610  params.apSupportsGreenfield = true;
611  params.nWifiB = 0;
612  params.bHasTraffic = false;
613  params.nWifiG = 1;
614  params.gHasTraffic = false;
615  params.nWifiNNonGreenfield = 0;
616  params.nNonGreenfieldHasTraffic = false;
617  params.nWifiNGreenfield = 1;
618  params.nGreenfieldHasTraffic = true;
619  throughput = experiment.Run (params);
620  if (verifyResults && (throughput < 44 || throughput > 45))
621  {
622  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
623  exit (1);
624  }
625  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
626 
627  params.testName = "HT only with RIFS enabled";
628  params.enableErpProtection = false;
629  params.enableShortSlotTime = false;
630  params.enableShortPlcpPreamble = false;
632  params.apSupportsGreenfield = false;
633  params.rifsSupported = true;
634  params.rifsMode = 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 with RIFS enabled but not forbidden";
652  params.enableErpProtection = false;
653  params.enableShortSlotTime = false;
654  params.enableShortPlcpPreamble = false;
656  params.apSupportsGreenfield = false;
657  params.rifsSupported = true;
658  params.rifsMode = false;
659  params.nWifiB = 0;
660  params.bHasTraffic = false;
661  params.nWifiG = 1;
662  params.gHasTraffic = false;
663  params.nWifiNNonGreenfield = 1;
664  params.nNonGreenfieldHasTraffic = true;
665  params.nWifiNGreenfield = 0;
666  params.nGreenfieldHasTraffic = false;
667  throughput = experiment.Run (params);
668  if (verifyResults && (throughput < 44 || throughput > 45))
669  {
670  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
671  exit (1);
672  }
673  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
674 
675  params.testName = "Mixed HT/non-HT with RIFS enabled but forbidden";
676  params.enableErpProtection = false;
677  params.enableShortSlotTime = false;
678  params.enableShortPlcpPreamble = false;
680  params.apSupportsGreenfield = false;
681  params.rifsSupported = true;
682  params.rifsMode = true;
683  params.nWifiB = 0;
684  params.bHasTraffic = false;
685  params.nWifiG = 1;
686  params.gHasTraffic = false;
687  params.nWifiNNonGreenfield = 1;
688  params.nNonGreenfieldHasTraffic = true;
689  params.nWifiNGreenfield = 0;
690  params.nGreenfieldHasTraffic = false;
691  throughput = experiment.Run (params);
692  if (verifyResults && (throughput < 43 || throughput > 44))
693  {
694  NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expected boundaries!");
695  exit (1);
696  }
697  std::cout << "Throughput: " << throughput << " Mbit/s \n" << std::endl;
698 
699  return 0;
700 }
ERP-OFDM PHY (Clause 19, Section 19.5)
void AddPropagationLoss(std::string name, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
Helper class for UAN CW MAC example.
tuple channel
Definition: third.py:85
void Set(std::string name, const AttributeValue &v)
Definition: wifi-helper.cc:132
holds a vector of ns3::Application pointers.
void experiment(bool enableCtsRts)
Run single 10 seconds experiment with enabled or disabled RTS/CTS mechanism.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Ptr< T > Get(void) const
Definition: pointer.h:194
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 and interface index.
Ptr< YansWifiChannel > Create(void) const
void SetRemoteStationManager(std::string type, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
Definition: wifi-helper.cc:719
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 Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container. ...
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:201
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...
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:213
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
Definition: on-off-helper.h:42
tuple cmd
Definition: second.py:35
void SetPcapDataLinkType(enum SupportedPcapDataLinkTypes dlt)
Set the data link type of PCAP traces to be used.
Definition: wifi-helper.cc:566
uint16_t port
Definition: dsdv-manet.cc:44
a polymophic address class
Definition: address.h:90
tuple clientApps
Definition: first.py:54
void SetChannel(Ptr< YansWifiChannel > channel)
uint32_t nWifiB
uint32_t simulationTime
WifiPhyStandard
Identifies the PHY specification that a Wifi device is configured to use.
This queue contains packets for a particular access class.
Definition: edca-txop-n.h:68
double Run(Parameters params)
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
tuple mobility
Definition: third.py:101
tuple phy
Definition: third.py:86
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:1055
Hold an unsigned integer type.
Definition: uinteger.h:44
holds a vector of ns3::NetDevice pointers
virtual void SetStandard(enum WifiPhyStandard standard)
Definition: wifi-helper.cc:742
Create a server application which waits for input UDP packets and uses the information carried into t...
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer::Iterator first, NodeContainer::Iterator last) const
Definition: wifi-helper.cc:748
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Definition: node.cc:142
uint32_t payloadSize
tuple mac
Definition: third.py:92
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:205
bool nGreenfieldHasTraffic
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:190
tuple wifiApNode
Definition: third.py:83
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.
Ptr< Application > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
Hold objects of type Ptr.
Definition: pointer.h:36
bool enableErpProtection
std::string erpProtectionMode
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18)
void SetMobilityModel(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
tuple ssid
Definition: third.py:93
manage and create wifi channel objects for the yans model.
create MAC layers for a ns3::WifiNetDevice.
uint32_t nWifiG
uint32_t nWifiNNonGreenfield
tuple stack
Definition: first.py:34
The IEEE 802.11 SSID Information Element.
Definition: ssid.h:35
virtual void SetType(std::string type, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue(), std::string n10="", const AttributeValue &v10=EmptyAttributeValue())
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...
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
ApplicationContainer Install(NodeContainer c)
Create one UDP server application on each of the Nodes in the NodeContainer.
bool rifsSupported
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
Definition: dca-txop.cc:188
AttributeValue implementation for DataRate.
Definition: data-rate.h:242
void AddValue(const std::string &name, const std::string &help, T &value)
Add a program argument, assigning to POD.
Definition: command-line.h:498
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:234
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
bool nNonGreenfieldHasTraffic
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:993
AttributeValue implementation for Ssid.
Definition: ssid.h:117
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:782
void Add(Vector v)
Add a position to the list of positions.
Ptr< WifiMac > GetMac(void) const
ApplicationContainer Install(NodeContainer c) const
Install an ns3::PacketSinkApplication on each node of the input container configured with all the att...
void Parse(int argc, char *argv[])
Parse the program arguments.
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:1009
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition: log.h:253
tuple wifi
Definition: third.py:89
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
tuple address
Definition: first.py:37
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
ApplicationContainer Install(NodeContainer c) const
Install an ns3::OnOffApplication on each node of the input container configured with all the attribut...
Include Radiotap link layer information.
Definition: wifi-helper.h:111
bool apSupportsGreenfield
bool gHasTraffic
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
bool enableShortPlcpPreamble
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const