A Discrete-Event Network Simulator
API
mesh-wifi-interface-mac.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 IITP RAS
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Authors: Kirill Andreev <andreev@iitp.ru>
18  * Pavel Boyko <boyko@iitp.ru>
19  */
20 
22 
23 #include "mesh-wifi-beacon.h"
24 
25 #include "ns3/boolean.h"
26 #include "ns3/channel-access-manager.h"
27 #include "ns3/double.h"
28 #include "ns3/log.h"
29 #include "ns3/mac-tx-middle.h"
30 #include "ns3/pointer.h"
31 #include "ns3/qos-txop.h"
32 #include "ns3/random-variable-stream.h"
33 #include "ns3/simulator.h"
34 #include "ns3/socket.h"
35 #include "ns3/trace-source-accessor.h"
36 #include "ns3/wifi-mac-queue-scheduler.h"
37 #include "ns3/wifi-mac-queue.h"
38 #include "ns3/wifi-net-device.h"
39 #include "ns3/wifi-utils.h"
40 #include "ns3/yans-wifi-phy.h"
41 
42 namespace ns3
43 {
44 
45 NS_LOG_COMPONENT_DEFINE("MeshWifiInterfaceMac");
46 
47 NS_OBJECT_ENSURE_REGISTERED(MeshWifiInterfaceMac);
48 
49 TypeId
51 {
52  static TypeId tid =
53  TypeId("ns3::MeshWifiInterfaceMac")
54  .SetParent<WifiMac>()
55  .SetGroupName("Mesh")
56  .AddConstructor<MeshWifiInterfaceMac>()
57  .AddAttribute("BeaconInterval",
58  "Beacon Interval",
59  TimeValue(Seconds(0.5)),
60 
63  .AddAttribute("RandomStart",
64  "Window when beacon generating starts (uniform random) in seconds",
65  TimeValue(Seconds(0.5)),
68  .AddAttribute("BeaconGeneration",
69  "Enable/Disable Beaconing.",
70  BooleanValue(true),
74  return tid;
75 }
76 
78  : m_standard(WIFI_STANDARD_80211a)
79 {
80  NS_LOG_FUNCTION(this);
81 
82  // Let the lower layers know that we are acting as a mesh node
84  m_coefficient = CreateObject<UniformRandomVariable>();
85 }
86 
88 {
89  NS_LOG_FUNCTION(this);
90 }
91 
92 //-----------------------------------------------------------------------------
93 // WifiMac inherited
94 //-----------------------------------------------------------------------------
95 bool
97 {
98  return true;
99 }
100 
101 void
103 {
104  NS_LOG_FUNCTION(this << packet << to << from);
105  ForwardDown(packet, from, to);
106 }
107 
108 void
110 {
111  NS_LOG_FUNCTION(this << packet << to);
112  ForwardDown(packet, GetAddress(), to);
113 }
114 
115 bool
117 {
118  return true;
119 }
120 
121 void
123 {
124  NS_LOG_FUNCTION(this);
126 
127  // The approach taken here is that, from the point of view of a mesh
128  // node, the link is always up, so we immediately invoke the
129  // callback if one is set
130  linkUp();
131 }
132 
133 void
135 {
136  NS_LOG_FUNCTION(this);
137  m_plugins.clear();
139 
141 }
142 
143 void
145 {
146  NS_LOG_FUNCTION(this);
148  if (m_beaconEnable)
149  {
150  Time randomStart = Seconds(m_coefficient->GetValue());
151  // Now start sending beacons after some random delay (to avoid collisions)
155  m_tbtt = Simulator::Now() + randomStart;
156  }
157  else
158  {
159  // stop sending beacons
161  }
162 }
163 
164 int64_t
166 {
167  NS_LOG_FUNCTION(this << stream);
168  int64_t currentStream = stream;
169  m_coefficient->SetStream(currentStream++);
170  for (auto i = m_plugins.begin(); i < m_plugins.end(); i++)
171  {
172  currentStream += (*i)->AssignStreams(currentStream);
173  }
174  return (currentStream - stream);
175 }
176 
177 //-----------------------------------------------------------------------------
178 // Plugins
179 //-----------------------------------------------------------------------------
180 void
182 {
183  NS_LOG_FUNCTION(this);
184 
185  plugin->SetParent(this);
186  m_plugins.push_back(plugin);
187 }
188 
189 //-----------------------------------------------------------------------------
190 // Switch channels
191 //-----------------------------------------------------------------------------
192 uint16_t
194 {
195  NS_LOG_FUNCTION(this);
196  NS_ASSERT(GetWifiPhy()); // need PHY to set/get channel
197  return GetWifiPhy()->GetChannelNumber();
198 }
199 
200 void
202 {
203  NS_LOG_FUNCTION(this);
204  NS_ASSERT(GetWifiPhy()); // need PHY to set/get channel
217  WifiPhy::ChannelTuple{new_id, 0, GetWifiPhy()->GetPhyBand(), 0});
218  // Don't know NAV on new channel
220 }
221 
222 //-----------------------------------------------------------------------------
223 // Forward frame down
224 //-----------------------------------------------------------------------------
225 void
227 {
228  WifiMacHeader hdr;
230  hdr.SetAddr2(GetAddress());
231  hdr.SetAddr3(to);
232  hdr.SetAddr4(from);
233  hdr.SetDsFrom();
234  hdr.SetDsTo();
235  // Fill QoS fields:
237  hdr.SetQosNoEosp();
238  hdr.SetQosNoAmsdu();
239  hdr.SetQosTxopLimit(0);
240  // Address 1 is unknown here. Routing plugin is responsible to correctly set it.
241  hdr.SetAddr1(Mac48Address());
242  // Filter packet through all installed plugins
243  for (auto i = m_plugins.end() - 1; i != m_plugins.begin() - 1; i--)
244  {
245  bool drop = !((*i)->UpdateOutcomingFrame(packet, hdr, from, to));
246  if (drop)
247  {
248  return; // plugin drops frame
249  }
250  }
251  // Assert that address1 is set. Assert will fail e.g. if there is no installed routing plugin.
252  NS_ASSERT(hdr.GetAddr1() != Mac48Address());
253  // Queue frame
254  if (GetWifiRemoteStationManager()->IsBrandNew(hdr.GetAddr1()))
255  {
256  // in adhoc mode, we assume that every destination
257  // supports all the rates we support.
258  for (const auto& mode : GetWifiPhy()->GetModeList())
259  {
260  GetWifiRemoteStationManager()->AddSupportedMode(hdr.GetAddr1(), mode);
261  }
262  GetWifiRemoteStationManager()->RecordDisassociated(hdr.GetAddr1());
263  }
264  // Classify: application may have set a tag, which is removed here
265  AcIndex ac;
266  SocketPriorityTag tag;
267  if (packet->RemovePacketTag(tag))
268  {
269  hdr.SetQosTid(tag.GetPriority());
270  ac = QosUtilsMapTidToAc(tag.GetPriority());
271  }
272  else
273  {
274  // No tag found; set to best effort
275  ac = AC_BE;
276  hdr.SetQosTid(0);
277  }
279  m_stats.sentBytes += packet->GetSize();
280  NS_ASSERT(GetQosTxop(ac) != nullptr);
281  GetQosTxop(ac)->Queue(packet, hdr);
282 }
283 
284 void
286 {
287  // Filter management frames:
288  WifiMacHeader header = hdr;
289  for (auto i = m_plugins.end() - 1; i != m_plugins.begin() - 1; i--)
290  {
291  bool drop = !((*i)->UpdateOutcomingFrame(packet, header, Mac48Address(), Mac48Address()));
292  if (drop)
293  {
294  return; // plugin drops frame
295  }
296  }
298  m_stats.sentBytes += packet->GetSize();
299  if ((GetQosTxop(AC_VO) == nullptr) || (GetQosTxop(AC_BK) == nullptr))
300  {
301  NS_FATAL_ERROR("Voice or Background queue is not set up!");
302  }
303  /*
304  * When we send a management frame - it is better to enqueue it to
305  * priority queue. But when we send a broadcast management frame,
306  * like PREQ, little MinCw value may cause collisions during
307  * retransmissions (two neighbor stations may choose the same window
308  * size, and two packets will be collided). So, broadcast management
309  * frames go to BK queue.
310  */
311  if (hdr.GetAddr1() != Mac48Address::GetBroadcast())
312  {
313  GetQosTxop(AC_VO)->Queue(packet, header);
314  }
315  else
316  {
317  GetQosTxop(AC_BK)->Queue(packet, header);
318  }
319 }
320 
323 {
324  // set the set of supported rates and make sure that we indicate
325  // the Basic Rate set in this set of supported rates.
326  AllSupportedRates rates;
327  for (const auto& mode : GetWifiPhy()->GetModeList())
328  {
329  uint16_t gi = ConvertGuardIntervalToNanoSeconds(mode, GetWifiPhy()->GetDevice());
330  rates.AddSupportedRate(mode.GetDataRate(GetWifiPhy()->GetChannelWidth(), gi, 1));
331  }
332  // set the basic rates
333  for (uint32_t j = 0; j < GetWifiRemoteStationManager()->GetNBasicModes(); j++)
334  {
335  WifiMode mode = GetWifiRemoteStationManager()->GetBasicMode(j);
336  uint16_t gi = ConvertGuardIntervalToNanoSeconds(mode, GetWifiPhy()->GetDevice());
337  rates.SetBasicRate(mode.GetDataRate(GetWifiPhy()->GetChannelWidth(), gi, 1));
338  }
339  return rates;
340 }
341 
342 bool
344 {
345  for (uint32_t i = 0; i < GetWifiRemoteStationManager()->GetNBasicModes(); i++)
346  {
347  WifiMode mode = GetWifiRemoteStationManager()->GetBasicMode(i);
348  uint16_t gi = ConvertGuardIntervalToNanoSeconds(mode, GetWifiPhy()->GetDevice());
349  if (!rates.IsSupportedRate(mode.GetDataRate(GetWifiPhy()->GetChannelWidth(), gi, 1)))
350  {
351  return false;
352  }
353  }
354  return true;
355 }
356 
357 //-----------------------------------------------------------------------------
358 // Beacons
359 //-----------------------------------------------------------------------------
360 void
362 {
363  NS_LOG_FUNCTION(this << interval);
364  m_randomStart = interval;
365 }
366 
367 void
369 {
370  NS_LOG_FUNCTION(this << interval);
371  m_beaconInterval = interval;
372 }
373 
374 Time
376 {
377  return m_beaconInterval;
378 }
379 
380 void
382 {
383  NS_LOG_FUNCTION(this << enable);
384  m_beaconEnable = enable;
385 }
386 
387 bool
389 {
390  return m_beaconSendEvent.IsRunning();
391 }
392 
393 Time
395 {
396  return m_tbtt;
397 }
398 
399 void
401 {
402  // User of ShiftTbtt () must take care don't shift it to the past
403  NS_ASSERT(GetTbtt() + shift > Simulator::Now());
404 
405  m_tbtt += shift;
406  // Shift scheduled event
410 }
411 
412 void
414 {
418 }
419 
420 void
422 {
423  NS_LOG_FUNCTION(this);
424  NS_LOG_DEBUG(GetAddress() << " is sending beacon");
425 
427 
428  // Form & send beacon
430 
431  // Ask all plugins to add their specific information elements to beacon
432  for (auto i = m_plugins.begin(); i != m_plugins.end(); ++i)
433  {
434  (*i)->UpdateBeacon(beacon);
435  }
437 
439 }
440 
441 void
443 {
444  const WifiMacHeader* hdr = &mpdu->GetHeader();
445  Ptr<Packet> packet = mpdu->GetPacket()->Copy();
446  // Process beacon
447  if ((hdr->GetAddr1() != GetAddress()) && (hdr->GetAddr1() != Mac48Address::GetBroadcast()))
448  {
449  return;
450  }
451  if (hdr->IsBeacon())
452  {
454  MgtBeaconHeader beacon_hdr;
455 
456  packet->PeekHeader(beacon_hdr);
457 
458  NS_LOG_DEBUG("Beacon received from " << hdr->GetAddr2() << " I am " << GetAddress()
459  << " at " << Simulator::Now().GetMicroSeconds()
460  << " microseconds");
461 
462  // update supported rates
463  if (beacon_hdr.Get<Ssid>()->IsEqual(GetSsid()))
464  {
465  NS_ASSERT(beacon_hdr.Get<SupportedRates>());
466  auto rates = AllSupportedRates{*beacon_hdr.Get<SupportedRates>(),
467  beacon_hdr.Get<ExtendedSupportedRatesIE>()};
468 
469  for (const auto& mode : GetWifiPhy()->GetModeList())
470  {
471  uint16_t gi = ConvertGuardIntervalToNanoSeconds(mode, GetWifiPhy()->GetDevice());
472  uint64_t rate = mode.GetDataRate(GetWifiPhy()->GetChannelWidth(), gi, 1);
473  if (rates.IsSupportedRate(rate))
474  {
475  GetWifiRemoteStationManager()->AddSupportedMode(hdr->GetAddr2(), mode);
476  if (rates.IsBasicRate(rate))
477  {
478  GetWifiRemoteStationManager()->AddBasicMode(mode);
479  }
480  }
481  }
482  }
483  }
484  else
485  {
486  m_stats.recvBytes += packet->GetSize();
488  }
489  // Filter frame through all installed plugins
490  for (auto i = m_plugins.begin(); i != m_plugins.end(); ++i)
491  {
492  bool drop = !((*i)->Receive(packet, *hdr));
493  if (drop)
494  {
495  return; // plugin drops frame
496  }
497  }
498  // Check if QoS tag exists and add it:
499  if (hdr->IsQosData())
500  {
501  SocketPriorityTag priorityTag;
502  priorityTag.SetPriority(hdr->GetQosTid());
503  packet->ReplacePacketTag(priorityTag);
504  }
505  // Forward data up
506  if (hdr->IsData())
507  {
508  ForwardUp(packet, hdr->GetAddr4(), hdr->GetAddr3());
509  }
510 
511  // We don't bother invoking WifiMac::Receive() here, because
512  // we've explicitly handled all the frames we care about. This is in
513  // contrast to most classes which derive from WifiMac.
514 }
515 
516 uint32_t
518 {
519  uint32_t metric = 1;
520  if (!m_linkMetricCallback.IsNull())
521  {
522  metric = m_linkMetricCallback(peerAddress, this);
523  }
524  return metric;
525 }
526 
527 void
530 {
532 }
533 
534 void
536 {
537  m_mpAddress = a;
538 }
539 
542 {
543  return m_mpAddress;
544 }
545 
546 // Statistics:
548  : recvBeacons(0),
549  sentFrames(0),
550  sentBytes(0),
551  recvFrames(0),
552  recvBytes(0)
553 {
554 }
555 
556 void
558 {
559  os << "<Statistics "
561  "rxBeacons=\""
562  << recvBeacons
563  << "\" "
564  "txFrames=\""
565  << sentFrames
566  << "\" "
567  "txBytes=\""
568  << sentBytes
569  << "\" "
570  "rxFrames=\""
571  << recvFrames
572  << "\" "
573  "rxBytes=\""
574  << recvBytes << "\"/>" << std::endl;
575 }
576 
577 void
578 MeshWifiInterfaceMac::Report(std::ostream& os) const
579 {
580  os << "<Interface "
581  "BeaconInterval=\""
583  << "\" "
584  "Channel=\""
586  << "\" "
587  "Address = \""
588  << GetAddress() << "\">" << std::endl;
589  m_stats.Print(os);
590  os << "</Interface>" << std::endl;
591 }
592 
593 void
595 {
596  m_stats = Statistics();
597 }
598 
599 void
601 {
603  WifiMac::ConfigureStandard(standard);
604  m_standard = standard;
605 }
606 
607 void
608 MeshWifiInterfaceMac::ConfigureContentionWindow(uint32_t cwMin, uint32_t cwMax)
609 {
611  // We use the single DCF provided by WifiMac for the purpose of
612  // Beacon transmission. For this we need to reconfigure the channel
613  // access parameters slightly, and do so here.
614  m_txop = CreateObject<Txop>();
615  m_txop->SetWifiMac(this);
618  m_txop->SetMinCw(0);
619  m_txop->SetMaxCw(0);
620  m_txop->SetAifsn(1);
621  m_scheduler->SetWifiMac(this);
622 }
623 } // namespace ns3
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:55
bool IsRunning() const
This method is syntactic sugar for !IsExpired().
Definition: event-id.cc:76
The Extended Supported Rates Information Element.
an EUI-48 address
Definition: mac48-address.h:46
static Mac48Address GetBroadcast()
Beacon is beacon header + list of arbitrary information elements.
WifiMacHeader CreateHeader(Mac48Address address, Mac48Address mpAddress)
Create Wifi header for beacon frame.
Ptr< Packet > CreatePacket()
Create frame = { beacon header + all information elements sorted by ElementId () }.
Basic MAC of mesh point Wi-Fi interface.
bool SupportsSendFrom() const override
void ForwardDown(Ptr< Packet > packet, Mac48Address from, Mac48Address to)
Send frame.
Time m_beaconInterval
Beaconing interval.
Mac48Address m_mpAddress
Mesh point address.
void SetBeaconInterval(Time interval)
Set interval between two successive beacons.
void SwitchFrequencyChannel(uint16_t new_id)
Switch frequency channel.
void ShiftTbtt(Time shift)
Shift TBTT.
Time GetTbtt() const
Next beacon frame time.
void SetRandomStartDelay(Time interval)
Set maximum initial random delay before first beacon.
bool CanForwardPacketsTo(Mac48Address to) const override
Return true if packets can be forwarded to the given destination, false otherwise.
void ResetStats()
Reset statistics function.
void ConfigureContentionWindow(uint32_t cwMin, uint32_t cwMax) override
void SendManagementFrame(Ptr< Packet > frame, const WifiMacHeader &hdr)
To be used by plugins sending management frames.
Callback< uint32_t, Mac48Address, Ptr< MeshWifiInterfaceMac > > m_linkMetricCallback
linkMetricCallback
EventId m_beaconSendEvent
"Timer" for the next beacon
void InstallPlugin(Ptr< MeshWifiInterfaceMacPlugin > plugin)
Install plugin.
WifiStandard m_standard
Current standard: needed to configure metric.
void ScheduleNextBeacon()
Schedule next beacon.
uint32_t GetLinkMetric(Mac48Address peerAddress)
Get the link metric.
uint16_t GetFrequencyChannel() const
Current channel Id.
void SetBeaconGeneration(bool enable)
Enable/disable beacons.
void DoInitialize() override
Initialize() implementation.
bool GetBeaconGeneration() const
Get current beaconing status.
AllSupportedRates GetSupportedRates() const
Get supported rates.
void SetMeshPointAddress(Mac48Address addr)
Set the mesh point address.
void Enqueue(Ptr< Packet > packet, Mac48Address to, Mac48Address from) override
Mac48Address GetMeshPointAddress() const
Get the mesh point address.
void Report(std::ostream &os) const
Report statistics.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Time GetBeaconInterval() const
Get beacon interval.
bool m_beaconEnable
Beaconing interval.
void SetLinkMetricCallback(Callback< uint32_t, Mac48Address, Ptr< MeshWifiInterfaceMac >> cb)
Set the link metric callback.
void Receive(Ptr< const WifiMpdu > mpdu, uint8_t linkId) override
Frame receive handler.
void SetLinkUpCallback(Callback< void > linkUp) override
Time m_randomStart
Maximum delay before first beacon.
static TypeId GetTypeId()
Get the type ID.
PluginList m_plugins
List of all installed plugins.
void ConfigureStandard(WifiStandard standard) override
Finish configuration based on the WifiStandard being provided.
bool CheckSupportedRates(AllSupportedRates rates) const
Check supported rates.
Ptr< UniformRandomVariable > m_coefficient
Add randomness to beacon generation.
Time m_tbtt
Time for the next frame.
void DoDispose() override
Real d-tor.
virtual void SetParent(Ptr< MeshWifiInterfaceMac > parent)=0
Each plugin must be installed on an interface to work.
Implement the header for management frames of type beacon.
Definition: mgt-headers.h:512
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:204
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
Definition: packet.cc:967
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:861
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:305
bool ReplacePacketTag(Tag &tag)
Replace the value of a packet tag.
Definition: packet.cc:975
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:571
static void Cancel(const EventId &id)
Set the cancel bit on this event: the event's associated function will not be invoked when it expires...
Definition: simulator.cc:285
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:208
indicates whether the socket has a priority set.
Definition: socket.h:1316
uint8_t GetPriority() const
Get the tag's priority.
Definition: socket.cc:860
void SetPriority(uint8_t priority)
Set the tag's priority.
Definition: socket.cc:854
The IEEE 802.11 SSID Information Element.
Definition: ssid.h:36
bool IsEqual(const Ssid &o) const
Check if the two SSIDs are equal.
Definition: ssid.cc:61
The Supported Rates Information Element.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:403
int64_t GetMicroSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:413
void SetMaxCw(uint32_t maxCw)
Set the maximum contention window size.
Definition: txop.cc:267
virtual void SetWifiMac(const Ptr< WifiMac > mac)
Set the wifi MAC this Txop is associated to.
Definition: txop.cc:209
void SetTxMiddle(const Ptr< MacTxMiddle > txMiddle)
Set MacTxMiddle this Txop is associated to.
Definition: txop.cc:202
void SetAifsn(uint8_t aifsn)
Set the number of slots that make up an AIFS.
Definition: txop.cc:365
void SetMinCw(uint32_t minCw)
Set the minimum contention window size.
Definition: txop.cc:237
virtual void Queue(Ptr< Packet > packet, const WifiMacHeader &hdr)
Definition: txop.cc:523
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:931
double GetValue(double min, double max)
Get the next random value drawn from the distribution.
Implements the IEEE 802.11 MAC header.
uint8_t GetQosTid() const
Return the Traffic ID of a QoS header.
void SetQosAckPolicy(QosAckPolicy policy)
Set the QoS Ack policy in the QoS control field.
Mac48Address GetAddr3() const
Return the address in the Address 3 field.
Mac48Address GetAddr4() const
Return the address in the Address 4 field.
bool IsBeacon() const
Return true if the header is a Beacon header.
Mac48Address GetAddr1() const
Return the address in the Address 1 field.
void SetQosTxopLimit(uint8_t txop)
Set TXOP limit in the QoS control field.
void SetAddr1(Mac48Address address)
Fill the Address 1 field with the given address.
void SetQosNoAmsdu()
Set that A-MSDU is not present.
virtual void SetType(WifiMacType type, bool resetToDsFromDs=true)
Set Type/Subtype values with the correct values depending on the given type.
void SetAddr4(Mac48Address address)
Fill the Address 4 field with the given address.
Mac48Address GetAddr2() const
Return the address in the Address 2 field.
void SetQosTid(uint8_t tid)
Set the TID for the QoS header.
bool IsData() const
Return true if the Type is DATA.
void SetQosNoEosp()
Un-set the end of service period (EOSP) bit in the QoS control field.
void SetDsFrom()
Set the From DS bit in the Frame Control field.
void SetDsTo()
Set the To DS bit in the Frame Control field.
void SetAddr2(Mac48Address address)
Fill the Address 2 field with the given address.
bool IsQosData() const
Return true if the Type is DATA and Subtype is one of the possible values for QoS Data.
void SetAddr3(Mac48Address address)
Fill the Address 3 field with the given address.
base class for all MAC-level wifi objects.
Definition: wifi-mac.h:96
bool GetQosSupported() const
Return whether the device supports QoS.
Definition: wifi-mac.cc:1222
Ptr< Txop > m_txop
TXOP used for transmission of frames to non-QoS peers.
Definition: wifi-mac.h:894
Ptr< WifiMacQueueScheduler > m_scheduler
wifi MAC queue scheduler
Definition: wifi-mac.h:895
virtual void ConfigureStandard(WifiStandard standard)
Definition: wifi-mac.cc:748
Ssid GetSsid() const
Definition: wifi-mac.cc:465
void SetTypeOfStation(TypeOfStation type)
This method is invoked by a subclass to specify what type of station it is implementing.
Definition: wifi-mac.cc:415
Ptr< WifiPhy > GetWifiPhy(uint8_t linkId=SINGLE_LINK_OP_ID) const
Definition: wifi-mac.cc:1171
Ptr< MacTxMiddle > m_txMiddle
TX middle (aggregation etc.)
Definition: wifi-mac.h:893
Ptr< WifiNetDevice > GetDevice() const
Return the device this PHY is associated with.
Definition: wifi-mac.cc:439
virtual void SetLinkUpCallback(Callback< void > linkUp)
Definition: wifi-mac.cc:1291
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(uint8_t linkId=0) const
Definition: wifi-mac.cc:906
void ForwardUp(Ptr< const Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet up to the device.
Definition: wifi-mac.cc:1490
virtual void ConfigureContentionWindow(uint32_t cwMin, uint32_t cwMax)
Definition: wifi-mac.cc:646
Mac48Address GetAddress() const
Definition: wifi-mac.cc:452
LinkEntity & GetLink(uint8_t linkId) const
Get a reference to the link associated with the given ID.
Definition: wifi-mac.cc:924
Ptr< QosTxop > GetQosTxop(AcIndex ac) const
Accessor for a specified EDCA object.
Definition: wifi-mac.cc:499
void DoDispose() override
Destructor implementation.
Definition: wifi-mac.cc:373
represent a single transmission mode
Definition: wifi-mode.h:51
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:122
void SetOperatingChannel(const ChannelTuple &channelTuple)
If the standard for this object has not been set yet, store the given channel settings.
Definition: wifi-phy.cc:1098
WifiPhyBand GetPhyBand() const
Get the configured Wi-Fi band.
Definition: wifi-phy.cc:1021
uint8_t GetChannelNumber() const
Return current channel number.
Definition: wifi-phy.cc:1045
std::tuple< uint8_t, uint16_t, WifiPhyBand, uint8_t > ChannelTuple
Tuple identifying an operating channel.
Definition: wifi-phy.h:891
std::list< WifiMode > GetModeList() const
The WifiPhy::GetModeList() method is used (e.g., by a WifiRemoteStationManager) to determine the set ...
Definition: wifi-phy.cc:1954
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:179
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
Definition: abort.h:76
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
WifiStandard
Identifies the IEEE 802.11 specifications that a Wifi device can be configured to use.
AcIndex QosUtilsMapTidToAc(uint8_t tid)
Maps TID (Traffic ID) to Access classes.
Definition: qos-utils.cc:134
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:73
@ MESH
Definition: wifi-mac.h:68
@ WIFI_STANDARD_80211a
@ AC_BE
Best Effort.
Definition: qos-utils.h:75
@ AC_VO
Voice.
Definition: qos-utils.h:81
@ AC_BK
Background.
Definition: qos-utils.h:77
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeBooleanChecker()
Definition: boolean.cc:124
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Definition: nstime.h:1414
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:533
static constexpr uint8_t SINGLE_LINK_OP_ID
Link ID for single link operations (helps tracking places where correct link ID is to be used to supp...
Definition: wifi-utils.h:192
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Definition: boolean.h:86
@ WIFI_MAC_QOSDATA
uint16_t ConvertGuardIntervalToNanoSeconds(WifiMode mode, const Ptr< WifiNetDevice > device)
Convert the guard interval to nanoseconds based on the WifiMode.
Struct containing all supported rates.
void SetBasicRate(uint64_t bs)
Set the given rate to basic rates.
void AddSupportedRate(uint64_t bs)
Add the given rate to the supported rates.
bool IsSupportedRate(uint64_t bs) const
Check if the given rate is supported.
void Print(std::ostream &os) const
Print statistics.