A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-spectrum-per-interference.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 MIRKO BANCHI
3 * Copyright (c) 2015 University of Washington
4 *
5 * SPDX-License-Identifier: GPL-2.0-only
6 *
7 * Authors: Mirko Banchi <mk.banchi@gmail.com>
8 * Sebastien Deronne <sebastien.deronne@gmail.com>
9 * Tom Henderson <tomhend@u.washington.edu>
10 *
11 * Adapted from wifi-ht-network.cc example
12 */
13
14#include "ns3/command-line.h"
15#include "ns3/config.h"
16#include "ns3/internet-stack-helper.h"
17#include "ns3/ipv4-address-helper.h"
18#include "ns3/mobility-helper.h"
19#include "ns3/multi-model-spectrum-channel.h"
20#include "ns3/non-communicating-net-device.h"
21#include "ns3/on-off-helper.h"
22#include "ns3/packet-sink-helper.h"
23#include "ns3/packet-sink.h"
24#include "ns3/propagation-loss-model.h"
25#include "ns3/spectrum-wifi-helper.h"
26#include "ns3/ssid.h"
27#include "ns3/string.h"
28#include "ns3/udp-client-server-helper.h"
29#include "ns3/udp-server.h"
30#include "ns3/waveform-generator-helper.h"
31#include "ns3/waveform-generator.h"
32#include "ns3/wifi-net-device.h"
33#include "ns3/yans-wifi-channel.h"
34#include "ns3/yans-wifi-helper.h"
35
36#include <iomanip>
37
38// This is a simple example of an IEEE 802.11n Wi-Fi network with a
39// non-Wi-Fi interferer. It is an adaptation of the wifi-spectrum-per-example
40//
41// Unless the --waveformPower argument is passed, it will operate similarly to
42// wifi-spectrum-per-example. Adding --waveformPower=value for values
43// greater than 0.0001 will result in frame losses beyond those that
44// result from the normal SNR based on distance path loss.
45//
46// If YansWifiPhy is selected as the wifiType, --waveformPower will have
47// no effect.
48//
49// Network topology:
50//
51// Wi-Fi 192.168.1.0
52//
53// STA AP
54// * <-- distance --> *
55// | |
56// n1 n2
57//
58// Users may vary the following command-line arguments in addition to the
59// attributes, global values, and default values typically available:
60//
61// --simulationTime: Simulation time [10s]
62// --udp: UDP if set to 1, TCP otherwise [true]
63// --distance: meters separation between nodes [50]
64// --index: restrict index to single value between 0 and 31 [256]
65// --wifiType: select ns3::SpectrumWifiPhy or ns3::YansWifiPhy [ns3::SpectrumWifiPhy]
66// --errorModelType: select ns3::NistErrorRateModel or ns3::YansErrorRateModel
67// [ns3::NistErrorRateModel]
68// --enablePcap: enable pcap output [false]
69// --waveformPower: Waveform power (linear W) [0]
70//
71// By default, the program will step through 32 index values, corresponding
72// to the following MCS, channel width, and guard interval combinations:
73// index 0-7: MCS 0-7, long guard interval, 20 MHz channel
74// index 8-15: MCS 0-7, short guard interval, 20 MHz channel
75// index 16-23: MCS 0-7, long guard interval, 40 MHz channel
76// index 24-31: MCS 0-7, short guard interval, 40 MHz channel
77// and send UDP for 10 seconds using each MCS, using the SpectrumWifiPhy and the
78// NistErrorRateModel, at a distance of 50 meters. The program outputs
79// results such as:
80//
81// wifiType: ns3::SpectrumWifiPhy distance: 50m; time: 10; TxPower: 16 dBm (40 mW)
82// index MCS Rate (Mb/s) Tput (Mb/s) Received Signal (dBm)Noi+Inf(dBm) SNR (dB)
83// 0 0 6.50 5.77 7414 -64.69 -93.97 29.27
84// 1 1 13.00 11.58 14892 -64.69 -93.97 29.27
85// 2 2 19.50 17.39 22358 -64.69 -93.97 29.27
86// 3 3 26.00 23.23 29875 -64.69 -93.97 29.27
87// ...
88//
89
90using namespace ns3;
91
92// Global variables for use in callbacks.
93double g_signalDbmAvg; //!< Average signal power [dBm]
94double g_noiseDbmAvg; //!< Average noise power [dBm]
95uint32_t g_samples; //!< Number of samples
96
97/**
98 * Monitor sniffer Rx trace
99 *
100 * \param packet The sensed packet.
101 * \param channelFreqMhz The channel frequency [MHz].
102 * \param txVector The Tx vector.
103 * \param aMpdu The aMPDU.
104 * \param signalNoise The signal and noise dBm.
105 * \param staId The STA ID.
106 */
107void
109 uint16_t channelFreqMhz,
110 WifiTxVector txVector,
111 MpduInfo aMpdu,
112 SignalNoiseDbm signalNoise,
113 uint16_t staId)
114
115{
116 g_samples++;
117 g_signalDbmAvg += ((signalNoise.signal - g_signalDbmAvg) / g_samples);
118 g_noiseDbmAvg += ((signalNoise.noise - g_noiseDbmAvg) / g_samples);
119}
120
121NS_LOG_COMPONENT_DEFINE("WifiSpectrumPerInterference");
122
123Ptr<SpectrumModel> SpectrumModelWifi5180MHz; //!< Spectrum model at 5180 MHz.
124Ptr<SpectrumModel> SpectrumModelWifi5190MHz; //!< Spectrum model at 5190 MHz.
125
126/** Initializer for a static spectrum model centered around 5180 MHz */
128{
129 public:
131 {
132 BandInfo bandInfo;
133 bandInfo.fc = 5180e6;
134 bandInfo.fl = 5180e6 - 10e6;
135 bandInfo.fh = 5180e6 + 10e6;
136
137 Bands bands;
138 bands.push_back(bandInfo);
139
141 }
142};
143
144/// Static instance to initizlize the spectrum model around 5180 MHz.
146
147/** Initializer for a static spectrum model centered around 5190 MHz */
149{
150 public:
152 {
153 BandInfo bandInfo;
154 bandInfo.fc = 5190e6;
155 bandInfo.fl = 5190e6 - 10e6;
156 bandInfo.fh = 5190e6 + 10e6;
157
158 Bands bands;
159 bands.push_back(bandInfo);
160
162 }
163};
164
165/// Static instance to initizlize the spectrum model around 5190 MHz.
167
168int
169main(int argc, char* argv[])
170{
171 bool udp{true};
172 meter_u distance{50};
173 Time simulationTime{"10s"};
174 uint16_t index{256};
175 std::string wifiType{"ns3::SpectrumWifiPhy"};
176 std::string errorModelType{"ns3::NistErrorRateModel"};
177 bool enablePcap{false};
178 const uint32_t tcpPacketSize{1448};
179 Watt_u waveformPower{0};
180
181 CommandLine cmd(__FILE__);
182 cmd.AddValue("simulationTime", "Simulation time", simulationTime);
183 cmd.AddValue("udp", "UDP if set to 1, TCP otherwise", udp);
184 cmd.AddValue("distance", "meters separation between nodes", distance);
185 cmd.AddValue("index", "restrict index to single value between 0 and 31", index);
186 cmd.AddValue("wifiType", "select ns3::SpectrumWifiPhy or ns3::YansWifiPhy", wifiType);
187 cmd.AddValue("errorModelType",
188 "select ns3::NistErrorRateModel or ns3::YansErrorRateModel",
189 errorModelType);
190 cmd.AddValue("enablePcap", "enable pcap output", enablePcap);
191 cmd.AddValue("waveformPower", "Waveform power (linear W)", waveformPower);
192 cmd.Parse(argc, argv);
193
194 uint16_t startIndex = 0;
195 uint16_t stopIndex = 31;
196 if (index < 32)
197 {
198 startIndex = index;
199 stopIndex = index;
200 }
201
202 std::cout << "wifiType: " << wifiType << " distance: " << distance
203 << "m; time: " << simulationTime << "; TxPower: 16 dBm (40 mW)" << std::endl;
204 std::cout << std::setw(5) << "index" << std::setw(6) << "MCS" << std::setw(13) << "Rate (Mb/s)"
205 << std::setw(12) << "Tput (Mb/s)" << std::setw(10) << "Received " << std::setw(12)
206 << "Signal (dBm)" << std::setw(12) << "Noi+Inf(dBm)" << std::setw(9) << "SNR (dB)"
207 << std::endl;
208 for (uint16_t i = startIndex; i <= stopIndex; i++)
209 {
210 uint32_t payloadSize;
211 if (udp)
212 {
213 payloadSize = 972; // 1000 bytes IPv4
214 }
215 else
216 {
217 payloadSize = 1448; // 1500 bytes IPv6
218 Config::SetDefault("ns3::TcpSocket::SegmentSize", UintegerValue(payloadSize));
219 }
220
221 NodeContainer wifiStaNode;
222 wifiStaNode.Create(1);
223 NodeContainer wifiApNode;
224 wifiApNode.Create(1);
225 NodeContainer interferingNode;
226 interferingNode.Create(1);
227
229 SpectrumWifiPhyHelper spectrumPhy;
230 Ptr<MultiModelSpectrumChannel> spectrumChannel;
231 uint16_t frequency = (i <= 15 ? 5180 : 5190);
232 if (wifiType == "ns3::YansWifiPhy")
233 {
234 YansWifiChannelHelper channel;
235 channel.AddPropagationLoss("ns3::FriisPropagationLossModel",
236 "Frequency",
237 DoubleValue(frequency * 1e6));
238 channel.SetPropagationDelay("ns3::ConstantSpeedPropagationDelayModel");
239 phy.SetChannel(channel.Create());
240 phy.Set("ChannelSettings",
241 StringValue(std::string("{") + (frequency == 5180 ? "36" : "38") +
242 ", 0, BAND_5GHZ, 0}"));
243 }
244 else if (wifiType == "ns3::SpectrumWifiPhy")
245 {
246 spectrumChannel = CreateObject<MultiModelSpectrumChannel>();
248 lossModel->SetFrequency(frequency * 1e6);
249 spectrumChannel->AddPropagationLossModel(lossModel);
250
253 spectrumChannel->SetPropagationDelayModel(delayModel);
254
255 spectrumPhy.SetChannel(spectrumChannel);
256 spectrumPhy.SetErrorRateModel(errorModelType);
257 // channel 36 at 20 MHz, 38 at 40 MHz
258 spectrumPhy.Set("ChannelSettings",
259 StringValue(std::string("{") + (frequency == 5180 ? "36" : "38") +
260 ", 0, BAND_5GHZ, 0}"));
261 }
262 else
263 {
264 NS_FATAL_ERROR("Unsupported WiFi type " << wifiType);
265 }
266
267 WifiHelper wifi;
268 wifi.SetStandard(WIFI_STANDARD_80211n);
269 WifiMacHelper mac;
270
271 Ssid ssid = Ssid("ns380211n");
272
273 double datarate = 0;
275 if (i == 0)
276 {
277 DataRate = StringValue("HtMcs0");
278 datarate = 6.5;
279 }
280 else if (i == 1)
281 {
282 DataRate = StringValue("HtMcs1");
283 datarate = 13;
284 }
285 else if (i == 2)
286 {
287 DataRate = StringValue("HtMcs2");
288 datarate = 19.5;
289 }
290 else if (i == 3)
291 {
292 DataRate = StringValue("HtMcs3");
293 datarate = 26;
294 }
295 else if (i == 4)
296 {
297 DataRate = StringValue("HtMcs4");
298 datarate = 39;
299 }
300 else if (i == 5)
301 {
302 DataRate = StringValue("HtMcs5");
303 datarate = 52;
304 }
305 else if (i == 6)
306 {
307 DataRate = StringValue("HtMcs6");
308 datarate = 58.5;
309 }
310 else if (i == 7)
311 {
312 DataRate = StringValue("HtMcs7");
313 datarate = 65;
314 }
315 else if (i == 8)
316 {
317 DataRate = StringValue("HtMcs0");
318 datarate = 7.2;
319 }
320 else if (i == 9)
321 {
322 DataRate = StringValue("HtMcs1");
323 datarate = 14.4;
324 }
325 else if (i == 10)
326 {
327 DataRate = StringValue("HtMcs2");
328 datarate = 21.7;
329 }
330 else if (i == 11)
331 {
332 DataRate = StringValue("HtMcs3");
333 datarate = 28.9;
334 }
335 else if (i == 12)
336 {
337 DataRate = StringValue("HtMcs4");
338 datarate = 43.3;
339 }
340 else if (i == 13)
341 {
342 DataRate = StringValue("HtMcs5");
343 datarate = 57.8;
344 }
345 else if (i == 14)
346 {
347 DataRate = StringValue("HtMcs6");
348 datarate = 65;
349 }
350 else if (i == 15)
351 {
352 DataRate = StringValue("HtMcs7");
353 datarate = 72.2;
354 }
355 else if (i == 16)
356 {
357 DataRate = StringValue("HtMcs0");
358 datarate = 13.5;
359 }
360 else if (i == 17)
361 {
362 DataRate = StringValue("HtMcs1");
363 datarate = 27;
364 }
365 else if (i == 18)
366 {
367 DataRate = StringValue("HtMcs2");
368 datarate = 40.5;
369 }
370 else if (i == 19)
371 {
372 DataRate = StringValue("HtMcs3");
373 datarate = 54;
374 }
375 else if (i == 20)
376 {
377 DataRate = StringValue("HtMcs4");
378 datarate = 81;
379 }
380 else if (i == 21)
381 {
382 DataRate = StringValue("HtMcs5");
383 datarate = 108;
384 }
385 else if (i == 22)
386 {
387 DataRate = StringValue("HtMcs6");
388 datarate = 121.5;
389 }
390 else if (i == 23)
391 {
392 DataRate = StringValue("HtMcs7");
393 datarate = 135;
394 }
395 else if (i == 24)
396 {
397 DataRate = StringValue("HtMcs0");
398 datarate = 15;
399 }
400 else if (i == 25)
401 {
402 DataRate = StringValue("HtMcs1");
403 datarate = 30;
404 }
405 else if (i == 26)
406 {
407 DataRate = StringValue("HtMcs2");
408 datarate = 45;
409 }
410 else if (i == 27)
411 {
412 DataRate = StringValue("HtMcs3");
413 datarate = 60;
414 }
415 else if (i == 28)
416 {
417 DataRate = StringValue("HtMcs4");
418 datarate = 90;
419 }
420 else if (i == 29)
421 {
422 DataRate = StringValue("HtMcs5");
423 datarate = 120;
424 }
425 else if (i == 30)
426 {
427 DataRate = StringValue("HtMcs6");
428 datarate = 135;
429 }
430 else
431 {
432 DataRate = StringValue("HtMcs7");
433 datarate = 150;
434 }
435
436 wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager",
437 "DataMode",
438 DataRate,
439 "ControlMode",
440 DataRate);
441
442 NetDeviceContainer staDevice;
443 NetDeviceContainer apDevice;
444
445 if (wifiType == "ns3::YansWifiPhy")
446 {
447 mac.SetType("ns3::StaWifiMac", "Ssid", SsidValue(ssid));
448 staDevice = wifi.Install(phy, mac, wifiStaNode);
449 mac.SetType("ns3::ApWifiMac", "Ssid", SsidValue(ssid));
450 apDevice = wifi.Install(phy, mac, wifiApNode);
451 }
452 else if (wifiType == "ns3::SpectrumWifiPhy")
453 {
454 mac.SetType("ns3::StaWifiMac", "Ssid", SsidValue(ssid));
455 staDevice = wifi.Install(spectrumPhy, mac, wifiStaNode);
456 mac.SetType("ns3::ApWifiMac", "Ssid", SsidValue(ssid));
457 apDevice = wifi.Install(spectrumPhy, mac, wifiApNode);
458 }
459
460 bool shortGuardIntervalSupported = (i > 7 && i <= 15) || (i > 23);
461 Config::Set("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HtConfiguration/"
462 "ShortGuardIntervalSupported",
463 BooleanValue(shortGuardIntervalSupported));
464
465 // mobility.
466 MobilityHelper mobility;
468
469 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
470 positionAlloc->Add(Vector(distance, 0.0, 0.0));
471 positionAlloc->Add(Vector(distance, distance, 0.0));
472 mobility.SetPositionAllocator(positionAlloc);
473
474 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
475
476 mobility.Install(wifiApNode);
477 mobility.Install(wifiStaNode);
478 mobility.Install(interferingNode);
479
480 /* Internet stack*/
482 stack.Install(wifiApNode);
483 stack.Install(wifiStaNode);
484
485 Ipv4AddressHelper address;
486 address.SetBase("192.168.1.0", "255.255.255.0");
487 Ipv4InterfaceContainer staNodeInterface;
488 Ipv4InterfaceContainer apNodeInterface;
489
490 staNodeInterface = address.Assign(staDevice);
491 apNodeInterface = address.Assign(apDevice);
492
493 /* Setting applications */
494 ApplicationContainer serverApp;
495 if (udp)
496 {
497 // UDP flow
498 uint16_t port = 9;
499 UdpServerHelper server(port);
500 serverApp = server.Install(wifiStaNode.Get(0));
501 serverApp.Start(Seconds(0.0));
502 serverApp.Stop(simulationTime + Seconds(1.0));
503 const auto packetInterval = payloadSize * 8.0 / (datarate * 1e6);
504
505 UdpClientHelper client(staNodeInterface.GetAddress(0), port);
506 client.SetAttribute("MaxPackets", UintegerValue(4294967295U));
507 client.SetAttribute("Interval", TimeValue(Seconds(packetInterval)));
508 client.SetAttribute("PacketSize", UintegerValue(payloadSize));
509 ApplicationContainer clientApp = client.Install(wifiApNode.Get(0));
510 clientApp.Start(Seconds(1.0));
511 clientApp.Stop(simulationTime + Seconds(1.0));
512 }
513 else
514 {
515 // TCP flow
516 uint16_t port = 50000;
518 PacketSinkHelper packetSinkHelper("ns3::TcpSocketFactory", localAddress);
519 serverApp = packetSinkHelper.Install(wifiStaNode.Get(0));
520 serverApp.Start(Seconds(0.0));
521 serverApp.Stop(simulationTime + Seconds(1.0));
522
523 OnOffHelper onoff("ns3::TcpSocketFactory", Ipv4Address::GetAny());
524 onoff.SetAttribute("OnTime", StringValue("ns3::ConstantRandomVariable[Constant=1]"));
525 onoff.SetAttribute("OffTime", StringValue("ns3::ConstantRandomVariable[Constant=0]"));
526 onoff.SetAttribute("PacketSize", UintegerValue(payloadSize));
527 onoff.SetAttribute("DataRate", DataRateValue(datarate * 1e6));
528 AddressValue remoteAddress(InetSocketAddress(staNodeInterface.GetAddress(0), port));
529 onoff.SetAttribute("Remote", remoteAddress);
530 ApplicationContainer clientApp = onoff.Install(wifiApNode.Get(0));
531 clientApp.Start(Seconds(1.0));
532 clientApp.Stop(simulationTime + Seconds(1.0));
533 }
534
535 // Configure waveform generator
536 Ptr<SpectrumValue> wgPsd =
538 *wgPsd = waveformPower / 20e6; // PSD spread across 20 MHz
539 NS_LOG_INFO("wgPsd : " << *wgPsd
540 << " integrated power: " << Integral(*(GetPointer(wgPsd))));
541
542 if (wifiType == "ns3::SpectrumWifiPhy")
543 {
544 WaveformGeneratorHelper waveformGeneratorHelper;
545 waveformGeneratorHelper.SetChannel(spectrumChannel);
546 waveformGeneratorHelper.SetTxPowerSpectralDensity(wgPsd);
547
548 waveformGeneratorHelper.SetPhyAttribute("Period", TimeValue(Seconds(0.0007)));
549 waveformGeneratorHelper.SetPhyAttribute("DutyCycle", DoubleValue(1));
550 NetDeviceContainer waveformGeneratorDevices =
551 waveformGeneratorHelper.Install(interferingNode);
552
555 waveformGeneratorDevices.Get(0)
556 ->GetObject<NonCommunicatingNetDevice>()
557 ->GetPhy()
559 }
560
561 Config::ConnectWithoutContext("/NodeList/0/DeviceList/*/Phy/MonitorSnifferRx",
563
564 if (enablePcap)
565 {
566 phy.SetPcapDataLinkType(WifiPhyHelper::DLT_IEEE802_11_RADIO);
567 std::stringstream ss;
568 ss << "wifi-spectrum-per-example-" << i;
569 phy.EnablePcap(ss.str(), apDevice);
570 }
571 g_signalDbmAvg = 0;
572 g_noiseDbmAvg = 0;
573 g_samples = 0;
574
575 // Make sure we are tuned to 5180 MHz; if not, the example will
576 // not work properly
577 Ptr<NetDevice> staDevicePtr = staDevice.Get(0);
578 Ptr<WifiPhy> wifiPhyPtr = staDevicePtr->GetObject<WifiNetDevice>()->GetPhy();
579 if (i <= 15)
580 {
581 NS_ABORT_MSG_IF(wifiPhyPtr->GetChannelWidth() != 20,
582 "Error: Channel width must be 20 MHz if MCS index <= 15");
584 wifiPhyPtr->GetFrequency() != 5180,
585 "Error: Wi-Fi nodes must be tuned to 5180 MHz to match the waveform generator");
586 }
587 else
588 {
589 NS_ABORT_MSG_IF(wifiPhyPtr->GetChannelWidth() != 40,
590 "Error: Channel width must be 40 MHz if MCS index > 15");
592 wifiPhyPtr->GetFrequency() != 5190,
593 "Error: Wi-Fi nodes must be tuned to 5190 MHz to match the waveform generator");
594 }
595
596 Simulator::Stop(simulationTime + Seconds(1.0));
598
599 auto throughput = 0.0;
600 auto totalPacketsThrough = 0.0;
601 if (udp)
602 {
603 // UDP
604 totalPacketsThrough = DynamicCast<UdpServer>(serverApp.Get(0))->GetReceived();
605 throughput =
606 totalPacketsThrough * payloadSize * 8 / simulationTime.GetMicroSeconds(); // Mbit/s
607 }
608 else
609 {
610 // TCP
611 auto totalBytesRx = DynamicCast<PacketSink>(serverApp.Get(0))->GetTotalRx();
612 totalPacketsThrough = totalBytesRx / tcpPacketSize;
613 throughput = totalBytesRx * 8 / simulationTime.GetMicroSeconds(); // Mbit/s
614 }
615 std::cout << std::setw(5) << i << std::setw(6) << (i % 8) << std::setprecision(2)
616 << std::fixed << std::setw(10) << datarate << std::setw(12) << throughput
617 << std::setw(8) << totalPacketsThrough;
618 if (totalPacketsThrough > 0)
619 {
620 std::cout << std::setw(12) << g_signalDbmAvg << std::setw(12) << g_noiseDbmAvg
621 << std::setw(12) << (g_signalDbmAvg - g_noiseDbmAvg) << std::endl;
622 }
623 else
624 {
625 std::cout << std::setw(12) << "N/A" << std::setw(12) << "N/A" << std::setw(12) << "N/A"
626 << std::endl;
627 }
629 }
630 return 0;
631}
a polymophic address class
Definition address.h:90
holds a vector of ns3::Application pointers.
void Start(Time start) const
Start all of the Applications in this container at the start time given as a parameter.
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
void Stop(Time stop) const
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
Parse command-line arguments.
Class for representing data rates.
Definition data-rate.h:78
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
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()
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...
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition object.h:511
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition simulator.h:560
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
static void Run()
Run the simulation.
Definition simulator.cc:167
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition simulator.cc:175
Make it easy to create and manage PHY objects for the spectrum model.
void SetChannel(const Ptr< SpectrumChannel > channel)
The IEEE 802.11 SSID Information Element.
Definition ssid.h:25
Hold variables of type string.
Definition string.h:45
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
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:34
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
create MAC layers for a ns3::WifiNetDevice.
Hold together all Wifi-related objects.
void Set(std::string name, const AttributeValue &v)
void SetErrorRateModel(std::string type, Args &&... args)
Helper function used to set the error rate model.
@ DLT_IEEE802_11_RADIO
Include Radiotap link layer information.
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.
Initializer for a static spectrum model centered around 5180 MHz.
Initializer for a static spectrum model centered around 5190 MHz.
uint16_t port
Definition dsdv-manet.cc:33
void SetDefault(std::string name, const AttributeValue &value)
Definition config.cc:883
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
Definition config.cc:943
void Set(std::string path, const AttributeValue &value)
Definition config.cc:869
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition abort.h:97
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition log.h:264
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
@ WIFI_STANDARD_80211n
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition callback.h:684
double Integral(const SpectrumValue &arg)
std::vector< BandInfo > Bands
Container of BandInfo.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:580
U * GetPointer(const Ptr< U > &p)
Definition ptr.h:450
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 wifi-types.h:65
SignalNoiseDbm structure.
Definition wifi-types.h:58
dBm_u noise
noise power
Definition wifi-types.h:60
dBm_u signal
signal strength
Definition wifi-types.h:59
std::ofstream throughput
double g_signalDbmAvg
Average signal power [dBm].
double g_noiseDbmAvg
Average noise power [dBm].
Ptr< SpectrumModel > SpectrumModelWifi5190MHz
Spectrum model at 5190 MHz.
static_SpectrumModelWifi5180MHz_initializer static_SpectrumModelWifi5180MHz_initializer_instance
Static instance to initizlize the spectrum model around 5180 MHz.
uint32_t g_samples
Number of samples.
void MonitorSniffRx(Ptr< const Packet > packet, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise, uint16_t staId)
Monitor sniffer Rx trace.
static_SpectrumModelWifi5190MHz_initializer static_SpectrumModelWifi5190MHz_initializer_instance
Static instance to initizlize the spectrum model around 5190 MHz.
Ptr< SpectrumModel > SpectrumModelWifi5180MHz
Spectrum model at 5180 MHz.