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-utils.h"
30 #include "wifi-mac-header.h"
31 #include "wifi-mac-trailer.h"
32 #include "ht-configuration.h"
33 #include "vht-configuration.h"
34 #include "he-configuration.h"
35 #include "wifi-net-device.h"
36 
37 namespace ns3 {
38 
39 NS_LOG_COMPONENT_DEFINE ("WifiRemoteStationManager");
40 
41 NS_OBJECT_ENSURE_REGISTERED (WifiRemoteStationManager);
42 
43 TypeId
45 {
46  static TypeId tid = TypeId ("ns3::WifiRemoteStationManager")
47  .SetParent<Object> ()
48  .SetGroupName ("Wifi")
49  .AddAttribute ("MaxSsrc",
50  "The maximum number of retransmission attempts for any packet with size <= RtsCtsThreshold. "
51  "This value will not have any effect on some rate control algorithms.",
52  UintegerValue (7),
54  MakeUintegerChecker<uint32_t> ())
55  .AddAttribute ("MaxSlrc",
56  "The maximum number of retransmission attempts for any packet with size > RtsCtsThreshold. "
57  "This value will not have any effect on some rate control algorithms.",
58  UintegerValue (4),
60  MakeUintegerChecker<uint32_t> ())
61  .AddAttribute ("RtsCtsThreshold",
62  "If the size of the PSDU is bigger than this value, we use an RTS/CTS handshake before sending the data frame."
63  "This value will not have any effect on some rate control algorithms.",
64  UintegerValue (65535),
66  MakeUintegerChecker<uint32_t> ())
67  .AddAttribute ("FragmentationThreshold",
68  "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. "
69  "This value does not apply when it is carried in an A-MPDU. "
70  "This value will not have any effect on some rate control algorithms.",
71  UintegerValue (65535),
74  MakeUintegerChecker<uint32_t> ())
75  .AddAttribute ("NonUnicastMode",
76  "Wifi mode used for non-unicast transmissions.",
77  WifiModeValue (),
80  .AddAttribute ("DefaultTxPowerLevel",
81  "Default power level to be used for transmissions. "
82  "This is the power level that is used by all those WifiManagers that do not implement TX power control.",
83  UintegerValue (0),
85  MakeUintegerChecker<uint8_t> ())
86  .AddAttribute ("ErpProtectionMode",
87  "Protection mode used when non-ERP STAs are connected to an ERP AP: Rts-Cts or Cts-To-Self",
92  .AddAttribute ("HtProtectionMode",
93  "Protection mode used when non-HT STAs are connected to a HT AP: Rts-Cts or Cts-To-Self",
98  .AddTraceSource ("MacTxRtsFailed",
99  "The transmission of a RTS by the MAC layer has failed",
101  "ns3::Mac48Address::TracedCallback")
102  .AddTraceSource ("MacTxDataFailed",
103  "The transmission of a data packet by the MAC layer has failed",
105  "ns3::Mac48Address::TracedCallback")
106  .AddTraceSource ("MacTxFinalRtsFailed",
107  "The transmission of a RTS has exceeded the maximum number of attempts",
109  "ns3::Mac48Address::TracedCallback")
110  .AddTraceSource ("MacTxFinalDataFailed",
111  "The transmission of a data packet has exceeded the maximum number of attempts",
113  "ns3::Mac48Address::TracedCallback")
114  ;
115  return tid;
116 }
117 
119  : m_pcfSupported (false),
120  m_useNonErpProtection (false),
121  m_useNonHtProtection (false),
122  m_useGreenfieldProtection (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->GetMode (0);
153  if (GetHtSupported ())
154  {
155  m_defaultTxMcs = phy->GetMcs (0);
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 void
172 {
173  NS_LOG_FUNCTION (this << maxSsrc);
174  m_maxSsrc = maxSsrc;
175 }
176 
177 void
179 {
180  NS_LOG_FUNCTION (this << maxSlrc);
181  m_maxSlrc = maxSlrc;
182 }
183 
184 void
186 {
187  NS_LOG_FUNCTION (this << threshold);
188  m_rtsCtsThreshold = threshold;
189 }
190 
191 void
193 {
194  NS_LOG_FUNCTION (this << threshold);
195  DoSetFragmentationThreshold (threshold);
196 }
197 
198 void
200 {
201  NS_LOG_FUNCTION (this << enable);
202  m_shortPreambleEnabled = enable;
203 }
204 
205 void
207 {
208  NS_LOG_FUNCTION (this << enable);
209  m_shortSlotTimeEnabled = enable;
210 }
211 
212 bool
214 {
215  return m_shortSlotTimeEnabled;
216 }
217 
218 bool
220 {
221  return m_shortPreambleEnabled;
222 }
223 
224 bool
226 {
227  Ptr<WifiNetDevice> device = DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ());
228  Ptr<HtConfiguration> htConfiguration = device->GetHtConfiguration ();
229  if (htConfiguration)
230  {
231  return true;
232  }
233  return false;
234 }
235 
236 bool
238 {
239  Ptr<WifiNetDevice> device = DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ());
240  Ptr<VhtConfiguration> vhtConfiguration = device->GetVhtConfiguration ();
241  if (vhtConfiguration)
242  {
243  return true;
244  }
245  return false;
246 }
247 
248 bool
250 {
251  Ptr<WifiNetDevice> device = DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ());
252  Ptr<HeConfiguration> heConfiguration = device->GetHeConfiguration ();
253  if (heConfiguration)
254  {
255  return true;
256  }
257  return false;
258 }
259 
260 void
262 {
263  m_pcfSupported = enable;
264 }
265 
266 bool
268 {
269  return m_pcfSupported;
270 }
271 
272 bool
274 {
275  if (GetHtSupported ())
276  {
277  Ptr<WifiNetDevice> device = DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ());
278  Ptr<HtConfiguration> htConfiguration = device->GetHtConfiguration ();
279  NS_ASSERT (htConfiguration); //If HT is supported, we should have a HT configuration attached
280  if (htConfiguration->GetGreenfieldSupported ())
281  {
282  return true;
283  }
284  }
285  return false;
286 }
287 
288 bool
290 {
291  if (GetHtSupported ())
292  {
293  Ptr<WifiNetDevice> device = DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ());
294  Ptr<HtConfiguration> htConfiguration = device->GetHtConfiguration ();
295  NS_ASSERT (htConfiguration); //If HT is supported, we should have a HT configuration attached
296  if (htConfiguration->GetShortGuardIntervalSupported ())
297  {
298  return true;
299  }
300  }
301  return false;
302 }
303 
304 uint16_t
306 {
307  uint16_t gi = 0;
308  if (GetHeSupported ())
309  {
310  Ptr<WifiNetDevice> device = DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ());
311  Ptr<HeConfiguration> heConfiguration = device->GetHeConfiguration ();
312  NS_ASSERT (heConfiguration); //If HE is supported, we should have a HE configuration attached
313  gi = static_cast<uint16_t>(heConfiguration->GetGuardInterval ().GetNanoSeconds ());
314  }
315  return gi;
316 }
317 
318 uint32_t
320 {
321  return DoGetFragmentationThreshold ();
322 }
323 
324 void
326 {
327  NS_LOG_FUNCTION (this << address << isShortPreambleSupported);
328  NS_ASSERT (!address.IsGroup ());
330  state->m_shortPreamble = isShortPreambleSupported;
331 }
332 
333 void
335 {
336  NS_LOG_FUNCTION (this << address << isShortSlotTimeSupported);
337  NS_ASSERT (!address.IsGroup ());
339  state->m_shortSlotTime = isShortSlotTimeSupported;
340 }
341 
342 void
344 {
345  NS_LOG_FUNCTION (this << address << mode);
346  NS_ASSERT (!address.IsGroup ());
348  for (WifiModeListIterator i = state->m_operationalRateSet.begin (); i != state->m_operationalRateSet.end (); i++)
349  {
350  if ((*i) == mode)
351  {
352  //already in.
353  return;
354  }
355  }
356  state->m_operationalRateSet.push_back (mode);
357 }
358 
359 void
361 {
362  NS_LOG_FUNCTION (this << address);
363  NS_ASSERT (!address.IsGroup ());
365  state->m_operationalRateSet.clear ();
366  for (uint8_t i = 0; i < m_wifiPhy->GetNModes (); i++)
367  {
368  state->m_operationalRateSet.push_back (m_wifiPhy->GetMode (i));
369  if (m_wifiPhy->GetMode (i).IsMandatory ())
370  {
372  }
373  }
374 }
375 
376 void
378 {
379  NS_LOG_FUNCTION (this << address);
380  NS_ASSERT (!address.IsGroup ());
382  state->m_operationalMcsSet.clear ();
383  for (uint8_t i = 0; i < m_wifiPhy->GetNMcs (); i++)
384  {
385  state->m_operationalMcsSet.push_back (m_wifiPhy->GetMcs (i));
386  }
387 }
388 
389 void
391 {
392  NS_LOG_FUNCTION (this << address);
393  NS_ASSERT (!address.IsGroup ());
395  state->m_operationalMcsSet.clear ();
396 }
397 
398 void
400 {
401  NS_LOG_FUNCTION (this << address << mcs);
402  NS_ASSERT (!address.IsGroup ());
404  for (WifiModeListIterator i = state->m_operationalMcsSet.begin (); i != state->m_operationalMcsSet.end (); i++)
405  {
406  if ((*i) == mcs)
407  {
408  //already in.
409  return;
410  }
411  }
412  state->m_operationalMcsSet.push_back (mcs);
413 }
414 
415 bool
417 {
419 }
420 
421 bool
423 {
425 }
426 
427 bool
429 {
431 }
432 
433 bool
435 {
436  if (address.IsGroup ())
437  {
438  return false;
439  }
441 }
442 
443 bool
445 {
446  if (address.IsGroup ())
447  {
448  return true;
449  }
451 }
452 
453 bool
455 {
456  if (address.IsGroup ())
457  {
458  return false;
459  }
461 }
462 
463 void
465 {
466  NS_ASSERT (!address.IsGroup ());
468 }
469 
470 void
472 {
473  NS_ASSERT (!address.IsGroup ());
475 }
476 
477 void
479 {
480  NS_ASSERT (!address.IsGroup ());
482 }
483 
484 void
486 {
487  NS_ASSERT (!address.IsGroup ());
489 }
490 
493 {
494  NS_LOG_FUNCTION (this << header);
495  Mac48Address address = header.GetAddr1 ();
496  if (!header.IsMgt () && address.IsGroup ())
497  {
498  WifiMode mode = GetNonUnicastMode ();
499  WifiTxVector v;
500  v.SetMode (mode);
504  v.SetGuardInterval (ConvertGuardIntervalToNanoSeconds (mode, DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ())));
505  v.SetNTx (1);
506  v.SetNss (1);
507  v.SetNess (0);
508  v.SetStbc (0);
509  return v;
510  }
511  WifiTxVector txVector;
512  if (header.IsMgt ())
513  {
514  //Use the lowest basic rate for management frames
515  WifiMode mgtMode;
516  if (GetNBasicModes () > 0)
517  {
518  mgtMode = GetBasicMode (0);
519  }
520  else
521  {
522  mgtMode = GetDefaultMode ();
523  }
524  txVector.SetMode (mgtMode);
528  txVector.SetGuardInterval (ConvertGuardIntervalToNanoSeconds (mgtMode, DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ())));
529  }
530  else
531  {
532  txVector = DoGetDataTxVector (Lookup (address));
533  }
534  Ptr<WifiNetDevice> device = DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ());
535  Ptr<HeConfiguration> heConfiguration = device->GetHeConfiguration ();
536  if (heConfiguration)
537  {
538  UintegerValue bssColor;
539  heConfiguration->GetAttribute ("BssColor", bssColor);
540  txVector.SetBssColor (bssColor.Get ());
541  }
542  return txVector;
543 }
544 
547 {
548  WifiMode defaultMode = GetDefaultMode ();
549  WifiPreamble defaultPreamble;
550  if (defaultMode.GetModulationClass () == WIFI_MOD_CLASS_HE)
551  {
552  defaultPreamble = WIFI_PREAMBLE_HE_SU;
553  }
554  else if (defaultMode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
555  {
556  defaultPreamble = WIFI_PREAMBLE_VHT_SU;
557  }
558  else if (defaultMode.GetModulationClass () == WIFI_MOD_CLASS_HT)
559  {
560  defaultPreamble = WIFI_PREAMBLE_HT_MF;
561  }
562  else
563  {
564  defaultPreamble = WIFI_PREAMBLE_LONG;
565  }
566 
567  return WifiTxVector (defaultMode,
569  defaultPreamble,
570  ConvertGuardIntervalToNanoSeconds (defaultMode, DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ())),
573  0,
575  false,
576  false);
577 }
578 
581 {
582  NS_LOG_FUNCTION (this << address);
583  if (address.IsGroup ())
584  {
585  WifiMode mode = GetNonUnicastMode ();
586  WifiTxVector v;
587  v.SetMode (mode);
591  v.SetGuardInterval (ConvertGuardIntervalToNanoSeconds (mode, DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ())));
592  v.SetNTx (1);
593  v.SetNss (1);
594  v.SetNess (0);
595  v.SetStbc (0);
596  return v;
597  }
598  return DoGetRtsTxVector (Lookup (address));
599 }
600 
601 void
603 {
604  NS_LOG_FUNCTION (this << address << *header);
605  NS_ASSERT (!address.IsGroup ());
606  AcIndex ac = QosUtilsMapTidToAc ((header->IsQosData ()) ? header->GetQosTid () : 0);
607  m_ssrc[ac]++;
610 }
611 
612 void
614  uint32_t packetSize)
615 {
616  NS_LOG_FUNCTION (this << address << *header);
617  NS_ASSERT (!address.IsGroup ());
618  AcIndex ac = QosUtilsMapTidToAc ((header->IsQosData ()) ? header->GetQosTid () : 0);
619  bool longMpdu = (packetSize + header->GetSize () + WIFI_MAC_FCS_LENGTH) > m_rtsCtsThreshold;
620  if (longMpdu)
621  {
622  m_slrc[ac]++;
623  }
624  else
625  {
626  m_ssrc[ac]++;
627  }
630 }
631 
632 void
634  double ctsSnr, WifiMode ctsMode, double rtsSnr)
635 {
636  NS_LOG_FUNCTION (this << address << *header << ctsSnr << ctsMode << rtsSnr);
637  NS_ASSERT (!address.IsGroup ());
638  WifiRemoteStation *station = Lookup (address);
639  AcIndex ac = QosUtilsMapTidToAc ((header->IsQosData ()) ? header->GetQosTid () : 0);
640  station->m_state->m_info.NotifyTxSuccess (m_ssrc[ac]);
641  m_ssrc[ac] = 0;
642  DoReportRtsOk (station, ctsSnr, ctsMode, rtsSnr);
643 }
644 
645 void
647  double ackSnr, WifiMode ackMode, double dataSnr,
648  WifiTxVector dataTxVector, uint32_t packetSize)
649 {
650  NS_LOG_FUNCTION (this << address << *header << ackSnr << ackMode << dataSnr << dataTxVector << packetSize);
651  NS_ASSERT (!address.IsGroup ());
652  WifiRemoteStation *station = Lookup (address);
653  AcIndex ac = QosUtilsMapTidToAc ((header->IsQosData ()) ? header->GetQosTid () : 0);
654  bool longMpdu = (packetSize + header->GetSize () + WIFI_MAC_FCS_LENGTH) > m_rtsCtsThreshold;
655  if (longMpdu)
656  {
657  station->m_state->m_info.NotifyTxSuccess (m_slrc[ac]);
658  m_slrc[ac] = 0;
659  }
660  else
661  {
662  station->m_state->m_info.NotifyTxSuccess (m_ssrc[ac]);
663  m_ssrc[ac] = 0;
664  }
665  DoReportDataOk (station, ackSnr, ackMode, dataSnr, dataTxVector.GetChannelWidth (), dataTxVector.GetNss ());
666 }
667 
668 void
670 {
671  NS_LOG_FUNCTION (this << address << *header);
672  NS_ASSERT (!address.IsGroup ());
673  WifiRemoteStation *station = Lookup (address);
674  AcIndex ac = QosUtilsMapTidToAc ((header->IsQosData ()) ? header->GetQosTid () : 0);
675  station->m_state->m_info.NotifyTxFailed ();
676  m_ssrc[ac] = 0;
678  DoReportFinalRtsFailed (station);
679 }
680 
681 void
683  uint32_t packetSize)
684 {
685  NS_LOG_FUNCTION (this << address << *header);
686  NS_ASSERT (!address.IsGroup ());
687  WifiRemoteStation *station = Lookup (address);
688  AcIndex ac = QosUtilsMapTidToAc ((header->IsQosData ()) ? header->GetQosTid () : 0);
689  station->m_state->m_info.NotifyTxFailed ();
690  bool longMpdu = (packetSize + header->GetSize () + WIFI_MAC_FCS_LENGTH) > m_rtsCtsThreshold;
691  if (longMpdu)
692  {
693  m_slrc[ac] = 0;
694  }
695  else
696  {
697  m_ssrc[ac] = 0;
698  }
700  DoReportFinalDataFailed (station);
701 }
702 
703 void
705 {
706  NS_LOG_FUNCTION (this << address << rxSnr << txMode);
707  if (address.IsGroup ())
708  {
709  return;
710  }
711  DoReportRxOk (Lookup (address), rxSnr, txMode);
712 }
713 
714 void
716  uint8_t nSuccessfulMpdus, uint8_t nFailedMpdus,
717  double rxSnr, double dataSnr, WifiTxVector dataTxVector)
718 {
719  NS_LOG_FUNCTION (this << address << +nSuccessfulMpdus << +nFailedMpdus << rxSnr << dataSnr << dataTxVector);
720  NS_ASSERT (!address.IsGroup ());
721  for (uint8_t i = 0; i < nFailedMpdus; i++)
722  {
724  }
725  DoReportAmpduTxStatus (Lookup (address), nSuccessfulMpdus, nFailedMpdus, rxSnr, dataSnr, dataTxVector.GetChannelWidth (), dataTxVector.GetNss ());
726 }
727 
728 bool
729 WifiRemoteStationManager::NeedRts (const WifiMacHeader &header, uint32_t size)
730 {
731  NS_LOG_FUNCTION (this << header << size);
732  Mac48Address address = header.GetAddr1 ();
733  WifiTxVector txVector = GetDataTxVector (header);
734  WifiMode mode = txVector.GetMode ();
735  if (address.IsGroup ())
736  {
737  return false;
738  }
741  || (mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
742  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
743  || (mode.GetModulationClass () == WIFI_MOD_CLASS_HE))
745  {
746  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedRTS returning true to protect non-ERP stations");
747  return true;
748  }
749  else if (m_htProtectionMode == RTS_CTS
750  && ((mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
751  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT))
754  {
755  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedRTS returning true to protect non-HT stations");
756  return true;
757  }
758  bool normally = (size > m_rtsCtsThreshold);
759  return DoNeedRts (Lookup (address), size, normally);
760 }
761 
762 bool
764 {
765  WifiMode mode = txVector.GetMode ();
766  NS_LOG_FUNCTION (this << mode);
769  || (mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
770  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
771  || (mode.GetModulationClass () == WIFI_MOD_CLASS_HE))
773  {
774  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true to protect non-ERP stations");
775  return true;
776  }
777  else if (m_htProtectionMode == CTS_TO_SELF
778  && ((mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
779  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT))
782  {
783  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true to protect non-HT stations");
784  return true;
785  }
786  else if (!m_useNonErpProtection)
787  {
788  //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
789  for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
790  {
791  if (mode == *i)
792  {
793  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
794  return false;
795  }
796  }
797  if (GetHtSupported ())
798  {
799  //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
800  for (WifiModeListIterator i = m_bssBasicMcsSet.begin (); i != m_bssBasicMcsSet.end (); i++)
801  {
802  if (mode == *i)
803  {
804  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
805  return false;
806  }
807  }
808  }
809  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true");
810  return true;
811  }
812  return false;
813 }
814 
815 void
817 {
818  NS_LOG_FUNCTION (this << enable);
819  m_useNonErpProtection = enable;
820 }
821 
822 bool
824 {
825  return m_useNonErpProtection;
826 }
827 
828 void
830 {
831  NS_LOG_FUNCTION (this << enable);
832  m_useNonHtProtection = enable;
833 }
834 
835 bool
837 {
838  return m_useNonHtProtection;
839 }
840 
841 void
843 {
844  NS_LOG_FUNCTION (this << enable);
845  m_useGreenfieldProtection = enable;
846 }
847 
848 bool
850 {
852 }
853 
854 bool
856  Ptr<const Packet> packet)
857 {
858  NS_LOG_FUNCTION (this << address << packet << *header);
859  NS_ASSERT (!address.IsGroup ());
860  AcIndex ac = QosUtilsMapTidToAc ((header->IsQosData ()) ? header->GetQosTid () : 0);
861  bool longMpdu = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > m_rtsCtsThreshold;
862  uint32_t retryCount, maxRetryCount;
863  if (longMpdu)
864  {
865  retryCount = m_slrc[ac];
866  maxRetryCount = m_maxSlrc;
867  }
868  else
869  {
870  retryCount = m_ssrc[ac];
871  maxRetryCount = m_maxSsrc;
872  }
873  bool normally = retryCount < maxRetryCount;
874  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedRetransmission count: " << retryCount << " result: " << std::boolalpha << normally);
875  return DoNeedRetransmission (Lookup (address), packet, normally);
876 }
877 
878 bool
880  Ptr<const Packet> packet)
881 {
882  NS_LOG_FUNCTION (this << address << packet << *header);
883  if (address.IsGroup ())
884  {
885  return false;
886  }
887  bool normally = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > GetFragmentationThreshold ();
888  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedFragmentation result: " << std::boolalpha << normally);
889  return DoNeedFragmentation (Lookup (address), packet, normally);
890 }
891 
892 void
894 {
895  NS_LOG_FUNCTION (this << threshold);
896  if (threshold < 256)
897  {
898  /*
899  * ASN.1 encoding of the MAC and PHY MIB (256 ... 8000)
900  */
901  NS_LOG_WARN ("Fragmentation threshold should be larger than 256. Setting to 256.");
903  }
904  else
905  {
906  /*
907  * The length of each fragment shall be an even number of octets, except for the last fragment if an MSDU or
908  * MMPDU, which may be either an even or an odd number of octets.
909  */
910  if (threshold % 2 != 0)
911  {
912  NS_LOG_WARN ("Fragmentation threshold should be an even number. Setting to " << threshold - 1);
913  m_nextFragmentationThreshold = threshold - 1;
914  }
915  else
916  {
917  m_nextFragmentationThreshold = threshold;
918  }
919  }
920 }
921 
922 void
924 {
926 }
927 
928 uint32_t
930 {
932 }
933 
934 uint32_t
936 {
937  NS_LOG_FUNCTION (this << *header << packet);
938  //The number of bytes a fragment can support is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
939  uint32_t nFragments = (packet->GetSize () / (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
940 
941  //If the size of the last fragment is not 0.
942  if ((packet->GetSize () % (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH)) > 0)
943  {
944  nFragments++;
945  }
946  NS_LOG_DEBUG ("WifiRemoteStationManager::GetNFragments returning " << nFragments);
947  return nFragments;
948 }
949 
950 uint32_t
952  Ptr<const Packet> packet, uint32_t fragmentNumber)
953 {
954  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
955  NS_ASSERT (!address.IsGroup ());
956  uint32_t nFragment = GetNFragments (header, packet);
957  if (fragmentNumber >= nFragment)
958  {
959  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning 0");
960  return 0;
961  }
962  //Last fragment
963  if (fragmentNumber == nFragment - 1)
964  {
965  uint32_t lastFragmentSize = packet->GetSize () - (fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
966  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << lastFragmentSize);
967  return lastFragmentSize;
968  }
969  //All fragments but the last, the number of bytes is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
970  else
971  {
972  uint32_t fragmentSize = GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH;
973  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << fragmentSize);
974  return fragmentSize;
975  }
976 }
977 
978 uint32_t
980  Ptr<const Packet> packet, uint32_t fragmentNumber)
981 {
982  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
983  NS_ASSERT (!address.IsGroup ());
984  NS_ASSERT (fragmentNumber < GetNFragments (header, packet));
985  uint32_t fragmentOffset = fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH);
986  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentOffset returning " << fragmentOffset);
987  return fragmentOffset;
988 }
989 
990 bool
992  Ptr<const Packet> packet, uint32_t fragmentNumber)
993 {
994  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
995  NS_ASSERT (!address.IsGroup ());
996  bool isLast = fragmentNumber == (GetNFragments (header, packet) - 1);
997  NS_LOG_DEBUG ("WifiRemoteStationManager::IsLastFragment returning " << std::boolalpha << isLast);
998  return isLast;
999 }
1000 
1001 uint8_t
1003 {
1004  return m_defaultTxPowerLevel;
1005 }
1006 
1009 {
1011  return state->m_info;
1012 }
1013 
1016 {
1017  NS_LOG_FUNCTION (this << address);
1018  for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
1019  {
1020  if ((*i)->m_address == address)
1021  {
1022  NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning existing state");
1023  return (*i);
1024  }
1025  }
1028  state->m_address = address;
1029  state->m_operationalRateSet.push_back (GetDefaultMode ());
1030  state->m_operationalMcsSet.push_back (GetDefaultMcs ());
1031  state->m_htCapabilities = 0;
1032  state->m_vhtCapabilities = 0;
1033  state->m_heCapabilities = 0;
1035  state->m_guardInterval = GetGuardInterval ();
1036  state->m_ness = 0;
1037  state->m_aggregation = false;
1038  state->m_qosSupported = false;
1039  const_cast<WifiRemoteStationManager *> (this)->m_states.push_back (state);
1040  NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning new state");
1041  return state;
1042 }
1043 
1046 {
1047  NS_LOG_FUNCTION (this << address);
1048  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1049  {
1050  if ((*i)->m_state->m_address == address)
1051  {
1052  return (*i);
1053  }
1054  }
1056 
1057  WifiRemoteStation *station = DoCreateStation ();
1058  station->m_state = state;
1059  const_cast<WifiRemoteStationManager *> (this)->m_stations.push_back (station);
1060  return station;
1061 }
1062 
1063 void
1065 {
1066  NS_LOG_FUNCTION (this << from << qosSupported);
1067  WifiRemoteStationState *state;
1068  state = LookupState (from);
1069  state->m_qosSupported = qosSupported;
1070 }
1071 
1072 void
1074 {
1075  //Used by all stations to record HT capabilities of remote stations
1076  NS_LOG_FUNCTION (this << from << htCapabilities);
1077  WifiRemoteStationState *state;
1078  state = LookupState (from);
1079  if (htCapabilities.GetSupportedChannelWidth () == 1)
1080  {
1081  state->m_channelWidth = 40;
1082  }
1083  else
1084  {
1085  state->m_channelWidth = 20;
1086  }
1087  SetQosSupport (from, true);
1088  for (uint8_t j = 0; j < m_wifiPhy->GetNMcs (); j++)
1089  {
1090  WifiMode mcs = m_wifiPhy->GetMcs (j);
1091  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HT && htCapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1092  {
1093  AddSupportedMcs (from, mcs);
1094  }
1095  }
1096  state->m_htCapabilities = Create<const HtCapabilities> (htCapabilities);
1097 }
1098 
1099 void
1101 {
1102  //Used by all stations to record VHT capabilities of remote stations
1103  NS_LOG_FUNCTION (this << from << vhtCapabilities);
1104  WifiRemoteStationState *state;
1105  state = LookupState (from);
1106  if (vhtCapabilities.GetSupportedChannelWidthSet () == 1)
1107  {
1108  state->m_channelWidth = 160;
1109  }
1110  else
1111  {
1112  state->m_channelWidth = 80;
1113  }
1114  //This is a workaround to enable users to force a 20 or 40 MHz channel for a VHT-compliant device,
1115  //since IEEE 802.11ac standard says that 20, 40 and 80 MHz channels are mandatory.
1116  if (m_wifiPhy->GetChannelWidth () < state->m_channelWidth)
1117  {
1119  }
1120  for (uint8_t i = 1; i <= m_wifiPhy->GetMaxSupportedTxSpatialStreams (); i++)
1121  {
1122  for (uint8_t j = 0; j < m_wifiPhy->GetNMcs (); j++)
1123  {
1124  WifiMode mcs = m_wifiPhy->GetMcs (j);
1125  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtCapabilities.IsSupportedMcs (mcs.GetMcsValue (), i))
1126  {
1127  AddSupportedMcs (from, mcs);
1128  }
1129  }
1130  }
1131  state->m_vhtCapabilities = Create<const VhtCapabilities> (vhtCapabilities);
1132 }
1133 
1134 void
1136 {
1137  //Used by all stations to record HE capabilities of remote stations
1138  NS_LOG_FUNCTION (this << from << heCapabilities);
1139  WifiRemoteStationState *state;
1140  state = LookupState (from);
1141  if (Is5Ghz (m_wifiPhy->GetFrequency ()))
1142  {
1143  if (heCapabilities.GetChannelWidthSet () & 0x04)
1144  {
1145  state->m_channelWidth = 160;
1146  }
1147  else if (heCapabilities.GetChannelWidthSet () & 0x02)
1148  {
1149  state->m_channelWidth = 80;
1150  }
1151  //For other cases at 5 GHz, the supported channel width is set by the VHT capabilities
1152  }
1153  else if (Is2_4Ghz (m_wifiPhy->GetFrequency ()))
1154  {
1155  if (heCapabilities.GetChannelWidthSet () & 0x01)
1156  {
1157  state->m_channelWidth = 40;
1158  }
1159  else
1160  {
1161  state->m_channelWidth = 20;
1162  }
1163  }
1164  if (heCapabilities.GetHeLtfAndGiForHePpdus () >= 2)
1165  {
1166  state->m_guardInterval = 800;
1167  }
1168  else if (heCapabilities.GetHeLtfAndGiForHePpdus () == 1)
1169  {
1170  state->m_guardInterval = 1600;
1171  }
1172  else
1173  {
1174  state->m_guardInterval = 3200;
1175  }
1176  for (uint8_t i = 1; i <= m_wifiPhy->GetMaxSupportedTxSpatialStreams (); i++)
1177  {
1178  for (uint8_t j = 0; j < m_wifiPhy->GetNMcs (); j++)
1179  {
1180  WifiMode mcs = m_wifiPhy->GetMcs (j);
1182  && heCapabilities.GetHighestNssSupported () >= i
1183  && heCapabilities.GetHighestMcsSupported () >= j)
1184  {
1185  AddSupportedMcs (from, mcs);
1186  }
1187  }
1188  }
1189  state->m_heCapabilities = Create<const HeCapabilities> (heCapabilities);
1190  SetQosSupport (from, true);
1191 }
1192 
1195 {
1196  return LookupState (from)->m_htCapabilities;
1197 }
1198 
1201 {
1202  return LookupState (from)->m_vhtCapabilities;
1203 }
1204 
1207 {
1208  return LookupState (from)->m_heCapabilities;
1209 }
1210 
1211 bool
1213 {
1215 
1216  if (!htCapabilities)
1217  {
1218  return false;
1219  }
1220  return htCapabilities->GetGreenfield ();
1221 }
1222 
1223 WifiMode
1225 {
1226  return m_defaultTxMode;
1227 }
1228 
1229 WifiMode
1231 {
1232  return m_defaultTxMcs;
1233 }
1234 
1235 void
1237 {
1238  NS_LOG_FUNCTION (this);
1239  for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
1240  {
1241  delete (*i);
1242  }
1243  m_states.clear ();
1244  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1245  {
1246  delete (*i);
1247  }
1248  m_stations.clear ();
1249  m_bssBasicRateSet.clear ();
1250  m_bssBasicMcsSet.clear ();
1251  m_ssrc.fill (0);
1252  m_slrc.fill (0);
1253 }
1254 
1255 void
1257 {
1258  NS_LOG_FUNCTION (this << mode);
1259  if (mode.GetModulationClass () >= WIFI_MOD_CLASS_HT)
1260  {
1261  NS_FATAL_ERROR ("It is not allowed to add a HT rate in the BSSBasicRateSet!");
1262  }
1263  for (uint8_t i = 0; i < GetNBasicModes (); i++)
1264  {
1265  if (GetBasicMode (i) == mode)
1266  {
1267  return;
1268  }
1269  }
1270  m_bssBasicRateSet.push_back (mode);
1271 }
1272 
1273 uint8_t
1275 {
1276  return static_cast<uint8_t> (m_bssBasicRateSet.size ());
1277 }
1278 
1279 WifiMode
1281 {
1282  NS_ASSERT (i < GetNBasicModes ());
1283  return m_bssBasicRateSet[i];
1284 }
1285 
1286 uint32_t
1288 {
1289  uint32_t size = 0;
1290  for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
1291  {
1292  if (i->GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1293  {
1294  continue;
1295  }
1296  size++;
1297  }
1298  return size;
1299 }
1300 
1301 WifiMode
1303 {
1305  uint32_t index = 0;
1306  bool found = false;
1307  for (WifiModeListIterator j = m_bssBasicRateSet.begin (); j != m_bssBasicRateSet.end (); )
1308  {
1309  if (i == index)
1310  {
1311  found = true;
1312  }
1313  if (j->GetModulationClass () != WIFI_MOD_CLASS_ERP_OFDM)
1314  {
1315  if (found)
1316  {
1317  break;
1318  }
1319  }
1320  index++;
1321  j++;
1322  }
1323  return m_bssBasicRateSet[index];
1324 }
1325 
1326 void
1328 {
1329  NS_LOG_FUNCTION (this << +mcs.GetMcsValue ());
1330  for (uint8_t i = 0; i < GetNBasicMcs (); i++)
1331  {
1332  if (GetBasicMcs (i) == mcs)
1333  {
1334  return;
1335  }
1336  }
1337  m_bssBasicMcsSet.push_back (mcs);
1338 }
1339 
1340 uint8_t
1342 {
1343  return static_cast<uint8_t> (m_bssBasicMcsSet.size ());
1344 }
1345 
1346 WifiMode
1348 {
1349  NS_ASSERT (i < GetNBasicMcs ());
1350  return m_bssBasicMcsSet[i];
1351 }
1352 
1353 WifiMode
1355 {
1356  if (m_nonUnicastMode == WifiMode ())
1357  {
1358  if (GetNBasicModes () > 0)
1359  {
1360  return GetBasicMode (0);
1361  }
1362  else
1363  {
1364  return GetDefaultMode ();
1365  }
1366  }
1367  else
1368  {
1369  return m_nonUnicastMode;
1370  }
1371 }
1372 
1373 bool
1375  uint32_t size, bool normally)
1376 {
1377  return normally;
1378 }
1379 
1380 bool
1382  Ptr<const Packet> packet, bool normally)
1383 {
1384  return normally;
1385 }
1386 
1387 bool
1389  Ptr<const Packet> packet, bool normally)
1390 {
1391  return normally;
1392 }
1393 
1394 void
1395 WifiRemoteStationManager::DoReportAmpduTxStatus (WifiRemoteStation *station, uint8_t nSuccessfulMpdus, uint8_t nFailedMpdus, double rxSnr, double dataSnr, uint16_t dataChannelWidth, uint8_t dataNss)
1396 {
1397  NS_LOG_DEBUG ("DoReportAmpduTxStatus received but the manager does not handle A-MPDUs!");
1398 }
1399 
1400 WifiMode
1402 {
1403  NS_ASSERT (i < GetNSupported (station));
1404  return station->m_state->m_operationalRateSet[i];
1405 }
1406 
1407 WifiMode
1409 {
1410  NS_ASSERT (i < GetNMcsSupported (station));
1411  return station->m_state->m_operationalMcsSet[i];
1412 }
1413 
1414 WifiMode
1416 {
1417  NS_ASSERT (i < GetNNonErpSupported (station));
1418  //IEEE 802.11g standard defines that if the protection mechanism is enabled, RTS, CTS and CTS-To-Self
1419  //frames should select a rate in the BSSBasicRateSet that corresponds to an 802.11b basic rate.
1420  //This is a implemented here to avoid changes in every RAA, but should maybe be moved in case it breaks standard rules.
1421  uint32_t index = 0;
1422  bool found = false;
1423  for (WifiModeListIterator j = station->m_state->m_operationalRateSet.begin (); j != station->m_state->m_operationalRateSet.end (); )
1424  {
1425  if (i == index)
1426  {
1427  found = true;
1428  }
1429  if (j->GetModulationClass () != WIFI_MOD_CLASS_ERP_OFDM)
1430  {
1431  if (found)
1432  {
1433  break;
1434  }
1435  }
1436  index++;
1437  j++;
1438  }
1439  return station->m_state->m_operationalRateSet[index];
1440 }
1441 
1444 {
1445  return station->m_state->m_address;
1446 }
1447 
1448 uint16_t
1450 {
1451  return station->m_state->m_channelWidth;
1452 }
1453 
1454 bool
1456 {
1457  Ptr<const HtCapabilities> htCapabilities = station->m_state->m_htCapabilities;
1458 
1459  if (!htCapabilities)
1460  {
1461  return false;
1462  }
1463  return htCapabilities->GetShortGuardInterval20 ();
1464 }
1465 
1466 uint16_t
1468 {
1469  return station->m_state->m_guardInterval;
1470 }
1471 
1472 bool
1474 {
1475  Ptr<const HtCapabilities> htCapabilities = station->m_state->m_htCapabilities;
1476 
1477  if (!htCapabilities)
1478  {
1479  return false;
1480  }
1481  return htCapabilities->GetGreenfield ();
1482 }
1483 
1484 bool
1486 {
1487  return station->m_state->m_aggregation;
1488 }
1489 
1490 uint8_t
1492 {
1493  Ptr<const HtCapabilities> htCapabilities = station->m_state->m_htCapabilities;
1494 
1495  if (!htCapabilities)
1496  {
1497  return 1;
1498  }
1499  return htCapabilities->GetRxHighestSupportedAntennas ();
1500 }
1501 
1502 uint8_t
1504 {
1505  return station->m_state->m_ness;
1506 }
1507 
1510 {
1511  return m_wifiPhy;
1512 }
1513 
1516 {
1517  return m_wifiMac;
1518 }
1519 
1520 uint8_t
1522 {
1523  return static_cast<uint8_t> (station->m_state->m_operationalRateSet.size ());
1524 }
1525 
1526 bool
1528 {
1529  return station->m_state->m_qosSupported;
1530 }
1531 
1532 bool
1534 {
1535  return (station->m_state->m_htCapabilities != 0);
1536 }
1537 
1538 bool
1540 {
1541  return (station->m_state->m_vhtCapabilities != 0);
1542 }
1543 
1544 bool
1546 {
1547  return (station->m_state->m_heCapabilities != 0);
1548 }
1549 
1550 uint8_t
1552 {
1553  return static_cast<uint8_t> (station->m_state->m_operationalMcsSet.size ());
1554 }
1555 
1556 uint32_t
1558 {
1559  uint32_t size = 0;
1560  for (WifiModeListIterator i = station->m_state->m_operationalRateSet.begin (); i != station->m_state->m_operationalRateSet.end (); i++)
1561  {
1562  if (i->GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1563  {
1564  continue;
1565  }
1566  size++;
1567  }
1568  return size;
1569 }
1570 
1571 uint16_t
1573 {
1575 }
1576 
1577 bool
1579 {
1581 
1582  if (!htCapabilities)
1583  {
1584  return false;
1585  }
1586  return htCapabilities->GetShortGuardInterval20 ();
1587 }
1588 
1589 uint8_t
1591 {
1593 
1594  if (!htCapabilities)
1595  {
1596  return 1;
1597  }
1598  return htCapabilities->GetRxHighestSupportedAntennas ();
1599 }
1600 
1601 uint8_t
1603 {
1604  return static_cast<uint8_t> (LookupState (address)->m_operationalMcsSet.size ());
1605 }
1606 
1607 bool
1609 {
1610  return (LookupState (address)->m_htCapabilities != 0);
1611 }
1612 
1613 bool
1615 {
1616  return (LookupState (address)->m_vhtCapabilities != 0);
1617 }
1618 
1619 bool
1621 {
1622  return (LookupState (address)->m_heCapabilities != 0);
1623 }
1624 
1625 void
1627 {
1628  m_defaultTxPowerLevel = txPower;
1629 }
1630 
1631 uint8_t
1633 {
1634  return m_wifiPhy->GetNumberOfAntennas ();
1635 }
1636 
1637 uint8_t
1639 {
1641 }
1642 
1643 bool
1645 {
1647 }
1648 
1649 } //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:4110
#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.
uint32_t m_nextFragmentationThreshold
Threshold for fragmentation that will be used for the next transmission.
bool Is2_4Ghz(double frequency)
Definition: wifi-utils.cc:59
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:162
void UpdateFragmentationThreshold(void)
Typically called to update the fragmentation threshold at the start of a new transmission.
bool Is5Ghz(double frequency)
Definition: wifi-utils.cc:65
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
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:128
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:1508
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:4104
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:225
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:71
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
uint16_t GetFrequency(void) const
Definition: wifi-phy.cc:1488
void SetPreambleType(WifiPreamble preamble)
Sets the preamble type.
uint8_t GetNumberOfAntennas(void) const
Definition: wifi-phy.cc:1522
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:109
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.
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:4092
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.
Ptr< const AttributeChecker > MakeEnumChecker(int v1, std::string n1, int v2, std::string n2, int v3, std::string n3, int v4, std::string n4, int v5, std::string n5, int v6, std::string n6, int v7, std::string n7, int v8, std::string n8, int v9, std::string n9, int v10, std::string n10, int v11, std::string n11, int v12, std::string n12, int v13, std::string n13, int v14, std::string n14, int v15, std::string n15, int v16, std::string n16, int v17, std::string n17, int v18, std::string n18, int v19, std::string n19, int v20, std::string n20, int v21, std::string n21, int v22, std::string n22)
Make an EnumChecker pre-configured with a set of allowed values by name.
Definition: enum.cc:180
WifiMode GetMode(uint8_t mode) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
Definition: wifi-phy.cc:4098
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)
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:775
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.
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:1541
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.