A Discrete-Event Network Simulator
API
wifi-spectrum-per-interference.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 MIRKO BANCHI
4  * Copyright (c) 2015 University of Washington
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Authors: Mirko Banchi <mk.banchi@gmail.com>
20  * Sebastien Deronne <sebastien.deronne@gmail.com>
21  * Tom Henderson <tomhend@u.washington.edu>
22  *
23  * Adapted from wifi-ht-network.cc example
24  */
25 
26 #include <iomanip>
27 #include "ns3/command-line.h"
28 #include "ns3/config.h"
29 #include "ns3/string.h"
30 #include "ns3/yans-wifi-helper.h"
31 #include "ns3/spectrum-wifi-helper.h"
32 #include "ns3/ssid.h"
33 #include "ns3/mobility-helper.h"
34 #include "ns3/internet-stack-helper.h"
35 #include "ns3/ipv4-address-helper.h"
36 #include "ns3/udp-client-server-helper.h"
37 #include "ns3/packet-sink-helper.h"
38 #include "ns3/on-off-helper.h"
39 #include "ns3/packet-sink.h"
40 #include "ns3/yans-wifi-channel.h"
41 #include "ns3/multi-model-spectrum-channel.h"
42 #include "ns3/propagation-loss-model.h"
43 #include "ns3/waveform-generator.h"
44 #include "ns3/waveform-generator-helper.h"
45 #include "ns3/non-communicating-net-device.h"
46 #include "ns3/wifi-net-device.h"
47 
48 // This is a simple example of an IEEE 802.11n Wi-Fi network with a
49 // non-Wi-Fi interferer. It is an adaptation of the wifi-spectrum-per-example
50 //
51 // Unless the --waveformPower argument is passed, it will operate similarly to
52 // wifi-spectrum-per-example. Adding --waveformPower=value for values
53 // greater than 0.0001 will result in frame losses beyond those that
54 // result from the normal SNR based on distance path loss.
55 //
56 // If YansWifiPhy is selected as the wifiType, --waveformPower will have
57 // no effect.
58 //
59 // Network topology:
60 //
61 // Wi-Fi 192.168.1.0
62 //
63 // STA AP
64 // * <-- distance --> *
65 // | |
66 // n1 n2
67 //
68 // Users may vary the following command-line arguments in addition to the
69 // attributes, global values, and default values typically available:
70 //
71 // --simulationTime: Simulation time in seconds [10]
72 // --udp: UDP if set to 1, TCP otherwise [true]
73 // --distance: meters separation between nodes [50]
74 // --index: restrict index to single value between 0 and 31 [256]
75 // --wifiType: select ns3::SpectrumWifiPhy or ns3::YansWifiPhy [ns3::SpectrumWifiPhy]
76 // --errorModelType: select ns3::NistErrorRateModel or ns3::YansErrorRateModel [ns3::NistErrorRateModel]
77 // --enablePcap: enable pcap output [false]
78 // --waveformPower: Waveform power (linear W) [0]
79 //
80 // By default, the program will step through 32 index values, corresponding
81 // to the following MCS, channel width, and guard interval combinations:
82 // index 0-7: MCS 0-7, long guard interval, 20 MHz channel
83 // index 8-15: MCS 0-7, short guard interval, 20 MHz channel
84 // index 16-23: MCS 0-7, long guard interval, 40 MHz channel
85 // index 24-31: MCS 0-7, short guard interval, 40 MHz channel
86 // and send UDP for 10 seconds using each MCS, using the SpectrumWifiPhy and the
87 // NistErrorRateModel, at a distance of 50 meters. The program outputs
88 // results such as:
89 //
90 // wifiType: ns3::SpectrumWifiPhy distance: 50m; time: 10; TxPower: 16 dBm (40 mW)
91 // index MCS Rate (Mb/s) Tput (Mb/s) Received Signal (dBm)Noi+Inf(dBm) SNR (dB)
92 // 0 0 6.50 5.77 7414 -64.69 -93.97 29.27
93 // 1 1 13.00 11.58 14892 -64.69 -93.97 29.27
94 // 2 2 19.50 17.39 22358 -64.69 -93.97 29.27
95 // 3 3 26.00 23.23 29875 -64.69 -93.97 29.27
96 // ...
97 //
98 
99 using namespace ns3;
100 
101 // Global variables for use in callbacks.
104 uint32_t g_samples;
105 
107  uint16_t channelFreqMhz,
108  WifiTxVector txVector,
109  MpduInfo aMpdu,
110  SignalNoiseDbm signalNoise,
111  uint16_t staId)
112 
113 {
114  g_samples++;
115  g_signalDbmAvg += ((signalNoise.signal - g_signalDbmAvg) / g_samples);
116  g_noiseDbmAvg += ((signalNoise.noise - g_noiseDbmAvg) / g_samples);
117 }
118 
119 NS_LOG_COMPONENT_DEFINE ("WifiSpectrumPerInterference");
120 
122 
124 {
125 public:
127  {
128  BandInfo bandInfo;
129  bandInfo.fc = 5180e6;
130  bandInfo.fl = 5180e6 - 10e6;
131  bandInfo.fh = 5180e6 + 10e6;
132 
133  Bands bands;
134  bands.push_back (bandInfo);
135 
136  SpectrumModelWifi5180MHz = Create<SpectrumModel> (bands);
137  }
138 
140 
141 int main (int argc, char *argv[])
142 {
143  bool udp = true;
144  double distance = 50;
145  double simulationTime = 10; //seconds
146  uint16_t index = 256;
147  std::string wifiType = "ns3::SpectrumWifiPhy";
148  std::string errorModelType = "ns3::NistErrorRateModel";
149  bool enablePcap = false;
150  const uint32_t tcpPacketSize = 1448;
151  double waveformPower = 0;
152 
153  CommandLine cmd (__FILE__);
154  cmd.AddValue ("simulationTime", "Simulation time in seconds", simulationTime);
155  cmd.AddValue ("udp", "UDP if set to 1, TCP otherwise", udp);
156  cmd.AddValue ("distance", "meters separation between nodes", distance);
157  cmd.AddValue ("index", "restrict index to single value between 0 and 31", index);
158  cmd.AddValue ("wifiType", "select ns3::SpectrumWifiPhy or ns3::YansWifiPhy", wifiType);
159  cmd.AddValue ("errorModelType", "select ns3::NistErrorRateModel or ns3::YansErrorRateModel", errorModelType);
160  cmd.AddValue ("enablePcap", "enable pcap output", enablePcap);
161  cmd.AddValue ("waveformPower", "Waveform power (linear W)", waveformPower);
162  cmd.Parse (argc,argv);
163 
164  uint16_t startIndex = 0;
165  uint16_t stopIndex = 31;
166  if (index < 32)
167  {
168  startIndex = index;
169  stopIndex = index;
170  }
171 
172  std::cout << "wifiType: " << wifiType << " distance: " << distance << "m; time: " << simulationTime << "; TxPower: 16 dBm (40 mW)" << std::endl;
173  std::cout << std::setw (5) << "index" <<
174  std::setw (6) << "MCS" <<
175  std::setw (13) << "Rate (Mb/s)" <<
176  std::setw (12) << "Tput (Mb/s)" <<
177  std::setw (10) << "Received " <<
178  std::setw (12) << "Signal (dBm)" <<
179  std::setw (12) << "Noi+Inf(dBm)" <<
180  std::setw (9) << "SNR (dB)" <<
181  std::endl;
182  for (uint16_t i = startIndex; i <= stopIndex; i++)
183  {
184  uint32_t payloadSize;
185  if (udp)
186  {
187  payloadSize = 972; // 1000 bytes IPv4
188  }
189  else
190  {
191  payloadSize = 1448; // 1500 bytes IPv6
192  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (payloadSize));
193  }
194 
195  NodeContainer wifiStaNode;
196  wifiStaNode.Create (1);
198  wifiApNode.Create (1);
199  NodeContainer interferingNode;
200  interferingNode.Create (1);
201 
203  SpectrumWifiPhyHelper spectrumPhy;
204  Ptr<MultiModelSpectrumChannel> spectrumChannel;
205  if (wifiType == "ns3::YansWifiPhy")
206  {
208  channel.AddPropagationLoss ("ns3::FriisPropagationLossModel",
209  "Frequency", DoubleValue (5.180e9));
210  channel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
211  phy.SetChannel (channel.Create ());
212  phy.Set ("Frequency", UintegerValue (5180));
213  }
214  else if (wifiType == "ns3::SpectrumWifiPhy")
215  {
216  spectrumChannel
217  = CreateObject<MultiModelSpectrumChannel> ();
219  = CreateObject<FriisPropagationLossModel> ();
220  lossModel->SetFrequency (5.180e9);
221  spectrumChannel->AddPropagationLossModel (lossModel);
222 
224  = CreateObject<ConstantSpeedPropagationDelayModel> ();
225  spectrumChannel->SetPropagationDelayModel (delayModel);
226 
227  spectrumPhy.SetChannel (spectrumChannel);
228  spectrumPhy.SetErrorRateModel (errorModelType);
229  spectrumPhy.Set ("Frequency", UintegerValue (5180)); // channel 36 at 20 MHz
230  }
231  else
232  {
233  NS_FATAL_ERROR ("Unsupported WiFi type " << wifiType);
234  }
235 
237  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
239 
240  Ssid ssid = Ssid ("ns380211n");
241 
242  double datarate = 0;
244  if (i == 0)
245  {
246  DataRate = StringValue ("HtMcs0");
247  datarate = 6.5;
248  }
249  else if (i == 1)
250  {
251  DataRate = StringValue ("HtMcs1");
252  datarate = 13;
253  }
254  else if (i == 2)
255  {
256  DataRate = StringValue ("HtMcs2");
257  datarate = 19.5;
258  }
259  else if (i == 3)
260  {
261  DataRate = StringValue ("HtMcs3");
262  datarate = 26;
263  }
264  else if (i == 4)
265  {
266  DataRate = StringValue ("HtMcs4");
267  datarate = 39;
268  }
269  else if (i == 5)
270  {
271  DataRate = StringValue ("HtMcs5");
272  datarate = 52;
273  }
274  else if (i == 6)
275  {
276  DataRate = StringValue ("HtMcs6");
277  datarate = 58.5;
278  }
279  else if (i == 7)
280  {
281  DataRate = StringValue ("HtMcs7");
282  datarate = 65;
283  }
284  else if (i == 8)
285  {
286  DataRate = StringValue ("HtMcs0");
287  datarate = 7.2;
288  }
289  else if (i == 9)
290  {
291  DataRate = StringValue ("HtMcs1");
292  datarate = 14.4;
293  }
294  else if (i == 10)
295  {
296  DataRate = StringValue ("HtMcs2");
297  datarate = 21.7;
298  }
299  else if (i == 11)
300  {
301  DataRate = StringValue ("HtMcs3");
302  datarate = 28.9;
303  }
304  else if (i == 12)
305  {
306  DataRate = StringValue ("HtMcs4");
307  datarate = 43.3;
308  }
309  else if (i == 13)
310  {
311  DataRate = StringValue ("HtMcs5");
312  datarate = 57.8;
313  }
314  else if (i == 14)
315  {
316  DataRate = StringValue ("HtMcs6");
317  datarate = 65;
318  }
319  else if (i == 15)
320  {
321  DataRate = StringValue ("HtMcs7");
322  datarate = 72.2;
323  }
324  else if (i == 16)
325  {
326  DataRate = StringValue ("HtMcs0");
327  datarate = 13.5;
328  }
329  else if (i == 17)
330  {
331  DataRate = StringValue ("HtMcs1");
332  datarate = 27;
333  }
334  else if (i == 18)
335  {
336  DataRate = StringValue ("HtMcs2");
337  datarate = 40.5;
338  }
339  else if (i == 19)
340  {
341  DataRate = StringValue ("HtMcs3");
342  datarate = 54;
343  }
344  else if (i == 20)
345  {
346  DataRate = StringValue ("HtMcs4");
347  datarate = 81;
348  }
349  else if (i == 21)
350  {
351  DataRate = StringValue ("HtMcs5");
352  datarate = 108;
353  }
354  else if (i == 22)
355  {
356  DataRate = StringValue ("HtMcs6");
357  datarate = 121.5;
358  }
359  else if (i == 23)
360  {
361  DataRate = StringValue ("HtMcs7");
362  datarate = 135;
363  }
364  else if (i == 24)
365  {
366  DataRate = StringValue ("HtMcs0");
367  datarate = 15;
368  }
369  else if (i == 25)
370  {
371  DataRate = StringValue ("HtMcs1");
372  datarate = 30;
373  }
374  else if (i == 26)
375  {
376  DataRate = StringValue ("HtMcs2");
377  datarate = 45;
378  }
379  else if (i == 27)
380  {
381  DataRate = StringValue ("HtMcs3");
382  datarate = 60;
383  }
384  else if (i == 28)
385  {
386  DataRate = StringValue ("HtMcs4");
387  datarate = 90;
388  }
389  else if (i == 29)
390  {
391  DataRate = StringValue ("HtMcs5");
392  datarate = 120;
393  }
394  else if (i == 30)
395  {
396  DataRate = StringValue ("HtMcs6");
397  datarate = 135;
398  }
399  else
400  {
401  DataRate = StringValue ("HtMcs7");
402  datarate = 150;
403  }
404 
405  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager","DataMode", DataRate,
406  "ControlMode", DataRate);
407 
408  NetDeviceContainer staDevice;
409  NetDeviceContainer apDevice;
410 
411  if (wifiType == "ns3::YansWifiPhy")
412  {
413  mac.SetType ("ns3::StaWifiMac",
414  "Ssid", SsidValue (ssid));
415  staDevice = wifi.Install (phy, mac, wifiStaNode);
416  mac.SetType ("ns3::ApWifiMac",
417  "Ssid", SsidValue (ssid));
418  apDevice = wifi.Install (phy, mac, wifiApNode);
419 
420  }
421  else if (wifiType == "ns3::SpectrumWifiPhy")
422  {
423  mac.SetType ("ns3::StaWifiMac",
424  "Ssid", SsidValue (ssid));
425  staDevice = wifi.Install (spectrumPhy, mac, wifiStaNode);
426  mac.SetType ("ns3::ApWifiMac",
427  "Ssid", SsidValue (ssid));
428  apDevice = wifi.Install (spectrumPhy, mac, wifiApNode);
429  }
430 
431  if (i <= 7)
432  {
433  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/ChannelWidth", UintegerValue (20));
434  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HtConfiguration/ShortGuardIntervalSupported", BooleanValue (false));
435  }
436  else if (i > 7 && i <= 15)
437  {
438  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/ChannelWidth", UintegerValue (20));
439  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HtConfiguration/ShortGuardIntervalSupported", BooleanValue (true));
440  }
441  else if (i > 15 && i <= 23)
442  {
443  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/ChannelWidth", UintegerValue (40));
444  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HtConfiguration/ShortGuardIntervalSupported", BooleanValue (false));
445  }
446  else
447  {
448  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/ChannelWidth", UintegerValue (40));
449  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HtConfiguration/ShortGuardIntervalSupported", BooleanValue (true));
450  }
451 
452  // mobility.
454  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
455 
456  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
457  positionAlloc->Add (Vector (distance, 0.0, 0.0));
458  positionAlloc->Add (Vector (distance, distance, 0.0));
459  mobility.SetPositionAllocator (positionAlloc);
460 
461  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
462 
463  mobility.Install (wifiApNode);
464  mobility.Install (wifiStaNode);
465  mobility.Install (interferingNode);
466 
467  /* Internet stack*/
469  stack.Install (wifiApNode);
470  stack.Install (wifiStaNode);
471 
473  address.SetBase ("192.168.1.0", "255.255.255.0");
474  Ipv4InterfaceContainer staNodeInterface;
475  Ipv4InterfaceContainer apNodeInterface;
476 
477  staNodeInterface = address.Assign (staDevice);
478  apNodeInterface = address.Assign (apDevice);
479 
480  /* Setting applications */
481  ApplicationContainer serverApp;
482  if (udp)
483  {
484  //UDP flow
485  uint16_t port = 9;
486  UdpServerHelper server (port);
487  serverApp = server.Install (wifiStaNode.Get (0));
488  serverApp.Start (Seconds (0.0));
489  serverApp.Stop (Seconds (simulationTime + 1));
490 
491  UdpClientHelper client (staNodeInterface.GetAddress (0), port);
492  client.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
493  client.SetAttribute ("Interval", TimeValue (Time ("0.0001"))); //packets/s
494  client.SetAttribute ("PacketSize", UintegerValue (payloadSize));
495  ApplicationContainer clientApp = client.Install (wifiApNode.Get (0));
496  clientApp.Start (Seconds (1.0));
497  clientApp.Stop (Seconds (simulationTime + 1));
498  }
499  else
500  {
501  //TCP flow
502  uint16_t port = 50000;
503  Address localAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
504  PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", localAddress);
505  serverApp = packetSinkHelper.Install (wifiStaNode.Get (0));
506  serverApp.Start (Seconds (0.0));
507  serverApp.Stop (Seconds (simulationTime + 1));
508 
509  OnOffHelper onoff ("ns3::TcpSocketFactory", Ipv4Address::GetAny ());
510  onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
511  onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
512  onoff.SetAttribute ("PacketSize", UintegerValue (payloadSize));
513  onoff.SetAttribute ("DataRate", DataRateValue (1000000000)); //bit/s
514  AddressValue remoteAddress (InetSocketAddress (staNodeInterface.GetAddress (0), port));
515  onoff.SetAttribute ("Remote", remoteAddress);
516  ApplicationContainer clientApp = onoff.Install (wifiApNode.Get (0));
517  clientApp.Start (Seconds (1.0));
518  clientApp.Stop (Seconds (simulationTime + 1));
519  }
520 
521  // Configure waveform generator
522  Ptr<SpectrumValue> wgPsd = Create<SpectrumValue> (SpectrumModelWifi5180MHz);
523  *wgPsd = waveformPower / 20e6; // PSD spread across 20 MHz
524  NS_LOG_INFO ("wgPsd : " << *wgPsd << " integrated power: " << Integral (*(GetPointer (wgPsd))));
525 
526  if (wifiType == "ns3::SpectrumWifiPhy")
527  {
528  WaveformGeneratorHelper waveformGeneratorHelper;
529  waveformGeneratorHelper.SetChannel (spectrumChannel);
530  waveformGeneratorHelper.SetTxPowerSpectralDensity (wgPsd);
531 
532  waveformGeneratorHelper.SetPhyAttribute ("Period", TimeValue (Seconds (0.0007)));
533  waveformGeneratorHelper.SetPhyAttribute ("DutyCycle", DoubleValue (1));
534  NetDeviceContainer waveformGeneratorDevices = waveformGeneratorHelper.Install (interferingNode);
535 
537  waveformGeneratorDevices.Get (0)->GetObject<NonCommunicatingNetDevice> ()->GetPhy ()->GetObject<WaveformGenerator> ());
538  }
539 
540  Config::ConnectWithoutContext ("/NodeList/0/DeviceList/*/Phy/MonitorSnifferRx", MakeCallback (&MonitorSniffRx));
541 
542  if (enablePcap)
543  {
544  std::stringstream ss;
545  ss << "wifi-spectrum-per-example-" << i;
546  phy.EnablePcap (ss.str (), apDevice);
547  }
548  g_signalDbmAvg = 0;
549  g_noiseDbmAvg = 0;
550  g_samples = 0;
551 
552  // Make sure we are tuned to 5180 MHz; if not, the example will
553  // not work properly
554  Ptr<NetDevice> staDevicePtr = staDevice.Get (0);
555  Ptr<WifiNetDevice> wifiStaDevicePtr = staDevicePtr->GetObject <WifiNetDevice> ();
556  UintegerValue val;
557  wifiStaDevicePtr->GetPhy ()->GetAttribute ("Frequency", val);
558  if (val.Get () != 5180)
559  {
560  NS_FATAL_ERROR ("Error: Wi-Fi nodes must be tuned to 5180 MHz to match the waveform generator");
561  }
562 
563  Simulator::Stop (Seconds (simulationTime + 1));
564  Simulator::Run ();
565 
566  double throughput = 0;
567  uint64_t totalPacketsThrough = 0;
568  if (udp)
569  {
570  //UDP
571  totalPacketsThrough = DynamicCast<UdpServer> (serverApp.Get (0))->GetReceived ();
572  throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0); //Mbit/s
573  }
574  else
575  {
576  //TCP
577  uint64_t totalBytesRx = DynamicCast<PacketSink> (serverApp.Get (0))->GetTotalRx ();
578  totalPacketsThrough = totalBytesRx / tcpPacketSize;
579  throughput = totalBytesRx * 8 / (simulationTime * 1000000.0); //Mbit/s
580  }
581  std::cout << std::setw (5) << i <<
582  std::setw (6) << (i % 8) <<
583  std::setprecision (2) << std::fixed <<
584  std::setw (10) << datarate <<
585  std::setw (12) << throughput <<
586  std::setw (8) << totalPacketsThrough;
587  if (totalPacketsThrough > 0)
588  {
589  std::cout << std::setw (12) << g_signalDbmAvg <<
590  std::setw (12) << g_noiseDbmAvg <<
591  std::setw (12) << (g_signalDbmAvg - g_noiseDbmAvg) <<
592  std::endl;
593  }
594  else
595  {
596  std::cout << std::setw (12) << "N/A" <<
597  std::setw (12) << "N/A" <<
598  std::setw (12) << "N/A" <<
599  std::endl;
600  }
602  }
603  return 0;
604 }
a polymophic address class
Definition: address.h:91
AttributeValue implementation for Address.
Definition: address.h:278
holds a vector of ns3::Application pointers.
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
AttributeValue implementation for Boolean.
Definition: boolean.h:37
Parse command-line arguments.
Definition: command-line.h:229
Class for representing data rates.
Definition: data-rate.h:89
AttributeValue implementation for DataRate.
Definition: data-rate.h:298
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:41
an Inet address class
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
static Ipv4Address GetAny(void)
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
This class implements a device which does not communicate, in the sense that it does not interact wit...
void GetAttribute(std::string name, AttributeValue &value) const
Get the value of an attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:294
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
Definition: on-off-helper.h:43
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:180
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:136
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:556
static void Run(void)
Run the simulation.
Definition: simulator.cc:172
Make it easy to create and manage PHY objects for the spectrum model.
void SetChannel(Ptr< SpectrumChannel > channel)
The IEEE 802.11 SSID Information Element.
Definition: ssid.h:36
AttributeValue implementation for Ssid.
Definition: ssid.h:105
Hold variables of type string.
Definition: string.h:41
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
AttributeValue implementation for Time.
Definition: nstime.h:1308
Create a client application which sends UDP packets carrying a 32bit sequence number and a 64 bit tim...
Create a server application which waits for input UDP packets and uses the information carried into t...
Hold an unsigned integer type.
Definition: uinteger.h:44
Create a Waveform generator, which can be used to inject specific noise in the channel.
void SetTxPowerSpectralDensity(Ptr< SpectrumValue > txPsd)
void SetChannel(Ptr< SpectrumChannel > channel)
set the SpectrumChannel that will be used by SpectrumPhy instances created by this helper
NetDeviceContainer Install(NodeContainer c) const
void SetPhyAttribute(std::string name, const AttributeValue &v)
Simple SpectrumPhy implementation that sends customizable waveform.
virtual void Start()
Start the waveform generator.
helps to create WifiNetDevice objects
Definition: wifi-helper.h:274
create MAC layers for a ns3::WifiNetDevice.
Hold together all Wifi-related objects.
Ptr< WifiPhy > GetPhy(void) const
void Set(std::string name, const AttributeValue &v)
Definition: wifi-helper.cc:154
void SetErrorRateModel(std::string type, Args &&... args)
Helper function used to set the error rate model.
Definition: wifi-helper.h:440
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
manage and create wifi channel objects for the YANS model.
Make it easy to create and manage PHY objects for the YANS model.
uint16_t port
Definition: dsdv-manet.cc:45
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:849
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
Definition: config.cc:901
void Set(std::string path, const AttributeValue &value)
Definition: config.cc:839
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
Definition: data-rate.h:329
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1244
address
Definition: first.py:44
stack
Definition: first.py:41
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double Integral(const SpectrumValue &arg)
std::vector< BandInfo > Bands
Container of BandInfo.
U * GetPointer(const Ptr< U > &p)
Definition: ptr.h:421
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:1648
cmd
Definition: second.py:35
ssid
Definition: third.py:100
channel
Definition: third.py:92
mac
Definition: third.py:99
wifi
Definition: third.py:96
wifiApNode
Definition: third.py:90
mobility
Definition: third.py:108
phy
Definition: third.py:93
The building block of a SpectrumModel.
double fc
center frequency
double fl
lower limit of subband
double fh
upper limit of subband
MpduInfo structure.
Definition: phy-entity.h:60
SignalNoiseDbm structure.
Definition: phy-entity.h:53
double noise
noise power in dBm
Definition: phy-entity.h:55
double signal
signal strength in dBm
Definition: phy-entity.h:54
bool enablePcap
class static_SpectrumModelWifi5180MHz_initializer static_SpectrumModelWifi5180MHz_initializer_instance
void MonitorSniffRx(Ptr< const Packet > packet, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise, uint16_t staId)
Ptr< SpectrumModel > SpectrumModelWifi5180MHz