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-utils.h"
28 #include "wifi-mac-header.h"
29 #include "wifi-mac-trailer.h"
30 
31 /***************************************************************
32  * Packet Mode Tagger
33  ***************************************************************/
34 
35 namespace ns3 {
36 
37 NS_LOG_COMPONENT_DEFINE ("WifiRemoteStationManager");
38 
43 {
44 public:
55  WifiTxVector GetDataTxVector (void) const;
56 
61  static TypeId GetTypeId (void);
62  virtual TypeId GetInstanceTypeId (void) const;
63  virtual uint32_t GetSerializedSize (void) const;
64  virtual void Serialize (TagBuffer i) const;
65  virtual void Deserialize (TagBuffer i);
66  virtual void Print (std::ostream &os) const;
67 
68 private:
70 };
71 
73 {
74 }
75 
77  : m_dataTxVector (dataTxVector)
78 {
79 }
80 
83 {
84  return m_dataTxVector;
85 }
86 
87 TypeId
89 {
90  static TypeId tid = TypeId ("ns3::HighLatencyDataTxVectorTag")
91  .SetParent<Tag> ()
92  .SetGroupName ("Wifi")
93  .AddConstructor<HighLatencyDataTxVectorTag> ()
94  ;
95  return tid;
96 }
97 
98 TypeId
100 {
101  return GetTypeId ();
102 }
103 
104 uint32_t
106 {
107  return sizeof (WifiTxVector);
108 }
109 
110 void
112 {
113  i.Write ((uint8_t *)&m_dataTxVector, sizeof (WifiTxVector));
114 }
115 
116 void
118 {
119  i.Read ((uint8_t *)&m_dataTxVector, sizeof (WifiTxVector));
120 }
121 
122 void
123 HighLatencyDataTxVectorTag::Print (std::ostream &os) const
124 {
125  os << "Data=" << m_dataTxVector;
126 }
127 
132 {
133 public:
145  WifiTxVector GetRtsTxVector (void) const;
146 
151  static TypeId GetTypeId (void);
152  virtual TypeId GetInstanceTypeId (void) const;
153  virtual uint32_t GetSerializedSize (void) const;
154  virtual void Serialize (TagBuffer i) const;
155  virtual void Deserialize (TagBuffer i);
156  virtual void Print (std::ostream &os) const;
157 
158 private:
160 };
161 
163 {
164 }
165 
167  : m_rtsTxVector (rtsTxVector)
168 {
169 }
170 
173 {
174  return m_rtsTxVector;
175 }
176 
177 TypeId
179 {
180  static TypeId tid = TypeId ("ns3::HighLatencyRtsTxVectorTag")
181  .SetParent<Tag> ()
182  .SetGroupName ("Wifi")
183  .AddConstructor<HighLatencyRtsTxVectorTag> ()
184  ;
185  return tid;
186 }
187 
188 TypeId
190 {
191  return GetTypeId ();
192 }
193 
194 uint32_t
196 {
197  return sizeof (WifiTxVector);
198 }
199 
200 void
202 {
203  i.Write ((uint8_t *)&m_rtsTxVector, sizeof (WifiTxVector));
204 }
205 
206 void
208 {
209  i.Read ((uint8_t *)&m_rtsTxVector, sizeof (WifiTxVector));
210 }
211 
212 void
213 HighLatencyRtsTxVectorTag::Print (std::ostream &os) const
214 {
215  os << "Rts=" << m_rtsTxVector;
216 }
217 
222 {
223 public:
230  HighLatencyCtsToSelfTxVectorTag (WifiTxVector ctsToSelfTxVector);
234  WifiTxVector GetCtsToSelfTxVector (void) const;
235 
240  static TypeId GetTypeId (void);
241  virtual TypeId GetInstanceTypeId (void) const;
242  virtual uint32_t GetSerializedSize (void) const;
243  virtual void Serialize (TagBuffer i) const;
244  virtual void Deserialize (TagBuffer i);
245  virtual void Print (std::ostream &os) const;
246 
247 private:
249 };
250 
252 {
253 }
254 
256  : m_ctsToSelfTxVector (ctsToSelfTxVector)
257 {
258 }
259 
262 {
263  return m_ctsToSelfTxVector;
264 }
265 
266 TypeId
268 {
269  static TypeId tid = TypeId ("ns3::HighLatencyCtsToSelfTxVectorTag")
270  .SetParent<Tag> ()
271  .SetGroupName ("Wifi")
272  .AddConstructor<HighLatencyCtsToSelfTxVectorTag> ()
273  ;
274  return tid;
275 }
276 
277 TypeId
279 {
280  return GetTypeId ();
281 }
282 
283 uint32_t
285 {
286  return sizeof (WifiTxVector);
287 }
288 
289 void
291 {
292  i.Write ((uint8_t *)&m_ctsToSelfTxVector, sizeof (WifiTxVector));
293 }
294 
295 void
297 {
298  i.Read ((uint8_t *)&m_ctsToSelfTxVector, sizeof (WifiTxVector));
299 }
300 
301 void
303 {
304  os << "Cts To Self=" << m_ctsToSelfTxVector;
305 }
306 
307 } //namespace ns3
308 
309 namespace ns3 {
310 
311 NS_OBJECT_ENSURE_REGISTERED (WifiRemoteStationManager);
312 
313 TypeId
315 {
316  static TypeId tid = TypeId ("ns3::WifiRemoteStationManager")
317  .SetParent<Object> ()
318  .SetGroupName ("Wifi")
319  .AddAttribute ("IsLowLatency",
320  "If true, we attempt to modelize a so-called low-latency device: "
321  "a device where decisions about tx parameters can be made on a per-packet basis and "
322  "feedback about the transmission of each packet is obtained before sending the next. "
323  "Otherwise, we modelize a high-latency device, that is a device where we cannot update "
324  "our decision about tx parameters after every packet transmission.",
326  BooleanValue (true), //this value is ignored because there is no setter
329  .AddAttribute ("MaxSsrc",
330  "The maximum number of retransmission attempts for an RTS. "
331  " This value will not have any effect on some rate control algorithms.",
332  UintegerValue (7),
334  MakeUintegerChecker<uint32_t> ())
335  .AddAttribute ("MaxSlrc",
336  "The maximum number of retransmission attempts for a DATA packet. "
337  "This value will not have any effect on some rate control algorithms.",
338  UintegerValue (7),
340  MakeUintegerChecker<uint32_t> ())
341  .AddAttribute ("RtsCtsThreshold",
342  "If the size of the PSDU is bigger than this value, we use an RTS/CTS handshake before sending the data frame."
343  "This value will not have any effect on some rate control algorithms.",
344  UintegerValue (65535),
346  MakeUintegerChecker<uint32_t> ())
347  .AddAttribute ("FragmentationThreshold",
348  "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. "
349  "This value does not apply when it is carried in an A-MPDU. "
350  "This value will not have any effect on some rate control algorithms.",
351  UintegerValue (2346),
354  MakeUintegerChecker<uint32_t> ())
355  .AddAttribute ("NonUnicastMode",
356  "Wifi mode used for non-unicast transmissions.",
357  WifiModeValue (),
360  .AddAttribute ("DefaultTxPowerLevel",
361  "Default power level to be used for transmissions. "
362  "This is the power level that is used by all those WifiManagers that do not implement TX power control.",
363  UintegerValue (0),
365  MakeUintegerChecker<uint8_t> ())
366  .AddAttribute ("ErpProtectionMode",
367  "Protection mode used when non-ERP STAs are connected to an ERP AP: Rts-Cts or Cts-To-Self",
373  .AddAttribute ("HtProtectionMode",
374  "Protection mode used when non-HT STAs are connected to a HT AP: Rts-Cts or Cts-To-Self",
380  .AddTraceSource ("MacTxRtsFailed",
381  "The transmission of a RTS by the MAC layer has failed",
383  "ns3::Mac48Address::TracedCallback")
384  .AddTraceSource ("MacTxDataFailed",
385  "The transmission of a data packet by the MAC layer has failed",
387  "ns3::Mac48Address::TracedCallback")
388  .AddTraceSource ("MacTxFinalRtsFailed",
389  "The transmission of a RTS has exceeded the maximum number of attempts",
391  "ns3::Mac48Address::TracedCallback")
392  .AddTraceSource ("MacTxFinalDataFailed",
393  "The transmission of a data packet has exceeded the maximum number of attempts",
395  "ns3::Mac48Address::TracedCallback")
396  ;
397  return tid;
398 }
399 
401  : m_qosSupported (false),
402  m_htSupported (false),
403  m_vhtSupported (false),
404  m_heSupported (false),
405  m_useNonErpProtection (false),
406  m_useNonHtProtection (false),
407  m_useGreenfieldProtection (false),
408  m_shortPreambleEnabled (false),
409  m_shortSlotTimeEnabled (false),
410  m_rifsPermitted (false)
411 {
412  NS_LOG_FUNCTION (this);
413 }
414 
416 {
417  NS_LOG_FUNCTION (this);
418 }
419 
420 void
422 {
423  NS_LOG_FUNCTION (this);
424  Reset ();
425 }
426 
427 void
429 {
430  NS_LOG_FUNCTION (this << phy);
431  //We need to track our PHY because it is the object that knows the
432  //full set of transmit rates that are supported. We need to know
433  //this in order to find the relevant mandatory rates when chosing a
434  //transmit rate for automatic control responses like
435  //acknowledgements.
436  m_wifiPhy = phy;
437  m_defaultTxMode = phy->GetMode (0);
439  if (HasHtSupported () || HasVhtSupported () || HasHeSupported ())
440  {
441  m_defaultTxMcs = phy->GetMcs (0);
442  }
443  Reset ();
444 }
445 
446 void
448 {
449  NS_LOG_FUNCTION (this << mac);
450  //We need to track our MAC because it is the object that knows the
451  //full set of interframe spaces.
452  m_wifiMac = mac;
453  Reset ();
454 }
455 
456 void
458 {
459  NS_LOG_FUNCTION (this << enable);
460  m_qosSupported = enable;
461 }
462 
463 void
465 {
466  NS_LOG_FUNCTION (this << enable);
467  m_htSupported = enable;
468 }
469 
470 void
472 {
473  NS_LOG_FUNCTION (this << maxSsrc);
474  m_maxSsrc = maxSsrc;
475 }
476 
477 void
479 {
480  NS_LOG_FUNCTION (this << maxSlrc);
481  m_maxSlrc = maxSlrc;
482 }
483 
484 void
486 {
487  NS_LOG_FUNCTION (this << threshold);
488  m_rtsCtsThreshold = threshold;
489 }
490 
491 void
493 {
494  NS_LOG_FUNCTION (this << threshold);
495  DoSetFragmentationThreshold (threshold);
496 }
497 
498 void
500 {
501  NS_LOG_FUNCTION (this << mode);
502  m_erpProtectionMode = mode;
503 }
504 
505 void
507 {
508  NS_LOG_FUNCTION (this << mode);
509  m_htProtectionMode = mode;
510 }
511 
512 void
514 {
515  NS_LOG_FUNCTION (this << enable);
516  m_shortPreambleEnabled = enable;
517 }
518 
519 void
521 {
522  NS_LOG_FUNCTION (this << enable);
523  m_shortSlotTimeEnabled = enable;
524 }
525 
526 void
528 {
529  NS_LOG_FUNCTION (this << allow);
530  m_rifsPermitted = allow;
531 }
532 
533 bool
535 {
536  return m_shortSlotTimeEnabled;
537 }
538 
539 bool
541 {
542  return m_shortPreambleEnabled;
543 }
544 
545 bool
547 {
548  return m_rifsPermitted;
549 }
550 
553 {
554  return m_erpProtectionMode;
555 }
556 
559 {
560  return m_htProtectionMode;
561 }
562 
563 bool
565 {
566  return m_qosSupported;
567 }
568 
569 bool
571 {
572  return m_htSupported;
573 }
574 
575 void
577 {
578  m_vhtSupported = enable;
579 }
580 
581 bool
583 {
584  return m_vhtSupported;
585 }
586 
587 void
589 {
590  m_heSupported = enable;
591 }
592 
593 bool
595 {
596  return m_heSupported;
597 }
598 
599 uint32_t
601 {
602  return m_maxSsrc;
603 }
604 
605 uint32_t
607 {
608  return m_maxSlrc;
609 }
610 
611 uint32_t
613 {
614  return m_rtsCtsThreshold;
615 }
616 
617 uint32_t
619 {
620  return DoGetFragmentationThreshold ();
621 }
622 
623 void
625 {
626  NS_LOG_FUNCTION (this << address << isShortPreambleSupported);
627  NS_ASSERT (!address.IsGroup ());
628  WifiRemoteStationState *state = LookupState (address);
629  state->m_shortPreamble = isShortPreambleSupported;
630 }
631 
632 void
634 {
635  NS_LOG_FUNCTION (this << address << isShortSlotTimeSupported);
636  NS_ASSERT (!address.IsGroup ());
637  WifiRemoteStationState *state = LookupState (address);
638  state->m_shortSlotTime = isShortSlotTimeSupported;
639 }
640 
641 void
643 {
644  NS_LOG_FUNCTION (this << address << mode);
645  NS_ASSERT (!address.IsGroup ());
646  WifiRemoteStationState *state = LookupState (address);
647  for (WifiModeListIterator i = state->m_operationalRateSet.begin (); i != state->m_operationalRateSet.end (); i++)
648  {
649  if ((*i) == mode)
650  {
651  //already in.
652  return;
653  }
654  }
655  state->m_operationalRateSet.push_back (mode);
656 }
657 
658 void
660 {
661  NS_LOG_FUNCTION (this << address);
662  NS_ASSERT (!address.IsGroup ());
663  WifiRemoteStationState *state = LookupState (address);
664  state->m_operationalRateSet.clear ();
665  for (uint8_t i = 0; i < m_wifiPhy->GetNModes (); i++)
666  {
667  state->m_operationalRateSet.push_back (m_wifiPhy->GetMode (i));
668  if (m_wifiPhy->GetMode (i).IsMandatory ())
669  {
671  }
672  }
673 }
674 
675 void
677 {
678  NS_LOG_FUNCTION (this << address);
679  NS_ASSERT (!address.IsGroup ());
680  WifiRemoteStationState *state = LookupState (address);
681  state->m_operationalMcsSet.clear ();
682  for (uint8_t i = 0; i < m_wifiPhy->GetNMcs (); i++)
683  {
684  state->m_operationalMcsSet.push_back (m_wifiPhy->GetMcs (i));
685  }
686 }
687 
688 void
690 {
691  NS_LOG_FUNCTION (this << address);
692  NS_ASSERT (!address.IsGroup ());
693  WifiRemoteStationState *state = LookupState (address);
694  state->m_operationalMcsSet.clear ();
695 }
696 
697 void
699 {
700  NS_LOG_FUNCTION (this << address << mcs);
701  NS_ASSERT (!address.IsGroup ());
702  WifiRemoteStationState *state = LookupState (address);
703  for (WifiModeListIterator i = state->m_operationalMcsSet.begin (); i != state->m_operationalMcsSet.end (); i++)
704  {
705  if ((*i) == mcs)
706  {
707  //already in.
708  return;
709  }
710  }
711  state->m_operationalMcsSet.push_back (mcs);
712 }
713 
714 bool
716 {
717  return LookupState (address)->m_shortPreamble;
718 }
719 
720 bool
722 {
723  return LookupState (address)->m_shortSlotTime;
724 }
725 
726 bool
728 {
729  return LookupState (address)->m_qosSupported;
730 }
731 
732 bool
734 {
735  if (address.IsGroup ())
736  {
737  return false;
738  }
740 }
741 
742 bool
744 {
745  if (address.IsGroup ())
746  {
747  return true;
748  }
750 }
751 
752 bool
754 {
755  if (address.IsGroup ())
756  {
757  return false;
758  }
760 }
761 
762 void
764 {
765  NS_ASSERT (!address.IsGroup ());
767 }
768 
769 void
771 {
772  NS_ASSERT (!address.IsGroup ());
774 }
775 
776 void
778 {
779  NS_ASSERT (!address.IsGroup ());
781 }
782 
783 void
785 {
786  NS_ASSERT (!address.IsGroup ());
788 }
789 
790 void
792 {
793  NS_LOG_FUNCTION (this << address << *header << packet);
794  if (IsLowLatency () || address.IsGroup ())
795  {
796  return;
797  }
798  WifiRemoteStation *station = Lookup (address, header);
799  WifiTxVector rts = DoGetRtsTxVector (station);
800  WifiTxVector data = DoGetDataTxVector (station);
801  WifiTxVector ctstoself = DoGetCtsToSelfTxVector ();
804  HighLatencyCtsToSelfTxVectorTag ctstoselftag;
805  //first, make sure that the tag is not here anymore.
806  ConstCast<Packet> (packet)->RemovePacketTag (datatag);
807  ConstCast<Packet> (packet)->RemovePacketTag (rtstag);
808  ConstCast<Packet> (packet)->RemovePacketTag (ctstoselftag);
809  datatag = HighLatencyDataTxVectorTag (data);
810  rtstag = HighLatencyRtsTxVectorTag (rts);
811  ctstoselftag = HighLatencyCtsToSelfTxVectorTag (ctstoself);
812  //and then, add it back
813  packet->AddPacketTag (datatag);
814  packet->AddPacketTag (rtstag);
815  packet->AddPacketTag (ctstoselftag);
816 }
817 
818 uint8_t
820 {
821  NS_LOG_FUNCTION (mode << +maxSupportedChannelWidth);
822  WifiModulationClass modulationClass = mode.GetModulationClass ();
823  if (maxSupportedChannelWidth > 20
824  && (modulationClass == WifiModulationClass::WIFI_MOD_CLASS_OFDM // all non-HT OFDM control and management frames
825  || modulationClass == WifiModulationClass::WIFI_MOD_CLASS_ERP_OFDM)) // special case of beacons at 2.4 GHz
826  {
827  NS_LOG_LOGIC ("Channel width reduced to 20 MHz");
828  return 20;
829  }
830  //at 2.4 GHz basic rate can be non-ERP DSSS
831  if (modulationClass == WifiModulationClass::WIFI_MOD_CLASS_DSSS
832  || modulationClass == WifiModulationClass::WIFI_MOD_CLASS_HR_DSSS)
833  {
834  return 22;
835  }
836  return maxSupportedChannelWidth;
837 }
838 
841 {
842  NS_LOG_FUNCTION (this << address << *header << packet);
843  if (address.IsGroup ())
844  {
845  WifiMode mode = GetNonUnicastMode ();
846  WifiTxVector v;
847  v.SetMode (mode);
848  v.SetPreambleType (GetPreambleForTransmission (mode, address));
852  v.SetNss (1);
853  v.SetNess (0);
854  v.SetStbc (m_wifiPhy->GetStbc ());
855  return v;
856  }
857  if (!IsLowLatency ())
858  {
860  bool found;
861  found = ConstCast<Packet> (packet)->PeekPacketTag (datatag);
862  NS_ASSERT (found);
863  //cast found to void, to suppress 'found' set but not used
864  //compiler warning
865  (void) found;
866  return datatag.GetDataTxVector ();
867  }
868  WifiTxVector txVector = DoGetDataTxVector (Lookup (address, header));
869  if (header->IsMgt ())
870  {
871  //Use the lowest basic rate for management frames
872  WifiMode mgtMode;
873  if (GetNBasicModes () > 0)
874  {
875  mgtMode = GetBasicMode (0);
876  }
877  else
878  {
879  mgtMode = GetDefaultMode ();
880  }
881  txVector.SetMode (mgtMode);
882  txVector.SetPreambleType (GetPreambleForTransmission (mgtMode, address));
885  }
886  return txVector;
887 }
888 
891  Ptr<const Packet> packet)
892 {
893  NS_LOG_FUNCTION (this << *header << packet);
894  if (!IsLowLatency ())
895  {
896  HighLatencyCtsToSelfTxVectorTag ctstoselftag;
897  bool found;
898  found = ConstCast<Packet> (packet)->PeekPacketTag (ctstoselftag);
899  NS_ASSERT (found);
900  //cast found to void, to suppress 'found' set but not used
901  //compiler warning
902  (void) found;
903  return ctstoselftag.GetCtsToSelfTxVector ();
904  }
905  return DoGetCtsToSelfTxVector ();
906 }
907 
910 {
911  WifiMode defaultMode = GetDefaultMode ();
912  WifiPreamble defaultPreamble;
913  if (defaultMode.GetModulationClass () == WIFI_MOD_CLASS_HE)
914  {
915  defaultPreamble = WIFI_PREAMBLE_HE_SU;
916  }
917  else if (defaultMode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
918  {
919  defaultPreamble = WIFI_PREAMBLE_VHT;
920  }
921  else if (defaultMode.GetModulationClass () == WIFI_MOD_CLASS_HT)
922  {
923  defaultPreamble = WIFI_PREAMBLE_HT_MF;
924  }
925  else
926  {
927  defaultPreamble = WIFI_PREAMBLE_LONG;
928  }
929 
930  return WifiTxVector (defaultMode,
932  defaultPreamble,
936  0,
938  false,
939  false);
940 }
941 
944  Ptr<const Packet> packet)
945 {
946  NS_LOG_FUNCTION (this << address << *header << packet);
947  NS_ASSERT (!address.IsGroup ());
948  if (!IsLowLatency ())
949  {
951  bool found;
952  found = ConstCast<Packet> (packet)->PeekPacketTag (rtstag);
953  NS_ASSERT (found);
954  //cast found to void, to suppress 'found' set but not used
955  //compiler warning
956  (void) found;
957  return rtstag.GetRtsTxVector ();
958  }
959  return DoGetRtsTxVector (Lookup (address, header));
960 }
961 
962 void
964 {
965  NS_LOG_FUNCTION (this << address << *header);
966  NS_ASSERT (!address.IsGroup ());
967  WifiRemoteStation *station = Lookup (address, header);
968  station->m_ssrc++;
969  m_macTxRtsFailed (address);
970  DoReportRtsFailed (station);
971 }
972 
973 void
975 {
976  NS_LOG_FUNCTION (this << address << *header);
977  NS_ASSERT (!address.IsGroup ());
978  WifiRemoteStation *station = Lookup (address, header);
979  station->m_slrc++;
980  m_macTxDataFailed (address);
981  DoReportDataFailed (station);
982 }
983 
984 void
986  double ctsSnr, WifiMode ctsMode, double rtsSnr)
987 {
988  NS_LOG_FUNCTION (this << address << *header << ctsSnr << ctsMode << rtsSnr);
989  NS_ASSERT (!address.IsGroup ());
990  WifiRemoteStation *station = Lookup (address, header);
991  station->m_state->m_info.NotifyTxSuccess (station->m_ssrc);
992  station->m_ssrc = 0;
993  DoReportRtsOk (station, ctsSnr, ctsMode, rtsSnr);
994 }
995 
996 void
998  double ackSnr, WifiMode ackMode, double dataSnr)
999 {
1000  NS_LOG_FUNCTION (this << address << *header << ackSnr << ackMode << dataSnr);
1001  NS_ASSERT (!address.IsGroup ());
1002  WifiRemoteStation *station = Lookup (address, header);
1003  station->m_state->m_info.NotifyTxSuccess (station->m_slrc);
1004  station->m_slrc = 0;
1005  DoReportDataOk (station, ackSnr, ackMode, dataSnr);
1006 }
1007 
1008 void
1010 {
1011  NS_LOG_FUNCTION (this << address << *header);
1012  NS_ASSERT (!address.IsGroup ());
1013  WifiRemoteStation *station = Lookup (address, header);
1014  station->m_state->m_info.NotifyTxFailed ();
1015  station->m_ssrc = 0;
1016  m_macTxFinalRtsFailed (address);
1017  DoReportFinalRtsFailed (station);
1018 }
1019 
1020 void
1022 {
1023  NS_LOG_FUNCTION (this << address << *header);
1024  NS_ASSERT (!address.IsGroup ());
1025  WifiRemoteStation *station = Lookup (address, header);
1026  station->m_state->m_info.NotifyTxFailed ();
1027  station->m_slrc = 0;
1028  m_macTxFinalDataFailed (address);
1029  DoReportFinalDataFailed (station);
1030 }
1031 
1032 void
1034  double rxSnr, WifiMode txMode)
1035 {
1036  NS_LOG_FUNCTION (this << address << *header << rxSnr << txMode);
1037  if (address.IsGroup ())
1038  {
1039  return;
1040  }
1041  WifiRemoteStation *station = Lookup (address, header);
1042  DoReportRxOk (station, rxSnr, txMode);
1043 }
1044 
1045 void
1047  uint8_t nSuccessfulMpdus, uint8_t nFailedMpdus,
1048  double rxSnr, double dataSnr)
1049 {
1050  NS_LOG_FUNCTION (this << address << +tid << +nSuccessfulMpdus << +nFailedMpdus << rxSnr << dataSnr);
1051  NS_ASSERT (!address.IsGroup ());
1052  WifiRemoteStation *station = Lookup (address, tid);
1053  for (uint8_t i = 0; i < nFailedMpdus; i++)
1054  {
1055  m_macTxDataFailed (address);
1056  }
1057  DoReportAmpduTxStatus (station, nSuccessfulMpdus, nFailedMpdus, rxSnr, dataSnr);
1058 }
1059 
1060 bool
1062  Ptr<const Packet> packet, WifiTxVector txVector)
1063 {
1064  WifiMode mode = txVector.GetMode ();
1065  NS_LOG_FUNCTION (this << address << *header << packet << mode);
1066  if (address.IsGroup ())
1067  {
1068  return false;
1069  }
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::NeedRTS returning true to protect non-ERP stations");
1078  return true;
1079  }
1080  else if (m_htProtectionMode == RTS_CTS
1081  && ((mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
1082  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT))
1085  {
1086  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedRTS returning true to protect non-HT stations");
1087  return true;
1088  }
1089  bool normally = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > GetRtsCtsThreshold ();
1090  return DoNeedRts (Lookup (address, header), packet, normally);
1091 }
1092 
1093 bool
1095 {
1096  WifiMode mode = txVector.GetMode ();
1097  NS_LOG_FUNCTION (this << mode);
1100  || (mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
1101  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
1102  || (mode.GetModulationClass () == WIFI_MOD_CLASS_HE))
1104  {
1105  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true to protect non-ERP stations");
1106  return true;
1107  }
1108  else if (m_htProtectionMode == CTS_TO_SELF
1109  && ((mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
1110  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT))
1113  {
1114  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true to protect non-HT stations");
1115  return true;
1116  }
1117  else if (!m_useNonErpProtection)
1118  {
1119  //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
1120  for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
1121  {
1122  if (mode == *i)
1123  {
1124  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
1125  return false;
1126  }
1127  }
1128  if (HasHtSupported ())
1129  {
1130  //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
1131  for (WifiModeListIterator i = m_bssBasicMcsSet.begin (); i != m_bssBasicMcsSet.end (); i++)
1132  {
1133  if (mode == *i)
1134  {
1135  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
1136  return false;
1137  }
1138  }
1139  }
1140  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true");
1141  return true;
1142  }
1143  return false;
1144 }
1145 
1146 void
1148 {
1149  NS_LOG_FUNCTION (this << enable);
1150  m_useNonErpProtection = enable;
1151 }
1152 
1153 bool
1155 {
1156  return m_useNonErpProtection;
1157 }
1158 
1159 void
1161 {
1162  NS_LOG_FUNCTION (this << enable);
1163  m_useNonHtProtection = enable;
1164 }
1165 
1166 bool
1168 {
1169  return m_useNonHtProtection;
1170 }
1171 
1172 void
1174 {
1175  NS_LOG_FUNCTION (this << enable);
1176  m_useGreenfieldProtection = enable;
1177 }
1178 
1179 bool
1181 {
1183 }
1184 
1185 bool
1187  Ptr<const Packet> packet)
1188 {
1189  NS_LOG_FUNCTION (this << address << packet << *header);
1190  NS_ASSERT (!address.IsGroup ());
1191  WifiRemoteStation *station = Lookup (address, header);
1192  bool normally = station->m_ssrc < GetMaxSsrc ();
1193  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedDataRetransmission count: " << station->m_ssrc << " result: " << std::boolalpha << normally);
1194  return DoNeedRtsRetransmission (station, packet, normally);
1195 }
1196 
1197 bool
1199  Ptr<const Packet> packet)
1200 {
1201  NS_LOG_FUNCTION (this << address << packet << *header);
1202  NS_ASSERT (!address.IsGroup ());
1203  WifiRemoteStation *station = Lookup (address, header);
1204  bool normally = station->m_slrc < GetMaxSlrc ();
1205  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedDataRetransmission count: " << station->m_slrc << " result: " << std::boolalpha << normally);
1206  return DoNeedDataRetransmission (station, packet, normally);
1207 }
1208 
1209 bool
1211  Ptr<const Packet> packet)
1212 {
1213  NS_LOG_FUNCTION (this << address << packet << *header);
1214  if (address.IsGroup ())
1215  {
1216  return false;
1217  }
1218  WifiRemoteStation *station = Lookup (address, header);
1219  bool normally = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > GetFragmentationThreshold ();
1220  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedFragmentation result: " << std::boolalpha << normally);
1221  return DoNeedFragmentation (station, packet, normally);
1222 }
1223 
1224 void
1226 {
1227  NS_LOG_FUNCTION (this << threshold);
1228  if (threshold < 256)
1229  {
1230  /*
1231  * ASN.1 encoding of the MAC and PHY MIB (256 ... 8000)
1232  */
1233  NS_LOG_WARN ("Fragmentation threshold should be larger than 256. Setting to 256.");
1235  }
1236  else
1237  {
1238  /*
1239  * The length of each fragment shall be an even number of octets, except for the last fragment if an MSDU or
1240  * MMPDU, which may be either an even or an odd number of octets.
1241  */
1242  if (threshold % 2 != 0)
1243  {
1244  NS_LOG_WARN ("Fragmentation threshold should be an even number. Setting to " << threshold - 1);
1245  m_nextFragmentationThreshold = threshold - 1;
1246  }
1247  else
1248  {
1249  m_nextFragmentationThreshold = threshold;
1250  }
1251  }
1252 }
1253 
1254 void
1256 {
1258 }
1259 
1260 uint32_t
1262 {
1263  return m_fragmentationThreshold;
1264 }
1265 
1266 uint32_t
1268 {
1269  NS_LOG_FUNCTION (this << *header << packet);
1270  //The number of bytes a fragment can support is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
1271  uint32_t nFragments = (packet->GetSize () / (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
1272 
1273  //If the size of the last fragment is not 0.
1274  if ((packet->GetSize () % (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH)) > 0)
1275  {
1276  nFragments++;
1277  }
1278  NS_LOG_DEBUG ("WifiRemoteStationManager::GetNFragments returning " << nFragments);
1279  return nFragments;
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  uint32_t nFragment = GetNFragments (header, packet);
1289  if (fragmentNumber >= nFragment)
1290  {
1291  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning 0");
1292  return 0;
1293  }
1294  //Last fragment
1295  if (fragmentNumber == nFragment - 1)
1296  {
1297  uint32_t lastFragmentSize = packet->GetSize () - (fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
1298  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << lastFragmentSize);
1299  return lastFragmentSize;
1300  }
1301  //All fragments but the last, the number of bytes is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
1302  else
1303  {
1304  uint32_t fragmentSize = GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH;
1305  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << fragmentSize);
1306  return fragmentSize;
1307  }
1308 }
1309 
1310 uint32_t
1312  Ptr<const Packet> packet, uint32_t fragmentNumber)
1313 {
1314  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
1315  NS_ASSERT (!address.IsGroup ());
1316  NS_ASSERT (fragmentNumber < GetNFragments (header, packet));
1317  uint32_t fragmentOffset = fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH);
1318  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentOffset returning " << fragmentOffset);
1319  return fragmentOffset;
1320 }
1321 
1322 bool
1324  Ptr<const Packet> packet, uint32_t fragmentNumber)
1325 {
1326  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
1327  NS_ASSERT (!address.IsGroup ());
1328  bool isLast = fragmentNumber == (GetNFragments (header, packet) - 1);
1329  NS_LOG_DEBUG ("WifiRemoteStationManager::IsLastFragment returning " << std::boolalpha << isLast);
1330  return isLast;
1331 }
1332 
1333 bool
1335 {
1336  switch (modClassReq)
1337  {
1338  case WIFI_MOD_CLASS_DSSS:
1339  return (modClassAnswer == WIFI_MOD_CLASS_DSSS);
1341  return (modClassAnswer == WIFI_MOD_CLASS_DSSS || modClassAnswer == WIFI_MOD_CLASS_HR_DSSS);
1343  return (modClassAnswer == WIFI_MOD_CLASS_DSSS || modClassAnswer == WIFI_MOD_CLASS_HR_DSSS || modClassAnswer == WIFI_MOD_CLASS_ERP_OFDM);
1344  case WIFI_MOD_CLASS_OFDM:
1345  return (modClassAnswer == WIFI_MOD_CLASS_OFDM);
1346  case WIFI_MOD_CLASS_HT:
1347  case WIFI_MOD_CLASS_VHT:
1348  case WIFI_MOD_CLASS_HE:
1349  return true;
1350  default:
1351  NS_FATAL_ERROR ("Modulation class not defined");
1352  return false;
1353  }
1354 }
1355 
1356 WifiMode
1358 {
1373  NS_LOG_FUNCTION (this << address << reqMode);
1374  WifiMode mode = GetDefaultMode ();
1375  bool found = false;
1376  //First, search the BSS Basic Rate set
1377  for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
1378  {
1379  if ((!found || i->IsHigherDataRate (mode))
1380  && (!i->IsHigherDataRate (reqMode))
1381  && (IsAllowedControlAnswerModulationClass (reqMode.GetModulationClass (), i->GetModulationClass ())))
1382  {
1383  mode = *i;
1384  //We've found a potentially-suitable transmit rate, but we
1385  //need to continue and consider all the basic rates before
1386  //we can be sure we've got the right one.
1387  found = true;
1388  }
1389  }
1390  if (HasHtSupported () || HasVhtSupported () || HasHeSupported ())
1391  {
1392  if (!found)
1393  {
1394  mode = GetDefaultMcs ();
1395  for (WifiModeListIterator i = m_bssBasicMcsSet.begin (); i != m_bssBasicMcsSet.end (); i++)
1396  {
1397  if ((!found || i->IsHigherDataRate (mode))
1398  && (!i->IsHigherDataRate (reqMode))
1399  && (i->GetModulationClass () == reqMode.GetModulationClass ()))
1400  {
1401  mode = *i;
1402  //We've found a potentially-suitable transmit rate, but we
1403  //need to continue and consider all the basic rates before
1404  //we can be sure we've got the right one.
1405  found = true;
1406  }
1407  }
1408  }
1409  }
1410  //If we found a suitable rate in the BSSBasicRateSet, then we are
1411  //done and can return that mode.
1412  if (found)
1413  {
1414  NS_LOG_DEBUG ("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
1415  return mode;
1416  }
1417 
1435  for (uint8_t idx = 0; idx < m_wifiPhy->GetNModes (); idx++)
1436  {
1437  WifiMode thismode = m_wifiPhy->GetMode (idx);
1438  /* If the rate:
1439  *
1440  * - is a mandatory rate for the PHY, and
1441  * - is equal to or faster than our current best choice, and
1442  * - is less than or equal to the rate of the received frame, and
1443  * - is of the same modulation class as the received frame
1444  *
1445  * ...then it's our best choice so far.
1446  */
1447  if (thismode.IsMandatory ()
1448  && (!found || thismode.IsHigherDataRate (mode))
1449  && (!thismode.IsHigherDataRate (reqMode))
1451  {
1452  mode = thismode;
1453  //As above; we've found a potentially-suitable transmit
1454  //rate, but we need to continue and consider all the
1455  //mandatory rates before we can be sure we've got the right one.
1456  found = true;
1457  }
1458  }
1459  if (HasHtSupported () || HasVhtSupported () || HasHeSupported ())
1460  {
1461  for (uint8_t idx = 0; idx < m_wifiPhy->GetNMcs (); idx++)
1462  {
1463  WifiMode thismode = m_wifiPhy->GetMcs (idx);
1464  if (thismode.IsMandatory ()
1465  && (!found || thismode.IsHigherDataRate (mode))
1466  && (!thismode.IsHigherCodeRate (reqMode))
1467  && (thismode.GetModulationClass () == reqMode.GetModulationClass ()))
1468  {
1469  mode = thismode;
1470  //As above; we've found a potentially-suitable transmit
1471  //rate, but we need to continue and consider all the
1472  //mandatory rates before we can be sure we've got the right one.
1473  found = true;
1474  }
1475  }
1476  }
1477 
1488  if (!found)
1489  {
1490  NS_FATAL_ERROR ("Can't find response rate for " << reqMode);
1491  }
1492 
1493  NS_LOG_DEBUG ("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
1494  return mode;
1495 }
1496 
1499 {
1500  NS_ASSERT (!address.IsGroup ());
1501  WifiMode ctsMode = GetControlAnswerMode (address, rtsMode);
1502  WifiTxVector v;
1503  v.SetMode (ctsMode);
1504  v.SetPreambleType (GetPreambleForTransmission (ctsMode, address));
1505  v.SetTxPowerLevel (DoGetCtsTxPowerLevel (address, ctsMode));
1506  v.SetChannelWidth (GetChannelWidthForTransmission (ctsMode, DoGetCtsTxChannelWidth (address, ctsMode)));
1507  v.SetGuardInterval (DoGetCtsTxGuardInterval (address, ctsMode));
1508  v.SetNss (DoGetCtsTxNss (address, ctsMode));
1509  v.SetNess (DoGetCtsTxNess (address, ctsMode));
1510  v.SetStbc (m_wifiPhy->GetStbc ());
1511  return v;
1512 }
1513 
1516 {
1517  NS_ASSERT (!address.IsGroup ());
1518  WifiMode ackMode = GetControlAnswerMode (address, dataMode);
1519  WifiTxVector v;
1520  v.SetMode (ackMode);
1521  v.SetPreambleType (GetPreambleForTransmission (ackMode, address));
1522  v.SetTxPowerLevel (DoGetAckTxPowerLevel (address, ackMode));
1523  v.SetChannelWidth (GetChannelWidthForTransmission (ackMode, DoGetAckTxChannelWidth (address, ackMode)));
1524  v.SetGuardInterval (DoGetAckTxGuardInterval (address, ackMode));
1525  v.SetNss (DoGetAckTxNss (address, ackMode));
1526  v.SetNess (DoGetAckTxNess (address, ackMode));
1527  v.SetStbc (m_wifiPhy->GetStbc ());
1528  return v;
1529 }
1530 
1533 {
1534  NS_ASSERT (!address.IsGroup ());
1535  WifiMode blockAckMode = GetControlAnswerMode (address, blockAckReqMode);
1536  WifiTxVector v;
1537  v.SetMode (blockAckMode);
1538  v.SetPreambleType (GetPreambleForTransmission (blockAckMode, address));
1539  v.SetTxPowerLevel (DoGetBlockAckTxPowerLevel (address, blockAckMode));
1540  v.SetChannelWidth (GetChannelWidthForTransmission (blockAckMode, DoGetBlockAckTxChannelWidth (address, blockAckMode)));
1541  v.SetGuardInterval (DoGetBlockAckTxGuardInterval (address, blockAckMode));
1542  v.SetNss (DoGetBlockAckTxNss (address, blockAckMode));
1543  v.SetNess (DoGetBlockAckTxNess (address, blockAckMode));
1544  v.SetStbc (m_wifiPhy->GetStbc ());
1545  return v;
1546 }
1547 
1548 uint8_t
1550 {
1551  return m_defaultTxPowerLevel;
1552 }
1553 
1554 uint8_t
1556 {
1557  return m_wifiPhy->GetChannelWidth ();
1558 }
1559 
1560 uint16_t
1562 {
1564 }
1565 
1566 uint8_t
1568 {
1569  return 1;
1570 }
1571 
1572 uint8_t
1574 {
1575  return 0;
1576 }
1577 
1578 uint8_t
1580 {
1581  return m_defaultTxPowerLevel;
1582 }
1583 
1584 uint8_t
1586 {
1587  return m_wifiPhy->GetChannelWidth ();
1588 }
1589 
1590 uint16_t
1592 {
1594 }
1595 
1596 uint8_t
1598 {
1599  return 1;
1600 }
1601 
1602 uint8_t
1604 {
1605  return 0;
1606 }
1607 
1608 uint8_t
1610 {
1611  return m_defaultTxPowerLevel;
1612 }
1613 
1614 uint8_t
1616 {
1617  return m_wifiPhy->GetChannelWidth ();
1618 }
1619 
1620 uint16_t
1622 {
1624 }
1625 
1626 uint8_t
1628 {
1629  return 1;
1630 }
1631 
1632 uint8_t
1634 {
1635  return 0;
1636 }
1637 
1638 uint8_t
1640 {
1641  return m_defaultTxPowerLevel;
1642 }
1643 
1646 {
1647  WifiRemoteStationState *state = LookupState (address);
1648  return state->m_info;
1649 }
1650 
1653 {
1654  NS_LOG_FUNCTION (this << address);
1655  for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
1656  {
1657  if ((*i)->m_address == address)
1658  {
1659  NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning existing state");
1660  return (*i);
1661  }
1662  }
1665  state->m_address = address;
1666  state->m_operationalRateSet.push_back (GetDefaultMode ());
1667  state->m_operationalMcsSet.push_back (GetDefaultMcs ());
1671  state->m_greenfield = m_wifiPhy->GetGreenfield ();
1672  state->m_streams = 1;
1673  state->m_ness = 0;
1674  state->m_aggregation = false;
1675  state->m_stbc = false;
1676  state->m_ldpc = false;
1677  state->m_qosSupported = false;
1678  state->m_htSupported = false;
1679  state->m_vhtSupported = false;
1680  state->m_heSupported = false;
1681  const_cast<WifiRemoteStationManager *> (this)->m_states.push_back (state);
1682  NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning new state");
1683  return state;
1684 }
1685 
1688 {
1689  uint8_t tid;
1690  if (header->IsQosData ())
1691  {
1692  tid = header->GetQosTid ();
1693  }
1694  else
1695  {
1696  tid = 0;
1697  }
1698  return Lookup (address, tid);
1699 }
1700 
1703 {
1704  NS_LOG_FUNCTION (this << address << +tid);
1705  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1706  {
1707  if ((*i)->m_tid == tid
1708  && (*i)->m_state->m_address == address)
1709  {
1710  return (*i);
1711  }
1712  }
1713  WifiRemoteStationState *state = LookupState (address);
1714 
1715  WifiRemoteStation *station = DoCreateStation ();
1716  station->m_state = state;
1717  station->m_tid = tid;
1718  station->m_ssrc = 0;
1719  station->m_slrc = 0;
1720  const_cast<WifiRemoteStationManager *> (this)->m_stations.push_back (station);
1721  return station;
1722 }
1723 
1724 void
1726 {
1727  NS_LOG_FUNCTION (this << from << qosSupported);
1728  WifiRemoteStationState *state;
1729  state = LookupState (from);
1730  state->m_qosSupported = qosSupported;
1731 }
1732 
1733 void
1735 {
1736  //Used by all stations to record HT capabilities of remote stations
1737  NS_LOG_FUNCTION (this << from << htCapabilities);
1738  WifiRemoteStationState *state;
1739  state = LookupState (from);
1740  state->m_shortGuardInterval = htCapabilities.GetShortGuardInterval20 ();
1741  if (htCapabilities.GetSupportedChannelWidth () == 1)
1742  {
1743  state->m_channelWidth = 40;
1744  }
1745  else
1746  {
1747  state->m_channelWidth = 20;
1748  }
1749  SetQosSupport (from, true);
1750  state->m_greenfield = htCapabilities.GetGreenfield ();
1751  state->m_streams = htCapabilities.GetRxHighestSupportedAntennas ();
1752  for (uint8_t j = 0; j < m_wifiPhy->GetNMcs (); j++)
1753  {
1754  WifiMode mcs = m_wifiPhy->GetMcs (j);
1755  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HT && htCapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1756  {
1757  AddSupportedMcs (from, mcs);
1758  }
1759  }
1760  state->m_htSupported = true;
1761 }
1762 
1763 void
1765 {
1766  //Used by all stations to record VHT capabilities of remote stations
1767  NS_LOG_FUNCTION (this << from << vhtCapabilities);
1768  WifiRemoteStationState *state;
1769  state = LookupState (from);
1770  if (vhtCapabilities.GetSupportedChannelWidthSet () == 1)
1771  {
1772  state->m_channelWidth = 160;
1773  }
1774  else
1775  {
1776  state->m_channelWidth = 80;
1777  }
1778  //This is a workaround to enable users to force a 20 or 40 MHz channel for a VHT-compliant device,
1779  //since IEEE 802.11ac standard says that 20, 40 and 80 MHz channels are mandatory.
1780  if (m_wifiPhy->GetChannelWidth () < state->m_channelWidth)
1781  {
1783  }
1784  state->m_ldpc = (vhtCapabilities.GetRxLdpc () != 0);
1785  state->m_stbc = (vhtCapabilities.GetTxStbc () != 0 && vhtCapabilities.GetRxStbc () != 0);
1786  for (uint8_t i = 1; i <= m_wifiPhy->GetMaxSupportedTxSpatialStreams (); i++)
1787  {
1788  for (uint8_t j = 0; j < m_wifiPhy->GetNMcs (); j++)
1789  {
1790  WifiMode mcs = m_wifiPhy->GetMcs (j);
1791  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtCapabilities.IsSupportedMcs (mcs.GetMcsValue (), i))
1792  {
1793  AddSupportedMcs (from, mcs);
1794  }
1795  }
1796  }
1797  state->m_vhtSupported = true;
1798 }
1799 
1800 void
1802 {
1803  //Used by all stations to record HE capabilities of remote stations
1804  NS_LOG_FUNCTION (this << from << heCapabilities);
1805  WifiRemoteStationState *state;
1806  state = LookupState (from);
1807  if (Is5Ghz (m_wifiPhy->GetFrequency ()))
1808  {
1809  if (heCapabilities.GetChannelWidthSet () & 0x04)
1810  {
1811  state->m_channelWidth = 160;
1812  }
1813  else if (heCapabilities.GetChannelWidthSet () & 0x02)
1814  {
1815  state->m_channelWidth = 80;
1816  }
1817  //For other cases at 5 GHz, the supported channel width is set by the VHT capabilities
1818  }
1819  else if (Is2_4Ghz (m_wifiPhy->GetFrequency ()))
1820  {
1821  if (heCapabilities.GetChannelWidthSet () & 0x01)
1822  {
1823  state->m_channelWidth = 40;
1824  }
1825  else
1826  {
1827  state->m_channelWidth = 20;
1828  }
1829  }
1830  if (heCapabilities.GetHeLtfAndGiForHePpdus () >= 2)
1831  {
1832  state->m_guardInterval = 800;
1833  }
1834  else if (heCapabilities.GetHeLtfAndGiForHePpdus () == 1)
1835  {
1836  state->m_guardInterval = 1600;
1837  }
1838  else
1839  {
1840  state->m_guardInterval = 3200;
1841  }
1842  state->m_heSupported = true;
1843  SetQosSupport (from, true);
1844 }
1845 
1846 bool
1848 {
1849  return LookupState (address)->m_greenfield;
1850 }
1851 
1852 WifiMode
1854 {
1855  return m_defaultTxMode;
1856 }
1857 
1858 WifiMode
1860 {
1861  return m_defaultTxMcs;
1862 }
1863 
1864 void
1866 {
1867  NS_LOG_FUNCTION (this);
1868  for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
1869  {
1870  delete (*i);
1871  }
1872  m_states.clear ();
1873  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1874  {
1875  delete (*i);
1876  }
1877  m_stations.clear ();
1878  m_bssBasicRateSet.clear ();
1879  m_bssBasicMcsSet.clear ();
1880 }
1881 
1882 void
1884 {
1885  NS_LOG_FUNCTION (this << mode);
1887  {
1888  NS_FATAL_ERROR ("It is not allowed to add a (V)HT rate in the BSSBasicRateSet!");
1889  }
1890  for (uint8_t i = 0; i < GetNBasicModes (); i++)
1891  {
1892  if (GetBasicMode (i) == mode)
1893  {
1894  return;
1895  }
1896  }
1897  m_bssBasicRateSet.push_back (mode);
1898 }
1899 
1900 uint8_t
1902 {
1903  return m_bssBasicRateSet.size ();
1904 }
1905 
1906 WifiMode
1908 {
1909  NS_ASSERT (i < GetNBasicModes ());
1910  return m_bssBasicRateSet[i];
1911 }
1912 
1913 uint32_t
1915 {
1916  uint32_t size = 0;
1917  for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
1918  {
1919  if (i->GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1920  {
1921  continue;
1922  }
1923  size++;
1924  }
1925  return size;
1926 }
1927 
1928 WifiMode
1930 {
1932  uint32_t index = 0;
1933  bool found = false;
1934  for (WifiModeListIterator j = m_bssBasicRateSet.begin (); j != m_bssBasicRateSet.end (); )
1935  {
1936  if (i == index)
1937  {
1938  found = true;
1939  }
1940  if (j->GetModulationClass () != WIFI_MOD_CLASS_ERP_OFDM)
1941  {
1942  if (found)
1943  {
1944  break;
1945  }
1946  }
1947  index++;
1948  j++;
1949  }
1950  return m_bssBasicRateSet[index];
1951 }
1952 
1953 void
1955 {
1956  NS_LOG_FUNCTION (this << +mcs.GetMcsValue ());
1957  for (uint8_t i = 0; i < GetNBasicMcs (); i++)
1958  {
1959  if (GetBasicMcs (i) == mcs)
1960  {
1961  return;
1962  }
1963  }
1964  m_bssBasicMcsSet.push_back (mcs);
1965 }
1966 
1967 uint8_t
1969 {
1970  return m_bssBasicMcsSet.size ();
1971 }
1972 
1973 WifiMode
1975 {
1976  NS_ASSERT (i < GetNBasicMcs ());
1977  return m_bssBasicMcsSet[i];
1978 }
1979 
1980 WifiMode
1982 {
1983  if (m_nonUnicastMode == WifiMode ())
1984  {
1985  if (GetNBasicModes () > 0)
1986  {
1987  return GetBasicMode (0);
1988  }
1989  else
1990  {
1991  return GetDefaultMode ();
1992  }
1993  }
1994  else
1995  {
1996  return m_nonUnicastMode;
1997  }
1998 }
1999 
2000 bool
2002  Ptr<const Packet> packet, bool normally)
2003 {
2004  return normally;
2005 }
2006 
2007 bool
2009  Ptr<const Packet> packet, bool normally)
2010 {
2011  return normally;
2012 }
2013 
2014 bool
2016  Ptr<const Packet> packet, bool normally)
2017 {
2018  return normally;
2019 }
2020 
2021 bool
2023  Ptr<const Packet> packet, bool normally)
2024 {
2025  return normally;
2026 }
2027 
2028 void
2029 WifiRemoteStationManager::DoReportAmpduTxStatus (WifiRemoteStation *station, uint8_t nSuccessfulMpdus, uint8_t nFailedMpdus, double rxSnr, double dataSnr)
2030 {
2031  NS_LOG_DEBUG ("DoReportAmpduTxStatus received but the manager does not handle A-MPDUs!");
2032 }
2033 
2034 WifiMode
2036 {
2037  NS_ASSERT (i < GetNSupported (station));
2038  return station->m_state->m_operationalRateSet[i];
2039 }
2040 
2041 WifiMode
2043 {
2044  NS_ASSERT (i < GetNMcsSupported (station));
2045  return station->m_state->m_operationalMcsSet[i];
2046 }
2047 
2048 WifiMode
2050 {
2051  NS_ASSERT (i < GetNNonErpSupported (station));
2052  //IEEE 802.11g standard defines that if the protection mechanism is enabled, Rts, Cts and Cts-To-Self
2053  //frames should select a rate in the BSSBasicRateSet that corresponds to an 802.11b basic rate.
2054  //This is a implemented here to avoid changes in every RAA, but should maybe be moved in case it breaks standard rules.
2055  uint32_t index = 0;
2056  bool found = false;
2057  for (WifiModeListIterator j = station->m_state->m_operationalRateSet.begin (); j != station->m_state->m_operationalRateSet.end (); )
2058  {
2059  if (i == index)
2060  {
2061  found = true;
2062  }
2063  if (j->GetModulationClass () != WIFI_MOD_CLASS_ERP_OFDM)
2064  {
2065  if (found)
2066  {
2067  break;
2068  }
2069  }
2070  index++;
2071  j++;
2072  }
2073  return station->m_state->m_operationalRateSet[index];
2074 }
2075 
2078 {
2079  return station->m_state->m_address;
2080 }
2081 
2082 uint8_t
2084 {
2085  return station->m_state->m_channelWidth;
2086 }
2087 
2088 bool
2090 {
2091  return station->m_state->m_shortGuardInterval;
2092 }
2093 
2094 uint16_t
2096 {
2097  return station->m_state->m_guardInterval;
2098 }
2099 
2100 bool
2102 {
2103  return station->m_state->m_greenfield;
2104 }
2105 
2106 bool
2108 {
2109  return station->m_state->m_aggregation;
2110 }
2111 
2112 uint8_t
2114 {
2115  return station->m_state->m_streams;
2116 }
2117 
2118 uint32_t
2120 {
2121  return station->m_state->m_ness;
2122 }
2123 
2126 {
2127  return m_wifiPhy;
2128 }
2129 
2132 {
2133  return m_wifiMac;
2134 }
2135 
2136 uint8_t
2138 {
2139  return station->m_state->m_operationalRateSet.size ();
2140 }
2141 
2142 bool
2144 {
2145  return station->m_state->m_qosSupported;
2146 }
2147 
2148 bool
2150 {
2151  return station->m_state->m_htSupported;
2152 }
2153 
2154 bool
2156 {
2157  return station->m_state->m_vhtSupported;
2158 }
2159 
2160 bool
2162 {
2163  return station->m_state->m_heSupported;
2164 }
2165 
2166 uint8_t
2168 {
2169  return station->m_state->m_operationalMcsSet.size ();
2170 }
2171 
2172 uint32_t
2174 {
2175  uint32_t size = 0;
2176  for (WifiModeListIterator i = station->m_state->m_operationalRateSet.begin (); i != station->m_state->m_operationalRateSet.end (); i++)
2177  {
2178  if (i->GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
2179  {
2180  continue;
2181  }
2182  size++;
2183  }
2184  return size;
2185 }
2186 
2187 uint8_t
2189 {
2190  return LookupState (address)->m_channelWidth;
2191 }
2192 
2193 bool
2195 {
2196  return LookupState (address)->m_shortGuardInterval;
2197 }
2198 
2199 uint8_t
2201 {
2202  return LookupState (address)->m_streams;
2203 }
2204 
2205 uint8_t
2207 {
2208  return LookupState (address)->m_operationalMcsSet.size ();
2209 }
2210 
2211 bool
2213 {
2214  return LookupState (address)->m_htSupported;
2215 }
2216 
2217 bool
2219 {
2220  return LookupState (address)->m_vhtSupported;
2221 }
2222 
2223 void
2225 {
2226  m_defaultTxPowerLevel = txPower;
2227 }
2228 
2229 uint8_t
2231 {
2232  return m_wifiPhy->GetNumberOfAntennas ();
2233 }
2234 
2235 uint8_t
2237 {
2239 }
2240 
2243 {
2244  NS_LOG_FUNCTION (this << mode << dest);
2245  WifiPreamble preamble;
2246  if (mode.GetModulationClass () == WIFI_MOD_CLASS_HE)
2247  {
2248  preamble = WIFI_PREAMBLE_HE_SU;
2249  }
2250  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
2251  {
2252  preamble = WIFI_PREAMBLE_VHT;
2253  }
2255  {
2256  //If protection for greenfield is used we go for HT_MF preamble which is the default protection for GF format defined in the standard.
2257  preamble = WIFI_PREAMBLE_HT_GF;
2258  }
2259  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
2260  {
2261  preamble = WIFI_PREAMBLE_HT_MF;
2262  }
2263  else if (GetShortPreambleEnabled ())
2264  {
2265  preamble = WIFI_PREAMBLE_SHORT;
2266  }
2267  else
2268  {
2269  preamble = WIFI_PREAMBLE_LONG;
2270  }
2271  NS_LOG_DEBUG ("selected preamble=" << preamble);
2272  return preamble;
2273 }
2274 
2276 {
2277  NS_LOG_FUNCTION (this);
2278 }
2279 
2281  : m_memoryTime (Seconds (1.0)),
2282  m_lastUpdate (Seconds (0.0)),
2283  m_failAvg (0.0)
2284 {
2285  NS_LOG_FUNCTION (this);
2286 }
2287 
2288 double
2290 {
2291  double retval = std::exp (static_cast<double> (m_lastUpdate.GetMicroSeconds () - Simulator::Now ().GetMicroSeconds ()) / m_memoryTime.GetMicroSeconds ());
2293  return retval;
2294 }
2295 
2296 void
2298 {
2299  double coefficient = CalculateAveragingCoefficient ();
2300  m_failAvg = static_cast<double> (retryCounter) / (1 + retryCounter) * (1 - coefficient) + coefficient * m_failAvg;
2301 }
2302 
2303 void
2305 {
2306  double coefficient = CalculateAveragingCoefficient ();
2307  m_failAvg = (1 - coefficient) + coefficient * m_failAvg;
2308 }
2309 
2310 double
2312 {
2313  return m_failAvg;
2314 }
2315 
2316 } //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
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.
bool GetShortGuardInterval(Mac48Address address) const
Return whether the station supports HT/VHT short guard interval.
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:608
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:81
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:852
bool Is2_4Ghz(double frequency)
Definition: wifi-utils.cc:61
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)
WifiMode GetBasicMcs(uint8_t i) const
Return the MCS at the given list index.
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:821
bool GetShortGuardInterval(void) const
Return whether short guard interval is supported.
Definition: wifi-phy.cc:621
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.
bool Is5Ghz(double frequency)
Definition: wifi-utils.cc:71
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:3582
bool IsLastFragment(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fragmentNumber)
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.
uint16_t GetFrequency(void) const
Definition: wifi-phy.cc:1260
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:595
virtual bool DoNeedRts(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
uint8_t GetRxStbc() const
Get the receive STBC.
Tid independent remote station statistics.
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
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.
uint8_t GetNBasicModes(void) const
Return the number of basic modes we support.
static uint8_t GetChannelWidthForTransmission(WifiMode mode, uint8_t maxSupportedChannelWidth)
Return the channel width that corresponds to the selected mode (instead of letting the PHY's default ...
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:363
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
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.
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:635
void SetMaxSsrc(uint32_t maxSsrc)
Sets the maximum STA short retry count (SSRC).
WifiMode GetMode(uint8_t mode) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
Definition: wifi-phy.cc:3576
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.
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.
bool IsMgt(void) const
Return true if the Type is Management.
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.
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)
bool m_ldpc
Flag if LDPC is supported by the remote station.
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:3588
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
bool IsSupportedMcs(uint8_t mcs) const
Return the is MCS supported flag.
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
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
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.
WifiMode GetBasicMode(uint8_t i) const
Return a basic mode from the set of basic modes.
WifiMode GetNonErpBasicMode(uint8_t i) const
Return a basic mode from the set of basic modes that is not an ERP mode.
virtual uint16_t DoGetCtsTxGuardInterval(Mac48Address address, WifiMode ctsMode)
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
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:1313
WifiMode GetSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether mode associated with the specified station at the specified index. ...
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.
WifiMode GetMcsSupported(const WifiRemoteStation *station, uint8_t i) const
Return the WifiMode supported by the specified station at the specified index.
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:367
HighLatencyCtsToSelfTxVectorTag class.
uint8_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1280
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.
WifiMode GetNonErpSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether non-ERP mode associated with the specified station at the specified index...
bool HasHeSupported(void) const
Return whether the device has HE capability support enabled.
ProtectionMode
ProtectionMode enumeration.
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.
uint8_t GetNBasicMcs(void) const
Return the number of basic MCS index.
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.
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.
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
uint8_t GetNumberOfSupportedStreams(Mac48Address address) const
Return the number of spatial streams supported by the station.
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:1007
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.
uint8_t GetNSupported(const WifiRemoteStation *station) const
Return the number of modes supported by the given station.
void Read(uint8_t *buffer, uint32_t size)
Definition: tag-buffer.cc:176
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)
Ptr< const AttributeChecker > MakeWifiModeChecker(void)
Definition: wifi-mode.cc:674
bool IsSupportedMcs(uint8_t mcs, uint8_t Nss) const
Get the is MCS supported.
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 GetHtSupported(Mac48Address address) const
Return whether the station supports HT or not.
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
uint8_t GetTxStbc() const
Get the transmit STBC.
uint8_t GetRxLdpc() const
Get the receive LDPC.
void SetShortPreambleEnabled(bool enable)
Enable or disable short PLCP preambles.
WifiMode GetMode(void) const
uint8_t GetNumberOfAntennas(void) const
Definition: wifi-phy.cc:1294
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
uint8_t GetChannelWidthSet(void) const
Get channel width set.
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
uint8_t GetNMcsSupported(Mac48Address address) const
Return the number of MCS supported by the station.
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.
DSSS PHY (Clause 15)
Definition: wifi-mode.h:46
uint8_t GetNModes(void) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
Definition: wifi-phy.cc:3570
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.
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.