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 
22 #include "ns3/simulator.h"
23 #include "ns3/log.h"
24 #include "ns3/boolean.h"
25 #include "ns3/enum.h"
26 #include "wifi-mac.h"
27 #include "wifi-phy.h"
28 #include "wifi-utils.h"
29 #include "wifi-mac-header.h"
30 #include "wifi-mac-trailer.h"
31 
32 /***************************************************************
33  * Packet Mode Tagger
34  ***************************************************************/
35 
36 namespace ns3 {
37 
38 NS_LOG_COMPONENT_DEFINE ("WifiRemoteStationManager");
39 
44 {
45 public:
56  WifiTxVector GetDataTxVector (void) const;
57 
62  static TypeId GetTypeId (void);
63  virtual TypeId GetInstanceTypeId (void) const;
64  virtual uint32_t GetSerializedSize (void) const;
65  virtual void Serialize (TagBuffer i) const;
66  virtual void Deserialize (TagBuffer i);
67  virtual void Print (std::ostream &os) const;
68 
69 private:
71 };
72 
74 {
75 }
76 
78  : m_dataTxVector (dataTxVector)
79 {
80 }
81 
84 {
85  return m_dataTxVector;
86 }
87 
88 TypeId
90 {
91  static TypeId tid = TypeId ("ns3::HighLatencyDataTxVectorTag")
92  .SetParent<Tag> ()
93  .SetGroupName ("Wifi")
94  .AddConstructor<HighLatencyDataTxVectorTag> ()
95  ;
96  return tid;
97 }
98 
99 TypeId
101 {
102  return GetTypeId ();
103 }
104 
105 uint32_t
107 {
108  return sizeof (WifiTxVector);
109 }
110 
111 void
113 {
114  i.Write ((uint8_t *)&m_dataTxVector, sizeof (WifiTxVector));
115 }
116 
117 void
119 {
120  i.Read ((uint8_t *)&m_dataTxVector, sizeof (WifiTxVector));
121 }
122 
123 void
124 HighLatencyDataTxVectorTag::Print (std::ostream &os) const
125 {
126  os << "Data=" << m_dataTxVector;
127 }
128 
133 {
134 public:
146  WifiTxVector GetRtsTxVector (void) const;
147 
152  static TypeId GetTypeId (void);
153  virtual TypeId GetInstanceTypeId (void) const;
154  virtual uint32_t GetSerializedSize (void) const;
155  virtual void Serialize (TagBuffer i) const;
156  virtual void Deserialize (TagBuffer i);
157  virtual void Print (std::ostream &os) const;
158 
159 private:
161 };
162 
164 {
165 }
166 
168  : m_rtsTxVector (rtsTxVector)
169 {
170 }
171 
174 {
175  return m_rtsTxVector;
176 }
177 
178 TypeId
180 {
181  static TypeId tid = TypeId ("ns3::HighLatencyRtsTxVectorTag")
182  .SetParent<Tag> ()
183  .SetGroupName ("Wifi")
184  .AddConstructor<HighLatencyRtsTxVectorTag> ()
185  ;
186  return tid;
187 }
188 
189 TypeId
191 {
192  return GetTypeId ();
193 }
194 
195 uint32_t
197 {
198  return sizeof (WifiTxVector);
199 }
200 
201 void
203 {
204  i.Write ((uint8_t *)&m_rtsTxVector, sizeof (WifiTxVector));
205 }
206 
207 void
209 {
210  i.Read ((uint8_t *)&m_rtsTxVector, sizeof (WifiTxVector));
211 }
212 
213 void
214 HighLatencyRtsTxVectorTag::Print (std::ostream &os) const
215 {
216  os << "Rts=" << m_rtsTxVector;
217 }
218 
223 {
224 public:
231  HighLatencyCtsToSelfTxVectorTag (WifiTxVector ctsToSelfTxVector);
235  WifiTxVector GetCtsToSelfTxVector (void) const;
236 
241  static TypeId GetTypeId (void);
242  virtual TypeId GetInstanceTypeId (void) const;
243  virtual uint32_t GetSerializedSize (void) const;
244  virtual void Serialize (TagBuffer i) const;
245  virtual void Deserialize (TagBuffer i);
246  virtual void Print (std::ostream &os) const;
247 
248 private:
250 };
251 
253 {
254 }
255 
257  : m_ctsToSelfTxVector (ctsToSelfTxVector)
258 {
259 }
260 
263 {
264  return m_ctsToSelfTxVector;
265 }
266 
267 TypeId
269 {
270  static TypeId tid = TypeId ("ns3::HighLatencyCtsToSelfTxVectorTag")
271  .SetParent<Tag> ()
272  .SetGroupName ("Wifi")
273  .AddConstructor<HighLatencyCtsToSelfTxVectorTag> ()
274  ;
275  return tid;
276 }
277 
278 TypeId
280 {
281  return GetTypeId ();
282 }
283 
284 uint32_t
286 {
287  return sizeof (WifiTxVector);
288 }
289 
290 void
292 {
293  i.Write ((uint8_t *)&m_ctsToSelfTxVector, sizeof (WifiTxVector));
294 }
295 
296 void
298 {
299  i.Read ((uint8_t *)&m_ctsToSelfTxVector, sizeof (WifiTxVector));
300 }
301 
302 void
304 {
305  os << "Cts To Self=" << m_ctsToSelfTxVector;
306 }
307 
308 } //namespace ns3
309 
310 namespace ns3 {
311 
312 NS_OBJECT_ENSURE_REGISTERED (WifiRemoteStationManager);
313 
314 TypeId
316 {
317  static TypeId tid = TypeId ("ns3::WifiRemoteStationManager")
318  .SetParent<Object> ()
319  .SetGroupName ("Wifi")
320  .AddAttribute ("IsLowLatency",
321  "If true, we attempt to modelize a so-called low-latency device: "
322  "a device where decisions about tx parameters can be made on a per-packet basis and "
323  "feedback about the transmission of each packet is obtained before sending the next. "
324  "Otherwise, we modelize a high-latency device, that is a device where we cannot update "
325  "our decision about tx parameters after every packet transmission.",
327  BooleanValue (true), //this value is ignored because there is no setter
330  .AddAttribute ("MaxSsrc",
331  "The maximum number of retransmission attempts for an RTS. "
332  " This value will not have any effect on some rate control algorithms.",
333  UintegerValue (7),
335  MakeUintegerChecker<uint32_t> ())
336  .AddAttribute ("MaxSlrc",
337  "The maximum number of retransmission attempts for a DATA packet. "
338  "This value will not have any effect on some rate control algorithms.",
339  UintegerValue (7),
341  MakeUintegerChecker<uint32_t> ())
342  .AddAttribute ("RtsCtsThreshold",
343  "If the size of the PSDU is bigger than this value, we use an RTS/CTS handshake before sending the data frame."
344  "This value will not have any effect on some rate control algorithms.",
345  UintegerValue (65535),
347  MakeUintegerChecker<uint32_t> ())
348  .AddAttribute ("FragmentationThreshold",
349  "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. "
350  "This value does not apply when it is carried in an A-MPDU. "
351  "This value will not have any effect on some rate control algorithms.",
352  UintegerValue (2346),
355  MakeUintegerChecker<uint32_t> ())
356  .AddAttribute ("NonUnicastMode",
357  "Wifi mode used for non-unicast transmissions.",
358  WifiModeValue (),
361  .AddAttribute ("DefaultTxPowerLevel",
362  "Default power level to be used for transmissions. "
363  "This is the power level that is used by all those WifiManagers that do not implement TX power control.",
364  UintegerValue (0),
366  MakeUintegerChecker<uint8_t> ())
367  .AddAttribute ("ErpProtectionMode",
368  "Protection mode used when non-ERP STAs are connected to an ERP AP: Rts-Cts or Cts-To-Self",
374  .AddAttribute ("HtProtectionMode",
375  "Protection mode used when non-HT STAs are connected to a HT AP: Rts-Cts or Cts-To-Self",
381  .AddTraceSource ("MacTxRtsFailed",
382  "The transmission of a RTS by the MAC layer has failed",
384  "ns3::Mac48Address::TracedCallback")
385  .AddTraceSource ("MacTxDataFailed",
386  "The transmission of a data packet by the MAC layer has failed",
388  "ns3::Mac48Address::TracedCallback")
389  .AddTraceSource ("MacTxFinalRtsFailed",
390  "The transmission of a RTS has exceeded the maximum number of attempts",
392  "ns3::Mac48Address::TracedCallback")
393  .AddTraceSource ("MacTxFinalDataFailed",
394  "The transmission of a data packet has exceeded the maximum number of attempts",
396  "ns3::Mac48Address::TracedCallback")
397  ;
398  return tid;
399 }
400 
402  : m_qosSupported (false),
403  m_htSupported (false),
404  m_vhtSupported (false),
405  m_heSupported (false),
406  m_useNonErpProtection (false),
407  m_useNonHtProtection (false),
408  m_useGreenfieldProtection (false),
409  m_shortPreambleEnabled (false),
410  m_shortSlotTimeEnabled (false),
411  m_rifsPermitted (false)
412 {
413 }
414 
416 {
417 }
418 
419 void
421 {
422  for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
423  {
424  delete (*i);
425  }
426  m_states.clear ();
427  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
428  {
429  delete (*i);
430  }
431  m_stations.clear ();
432 }
433 
434 void
436 {
437  //We need to track our PHY because it is the object that knows the
438  //full set of transmit rates that are supported. We need to know
439  //this in order to find the relevant mandatory rates when chosing a
440  //transmit rate for automatic control responses like
441  //acknowledgements.
442  m_wifiPhy = phy;
443  m_defaultTxMode = phy->GetMode (0);
444  if (HasHtSupported () || HasVhtSupported () || HasHeSupported ())
445  {
446  m_defaultTxMcs = phy->GetMcs (0);
447  }
448  Reset ();
449 }
450 
451 void
453 {
454  //We need to track our MAC because it is the object that knows the
455  //full set of interframe spaces.
456  m_wifiMac = mac;
457  Reset ();
458 }
459 
460 void
462 {
463  m_qosSupported = enable;
464 }
465 
466 void
468 {
469  m_htSupported = enable;
470 }
471 
472 void
474 {
475  m_maxSsrc = maxSsrc;
476 }
477 
478 void
480 {
481  m_maxSlrc = maxSlrc;
482 }
483 
484 void
486 {
487  m_rtsCtsThreshold = threshold;
488 }
489 
490 void
492 {
493  DoSetFragmentationThreshold (threshold);
494 }
495 
496 void
498 {
499  NS_LOG_FUNCTION (this << mode);
500  m_erpProtectionMode = mode;
501 }
502 
503 void
505 {
506  NS_LOG_FUNCTION (this << mode);
507  m_htProtectionMode = mode;
508 }
509 
510 void
512 {
513  NS_LOG_FUNCTION (this << enable);
514  m_shortPreambleEnabled = enable;
515 }
516 
517 void
519 {
520  NS_LOG_FUNCTION (this << enable);
521  m_shortSlotTimeEnabled = enable;
522 }
523 
524 void
526 {
527  NS_LOG_FUNCTION (this << allow);
528  m_rifsPermitted = allow;
529 }
530 
531 bool
533 {
534  return m_shortSlotTimeEnabled;
535 }
536 
537 bool
539 {
540  return m_shortPreambleEnabled;
541 }
542 
543 bool
545 {
546  return m_rifsPermitted;
547 }
548 
551 {
552  return m_erpProtectionMode;
553 }
554 
557 {
558  return m_htProtectionMode;
559 }
560 
561 bool
563 {
564  return m_qosSupported;
565 }
566 
567 bool
569 {
570  return m_htSupported;
571 }
572 
573 void
575 {
576  m_vhtSupported = enable;
577 }
578 
579 bool
581 {
582  return m_vhtSupported;
583 }
584 
585 void
587 {
588  m_heSupported = enable;
589 }
590 
591 bool
593 {
594  return m_heSupported;
595 }
596 
597 uint32_t
599 {
600  return m_maxSsrc;
601 }
602 
603 uint32_t
605 {
606  return m_maxSlrc;
607 }
608 
609 uint32_t
611 {
612  return m_rtsCtsThreshold;
613 }
614 
615 uint32_t
617 {
618  return DoGetFragmentationThreshold ();
619 }
620 
621 void
623 {
624  NS_LOG_FUNCTION (this << address);
625  NS_ASSERT (!address.IsGroup ());
626  WifiRemoteStationState *state = LookupState (address);
627  state->m_operationalRateSet.clear ();
628  state->m_operationalMcsSet.clear ();
629  AddSupportedMode (address, GetDefaultMode ());
630  AddSupportedMcs (address, GetDefaultMcs ());
631 }
632 
633 void
635 {
636  NS_LOG_FUNCTION (this << address << isShortPreambleSupported);
637  NS_ASSERT (!address.IsGroup ());
638  WifiRemoteStationState *state = LookupState (address);
639  state->m_shortPreamble = isShortPreambleSupported;
640 }
641 
642 void
644 {
645  NS_LOG_FUNCTION (this << address << isShortSlotTimeSupported);
646  NS_ASSERT (!address.IsGroup ());
647  WifiRemoteStationState *state = LookupState (address);
648  state->m_shortSlotTime = isShortSlotTimeSupported;
649 }
650 
651 void
653 {
654  NS_LOG_FUNCTION (this << address << mode);
655  NS_ASSERT (!address.IsGroup ());
656  WifiRemoteStationState *state = LookupState (address);
657  for (WifiModeListIterator i = state->m_operationalRateSet.begin (); i != state->m_operationalRateSet.end (); i++)
658  {
659  if ((*i) == mode)
660  {
661  //already in.
662  return;
663  }
664  }
665  state->m_operationalRateSet.push_back (mode);
666 }
667 
668 void
670 {
671  NS_LOG_FUNCTION (this << address);
672  NS_ASSERT (!address.IsGroup ());
673  WifiRemoteStationState *state = LookupState (address);
674  state->m_operationalRateSet.clear ();
675  for (uint32_t i = 0; i < m_wifiPhy->GetNModes (); i++)
676  {
677  state->m_operationalRateSet.push_back (m_wifiPhy->GetMode (i));
678  if (m_wifiPhy->GetMode (i).IsMandatory ())
679  {
681  }
682  }
683 }
684 
685 void
687 {
688  NS_LOG_FUNCTION (this << address);
689  NS_ASSERT (!address.IsGroup ());
690  WifiRemoteStationState *state = LookupState (address);
691  state->m_operationalMcsSet.clear ();
692  for (uint32_t i = 0; i < m_wifiPhy->GetNMcs (); i++)
693  {
694  state->m_operationalMcsSet.push_back (m_wifiPhy->GetMcs (i));
695  }
696 }
697 
698 void
700 {
701  NS_LOG_FUNCTION (this << address);
702  NS_ASSERT (!address.IsGroup ());
703  WifiRemoteStationState *state = LookupState (address);
704  state->m_operationalMcsSet.clear ();
705 }
706 
707 void
709 {
710  NS_LOG_FUNCTION (this << address << mcs);
711  NS_ASSERT (!address.IsGroup ());
712  WifiRemoteStationState *state = LookupState (address);
713  for (WifiModeListIterator i = state->m_operationalMcsSet.begin (); i != state->m_operationalMcsSet.end (); i++)
714  {
715  if ((*i) == mcs)
716  {
717  //already in.
718  return;
719  }
720  }
721  state->m_operationalMcsSet.push_back (mcs);
722 }
723 
724 bool
726 {
727  return LookupState (address)->m_shortPreamble;
728 }
729 
730 bool
732 {
733  return LookupState (address)->m_shortSlotTime;
734 }
735 
736 bool
738 {
739  return LookupState (address)->m_qosSupported;
740 }
741 
742 bool
744 {
745  if (address.IsGroup ())
746  {
747  return false;
748  }
750 }
751 
752 bool
754 {
755  if (address.IsGroup ())
756  {
757  return true;
758  }
760 }
761 
762 bool
764 {
765  if (address.IsGroup ())
766  {
767  return false;
768  }
770 }
771 
772 void
774 {
775  NS_ASSERT (!address.IsGroup ());
777 }
778 
779 void
781 {
782  NS_ASSERT (!address.IsGroup ());
784 }
785 
786 void
788 {
789  NS_ASSERT (!address.IsGroup ());
791 }
792 
793 void
795 {
796  NS_ASSERT (!address.IsGroup ());
798 }
799 
800 void
802 {
803  NS_LOG_FUNCTION (this << address << *header << packet);
804  if (IsLowLatency () || address.IsGroup ())
805  {
806  return;
807  }
808  WifiRemoteStation *station = Lookup (address, header);
809  WifiTxVector rts = DoGetRtsTxVector (station);
810  WifiTxVector data = DoGetDataTxVector (station);
811  WifiTxVector ctstoself = DoGetCtsToSelfTxVector ();
814  HighLatencyCtsToSelfTxVectorTag ctstoselftag;
815  //first, make sure that the tag is not here anymore.
816  ConstCast<Packet> (packet)->RemovePacketTag (datatag);
817  ConstCast<Packet> (packet)->RemovePacketTag (rtstag);
818  ConstCast<Packet> (packet)->RemovePacketTag (ctstoselftag);
819  datatag = HighLatencyDataTxVectorTag (data);
820  rtstag = HighLatencyRtsTxVectorTag (rts);
821  ctstoselftag = HighLatencyCtsToSelfTxVectorTag (ctstoself);
822  //and then, add it back
823  packet->AddPacketTag (datatag);
824  packet->AddPacketTag (rtstag);
825  packet->AddPacketTag (ctstoselftag);
826 }
827 
830 {
831  NS_LOG_FUNCTION (this << address << *header << packet);
832  if (address.IsGroup ())
833  {
834  WifiMode mode = GetNonUnicastMode ();
835  WifiTxVector v;
836  v.SetMode (mode);
837  v.SetPreambleType (GetPreambleForTransmission (mode, address));
841  v.SetNss (1);
842  v.SetNess (0);
843  v.SetStbc (false);
844  return v;
845  }
846  if (!IsLowLatency ())
847  {
849  bool found;
850  found = ConstCast<Packet> (packet)->PeekPacketTag (datatag);
851  NS_ASSERT (found);
852  //cast found to void, to suppress 'found' set but not used
853  //compiler warning
854  (void) found;
855  return datatag.GetDataTxVector ();
856  }
857  return DoGetDataTxVector (Lookup (address, header));
858 }
859 
862  Ptr<const Packet> packet)
863 {
864  NS_LOG_FUNCTION (this << *header << packet);
865  if (!IsLowLatency ())
866  {
867  HighLatencyCtsToSelfTxVectorTag ctstoselftag;
868  bool found;
869  found = ConstCast<Packet> (packet)->PeekPacketTag (ctstoselftag);
870  NS_ASSERT (found);
871  //cast found to void, to suppress 'found' set but not used
872  //compiler warning
873  (void) found;
874  return ctstoselftag.GetCtsToSelfTxVector ();
875  }
876  return DoGetCtsToSelfTxVector ();
877 }
878 
881 {
882  WifiMode defaultMode = GetDefaultMode ();
883  WifiPreamble defaultPreamble;
884  if (defaultMode.GetModulationClass () == WIFI_MOD_CLASS_HE)
885  {
886  defaultPreamble = WIFI_PREAMBLE_HE_SU;
887  }
888  else if (defaultMode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
889  {
890  defaultPreamble = WIFI_PREAMBLE_VHT;
891  }
892  else if (defaultMode.GetModulationClass () == WIFI_MOD_CLASS_HT)
893  {
894  defaultPreamble = WIFI_PREAMBLE_HT_MF;
895  }
896  else
897  {
898  defaultPreamble = WIFI_PREAMBLE_LONG;
899  }
900 
901  return WifiTxVector (defaultMode,
903  0,
904  defaultPreamble,
908  0,
910  false,
911  false);
912 }
913 
916  Ptr<const Packet> packet)
917 {
918  NS_LOG_FUNCTION (this << address << *header << packet);
919  NS_ASSERT (!address.IsGroup ());
920  if (!IsLowLatency ())
921  {
923  bool found;
924  found = ConstCast<Packet> (packet)->PeekPacketTag (rtstag);
925  NS_ASSERT (found);
926  //cast found to void, to suppress 'found' set but not used
927  //compiler warning
928  (void) found;
929  return rtstag.GetRtsTxVector ();
930  }
931  return DoGetRtsTxVector (Lookup (address, header));
932 }
933 
934 void
936 {
937  NS_LOG_FUNCTION (this << address << *header);
938  NS_ASSERT (!address.IsGroup ());
939  WifiRemoteStation *station = Lookup (address, header);
940  station->m_ssrc++;
941  m_macTxRtsFailed (address);
942  DoReportRtsFailed (station);
943 }
944 
945 void
947 {
948  NS_LOG_FUNCTION (this << address << *header);
949  NS_ASSERT (!address.IsGroup ());
950  WifiRemoteStation *station = Lookup (address, header);
951  station->m_slrc++;
952  m_macTxDataFailed (address);
953  DoReportDataFailed (station);
954 }
955 
956 void
958  double ctsSnr, WifiMode ctsMode, double rtsSnr)
959 {
960  NS_LOG_FUNCTION (this << address << *header << ctsSnr << ctsMode << rtsSnr);
961  NS_ASSERT (!address.IsGroup ());
962  WifiRemoteStation *station = Lookup (address, header);
963  station->m_state->m_info.NotifyTxSuccess (station->m_ssrc);
964  station->m_ssrc = 0;
965  DoReportRtsOk (station, ctsSnr, ctsMode, rtsSnr);
966 }
967 
968 void
970  double ackSnr, WifiMode ackMode, double dataSnr)
971 {
972  NS_LOG_FUNCTION (this << address << *header << ackSnr << ackMode << dataSnr);
973  NS_ASSERT (!address.IsGroup ());
974  WifiRemoteStation *station = Lookup (address, header);
975  station->m_state->m_info.NotifyTxSuccess (station->m_slrc);
976  station->m_slrc = 0;
977  DoReportDataOk (station, ackSnr, ackMode, dataSnr);
978 }
979 
980 void
982 {
983  NS_LOG_FUNCTION (this << address << *header);
984  NS_ASSERT (!address.IsGroup ());
985  WifiRemoteStation *station = Lookup (address, header);
986  station->m_state->m_info.NotifyTxFailed ();
987  station->m_ssrc = 0;
988  m_macTxFinalRtsFailed (address);
989  DoReportFinalRtsFailed (station);
990 }
991 
992 void
994 {
995  NS_LOG_FUNCTION (this << address << *header);
996  NS_ASSERT (!address.IsGroup ());
997  WifiRemoteStation *station = Lookup (address, header);
998  station->m_state->m_info.NotifyTxFailed ();
999  station->m_slrc = 0;
1000  m_macTxFinalDataFailed (address);
1001  DoReportFinalDataFailed (station);
1002 }
1003 
1004 void
1006  double rxSnr, WifiMode txMode)
1007 {
1008  NS_LOG_FUNCTION (this << address << *header << rxSnr << txMode);
1009  if (address.IsGroup ())
1010  {
1011  return;
1012  }
1013  WifiRemoteStation *station = Lookup (address, header);
1014  DoReportRxOk (station, rxSnr, txMode);
1015 }
1016 
1017 void
1019  uint8_t nSuccessfulMpdus, uint8_t nFailedMpdus,
1020  double rxSnr, double dataSnr)
1021 {
1022  NS_LOG_FUNCTION (this << address << (uint16_t)tid << (uint16_t)nSuccessfulMpdus << (uint16_t)nFailedMpdus << rxSnr << dataSnr);
1023  NS_ASSERT (!address.IsGroup ());
1024  WifiRemoteStation *station = Lookup (address, tid);
1025  for (uint32_t i = 0; i < nFailedMpdus; i++)
1026  {
1027  m_macTxDataFailed (address);
1028  }
1029  DoReportAmpduTxStatus (station, nSuccessfulMpdus, nFailedMpdus, rxSnr, dataSnr);
1030 }
1031 
1032 bool
1034  Ptr<const Packet> packet, WifiTxVector txVector)
1035 {
1036  WifiMode mode = txVector.GetMode ();
1037  NS_LOG_FUNCTION (this << address << *header << packet << mode);
1038  if (address.IsGroup ())
1039  {
1040  return false;
1041  }
1044  || (mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
1045  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
1046  || (mode.GetModulationClass () == WIFI_MOD_CLASS_HE))
1048  {
1049  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedRTS returning true to protect non-ERP stations");
1050  return true;
1051  }
1052  else if (m_htProtectionMode == RTS_CTS
1053  && ((mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
1054  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT))
1057  {
1058  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedRTS returning true to protect non-HT stations");
1059  return true;
1060  }
1061  bool normally = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > GetRtsCtsThreshold ();
1062  return DoNeedRts (Lookup (address, header), packet, normally);
1063 }
1064 
1065 bool
1067 {
1068  WifiMode mode = txVector.GetMode ();
1069  NS_LOG_FUNCTION (this << mode);
1072  || (mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
1073  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
1074  || (mode.GetModulationClass () == WIFI_MOD_CLASS_HE))
1076  {
1077  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true to protect non-ERP stations");
1078  return true;
1079  }
1080  else if (m_htProtectionMode == CTS_TO_SELF
1081  && ((mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
1082  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT))
1085  {
1086  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true to protect non-HT stations");
1087  return true;
1088  }
1089  else if (!m_useNonErpProtection)
1090  {
1091  //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
1092  for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
1093  {
1094  if (mode == *i)
1095  {
1096  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
1097  return false;
1098  }
1099  }
1100  if (HasHtSupported ())
1101  {
1102  //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
1103  for (WifiModeListIterator i = m_bssBasicMcsSet.begin (); i != m_bssBasicMcsSet.end (); i++)
1104  {
1105  if (mode == *i)
1106  {
1107  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
1108  return false;
1109  }
1110  }
1111  }
1112  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true");
1113  return true;
1114  }
1115  return false;
1116 }
1117 
1118 void
1120 {
1121  NS_LOG_FUNCTION (this << enable);
1122  m_useNonErpProtection = enable;
1123 }
1124 
1125 bool
1127 {
1128  return m_useNonErpProtection;
1129 }
1130 
1131 void
1133 {
1134  NS_LOG_FUNCTION (this << enable);
1135  m_useNonHtProtection = enable;
1136 }
1137 
1138 bool
1140 {
1141  return m_useNonHtProtection;
1142 }
1143 
1144 void
1146 {
1147  NS_LOG_FUNCTION (this << enable);
1148  m_useGreenfieldProtection = enable;
1149 }
1150 
1151 bool
1153 {
1155 }
1156 
1157 bool
1159  Ptr<const Packet> packet)
1160 {
1161  NS_LOG_FUNCTION (this << address << packet << *header);
1162  NS_ASSERT (!address.IsGroup ());
1163  WifiRemoteStation *station = Lookup (address, header);
1164  bool normally = station->m_ssrc < GetMaxSsrc ();
1165  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedDataRetransmission count: " << station->m_ssrc << " result: " << std::boolalpha << normally);
1166  return DoNeedRtsRetransmission (station, packet, normally);
1167 }
1168 
1169 bool
1171  Ptr<const Packet> packet)
1172 {
1173  NS_LOG_FUNCTION (this << address << packet << *header);
1174  NS_ASSERT (!address.IsGroup ());
1175  WifiRemoteStation *station = Lookup (address, header);
1176  bool normally = station->m_slrc < GetMaxSlrc ();
1177  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedDataRetransmission count: " << station->m_slrc << " result: " << std::boolalpha << normally);
1178  return DoNeedDataRetransmission (station, packet, normally);
1179 }
1180 
1181 bool
1183  Ptr<const Packet> packet)
1184 {
1185  NS_LOG_FUNCTION (this << address << packet << *header);
1186  if (address.IsGroup ())
1187  {
1188  return false;
1189  }
1190  WifiRemoteStation *station = Lookup (address, header);
1191  bool normally = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > GetFragmentationThreshold ();
1192  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedFragmentation result: " << std::boolalpha << normally);
1193  return DoNeedFragmentation (station, packet, normally);
1194 }
1195 
1196 void
1198 {
1199  NS_LOG_FUNCTION (this << threshold);
1200  if (threshold < 256)
1201  {
1202  /*
1203  * ASN.1 encoding of the MAC and PHY MIB (256 ... 8000)
1204  */
1205  NS_LOG_WARN ("Fragmentation threshold should be larger than 256. Setting to 256.");
1207  }
1208  else
1209  {
1210  /*
1211  * The length of each fragment shall be an even number of octets, except for the last fragment if an MSDU or
1212  * MMPDU, which may be either an even or an odd number of octets.
1213  */
1214  if (threshold % 2 != 0)
1215  {
1216  NS_LOG_WARN ("Fragmentation threshold should be an even number. Setting to " << threshold - 1);
1217  m_nextFragmentationThreshold = threshold - 1;
1218  }
1219  else
1220  {
1221  m_nextFragmentationThreshold = threshold;
1222  }
1223  }
1224 }
1225 
1226 void
1228 {
1230 }
1231 
1232 uint32_t
1234 {
1235  return m_fragmentationThreshold;
1236 }
1237 
1238 uint32_t
1240 {
1241  NS_LOG_FUNCTION (this << *header << packet);
1242  //The number of bytes a fragment can support is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
1243  uint32_t nFragments = (packet->GetSize () / (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
1244 
1245  //If the size of the last fragment is not 0.
1246  if ((packet->GetSize () % (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH)) > 0)
1247  {
1248  nFragments++;
1249  }
1250  NS_LOG_DEBUG ("WifiRemoteStationManager::GetNFragments returning " << nFragments);
1251  return nFragments;
1252 }
1253 
1254 uint32_t
1256  Ptr<const Packet> packet, uint32_t fragmentNumber)
1257 {
1258  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
1259  NS_ASSERT (!address.IsGroup ());
1260  uint32_t nFragment = GetNFragments (header, packet);
1261  if (fragmentNumber >= nFragment)
1262  {
1263  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning 0");
1264  return 0;
1265  }
1266  //Last fragment
1267  if (fragmentNumber == nFragment - 1)
1268  {
1269  uint32_t lastFragmentSize = packet->GetSize () - (fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
1270  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << lastFragmentSize);
1271  return lastFragmentSize;
1272  }
1273  //All fragments but the last, the number of bytes is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
1274  else
1275  {
1276  uint32_t fragmentSize = GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH;
1277  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << fragmentSize);
1278  return fragmentSize;
1279  }
1280 }
1281 
1282 uint32_t
1284  Ptr<const Packet> packet, uint32_t fragmentNumber)
1285 {
1286  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
1287  NS_ASSERT (!address.IsGroup ());
1288  NS_ASSERT (fragmentNumber < GetNFragments (header, packet));
1289  uint32_t fragmentOffset = fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH);
1290  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentOffset returning " << fragmentOffset);
1291  return fragmentOffset;
1292 }
1293 
1294 bool
1296  Ptr<const Packet> packet, uint32_t fragmentNumber)
1297 {
1298  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
1299  NS_ASSERT (!address.IsGroup ());
1300  bool isLast = fragmentNumber == (GetNFragments (header, packet) - 1);
1301  NS_LOG_DEBUG ("WifiRemoteStationManager::IsLastFragment returning " << std::boolalpha << isLast);
1302  return isLast;
1303 }
1304 
1305 bool
1307 {
1308  switch (modClassReq)
1309  {
1310  case WIFI_MOD_CLASS_DSSS:
1311  return (modClassAnswer == WIFI_MOD_CLASS_DSSS);
1313  return (modClassAnswer == WIFI_MOD_CLASS_DSSS || modClassAnswer == WIFI_MOD_CLASS_HR_DSSS);
1315  return (modClassAnswer == WIFI_MOD_CLASS_DSSS || modClassAnswer == WIFI_MOD_CLASS_HR_DSSS || modClassAnswer == WIFI_MOD_CLASS_ERP_OFDM);
1316  case WIFI_MOD_CLASS_OFDM:
1317  return (modClassAnswer == WIFI_MOD_CLASS_OFDM);
1318  case WIFI_MOD_CLASS_HT:
1319  case WIFI_MOD_CLASS_VHT:
1320  case WIFI_MOD_CLASS_HE:
1321  return true;
1322  default:
1323  NS_FATAL_ERROR ("Modulation class not defined");
1324  return false;
1325  }
1326 }
1327 
1328 WifiMode
1330 {
1345  NS_LOG_FUNCTION (this << address << reqMode);
1346  WifiMode mode = GetDefaultMode ();
1347  bool found = false;
1348  //First, search the BSS Basic Rate set
1349  for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
1350  {
1351  if ((!found || i->IsHigherDataRate (mode))
1352  && (!i->IsHigherDataRate (reqMode))
1353  && (IsAllowedControlAnswerModulationClass (reqMode.GetModulationClass (), i->GetModulationClass ())))
1354  {
1355  mode = *i;
1356  //We've found a potentially-suitable transmit rate, but we
1357  //need to continue and consider all the basic rates before
1358  //we can be sure we've got the right one.
1359  found = true;
1360  }
1361  }
1362  if (HasHtSupported () || HasVhtSupported () || HasHeSupported ())
1363  {
1364  if (!found)
1365  {
1366  mode = GetDefaultMcs ();
1367  for (WifiModeListIterator i = m_bssBasicMcsSet.begin (); i != m_bssBasicMcsSet.end (); i++)
1368  {
1369  if ((!found || i->IsHigherDataRate (mode))
1370  && (!i->IsHigherDataRate (reqMode))
1371  && (i->GetModulationClass () == reqMode.GetModulationClass ()))
1372  {
1373  mode = *i;
1374  //We've found a potentially-suitable transmit rate, but we
1375  //need to continue and consider all the basic rates before
1376  //we can be sure we've got the right one.
1377  found = true;
1378  }
1379  }
1380  }
1381  }
1382  //If we found a suitable rate in the BSSBasicRateSet, then we are
1383  //done and can return that mode.
1384  if (found)
1385  {
1386  NS_LOG_DEBUG ("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
1387  return mode;
1388  }
1389 
1407  for (uint32_t idx = 0; idx < m_wifiPhy->GetNModes (); idx++)
1408  {
1409  WifiMode thismode = m_wifiPhy->GetMode (idx);
1410  /* If the rate:
1411  *
1412  * - is a mandatory rate for the PHY, and
1413  * - is equal to or faster than our current best choice, and
1414  * - is less than or equal to the rate of the received frame, and
1415  * - is of the same modulation class as the received frame
1416  *
1417  * ...then it's our best choice so far.
1418  */
1419  if (thismode.IsMandatory ()
1420  && (!found || thismode.IsHigherDataRate (mode))
1421  && (!thismode.IsHigherDataRate (reqMode))
1423  {
1424  mode = thismode;
1425  //As above; we've found a potentially-suitable transmit
1426  //rate, but we need to continue and consider all the
1427  //mandatory rates before we can be sure we've got the right one.
1428  found = true;
1429  }
1430  }
1431  if (HasHtSupported () || HasVhtSupported () || HasHeSupported ())
1432  {
1433  for (uint32_t idx = 0; idx < m_wifiPhy->GetNMcs (); idx++)
1434  {
1435  WifiMode thismode = m_wifiPhy->GetMcs (idx);
1436  if (thismode.IsMandatory ()
1437  && (!found || thismode.IsHigherDataRate (mode))
1438  && (!thismode.IsHigherCodeRate (reqMode))
1439  && (thismode.GetModulationClass () == reqMode.GetModulationClass ()))
1440  {
1441  mode = thismode;
1442  //As above; we've found a potentially-suitable transmit
1443  //rate, but we need to continue and consider all the
1444  //mandatory rates before we can be sure we've got the right one.
1445  found = true;
1446  }
1447 
1448  }
1449  }
1450 
1461  if (!found)
1462  {
1463  NS_FATAL_ERROR ("Can't find response rate for " << reqMode);
1464  }
1465 
1466  NS_LOG_DEBUG ("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
1467  return mode;
1468 }
1469 
1472 {
1473  NS_ASSERT (!address.IsGroup ());
1474  WifiMode ctsMode = GetControlAnswerMode (address, rtsMode);
1475  WifiTxVector v;
1476  v.SetMode (ctsMode);
1477  v.SetPreambleType (GetPreambleForTransmission (ctsMode, address));
1478  v.SetTxPowerLevel (DoGetCtsTxPowerLevel (address, ctsMode));
1479  v.SetChannelWidth (DoGetCtsTxChannelWidth (address, ctsMode));
1480  v.SetGuardInterval (DoGetCtsTxGuardInterval (address, ctsMode));
1481  v.SetNss (DoGetCtsTxNss (address, ctsMode));
1482  v.SetNess (DoGetCtsTxNess (address, ctsMode));
1483  v.SetStbc (DoGetCtsTxStbc (address, ctsMode));
1484  return v;
1485 }
1486 
1489 {
1490  NS_ASSERT (!address.IsGroup ());
1491  WifiMode ackMode = GetControlAnswerMode (address, dataMode);
1492  WifiTxVector v;
1493  v.SetMode (ackMode);
1494  v.SetPreambleType (GetPreambleForTransmission (ackMode, address));
1495  v.SetTxPowerLevel (DoGetAckTxPowerLevel (address, ackMode));
1496  v.SetChannelWidth (DoGetAckTxChannelWidth (address, ackMode));
1497  v.SetGuardInterval (DoGetAckTxGuardInterval (address, ackMode));
1498  v.SetNss (DoGetAckTxNss (address, ackMode));
1499  v.SetNess (DoGetAckTxNess (address, ackMode));
1500  v.SetStbc (DoGetAckTxStbc (address, ackMode));
1501  return v;
1502 }
1503 
1506 {
1507  NS_ASSERT (!address.IsGroup ());
1508  WifiMode blockAckMode = GetControlAnswerMode (address, blockAckReqMode);
1509  WifiTxVector v;
1510  v.SetMode (blockAckMode);
1511  v.SetPreambleType (GetPreambleForTransmission (blockAckMode, address));
1512  v.SetTxPowerLevel (DoGetBlockAckTxPowerLevel (address, blockAckMode));
1513  v.SetChannelWidth (DoGetBlockAckTxChannelWidth (address, blockAckMode));
1514  v.SetGuardInterval (DoGetBlockAckTxGuardInterval (address, blockAckMode));
1515  v.SetNss (DoGetBlockAckTxNss (address, blockAckMode));
1516  v.SetNess (DoGetBlockAckTxNess (address, blockAckMode));
1517  v.SetStbc (DoGetBlockAckTxStbc (address, blockAckMode));
1518  return v;
1519 }
1520 
1521 uint8_t
1523 {
1524  return m_defaultTxPowerLevel;
1525 }
1526 
1527 uint8_t
1529 {
1530  return m_wifiPhy->GetChannelWidth ();
1531 }
1532 
1533 uint16_t
1535 {
1537 }
1538 
1539 uint8_t
1541 {
1542  return 1;
1543 }
1544 
1545 uint8_t
1547 {
1548  return 0;
1549 }
1550 
1551 bool
1553 {
1554  return m_wifiPhy->GetStbc ();
1555 }
1556 
1557 uint8_t
1559 {
1560  return m_defaultTxPowerLevel;
1561 }
1562 
1563 uint8_t
1565 {
1566  return m_wifiPhy->GetChannelWidth ();
1567 }
1568 
1569 uint16_t
1571 {
1573 }
1574 
1575 uint8_t
1577 {
1578  return 1;
1579 }
1580 
1581 uint8_t
1583 {
1584  return 0;
1585 }
1586 
1587 bool
1589 {
1590  return m_wifiPhy->GetStbc ();
1591 }
1592 
1593 uint8_t
1595 {
1596  return m_defaultTxPowerLevel;
1597 }
1598 
1599 uint8_t
1601 {
1602  return m_wifiPhy->GetChannelWidth ();
1603 }
1604 
1605 uint16_t
1607 {
1609 }
1610 
1611 uint8_t
1613 {
1614  return 1;
1615 }
1616 
1617 uint8_t
1619 {
1620  return 0;
1621 }
1622 
1623 bool
1625 {
1626  return m_wifiPhy->GetStbc ();
1627 }
1628 
1629 uint8_t
1631 {
1632  return m_defaultTxPowerLevel;
1633 }
1634 
1637 {
1638  WifiRemoteStationState *state = LookupState (address);
1639  return state->m_info;
1640 }
1641 
1644 {
1645  NS_LOG_FUNCTION (this << address);
1646  for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
1647  {
1648  if ((*i)->m_address == address)
1649  {
1650  NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning existing state");
1651  return (*i);
1652  }
1653  }
1656  state->m_address = address;
1657  state->m_operationalRateSet.push_back (GetDefaultMode ());
1658  state->m_operationalMcsSet.push_back (GetDefaultMcs ());
1662  state->m_greenfield = m_wifiPhy->GetGreenfield ();
1663  state->m_streams = 1;
1664  state->m_ness = 0;
1665  state->m_aggregation = false;
1666  state->m_stbc = false;
1667  state->m_qosSupported = false;
1668  state->m_htSupported = false;
1669  state->m_vhtSupported = false;
1670  state->m_heSupported = false;
1671  const_cast<WifiRemoteStationManager *> (this)->m_states.push_back (state);
1672  NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning new state");
1673  return state;
1674 }
1675 
1678 {
1679  uint8_t tid;
1680  if (header->IsQosData ())
1681  {
1682  tid = header->GetQosTid ();
1683  }
1684  else
1685  {
1686  tid = 0;
1687  }
1688  return Lookup (address, tid);
1689 }
1690 
1693 {
1694  NS_LOG_FUNCTION (this << address << (uint16_t)tid);
1695  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1696  {
1697  if ((*i)->m_tid == tid
1698  && (*i)->m_state->m_address == address)
1699  {
1700  return (*i);
1701  }
1702  }
1703  WifiRemoteStationState *state = LookupState (address);
1704 
1705  WifiRemoteStation *station = DoCreateStation ();
1706  station->m_state = state;
1707  station->m_tid = tid;
1708  station->m_ssrc = 0;
1709  station->m_slrc = 0;
1710  const_cast<WifiRemoteStationManager *> (this)->m_stations.push_back (station);
1711  return station;
1712 }
1713 
1714 void
1716 {
1717  NS_LOG_FUNCTION (this << from << qosSupported);
1718  WifiRemoteStationState *state;
1719  state = LookupState (from);
1720  state->m_qosSupported = qosSupported;
1721 }
1722 
1723 void
1725 {
1726  //Used by all stations to record HT capabilities of remote stations
1727  NS_LOG_FUNCTION (this << from << htCapabilities);
1728  WifiRemoteStationState *state;
1729  state = LookupState (from);
1730  state->m_shortGuardInterval = htCapabilities.GetShortGuardInterval20 ();
1731  if (htCapabilities.GetSupportedChannelWidth () == 1)
1732  {
1733  state->m_channelWidth = 40;
1734  }
1735  else
1736  {
1737  state->m_channelWidth = 20;
1738  }
1739  state->m_htSupported = true;
1740  SetQosSupport (from, true);
1741  state->m_greenfield = htCapabilities.GetGreenfield ();
1742  state->m_streams = htCapabilities.GetRxHighestSupportedAntennas ();
1743 }
1744 
1745 void
1747 {
1748  //Used by all stations to record VHT capabilities of remote stations
1749  NS_LOG_FUNCTION (this << from << vhtCapabilities);
1750  WifiRemoteStationState *state;
1751  state = LookupState (from);
1752  if (vhtCapabilities.GetSupportedChannelWidthSet () == 1)
1753  {
1754  state->m_channelWidth = 160;
1755  }
1756  else
1757  {
1758  state->m_channelWidth = 80;
1759  }
1760  //This is a workaround to enable users to force a 20 or 40 MHz channel for a VHT-compliant device,
1761  //since IEEE 802.11ac standard says that 20, 40 and 80 MHz channels are mandatory.
1762  if (m_wifiPhy->GetChannelWidth () < state->m_channelWidth)
1763  {
1765  }
1766  state->m_vhtSupported = true;
1767 }
1768 
1769 void
1771 {
1772  //Used by all stations to record HE capabilities of remote stations
1773  NS_LOG_FUNCTION (this << from << heCapabilities);
1774  WifiRemoteStationState *state;
1775  state = LookupState (from);
1776  if (heCapabilities.GetHeLtfAndGiForHePpdus () >= 2)
1777  {
1778  state->m_guardInterval = 800;
1779  }
1780  else if (heCapabilities.GetHeLtfAndGiForHePpdus () == 1)
1781  {
1782  state->m_guardInterval = 1600;
1783  }
1784  else
1785  {
1786  state->m_guardInterval = 3200;
1787  }
1788  state->m_heSupported = true;
1789  SetQosSupport (from, true);
1790 }
1791 
1792 bool
1794 {
1795  return LookupState (address)->m_greenfield;
1796 }
1797 
1798 WifiMode
1800 {
1801  return m_defaultTxMode;
1802 }
1803 
1804 WifiMode
1806 {
1807  return m_defaultTxMcs;
1808 }
1809 
1810 void
1812 {
1813  NS_LOG_FUNCTION (this);
1814  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1815  {
1816  delete (*i);
1817  }
1818  m_stations.clear ();
1819  m_bssBasicRateSet.clear ();
1820  m_bssBasicRateSet.push_back (m_defaultTxMode);
1821  m_bssBasicMcsSet.clear ();
1822  m_bssBasicMcsSet.push_back (m_defaultTxMcs);
1824 }
1825 
1826 void
1828 {
1829  NS_LOG_FUNCTION (this << mode);
1831  {
1832  NS_FATAL_ERROR ("It is not allowed to add a (V)HT rate in the BSSBasicRateSet!");
1833  }
1834  for (uint32_t i = 0; i < GetNBasicModes (); i++)
1835  {
1836  if (GetBasicMode (i) == mode)
1837  {
1838  return;
1839  }
1840  }
1841  m_bssBasicRateSet.push_back (mode);
1842 }
1843 
1844 uint32_t
1846 {
1847  return m_bssBasicRateSet.size ();
1848 }
1849 
1850 WifiMode
1852 {
1853  NS_ASSERT (i < GetNBasicModes ());
1854  return m_bssBasicRateSet[i];
1855 }
1856 
1857 uint32_t
1859 {
1860  uint32_t size = 0;
1861  for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
1862  {
1863  if (i->GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1864  {
1865  continue;
1866  }
1867  size++;
1868  }
1869  return size;
1870 }
1871 
1872 WifiMode
1874 {
1876  uint32_t index = 0;
1877  bool found = false;
1878  for (WifiModeListIterator j = m_bssBasicRateSet.begin (); j != m_bssBasicRateSet.end (); )
1879  {
1880  if (i == index)
1881  {
1882  found = true;
1883  }
1884  if (j->GetModulationClass () != WIFI_MOD_CLASS_ERP_OFDM)
1885  {
1886  if (found)
1887  {
1888  break;
1889  }
1890  }
1891  index++;
1892  j++;
1893  }
1894  return m_bssBasicRateSet[index];
1895 }
1896 
1897 void
1899 {
1900  NS_LOG_FUNCTION (this << (uint16_t)mcs.GetMcsValue ());
1901  for (uint32_t i = 0; i < GetNBasicMcs (); i++)
1902  {
1903  if (GetBasicMcs (i) == mcs)
1904  {
1905  return;
1906  }
1907  }
1908  m_bssBasicMcsSet.push_back (mcs);
1909 }
1910 
1911 uint32_t
1913 {
1914  return m_bssBasicMcsSet.size ();
1915 }
1916 
1917 WifiMode
1919 {
1920  NS_ASSERT (i < GetNBasicMcs ());
1921  return m_bssBasicMcsSet[i];
1922 }
1923 
1924 WifiMode
1926 {
1927  if (m_nonUnicastMode == WifiMode ())
1928  {
1929  return GetBasicMode (0);
1930  }
1931  else
1932  {
1933  return m_nonUnicastMode;
1934  }
1935 }
1936 
1937 bool
1939  Ptr<const Packet> packet, bool normally)
1940 {
1941  return normally;
1942 }
1943 
1944 bool
1946  Ptr<const Packet> packet, bool normally)
1947 {
1948  return normally;
1949 }
1950 
1951 bool
1953  Ptr<const Packet> packet, bool normally)
1954 {
1955  return normally;
1956 }
1957 
1958 bool
1960  Ptr<const Packet> packet, bool normally)
1961 {
1962  return normally;
1963 }
1964 
1965 void
1966 WifiRemoteStationManager::DoReportAmpduTxStatus (WifiRemoteStation *station, uint8_t nSuccessfulMpdus, uint8_t nFailedMpdus, double rxSnr, double dataSnr)
1967 {
1968  NS_LOG_DEBUG ("DoReportAmpduTxStatus received but the manager does not handle A-MPDUs!");
1969 }
1970 
1971 WifiMode
1973 {
1974  NS_ASSERT (i < GetNSupported (station));
1975  return station->m_state->m_operationalRateSet[i];
1976 }
1977 
1978 WifiMode
1980 {
1981  NS_ASSERT (i < GetNMcsSupported (station));
1982  return station->m_state->m_operationalMcsSet[i];
1983 }
1984 
1985 WifiMode
1987 {
1988  NS_ASSERT (i < GetNNonErpSupported (station));
1989  //IEEE 802.11g standard defines that if the protection mechanism is enabled, Rts, Cts and Cts-To-Self
1990  //frames should select a rate in the BSSBasicRateSet that corresponds to an 802.11b basic rate.
1991  //This is a implemented here to avoid changes in every RAA, but should maybe be moved in case it breaks standard rules.
1992  uint32_t index = 0;
1993  bool found = false;
1994  for (WifiModeListIterator j = station->m_state->m_operationalRateSet.begin (); j != station->m_state->m_operationalRateSet.end (); )
1995  {
1996  if (i == index)
1997  {
1998  found = true;
1999  }
2000  if (j->GetModulationClass () != WIFI_MOD_CLASS_ERP_OFDM)
2001  {
2002  if (found)
2003  {
2004  break;
2005  }
2006  }
2007  index++;
2008  j++;
2009  }
2010  return station->m_state->m_operationalRateSet[index];
2011 }
2012 
2015 {
2016  return station->m_state->m_address;
2017 }
2018 
2019 uint8_t
2021 {
2022  return station->m_state->m_channelWidth;
2023 }
2024 
2025 bool
2027 {
2028  return station->m_state->m_shortGuardInterval;
2029 }
2030 
2031 uint16_t
2033 {
2034  return station->m_state->m_guardInterval;
2035 }
2036 
2037 bool
2039 {
2040  return station->m_state->m_greenfield;
2041 }
2042 
2043 bool
2045 {
2046  return station->m_state->m_aggregation;
2047 }
2048 
2049 bool
2051 {
2052  return station->m_state->m_stbc;
2053 }
2054 
2055 uint8_t
2057 {
2058  return station->m_state->m_streams;
2059 }
2060 
2061 uint32_t
2063 {
2064  return station->m_state->m_ness;
2065 }
2066 
2067 uint32_t
2069 {
2070  return station->m_ssrc;
2071 }
2072 
2075 {
2076  return m_wifiPhy;
2077 }
2078 
2081 {
2082  return m_wifiMac;
2083 }
2084 
2085 uint32_t
2087 {
2088  return station->m_slrc;
2089 }
2090 
2091 uint32_t
2093 {
2094  return station->m_state->m_operationalRateSet.size ();
2095 }
2096 
2097 bool
2099 {
2100  return station->m_state->m_qosSupported;
2101 }
2102 
2103 bool
2105 {
2106  return station->m_state->m_htSupported;
2107 }
2108 
2109 bool
2111 {
2112  return station->m_state->m_vhtSupported;
2113 }
2114 
2115 bool
2117 {
2118  return station->m_state->m_heSupported;
2119 }
2120 
2121 uint32_t
2123 {
2124  return station->m_state->m_operationalMcsSet.size ();
2125 }
2126 
2127 uint32_t
2129 {
2130  uint32_t size = 0;
2131  for (WifiModeListIterator i = station->m_state->m_operationalRateSet.begin (); i != station->m_state->m_operationalRateSet.end (); i++)
2132  {
2133  if (i->GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
2134  {
2135  continue;
2136  }
2137  size++;
2138  }
2139  return size;
2140 }
2141 
2142 uint8_t
2144 {
2145  return LookupState (address)->m_channelWidth;
2146 }
2147 
2148 bool
2150 {
2151  return LookupState (address)->m_vhtSupported;
2152 }
2153 
2154 void
2156 {
2157  m_defaultTxPowerLevel = txPower;
2158 }
2159 
2160 uint8_t
2162 {
2163  return m_wifiPhy->GetNumberOfAntennas ();
2164 }
2165 
2166 uint8_t
2168 {
2170 }
2171 
2174 {
2175  NS_LOG_FUNCTION (this << mode << dest);
2176  WifiPreamble preamble;
2177  if (mode.GetModulationClass () == WIFI_MOD_CLASS_HE)
2178  {
2179  preamble = WIFI_PREAMBLE_HE_SU;
2180  }
2181  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
2182  {
2183  preamble = WIFI_PREAMBLE_VHT;
2184  }
2186  {
2187  //If protection for greenfield is used we go for HT_MF preamble which is the default protection for GF format defined in the standard.
2188  preamble = WIFI_PREAMBLE_HT_GF;
2189  }
2190  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
2191  {
2192  preamble = WIFI_PREAMBLE_HT_MF;
2193  }
2194  else if (GetShortPreambleEnabled ())
2195  {
2196  preamble = WIFI_PREAMBLE_SHORT;
2197  }
2198  else
2199  {
2200  preamble = WIFI_PREAMBLE_LONG;
2201  }
2202  NS_LOG_DEBUG ("selected preamble=" << preamble);
2203  return preamble;
2204 }
2205 
2207 {
2208  NS_LOG_FUNCTION (this);
2209 }
2210 
2212  : m_memoryTime (Seconds (1.0)),
2213  m_lastUpdate (Seconds (0.0)),
2214  m_failAvg (0.0)
2215 {
2216 }
2217 
2218 double
2220 {
2221  double retval = std::exp ((double)(m_lastUpdate.GetMicroSeconds () - Simulator::Now ().GetMicroSeconds ())
2222  / (double)m_memoryTime.GetMicroSeconds ());
2224  return retval;
2225 }
2226 
2227 void
2229 {
2230  double coefficient = CalculateAveragingCoefficient ();
2231  m_failAvg = (double)retryCounter / (1 + (double)retryCounter) * (1.0 - coefficient) + coefficient * m_failAvg;
2232 }
2233 
2234 void
2236 {
2237  double coefficient = CalculateAveragingCoefficient ();
2238  m_failAvg = (1.0 - coefficient) + coefficient * m_failAvg;
2239 }
2240 
2241 double
2243 {
2244  return m_failAvg;
2245 }
2246 
2247 } //namespace ns3
enum ns3::WifiRemoteStationState::@76 m_state
State of the station.
bool GetUseNonHtProtection(void) const
Return whether the device supports protection of non-HT stations.
virtual uint8_t DoGetAckTxNss(Mac48Address address, WifiMode ackMode)
bool m_useNonHtProtection
flag if protection for non-HT stations against HT transmissions is enabled
uint32_t GetNSupported(const WifiRemoteStation *station) const
Return the number of modes supported by the given station.
bool GetVhtSupported(Mac48Address address) const
Return whether the station supports VHT or not.
uint32_t m_ssrc
STA short retry count.
bool m_shortPreamble
Flag if short PLCP preamble is supported by the remote station.
void Write(const uint8_t *buffer, uint32_t size)
Definition: tag-buffer.cc:125
bool m_vhtSupported
Flag if VHT capability is supported.
virtual uint8_t DoGetAckTxNess(Mac48Address address, WifiMode ackMode)
HighLatencyDataTxVectorTag class.
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.
void SetDefaultTxPowerLevel(uint8_t txPower)
Set the default transmission power level.
bool GetShortSlotTimeEnabled(void) const
Return whether the device uses short slot time.
uint32_t GetSize(void) const
Return the size of the WifiMacHeader in octets.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
virtual void Print(std::ostream &os) const
bool GetGreenfieldSupported(Mac48Address address) const
Return whether the station supports Greenfield or not.
ERP-OFDM PHY (19.5)
Definition: wifi-mode.h:54
AttributeValue implementation for Boolean.
Definition: boolean.h:36
bool m_shortGuardInterval
Flag if HT/VHT short guard interval is supported by the remote station.
virtual uint16_t DoGetBlockAckTxGuardInterval(Mac48Address address, WifiMode blockAckMode)
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
uint8_t GetHeLtfAndGiForHePpdus(void) const
Get HE LTF and GI for HE PDPUs.
uint32_t m_rtsCtsThreshold
Threshold for RTS/CTS.
bool m_shortSlotTimeEnabled
flag if short slot time is enabled
bool NeedDataRetransmission(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
uint8_t GetSupportedChannelWidthSet() const
Get the supported channel width set.
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...
ProtectionMode GetHtProtectionMode(void) const
Return the HT protection mode.
bool GetGreenfield(void) const
Return whether Greenfield is supported.
Definition: wifi-phy.cc:624
bool m_vhtSupported
Flag if VHT is supported by the station.
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 ReportDataFailed(Mac48Address address, const WifiMacHeader *header)
Should be invoked whenever the AckTimeout associated to a transmission attempt expires.
bool GetUseNonErpProtection(void) const
Return whether the device supports protection of non-ERP stations.
virtual uint8_t DoGetBlockAckTxNss(Mac48Address address, WifiMode blockAckMode)
uint16_t ConvertGuardIntervalToNanoSeconds(WifiMode mode, bool htShortGuardInterval, Time heGuardInterval)
Convert the guard interval to nanoseconds based on the wifimode.
Definition: wifi-utils.cc:60
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:209
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: boolean.h:84
uint32_t m_nextFragmentationThreshold
Threshold for fragmentation that will be used for the next transmission.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition: packet.cc:814
bool GetQosSupported(Mac48Address address) const
Return whether the given station is QoS capable.
uint32_t GetMaxSsrc(void) const
Return the maximum STA short retry count (SSRC).
virtual uint8_t DoGetAckTxChannelWidth(Mac48Address address, WifiMode ctsMode)
WifiTxVector GetCtsTxVector(Mac48Address address, WifiMode rtsMode)
virtual uint8_t DoGetBlockAckTxNess(Mac48Address address, WifiMode blockAckMode)
uint8_t m_streams
Number of supported streams by the remote station.
#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
WifiMode GetNonUnicastMode(void) const
Return a mode for non-unicast packets.
static const uint16_t WIFI_MAC_FCS_LENGTH
The length in octects of the IEEE 802.11 MAC FCS field.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
uint32_t m_fragmentationThreshold
Current threshold for fragmentation.
WifiTxVector m_rtsTxVector
TXVECTOR for data frames.
virtual uint8_t DoGetBlockAckTxChannelWidth(Mac48Address address, WifiMode ctsMode)
The HT Capabilities Information ElementThis class knows how to serialise and deserialise the HT Capab...
uint8_t m_defaultTxPowerLevel
Default tranmission power level.
void SetStbc(bool stbc)
Sets if STBC is being used.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:796
bool GetShortGuardInterval(void) const
Return whether short guard interval is supported.
Definition: wifi-phy.cc:637
bool GetGreenfield(const WifiRemoteStation *station) const
Return whether the station supports Greenfield or not.
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
uint8_t GetSupportedChannelWidth(void) const
Return the supported channel width.
bool NeedRts(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, WifiTxVector txVector)
void UpdateFragmentationThreshold(void)
Typically called to update the fragmentation threshold at the start of a new transmission.
Time m_memoryTime
averaging coefficient depends on the memory time
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:3553
bool IsLastFragment(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fragmentNumber)
WifiMode GetMcsSupported(const WifiRemoteStation *station, uint32_t i) const
Return the WifiMode supported by the specified station at the specified index.
VHT PHY (Clause 22)
Definition: wifi-mode.h:60
TracedCallback< Mac48Address > m_macTxFinalRtsFailed
The trace source fired when the transmission of a RTS has exceeded the maximum number of attempts...
void PrepareForQueue(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
HR/DSSS PHY (Clause 18)
Definition: wifi-mode.h:48
bool IsBrandNew(Mac48Address address) const
Return whether the station state is brand new.
virtual void Serialize(TagBuffer i) const
WifiTxVector m_ctsToSelfTxVector
TXVECTOR for CTS-to-self frames.
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 PLCP preamble is enabled
bool IsMandatory(void) const
Definition: wifi-mode.cc:458
bool GetAggregation(const WifiRemoteStation *station) const
Return whether the given station supports A-MPDU.
bool GetStbc(void) const
Return whether STBC is supported.
Definition: wifi-phy.cc:611
virtual bool DoNeedRts(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
Tid independent remote station statistics.
WifiMode GetSupported(const WifiRemoteStation *station, uint32_t i) const
Return whether mode associated with the specified station at the specified index. ...
void SetErpProtectionMode(ProtectionMode mode)
Sets the ERP protection mode.
WifiRemoteStationState * LookupState(Mac48Address address) const
Return the state of the station associated with the given address.
WifiRemoteStationState * m_state
Remote station state.
double m_failAvg
moving percentage of failed frames
WifiTxVector GetCtsToSelfTxVector(const WifiMacHeader *header, Ptr< const Packet > packet)
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
void RecordDisassociated(Mac48Address address)
Records that the STA was disassociated.
TracedCallback< Mac48Address > m_macTxFinalDataFailed
The trace source fired when the transmission of a data packet has exceeded the maximum number of atte...
void SetShortSlotTimeEnabled(bool enable)
Enable or disable short slot time.
Ptr< WifiPhy > GetPhy(void) const
Return the WifiPhy.
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Definition: wifi-preamble.h:30
bool GetStbc(const WifiRemoteStation *station) const
Return whether the given station supports space-time block coding (STBC).
uint8_t GetQosTid(void) const
Return the Traffic ID of a QoS header.
virtual bool DoNeedDataRetransmission(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
static TypeId GetTypeId(void)
Get the type ID.
virtual void SetVhtSupported(bool enable)
Enable or disable VHT capability support.
virtual bool DoGetAckTxStbc(Mac48Address address, WifiMode ackMode)
ProtectionMode m_htProtectionMode
Protection mode for HT stations when non-HT stations are detected.
Time m_lastUpdate
when last update has occured
void ReportFinalDataFailed(Mac48Address address, const WifiMacHeader *header)
Should be invoked after calling ReportDataFailed if NeedDataRetransmission returns false...
void SetRtsCtsThreshold(uint32_t threshold)
Sets the RTS threshold.
tuple phy
Definition: third.py:86
bool m_qosSupported
Flag if HT is supported by the station.
Hold variables of type enum.
Definition: enum.h:54
WifiMode m_defaultTxMcs
The default transmission modulation-coding scheme (MCS)
virtual uint8_t DoGetCtsTxChannelWidth(Mac48Address address, WifiMode ctsMode)
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.
WifiRemoteStation * Lookup(Mac48Address address, uint8_t tid) const
Return the station associated with the given address and TID.
Ptr< WifiPhy > m_wifiPhy
This is a pointer to the WifiPhy associated with this WifiRemoteStationManager that is set on call to...
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:349
double CalculateAveragingCoefficient()
Calculate averaging coefficient for frame error rate.
uint8_t GetGreenfield(void) const
Return the green field.
WifiTxVector m_dataTxVector
TXVECTOR for data frames.
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.
The IEEE 802.11ac VHT Capabilities.
virtual bool DoNeedRtsRetransmission(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
void SetGuardInterval(uint16_t guardInterval)
Sets the guard interval duration (in nanoseconds)
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
bool IsHigherDataRate(WifiMode mode) const
Definition: wifi-mode.cc:602
bool m_useNonErpProtection
flag if protection for non-ERP stations against ERP transmissions is enabled
Hold an unsigned integer type.
Definition: uinteger.h:44
WifiMode GetNonErpSupported(const WifiRemoteStation *station, uint32_t i) const
Return whether non-ERP mode associated with the specified station at the specified index...
virtual void DoReportDataFailed(WifiRemoteStation *station)=0
This method is a pure virtual method that must be implemented by the sub-class.
uint8_t data[writeSize]
bool m_stbc
Flag if STBC is supported by the remote station.
void RecordGotAssocTxFailed(Mac48Address address)
Records that we missed an ACK for the association response we sent.
WifiPreamble GetPreambleForTransmission(WifiMode mode, Mac48Address dest)
Return the preamble to be used for the transmission.
WifiMode GetBasicMode(uint32_t i) const
Return a basic mode from the set of basic modes.
uint32_t GetFragmentationThreshold(void) const
Return the fragmentation threshold.
void AddStationHtCapabilities(Mac48Address from, HtCapabilities htcapabilities)
Records HT capabilities of the remote station.
uint8_t GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the station.
bool GetHeSupported(const WifiRemoteStation *station) const
Return whether the given station is HE capable.
WifiRemoteStationInfo GetInfo(Mac48Address address)
Time GetGuardInterval(void) const
Definition: wifi-phy.cc:651
void SetMaxSsrc(uint32_t maxSsrc)
Sets the maximum STA short retry count (SSRC).
uint32_t GetRtsCtsThreshold(void) const
Return the RTS threshold.
HT PHY (Clause 20)
Definition: wifi-mode.h:58
uint32_t m_maxSlrc
Maximum STA long retry count (SLRC)
uint8_t GetMcsValue(void) const
Definition: wifi-mode.cc:465
uint8_t GetShortGuardInterval20(void) const
Return the short guard interval 20 value.
void NotifyTxSuccess(uint32_t retryCounter)
Updates average frame error rate when data or RTS was transmitted successfully.
Ptr< WifiMac > m_wifiMac
This is a pointer to the WifiMac associated with this WifiRemoteStationManager that is set on call to...
uint32_t DoGetFragmentationThreshold(void) const
Return the current fragmentation threshold.
uint8_t GetChannelWidthSupported(Mac48Address address) const
Return the channel width supported by the station.
uint8_t GetNumberOfSupportedStreams(const WifiRemoteStation *station) const
Return the number of supported streams the station has.
Mac48Address GetAddress(const WifiRemoteStation *station) const
Return the address of the station.
void AddStationHeCapabilities(Mac48Address from, HeCapabilities hecapabilities)
Records HE capabilities of the remote station.
virtual void SetQosSupported(bool enable)
Enable or disable QoS support.
uint32_t GetNModes(void) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
Definition: wifi-phy.cc:3541
tuple mac
Definition: third.py:92
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.
virtual void Print(std::ostream &os) const
WifiMode GetControlAnswerMode(Mac48Address address, WifiMode reqMode)
Get control answer mode function.
uint32_t GetNBasicMcs(void) const
Return the number of basic MCS index.
void SetQosSupport(Mac48Address from, bool qosSupported)
Records QoS support of the remote station.
WifiMode m_defaultTxMode
The default transmission mode.
uint32_t GetNess(const WifiRemoteStation *station) const
void SetNss(uint8_t nss)
Sets the number of Nss refer to IEEE 802.11n Table 20-28 for explanation and range.
WifiMode GetDefaultMcs(void) const
Return the default Modulation and Coding Scheme (MCS) index.
virtual uint8_t DoGetCtsTxNss(Mac48Address address, WifiMode ctsMode)
WifiModeList m_bssBasicRateSet
This member is the list of WifiMode objects that comprise the BSSBasicRateSet parameter.
void ReportDataOk(Mac48Address address, const WifiMacHeader *header, double ackSnr, WifiMode ackMode, double dataSnr)
Should be invoked whenever we receive the Ack associated to a data packet we just sent...
virtual void SetHtSupported(bool enable)
Enable or disable HT capability support.
bool m_qosSupported
Flag if HT capability is supported.
virtual uint8_t DoGetAckTxPowerLevel(Mac48Address address, WifiMode ackMode)
uint32_t GetNNonErpBasicModes(void) const
Return the number of non-ERP basic modes we support.
tag a set of bytes in a packet
Definition: tag.h:36
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:3559
uint32_t GetFragmentOffset(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fragmentNumber)
bool IsWaitAssocTxOk(Mac48Address address) const
Return whether we are waiting for an ACK for the association response we sent.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetHtProtectionMode(ProtectionMode mode)
Sets the HT protection mode.
ProtectionMode GetErpProtectionMode(void) const
Return the ERP protection mode.
WifiTxVector DoGetCtsToSelfTxVector(void)
Since CTS-to-self parameters are not dependent on the station, it is implemented in wifiremote statio...
void SetPreambleType(WifiPreamble preamble)
Sets the preamble type.
uint32_t GetNNonErpSupported(const WifiRemoteStation *station) const
Return the number of non-ERP modes supported by the given station.
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...
bool IsGroup(void) const
WifiModeList m_operationalRateSet
This member is the list of WifiMode objects that comprise the OperationalRateSet parameter for this r...
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
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...
uint8_t m_channelWidth
Channel width (in MHz) supported by the remote station.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
void AddBasicMode(WifiMode mode)
Invoked in a STA upon association to store the set of rates which belong to the BSSBasicRateSet of th...
bool m_htSupported
Flag if HT capability is supported.
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:255
bool m_useGreenfieldProtection
flag if protection for stations that do not support HT greenfield format is enabled ...
virtual uint32_t GetSerializedSize(void) const
bool m_aggregation
Flag if MPDU aggregation is used by the remote station.
an EUI-48 address
Definition: mac48-address.h:43
WifiMode GetBasicMcs(uint32_t i) const
Return the MCS at the given list index.
TracedCallback< Mac48Address > m_macTxRtsFailed
The trace source fired when the transmission of a single RTS has failed.
bool HasVhtSupported(void) const
Return whether the device has VHT capability support enabled.
bool IsAssociated(Mac48Address address) const
Return whether the station associated.
virtual bool IsLowLatency(void) const =0
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:243
bool GetShortGuardInterval(const WifiRemoteStation *station) const
Return whether the given station supports HT/VHT short guard interval.
Stations m_stations
Information for each known stations.
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:249
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.
bool m_heSupported
Flag if HE capability is supported.
TracedCallback< Mac48Address > m_macTxDataFailed
The trace source fired when the transmission of a single data packet has failed.
static TypeId GetTypeId(void)
Get the type ID.
virtual uint16_t DoGetCtsTxGuardInterval(Mac48Address address, WifiMode ctsMode)
WifiMode GetNonErpBasicMode(uint32_t i) const
Return a basic mode from the set of basic modes that is not an ERP mode.
double GetFrameErrorRate() const
Return frame error rate (probability that frame is corrupted due to transmission error).
uint8_t GetMaxSupportedTxSpatialStreams(void) const
Definition: wifi-phy.cc:1332
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
virtual void Serialize(TagBuffer i) const
void AddBasicMcs(WifiMode mcs)
Add a given Modulation and Coding Scheme (MCS) index to the set of basic MCS.
void AddSupportedPlcpPreamble(Mac48Address address, bool isShortPreambleSupported)
Record whether the short PLCP preamble is supported by the station.
bool HasHtSupported(void) const
Return whether the device has HT capability support enabled.
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
virtual bool DoNeedFragmentation(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
void NotifyTxFailed()
Updates average frame error rate when final data or RTS has failed.
bool NeedCtsToSelf(WifiTxVector txVector)
Return if we need to do Cts-to-self before sending a DATA.
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:353
HighLatencyCtsToSelfTxVectorTag class.
uint8_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1304
static TypeId GetTypeId(void)
Get the type ID.
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:184
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).
bool m_htSupported
Flag if HT is supported by the station.
bool HasHeSupported(void) const
Return whether the device has HE capability support enabled.
ProtectionMode
ProtectionMode enumeration.
uint32_t GetNBasicModes(void) const
Return the number of basic modes we support.
read and write tag data
Definition: tag-buffer.h:51
WifiTxVector GetDataTxVector(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
bool GetShortSlotTimeSupported(Mac48Address address) const
Return whether the station supports short ERP slot time or not.
bool GetShortPreambleEnabled(void) const
Return whether the device uses short PLCP preambles.
The attribute can be read.
Definition: type-id.h:63
WifiModulationClass
This enumeration defines the modulation classes per (Table 9-4 "Modulation classes"; IEEE 802...
Definition: wifi-mode.h:36
A struct that holds information about each remote station.
uint32_t GetLongRetryCount(const WifiRemoteStation *station) const
Return the long retry limit of the given station.
WifiModeList m_operationalMcsSet
operational MCS set
bool IsQosData(void) const
Return true if the Type is DATA and Subtype is one of the possible values for QoS DATA...
static TypeId GetTypeId(void)
Get the type ID.
virtual bool DoGetCtsTxStbc(Mac48Address address, WifiMode ctsMode)
uint32_t GetNMcsSupported(const WifiRemoteStation *station) const
Return the number of MCS supported by the given station.
void AddSupportedErpSlotTime(Mac48Address address, bool isShortSlotTimeSupported)
Record whether the short ERP slot time is supported by the station.
WifiMode GetDefaultMode(void) const
Return the default transmission mode.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:261
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. ...
uint32_t m_maxSsrc
Maximum STA short retry count (SSRC)
bool GetRifsPermitted(void) const
Return whether the device can use RIFS.
virtual void Serialize(TagBuffer i) const
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:269
bool IsHigherCodeRate(WifiMode mode) const
Definition: wifi-mode.cc:582
virtual void DoDispose(void)
Destructor implementation.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:993
OFDM PHY (Clause 17)
Definition: wifi-mode.h:56
void ReportRxOk(Mac48Address address, const WifiMacHeader *header, double rxSnr, WifiMode txMode)
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.
void Read(uint8_t *buffer, uint32_t size)
Definition: tag-buffer.cc:176
virtual bool DoGetBlockAckTxStbc(Mac48Address address, WifiMode blockAckMode)
bool HasQosSupported(void) const
Return whether the device has QoS support enabled.
void SetChannelWidth(uint8_t channelWidth)
Sets the selected channelWidth (in MHz)
bool NeedRtsRetransmission(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
uint32_t GetShortRetryCount(const WifiRemoteStation *station) const
Return the short retry limit of the given station.
Ptr< const AttributeChecker > MakeWifiModeChecker(void)
Definition: wifi-mode.cc:674
virtual void SetHeSupported(bool enable)
Enable or disable HE capability support.
bool GetUseGreenfieldProtection(void) const
Return whether protection for stations that do not support HT greenfield format is enabled...
uint8_t GetRxHighestSupportedAntennas(void) const
Return the receive highest supported antennas.
bool IsAllowedControlAnswerModulationClass(WifiModulationClass modClassReq, WifiModulationClass modClassAnswer) const
Return whether the modulation class of the selected mode for the control answer frame is allowed...
bool m_shortSlotTime
Flag if short ERP slot time is supported by the remote station.
virtual uint8_t DoGetCtsTxNess(Mac48Address address, WifiMode ctsMode)
void ReportAmpduTxStatus(Mac48Address address, uint8_t tid, uint8_t nSuccessfulMpdus, uint8_t nFailedMpdus, double rxSnr, double dataSnr)
Typically called per A-MPDU, either when a Block ACK was successfully received or when a BlockAckTime...
WifiTxVector GetRtsTxVector(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
A base class which provides memory management and object aggregation.
Definition: object.h:87
tuple address
Definition: first.py:37
virtual uint32_t GetSerializedSize(void) const
AttributeValue implementation for WifiMode.
Definition: wifi-mode.h:243
virtual void DoReportAmpduTxStatus(WifiRemoteStation *station, uint8_t nSuccessfulMpdus, uint8_t nFailedMpdus, double rxSnr, double dataSnr)
Typically called per A-MPDU, either when a Block ACK was successfully received or when a BlockAckTime...
StationStates m_states
States of known stations.
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:487
void SetShortPreambleEnabled(bool enable)
Enable or disable short PLCP preambles.
WifiMode GetMode(void) const
uint8_t GetNumberOfAntennas(void) const
Definition: wifi-phy.cc:1318
WifiTxVector GetBlockAckTxVector(Mac48Address address, WifiMode dataMode)
virtual uint8_t DoGetCtsTxPowerLevel(Mac48Address address, WifiMode ctsMode)
ProtectionMode m_erpProtectionMode
Protection mode for ERP stations when non-ERP stations are detected.
virtual void Print(std::ostream &os) const
uint32_t GetMaxSlrc(void) const
Return the maximum STA long retry count (SLRC).
uint32_t m_slrc
STA long retry count.
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
The IEEE 802.11ax HE Capabilities.
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
a unique identifier for an interface.
Definition: type-id.h:58
bool m_rifsPermitted
flag if RIFS is enabled
void ReportFinalRtsFailed(Mac48Address address, const WifiMacHeader *header)
Should be invoked after calling ReportRtsFailed if NeedRtsRetransmission returns false.
WifiTxVector GetAckTxVector(Mac48Address address, WifiMode dataMode)
bool m_greenfield
Flag if greenfield is supported by the remote station.
void RemoveAllSupportedMcs(Mac48Address address)
Invoked in a STA or AP to delete all of the suppported MCS by a destination.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:914
HighLatencyRtsTxVectorTag class.
uint32_t m_ness
Number of streams in beamforming of the remote station.
virtual uint16_t DoGetAckTxGuardInterval(Mac48Address address, WifiMode ackMode)
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.
bool m_heSupported
Flag if HE is supported by the station.
HE PHY (Clause 26)
Definition: wifi-mode.h:62
hold per-remote-station state.
void SetRifsPermitted(bool allow)
Permit or prohibit RIFS.
virtual WifiRemoteStation * DoCreateStation(void) const =0
void RecordGotAssocTxOk(Mac48Address address)
Records that we got an ACK for the association response we sent.
void AddStationVhtCapabilities(Mac48Address from, VhtCapabilities vhtcapabilities)
Records VHT capabilities of the remote station.
Implements the IEEE 802.11 MAC header.
bool GetHtSupported(const WifiRemoteStation *station) const
Return whether the given station is HT capable.
DSSS PHY (Clause 15)
Definition: wifi-mode.h:46
virtual uint8_t DoGetBlockAckTxPowerLevel(Mac48Address address, WifiMode blockAckMode)
Ptr< WifiMac > GetMac(void) const
Return the WifiMac.
virtual void DoReportDataOk(WifiRemoteStation *station, double ackSnr, WifiMode ackMode, double dataSnr)=0
This method is a pure virtual method that must be implemented by the sub-class.
uint16_t GetGuardInterval(const WifiRemoteStation *station) const
Return the HE guard interval duration supported by the station.
WifiMode GetMode(uint32_t mode) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
Definition: wifi-phy.cc:3547
uint16_t m_guardInterval
HE Guard interval duration (in nanoseconds) supported by the remote station.
bool GetShortPreambleSupported(Mac48Address address) const
Return whether the station supports short PLCP preamble or not.