A Discrete-Event Network Simulator
API
wifi-remote-station-manager.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2006,2007 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 
21 #include "ns3/log.h"
22 #include "ns3/boolean.h"
23 #include "ns3/uinteger.h"
24 #include "ns3/enum.h"
25 #include "ns3/simulator.h"
27 #include "wifi-phy.h"
28 #include "wifi-mac.h"
29 #include "wifi-mac-header.h"
30 #include "wifi-mac-trailer.h"
31 #include "ht-configuration.h"
32 #include "vht-configuration.h"
33 #include "he-configuration.h"
34 #include "wifi-net-device.h"
35 
36 namespace ns3 {
37 
38 NS_LOG_COMPONENT_DEFINE ("WifiRemoteStationManager");
39 
40 NS_OBJECT_ENSURE_REGISTERED (WifiRemoteStationManager);
41 
42 TypeId
44 {
45  static TypeId tid = TypeId ("ns3::WifiRemoteStationManager")
46  .SetParent<Object> ()
47  .SetGroupName ("Wifi")
48  .AddAttribute ("MaxSsrc",
49  "The maximum number of retransmission attempts for any packet with size <= RtsCtsThreshold. "
50  "This value will not have any effect on some rate control algorithms.",
51  UintegerValue (7),
53  MakeUintegerChecker<uint32_t> ())
54  .AddAttribute ("MaxSlrc",
55  "The maximum number of retransmission attempts for any packet with size > RtsCtsThreshold. "
56  "This value will not have any effect on some rate control algorithms.",
57  UintegerValue (4),
59  MakeUintegerChecker<uint32_t> ())
60  .AddAttribute ("RtsCtsThreshold",
61  "If the size of the PSDU is bigger than this value, we use an RTS/CTS handshake before sending the data frame."
62  "This value will not have any effect on some rate control algorithms.",
63  UintegerValue (65535),
65  MakeUintegerChecker<uint32_t> ())
66  .AddAttribute ("FragmentationThreshold",
67  "If the size of the PSDU is bigger than this value, we fragment it such that the size of the fragments are equal or smaller. "
68  "This value does not apply when it is carried in an A-MPDU. "
69  "This value will not have any effect on some rate control algorithms.",
70  UintegerValue (65535),
73  MakeUintegerChecker<uint32_t> ())
74  .AddAttribute ("NonUnicastMode",
75  "Wifi mode used for non-unicast transmissions.",
76  WifiModeValue (),
79  .AddAttribute ("DefaultTxPowerLevel",
80  "Default power level to be used for transmissions. "
81  "This is the power level that is used by all those WifiManagers that do not implement TX power control.",
82  UintegerValue (0),
84  MakeUintegerChecker<uint8_t> ())
85  .AddAttribute ("ErpProtectionMode",
86  "Protection mode used when non-ERP STAs are connected to an ERP AP: Rts-Cts or Cts-To-Self",
91  .AddAttribute ("HtProtectionMode",
92  "Protection mode used when non-HT STAs are connected to a HT AP: Rts-Cts or Cts-To-Self",
97  .AddTraceSource ("MacTxRtsFailed",
98  "The transmission of a RTS by the MAC layer has failed",
100  "ns3::Mac48Address::TracedCallback")
101  .AddTraceSource ("MacTxDataFailed",
102  "The transmission of a data packet by the MAC layer has failed",
104  "ns3::Mac48Address::TracedCallback")
105  .AddTraceSource ("MacTxFinalRtsFailed",
106  "The transmission of a RTS has exceeded the maximum number of attempts",
108  "ns3::Mac48Address::TracedCallback")
109  .AddTraceSource ("MacTxFinalDataFailed",
110  "The transmission of a data packet has exceeded the maximum number of attempts",
112  "ns3::Mac48Address::TracedCallback")
113  ;
114  return tid;
115 }
116 
118  : m_pcfSupported (false),
119  m_useNonErpProtection (false),
120  m_useNonHtProtection (false),
121  m_useGreenfieldProtection (false),
122  m_shortPreambleEnabled (false),
123  m_shortSlotTimeEnabled (false)
124 {
125  NS_LOG_FUNCTION (this);
126 }
127 
129 {
130  NS_LOG_FUNCTION (this);
131 }
132 
133 void
135 {
136  NS_LOG_FUNCTION (this);
137  Reset ();
138 }
139 
140 void
142 {
143  NS_LOG_FUNCTION (this << phy);
144  //We need to track our PHY because it is the object that knows the
145  //full set of transmit rates that are supported. We need to know
146  //this in order to find the relevant mandatory rates when choosing a
147  //transmit rate for automatic control responses like
148  //acknowledgments.
149  m_wifiPhy = phy;
150  m_defaultTxMode = phy->GetMode (0);
152  if (GetHtSupported ())
153  {
154  m_defaultTxMcs = phy->GetMcs (0);
155  }
156  Reset ();
157 }
158 
159 void
161 {
162  NS_LOG_FUNCTION (this << mac);
163  //We need to track our MAC because it is the object that knows the
164  //full set of interframe spaces.
165  m_wifiMac = mac;
166  Reset ();
167 }
168 
169 void
171 {
172  NS_LOG_FUNCTION (this << maxSsrc);
173  m_maxSsrc = maxSsrc;
174 }
175 
176 void
178 {
179  NS_LOG_FUNCTION (this << maxSlrc);
180  m_maxSlrc = maxSlrc;
181 }
182 
183 void
185 {
186  NS_LOG_FUNCTION (this << threshold);
187  m_rtsCtsThreshold = threshold;
188 }
189 
190 void
192 {
193  NS_LOG_FUNCTION (this << threshold);
194  DoSetFragmentationThreshold (threshold);
195 }
196 
197 void
199 {
200  NS_LOG_FUNCTION (this << enable);
201  m_shortPreambleEnabled = enable;
202 }
203 
204 void
206 {
207  NS_LOG_FUNCTION (this << enable);
208  m_shortSlotTimeEnabled = enable;
209 }
210 
211 bool
213 {
214  return m_shortSlotTimeEnabled;
215 }
216 
217 bool
219 {
220  return m_shortPreambleEnabled;
221 }
222 
223 bool
225 {
226  Ptr<WifiNetDevice> device = DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ());
227  Ptr<HtConfiguration> htConfiguration = device->GetHtConfiguration ();
228  if (htConfiguration)
229  {
230  return true;
231  }
232  return false;
233 }
234 
235 bool
237 {
238  Ptr<WifiNetDevice> device = DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ());
239  Ptr<VhtConfiguration> vhtConfiguration = device->GetVhtConfiguration ();
240  if (vhtConfiguration)
241  {
242  return true;
243  }
244  return false;
245 }
246 
247 bool
249 {
250  Ptr<WifiNetDevice> device = DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ());
251  Ptr<HeConfiguration> heConfiguration = device->GetHeConfiguration ();
252  if (heConfiguration)
253  {
254  return true;
255  }
256  return false;
257 }
258 
259 void
261 {
262  m_pcfSupported = enable;
263 }
264 
265 bool
267 {
268  return m_pcfSupported;
269 }
270 
271 bool
273 {
274  if (GetHtSupported ())
275  {
276  Ptr<WifiNetDevice> device = DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ());
277  Ptr<HtConfiguration> htConfiguration = device->GetHtConfiguration ();
278  NS_ASSERT (htConfiguration); //If HT is supported, we should have a HT configuration attached
279  if (htConfiguration->GetGreenfieldSupported ())
280  {
281  return true;
282  }
283  }
284  return false;
285 }
286 
287 bool
289 {
290  if (GetHtSupported ())
291  {
292  Ptr<WifiNetDevice> device = DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ());
293  Ptr<HtConfiguration> htConfiguration = device->GetHtConfiguration ();
294  NS_ASSERT (htConfiguration); //If HT is supported, we should have a HT configuration attached
295  if (htConfiguration->GetShortGuardIntervalSupported ())
296  {
297  return true;
298  }
299  }
300  return false;
301 }
302 
303 uint16_t
305 {
306  uint16_t gi = 0;
307  if (GetHeSupported ())
308  {
309  Ptr<WifiNetDevice> device = DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ());
310  Ptr<HeConfiguration> heConfiguration = device->GetHeConfiguration ();
311  NS_ASSERT (heConfiguration); //If HE is supported, we should have a HE configuration attached
312  gi = static_cast<uint16_t>(heConfiguration->GetGuardInterval ().GetNanoSeconds ());
313  }
314  return gi;
315 }
316 
317 uint32_t
319 {
320  return DoGetFragmentationThreshold ();
321 }
322 
323 void
325 {
326  NS_LOG_FUNCTION (this << address << isShortPreambleSupported);
327  NS_ASSERT (!address.IsGroup ());
329  state->m_shortPreamble = isShortPreambleSupported;
330 }
331 
332 void
334 {
335  NS_LOG_FUNCTION (this << address << isShortSlotTimeSupported);
336  NS_ASSERT (!address.IsGroup ());
338  state->m_shortSlotTime = isShortSlotTimeSupported;
339 }
340 
341 void
343 {
344  NS_LOG_FUNCTION (this << address << mode);
345  NS_ASSERT (!address.IsGroup ());
347  for (WifiModeListIterator i = state->m_operationalRateSet.begin (); i != state->m_operationalRateSet.end (); i++)
348  {
349  if ((*i) == mode)
350  {
351  //already in.
352  return;
353  }
354  }
355  state->m_operationalRateSet.push_back (mode);
356 }
357 
358 void
360 {
361  NS_LOG_FUNCTION (this << address);
362  NS_ASSERT (!address.IsGroup ());
364  state->m_operationalRateSet.clear ();
365  for (uint8_t i = 0; i < m_wifiPhy->GetNModes (); i++)
366  {
367  state->m_operationalRateSet.push_back (m_wifiPhy->GetMode (i));
368  if (m_wifiPhy->GetMode (i).IsMandatory ())
369  {
371  }
372  }
373 }
374 
375 void
377 {
378  NS_LOG_FUNCTION (this << address);
379  NS_ASSERT (!address.IsGroup ());
381  state->m_operationalMcsSet.clear ();
382  for (uint8_t i = 0; i < m_wifiPhy->GetNMcs (); i++)
383  {
384  state->m_operationalMcsSet.push_back (m_wifiPhy->GetMcs (i));
385  }
386 }
387 
388 void
390 {
391  NS_LOG_FUNCTION (this << address);
392  NS_ASSERT (!address.IsGroup ());
394  state->m_operationalMcsSet.clear ();
395 }
396 
397 void
399 {
400  NS_LOG_FUNCTION (this << address << mcs);
401  NS_ASSERT (!address.IsGroup ());
403  for (WifiModeListIterator i = state->m_operationalMcsSet.begin (); i != state->m_operationalMcsSet.end (); i++)
404  {
405  if ((*i) == mcs)
406  {
407  //already in.
408  return;
409  }
410  }
411  state->m_operationalMcsSet.push_back (mcs);
412 }
413 
414 bool
416 {
418 }
419 
420 bool
422 {
424 }
425 
426 bool
428 {
430 }
431 
432 bool
434 {
435  if (address.IsGroup ())
436  {
437  return false;
438  }
440 }
441 
442 bool
444 {
445  if (address.IsGroup ())
446  {
447  return true;
448  }
450 }
451 
452 bool
454 {
455  if (address.IsGroup ())
456  {
457  return false;
458  }
460 }
461 
462 void
464 {
465  NS_ASSERT (!address.IsGroup ());
467 }
468 
469 void
471 {
472  NS_ASSERT (!address.IsGroup ());
474 }
475 
476 void
478 {
479  NS_ASSERT (!address.IsGroup ());
481 }
482 
483 void
485 {
486  NS_ASSERT (!address.IsGroup ());
488 }
489 
492 {
493  NS_LOG_FUNCTION (this << header);
494  Mac48Address address = header.GetAddr1 ();
495  if (!header.IsMgt () && address.IsGroup ())
496  {
497  WifiMode mode = GetNonUnicastMode ();
498  WifiTxVector v;
499  v.SetMode (mode);
503  v.SetGuardInterval (ConvertGuardIntervalToNanoSeconds (mode, DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ())));
504  v.SetNTx (1);
505  v.SetNss (1);
506  v.SetNess (0);
507  v.SetStbc (0);
508  return v;
509  }
510  WifiTxVector txVector;
511  if (header.IsMgt ())
512  {
513  //Use the lowest basic rate for management frames
514  WifiMode mgtMode;
515  if (GetNBasicModes () > 0)
516  {
517  mgtMode = GetBasicMode (0);
518  }
519  else
520  {
521  mgtMode = GetDefaultMode ();
522  }
523  txVector.SetMode (mgtMode);
527  txVector.SetGuardInterval (ConvertGuardIntervalToNanoSeconds (mgtMode, DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ())));
528  }
529  else
530  {
531  txVector = DoGetDataTxVector (Lookup (address));
532  }
533  Ptr<WifiNetDevice> device = DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ());
534  Ptr<HeConfiguration> heConfiguration = device->GetHeConfiguration ();
535  if (heConfiguration)
536  {
537  UintegerValue bssColor;
538  heConfiguration->GetAttribute ("BssColor", bssColor);
539  txVector.SetBssColor (bssColor.Get ());
540  }
541  return txVector;
542 }
543 
546 {
547  WifiMode defaultMode = GetDefaultMode ();
548  WifiPreamble defaultPreamble;
549  if (defaultMode.GetModulationClass () == WIFI_MOD_CLASS_HE)
550  {
551  defaultPreamble = WIFI_PREAMBLE_HE_SU;
552  }
553  else if (defaultMode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
554  {
555  defaultPreamble = WIFI_PREAMBLE_VHT_SU;
556  }
557  else if (defaultMode.GetModulationClass () == WIFI_MOD_CLASS_HT)
558  {
559  defaultPreamble = WIFI_PREAMBLE_HT_MF;
560  }
561  else
562  {
563  defaultPreamble = WIFI_PREAMBLE_LONG;
564  }
565 
566  return WifiTxVector (defaultMode,
568  defaultPreamble,
569  ConvertGuardIntervalToNanoSeconds (defaultMode, DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ())),
572  0,
574  false,
575  false);
576 }
577 
580 {
581  NS_LOG_FUNCTION (this << address);
582  if (address.IsGroup ())
583  {
584  WifiMode mode = GetNonUnicastMode ();
585  WifiTxVector v;
586  v.SetMode (mode);
590  v.SetGuardInterval (ConvertGuardIntervalToNanoSeconds (mode, DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ())));
591  v.SetNTx (1);
592  v.SetNss (1);
593  v.SetNess (0);
594  v.SetStbc (0);
595  return v;
596  }
597  return DoGetRtsTxVector (Lookup (address));
598 }
599 
600 void
602 {
603  NS_LOG_FUNCTION (this << address << *header);
604  NS_ASSERT (!address.IsGroup ());
605  AcIndex ac = QosUtilsMapTidToAc ((header->IsQosData ()) ? header->GetQosTid () : 0);
606  m_ssrc[ac]++;
609 }
610 
611 void
613  uint32_t packetSize)
614 {
615  NS_LOG_FUNCTION (this << address << *header);
616  NS_ASSERT (!address.IsGroup ());
617  AcIndex ac = QosUtilsMapTidToAc ((header->IsQosData ()) ? header->GetQosTid () : 0);
618  bool longMpdu = (packetSize + header->GetSize () + WIFI_MAC_FCS_LENGTH) > m_rtsCtsThreshold;
619  if (longMpdu)
620  {
621  m_slrc[ac]++;
622  }
623  else
624  {
625  m_ssrc[ac]++;
626  }
629 }
630 
631 void
633  double ctsSnr, WifiMode ctsMode, double rtsSnr)
634 {
635  NS_LOG_FUNCTION (this << address << *header << ctsSnr << ctsMode << rtsSnr);
636  NS_ASSERT (!address.IsGroup ());
637  WifiRemoteStation *station = Lookup (address);
638  AcIndex ac = QosUtilsMapTidToAc ((header->IsQosData ()) ? header->GetQosTid () : 0);
639  station->m_state->m_info.NotifyTxSuccess (m_ssrc[ac]);
640  m_ssrc[ac] = 0;
641  DoReportRtsOk (station, ctsSnr, ctsMode, rtsSnr);
642 }
643 
644 void
646  double ackSnr, WifiMode ackMode, double dataSnr,
647  WifiTxVector dataTxVector, uint32_t packetSize)
648 {
649  NS_LOG_FUNCTION (this << address << *header << ackSnr << ackMode << dataSnr << dataTxVector << packetSize);
650  NS_ASSERT (!address.IsGroup ());
651  WifiRemoteStation *station = Lookup (address);
652  AcIndex ac = QosUtilsMapTidToAc ((header->IsQosData ()) ? header->GetQosTid () : 0);
653  bool longMpdu = (packetSize + header->GetSize () + WIFI_MAC_FCS_LENGTH) > m_rtsCtsThreshold;
654  if (longMpdu)
655  {
656  station->m_state->m_info.NotifyTxSuccess (m_slrc[ac]);
657  m_slrc[ac] = 0;
658  }
659  else
660  {
661  station->m_state->m_info.NotifyTxSuccess (m_ssrc[ac]);
662  m_ssrc[ac] = 0;
663  }
664  DoReportDataOk (station, ackSnr, ackMode, dataSnr, dataTxVector.GetChannelWidth (), dataTxVector.GetNss ());
665 }
666 
667 void
669 {
670  NS_LOG_FUNCTION (this << address << *header);
671  NS_ASSERT (!address.IsGroup ());
672  WifiRemoteStation *station = Lookup (address);
673  AcIndex ac = QosUtilsMapTidToAc ((header->IsQosData ()) ? header->GetQosTid () : 0);
674  station->m_state->m_info.NotifyTxFailed ();
675  m_ssrc[ac] = 0;
677  DoReportFinalRtsFailed (station);
678 }
679 
680 void
682  uint32_t packetSize)
683 {
684  NS_LOG_FUNCTION (this << address << *header);
685  NS_ASSERT (!address.IsGroup ());
686  WifiRemoteStation *station = Lookup (address);
687  AcIndex ac = QosUtilsMapTidToAc ((header->IsQosData ()) ? header->GetQosTid () : 0);
688  station->m_state->m_info.NotifyTxFailed ();
689  bool longMpdu = (packetSize + header->GetSize () + WIFI_MAC_FCS_LENGTH) > m_rtsCtsThreshold;
690  if (longMpdu)
691  {
692  m_slrc[ac] = 0;
693  }
694  else
695  {
696  m_ssrc[ac] = 0;
697  }
699  DoReportFinalDataFailed (station);
700 }
701 
702 void
704 {
705  NS_LOG_FUNCTION (this << address << rxSnr << txMode);
706  if (address.IsGroup ())
707  {
708  return;
709  }
710  DoReportRxOk (Lookup (address), rxSnr, txMode);
711 }
712 
713 void
715  uint8_t nSuccessfulMpdus, uint8_t nFailedMpdus,
716  double rxSnr, double dataSnr, WifiTxVector dataTxVector)
717 {
718  NS_LOG_FUNCTION (this << address << +nSuccessfulMpdus << +nFailedMpdus << rxSnr << dataSnr << dataTxVector);
719  NS_ASSERT (!address.IsGroup ());
720  for (uint8_t i = 0; i < nFailedMpdus; i++)
721  {
723  }
724  DoReportAmpduTxStatus (Lookup (address), nSuccessfulMpdus, nFailedMpdus, rxSnr, dataSnr, dataTxVector.GetChannelWidth (), dataTxVector.GetNss ());
725 }
726 
727 bool
728 WifiRemoteStationManager::NeedRts (const WifiMacHeader &header, uint32_t size)
729 {
730  NS_LOG_FUNCTION (this << header << size);
731  Mac48Address address = header.GetAddr1 ();
732  WifiTxVector txVector = GetDataTxVector (header);
733  WifiMode mode = txVector.GetMode ();
734  if (address.IsGroup ())
735  {
736  return false;
737  }
740  || (mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
741  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
742  || (mode.GetModulationClass () == WIFI_MOD_CLASS_HE))
744  {
745  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedRTS returning true to protect non-ERP stations");
746  return true;
747  }
748  else if (m_htProtectionMode == RTS_CTS
749  && ((mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
750  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT))
753  {
754  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedRTS returning true to protect non-HT stations");
755  return true;
756  }
757  bool normally = (size > m_rtsCtsThreshold);
758  return DoNeedRts (Lookup (address), size, normally);
759 }
760 
761 bool
763 {
764  WifiMode mode = txVector.GetMode ();
765  NS_LOG_FUNCTION (this << mode);
768  || (mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
769  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
770  || (mode.GetModulationClass () == WIFI_MOD_CLASS_HE))
772  {
773  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true to protect non-ERP stations");
774  return true;
775  }
776  else if (m_htProtectionMode == CTS_TO_SELF
777  && ((mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
778  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT))
781  {
782  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true to protect non-HT stations");
783  return true;
784  }
785  else if (!m_useNonErpProtection)
786  {
787  //search for the BSS Basic Rate set, if the used mode is in the basic set then there is no need for CTS To Self
788  for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
789  {
790  if (mode == *i)
791  {
792  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
793  return false;
794  }
795  }
796  if (GetHtSupported ())
797  {
798  //search for the BSS Basic MCS set, if the used mode is in the basic set then there is no need for CTS To Self
799  for (WifiModeListIterator i = m_bssBasicMcsSet.begin (); i != m_bssBasicMcsSet.end (); i++)
800  {
801  if (mode == *i)
802  {
803  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
804  return false;
805  }
806  }
807  }
808  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true");
809  return true;
810  }
811  return false;
812 }
813 
814 void
816 {
817  NS_LOG_FUNCTION (this << enable);
818  m_useNonErpProtection = enable;
819 }
820 
821 bool
823 {
824  return m_useNonErpProtection;
825 }
826 
827 void
829 {
830  NS_LOG_FUNCTION (this << enable);
831  m_useNonHtProtection = enable;
832 }
833 
834 bool
836 {
837  return m_useNonHtProtection;
838 }
839 
840 void
842 {
843  NS_LOG_FUNCTION (this << enable);
844  m_useGreenfieldProtection = enable;
845 }
846 
847 bool
849 {
851 }
852 
853 bool
855  Ptr<const Packet> packet)
856 {
857  NS_LOG_FUNCTION (this << address << packet << *header);
858  NS_ASSERT (!address.IsGroup ());
859  AcIndex ac = QosUtilsMapTidToAc ((header->IsQosData ()) ? header->GetQosTid () : 0);
860  bool longMpdu = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > m_rtsCtsThreshold;
861  uint32_t retryCount, maxRetryCount;
862  if (longMpdu)
863  {
864  retryCount = m_slrc[ac];
865  maxRetryCount = m_maxSlrc;
866  }
867  else
868  {
869  retryCount = m_ssrc[ac];
870  maxRetryCount = m_maxSsrc;
871  }
872  bool normally = retryCount < maxRetryCount;
873  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedRetransmission count: " << retryCount << " result: " << std::boolalpha << normally);
874  return DoNeedRetransmission (Lookup (address), packet, normally);
875 }
876 
877 bool
879  Ptr<const Packet> packet)
880 {
881  NS_LOG_FUNCTION (this << address << packet << *header);
882  if (address.IsGroup ())
883  {
884  return false;
885  }
886  bool normally = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > GetFragmentationThreshold ();
887  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedFragmentation result: " << std::boolalpha << normally);
888  return DoNeedFragmentation (Lookup (address), packet, normally);
889 }
890 
891 void
893 {
894  NS_LOG_FUNCTION (this << threshold);
895  if (threshold < 256)
896  {
897  /*
898  * ASN.1 encoding of the MAC and PHY MIB (256 ... 8000)
899  */
900  NS_LOG_WARN ("Fragmentation threshold should be larger than 256. Setting to 256.");
902  }
903  else
904  {
905  /*
906  * The length of each fragment shall be an even number of octets, except for the last fragment if an MSDU or
907  * MMPDU, which may be either an even or an odd number of octets.
908  */
909  if (threshold % 2 != 0)
910  {
911  NS_LOG_WARN ("Fragmentation threshold should be an even number. Setting to " << threshold - 1);
912  m_nextFragmentationThreshold = threshold - 1;
913  }
914  else
915  {
916  m_nextFragmentationThreshold = threshold;
917  }
918  }
919 }
920 
921 void
923 {
925 }
926 
927 uint32_t
929 {
931 }
932 
933 uint32_t
935 {
936  NS_LOG_FUNCTION (this << *header << packet);
937  //The number of bytes a fragment can support is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
938  uint32_t nFragments = (packet->GetSize () / (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
939 
940  //If the size of the last fragment is not 0.
941  if ((packet->GetSize () % (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH)) > 0)
942  {
943  nFragments++;
944  }
945  NS_LOG_DEBUG ("WifiRemoteStationManager::GetNFragments returning " << nFragments);
946  return nFragments;
947 }
948 
949 uint32_t
951  Ptr<const Packet> packet, uint32_t fragmentNumber)
952 {
953  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
954  NS_ASSERT (!address.IsGroup ());
955  uint32_t nFragment = GetNFragments (header, packet);
956  if (fragmentNumber >= nFragment)
957  {
958  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning 0");
959  return 0;
960  }
961  //Last fragment
962  if (fragmentNumber == nFragment - 1)
963  {
964  uint32_t lastFragmentSize = packet->GetSize () - (fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
965  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << lastFragmentSize);
966  return lastFragmentSize;
967  }
968  //All fragments but the last, the number of bytes is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
969  else
970  {
971  uint32_t fragmentSize = GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH;
972  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << fragmentSize);
973  return fragmentSize;
974  }
975 }
976 
977 uint32_t
979  Ptr<const Packet> packet, uint32_t fragmentNumber)
980 {
981  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
982  NS_ASSERT (!address.IsGroup ());
983  NS_ASSERT (fragmentNumber < GetNFragments (header, packet));
984  uint32_t fragmentOffset = fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH);
985  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentOffset returning " << fragmentOffset);
986  return fragmentOffset;
987 }
988 
989 bool
991  Ptr<const Packet> packet, uint32_t fragmentNumber)
992 {
993  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
994  NS_ASSERT (!address.IsGroup ());
995  bool isLast = fragmentNumber == (GetNFragments (header, packet) - 1);
996  NS_LOG_DEBUG ("WifiRemoteStationManager::IsLastFragment returning " << std::boolalpha << isLast);
997  return isLast;
998 }
999 
1000 uint8_t
1002 {
1003  return m_defaultTxPowerLevel;
1004 }
1005 
1008 {
1010  return state->m_info;
1011 }
1012 
1015 {
1016  NS_LOG_FUNCTION (this << address);
1017  for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
1018  {
1019  if ((*i)->m_address == address)
1020  {
1021  NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning existing state");
1022  return (*i);
1023  }
1024  }
1027  state->m_address = address;
1028  state->m_operationalRateSet.push_back (GetDefaultMode ());
1029  state->m_operationalMcsSet.push_back (GetDefaultMcs ());
1030  state->m_htCapabilities = 0;
1031  state->m_vhtCapabilities = 0;
1032  state->m_heCapabilities = 0;
1034  state->m_guardInterval = GetGuardInterval ();
1035  state->m_ness = 0;
1036  state->m_aggregation = false;
1037  state->m_qosSupported = false;
1038  const_cast<WifiRemoteStationManager *> (this)->m_states.push_back (state);
1039  NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning new state");
1040  return state;
1041 }
1042 
1045 {
1046  NS_LOG_FUNCTION (this << address);
1047  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1048  {
1049  if ((*i)->m_state->m_address == address)
1050  {
1051  return (*i);
1052  }
1053  }
1055 
1056  WifiRemoteStation *station = DoCreateStation ();
1057  station->m_state = state;
1058  const_cast<WifiRemoteStationManager *> (this)->m_stations.push_back (station);
1059  return station;
1060 }
1061 
1062 void
1064 {
1065  NS_LOG_FUNCTION (this << from << qosSupported);
1066  WifiRemoteStationState *state;
1067  state = LookupState (from);
1068  state->m_qosSupported = qosSupported;
1069 }
1070 
1071 void
1073 {
1074  //Used by all stations to record HT capabilities of remote stations
1075  NS_LOG_FUNCTION (this << from << htCapabilities);
1076  WifiRemoteStationState *state;
1077  state = LookupState (from);
1078  if (htCapabilities.GetSupportedChannelWidth () == 1)
1079  {
1080  state->m_channelWidth = 40;
1081  }
1082  else
1083  {
1084  state->m_channelWidth = 20;
1085  }
1086  SetQosSupport (from, true);
1087  for (uint8_t j = 0; j < m_wifiPhy->GetNMcs (); j++)
1088  {
1089  WifiMode mcs = m_wifiPhy->GetMcs (j);
1090  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HT && htCapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1091  {
1092  AddSupportedMcs (from, mcs);
1093  }
1094  }
1095  state->m_htCapabilities = Create<const HtCapabilities> (htCapabilities);
1096 }
1097 
1098 void
1100 {
1101  //Used by all stations to record VHT capabilities of remote stations
1102  NS_LOG_FUNCTION (this << from << vhtCapabilities);
1103  WifiRemoteStationState *state;
1104  state = LookupState (from);
1105  if (vhtCapabilities.GetSupportedChannelWidthSet () == 1)
1106  {
1107  state->m_channelWidth = 160;
1108  }
1109  else
1110  {
1111  state->m_channelWidth = 80;
1112  }
1113  //This is a workaround to enable users to force a 20 or 40 MHz channel for a VHT-compliant device,
1114  //since IEEE 802.11ac standard says that 20, 40 and 80 MHz channels are mandatory.
1115  if (m_wifiPhy->GetChannelWidth () < state->m_channelWidth)
1116  {
1118  }
1119  for (uint8_t i = 1; i <= m_wifiPhy->GetMaxSupportedTxSpatialStreams (); i++)
1120  {
1121  for (uint8_t j = 0; j < m_wifiPhy->GetNMcs (); j++)
1122  {
1123  WifiMode mcs = m_wifiPhy->GetMcs (j);
1124  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtCapabilities.IsSupportedMcs (mcs.GetMcsValue (), i))
1125  {
1126  AddSupportedMcs (from, mcs);
1127  }
1128  }
1129  }
1130  state->m_vhtCapabilities = Create<const VhtCapabilities> (vhtCapabilities);
1131 }
1132 
1133 void
1135 {
1136  //Used by all stations to record HE capabilities of remote stations
1137  NS_LOG_FUNCTION (this << from << heCapabilities);
1138  WifiRemoteStationState *state;
1139  state = LookupState (from);
1141  {
1142  if (heCapabilities.GetChannelWidthSet () & 0x04)
1143  {
1144  state->m_channelWidth = 160;
1145  }
1146  else if (heCapabilities.GetChannelWidthSet () & 0x02)
1147  {
1148  state->m_channelWidth = 80;
1149  }
1150  //For other cases at 5 GHz, the supported channel width is set by the VHT capabilities
1151  }
1152  else if (m_wifiPhy->GetPhyBand () == WIFI_PHY_BAND_2_4GHZ)
1153  {
1154  if (heCapabilities.GetChannelWidthSet () & 0x01)
1155  {
1156  state->m_channelWidth = 40;
1157  }
1158  else
1159  {
1160  state->m_channelWidth = 20;
1161  }
1162  }
1163  if (heCapabilities.GetHeLtfAndGiForHePpdus () >= 2)
1164  {
1165  state->m_guardInterval = 800;
1166  }
1167  else if (heCapabilities.GetHeLtfAndGiForHePpdus () == 1)
1168  {
1169  state->m_guardInterval = 1600;
1170  }
1171  else
1172  {
1173  state->m_guardInterval = 3200;
1174  }
1175  for (uint8_t i = 1; i <= m_wifiPhy->GetMaxSupportedTxSpatialStreams (); i++)
1176  {
1177  for (uint8_t j = 0; j < m_wifiPhy->GetNMcs (); j++)
1178  {
1179  WifiMode mcs = m_wifiPhy->GetMcs (j);
1181  && heCapabilities.GetHighestNssSupported () >= i
1182  && heCapabilities.GetHighestMcsSupported () >= j)
1183  {
1184  AddSupportedMcs (from, mcs);
1185  }
1186  }
1187  }
1188  state->m_heCapabilities = Create<const HeCapabilities> (heCapabilities);
1189  SetQosSupport (from, true);
1190 }
1191 
1194 {
1195  return LookupState (from)->m_htCapabilities;
1196 }
1197 
1200 {
1201  return LookupState (from)->m_vhtCapabilities;
1202 }
1203 
1206 {
1207  return LookupState (from)->m_heCapabilities;
1208 }
1209 
1210 bool
1212 {
1214 
1215  if (!htCapabilities)
1216  {
1217  return false;
1218  }
1219  return htCapabilities->GetGreenfield ();
1220 }
1221 
1222 WifiMode
1224 {
1225  return m_defaultTxMode;
1226 }
1227 
1228 WifiMode
1230 {
1231  return m_defaultTxMcs;
1232 }
1233 
1234 void
1236 {
1237  NS_LOG_FUNCTION (this);
1238  for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
1239  {
1240  delete (*i);
1241  }
1242  m_states.clear ();
1243  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1244  {
1245  delete (*i);
1246  }
1247  m_stations.clear ();
1248  m_bssBasicRateSet.clear ();
1249  m_bssBasicMcsSet.clear ();
1250  m_ssrc.fill (0);
1251  m_slrc.fill (0);
1252 }
1253 
1254 void
1256 {
1257  NS_LOG_FUNCTION (this << mode);
1258  if (mode.GetModulationClass () >= WIFI_MOD_CLASS_HT)
1259  {
1260  NS_FATAL_ERROR ("It is not allowed to add a HT rate in the BSSBasicRateSet!");
1261  }
1262  for (uint8_t i = 0; i < GetNBasicModes (); i++)
1263  {
1264  if (GetBasicMode (i) == mode)
1265  {
1266  return;
1267  }
1268  }
1269  m_bssBasicRateSet.push_back (mode);
1270 }
1271 
1272 uint8_t
1274 {
1275  return static_cast<uint8_t> (m_bssBasicRateSet.size ());
1276 }
1277 
1278 WifiMode
1280 {
1281  NS_ASSERT (i < GetNBasicModes ());
1282  return m_bssBasicRateSet[i];
1283 }
1284 
1285 uint32_t
1287 {
1288  uint32_t size = 0;
1289  for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
1290  {
1291  if (i->GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1292  {
1293  continue;
1294  }
1295  size++;
1296  }
1297  return size;
1298 }
1299 
1300 WifiMode
1302 {
1304  uint32_t index = 0;
1305  bool found = false;
1306  for (WifiModeListIterator j = m_bssBasicRateSet.begin (); j != m_bssBasicRateSet.end (); )
1307  {
1308  if (i == index)
1309  {
1310  found = true;
1311  }
1312  if (j->GetModulationClass () != WIFI_MOD_CLASS_ERP_OFDM)
1313  {
1314  if (found)
1315  {
1316  break;
1317  }
1318  }
1319  index++;
1320  j++;
1321  }
1322  return m_bssBasicRateSet[index];
1323 }
1324 
1325 void
1327 {
1328  NS_LOG_FUNCTION (this << +mcs.GetMcsValue ());
1329  for (uint8_t i = 0; i < GetNBasicMcs (); i++)
1330  {
1331  if (GetBasicMcs (i) == mcs)
1332  {
1333  return;
1334  }
1335  }
1336  m_bssBasicMcsSet.push_back (mcs);
1337 }
1338 
1339 uint8_t
1341 {
1342  return static_cast<uint8_t> (m_bssBasicMcsSet.size ());
1343 }
1344 
1345 WifiMode
1347 {
1348  NS_ASSERT (i < GetNBasicMcs ());
1349  return m_bssBasicMcsSet[i];
1350 }
1351 
1352 WifiMode
1354 {
1355  if (m_nonUnicastMode == WifiMode ())
1356  {
1357  if (GetNBasicModes () > 0)
1358  {
1359  return GetBasicMode (0);
1360  }
1361  else
1362  {
1363  return GetDefaultMode ();
1364  }
1365  }
1366  else
1367  {
1368  return m_nonUnicastMode;
1369  }
1370 }
1371 
1372 bool
1374  uint32_t size, bool normally)
1375 {
1376  return normally;
1377 }
1378 
1379 bool
1381  Ptr<const Packet> packet, bool normally)
1382 {
1383  return normally;
1384 }
1385 
1386 bool
1388  Ptr<const Packet> packet, bool normally)
1389 {
1390  return normally;
1391 }
1392 
1393 void
1394 WifiRemoteStationManager::DoReportAmpduTxStatus (WifiRemoteStation *station, uint8_t nSuccessfulMpdus, uint8_t nFailedMpdus, double rxSnr, double dataSnr, uint16_t dataChannelWidth, uint8_t dataNss)
1395 {
1396  NS_LOG_DEBUG ("DoReportAmpduTxStatus received but the manager does not handle A-MPDUs!");
1397 }
1398 
1399 WifiMode
1401 {
1402  NS_ASSERT (i < GetNSupported (station));
1403  return station->m_state->m_operationalRateSet[i];
1404 }
1405 
1406 WifiMode
1408 {
1409  NS_ASSERT (i < GetNMcsSupported (station));
1410  return station->m_state->m_operationalMcsSet[i];
1411 }
1412 
1413 WifiMode
1415 {
1416  NS_ASSERT (i < GetNNonErpSupported (station));
1417  //IEEE 802.11g standard defines that if the protection mechanism is enabled, RTS, CTS and CTS-To-Self
1418  //frames should select a rate in the BSSBasicRateSet that corresponds to an 802.11b basic rate.
1419  //This is a implemented here to avoid changes in every RAA, but should maybe be moved in case it breaks standard rules.
1420  uint32_t index = 0;
1421  bool found = false;
1422  for (WifiModeListIterator j = station->m_state->m_operationalRateSet.begin (); j != station->m_state->m_operationalRateSet.end (); )
1423  {
1424  if (i == index)
1425  {
1426  found = true;
1427  }
1428  if (j->GetModulationClass () != WIFI_MOD_CLASS_ERP_OFDM)
1429  {
1430  if (found)
1431  {
1432  break;
1433  }
1434  }
1435  index++;
1436  j++;
1437  }
1438  return station->m_state->m_operationalRateSet[index];
1439 }
1440 
1443 {
1444  return station->m_state->m_address;
1445 }
1446 
1447 uint16_t
1449 {
1450  return station->m_state->m_channelWidth;
1451 }
1452 
1453 bool
1455 {
1456  Ptr<const HtCapabilities> htCapabilities = station->m_state->m_htCapabilities;
1457 
1458  if (!htCapabilities)
1459  {
1460  return false;
1461  }
1462  return htCapabilities->GetShortGuardInterval20 ();
1463 }
1464 
1465 uint16_t
1467 {
1468  return station->m_state->m_guardInterval;
1469 }
1470 
1471 bool
1473 {
1474  Ptr<const HtCapabilities> htCapabilities = station->m_state->m_htCapabilities;
1475 
1476  if (!htCapabilities)
1477  {
1478  return false;
1479  }
1480  return htCapabilities->GetGreenfield ();
1481 }
1482 
1483 bool
1485 {
1486  return station->m_state->m_aggregation;
1487 }
1488 
1489 uint8_t
1491 {
1492  Ptr<const HtCapabilities> htCapabilities = station->m_state->m_htCapabilities;
1493 
1494  if (!htCapabilities)
1495  {
1496  return 1;
1497  }
1498  return htCapabilities->GetRxHighestSupportedAntennas ();
1499 }
1500 
1501 uint8_t
1503 {
1504  return station->m_state->m_ness;
1505 }
1506 
1509 {
1510  return m_wifiPhy;
1511 }
1512 
1515 {
1516  return m_wifiMac;
1517 }
1518 
1519 uint8_t
1521 {
1522  return static_cast<uint8_t> (station->m_state->m_operationalRateSet.size ());
1523 }
1524 
1525 bool
1527 {
1528  return station->m_state->m_qosSupported;
1529 }
1530 
1531 bool
1533 {
1534  return (station->m_state->m_htCapabilities != 0);
1535 }
1536 
1537 bool
1539 {
1540  return (station->m_state->m_vhtCapabilities != 0);
1541 }
1542 
1543 bool
1545 {
1546  return (station->m_state->m_heCapabilities != 0);
1547 }
1548 
1549 uint8_t
1551 {
1552  return static_cast<uint8_t> (station->m_state->m_operationalMcsSet.size ());
1553 }
1554 
1555 uint32_t
1557 {
1558  uint32_t size = 0;
1559  for (WifiModeListIterator i = station->m_state->m_operationalRateSet.begin (); i != station->m_state->m_operationalRateSet.end (); i++)
1560  {
1561  if (i->GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1562  {
1563  continue;
1564  }
1565  size++;
1566  }
1567  return size;
1568 }
1569 
1570 uint16_t
1572 {
1574 }
1575 
1576 bool
1578 {
1580 
1581  if (!htCapabilities)
1582  {
1583  return false;
1584  }
1585  return htCapabilities->GetShortGuardInterval20 ();
1586 }
1587 
1588 uint8_t
1590 {
1592 
1593  if (!htCapabilities)
1594  {
1595  return 1;
1596  }
1597  return htCapabilities->GetRxHighestSupportedAntennas ();
1598 }
1599 
1600 uint8_t
1602 {
1603  return static_cast<uint8_t> (LookupState (address)->m_operationalMcsSet.size ());
1604 }
1605 
1606 bool
1608 {
1609  return (LookupState (address)->m_htCapabilities != 0);
1610 }
1611 
1612 bool
1614 {
1615  return (LookupState (address)->m_vhtCapabilities != 0);
1616 }
1617 
1618 bool
1620 {
1621  return (LookupState (address)->m_heCapabilities != 0);
1622 }
1623 
1624 void
1626 {
1627  m_defaultTxPowerLevel = txPower;
1628 }
1629 
1630 uint8_t
1632 {
1633  return m_wifiPhy->GetNumberOfAntennas ();
1634 }
1635 
1636 uint8_t
1638 {
1640 }
1641 
1642 bool
1644 {
1646 }
1647 
1648 } //namespace ns3
std::array< uint32_t, AC_BE_NQOS > m_ssrc
short retry count per AC
uint8_t GetNMcsSupported(Mac48Address address) const
Return the number of MCS supported by the station.
bool m_useNonHtProtection
flag if protection for non-HT stations against HT transmissions is enabled
bool m_shortPreamble
Flag if short PHY preamble is supported by the remote station.
uint8_t GetChannelWidthSet(void) const
Get channel width set.
void AddSupportedMcs(Mac48Address address, WifiMode mcs)
Record the MCS index supported by the station.
uint32_t GetNFragments(const WifiMacHeader *header, Ptr< const Packet > packet)
Return the number of fragments needed for the given packet.
Ptr< WifiMac > GetMac(void) const
Return the WifiMac.
void SetDefaultTxPowerLevel(uint8_t txPower)
Set the default transmission power level.
bool GetVhtSupported(void) const
Return whether the device has VHT capability support enabled.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
uint8_t GetNSupported(const WifiRemoteStation *station) const
Return the number of modes supported by the given station.
ERP-OFDM PHY (19.5)
Definition: wifi-mode.h:54
Ptr< HeConfiguration > GetHeConfiguration(void) const
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
uint32_t m_rtsCtsThreshold
Threshold for RTS/CTS.
bool m_shortSlotTimeEnabled
flag if short slot time is enabled
enum ns3::WifiRemoteStationState::@77 m_state
State of the station.
WifiMode GetMcs(uint8_t mcs) const
The WifiPhy::GetMcs() method is used (e.g., by a WifiRemoteStationManager) to determine the set of tr...
Definition: wifi-phy.cc:4138
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
void SetChannelWidth(uint16_t channelWidth)
Sets the selected channelWidth (in MHz)
bool GetShortPreambleSupported(Mac48Address address) const
Return whether the station supports short PHY preamble or not.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:852
void ReportFinalDataFailed(Mac48Address address, const WifiMacHeader *header, uint32_t packetSize)
Should be invoked after calling ReportDataFailed if NeedRetransmission returns false.
void AddAllSupportedMcs(Mac48Address address)
Invoked in a STA or AP to store all of the MCS supported by a destination which is also supported loc...
std::array< uint32_t, AC_BE_NQOS > m_slrc
long retry count per AC
void RecordWaitAssocTxOk(Mac48Address address)
Records that we are waiting for an ACK for the association response we sent.
virtual void DoReportRtsFailed(WifiRemoteStation *station)=0
This method is a pure virtual method that must be implemented by the sub-class.
static const uint32_t packetSize
WifiMode m_nonUnicastMode
Transmission mode for non-unicast Data frames.
void SetBssColor(uint8_t color)
Set the BSS color.
WifiPhyBand GetPhyBand(void) const
Get the configured Wi-Fi band.
Definition: wifi-phy.cc:1425
uint32_t m_nextFragmentationThreshold
Threshold for fragmentation that will be used for the next transmission.
void AddStationVhtCapabilities(Mac48Address from, VhtCapabilities vhtCapabilities)
Records VHT capabilities of the remote station.
uint32_t GetSize(void) const
Return the size of the WifiMacHeader in octets.
Mac48Address GetAddr1(void) const
Return the address in the Address 1 field.
bool GetHeSupported(void) const
Return whether the device has HE capability support enabled.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
Ptr< const HeCapabilities > m_heCapabilities
remote station HE capabilities
static const uint16_t WIFI_MAC_FCS_LENGTH
The length in octects of the IEEE 802.11 MAC FCS field.
WifiMode GetDefaultMcs(void) const
Return the default Modulation and Coding Scheme (MCS) index.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
uint32_t m_fragmentationThreshold
Current threshold for fragmentation.
The HT Capabilities Information ElementThis class knows how to serialise and deserialise the HT Capab...
uint8_t m_defaultTxPowerLevel
Default transmission power level.
void SetStbc(bool stbc)
Sets if STBC is being used.
void AddSupportedPhyPreamble(Mac48Address address, bool isShortPreambleSupported)
Record whether the short PHY preamble is supported by the station.
WifiMode GetNonUnicastMode(void) const
Return a mode for non-unicast packets.
WifiMode GetBasicMcs(uint8_t i) const
Return the MCS at the given list index.
Mac48Address m_address
Mac48Address of the remote station.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
void UpdateFragmentationThreshold(void)
Typically called to update the fragmentation threshold at the start of a new transmission.
void SetPcfSupported(bool enable)
Enable or disable PCF capability support.
bool GetUseNonHtProtection(void) const
Return whether the device supports protection of non-HT stations.
bool IsLastFragment(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fragmentNumber)
VHT PHY (Clause 22)
Definition: wifi-mode.h:60
The 5 GHz band.
Definition: wifi-phy-band.h:35
void ReportDataOk(Mac48Address address, const WifiMacHeader *header, double ackSnr, WifiMode ackMode, double dataSnr, WifiTxVector dataTxVector, uint32_t packetSize)
Should be invoked whenever we receive the ACK associated to a data packet we just sent...
TracedCallback< Mac48Address > m_macTxFinalRtsFailed
The trace source fired when the transmission of a RTS has exceeded the maximum number of attempts...
uint32_t GetFragmentationThreshold(void) const
Return the fragmentation threshold.
WifiPreamble GetPreambleForTransmission(WifiModulationClass modulation, bool useShortPreamble, bool useGreenfield)
Return the preamble to be used for the transmission.
Definition: wifi-utils.cc:116
bool GetUseGreenfieldProtection(void) const
Return whether protection for stations that do not support HT Greenfield format is enabled...
WifiMode GetSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether mode associated with the specified station at the specified index. ...
uint8_t GetNBasicMcs(void) const
Return the number of basic MCS index.
Ptr< const AttributeChecker > MakeWifiModeChecker(void)
Definition: wifi-mode.cc:650
uint32_t GetNNonErpSupported(const WifiRemoteStation *station) const
Return the number of non-ERP modes supported by the given station.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:97
bool m_shortPreambleEnabled
flag if short PHY preamble is enabled
uint8_t GetSupportedChannelWidth(void) const
Return the supported channel width.
TID independent remote station statistics.
WifiRemoteStationState * m_state
Remote station state.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
bool IsMandatory(void) const
Definition: wifi-mode.cc:434
void RecordDisassociated(Mac48Address address)
Records that the STA was disassociated.
phy
Definition: third.py:93
TracedCallback< Mac48Address > m_macTxFinalDataFailed
The trace source fired when the transmission of a data packet has exceeded the maximum number of atte...
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1515
void SetShortSlotTimeEnabled(bool enable)
Enable or disable short slot time.
WifiTxVector GetDataTxVector(const WifiMacHeader &header)
uint8_t GetNMcs(void) const
The WifiPhy::GetNMcs() method is used (e.g., by a WifiRemoteStationManager) to determine the set of t...
Definition: wifi-phy.cc:4132
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Definition: wifi-preamble.h:32
uint8_t GetNumberOfSupportedStreams(Mac48Address address) const
Return the number of spatial streams supported by the station.
bool GetShortPreambleEnabled(void) const
Return whether the device uses short PHY preambles.
bool GetGreenfield(const WifiRemoteStation *station) const
Return whether the station supports Greenfield or not.
ProtectionMode m_htProtectionMode
Protection mode for HT stations when non-HT stations are detected.
void SetRtsCtsThreshold(uint32_t threshold)
Sets the RTS threshold.
bool m_qosSupported
Flag if QoS is supported by the station.
Hold variables of type enum.
Definition: enum.h:54
WifiRemoteStationState * LookupState(Mac48Address address) const
Return the state of the station associated with the given address.
WifiMode m_defaultTxMcs
The default transmission modulation-coding scheme (MCS)
bool IsSupportedMcs(uint8_t mcs) const
Return the is MCS supported flag.
virtual void DoReportRtsOk(WifiRemoteStation *station, double ctsSnr, WifiMode ctsMode, double rtsSnr)=0
This method is a pure virtual method that must be implemented by the sub-class.
Ptr< WifiPhy > m_wifiPhy
This is a pointer to the WifiPhy associated with this WifiRemoteStationManager that is set on call to...
virtual void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode)=0
This method is a pure virtual method that must be implemented by the sub-class.
void ReportRtsFailed(Mac48Address address, const WifiMacHeader *header)
Should be invoked whenever the RtsTimeout associated to a transmission attempt expires.
bool GetPcfSupported(void) const
Return whether the device has PCF capability support enabled.
bool GetShortSlotTimeSupported(Mac48Address address) const
Return whether the station supports short ERP slot time or not.
The IEEE 802.11ac VHT Capabilities.
void SetGuardInterval(uint16_t guardInterval)
Sets the guard interval duration (in nanoseconds)
void AddStationHtCapabilities(Mac48Address from, HtCapabilities htCapabilities)
Records HT capabilities of the remote station.
bool m_useNonErpProtection
flag if protection for non-ERP stations against ERP transmissions is enabled
Hold an unsigned integer type.
Definition: uinteger.h:44
virtual void DoReportDataFailed(WifiRemoteStation *station)=0
This method is a pure virtual method that must be implemented by the sub-class.
uint8_t GetSupportedChannelWidthSet() const
Get the supported channel width set.
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: enum.h:203
void ReportRxOk(Mac48Address address, double rxSnr, WifiMode txMode)
void RecordGotAssocTxFailed(Mac48Address address)
Records that we missed an ACK for the association response we sent.
bool GetHtSupported(void) const
Return whether the device has HT capability support enabled.
mac
Definition: third.py:99
uint16_t ConvertGuardIntervalToNanoSeconds(WifiMode mode, const Ptr< WifiNetDevice > device)
Convert the guard interval to nanoseconds based on the WifiMode.
Definition: wifi-utils.cc:59
WifiRemoteStationInfo GetInfo(Mac48Address address)
AcIndex QosUtilsMapTidToAc(uint8_t tid)
Maps TID (Traffic ID) to Access classes.
Definition: qos-utils.cc:32
uint8_t GetQosTid(void) const
Return the Traffic ID of a QoS header.
void SetMaxSsrc(uint32_t maxSsrc)
Sets the maximum STA short retry count (SSRC).
void AddStationHeCapabilities(Mac48Address from, HeCapabilities heCapabilities)
Records HE capabilities of the remote station.
WifiMode GetMode(void) const
HT PHY (Clause 20)
Definition: wifi-mode.h:58
uint32_t m_maxSlrc
Maximum STA long retry count (SLRC)
bool m_pcfSupported
Flag if PCF capability is supported.
Ptr< const HeCapabilities > GetStationHeCapabilities(Mac48Address from)
Return the HE capabilities sent by the remote station.
bool NeedRetransmission(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
Ptr< WifiMac > m_wifiMac
This is a pointer to the WifiMac associated with this WifiRemoteStationManager that is set on call to...
Ptr< const VhtCapabilities > m_vhtCapabilities
remote station VHT capabilities
uint32_t GetNNonErpBasicModes(void) const
Return the number of non-ERP basic modes we support.
WifiTxVector GetCtsToSelfTxVector(void)
Since CTS-to-self parameters are not dependent on the station, it is implemented in wifi remote stati...
Ptr< const HtCapabilities > m_htCapabilities
remote station HT capabilities
bool IsSupportedMcs(uint8_t mcs, uint8_t nss) const
Get the is MCS supported.
WifiMode GetNonErpBasicMode(uint8_t i) const
Return a basic mode from the set of basic modes that is not an ERP mode.
bool IsAssociated(Mac48Address address) const
Return whether the station associated.
virtual void SetupPhy(const Ptr< WifiPhy > phy)
Set up PHY associated with this device since it is the object that knows the full set of transmit rat...
hold a list of per-remote-station state.
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:463
bool GetQosSupported(Mac48Address address) const
Return whether the given station is QoS capable.
Ptr< const HtCapabilities > GetStationHtCapabilities(Mac48Address from)
Return the HT capabilities sent by the remote station.
bool NeedRts(const WifiMacHeader &header, uint32_t size)
WifiMode GetDefaultMode(void) const
Return the default transmission mode.
void SetQosSupport(Mac48Address from, bool qosSupported)
Records QoS support of the remote station.
WifiMode m_defaultTxMode
The default transmission mode.
void SetNss(uint8_t nss)
Sets the number of Nss refer to IEEE 802.11n Table 20-28 for explanation and range.
WifiModeList m_bssBasicRateSet
This member is the list of WifiMode objects that comprise the BSSBasicRateSet parameter.
uint64_t Get(void) const
Definition: uinteger.cc:35
uint32_t GetFragmentOffset(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fragmentNumber)
bool GetShortSlotTimeEnabled(void) const
Return whether the device uses short slot time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
address
Definition: first.py:44
void SetPreambleType(WifiPreamble preamble)
Sets the preamble type.
uint8_t GetNumberOfAntennas(void) const
Definition: wifi-phy.cc:1529
void AddSupportedMode(Mac48Address address, WifiMode mode)
Invoked in a STA or AP to store the set of modes supported by a destination which is also supported l...
WifiModeList m_operationalRateSet
This member is the list of WifiMode objects that comprise the OperationalRateSet parameter for this r...
uint32_t GetFragmentSize(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fragmentNumber)
void DoSetFragmentationThreshold(uint32_t threshold)
Actually sets the fragmentation threshold, it also checks the validity of the given threshold...
void AddBasicMode(WifiMode mode)
Invoked in a STA upon association to store the set of rates which belong to the BSSBasicRateSet of th...
uint16_t GetChannelWidthForTransmission(WifiMode mode, uint16_t maxSupportedChannelWidth)
Return the channel width that corresponds to the selected mode (instead of letting the PHY&#39;s default ...
Definition: wifi-utils.cc:97
void SetUseNonErpProtection(bool enable)
Enable or disable protection for non-ERP stations.
WifiModeList::const_iterator WifiModeListIterator
An iterator for WifiModeList vector.
Definition: wifi-mode.h:287
bool UseGreenfieldForDestination(Mac48Address dest) const
bool m_useGreenfieldProtection
flag if protection for stations that do not support HT Greenfield format is enabled ...
bool m_aggregation
Flag if MPDU aggregation is used by the remote station.
an EUI-48 address
Definition: mac48-address.h:43
TracedCallback< Mac48Address > m_macTxRtsFailed
The trace source fired when the transmission of a single RTS has failed.
virtual void DoReportDataOk(WifiRemoteStation *station, double ackSnr, WifiMode ackMode, double dataSnr, uint16_t dataChannelWidth, uint8_t dataNss)=0
This method is a pure virtual method that must be implemented by the sub-class.
Mac48Address GetAddress(const WifiRemoteStation *station) const
Return the address of the station.
WifiMode GetNonErpSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether non-ERP mode associated with the specified station at the specified index...
void SetTxPowerLevel(uint8_t powerlevel)
Sets the selected transmission power level.
Ptr< const AttributeAccessor > MakeWifiModeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: wifi-mode.h:275
void SetNTx(uint8_t nTx)
Sets the number of TX antennas.
The 2.4 GHz band.
Definition: wifi-phy-band.h:33
bool GetShortGuardIntervalSupported(void) const
Return whether the device has SGI support enabled.
Stations m_stations
Information for each known stations.
void ReportRtsOk(Mac48Address address, const WifiMacHeader *header, double ctsSnr, WifiMode ctsMode, double rtsSnr)
Should be invoked whenever we receive the CTS associated to an RTS we just sent.
TracedCallback< Mac48Address > m_macTxDataFailed
The trace source fired when the transmission of a single data packet has failed.
bool GetAggregation(const WifiRemoteStation *station) const
Return whether the given station supports A-MPDU.
uint16_t m_channelWidth
Channel width (in MHz) supported by the remote station.
virtual bool DoNeedRetransmission(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
uint8_t GetHighestMcsSupported(void) const
Get highest MCS supported.
void AddBasicMcs(WifiMode mcs)
Add a given Modulation and Coding Scheme (MCS) index to the set of basic MCS.
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
uint8_t GetNModes(void) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
Definition: wifi-phy.cc:4120
virtual bool DoNeedFragmentation(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
bool NeedCtsToSelf(WifiTxVector txVector)
Return if we need to do CTS-to-self before sending a DATA.
uint8_t GetNBasicModes(void) const
Return the number of basic modes we support.
uint8_t GetHeLtfAndGiForHePpdus(void) const
Get HE LTF and GI for HE PDPUs.
void SetUseNonHtProtection(bool enable)
Enable or disable protection for non-HT stations.
WifiMode GetMode(uint8_t mode) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
Definition: wifi-phy.cc:4126
virtual void SetupMac(const Ptr< WifiMac > mac)
Set up MAC associated with this device since it is the object that knows the full set of timing param...
void SetMaxSlrc(uint32_t maxSlrc)
Sets the maximum STA long retry count (SLRC).
Ptr< WifiPhy > GetPhy(void) const
Return the WifiPhy.
void ReportDataFailed(Mac48Address address, const WifiMacHeader *header, uint32_t packetSize)
Should be invoked whenever the AckTimeout associated to a transmission attempt expires.
uint16_t GetGuardInterval(void) const
Return the supported HE guard interval duration (in nanoseconds).
bool IsMgt(void) const
Return true if the Type is Management.
A struct that holds information about each remote station.
WifiModeList m_operationalMcsSet
operational MCS set
static TypeId GetTypeId(void)
Get the type ID.
void AddSupportedErpSlotTime(Mac48Address address, bool isShortSlotTimeSupported)
Record whether the short ERP slot time is supported by the station.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:265
void SetFragmentationThreshold(uint32_t threshold)
Sets a fragmentation threshold.
void Reset(void)
Reset the station, invoked in a STA upon dis-association or in an AP upon reboot. ...
bool GetUseNonErpProtection(void) const
Return whether the device supports protection of non-ERP stations.
uint32_t m_maxSsrc
Maximum STA short retry count (SSRC)
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
virtual void DoDispose(void)
Destructor implementation.
Ptr< const VhtCapabilities > GetStationVhtCapabilities(Mac48Address from)
Return the VHT capabilities sent by the remote station.
bool GetGreenfieldSupported(void) const
Return whether the device has HT Greenfield support enabled.
WifiTxVector GetRtsTxVector(Mac48Address address)
void SetUseGreenfieldProtection(bool enable)
Enable or disable protection for stations that do not support HT Greenfield format.
bool NeedFragmentation(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
Ptr< const AttributeChecker > MakeEnumChecker(int v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Definition: enum.h:161
void SetNess(uint8_t ness)
Sets the Ness number refer to IEEE 802.11n Table 20-6 for explanation.
virtual void DoReportAmpduTxStatus(WifiRemoteStation *station, uint8_t nSuccessfulMpdus, uint8_t nFailedMpdus, double rxSnr, double dataSnr, uint16_t dataChannelWidth, uint8_t dataNss)
Typically called per A-MPDU, either when a Block ACK was successfully received or when a BlockAckTime...
Ptr< NetDevice > GetDevice(void) const
Return the device this PHY is associated with.
Definition: wifi-phy.cc:758
bool IsQosData(void) const
Return true if the Type is DATA and Subtype is one of the possible values for QoS Data...
uint8_t m_ness
Number of extended spatial streams of the remote station.
The 6 GHz band.
Definition: wifi-phy-band.h:37
uint16_t GetChannelWidth(void) const
bool m_shortSlotTime
Flag if short ERP slot time is supported by the remote station.
A base class which provides memory management and object aggregation.
Definition: object.h:87
AttributeValue implementation for WifiMode.
Definition: wifi-mode.h:275
StationStates m_states
States of known stations.
bool IsWaitAssocTxOk(Mac48Address address) const
Return whether we are waiting for an ACK for the association response we sent.
void SetShortPreambleEnabled(bool enable)
Enable or disable short PHY preambles.
virtual bool DoNeedRts(WifiRemoteStation *station, uint32_t size, bool normally)
ProtectionMode m_erpProtectionMode
Protection mode for ERP stations when non-ERP stations are detected.
WifiMode GetBasicMode(uint8_t i) const
Return a basic mode from the set of basic modes.
void AddAllSupportedModes(Mac48Address address)
Invoked in a STA or AP to store all of the modes supported by a destination which is also supported l...
virtual WifiTxVector DoGetDataTxVector(WifiRemoteStation *station)=0
Ptr< VhtConfiguration > GetVhtConfiguration(void) const
The IEEE 802.11ax HE Capabilities.
uint8_t GetMcsValue(void) const
Definition: wifi-mode.cc:441
Ptr< HtConfiguration > GetHtConfiguration(void) const
virtual void DoReportFinalDataFailed(WifiRemoteStation *station)=0
This method is a pure virtual method that must be implemented by the sub-class.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: uinteger.h:45
virtual WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station)=0
bool IsBrandNew(Mac48Address address) const
Return whether the station state is brand new.
uint8_t GetMaxSupportedTxSpatialStreams(void) const
Definition: wifi-phy.cc:1548
a unique identifier for an interface.
Definition: type-id.h:58
void ReportFinalRtsFailed(Mac48Address address, const WifiMacHeader *header)
Should be invoked after calling ReportRtsFailed if NeedRetransmission returns false.
WifiRemoteStation * Lookup(Mac48Address address) const
Return the station associated with the given address.
void RemoveAllSupportedMcs(Mac48Address address)
Invoked in a STA or AP to delete all of the supported MCS by a destination.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:38
WifiRemoteStationInfo m_info
remote station info
WifiModeList m_bssBasicMcsSet
basic MCS set
virtual void DoReportFinalRtsFailed(WifiRemoteStation *station)=0
This method is a pure virtual method that must be implemented by the sub-class.
HE PHY (Clause 26)
Definition: wifi-mode.h:62
hold per-remote-station state.
virtual WifiRemoteStation * DoCreateStation(void) const =0
void RecordGotAssocTxOk(Mac48Address address)
Records that we got an ACK for the association response we sent.
uint8_t GetHighestNssSupported(void) const
Get highest NSS supported.
Implements the IEEE 802.11 MAC header.
WifiMode GetMcsSupported(const WifiRemoteStation *station, uint8_t i) const
Return the WifiMode supported by the specified station at the specified index.
uint16_t GetChannelWidthSupported(Mac48Address address) const
Return the channel width supported by the station.
uint8_t GetNss(void) const
uint16_t GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the station.
uint8_t GetNess(const WifiRemoteStation *station) const
void ReportAmpduTxStatus(Mac48Address address, uint8_t nSuccessfulMpdus, uint8_t nFailedMpdus, double rxSnr, double dataSnr, WifiTxVector dataTxVector)
Typically called per A-MPDU, either when a Block ACK was successfully received or when a BlockAckTime...
uint16_t m_guardInterval
HE Guard interval duration (in nanoseconds) supported by the remote station.
uint32_t DoGetFragmentationThreshold(void) const
Return the current fragmentation threshold.