A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-multicast.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 DERONNE SOFTWARE ENGINEERING
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Sébastien Deronne <sebastien.deronne@gmail.com>
7 */
8
9#include "ns3/boolean.h"
10#include "ns3/command-line.h"
11#include "ns3/config.h"
12#include "ns3/data-rate.h"
13#include "ns3/double.h"
14#include "ns3/enum.h"
15#include "ns3/error-model.h"
16#include "ns3/inet-socket-address.h"
17#include "ns3/internet-stack-helper.h"
18#include "ns3/ipv4-address-helper.h"
19#include "ns3/ipv4-l3-protocol.h"
20#include "ns3/ipv4-list-routing-helper.h"
21#include "ns3/ipv4-static-routing-helper.h"
22#include "ns3/ipv4-static-routing.h"
23#include "ns3/log.h"
24#include "ns3/mobility-helper.h"
25#include "ns3/mobility-model.h"
26#include "ns3/names.h"
27#include "ns3/node.h"
28#include "ns3/on-off-helper.h"
29#include "ns3/packet-sink-helper.h"
30#include "ns3/packet-sink.h"
31#include "ns3/simulator.h"
32#include "ns3/socket.h"
33#include "ns3/ssid.h"
34#include "ns3/string.h"
35#include "ns3/test.h"
36#include "ns3/trace-helper.h"
37#include "ns3/udp-socket-factory.h"
38#include "ns3/udp-socket.h"
39#include "ns3/uinteger.h"
40#include "ns3/wifi-mac.h"
41#include "ns3/wifi-net-device.h"
42#include "ns3/wifi-psdu.h"
43#include "ns3/yans-wifi-channel.h"
44#include "ns3/yans-wifi-helper.h"
45
46#include <limits>
47#include <sstream>
48#include <string>
49
50// This is an example to verify performance of 802.11aa groupcast with retries (GCR) in comparison
51// with the usual NoAck/NoRetry retransmission policy. In the latter, a groupcast frame is
52// transmitted only once, whereas GCR allows to retransmit groupcast frames to improve reliability.
53//
54// The simulation considers a single 802.11ax AP and a configurable number of GCR-capable STAs in an
55// infrastructure network. Multicast traffic is generated from the AP to all the non-AP STAs and
56// artificial errors can be introduced to mimic interference on the wireless channel.
57//
58// There are a number of command-line options available to control the scenario under test. The list
59// of available command-line options can be listed with the following command:
60// ./ns3 run "wifi-multicast --help"
61//
62// The main command-line options are:
63// --gcrRetransmissionPolicy: control the retransmission policy by selecting "NoAckNoRetry" for
64// no retransmission, "GcrUr" for GCR with unsolicited retries or "GcrBlockAck" for GCR Block Ack
65// --nStations: control the number of GCR-capable STAs associated to the AP
66// --accessCategory: control the access category to use for the multicast traffic
67// --multicastFrameErrorRate: set the artificial frame error rate for the groupcast traffic
68// --nRetriesGcrUr: if GCR-UR is selected, this parameter controls the maximum number of retries
69// --gcrProtection: select the protection mechanism for groupcast frames if GCR-UR or GCR-BA is
70// used, either "Rts-Cts" or "Cts-To-Self" can be selected
71//
72// Example usage for NoAckNoRetry and a frame error rate of 20%:
73// ./ns3 run "wifi-multicast --gcrRetransmissionPolicy=NoAckNoRetry --multicastFrameErrorRate=0.2"
74// which outputs:
75// Node TX packets TX bytes RX packets RX bytes Throughput (Mbit/s)
76// AP 10 10000 0 0 11.1111
77// STA1 0 0 10 10000 10.992
78//
79// Example usage for GCR-UR with up to 2 retries and the same frame error rate:
80// ./ns3 run "wifi-multicast --gcrRetransmissionPolicy=GcrUr --nRetriesGcrUr=2
81// --multicastFrameErrorRate=0.2"
82// which outputs:
83// Node TX packets TX bytes RX packets RX bytes Throughput (Mbit/s)
84// AP 10 10000 0 0 11.1111
85// STA1 0 0 10 10000 10.992
86//
87// Example usage for GCR-BA with 4 STAs and the same frame error rate:
88// ./ns3 run "wifi-multicast --gcrRetransmissionPolicy=GcrBlockAck --nStations=4"
89// which outputs:
90// Node TX packets TX bytes RX packets RX bytes Throughput (Mbit/s)
91// AP 10 10000 0 0 11.1111
92// STA1 0 0 10 10000 8.26959
93// STA2 0 0 10 10000 8.26959
94// STA3 0 0 10 10000 8.26959
95// STA4 0 0 10 10000 8.26959
96
97using namespace ns3;
98
99NS_LOG_COMPONENT_DEFINE("WifiMulticast");
100
101uint64_t g_txBytes; //!< Number of generated bytes
102Time g_firstTx; //!< Time at which first TX packet is generated
103Time g_lastTx; //!< Time at which last TX packet is generated
104Time g_lastRx; //!< Time at which last RX packet is received
105
106/**
107 * Parse context strings of the form "/NodeList/x/DeviceList/x/..." to extract the NodeId integer
108 *
109 * @param context The context to parse.
110 * @return the NodeId
111 */
113ContextToNodeId(const std::string& context)
114{
115 std::string sub = context.substr(10);
116 uint32_t pos = sub.find("/Device");
117 return std::stoi(sub.substr(0, pos));
118}
119
120/**
121 * Socket sent packet.
122 *
123 * @param context The context.
124 * @param p The packet.
125 */
126void
127SocketTxPacket(std::string context, Ptr<const Packet> p)
128{
129 if (g_txBytes == 0)
130 {
132 }
133 g_txBytes += p->GetSize();
135}
136
137/**
138 *
139 * @param context The context.
140 * @param p The packet.
141 * @param from sender address.
142 */
143void
144SocketRxPacket(std::string context, Ptr<const Packet> p, const Address& from)
145{
147}
148
149/**
150 * Callback when a frame is transmitted.
151 * @param rxErrorModel the post reception error model on the receiver
152 * @param ranVar the random variable to determine whether the packet shall be corrupted
153 * @param errorRate the configured corruption error rate for multicast frames
154 * @param context the context
155 * @param psduMap the PSDU map
156 * @param txVector the TX vector
157 * @param txPowerW the tx power in Watts
158 */
159void
162 double errorRate,
163 std::string context,
164 WifiConstPsduMap psduMap,
165 WifiTxVector txVector,
166 double txPowerW)
167{
168 auto psdu = psduMap.begin()->second;
169 if (psdu->GetHeader(0).GetAddr1().IsGroup() && !psdu->GetHeader(0).GetAddr1().IsBroadcast() &&
170 psdu->GetHeader(0).IsQosData())
171 {
172 NS_LOG_INFO("AP tx multicast: PSDU=" << *psdu << " TXVECTOR=" << txVector);
173 if (ranVar->GetValue() < errorRate)
174 {
175 auto uid = psdu->GetPayload(0)->GetUid();
176 NS_LOG_INFO("Corrupt multicast frame with UID=" << uid);
177 rxErrorModel->SetList({uid});
178 }
179 else
180 {
181 rxErrorModel->SetList({});
182 }
183 }
184}
185
186/**
187 * Callback when a frame is successfully received.
188 *
189 * @param context the context
190 * @param p the packet
191 * @param snr the SNR (in linear scale)
192 * @param mode the mode used to transmit the packet
193 * @param preamble the preamble
194 */
195void
196RxCallback(std::string context,
198 double snr,
199 WifiMode mode,
200 WifiPreamble preamble)
201{
202 Ptr<Packet> packet = p->Copy();
203 WifiMacHeader hdr;
204 packet->RemoveHeader(hdr);
205 if (hdr.GetAddr1().IsGroup() && !hdr.GetAddr1().IsBroadcast() && hdr.IsQosData())
206 {
207 std::stringstream ss;
208 hdr.Print(ss);
209 NS_LOG_INFO("STA" << ContextToNodeId(context) << " rx multicast: " << ss.str());
210 }
211}
212
213int
214main(int argc, char* argv[])
215{
216 bool logging{false};
217 bool verbose{false};
218 bool pcap{false};
219 std::size_t nStations{1};
220 Time simulationTime{"10s"};
221 uint32_t payloadSize{1000}; // bytes
222 DataRate dataRate{"10Mb/s"};
223 uint32_t maxPackets{10};
224 uint32_t rtsThreshold{std::numeric_limits<uint16_t>::max()};
225 std::string targetAddr{"239.192.100.1"};
226 std::string accessCategory{"AC_BE"};
227 std::string gcrRetransmissionPolicy{"NoAckNoRetry"};
228 std::string rateManager{"Constant"};
229 uint16_t constantRateMcs{11};
230 uint16_t nRetriesGcrUr{7};
231 std::string gcrProtection{"Rts-Cts"};
232 double multicastFrameErrorRate{0.0};
233 uint16_t maxAmpduLength{0};
234 double minExpectedPackets{0};
235 double maxExpectedPackets{0};
236 double minExpectedThroughput{0};
237 double maxExpectedThroughput{0};
238 double tolerance{0.01};
239
240 CommandLine cmd(__FILE__);
241 cmd.AddValue("logging", "turn on example log components", logging);
242 cmd.AddValue("verbose", "turn on all wifi log components", verbose);
243 cmd.AddValue("pcap", "turn on pcap file output", pcap);
244 cmd.AddValue("nStations", "number of non-AP stations", nStations);
245 cmd.AddValue("simulationTime", "Simulation time", simulationTime);
246 cmd.AddValue("payloadSize", "The application payload size in bytes", payloadSize);
247 cmd.AddValue(
248 "maxPackets",
249 "The maximum number of packets to be generated by the application (0 for no limit)",
250 maxPackets);
251 cmd.AddValue("dataRate", "The application data rate", dataRate);
252 cmd.AddValue("rtsThreshold", "RTS threshold", rtsThreshold);
253 cmd.AddValue("rateManager",
254 "The rate adaptation manager to use (Constant, Ideal, MinstrelHt)",
255 rateManager);
256 cmd.AddValue("mcs",
257 "The MCS to use if Constant rate adaptation manager is used",
258 constantRateMcs);
259 cmd.AddValue("targetAddress", "multicast target address", targetAddr);
260 cmd.AddValue("accessCategory",
261 "select the multicast traffic access category (AC_BE, AC_BK, AC_VI, AC_VO)",
262 accessCategory);
263 cmd.AddValue(
264 "gcrRetransmissionPolicy",
265 "GCR retransmission policy for groupcast frames (NoAckNoRetry, GcrUr, GcrBlockAck)",
266 gcrRetransmissionPolicy);
267 cmd.AddValue("nRetriesGcrUr",
268 "number of retries per groupcast frame when GCR-UR retransmission policy is used",
269 nRetriesGcrUr);
270 cmd.AddValue("gcrProtection",
271 "protection to use for GCR (Rts-Cts or Cts-To-Self)",
272 gcrProtection);
273 cmd.AddValue("multicastFrameErrorRate",
274 "artificial error rate for multicast frame",
275 multicastFrameErrorRate);
276 cmd.AddValue("maxAmpduLength", "maximum length in bytes of an A-MPDU", maxAmpduLength);
277 cmd.AddValue("minExpectedPackets",
278 "if set, simulation fails if the lowest amount of received packets is below this "
279 "value (in Mbit/s)",
280 minExpectedPackets);
281 cmd.AddValue("maxExpectedPackets",
282 "if set, simulation fails if the highest amount of received packets is above this "
283 "value (in Mbit/s)",
284 maxExpectedPackets);
285 cmd.AddValue("minExpectedThroughput",
286 "if set, simulation fails if the throughput is below this value",
287 minExpectedThroughput);
288 cmd.AddValue("maxExpectedThroughput",
289 "if set, simulation fails if the throughput is above this value",
290 maxExpectedThroughput);
291 cmd.Parse(argc, argv);
292
293 Config::SetDefault("ns3::WifiMac::RobustAVStreamingSupported", BooleanValue(true));
294
295 // create nodes
297 wifiApNode.Create(1);
299 wifiStaNodes.Create(nStations);
300
301 // configure PHY and MAC
303 if (verbose)
304 {
306 }
307 if (logging)
308 {
309 LogComponentEnable("WifiMulticast", LOG_LEVEL_ALL);
310 }
311 wifi.SetStandard(WIFI_STANDARD_80211ax);
312
313 YansWifiPhyHelper wifiPhy;
315
316 auto wifiChannel = YansWifiChannelHelper::Default();
317 wifiChannel.SetPropagationDelay("ns3::ConstantSpeedPropagationDelayModel");
318 wifiPhy.SetChannel(wifiChannel.Create());
319
320 WifiMacHelper wifiMac;
321 if (rateManager == "Constant")
322 {
323 wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager",
324 "DataMode",
325 StringValue("HeMcs" + std::to_string(constantRateMcs)),
326 "RtsCtsThreshold",
327 UintegerValue(rtsThreshold));
328 }
329 else
330 {
331 wifi.SetRemoteStationManager("ns3::" + rateManager + "RateWifiManager",
332 "RtsCtsThreshold",
333 UintegerValue(rtsThreshold));
334 }
335
336 if (gcrRetransmissionPolicy != "NoAckNoRetry")
337 {
338 std::string retransmissionPolicyStr;
339 if (gcrRetransmissionPolicy == "GcrUr")
340 {
341 retransmissionPolicyStr = "GCR_UR";
342 }
343 else if (gcrRetransmissionPolicy == "GcrBlockAck")
344 {
345 retransmissionPolicyStr = "GCR_BA";
346 }
347 else
348 {
349 std::cout << "Wrong retransmission policy!" << std::endl;
350 return 0;
351 }
352 wifiMac.SetGcrManager("ns3::WifiDefaultGcrManager",
353 "RetransmissionPolicy",
354 StringValue(retransmissionPolicyStr),
355 "UnsolicitedRetryLimit",
356 UintegerValue(nRetriesGcrUr),
357 "GcrProtectionMode",
358 StringValue(gcrProtection));
359 }
360
361 Ssid ssid = Ssid("wifi-multicast");
362
363 // setup AP
364 wifiMac.SetType("ns3::ApWifiMac", "Ssid", SsidValue(ssid));
365 auto apDevice = wifi.Install(wifiPhy, wifiMac, wifiApNode);
366
367 // setup STAs
368 wifiMac.SetType("ns3::StaWifiMac", "Ssid", SsidValue(ssid));
369 auto staDevices = wifi.Install(wifiPhy, wifiMac, wifiStaNodes);
370
371 auto rxErrorModel = CreateObject<ListErrorModel>();
373 ranVar->SetStream(1);
374 Config::Connect("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phys/0/PhyTxPsduBegin",
375 MakeCallback(TxCallback).Bind(rxErrorModel, ranVar, multicastFrameErrorRate));
376 for (std::size_t i = 0; i < nStations; ++i)
377 {
378 auto wifiMac = DynamicCast<WifiNetDevice>(staDevices.Get(i))->GetMac();
379 wifiMac->GetWifiPhy(0)->SetPostReceptionErrorModel(rxErrorModel);
380 }
381 Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/State/RxOk",
383
384 // mobility
387 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
388 for (std::size_t i = 0; i < nStations; ++i)
389 {
390 positionAlloc->Add(Vector(i, 0.0, 0.0));
391 }
392 mobility.SetPositionAllocator(positionAlloc);
393 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
394 mobility.Install(wifiApNode);
395 mobility.Install(wifiStaNodes);
396
397 // setup static routes to facilitate multicast flood
398 Ipv4ListRoutingHelper listRouting;
399 Ipv4StaticRoutingHelper staticRouting;
400 listRouting.Add(staticRouting, 0);
401
402 // configure IP stack
404 internet.SetIpv6StackInstall(false);
405 internet.SetIpv4ArpJitter(true);
406 internet.SetRoutingHelper(listRouting);
407 internet.Install(wifiApNode);
408 internet.Install(wifiStaNodes);
409
410 Ipv4AddressHelper ipv4address;
411 ipv4address.SetBase("10.0.0.0", "255.255.255.0");
412 auto apNodeInterface = ipv4address.Assign(apDevice);
413 auto staNodeInterfaces = ipv4address.Assign(staDevices);
414
415 // add static route in AP
416 auto ipv4 = wifiApNode.Get(0)->GetObject<Ipv4>();
417 auto routing = staticRouting.GetStaticRouting(ipv4);
418 routing->AddHostRouteTo(targetAddr.c_str(),
419 ipv4->GetInterfaceForDevice(wifiApNode.Get(0)->GetDevice(0)),
420 0);
421
422 uint8_t tosValue;
423 std::string maxAmpduSizeAttribute;
424 if (accessCategory == "AC_BE")
425 {
426 tosValue = 0x70;
427 maxAmpduSizeAttribute = "BE_MaxAmpduSize";
428 }
429 else if (accessCategory == "AC_BK")
430 {
431 tosValue = 0x28;
432 maxAmpduSizeAttribute = "BK_MaxAmpduSize";
433 }
434 else if (accessCategory == "AC_VI")
435 {
436 tosValue = 0xb8;
437 maxAmpduSizeAttribute = "VI_MaxAmpduSize";
438 }
439 else if (accessCategory == "AC_VO")
440 {
441 tosValue = 0xc0;
442 maxAmpduSizeAttribute = "VO_MaxAmpduSize";
443 }
444 else
445 {
446 NS_ABORT_MSG("Invalid access category");
447 }
448 auto apWifiMac = DynamicCast<WifiNetDevice>(apDevice.Get(0))->GetMac();
449 apWifiMac->SetAttribute(maxAmpduSizeAttribute, UintegerValue(maxAmpduLength));
450
451 // sinks
452 InetSocketAddress sinkSocket(Ipv4Address::GetAny(), 90);
453 PacketSinkHelper sinkHelper("ns3::UdpSocketFactory", sinkSocket);
454 auto sinks = sinkHelper.Install(wifiStaNodes);
455 sinks.Start(Seconds(0));
456 sinks.Stop(simulationTime + Seconds(2.0));
457
458 // source
459 InetSocketAddress sourceSocket(targetAddr.c_str(), 90);
460 OnOffHelper onoffHelper("ns3::UdpSocketFactory", sourceSocket);
461 onoffHelper.SetAttribute("DataRate", DataRateValue(dataRate));
462 onoffHelper.SetAttribute("PacketSize", UintegerValue(payloadSize));
463 onoffHelper.SetAttribute("MaxBytes", UintegerValue(maxPackets * payloadSize));
464 onoffHelper.SetAttribute("Tos", UintegerValue(tosValue));
465 onoffHelper.SetAttribute("OnTime", StringValue("ns3::ConstantRandomVariable[Constant=1]"));
466 onoffHelper.SetAttribute("OffTime", StringValue("ns3::ConstantRandomVariable[Constant=0]"));
467 auto source = onoffHelper.Install(wifiApNode);
468 source.Start(Seconds(1));
469 source.Stop(simulationTime + Seconds(1.0));
470
471 // pcap
472 if (pcap)
473 {
474 wifiPhy.EnablePcap("wifi-multicast-AP", apDevice.Get(0));
475 for (std::size_t i = 0; i < nStations; ++i)
476 {
477 wifiPhy.EnablePcap("wifi-multicast-STA" + std::to_string(i + 1), staDevices.Get(i));
478 }
479 }
480
481 g_txBytes = 0;
482
483 Config::Connect("/NodeList/*/$ns3::Node/ApplicationList/*/$ns3::OnOffApplication/Tx",
485
486 Config::Connect("/NodeList/*/ApplicationList/*/$ns3::PacketSink/Rx",
488
489 // run simulation
490 Simulator::Stop(simulationTime + Seconds(2.0));
492
493 // check results
494 std::cout << "Node\t\t\tTX packets\t\tTX bytes\t\tRX packets\t\tRX bytes\t\tThroughput (Mbit/s)"
495 << std::endl;
496 const auto txRate =
497 (g_lastTx - g_firstTx).IsStrictlyPositive()
498 ? static_cast<double>(g_txBytes * 8) / ((g_lastTx - g_firstTx).GetMicroSeconds())
499 : 0.0; // Mbit/s
500 const auto txPackets = g_txBytes / payloadSize;
501 std::cout << "AP"
502 << "\t\t\t" << txPackets << "\t\t\t" << g_txBytes << "\t\t\t0\t\t\t0\t\t\t" << txRate
503 << "" << std::endl;
504 for (std::size_t i = 0; i < nStations; ++i)
505 {
506 const auto rxBytes = sinks.Get(0)->GetObject<PacketSink>()->GetTotalRx();
507 const auto rxPackets = rxBytes / payloadSize;
508 const auto throughput =
509 (g_lastRx - g_firstTx).IsStrictlyPositive()
510 ? static_cast<double>(rxBytes * 8) / ((g_lastRx - g_firstTx).GetMicroSeconds())
511 : 0.0; // Mbit/s
512 std::cout << "STA" << i + 1 << "\t\t\t0\t\t\t0\t\t\t" << rxPackets << "\t\t\t" << rxBytes
513 << "\t\t\t" << throughput << "" << std::endl;
514 if (rxPackets < minExpectedPackets)
515 {
516 NS_LOG_ERROR("Obtained RX packets " << rxPackets << " is not expected!");
517 exit(1);
518 }
519 if (maxExpectedPackets > 0 && rxPackets > maxExpectedPackets)
520 {
521 NS_LOG_ERROR("Obtained RX packets " << rxPackets << " is not expected!");
522 exit(1);
523 }
524 if ((throughput * (1 + tolerance)) < minExpectedThroughput)
525 {
526 NS_LOG_ERROR("Obtained throughput " << throughput << " is not expected!");
527 exit(1);
528 }
529 if (maxExpectedThroughput > 0 && (throughput > (maxExpectedThroughput * (1 + tolerance))))
530 {
531 NS_LOG_ERROR("Obtained throughput " << throughput << " is not expected!");
532 exit(1);
533 }
534 }
535
537 return 0;
538}
a polymophic address class
Definition address.h:90
Parse command-line arguments.
Class for representing data rates.
Definition data-rate.h:78
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.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
static Ipv4Address GetAny()
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition ipv4.h:69
Helper class that adds ns3::Ipv4ListRouting objects.
void Add(const Ipv4RoutingHelper &routing, int16_t priority)
Helper class that adds ns3::Ipv4StaticRouting objects.
Ptr< Ipv4StaticRouting > GetStaticRouting(Ptr< Ipv4 > ipv4) const
Try and find the static routing protocol as either the main routing protocol or in the list of routin...
bool IsGroup() const
bool IsBroadcast() const
Helper class used to assign positions and mobility models to nodes.
keep track of a set of node pointers.
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.
Receive and consume traffic generated to an IP address and port.
Definition packet-sink.h:62
void EnablePcap(std::string prefix, Ptr< NetDevice > nd, bool promiscuous=false, bool explicitFilename=false)
Enable pcap output the indicated net device.
Smart pointer class similar to boost::intrusive_ptr.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:197
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
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
Hold an unsigned integer type.
Definition uinteger.h:34
helps to create WifiNetDevice objects
static void EnableLogComponents(LogLevel logLevel=LOG_LEVEL_ALL)
Helper to enable all WifiNetDevice log components with one statement.
Implements the IEEE 802.11 MAC header.
Mac48Address GetAddr1() const
Return the address in the Address 1 field.
void Print(std::ostream &os) const override
bool IsQosData() const
Return true if the Type is DATA and Subtype is one of the possible values for QoS Data.
create MAC layers for a ns3::WifiNetDevice.
void SetGcrManager(std::string type, Args &&... args)
Helper function used to set the GCR Manager that can be installed on a QoS AP.
void SetType(std::string type, Args &&... args)
represent a single transmission mode
Definition wifi-mode.h:40
void SetPcapDataLinkType(SupportedPcapDataLinkTypes dlt)
Set the data link type of PCAP traces to be used.
@ 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...
static YansWifiChannelHelper Default()
Create a channel helper in a default working state.
Make it easy to create and manage PHY objects for the YANS model.
void SetChannel(Ptr< YansWifiChannel > channel)
void SetDefault(std::string name, const AttributeValue &value)
Definition config.cc:883
void Connect(std::string path, const CallbackBase &cb)
Definition config.cc:967
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition abort.h:38
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition log.h:243
#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
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1344
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
@ WIFI_STANDARD_80211ax
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Definition log.cc:291
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
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:580
@ LOG_LEVEL_ALL
Print everything.
Definition log.h:105
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
Definition wifi-ppdu.h:38
staDevices
Definition third.py:87
ssid
Definition third.py:82
wifi
Definition third.py:84
wifiApNode
Definition third.py:75
mobility
Definition third.py:92
wifiStaNodes
Definition third.py:73
bool verbose
std::ofstream throughput
Time g_lastTx
Time at which last TX packet is generated.
void TxCallback(Ptr< ListErrorModel > rxErrorModel, Ptr< RandomVariableStream > ranVar, double errorRate, std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
Callback when a frame is transmitted.
Time g_lastRx
Time at which last RX packet is received.
uint32_t ContextToNodeId(const std::string &context)
Parse context strings of the form "/NodeList/x/DeviceList/x/..." to extract the NodeId integer.
void RxCallback(std::string context, Ptr< const Packet > p, double snr, WifiMode mode, WifiPreamble preamble)
Callback when a frame is successfully received.
uint64_t g_txBytes
Number of generated bytes.
Time g_firstTx
Time at which first TX packet is generated.
void SocketRxPacket(std::string context, Ptr< const Packet > p, const Address &from)
void SocketTxPacket(std::string context, Ptr< const Packet > p)
Socket sent packet.