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 "ap-wifi-mac.h"
29 #include "sta-wifi-mac.h"
30 #include "wifi-mac-header.h"
31 #include "wifi-mac-queue-item.h"
32 #include "wifi-mac-trailer.h"
33 #include "ns3/ht-configuration.h"
34 #include "ns3/ht-phy.h"
35 #include "ns3/vht-configuration.h"
36 #include "ns3/he-configuration.h"
37 #include "wifi-net-device.h"
38 
39 namespace ns3 {
40 
41 NS_LOG_COMPONENT_DEFINE ("WifiRemoteStationManager");
42 
43 NS_OBJECT_ENSURE_REGISTERED (WifiRemoteStationManager);
44 
45 TypeId
47 {
48  static TypeId tid = TypeId ("ns3::WifiRemoteStationManager")
49  .SetParent<Object> ()
50  .SetGroupName ("Wifi")
51  .AddAttribute ("MaxSsrc",
52  "The maximum number of retransmission attempts for any packet with size <= RtsCtsThreshold. "
53  "This value will not have any effect on some rate control algorithms.",
54  UintegerValue (7),
56  MakeUintegerChecker<uint32_t> ())
57  .AddAttribute ("MaxSlrc",
58  "The maximum number of retransmission attempts for any packet with size > RtsCtsThreshold. "
59  "This value will not have any effect on some rate control algorithms.",
60  UintegerValue (4),
62  MakeUintegerChecker<uint32_t> ())
63  .AddAttribute ("RtsCtsThreshold",
64  "If the size of the PSDU is bigger than this value, we use an RTS/CTS handshake before sending the data frame."
65  "This value will not have any effect on some rate control algorithms.",
66  UintegerValue (65535),
68  MakeUintegerChecker<uint32_t> ())
69  .AddAttribute ("FragmentationThreshold",
70  "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. "
71  "This value does not apply when it is carried in an A-MPDU. "
72  "This value will not have any effect on some rate control algorithms.",
73  UintegerValue (65535),
76  MakeUintegerChecker<uint32_t> ())
77  .AddAttribute ("NonUnicastMode",
78  "Wifi mode used for non-unicast transmissions.",
79  WifiModeValue (),
82  .AddAttribute ("DefaultTxPowerLevel",
83  "Default power level to be used for transmissions. "
84  "This is the power level that is used by all those WifiManagers that do not implement TX power control.",
85  UintegerValue (0),
87  MakeUintegerChecker<uint8_t> ())
88  .AddAttribute ("ErpProtectionMode",
89  "Protection mode used when non-ERP STAs are connected to an ERP AP: Rts-Cts or Cts-To-Self",
94  .AddAttribute ("HtProtectionMode",
95  "Protection mode used when non-HT STAs are connected to a HT AP: Rts-Cts or Cts-To-Self",
100  .AddTraceSource ("MacTxRtsFailed",
101  "The transmission of a RTS by the MAC layer has failed",
103  "ns3::Mac48Address::TracedCallback")
104  .AddTraceSource ("MacTxDataFailed",
105  "The transmission of a data packet by the MAC layer has failed",
107  "ns3::Mac48Address::TracedCallback")
108  .AddTraceSource ("MacTxFinalRtsFailed",
109  "The transmission of a RTS has exceeded the maximum number of attempts",
111  "ns3::Mac48Address::TracedCallback")
112  .AddTraceSource ("MacTxFinalDataFailed",
113  "The transmission of a data packet has exceeded the maximum number of attempts",
115  "ns3::Mac48Address::TracedCallback")
116  ;
117  return tid;
118 }
119 
121  : m_useNonErpProtection (false),
122  m_useNonHtProtection (false),
123  m_shortPreambleEnabled (false),
124  m_shortSlotTimeEnabled (false)
125 {
126  NS_LOG_FUNCTION (this);
127 }
128 
130 {
131  NS_LOG_FUNCTION (this);
132 }
133 
134 void
136 {
137  NS_LOG_FUNCTION (this);
138  Reset ();
139 }
140 
141 void
143 {
144  NS_LOG_FUNCTION (this << phy);
145  //We need to track our PHY because it is the object that knows the
146  //full set of transmit rates that are supported. We need to know
147  //this in order to find the relevant mandatory rates when choosing a
148  //transmit rate for automatic control responses like
149  //acknowledgments.
150  m_wifiPhy = phy;
151  m_defaultTxMode = phy->GetDefaultMode ();
153  if (GetHtSupported ())
154  {
156  }
157  Reset ();
158 }
159 
160 void
162 {
163  NS_LOG_FUNCTION (this << mac);
164  //We need to track our MAC because it is the object that knows the
165  //full set of interframe spaces.
166  m_wifiMac = mac;
167  Reset ();
168 }
169 
170 int64_t
172 {
173  NS_LOG_FUNCTION (this << stream);
174  return 0;
175 }
176 
177 void
179 {
180  NS_LOG_FUNCTION (this << maxSsrc);
181  m_maxSsrc = maxSsrc;
182 }
183 
184 void
186 {
187  NS_LOG_FUNCTION (this << maxSlrc);
188  m_maxSlrc = maxSlrc;
189 }
190 
191 void
193 {
194  NS_LOG_FUNCTION (this << threshold);
195  m_rtsCtsThreshold = threshold;
196 }
197 
198 void
200 {
201  NS_LOG_FUNCTION (this << threshold);
202  DoSetFragmentationThreshold (threshold);
203 }
204 
205 void
207 {
208  NS_LOG_FUNCTION (this << enable);
209  m_shortPreambleEnabled = enable;
210 }
211 
212 void
214 {
215  NS_LOG_FUNCTION (this << enable);
216  m_shortSlotTimeEnabled = enable;
217 }
218 
219 bool
221 {
222  return m_shortSlotTimeEnabled;
223 }
224 
225 bool
227 {
228  return m_shortPreambleEnabled;
229 }
230 
231 bool
233 {
234  Ptr<WifiNetDevice> device = DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ());
235  Ptr<HtConfiguration> htConfiguration = device->GetHtConfiguration ();
236  if (htConfiguration)
237  {
238  return true;
239  }
240  return false;
241 }
242 
243 bool
245 {
246  Ptr<WifiNetDevice> device = DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ());
247  Ptr<VhtConfiguration> vhtConfiguration = device->GetVhtConfiguration ();
248  if (vhtConfiguration)
249  {
250  return true;
251  }
252  return false;
253 }
254 
255 bool
257 {
258  Ptr<WifiNetDevice> device = DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ());
259  Ptr<HeConfiguration> heConfiguration = device->GetHeConfiguration ();
260  if (heConfiguration)
261  {
262  return true;
263  }
264  return false;
265 }
266 
267 bool
269 {
270  if (GetHtSupported ())
271  {
272  Ptr<WifiNetDevice> device = DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ());
273  Ptr<HtConfiguration> htConfiguration = device->GetHtConfiguration ();
274  NS_ASSERT (htConfiguration); //If HT is supported, we should have a HT configuration attached
275  return htConfiguration->GetLdpcSupported ();
276  }
277  return false;
278 }
279 
280 bool
282 {
283  if (GetHtSupported ())
284  {
285  Ptr<WifiNetDevice> device = DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ());
286  Ptr<HtConfiguration> htConfiguration = device->GetHtConfiguration ();
287  NS_ASSERT (htConfiguration); //If HT is supported, we should have a HT configuration attached
288  if (htConfiguration->GetShortGuardIntervalSupported ())
289  {
290  return true;
291  }
292  }
293  return false;
294 }
295 
296 uint16_t
298 {
299  uint16_t gi = 0;
300  if (GetHeSupported ())
301  {
302  Ptr<WifiNetDevice> device = DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ());
303  Ptr<HeConfiguration> heConfiguration = device->GetHeConfiguration ();
304  NS_ASSERT (heConfiguration); //If HE is supported, we should have a HE configuration attached
305  gi = static_cast<uint16_t>(heConfiguration->GetGuardInterval ().GetNanoSeconds ());
306  }
307  return gi;
308 }
309 
310 uint32_t
312 {
313  return DoGetFragmentationThreshold ();
314 }
315 
316 void
318 {
319  NS_LOG_FUNCTION (this << address << isShortPreambleSupported);
320  NS_ASSERT (!address.IsGroup ());
322  state->m_shortPreamble = isShortPreambleSupported;
323 }
324 
325 void
327 {
328  NS_LOG_FUNCTION (this << address << isShortSlotTimeSupported);
329  NS_ASSERT (!address.IsGroup ());
331  state->m_shortSlotTime = isShortSlotTimeSupported;
332 }
333 
334 void
336 {
337  NS_LOG_FUNCTION (this << address << mode);
338  NS_ASSERT (!address.IsGroup ());
340  for (WifiModeListIterator i = state->m_operationalRateSet.begin (); i != state->m_operationalRateSet.end (); i++)
341  {
342  if ((*i) == mode)
343  {
344  //already in.
345  return;
346  }
347  }
349  {
350  state->m_dsssSupported = true;
351  }
352  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
353  {
354  state->m_erpOfdmSupported = true;
355  }
356  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM)
357  {
358  state->m_ofdmSupported = true;
359  }
360  state->m_operationalRateSet.push_back (mode);
361 }
362 
363 void
365 {
366  NS_LOG_FUNCTION (this << address);
367  NS_ASSERT (!address.IsGroup ());
369  state->m_operationalRateSet.clear ();
370  for (const auto & mode : m_wifiPhy->GetModeList ())
371  {
372  state->m_operationalRateSet.push_back (mode);
373  if (mode.IsMandatory ())
374  {
375  AddBasicMode (mode);
376  }
377  }
378 }
379 
380 void
382 {
383  NS_LOG_FUNCTION (this << address);
384  NS_ASSERT (!address.IsGroup ());
386  state->m_operationalMcsSet.clear ();
387  for (const auto & mcs : m_wifiPhy->GetMcsList ())
388  {
389  state->m_operationalMcsSet.push_back (mcs);
390  }
391 }
392 
393 void
395 {
396  NS_LOG_FUNCTION (this << address);
397  NS_ASSERT (!address.IsGroup ());
399  state->m_operationalMcsSet.clear ();
400 }
401 
402 void
404 {
405  NS_LOG_FUNCTION (this << address << mcs);
406  NS_ASSERT (!address.IsGroup ());
408  for (WifiModeListIterator i = state->m_operationalMcsSet.begin (); i != state->m_operationalMcsSet.end (); i++)
409  {
410  if ((*i) == mcs)
411  {
412  //already in.
413  return;
414  }
415  }
416  state->m_operationalMcsSet.push_back (mcs);
417 }
418 
419 bool
421 {
423 }
424 
425 bool
427 {
429 }
430 
431 bool
433 {
435 }
436 
437 bool
439 {
440  if (address.IsGroup ())
441  {
442  return false;
443  }
445 }
446 
447 bool
449 {
450  if (address.IsGroup ())
451  {
452  return true;
453  }
455 }
456 
457 bool
459 {
460  if (address.IsGroup ())
461  {
462  return false;
463  }
465 }
466 
467 void
469 {
470  NS_ASSERT (!address.IsGroup ());
472 }
473 
474 void
476 {
477  NS_ASSERT (!address.IsGroup ());
479 }
480 
481 void
483 {
484  NS_ASSERT (!address.IsGroup ());
486 }
487 
488 void
490 {
491  NS_ASSERT (!address.IsGroup ());
493 }
494 
495 uint16_t
497 {
498  NS_LOG_FUNCTION (this << address << txVector);
499 
500  uint16_t staId = SU_STA_ID;
501 
502  if (txVector.IsMu ())
503  {
504  if (m_wifiMac->GetTypeOfStation () == AP)
505  {
506  staId = StaticCast<ApWifiMac> (m_wifiMac)->GetAssociationId (address);
507  }
508  else if (m_wifiMac->GetTypeOfStation () == STA)
509  {
510  Ptr<StaWifiMac> staMac = StaticCast<StaWifiMac> (m_wifiMac);
511  if (staMac->IsAssociated ())
512  {
513  staId = staMac->GetAssociationId ();
514  }
515  }
516  }
517 
518  NS_LOG_DEBUG ("Returning STAID = " << staId);
519  return staId;
520 }
521 
524 {
525  NS_LOG_FUNCTION (this << header);
526  Mac48Address address = header.GetAddr1 ();
527  if (!header.IsMgt () && address.IsGroup ())
528  {
529  WifiMode mode = GetNonUnicastMode ();
530  WifiTxVector v;
531  v.SetMode (mode);
535  v.SetGuardInterval (ConvertGuardIntervalToNanoSeconds (mode, DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ())));
537  v.SetNss (1);
538  v.SetNess (0);
539  return v;
540  }
541  WifiTxVector txVector;
542  if (header.IsMgt ())
543  {
544  //Use the lowest basic rate for management frames
545  WifiMode mgtMode;
546  if (GetNBasicModes () > 0)
547  {
548  mgtMode = GetBasicMode (0);
549  }
550  else
551  {
552  mgtMode = GetDefaultMode ();
553  }
554  txVector.SetMode (mgtMode);
558  txVector.SetGuardInterval (ConvertGuardIntervalToNanoSeconds (mgtMode, DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ())));
559  }
560  else
561  {
562  txVector = DoGetDataTxVector (Lookup (address));
564  }
565  Ptr<WifiNetDevice> device = DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ());
566  Ptr<HeConfiguration> heConfiguration = device->GetHeConfiguration ();
567  if (heConfiguration)
568  {
569  txVector.SetBssColor (heConfiguration->GetBssColor ());
570  }
571  return txVector;
572 }
573 
576 {
577  WifiMode defaultMode = GetDefaultMode ();
578  WifiPreamble defaultPreamble;
579  if (defaultMode.GetModulationClass () == WIFI_MOD_CLASS_HE)
580  {
581  defaultPreamble = WIFI_PREAMBLE_HE_SU;
582  }
583  else if (defaultMode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
584  {
585  defaultPreamble = WIFI_PREAMBLE_VHT_SU;
586  }
587  else if (defaultMode.GetModulationClass () == WIFI_MOD_CLASS_HT)
588  {
589  defaultPreamble = WIFI_PREAMBLE_HT_MF;
590  }
591  else
592  {
593  defaultPreamble = WIFI_PREAMBLE_LONG;
594  }
595 
596  return WifiTxVector (defaultMode,
598  defaultPreamble,
599  ConvertGuardIntervalToNanoSeconds (defaultMode, DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ())),
601  1,
602  0,
604  false);
605 }
606 
609 {
610  NS_LOG_FUNCTION (this << address);
611  if (address.IsGroup ())
612  {
613  WifiMode mode = GetNonUnicastMode ();
614  WifiTxVector v;
615  v.SetMode (mode);
619  v.SetGuardInterval (ConvertGuardIntervalToNanoSeconds (mode, DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ())));
621  v.SetNss (1);
622  v.SetNess (0);
623  return v;
624  }
625  return DoGetRtsTxVector (Lookup (address));
626 }
627 
630 {
631  NS_ASSERT (!to.IsGroup ());
632  WifiMode ctsMode = GetControlAnswerMode (rtsTxMode);
633  WifiTxVector v;
634  v.SetMode (ctsMode);
635  v.SetPreambleType (GetPreambleForTransmission (ctsMode.GetModulationClass (), GetShortPreambleEnabled ()));
638  uint16_t ctsTxGuardInterval = ConvertGuardIntervalToNanoSeconds (ctsMode, DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ()));
639  v.SetGuardInterval (ctsTxGuardInterval);
640  v.SetNss (1);
641  return v;
642 }
643 
646 {
647  NS_ASSERT (!to.IsGroup ());
648  WifiMode ackMode = GetControlAnswerMode (dataTxVector.GetMode (GetStaId (to, dataTxVector)));
649  WifiTxVector v;
650  v.SetMode (ackMode);
651  v.SetPreambleType (GetPreambleForTransmission (ackMode.GetModulationClass (), GetShortPreambleEnabled ()));
652  v.SetTxPowerLevel (GetDefaultTxPowerLevel ());
653  v.SetChannelWidth (GetChannelWidthForTransmission (ackMode, m_wifiPhy->GetChannelWidth ()));
654  uint16_t ackTxGuardInterval = ConvertGuardIntervalToNanoSeconds (ackMode, DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ()));
655  v.SetGuardInterval (ackTxGuardInterval);
656  v.SetNss (1);
657  return v;
658 }
659 
662 {
663  NS_ASSERT (!to.IsGroup ());
664  WifiMode blockAckMode = GetControlAnswerMode (dataTxVector.GetMode (GetStaId (to, dataTxVector)));
665  WifiTxVector v;
666  v.SetMode (blockAckMode);
667  v.SetPreambleType (GetPreambleForTransmission (blockAckMode.GetModulationClass (), GetShortPreambleEnabled ()));
668  v.SetTxPowerLevel (GetDefaultTxPowerLevel ());
669  v.SetChannelWidth (GetChannelWidthForTransmission (blockAckMode, m_wifiPhy->GetChannelWidth ()));
670  uint16_t blockAckTxGuardInterval = ConvertGuardIntervalToNanoSeconds (blockAckMode, DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ()));
671  v.SetGuardInterval (blockAckTxGuardInterval);
672  v.SetNss (1);
673  return v;
674 }
675 
676 WifiMode
678 {
693  NS_LOG_FUNCTION (this << reqMode);
694  WifiMode mode = GetDefaultMode ();
695  bool found = false;
696  //First, search the BSS Basic Rate set
697  for (uint8_t i = 0; i < GetNBasicModes (); i++)
698  {
699  WifiMode testMode = GetBasicMode (i);
700  if ((!found || testMode.IsHigherDataRate (mode))
701  && (!testMode.IsHigherDataRate (reqMode))
703  {
704  mode = testMode;
705  //We've found a potentially-suitable transmit rate, but we
706  //need to continue and consider all the basic rates before
707  //we can be sure we've got the right one.
708  found = true;
709  }
710  }
711  if (GetHtSupported ())
712  {
713  if (!found)
714  {
715  mode = GetDefaultMcs ();
716  for (uint8_t i = 0; i != GetNBasicMcs (); i++)
717  {
718  WifiMode testMode = GetBasicMcs (i);
719  if ((!found || testMode.IsHigherDataRate (mode))
720  && (!testMode.IsHigherDataRate (reqMode))
721  && (testMode.GetModulationClass () == reqMode.GetModulationClass ()))
722  {
723  mode = testMode;
724  //We've found a potentially-suitable transmit rate, but we
725  //need to continue and consider all the basic rates before
726  //we can be sure we've got the right one.
727  found = true;
728  }
729  }
730  }
731  }
732  //If we found a suitable rate in the BSSBasicRateSet, then we are
733  //done and can return that mode.
734  if (found)
735  {
736  NS_LOG_DEBUG ("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
737  return mode;
738  }
739 
757  for (const auto & thismode : m_wifiPhy->GetModeList ())
758  {
759  /* If the rate:
760  *
761  * - is a mandatory rate for the PHY, and
762  * - is equal to or faster than our current best choice, and
763  * - is less than or equal to the rate of the received frame, and
764  * - is of the same modulation class as the received frame
765  *
766  * ...then it's our best choice so far.
767  */
768  if (thismode.IsMandatory ()
769  && (!found || thismode.IsHigherDataRate (mode))
770  && (!thismode.IsHigherDataRate (reqMode))
771  && (IsAllowedControlAnswerModulationClass (reqMode.GetModulationClass (), thismode.GetModulationClass ())))
772  {
773  mode = thismode;
774  //As above; we've found a potentially-suitable transmit
775  //rate, but we need to continue and consider all the
776  //mandatory rates before we can be sure we've got the right one.
777  found = true;
778  }
779  }
780  if (GetHtSupported () )
781  {
782  for (const auto & thismode : m_wifiPhy->GetMcsList ())
783  {
784  if (thismode.IsMandatory ()
785  && (!found || thismode.IsHigherDataRate (mode))
786  && (!thismode.IsHigherCodeRate (reqMode))
787  && (thismode.GetModulationClass () == reqMode.GetModulationClass ()))
788  {
789  mode = thismode;
790  //As above; we've found a potentially-suitable transmit
791  //rate, but we need to continue and consider all the
792  //mandatory rates before we can be sure we've got the right one.
793  found = true;
794  }
795  }
796  }
797 
807  if (!found)
808  {
809  NS_FATAL_ERROR ("Can't find response rate for " << reqMode);
810  }
811 
812  NS_LOG_DEBUG ("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
813  return mode;
814 }
815 
816 void
818 {
819  NS_LOG_FUNCTION (this << header);
820  NS_ASSERT (!header.GetAddr1 ().IsGroup ());
821  AcIndex ac = QosUtilsMapTidToAc ((header.IsQosData ()) ? header.GetQosTid () : 0);
822  m_ssrc[ac]++;
823  m_macTxRtsFailed (header.GetAddr1 ());
824  DoReportRtsFailed (Lookup (header.GetAddr1 ()));
825 }
826 
827 void
829 {
830  NS_LOG_FUNCTION (this << *mpdu);
831  NS_ASSERT (!mpdu->GetHeader ().GetAddr1 ().IsGroup ());
832  AcIndex ac = QosUtilsMapTidToAc ((mpdu->GetHeader ().IsQosData ()) ? mpdu->GetHeader ().GetQosTid () : 0);
833  bool longMpdu = (mpdu->GetSize () > m_rtsCtsThreshold);
834  if (longMpdu)
835  {
836  m_slrc[ac]++;
837  }
838  else
839  {
840  m_ssrc[ac]++;
841  }
842  m_macTxDataFailed (mpdu->GetHeader ().GetAddr1 ());
843  DoReportDataFailed (Lookup (mpdu->GetHeader ().GetAddr1 ()));
844 }
845 
846 void
848  double ctsSnr, WifiMode ctsMode, double rtsSnr)
849 {
850  NS_LOG_FUNCTION (this << header << ctsSnr << ctsMode << rtsSnr);
851  NS_ASSERT (!header.GetAddr1 ().IsGroup ());
852  WifiRemoteStation *station = Lookup (header.GetAddr1 ());
853  AcIndex ac = QosUtilsMapTidToAc ((header.IsQosData ()) ? header.GetQosTid () : 0);
854  station->m_state->m_info.NotifyTxSuccess (m_ssrc[ac]);
855  m_ssrc[ac] = 0;
856  DoReportRtsOk (station, ctsSnr, ctsMode, rtsSnr);
857 }
858 
859 void
861  WifiMode ackMode, double dataSnr, WifiTxVector dataTxVector)
862 {
863  NS_LOG_FUNCTION (this << *mpdu << ackSnr << ackMode << dataSnr << dataTxVector);
864  const WifiMacHeader& hdr = mpdu->GetHeader ();
865  NS_ASSERT (!hdr.GetAddr1 ().IsGroup ());
866  WifiRemoteStation *station = Lookup (hdr.GetAddr1 ());
867  AcIndex ac = QosUtilsMapTidToAc ((hdr.IsQosData ()) ? hdr.GetQosTid () : 0);
868  bool longMpdu = (mpdu->GetSize () > m_rtsCtsThreshold);
869  if (longMpdu)
870  {
871  station->m_state->m_info.NotifyTxSuccess (m_slrc[ac]);
872  m_slrc[ac] = 0;
873  }
874  else
875  {
876  station->m_state->m_info.NotifyTxSuccess (m_ssrc[ac]);
877  m_ssrc[ac] = 0;
878  }
879  DoReportDataOk (station, ackSnr, ackMode, dataSnr, dataTxVector.GetChannelWidth (),
880  dataTxVector.GetNss (GetStaId (hdr.GetAddr1 (), dataTxVector)));
881 }
882 
883 void
885 {
886  NS_LOG_FUNCTION (this << header);
887  NS_ASSERT (!header.GetAddr1 ().IsGroup ());
888  WifiRemoteStation *station = Lookup (header.GetAddr1 ());
889  AcIndex ac = QosUtilsMapTidToAc ((header.IsQosData ()) ? header.GetQosTid () : 0);
890  station->m_state->m_info.NotifyTxFailed ();
891  m_ssrc[ac] = 0;
892  m_macTxFinalRtsFailed (header.GetAddr1 ());
893  DoReportFinalRtsFailed (station);
894 }
895 
896 void
898 {
899  NS_LOG_FUNCTION (this << *mpdu);
900  NS_ASSERT (!mpdu->GetHeader ().GetAddr1 ().IsGroup ());
901  WifiRemoteStation *station = Lookup (mpdu->GetHeader ().GetAddr1 ());
902  AcIndex ac = QosUtilsMapTidToAc ((mpdu->GetHeader ().IsQosData ()) ? mpdu->GetHeader ().GetQosTid () : 0);
903  station->m_state->m_info.NotifyTxFailed ();
904  bool longMpdu = (mpdu->GetSize () > m_rtsCtsThreshold);
905  if (longMpdu)
906  {
907  m_slrc[ac] = 0;
908  }
909  else
910  {
911  m_ssrc[ac] = 0;
912  }
913  m_macTxFinalDataFailed (mpdu->GetHeader ().GetAddr1 ());
914  DoReportFinalDataFailed (station);
915 }
916 
917 void
919 {
920  NS_LOG_FUNCTION (this << address << rxSignalInfo << txVector);
921  if (address.IsGroup ())
922  {
923  return;
924  }
925  WifiRemoteStation *station = Lookup (address);
926  DoReportRxOk (station, rxSignalInfo.snr, txVector.GetMode (GetStaId (address, txVector)));
927  station->m_rssiAndUpdateTimePair = std::make_pair (rxSignalInfo.rssi, Simulator::Now ());
928 }
929 
930 void
932  uint16_t nSuccessfulMpdus, uint16_t nFailedMpdus,
933  double rxSnr, double dataSnr, WifiTxVector dataTxVector)
934 {
935  NS_LOG_FUNCTION (this << address << nSuccessfulMpdus << nFailedMpdus << rxSnr << dataSnr << dataTxVector);
936  NS_ASSERT (!address.IsGroup ());
937  for (uint8_t i = 0; i < nFailedMpdus; i++)
938  {
940  }
941  DoReportAmpduTxStatus (Lookup (address), nSuccessfulMpdus, nFailedMpdus, rxSnr, dataSnr, dataTxVector.GetChannelWidth (), dataTxVector.GetNss (GetStaId (address, dataTxVector)));
942 }
943 
944 bool
945 WifiRemoteStationManager::NeedRts (const WifiMacHeader &header, uint32_t size)
946 {
947  NS_LOG_FUNCTION (this << header << size);
948  Mac48Address address = header.GetAddr1 ();
949  WifiTxVector txVector = GetDataTxVector (header);
950  WifiMode mode = txVector.GetMode ();
951  if (address.IsGroup ())
952  {
953  return false;
954  }
957  || (mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
958  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
959  || (mode.GetModulationClass () == WIFI_MOD_CLASS_HE))
961  {
962  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedRTS returning true to protect non-ERP stations");
963  return true;
964  }
965  else if (m_htProtectionMode == RTS_CTS
966  && ((mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
967  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT))
970  {
971  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedRTS returning true to protect non-HT stations");
972  return true;
973  }
974  bool normally = (size > m_rtsCtsThreshold);
975  return DoNeedRts (Lookup (address), size, normally);
976 }
977 
978 bool
980 {
981  WifiMode mode = txVector.GetMode ();
982  NS_LOG_FUNCTION (this << mode);
985  || (mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
986  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
987  || (mode.GetModulationClass () == WIFI_MOD_CLASS_HE))
989  {
990  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true to protect non-ERP stations");
991  return true;
992  }
993  else if (m_htProtectionMode == CTS_TO_SELF
994  && ((mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
995  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT))
998  {
999  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true to protect non-HT stations");
1000  return true;
1001  }
1002  else if (!m_useNonErpProtection)
1003  {
1004  //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
1005  for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
1006  {
1007  if (mode == *i)
1008  {
1009  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
1010  return false;
1011  }
1012  }
1013  if (GetHtSupported ())
1014  {
1015  //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
1016  for (WifiModeListIterator i = m_bssBasicMcsSet.begin (); i != m_bssBasicMcsSet.end (); i++)
1017  {
1018  if (mode == *i)
1019  {
1020  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
1021  return false;
1022  }
1023  }
1024  }
1025  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true");
1026  return true;
1027  }
1028  return false;
1029 }
1030 
1031 void
1033 {
1034  NS_LOG_FUNCTION (this << enable);
1035  m_useNonErpProtection = enable;
1036 }
1037 
1038 bool
1040 {
1041  return m_useNonErpProtection;
1042 }
1043 
1044 void
1046 {
1047  NS_LOG_FUNCTION (this << enable);
1048  m_useNonHtProtection = enable;
1049 }
1050 
1051 bool
1053 {
1054  return m_useNonHtProtection;
1055 }
1056 
1057 bool
1059 {
1060  NS_LOG_FUNCTION (this << *mpdu);
1061  NS_ASSERT (!mpdu->GetHeader ().GetAddr1 ().IsGroup ());
1062  AcIndex ac = QosUtilsMapTidToAc ((mpdu->GetHeader ().IsQosData ()) ? mpdu->GetHeader ().GetQosTid () : 0);
1063  bool longMpdu = (mpdu->GetSize () > m_rtsCtsThreshold);
1064  uint32_t retryCount, maxRetryCount;
1065  if (longMpdu)
1066  {
1067  retryCount = m_slrc[ac];
1068  maxRetryCount = m_maxSlrc;
1069  }
1070  else
1071  {
1072  retryCount = m_ssrc[ac];
1073  maxRetryCount = m_maxSsrc;
1074  }
1075  bool normally = retryCount < maxRetryCount;
1076  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedRetransmission count: " << retryCount << " result: " << std::boolalpha << normally);
1077  return DoNeedRetransmission (Lookup (mpdu->GetHeader ().GetAddr1 ()), mpdu->GetPacket (), normally);
1078 }
1079 
1080 bool
1082 {
1083  NS_LOG_FUNCTION (this << *mpdu);
1084  if (mpdu->GetHeader ().GetAddr1 ().IsGroup ())
1085  {
1086  return false;
1087  }
1088  bool normally = mpdu->GetSize () > GetFragmentationThreshold ();
1089  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedFragmentation result: " << std::boolalpha << normally);
1090  return DoNeedFragmentation (Lookup (mpdu->GetHeader ().GetAddr1 ()), mpdu->GetPacket (), normally);
1091 }
1092 
1093 void
1095 {
1096  NS_LOG_FUNCTION (this << threshold);
1097  if (threshold < 256)
1098  {
1099  /*
1100  * ASN.1 encoding of the MAC and PHY MIB (256 ... 8000)
1101  */
1102  NS_LOG_WARN ("Fragmentation threshold should be larger than 256. Setting to 256.");
1104  }
1105  else
1106  {
1107  /*
1108  * The length of each fragment shall be an even number of octets, except for the last fragment if an MSDU or
1109  * MMPDU, which may be either an even or an odd number of octets.
1110  */
1111  if (threshold % 2 != 0)
1112  {
1113  NS_LOG_WARN ("Fragmentation threshold should be an even number. Setting to " << threshold - 1);
1114  m_fragmentationThreshold = threshold - 1;
1115  }
1116  else
1117  {
1118  m_fragmentationThreshold = threshold;
1119  }
1120  }
1121 }
1122 
1123 uint32_t
1125 {
1126  return m_fragmentationThreshold;
1127 }
1128 
1129 uint32_t
1131 {
1132  NS_LOG_FUNCTION (this << *mpdu);
1133  //The number of bytes a fragment can support is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
1134  uint32_t nFragments = (mpdu->GetPacket ()->GetSize () / (GetFragmentationThreshold () - mpdu->GetHeader ().GetSize () - WIFI_MAC_FCS_LENGTH));
1135 
1136  //If the size of the last fragment is not 0.
1137  if ((mpdu->GetPacket ()->GetSize () % (GetFragmentationThreshold () - mpdu->GetHeader ().GetSize () - WIFI_MAC_FCS_LENGTH)) > 0)
1138  {
1139  nFragments++;
1140  }
1141  NS_LOG_DEBUG ("WifiRemoteStationManager::GetNFragments returning " << nFragments);
1142  return nFragments;
1143 }
1144 
1145 uint32_t
1147 {
1148  NS_LOG_FUNCTION (this << *mpdu << fragmentNumber);
1149  NS_ASSERT (!mpdu->GetHeader ().GetAddr1 ().IsGroup ());
1150  uint32_t nFragment = GetNFragments (mpdu);
1151  if (fragmentNumber >= nFragment)
1152  {
1153  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning 0");
1154  return 0;
1155  }
1156  //Last fragment
1157  if (fragmentNumber == nFragment - 1)
1158  {
1159  uint32_t lastFragmentSize = mpdu->GetPacket ()->GetSize () - (fragmentNumber * (GetFragmentationThreshold () - mpdu->GetHeader ().GetSize () - WIFI_MAC_FCS_LENGTH));
1160  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << lastFragmentSize);
1161  return lastFragmentSize;
1162  }
1163  //All fragments but the last, the number of bytes is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
1164  else
1165  {
1166  uint32_t fragmentSize = GetFragmentationThreshold () - mpdu->GetHeader ().GetSize () - WIFI_MAC_FCS_LENGTH;
1167  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << fragmentSize);
1168  return fragmentSize;
1169  }
1170 }
1171 
1172 uint32_t
1174 {
1175  NS_LOG_FUNCTION (this << *mpdu << fragmentNumber);
1176  NS_ASSERT (!mpdu->GetHeader ().GetAddr1 ().IsGroup ());
1177  NS_ASSERT (fragmentNumber < GetNFragments (mpdu));
1178  uint32_t fragmentOffset = fragmentNumber * (GetFragmentationThreshold () - mpdu->GetHeader ().GetSize () - WIFI_MAC_FCS_LENGTH);
1179  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentOffset returning " << fragmentOffset);
1180  return fragmentOffset;
1181 }
1182 
1183 bool
1185 {
1186  NS_LOG_FUNCTION (this << *mpdu << fragmentNumber);
1187  NS_ASSERT (!mpdu->GetHeader ().GetAddr1 ().IsGroup ());
1188  bool isLast = fragmentNumber == (GetNFragments (mpdu) - 1);
1189  NS_LOG_DEBUG ("WifiRemoteStationManager::IsLastFragment returning " << std::boolalpha << isLast);
1190  return isLast;
1191 }
1192 
1193 uint8_t
1195 {
1196  return m_defaultTxPowerLevel;
1197 }
1198 
1201 {
1203  return state->m_info;
1204 }
1205 
1206 double
1208 {
1209  double rssi = 0.0;
1210  Time mostRecentUpdateTime = NanoSeconds (0);
1211  for (const auto & station : m_stations)
1212  {
1213  if (station->m_state->m_address == address) //get most recent RSSI irrespective of TID
1214  {
1215  if (station->m_rssiAndUpdateTimePair.second >= mostRecentUpdateTime)
1216  {
1217  rssi = station->m_rssiAndUpdateTimePair.first;
1218  mostRecentUpdateTime = station->m_rssiAndUpdateTimePair.second;
1219  }
1220  }
1221  }
1222  NS_ASSERT (mostRecentUpdateTime.IsStrictlyPositive ());
1223  return rssi;
1224 }
1225 
1228 {
1229  NS_LOG_FUNCTION (this << address);
1230  for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
1231  {
1232  if ((*i)->m_address == address)
1233  {
1234  NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning existing state");
1235  return (*i);
1236  }
1237  }
1240  state->m_address = address;
1241  state->m_operationalRateSet.push_back (GetDefaultMode ());
1242  state->m_operationalMcsSet.push_back (GetDefaultMcs ());
1243  state->m_dsssSupported = false;
1244  state->m_erpOfdmSupported = false;
1245  state->m_ofdmSupported = false;
1246  state->m_htCapabilities = 0;
1247  state->m_vhtCapabilities = 0;
1248  state->m_heCapabilities = 0;
1250  state->m_guardInterval = GetGuardInterval ();
1251  state->m_ness = 0;
1252  state->m_aggregation = false;
1253  state->m_qosSupported = false;
1254  const_cast<WifiRemoteStationManager *> (this)->m_states.push_back (state);
1255  NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning new state");
1256  return state;
1257 }
1258 
1261 {
1262  NS_LOG_FUNCTION (this << address);
1263  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1264  {
1265  if ((*i)->m_state->m_address == address)
1266  {
1267  return (*i);
1268  }
1269  }
1271 
1272  WifiRemoteStation *station = DoCreateStation ();
1273  station->m_state = state;
1274  station->m_rssiAndUpdateTimePair = std::make_pair (0, Seconds (0));
1275  const_cast<WifiRemoteStationManager *> (this)->m_stations.push_back (station);
1276  return station;
1277 }
1278 
1279 void
1281 {
1282  NS_LOG_FUNCTION (this << from << qosSupported);
1283  WifiRemoteStationState *state;
1284  state = LookupState (from);
1285  state->m_qosSupported = qosSupported;
1286 }
1287 
1288 void
1290 {
1291  //Used by all stations to record HT capabilities of remote stations
1292  NS_LOG_FUNCTION (this << from << htCapabilities);
1293  WifiRemoteStationState *state;
1294  state = LookupState (from);
1295  if (htCapabilities.GetSupportedChannelWidth () == 1)
1296  {
1297  state->m_channelWidth = 40;
1298  }
1299  else
1300  {
1301  state->m_channelWidth = 20;
1302  }
1303  SetQosSupport (from, true);
1304  for (const auto & mcs : m_wifiPhy->GetMcsList (WIFI_MOD_CLASS_HT))
1305  {
1306  if (htCapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1307  {
1308  AddSupportedMcs (from, mcs);
1309  }
1310  }
1311  state->m_htCapabilities = Create<const HtCapabilities> (htCapabilities);
1312 }
1313 
1314 void
1316 {
1317  //Used by all stations to record VHT capabilities of remote stations
1318  NS_LOG_FUNCTION (this << from << vhtCapabilities);
1319  WifiRemoteStationState *state;
1320  state = LookupState (from);
1321  if (vhtCapabilities.GetSupportedChannelWidthSet () == 1)
1322  {
1323  state->m_channelWidth = 160;
1324  }
1325  else
1326  {
1327  state->m_channelWidth = 80;
1328  }
1329  //This is a workaround to enable users to force a 20 or 40 MHz channel for a VHT-compliant device,
1330  //since IEEE 802.11ac standard says that 20, 40 and 80 MHz channels are mandatory.
1331  if (m_wifiPhy->GetChannelWidth () < state->m_channelWidth)
1332  {
1334  }
1335  for (uint8_t i = 1; i <= m_wifiPhy->GetMaxSupportedTxSpatialStreams (); i++)
1336  {
1337  for (const auto & mcs : m_wifiPhy->GetMcsList (WIFI_MOD_CLASS_VHT))
1338  {
1339  if (vhtCapabilities.IsSupportedMcs (mcs.GetMcsValue (), i))
1340  {
1341  AddSupportedMcs (from, mcs);
1342  }
1343  }
1344  }
1345  state->m_vhtCapabilities = Create<const VhtCapabilities> (vhtCapabilities);
1346 }
1347 
1348 void
1350 {
1351  //Used by all stations to record HE capabilities of remote stations
1352  NS_LOG_FUNCTION (this << from << heCapabilities);
1353  WifiRemoteStationState *state;
1354  state = LookupState (from);
1356  {
1357  if (heCapabilities.GetChannelWidthSet () & 0x04)
1358  {
1359  state->m_channelWidth = 160;
1360  }
1361  else if (heCapabilities.GetChannelWidthSet () & 0x02)
1362  {
1363  state->m_channelWidth = 80;
1364  }
1365  //For other cases at 5 GHz, the supported channel width is set by the VHT capabilities
1366  }
1367  else if (m_wifiPhy->GetPhyBand () == WIFI_PHY_BAND_2_4GHZ)
1368  {
1369  if (heCapabilities.GetChannelWidthSet () & 0x01)
1370  {
1371  state->m_channelWidth = 40;
1372  }
1373  else
1374  {
1375  state->m_channelWidth = 20;
1376  }
1377  }
1378  if (heCapabilities.GetHeLtfAndGiForHePpdus () >= 2)
1379  {
1380  state->m_guardInterval = 800;
1381  }
1382  else if (heCapabilities.GetHeLtfAndGiForHePpdus () == 1)
1383  {
1384  state->m_guardInterval = 1600;
1385  }
1386  else
1387  {
1388  state->m_guardInterval = 3200;
1389  }
1390  for (uint8_t i = 1; i <= m_wifiPhy->GetMaxSupportedTxSpatialStreams (); i++)
1391  {
1392  for (const auto & mcs : m_wifiPhy->GetMcsList (WIFI_MOD_CLASS_HE))
1393  {
1394  if (heCapabilities.GetHighestNssSupported () >= i
1395  && heCapabilities.GetHighestMcsSupported () >= mcs.GetMcsValue ())
1396  {
1397  AddSupportedMcs (from, mcs);
1398  }
1399  }
1400  }
1401  state->m_heCapabilities = Create<const HeCapabilities> (heCapabilities);
1402  SetQosSupport (from, true);
1403 }
1404 
1407 {
1408  return LookupState (from)->m_htCapabilities;
1409 }
1410 
1413 {
1414  return LookupState (from)->m_vhtCapabilities;
1415 }
1416 
1419 {
1420  return LookupState (from)->m_heCapabilities;
1421 }
1422 
1423 bool
1425 {
1429  bool supported = false;
1430  if (htCapabilities)
1431  {
1432  supported |= htCapabilities->GetLdpc ();
1433  }
1434  if (vhtCapabilities)
1435  {
1436  supported |= vhtCapabilities->GetRxLdpc ();
1437  }
1438  if (heCapabilities)
1439  {
1440  supported |= heCapabilities->GetLdpcCodingInPayload ();
1441  }
1442  return supported;
1443 }
1444 
1445 WifiMode
1447 {
1448  return m_defaultTxMode;
1449 }
1450 
1451 WifiMode
1453 {
1454  return m_defaultTxMcs;
1455 }
1456 
1457 void
1459 {
1460  NS_LOG_FUNCTION (this);
1461  for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
1462  {
1463  delete (*i);
1464  }
1465  m_states.clear ();
1466  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1467  {
1468  delete (*i);
1469  }
1470  m_stations.clear ();
1471  m_bssBasicRateSet.clear ();
1472  m_bssBasicMcsSet.clear ();
1473  m_ssrc.fill (0);
1474  m_slrc.fill (0);
1475 }
1476 
1477 void
1479 {
1480  NS_LOG_FUNCTION (this << mode);
1481  if (mode.GetModulationClass () >= WIFI_MOD_CLASS_HT)
1482  {
1483  NS_FATAL_ERROR ("It is not allowed to add a HT rate in the BSSBasicRateSet!");
1484  }
1485  for (uint8_t i = 0; i < GetNBasicModes (); i++)
1486  {
1487  if (GetBasicMode (i) == mode)
1488  {
1489  return;
1490  }
1491  }
1492  m_bssBasicRateSet.push_back (mode);
1493 }
1494 
1495 uint8_t
1497 {
1498  return static_cast<uint8_t> (m_bssBasicRateSet.size ());
1499 }
1500 
1501 WifiMode
1503 {
1504  NS_ASSERT (i < GetNBasicModes ());
1505  return m_bssBasicRateSet[i];
1506 }
1507 
1508 uint32_t
1510 {
1511  uint32_t size = 0;
1512  for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
1513  {
1514  if (i->GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1515  {
1516  continue;
1517  }
1518  size++;
1519  }
1520  return size;
1521 }
1522 
1523 WifiMode
1525 {
1527  uint32_t index = 0;
1528  bool found = false;
1529  for (WifiModeListIterator j = m_bssBasicRateSet.begin (); j != m_bssBasicRateSet.end (); )
1530  {
1531  if (i == index)
1532  {
1533  found = true;
1534  }
1535  if (j->GetModulationClass () != WIFI_MOD_CLASS_ERP_OFDM)
1536  {
1537  if (found)
1538  {
1539  break;
1540  }
1541  }
1542  index++;
1543  j++;
1544  }
1545  return m_bssBasicRateSet[index];
1546 }
1547 
1548 void
1550 {
1551  NS_LOG_FUNCTION (this << +mcs.GetMcsValue ());
1552  for (uint8_t i = 0; i < GetNBasicMcs (); i++)
1553  {
1554  if (GetBasicMcs (i) == mcs)
1555  {
1556  return;
1557  }
1558  }
1559  m_bssBasicMcsSet.push_back (mcs);
1560 }
1561 
1562 uint8_t
1564 {
1565  return static_cast<uint8_t> (m_bssBasicMcsSet.size ());
1566 }
1567 
1568 WifiMode
1570 {
1571  NS_ASSERT (i < GetNBasicMcs ());
1572  return m_bssBasicMcsSet[i];
1573 }
1574 
1575 WifiMode
1577 {
1578  if (m_nonUnicastMode == WifiMode ())
1579  {
1580  if (GetNBasicModes () > 0)
1581  {
1582  return GetBasicMode (0);
1583  }
1584  else
1585  {
1586  return GetDefaultMode ();
1587  }
1588  }
1589  else
1590  {
1591  return m_nonUnicastMode;
1592  }
1593 }
1594 
1595 bool
1597  uint32_t size, bool normally)
1598 {
1599  return normally;
1600 }
1601 
1602 bool
1604  Ptr<const Packet> packet, bool normally)
1605 {
1606  return normally;
1607 }
1608 
1609 bool
1611  Ptr<const Packet> packet, bool normally)
1612 {
1613  return normally;
1614 }
1615 
1616 void
1617 WifiRemoteStationManager::DoReportAmpduTxStatus (WifiRemoteStation *station, uint16_t nSuccessfulMpdus, uint16_t nFailedMpdus, double rxSnr, double dataSnr, uint16_t dataChannelWidth, uint8_t dataNss)
1618 {
1619  NS_LOG_DEBUG ("DoReportAmpduTxStatus received but the manager does not handle A-MPDUs!");
1620 }
1621 
1622 WifiMode
1624 {
1625  NS_ASSERT (i < GetNSupported (station));
1626  return station->m_state->m_operationalRateSet[i];
1627 }
1628 
1629 WifiMode
1631 {
1632  NS_ASSERT (i < GetNMcsSupported (station));
1633  return station->m_state->m_operationalMcsSet[i];
1634 }
1635 
1636 WifiMode
1638 {
1639  NS_ASSERT (i < GetNNonErpSupported (station));
1640  //IEEE 802.11g standard defines that if the protection mechanism is enabled, RTS, CTS and CTS-To-Self
1641  //frames should select a rate in the BSSBasicRateSet that corresponds to an 802.11b basic rate.
1642  //This is a implemented here to avoid changes in every RAA, but should maybe be moved in case it breaks standard rules.
1643  uint32_t index = 0;
1644  bool found = false;
1645  for (WifiModeListIterator j = station->m_state->m_operationalRateSet.begin (); j != station->m_state->m_operationalRateSet.end (); )
1646  {
1647  if (i == index)
1648  {
1649  found = true;
1650  }
1651  if (j->GetModulationClass () != WIFI_MOD_CLASS_ERP_OFDM)
1652  {
1653  if (found)
1654  {
1655  break;
1656  }
1657  }
1658  index++;
1659  j++;
1660  }
1661  return station->m_state->m_operationalRateSet[index];
1662 }
1663 
1666 {
1667  return station->m_state->m_address;
1668 }
1669 
1670 uint16_t
1672 {
1673  return station->m_state->m_channelWidth;
1674 }
1675 
1676 bool
1678 {
1679  Ptr<const HtCapabilities> htCapabilities = station->m_state->m_htCapabilities;
1680 
1681  if (!htCapabilities)
1682  {
1683  return false;
1684  }
1685  return htCapabilities->GetShortGuardInterval20 ();
1686 }
1687 
1688 uint16_t
1690 {
1691  return station->m_state->m_guardInterval;
1692 }
1693 
1694 bool
1696 {
1697  return station->m_state->m_aggregation;
1698 }
1699 
1700 uint8_t
1702 {
1703  Ptr<const HtCapabilities> htCapabilities = station->m_state->m_htCapabilities;
1704 
1705  if (!htCapabilities)
1706  {
1707  return 1;
1708  }
1709  return htCapabilities->GetRxHighestSupportedAntennas ();
1710 }
1711 
1712 uint8_t
1714 {
1715  return station->m_state->m_ness;
1716 }
1717 
1720 {
1721  return m_wifiPhy;
1722 }
1723 
1726 {
1727  return m_wifiMac;
1728 }
1729 
1730 uint8_t
1732 {
1733  return static_cast<uint8_t> (station->m_state->m_operationalRateSet.size ());
1734 }
1735 
1736 bool
1738 {
1739  return station->m_state->m_qosSupported;
1740 }
1741 
1742 bool
1744 {
1745  return (station->m_state->m_htCapabilities != 0);
1746 }
1747 
1748 bool
1750 {
1751  return (station->m_state->m_vhtCapabilities != 0);
1752 }
1753 
1754 bool
1756 {
1757  return (station->m_state->m_heCapabilities != 0);
1758 }
1759 
1760 uint8_t
1762 {
1763  return static_cast<uint8_t> (station->m_state->m_operationalMcsSet.size ());
1764 }
1765 
1766 uint32_t
1768 {
1769  uint32_t size = 0;
1770  for (WifiModeListIterator i = station->m_state->m_operationalRateSet.begin (); i != station->m_state->m_operationalRateSet.end (); i++)
1771  {
1772  if (i->GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1773  {
1774  continue;
1775  }
1776  size++;
1777  }
1778  return size;
1779 }
1780 
1781 uint16_t
1783 {
1785 }
1786 
1787 bool
1789 {
1791 
1792  if (!htCapabilities)
1793  {
1794  return false;
1795  }
1796  return htCapabilities->GetShortGuardInterval20 ();
1797 }
1798 
1799 uint8_t
1801 {
1803 
1804  if (!htCapabilities)
1805  {
1806  return 1;
1807  }
1808  return htCapabilities->GetRxHighestSupportedAntennas ();
1809 }
1810 
1811 uint8_t
1813 {
1814  return static_cast<uint8_t> (LookupState (address)->m_operationalMcsSet.size ());
1815 }
1816 
1817 bool
1819 {
1820  return (LookupState (address)->m_dsssSupported);
1821 }
1822 
1823 bool
1825 {
1826  return (LookupState (address)->m_erpOfdmSupported);
1827 }
1828 
1829 bool
1831 {
1832  return (LookupState (address)->m_ofdmSupported);
1833 }
1834 
1835 bool
1837 {
1838  return (LookupState (address)->m_htCapabilities != 0);
1839 }
1840 
1841 bool
1843 {
1844  return (LookupState (address)->m_vhtCapabilities != 0);
1845 }
1846 
1847 bool
1849 {
1850  return (LookupState (address)->m_heCapabilities != 0);
1851 }
1852 
1853 void
1855 {
1856  m_defaultTxPowerLevel = txPower;
1857 }
1858 
1859 uint8_t
1861 {
1862  return m_wifiPhy->GetNumberOfAntennas ();
1863 }
1864 
1865 uint8_t
1867 {
1869 }
1870 
1871 bool
1873 {
1874  return (GetLdpcSupported () && GetLdpcSupported (dest));
1875 }
1876 
1877 } //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.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
void AddSupportedMcs(Mac48Address address, WifiMode mcs)
Record the MCS index supported by the station.
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.
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...
bool m_erpOfdmSupported
Flag if ERP OFDM is supported by the remote station.
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.
#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.
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
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:70
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.
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:1124
void AddStationVhtCapabilities(Mac48Address from, VhtCapabilities vhtCapabilities)
Records VHT capabilities of the remote station.
std::list< WifiMode > GetModeList(void) const
The WifiPhy::GetModeList() method is used (e.g., by a WifiRemoteStationManager) to determine the set ...
Definition: wifi-phy.cc:2004
bool m_ofdmSupported
Flag if OFDM is supported by the remote station.
Mac48Address GetAddr1(void) const
Return the address in the Address 1 field.
void ReportFinalDataFailed(Ptr< const WifiMacQueueItem > mpdu)
Should be invoked after calling ReportDataFailed if NeedRetransmission returns false.
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
void ReportAmpduTxStatus(Mac48Address address, uint16_t nSuccessfulMpdus, uint16_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...
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 ReportDataFailed(Ptr< const WifiMacQueueItem > mpdu)
Should be invoked whenever the AckTimeout associated to a transmission attempt expires.
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
bool IsStrictlyPositive(void) const
Exactly equivalent to t > 0.
Definition: nstime.h:333
bool IsMu(void) const
Return true if this TX vector is used for a multi-user transmission.
bool GetUseNonHtProtection(void) const
Return whether the device supports protection of non-HT stations.
The 5 GHz band.
Definition: wifi-phy-band.h:37
uint8_t GetNss(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the number of spatial streams.
uint32_t GetNFragments(Ptr< const WifiMacQueueItem > mpdu)
Return the number of fragments needed for the given packet.
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.
void SetLdpc(bool ldpc)
Sets if LDPC FEC coding is being used.
std::list< WifiMode > GetMcsList(void) const
The WifiPhy::GetMcsList() method is used (e.g., by a WifiRemoteStationManager) to determine the set o...
Definition: wifi-phy.cc:2053
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:235
WifiPreamble GetPreambleForTransmission(WifiModulationClass modulation, bool useShortPreamble)
Return the preamble to be used for the transmission.
Definition: wifi-utils.cc:116
void ReportRtsFailed(const WifiMacHeader &header)
Should be invoked whenever the RtsTimeout associated to a transmission attempt expires.
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
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:47
bool m_shortPreambleEnabled
flag if short PHY preamble is enabled
uint8_t GetSupportedChannelWidth(void) const
Return the supported channel width.
bool NeedFragmentation(Ptr< const WifiMacQueueItem > mpdu)
TID independent remote station statistics.
bool NeedRetransmission(Ptr< const WifiMacQueueItem > mpdu)
void ReportRtsOk(const WifiMacHeader &header, double ctsSnr, WifiMode ctsMode, double rtsSnr)
Should be invoked whenever we receive the CTS associated to an RTS we just sent.
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:130
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...
WifiMode GetMode(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the selected payload transmission mode...
HR/DSSS (Clause 16)
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1233
WifiMode GetControlAnswerMode(WifiMode reqMode) const
Get control answer mode function.
void SetShortSlotTimeEnabled(bool enable)
Enable or disable short slot time.
WifiTxVector GetDataTxVector(const WifiMacHeader &header)
std::pair< double, Time > m_rssiAndUpdateTimePair
RSSI (in dBm) of the most recent packet received from the remote station along with update time...
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
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.
RxSignalInfo structure containing info on the received signal.
Definition: phy-entity.h:66
ProtectionMode m_htProtectionMode
Protection mode for HT stations when non-HT stations are detected.
void SetRtsCtsThreshold(uint32_t threshold)
Sets the RTS threshold.
bool GetLdpcSupported(void) const
Return whether the device has LDPC support enabled.
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...
double rssi
RSSI in dBm.
Definition: phy-entity.h:69
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.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1313
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 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:126
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).
virtual void DoReportAmpduTxStatus(WifiRemoteStation *station, uint16_t nSuccessfulMpdus, uint16_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...
void AddStationHeCapabilities(Mac48Address from, HeCapabilities heCapabilities)
Records HE capabilities of the remote station.
uint32_t m_maxSlrc
Maximum STA long retry count (SLRC)
Ptr< const HeCapabilities > GetStationHeCapabilities(Mac48Address from)
Return the HE capabilities sent by the remote station.
bool GetErpOfdmSupported(const Mac48Address &address) const
Return whether the station supports ERP OFDM or not.
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
void ReportDataOk(Ptr< const WifiMacQueueItem > mpdu, double ackSnr, WifiMode ackMode, double dataSnr, WifiTxVector dataTxVector)
Should be invoked whenever we receive the ACK associated to a data packet we just sent...
uint32_t GetNNonErpBasicModes(void) const
Return the number of non-ERP basic modes we support.
WifiTxVector GetCtsTxVector(Mac48Address to, WifiMode rtsTxMode) const
Return a TXVECTOR for the CTS frame given the destination and the mode of the RTS used by the sender...
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:159
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.
WifiModeList m_bssBasicRateSet
This member is the list of WifiMode objects that comprise the BSSBasicRateSet parameter.
bool GetShortSlotTimeEnabled(void) const
Return whether the device uses short slot time.
uint16_t GetStaId(Mac48Address address, const WifiTxVector &txVector) const
If the given TXVECTOR is used for a MU transmission, return the STAID of the station with the given a...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool IsLastFragment(Ptr< const WifiMacQueueItem > mpdu, uint32_t fragmentNumber)
address
Definition: first.py:44
void SetPreambleType(WifiPreamble preamble)
Sets the preamble type.
uint8_t GetNumberOfAntennas(void) const
Definition: wifi-phy.cc:1372
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...
void DoSetFragmentationThreshold(uint32_t threshold)
Actually sets the fragmentation threshold, it also checks the validity of the given threshold...
double GetMostRecentRssi(Mac48Address address) const
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:258
uint32_t GetFragmentOffset(Ptr< const WifiMacQueueItem > mpdu, uint32_t fragmentNumber)
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.
bool GetDsssSupported(const Mac48Address &address) const
Return whether the station supports DSSS or not.
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:246
void SetNTx(uint8_t nTx)
Sets the number of TX antennas.
bool IsAllowedControlAnswerModulationClass(WifiModulationClass modClassReq, WifiModulationClass modClassAnswer)
Return whether the modulation class of the selected mode for the control answer frame is allowed...
Definition: wifi-utils.cc:141
The 2.4 GHz band.
Definition: wifi-phy-band.h:35
bool IsGroup(void) const
bool GetShortGuardIntervalSupported(void) const
Return whether the device has SGI support enabled.
Stations m_stations
Information for each known stations.
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
TracedCallback< Mac48Address > m_macTxDataFailed
The trace source fired when the transmission of a single data packet has failed.
bool GetOfdmSupported(const Mac48Address &address) const
Return whether the station supports OFDM or not.
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 ReportFinalRtsFailed(const WifiMacHeader &header)
Should be invoked after calling ReportRtsFailed if NeedRetransmission returns false.
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.
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.
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.
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)
double snr
SNR in linear scale.
Definition: phy-entity.h:68
#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.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1289
Ptr< const VhtCapabilities > GetStationVhtCapabilities(Mac48Address from)
Return the VHT capabilities sent by the remote station.
WifiTxVector GetRtsTxVector(Mac48Address address)
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.
Ptr< NetDevice > GetDevice(void) const
Return the device this PHY is associated with.
Definition: wifi-phy.cc:783
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:39
uint16_t GetChannelWidth(void) const
WifiTxVector GetBlockAckTxVector(Mac48Address to, const WifiTxVector &dataTxVector) const
Return a TXVECTOR for the BlockAck frame given the destination and the mode of the Data used by the s...
bool UseLdpcForDestination(Mac48Address dest) const
uint16_t GetAssociationId(void) const
Return the association ID.
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
WifiTxVector GetAckTxVector(Mac48Address to, const WifiTxVector &dataTxVector) const
Return a TXVECTOR for the Ack frame given the destination and the mode of the Data used by the sender...
AttributeValue implementation for WifiMode.
Definition: wifi-mode.h:246
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)
void ReportRxOk(Mac48Address address, RxSignalInfo rxSignalInfo, WifiTxVector txVector)
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:137
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
uint32_t GetFragmentSize(Ptr< const WifiMacQueueItem > mpdu, uint32_t fragmentNumber)
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:1403
a unique identifier for an interface.
Definition: type-id.h:58
bool IsHigherDataRate(WifiMode mode) const
Definition: wifi-mode.cc:181
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
#define SU_STA_ID
Definition: wifi-mode.h:32
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.
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.
static WifiMode GetHtMcs(uint8_t index)
Return the HT MCS corresponding to the provided index.
Definition: ht-phy.cc:456
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.
uint16_t GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the station.
bool m_dsssSupported
Flag if DSSS is supported by the remote station.
bool IsAssociated(void) const
Return whether we are associated with an AP.
uint8_t GetNess(const WifiRemoteStation *station) const
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.