A Discrete-Event Network Simulator
API
wifi-remote-station-manager.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2006,2007 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 
21 #include "ns3/log.h"
22 #include "ns3/boolean.h"
23 #include "ns3/uinteger.h"
24 #include "ns3/enum.h"
25 #include "ns3/packet.h"
26 #include "ns3/simulator.h"
27 #include "ns3/tag.h"
29 #include "wifi-phy.h"
30 #include "wifi-mac.h"
31 #include "wifi-utils.h"
32 #include "wifi-mac-header.h"
33 #include "wifi-mac-trailer.h"
34 #include "ht-capabilities.h"
35 #include "vht-capabilities.h"
36 #include "he-capabilities.h"
37 
38 /***************************************************************
39  * Packet Mode Tagger
40  ***************************************************************/
41 
42 namespace ns3 {
43 
44 NS_LOG_COMPONENT_DEFINE ("WifiRemoteStationManager");
45 
50 {
51 public:
62  WifiTxVector GetDataTxVector (void) const;
63 
68  static TypeId GetTypeId (void);
69  virtual TypeId GetInstanceTypeId (void) const;
70  virtual uint32_t GetSerializedSize (void) const;
71  virtual void Serialize (TagBuffer i) const;
72  virtual void Deserialize (TagBuffer i);
73  virtual void Print (std::ostream &os) const;
74 
75 private:
77 };
78 
80 {
81 }
82 
84  : m_dataTxVector (dataTxVector)
85 {
86 }
87 
90 {
91  return m_dataTxVector;
92 }
93 
94 TypeId
96 {
97  static TypeId tid = TypeId ("ns3::HighLatencyDataTxVectorTag")
98  .SetParent<Tag> ()
99  .SetGroupName ("Wifi")
100  .AddConstructor<HighLatencyDataTxVectorTag> ()
101  ;
102  return tid;
103 }
104 
105 TypeId
107 {
108  return GetTypeId ();
109 }
110 
111 uint32_t
113 {
114  return sizeof (WifiTxVector);
115 }
116 
117 void
119 {
120  i.Write ((uint8_t *)&m_dataTxVector, sizeof (WifiTxVector));
121 }
122 
123 void
125 {
126  i.Read ((uint8_t *)&m_dataTxVector, sizeof (WifiTxVector));
127 }
128 
129 void
130 HighLatencyDataTxVectorTag::Print (std::ostream &os) const
131 {
132  os << "Data=" << m_dataTxVector;
133 }
134 
139 {
140 public:
152  WifiTxVector GetRtsTxVector (void) const;
153 
158  static TypeId GetTypeId (void);
159  virtual TypeId GetInstanceTypeId (void) const;
160  virtual uint32_t GetSerializedSize (void) const;
161  virtual void Serialize (TagBuffer i) const;
162  virtual void Deserialize (TagBuffer i);
163  virtual void Print (std::ostream &os) const;
164 
165 private:
167 };
168 
170 {
171 }
172 
174  : m_rtsTxVector (rtsTxVector)
175 {
176 }
177 
180 {
181  return m_rtsTxVector;
182 }
183 
184 TypeId
186 {
187  static TypeId tid = TypeId ("ns3::HighLatencyRtsTxVectorTag")
188  .SetParent<Tag> ()
189  .SetGroupName ("Wifi")
190  .AddConstructor<HighLatencyRtsTxVectorTag> ()
191  ;
192  return tid;
193 }
194 
195 TypeId
197 {
198  return GetTypeId ();
199 }
200 
201 uint32_t
203 {
204  return sizeof (WifiTxVector);
205 }
206 
207 void
209 {
210  i.Write ((uint8_t *)&m_rtsTxVector, sizeof (WifiTxVector));
211 }
212 
213 void
215 {
216  i.Read ((uint8_t *)&m_rtsTxVector, sizeof (WifiTxVector));
217 }
218 
219 void
220 HighLatencyRtsTxVectorTag::Print (std::ostream &os) const
221 {
222  os << "Rts=" << m_rtsTxVector;
223 }
224 
229 {
230 public:
237  HighLatencyCtsToSelfTxVectorTag (WifiTxVector ctsToSelfTxVector);
241  WifiTxVector GetCtsToSelfTxVector (void) const;
242 
247  static TypeId GetTypeId (void);
248  virtual TypeId GetInstanceTypeId (void) const;
249  virtual uint32_t GetSerializedSize (void) const;
250  virtual void Serialize (TagBuffer i) const;
251  virtual void Deserialize (TagBuffer i);
252  virtual void Print (std::ostream &os) const;
253 
254 private:
256 };
257 
259 {
260 }
261 
263  : m_ctsToSelfTxVector (ctsToSelfTxVector)
264 {
265 }
266 
269 {
270  return m_ctsToSelfTxVector;
271 }
272 
273 TypeId
275 {
276  static TypeId tid = TypeId ("ns3::HighLatencyCtsToSelfTxVectorTag")
277  .SetParent<Tag> ()
278  .SetGroupName ("Wifi")
279  .AddConstructor<HighLatencyCtsToSelfTxVectorTag> ()
280  ;
281  return tid;
282 }
283 
284 TypeId
286 {
287  return GetTypeId ();
288 }
289 
290 uint32_t
292 {
293  return sizeof (WifiTxVector);
294 }
295 
296 void
298 {
299  i.Write ((uint8_t *)&m_ctsToSelfTxVector, sizeof (WifiTxVector));
300 }
301 
302 void
304 {
305  i.Read ((uint8_t *)&m_ctsToSelfTxVector, sizeof (WifiTxVector));
306 }
307 
308 void
310 {
311  os << "Cts To Self=" << m_ctsToSelfTxVector;
312 }
313 
314 } //namespace ns3
315 
316 namespace ns3 {
317 
319 
320 TypeId
322 {
323  static TypeId tid = TypeId ("ns3::WifiRemoteStationManager")
324  .SetParent<Object> ()
325  .SetGroupName ("Wifi")
326  .AddAttribute ("IsLowLatency",
327  "If true, we attempt to modelize a so-called low-latency device: "
328  "a device where decisions about tx parameters can be made on a per-packet basis and "
329  "feedback about the transmission of each packet is obtained before sending the next. "
330  "Otherwise, we modelize a high-latency device, that is a device where we cannot update "
331  "our decision about tx parameters after every packet transmission.",
333  BooleanValue (true), //this value is ignored because there is no setter
336  .AddAttribute ("MaxSsrc",
337  "The maximum number of retransmission attempts for any packet with size <= RtsCtsThreshold. "
338  "This value will not have any effect on some rate control algorithms.",
339  UintegerValue (7),
341  MakeUintegerChecker<uint32_t> ())
342  .AddAttribute ("MaxSlrc",
343  "The maximum number of retransmission attempts for any packet with size > RtsCtsThreshold. "
344  "This value will not have any effect on some rate control algorithms.",
345  UintegerValue (4),
347  MakeUintegerChecker<uint32_t> ())
348  .AddAttribute ("RtsCtsThreshold",
349  "If the size of the PSDU is bigger than this value, we use an RTS/CTS handshake before sending the data frame."
350  "This value will not have any effect on some rate control algorithms.",
351  UintegerValue (65535),
353  MakeUintegerChecker<uint32_t> ())
354  .AddAttribute ("FragmentationThreshold",
355  "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. "
356  "This value does not apply when it is carried in an A-MPDU. "
357  "This value will not have any effect on some rate control algorithms.",
358  UintegerValue (65535),
361  MakeUintegerChecker<uint32_t> ())
362  .AddAttribute ("NonUnicastMode",
363  "Wifi mode used for non-unicast transmissions.",
364  WifiModeValue (),
367  .AddAttribute ("DefaultTxPowerLevel",
368  "Default power level to be used for transmissions. "
369  "This is the power level that is used by all those WifiManagers that do not implement TX power control.",
370  UintegerValue (0),
372  MakeUintegerChecker<uint8_t> ())
373  .AddAttribute ("ErpProtectionMode",
374  "Protection mode used when non-ERP STAs are connected to an ERP AP: Rts-Cts or Cts-To-Self",
379  .AddAttribute ("HtProtectionMode",
380  "Protection mode used when non-HT STAs are connected to a HT AP: Rts-Cts or Cts-To-Self",
385  .AddTraceSource ("MacTxRtsFailed",
386  "The transmission of a RTS by the MAC layer has failed",
388  "ns3::Mac48Address::TracedCallback")
389  .AddTraceSource ("MacTxDataFailed",
390  "The transmission of a data packet by the MAC layer has failed",
392  "ns3::Mac48Address::TracedCallback")
393  .AddTraceSource ("MacTxFinalRtsFailed",
394  "The transmission of a RTS has exceeded the maximum number of attempts",
396  "ns3::Mac48Address::TracedCallback")
397  .AddTraceSource ("MacTxFinalDataFailed",
398  "The transmission of a data packet has exceeded the maximum number of attempts",
400  "ns3::Mac48Address::TracedCallback")
401  ;
402  return tid;
403 }
404 
406  : m_htSupported (false),
407  m_vhtSupported (false),
408  m_heSupported (false),
409  m_pcfSupported (false),
410  m_useNonErpProtection (false),
411  m_useNonHtProtection (false),
412  m_useGreenfieldProtection (false),
413  m_shortPreambleEnabled (false),
414  m_shortSlotTimeEnabled (false),
415  m_rifsPermitted (false)
416 {
417  NS_LOG_FUNCTION (this);
418 }
419 
421 {
422  NS_LOG_FUNCTION (this);
423 }
424 
425 void
427 {
428  NS_LOG_FUNCTION (this);
429  Reset ();
430 }
431 
432 void
434 {
435  NS_LOG_FUNCTION (this << phy);
436  //We need to track our PHY because it is the object that knows the
437  //full set of transmit rates that are supported. We need to know
438  //this in order to find the relevant mandatory rates when choosing a
439  //transmit rate for automatic control responses like
440  //acknowledgements.
441  m_wifiPhy = phy;
442  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  NS_LOG_FUNCTION (this << mac);
455  //We need to track our MAC because it is the object that knows the
456  //full set of interframe spaces.
457  m_wifiMac = mac;
458  Reset ();
459 }
460 
461 void
463 {
464  NS_LOG_FUNCTION (this << maxSsrc);
465  m_maxSsrc = maxSsrc;
466 }
467 
468 void
470 {
471  NS_LOG_FUNCTION (this << maxSlrc);
472  m_maxSlrc = maxSlrc;
473 }
474 
475 void
477 {
478  NS_LOG_FUNCTION (this << threshold);
479  m_rtsCtsThreshold = threshold;
480 }
481 
482 void
484 {
485  NS_LOG_FUNCTION (this << enable);
486  m_htSupported = enable;
487 }
488 
489 void
491 {
492  NS_LOG_FUNCTION (this << threshold);
493  DoSetFragmentationThreshold (threshold);
494 }
495 
496 void
498 {
499  NS_LOG_FUNCTION (this << enable);
500  m_shortPreambleEnabled = enable;
501 }
502 
503 void
505 {
506  NS_LOG_FUNCTION (this << enable);
507  m_shortSlotTimeEnabled = enable;
508 }
509 
510 void
512 {
513  NS_LOG_FUNCTION (this << allow);
514  m_rifsPermitted = allow;
515 }
516 
517 bool
519 {
520  return m_shortSlotTimeEnabled;
521 }
522 
523 bool
525 {
526  return m_shortPreambleEnabled;
527 }
528 
529 bool
531 {
532  return m_rifsPermitted;
533 }
534 
535 bool
537 {
538  return m_htSupported;
539 }
540 
541 void
543 {
544  m_vhtSupported = enable;
545 }
546 
547 bool
549 {
550  return m_vhtSupported;
551 }
552 
553 void
555 {
556  m_heSupported = enable;
557 }
558 
559 bool
561 {
562  return m_heSupported;
563 }
564 
565 void
567 {
568  m_pcfSupported = enable;
569 }
570 
571 bool
573 {
574  return m_pcfSupported;
575 }
576 
577 uint32_t
579 {
580  return DoGetFragmentationThreshold ();
581 }
582 
583 void
585 {
586  NS_LOG_FUNCTION (this << address << isShortPreambleSupported);
587  NS_ASSERT (!address.IsGroup ());
588  WifiRemoteStationState *state = LookupState (address);
589  state->m_shortPreamble = isShortPreambleSupported;
590 }
591 
592 void
594 {
595  NS_LOG_FUNCTION (this << address << isShortSlotTimeSupported);
596  NS_ASSERT (!address.IsGroup ());
597  WifiRemoteStationState *state = LookupState (address);
598  state->m_shortSlotTime = isShortSlotTimeSupported;
599 }
600 
601 void
603 {
604  NS_LOG_FUNCTION (this << address << mode);
605  NS_ASSERT (!address.IsGroup ());
606  WifiRemoteStationState *state = LookupState (address);
607  for (WifiModeListIterator i = state->m_operationalRateSet.begin (); i != state->m_operationalRateSet.end (); i++)
608  {
609  if ((*i) == mode)
610  {
611  //already in.
612  return;
613  }
614  }
615  state->m_operationalRateSet.push_back (mode);
616 }
617 
618 void
620 {
621  NS_LOG_FUNCTION (this << address);
622  NS_ASSERT (!address.IsGroup ());
623  WifiRemoteStationState *state = LookupState (address);
624  state->m_operationalRateSet.clear ();
625  for (uint8_t i = 0; i < m_wifiPhy->GetNModes (); i++)
626  {
627  state->m_operationalRateSet.push_back (m_wifiPhy->GetMode (i));
628  if (m_wifiPhy->GetMode (i).IsMandatory ())
629  {
631  }
632  }
633 }
634 
635 void
637 {
638  NS_LOG_FUNCTION (this << address);
639  NS_ASSERT (!address.IsGroup ());
640  WifiRemoteStationState *state = LookupState (address);
641  state->m_operationalMcsSet.clear ();
642  for (uint8_t i = 0; i < m_wifiPhy->GetNMcs (); i++)
643  {
644  state->m_operationalMcsSet.push_back (m_wifiPhy->GetMcs (i));
645  }
646 }
647 
648 void
650 {
651  NS_LOG_FUNCTION (this << address);
652  NS_ASSERT (!address.IsGroup ());
653  WifiRemoteStationState *state = LookupState (address);
654  state->m_operationalMcsSet.clear ();
655 }
656 
657 void
659 {
660  NS_LOG_FUNCTION (this << address << mcs);
661  NS_ASSERT (!address.IsGroup ());
662  WifiRemoteStationState *state = LookupState (address);
663  for (WifiModeListIterator i = state->m_operationalMcsSet.begin (); i != state->m_operationalMcsSet.end (); i++)
664  {
665  if ((*i) == mcs)
666  {
667  //already in.
668  return;
669  }
670  }
671  state->m_operationalMcsSet.push_back (mcs);
672 }
673 
674 bool
676 {
677  return LookupState (address)->m_shortPreamble;
678 }
679 
680 bool
682 {
683  return LookupState (address)->m_shortSlotTime;
684 }
685 
686 bool
688 {
689  return LookupState (address)->m_qosSupported;
690 }
691 
692 bool
694 {
695  if (address.IsGroup ())
696  {
697  return false;
698  }
700 }
701 
702 bool
704 {
705  if (address.IsGroup ())
706  {
707  return true;
708  }
710 }
711 
712 bool
714 {
715  if (address.IsGroup ())
716  {
717  return false;
718  }
720 }
721 
722 void
724 {
725  NS_ASSERT (!address.IsGroup ());
727 }
728 
729 void
731 {
732  NS_ASSERT (!address.IsGroup ());
734 }
735 
736 void
738 {
739  NS_ASSERT (!address.IsGroup ());
741 }
742 
743 void
745 {
746  NS_ASSERT (!address.IsGroup ());
748 }
749 
750 void
752 {
753  NS_LOG_FUNCTION (this << address << *header << packet);
754  if (IsLowLatency () || address.IsGroup ())
755  {
756  return;
757  }
758  WifiRemoteStation *station = Lookup (address, header);
759  WifiTxVector rts = DoGetRtsTxVector (station);
760  WifiTxVector data = DoGetDataTxVector (station);
761  WifiTxVector ctstoself = DoGetCtsToSelfTxVector ();
764  HighLatencyCtsToSelfTxVectorTag ctstoselftag;
765  //first, make sure that the tag is not here anymore.
766  ConstCast<Packet> (packet)->RemovePacketTag (datatag);
767  ConstCast<Packet> (packet)->RemovePacketTag (rtstag);
768  ConstCast<Packet> (packet)->RemovePacketTag (ctstoselftag);
769  datatag = HighLatencyDataTxVectorTag (data);
770  rtstag = HighLatencyRtsTxVectorTag (rts);
771  ctstoselftag = HighLatencyCtsToSelfTxVectorTag (ctstoself);
772  //and then, add it back
773  packet->AddPacketTag (datatag);
774  packet->AddPacketTag (rtstag);
775  packet->AddPacketTag (ctstoselftag);
776 }
777 
778 uint16_t
780 {
781  NS_LOG_FUNCTION (mode << maxSupportedChannelWidth);
782  WifiModulationClass modulationClass = mode.GetModulationClass ();
783  if (maxSupportedChannelWidth > 20
784  && (modulationClass == WifiModulationClass::WIFI_MOD_CLASS_OFDM // all non-HT OFDM control and management frames
785  || modulationClass == WifiModulationClass::WIFI_MOD_CLASS_ERP_OFDM)) // special case of beacons at 2.4 GHz
786  {
787  NS_LOG_LOGIC ("Channel width reduced to 20 MHz");
788  return 20;
789  }
790  //at 2.4 GHz basic rate can be non-ERP DSSS
791  if (modulationClass == WifiModulationClass::WIFI_MOD_CLASS_DSSS
792  || modulationClass == WifiModulationClass::WIFI_MOD_CLASS_HR_DSSS)
793  {
794  return 22;
795  }
796  return maxSupportedChannelWidth;
797 }
798 
801 {
802  NS_LOG_FUNCTION (this << address << *header << packet);
803  if (address.IsGroup ())
804  {
805  WifiMode mode = GetNonUnicastMode ();
806  WifiTxVector v;
807  v.SetMode (mode);
808  v.SetPreambleType (GetPreambleForTransmission (mode, address));
812  v.SetNTx (1);
813  v.SetNss (1);
814  v.SetNess (0);
815  v.SetStbc (m_wifiPhy->GetStbc ());
816  return v;
817  }
818  if (!IsLowLatency ())
819  {
821  bool found;
822  found = ConstCast<Packet> (packet)->PeekPacketTag (datatag);
823  NS_ASSERT (found);
824  //cast found to void, to suppress 'found' set but not used
825  //compiler warning
826  (void) found;
827  return datatag.GetDataTxVector ();
828  }
829  WifiTxVector txVector = DoGetDataTxVector (Lookup (address, header));
830  if (header->IsMgt ())
831  {
832  //Use the lowest basic rate for management frames
833  WifiMode mgtMode;
834  if (GetNBasicModes () > 0)
835  {
836  mgtMode = GetBasicMode (0);
837  }
838  else
839  {
840  mgtMode = GetDefaultMode ();
841  }
842  txVector.SetMode (mgtMode);
843  txVector.SetPreambleType (GetPreambleForTransmission (mgtMode, address));
846  }
847  return txVector;
848 }
849 
852  Ptr<const Packet> packet)
853 {
854  NS_LOG_FUNCTION (this << *header << packet);
855  if (!IsLowLatency ())
856  {
857  HighLatencyCtsToSelfTxVectorTag ctstoselftag;
858  bool found;
859  found = ConstCast<Packet> (packet)->PeekPacketTag (ctstoselftag);
860  NS_ASSERT (found);
861  //cast found to void, to suppress 'found' set but not used
862  //compiler warning
863  (void) found;
864  return ctstoselftag.GetCtsToSelfTxVector ();
865  }
866  return DoGetCtsToSelfTxVector ();
867 }
868 
871 {
872  WifiMode defaultMode = GetDefaultMode ();
873  WifiPreamble defaultPreamble;
874  if (defaultMode.GetModulationClass () == WIFI_MOD_CLASS_HE)
875  {
876  defaultPreamble = WIFI_PREAMBLE_HE_SU;
877  }
878  else if (defaultMode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
879  {
880  defaultPreamble = WIFI_PREAMBLE_VHT;
881  }
882  else if (defaultMode.GetModulationClass () == WIFI_MOD_CLASS_HT)
883  {
884  defaultPreamble = WIFI_PREAMBLE_HT_MF;
885  }
886  else
887  {
888  defaultPreamble = WIFI_PREAMBLE_LONG;
889  }
890 
891  return WifiTxVector (defaultMode,
893  defaultPreamble,
897  0,
899  false,
900  false);
901 }
902 
905  Ptr<const Packet> packet)
906 {
907  NS_LOG_FUNCTION (this << address << *header << packet);
908  NS_ASSERT (!address.IsGroup ());
909  if (!IsLowLatency ())
910  {
912  bool found;
913  found = ConstCast<Packet> (packet)->PeekPacketTag (rtstag);
914  NS_ASSERT (found);
915  //cast found to void, to suppress 'found' set but not used
916  //compiler warning
917  (void) found;
918  return rtstag.GetRtsTxVector ();
919  }
920  return DoGetRtsTxVector (Lookup (address, header));
921 }
922 
923 void
925 {
926  NS_LOG_FUNCTION (this << address << *header);
927  NS_ASSERT (!address.IsGroup ());
928  WifiRemoteStation *station = Lookup (address, header);
929  station->m_ssrc++;
930  m_macTxRtsFailed (address);
931  DoReportRtsFailed (station);
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_slrc++;
941  m_macTxDataFailed (address);
942  DoReportDataFailed (station);
943 }
944 
945 void
947  double ctsSnr, WifiMode ctsMode, double rtsSnr)
948 {
949  NS_LOG_FUNCTION (this << address << *header << ctsSnr << ctsMode << rtsSnr);
950  NS_ASSERT (!address.IsGroup ());
951  WifiRemoteStation *station = Lookup (address, header);
952  station->m_state->m_info.NotifyTxSuccess (station->m_ssrc);
953  station->m_ssrc = 0;
954  DoReportRtsOk (station, ctsSnr, ctsMode, rtsSnr);
955 }
956 
957 void
959  double ackSnr, WifiMode ackMode, double dataSnr)
960 {
961  NS_LOG_FUNCTION (this << address << *header << ackSnr << ackMode << dataSnr);
962  NS_ASSERT (!address.IsGroup ());
963  WifiRemoteStation *station = Lookup (address, header);
964  station->m_state->m_info.NotifyTxSuccess (station->m_slrc);
965  station->m_slrc = 0;
966  DoReportDataOk (station, ackSnr, ackMode, dataSnr);
967 }
968 
969 void
971 {
972  NS_LOG_FUNCTION (this << address << *header);
973  NS_ASSERT (!address.IsGroup ());
974  WifiRemoteStation *station = Lookup (address, header);
975  station->m_state->m_info.NotifyTxFailed ();
976  station->m_ssrc = 0;
977  m_macTxFinalRtsFailed (address);
978  DoReportFinalRtsFailed (station);
979 }
980 
981 void
983 {
984  NS_LOG_FUNCTION (this << address << *header);
985  NS_ASSERT (!address.IsGroup ());
986  WifiRemoteStation *station = Lookup (address, header);
987  station->m_state->m_info.NotifyTxFailed ();
988  station->m_slrc = 0;
989  m_macTxFinalDataFailed (address);
990  DoReportFinalDataFailed (station);
991 }
992 
993 void
995  double rxSnr, WifiMode txMode)
996 {
997  NS_LOG_FUNCTION (this << address << *header << rxSnr << txMode);
998  if (address.IsGroup ())
999  {
1000  return;
1001  }
1002  WifiRemoteStation *station = Lookup (address, header);
1003  DoReportRxOk (station, rxSnr, txMode);
1004 }
1005 
1006 void
1008  uint8_t nSuccessfulMpdus, uint8_t nFailedMpdus,
1009  double rxSnr, double dataSnr)
1010 {
1011  NS_LOG_FUNCTION (this << address << +tid << +nSuccessfulMpdus << +nFailedMpdus << rxSnr << dataSnr);
1012  NS_ASSERT (!address.IsGroup ());
1013  WifiRemoteStation *station = Lookup (address, tid);
1014  for (uint8_t i = 0; i < nFailedMpdus; i++)
1015  {
1016  m_macTxDataFailed (address);
1017  }
1018  DoReportAmpduTxStatus (station, nSuccessfulMpdus, nFailedMpdus, rxSnr, dataSnr);
1019 }
1020 
1021 bool
1023  Ptr<const Packet> packet, WifiTxVector txVector)
1024 {
1025  WifiMode mode = txVector.GetMode ();
1026  NS_LOG_FUNCTION (this << address << *header << packet << mode);
1027  if (address.IsGroup ())
1028  {
1029  return false;
1030  }
1033  || (mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
1034  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
1035  || (mode.GetModulationClass () == WIFI_MOD_CLASS_HE))
1037  {
1038  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedRTS returning true to protect non-ERP stations");
1039  return true;
1040  }
1041  else if (m_htProtectionMode == RTS_CTS
1042  && ((mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
1043  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT))
1046  {
1047  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedRTS returning true to protect non-HT stations");
1048  return true;
1049  }
1050  bool normally = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > m_rtsCtsThreshold;
1051  return DoNeedRts (Lookup (address, header), packet, normally);
1052 }
1053 
1054 bool
1056 {
1057  WifiMode mode = txVector.GetMode ();
1058  NS_LOG_FUNCTION (this << mode);
1061  || (mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
1062  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
1063  || (mode.GetModulationClass () == WIFI_MOD_CLASS_HE))
1065  {
1066  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true to protect non-ERP stations");
1067  return true;
1068  }
1069  else if (m_htProtectionMode == CTS_TO_SELF
1070  && ((mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
1071  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT))
1074  {
1075  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true to protect non-HT stations");
1076  return true;
1077  }
1078  else if (!m_useNonErpProtection)
1079  {
1080  //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
1081  for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
1082  {
1083  if (mode == *i)
1084  {
1085  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
1086  return false;
1087  }
1088  }
1089  if (HasHtSupported ())
1090  {
1091  //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
1092  for (WifiModeListIterator i = m_bssBasicMcsSet.begin (); i != m_bssBasicMcsSet.end (); i++)
1093  {
1094  if (mode == *i)
1095  {
1096  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
1097  return false;
1098  }
1099  }
1100  }
1101  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true");
1102  return true;
1103  }
1104  return false;
1105 }
1106 
1107 void
1109 {
1110  NS_LOG_FUNCTION (this << enable);
1111  m_useNonErpProtection = enable;
1112 }
1113 
1114 bool
1116 {
1117  return m_useNonErpProtection;
1118 }
1119 
1120 void
1122 {
1123  NS_LOG_FUNCTION (this << enable);
1124  m_useNonHtProtection = enable;
1125 }
1126 
1127 bool
1129 {
1130  return m_useNonHtProtection;
1131 }
1132 
1133 void
1135 {
1136  NS_LOG_FUNCTION (this << enable);
1137  m_useGreenfieldProtection = enable;
1138 }
1139 
1140 bool
1142 {
1144 }
1145 
1146 bool
1148  Ptr<const Packet> packet)
1149 {
1150  NS_LOG_FUNCTION (this << address << packet << *header);
1151  NS_ASSERT (!address.IsGroup ());
1152  WifiRemoteStation *station = Lookup (address, header);
1153  bool longMpdu = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > m_rtsCtsThreshold;
1154  uint32_t retryCount, maxRetryCount;
1155  if (longMpdu)
1156  {
1157  retryCount = station->m_slrc;
1158  maxRetryCount = m_maxSlrc;
1159  }
1160  else
1161  {
1162  retryCount = station->m_ssrc;
1163  maxRetryCount = m_maxSsrc;
1164  }
1165  bool normally = retryCount < maxRetryCount;
1166  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedRetransmission count: " << retryCount << " result: " << std::boolalpha << normally);
1167  return DoNeedRetransmission (station, packet, normally);
1168 }
1169 
1170 bool
1172  Ptr<const Packet> packet)
1173 {
1174  NS_LOG_FUNCTION (this << address << packet << *header);
1175  if (address.IsGroup ())
1176  {
1177  return false;
1178  }
1179  WifiRemoteStation *station = Lookup (address, header);
1180  bool normally = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > GetFragmentationThreshold ();
1181  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedFragmentation result: " << std::boolalpha << normally);
1182  return DoNeedFragmentation (station, packet, normally);
1183 }
1184 
1185 void
1187 {
1188  NS_LOG_FUNCTION (this << threshold);
1189  if (threshold < 256)
1190  {
1191  /*
1192  * ASN.1 encoding of the MAC and PHY MIB (256 ... 8000)
1193  */
1194  NS_LOG_WARN ("Fragmentation threshold should be larger than 256. Setting to 256.");
1196  }
1197  else
1198  {
1199  /*
1200  * The length of each fragment shall be an even number of octets, except for the last fragment if an MSDU or
1201  * MMPDU, which may be either an even or an odd number of octets.
1202  */
1203  if (threshold % 2 != 0)
1204  {
1205  NS_LOG_WARN ("Fragmentation threshold should be an even number. Setting to " << threshold - 1);
1206  m_nextFragmentationThreshold = threshold - 1;
1207  }
1208  else
1209  {
1210  m_nextFragmentationThreshold = threshold;
1211  }
1212  }
1213 }
1214 
1215 void
1217 {
1219 }
1220 
1221 uint32_t
1223 {
1224  return m_fragmentationThreshold;
1225 }
1226 
1227 uint32_t
1229 {
1230  NS_LOG_FUNCTION (this << *header << packet);
1231  //The number of bytes a fragment can support is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
1232  uint32_t nFragments = (packet->GetSize () / (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
1233 
1234  //If the size of the last fragment is not 0.
1235  if ((packet->GetSize () % (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH)) > 0)
1236  {
1237  nFragments++;
1238  }
1239  NS_LOG_DEBUG ("WifiRemoteStationManager::GetNFragments returning " << nFragments);
1240  return nFragments;
1241 }
1242 
1243 uint32_t
1245  Ptr<const Packet> packet, uint32_t fragmentNumber)
1246 {
1247  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
1248  NS_ASSERT (!address.IsGroup ());
1249  uint32_t nFragment = GetNFragments (header, packet);
1250  if (fragmentNumber >= nFragment)
1251  {
1252  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning 0");
1253  return 0;
1254  }
1255  //Last fragment
1256  if (fragmentNumber == nFragment - 1)
1257  {
1258  uint32_t lastFragmentSize = packet->GetSize () - (fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
1259  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << lastFragmentSize);
1260  return lastFragmentSize;
1261  }
1262  //All fragments but the last, the number of bytes is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
1263  else
1264  {
1265  uint32_t fragmentSize = GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH;
1266  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << fragmentSize);
1267  return fragmentSize;
1268  }
1269 }
1270 
1271 uint32_t
1273  Ptr<const Packet> packet, uint32_t fragmentNumber)
1274 {
1275  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
1276  NS_ASSERT (!address.IsGroup ());
1277  NS_ASSERT (fragmentNumber < GetNFragments (header, packet));
1278  uint32_t fragmentOffset = fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH);
1279  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentOffset returning " << fragmentOffset);
1280  return fragmentOffset;
1281 }
1282 
1283 bool
1285  Ptr<const Packet> packet, uint32_t fragmentNumber)
1286 {
1287  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
1288  NS_ASSERT (!address.IsGroup ());
1289  bool isLast = fragmentNumber == (GetNFragments (header, packet) - 1);
1290  NS_LOG_DEBUG ("WifiRemoteStationManager::IsLastFragment returning " << std::boolalpha << isLast);
1291  return isLast;
1292 }
1293 
1294 bool
1296 {
1297  switch (modClassReq)
1298  {
1299  case WIFI_MOD_CLASS_DSSS:
1300  return (modClassAnswer == WIFI_MOD_CLASS_DSSS);
1302  return (modClassAnswer == WIFI_MOD_CLASS_DSSS || modClassAnswer == WIFI_MOD_CLASS_HR_DSSS);
1304  return (modClassAnswer == WIFI_MOD_CLASS_DSSS || modClassAnswer == WIFI_MOD_CLASS_HR_DSSS || modClassAnswer == WIFI_MOD_CLASS_ERP_OFDM);
1305  case WIFI_MOD_CLASS_OFDM:
1306  return (modClassAnswer == WIFI_MOD_CLASS_OFDM);
1307  case WIFI_MOD_CLASS_HT:
1308  case WIFI_MOD_CLASS_VHT:
1309  case WIFI_MOD_CLASS_HE:
1310  return true;
1311  default:
1312  NS_FATAL_ERROR ("Modulation class not defined");
1313  return false;
1314  }
1315 }
1316 
1317 WifiMode
1319 {
1334  NS_LOG_FUNCTION (this << address << reqMode);
1335  WifiMode mode = GetDefaultMode ();
1336  bool found = false;
1337  //First, search the BSS Basic Rate set
1338  for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
1339  {
1340  if ((!found || i->IsHigherDataRate (mode))
1341  && (!i->IsHigherDataRate (reqMode))
1342  && (IsAllowedControlAnswerModulationClass (reqMode.GetModulationClass (), i->GetModulationClass ())))
1343  {
1344  mode = *i;
1345  //We've found a potentially-suitable transmit rate, but we
1346  //need to continue and consider all the basic rates before
1347  //we can be sure we've got the right one.
1348  found = true;
1349  }
1350  }
1351  if (HasHtSupported () || HasVhtSupported () || HasHeSupported ())
1352  {
1353  if (!found)
1354  {
1355  mode = GetDefaultMcs ();
1356  for (WifiModeListIterator i = m_bssBasicMcsSet.begin (); i != m_bssBasicMcsSet.end (); i++)
1357  {
1358  if ((!found || i->IsHigherDataRate (mode))
1359  && (!i->IsHigherDataRate (reqMode))
1360  && (i->GetModulationClass () == reqMode.GetModulationClass ()))
1361  {
1362  mode = *i;
1363  //We've found a potentially-suitable transmit rate, but we
1364  //need to continue and consider all the basic rates before
1365  //we can be sure we've got the right one.
1366  found = true;
1367  }
1368  }
1369  }
1370  }
1371  //If we found a suitable rate in the BSSBasicRateSet, then we are
1372  //done and can return that mode.
1373  if (found)
1374  {
1375  NS_LOG_DEBUG ("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
1376  return mode;
1377  }
1378 
1396  for (uint8_t idx = 0; idx < m_wifiPhy->GetNModes (); idx++)
1397  {
1398  WifiMode thismode = m_wifiPhy->GetMode (idx);
1399  /* If the rate:
1400  *
1401  * - is a mandatory rate for the PHY, and
1402  * - is equal to or faster than our current best choice, and
1403  * - is less than or equal to the rate of the received frame, and
1404  * - is of the same modulation class as the received frame
1405  *
1406  * ...then it's our best choice so far.
1407  */
1408  if (thismode.IsMandatory ()
1409  && (!found || thismode.IsHigherDataRate (mode))
1410  && (!thismode.IsHigherDataRate (reqMode))
1412  {
1413  mode = thismode;
1414  //As above; we've found a potentially-suitable transmit
1415  //rate, but we need to continue and consider all the
1416  //mandatory rates before we can be sure we've got the right one.
1417  found = true;
1418  }
1419  }
1420  if (HasHtSupported () || HasVhtSupported () || HasHeSupported ())
1421  {
1422  for (uint8_t idx = 0; idx < m_wifiPhy->GetNMcs (); idx++)
1423  {
1424  WifiMode thismode = m_wifiPhy->GetMcs (idx);
1425  if (thismode.IsMandatory ()
1426  && (!found || thismode.IsHigherDataRate (mode))
1427  && (!thismode.IsHigherCodeRate (reqMode))
1428  && (thismode.GetModulationClass () == reqMode.GetModulationClass ()))
1429  {
1430  mode = thismode;
1431  //As above; we've found a potentially-suitable transmit
1432  //rate, but we need to continue and consider all the
1433  //mandatory rates before we can be sure we've got the right one.
1434  found = true;
1435  }
1436  }
1437  }
1438 
1449  if (!found)
1450  {
1451  NS_FATAL_ERROR ("Can't find response rate for " << reqMode);
1452  }
1453 
1454  NS_LOG_DEBUG ("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
1455  return mode;
1456 }
1457 
1460 {
1461  NS_ASSERT (!address.IsGroup ());
1462  WifiMode ctsMode = GetControlAnswerMode (address, rtsMode);
1463  WifiTxVector v;
1464  v.SetMode (ctsMode);
1465  v.SetPreambleType (GetPreambleForTransmission (ctsMode, address));
1466  v.SetTxPowerLevel (DoGetCtsTxPowerLevel (address, ctsMode));
1467  v.SetChannelWidth (GetChannelWidthForTransmission (ctsMode, DoGetCtsTxChannelWidth (address, ctsMode)));
1468  v.SetGuardInterval (DoGetCtsTxGuardInterval (address, ctsMode));
1469  v.SetNss (DoGetCtsTxNss (address, ctsMode));
1470  v.SetNess (DoGetCtsTxNess (address, ctsMode));
1471  v.SetStbc (m_wifiPhy->GetStbc ());
1472  return v;
1473 }
1474 
1477 {
1478  NS_ASSERT (!address.IsGroup ());
1479  WifiMode ackMode = GetControlAnswerMode (address, dataMode);
1480  WifiTxVector v;
1481  v.SetMode (ackMode);
1482  v.SetPreambleType (GetPreambleForTransmission (ackMode, address));
1483  v.SetTxPowerLevel (DoGetAckTxPowerLevel (address, ackMode));
1484  v.SetChannelWidth (GetChannelWidthForTransmission (ackMode, DoGetAckTxChannelWidth (address, ackMode)));
1485  v.SetGuardInterval (DoGetAckTxGuardInterval (address, ackMode));
1486  v.SetNss (DoGetAckTxNss (address, ackMode));
1487  v.SetNess (DoGetAckTxNess (address, ackMode));
1488  v.SetStbc (m_wifiPhy->GetStbc ());
1489  return v;
1490 }
1491 
1494 {
1495  NS_ASSERT (!address.IsGroup ());
1496  WifiMode blockAckMode = GetControlAnswerMode (address, blockAckReqMode);
1497  WifiTxVector v;
1498  v.SetMode (blockAckMode);
1499  v.SetPreambleType (GetPreambleForTransmission (blockAckMode, address));
1500  v.SetTxPowerLevel (DoGetBlockAckTxPowerLevel (address, blockAckMode));
1501  v.SetChannelWidth (GetChannelWidthForTransmission (blockAckMode, DoGetBlockAckTxChannelWidth (address, blockAckMode)));
1502  v.SetGuardInterval (DoGetBlockAckTxGuardInterval (address, blockAckMode));
1503  v.SetNss (DoGetBlockAckTxNss (address, blockAckMode));
1504  v.SetNess (DoGetBlockAckTxNess (address, blockAckMode));
1505  v.SetStbc (m_wifiPhy->GetStbc ());
1506  return v;
1507 }
1508 
1509 uint8_t
1511 {
1512  return m_defaultTxPowerLevel;
1513 }
1514 
1515 uint16_t
1517 {
1518  return m_wifiPhy->GetChannelWidth ();
1519 }
1520 
1521 uint16_t
1523 {
1525 }
1526 
1527 uint8_t
1529 {
1530  return 1;
1531 }
1532 
1533 uint8_t
1535 {
1536  return 0;
1537 }
1538 
1539 uint8_t
1541 {
1542  return m_defaultTxPowerLevel;
1543 }
1544 
1545 uint16_t
1547 {
1548  return m_wifiPhy->GetChannelWidth ();
1549 }
1550 
1551 uint16_t
1553 {
1555 }
1556 
1557 uint8_t
1559 {
1560  return 1;
1561 }
1562 
1563 uint8_t
1565 {
1566  return 0;
1567 }
1568 
1569 uint8_t
1571 {
1572  return m_defaultTxPowerLevel;
1573 }
1574 
1575 uint16_t
1577 {
1578  return m_wifiPhy->GetChannelWidth ();
1579 }
1580 
1581 uint16_t
1583 {
1585 }
1586 
1587 uint8_t
1589 {
1590  return 1;
1591 }
1592 
1593 uint8_t
1595 {
1596  return 0;
1597 }
1598 
1599 uint8_t
1601 {
1602  return m_defaultTxPowerLevel;
1603 }
1604 
1607 {
1608  WifiRemoteStationState *state = LookupState (address);
1609  return state->m_info;
1610 }
1611 
1614 {
1615  NS_LOG_FUNCTION (this << address);
1616  for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
1617  {
1618  if ((*i)->m_address == address)
1619  {
1620  NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning existing state");
1621  return (*i);
1622  }
1623  }
1626  state->m_address = address;
1627  state->m_operationalRateSet.push_back (GetDefaultMode ());
1628  state->m_operationalMcsSet.push_back (GetDefaultMcs ());
1631  state->m_guardInterval = static_cast<uint16_t> (m_wifiPhy->GetGuardInterval ().GetNanoSeconds ());
1632  state->m_greenfield = m_wifiPhy->GetGreenfield ();
1633  state->m_streams = 1;
1634  state->m_ness = 0;
1635  state->m_aggregation = false;
1636  state->m_stbc = false;
1637  state->m_ldpc = false;
1638  state->m_qosSupported = false;
1639  state->m_htSupported = false;
1640  state->m_vhtSupported = false;
1641  state->m_heSupported = false;
1642  const_cast<WifiRemoteStationManager *> (this)->m_states.push_back (state);
1643  NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning new state");
1644  return state;
1645 }
1646 
1649 {
1650  uint8_t tid;
1651  if (header->IsQosData ())
1652  {
1653  tid = header->GetQosTid ();
1654  }
1655  else
1656  {
1657  tid = 0;
1658  }
1659  return Lookup (address, tid);
1660 }
1661 
1664 {
1665  NS_LOG_FUNCTION (this << address << +tid);
1666  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1667  {
1668  if ((*i)->m_tid == tid
1669  && (*i)->m_state->m_address == address)
1670  {
1671  return (*i);
1672  }
1673  }
1674  WifiRemoteStationState *state = LookupState (address);
1675 
1676  WifiRemoteStation *station = DoCreateStation ();
1677  station->m_state = state;
1678  station->m_tid = tid;
1679  station->m_ssrc = 0;
1680  station->m_slrc = 0;
1681  const_cast<WifiRemoteStationManager *> (this)->m_stations.push_back (station);
1682  return station;
1683 }
1684 
1685 void
1687 {
1688  NS_LOG_FUNCTION (this << from << qosSupported);
1689  WifiRemoteStationState *state;
1690  state = LookupState (from);
1691  state->m_qosSupported = qosSupported;
1692 }
1693 
1694 void
1696 {
1697  //Used by all stations to record HT capabilities of remote stations
1698  NS_LOG_FUNCTION (this << from << htCapabilities);
1699  WifiRemoteStationState *state;
1700  state = LookupState (from);
1701  state->m_shortGuardInterval = htCapabilities.GetShortGuardInterval20 ();
1702  if (htCapabilities.GetSupportedChannelWidth () == 1)
1703  {
1704  state->m_channelWidth = 40;
1705  }
1706  else
1707  {
1708  state->m_channelWidth = 20;
1709  }
1710  SetQosSupport (from, true);
1711  state->m_greenfield = htCapabilities.GetGreenfield ();
1712  state->m_streams = htCapabilities.GetRxHighestSupportedAntennas ();
1713  for (uint8_t j = 0; j < m_wifiPhy->GetNMcs (); j++)
1714  {
1715  WifiMode mcs = m_wifiPhy->GetMcs (j);
1716  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HT && htCapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1717  {
1718  AddSupportedMcs (from, mcs);
1719  }
1720  }
1721  state->m_htSupported = true;
1722 }
1723 
1724 void
1726 {
1727  //Used by all stations to record VHT capabilities of remote stations
1728  NS_LOG_FUNCTION (this << from << vhtCapabilities);
1729  WifiRemoteStationState *state;
1730  state = LookupState (from);
1731  if (vhtCapabilities.GetSupportedChannelWidthSet () == 1)
1732  {
1733  state->m_channelWidth = 160;
1734  }
1735  else
1736  {
1737  state->m_channelWidth = 80;
1738  }
1739  //This is a workaround to enable users to force a 20 or 40 MHz channel for a VHT-compliant device,
1740  //since IEEE 802.11ac standard says that 20, 40 and 80 MHz channels are mandatory.
1741  if (m_wifiPhy->GetChannelWidth () < state->m_channelWidth)
1742  {
1744  }
1745  state->m_ldpc = (vhtCapabilities.GetRxLdpc () != 0);
1746  state->m_stbc = (vhtCapabilities.GetTxStbc () != 0 || vhtCapabilities.GetRxStbc () != 0);
1747  for (uint8_t i = 1; i <= m_wifiPhy->GetMaxSupportedTxSpatialStreams (); i++)
1748  {
1749  for (uint8_t j = 0; j < m_wifiPhy->GetNMcs (); j++)
1750  {
1751  WifiMode mcs = m_wifiPhy->GetMcs (j);
1752  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtCapabilities.IsSupportedMcs (mcs.GetMcsValue (), i))
1753  {
1754  AddSupportedMcs (from, mcs);
1755  }
1756  }
1757  }
1758  state->m_vhtSupported = true;
1759 }
1760 
1761 void
1763 {
1764  //Used by all stations to record HE capabilities of remote stations
1765  NS_LOG_FUNCTION (this << from << heCapabilities);
1766  WifiRemoteStationState *state;
1767  state = LookupState (from);
1768  if (Is5Ghz (m_wifiPhy->GetFrequency ()))
1769  {
1770  if (heCapabilities.GetChannelWidthSet () & 0x04)
1771  {
1772  state->m_channelWidth = 160;
1773  }
1774  else if (heCapabilities.GetChannelWidthSet () & 0x02)
1775  {
1776  state->m_channelWidth = 80;
1777  }
1778  //For other cases at 5 GHz, the supported channel width is set by the VHT capabilities
1779  }
1780  else if (Is2_4Ghz (m_wifiPhy->GetFrequency ()))
1781  {
1782  if (heCapabilities.GetChannelWidthSet () & 0x01)
1783  {
1784  state->m_channelWidth = 40;
1785  }
1786  else
1787  {
1788  state->m_channelWidth = 20;
1789  }
1790  }
1791  if (heCapabilities.GetHeLtfAndGiForHePpdus () >= 2)
1792  {
1793  state->m_guardInterval = 800;
1794  }
1795  else if (heCapabilities.GetHeLtfAndGiForHePpdus () == 1)
1796  {
1797  state->m_guardInterval = 1600;
1798  }
1799  else
1800  {
1801  state->m_guardInterval = 3200;
1802  }
1803  for (uint8_t i = 1; i <= m_wifiPhy->GetMaxSupportedTxSpatialStreams (); i++)
1804  {
1805  for (uint8_t j = 0; j < m_wifiPhy->GetNMcs (); j++)
1806  {
1807  WifiMode mcs = m_wifiPhy->GetMcs (j);
1809  && heCapabilities.GetHighestNssSupported () >= i
1810  && heCapabilities.GetHighestMcsSupported () >= j)
1811  {
1812  AddSupportedMcs (from, mcs);
1813  }
1814  }
1815  }
1816  state->m_heSupported = true;
1817  SetQosSupport (from, true);
1818 }
1819 
1820 bool
1822 {
1823  return LookupState (address)->m_greenfield;
1824 }
1825 
1826 WifiMode
1828 {
1829  return m_defaultTxMode;
1830 }
1831 
1832 WifiMode
1834 {
1835  return m_defaultTxMcs;
1836 }
1837 
1838 void
1840 {
1841  NS_LOG_FUNCTION (this);
1842  for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
1843  {
1844  delete (*i);
1845  }
1846  m_states.clear ();
1847  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1848  {
1849  delete (*i);
1850  }
1851  m_stations.clear ();
1852  m_bssBasicRateSet.clear ();
1853  m_bssBasicMcsSet.clear ();
1854 }
1855 
1856 void
1858 {
1859  NS_LOG_FUNCTION (this << mode);
1861  {
1862  NS_FATAL_ERROR ("It is not allowed to add a (V)HT rate in the BSSBasicRateSet!");
1863  }
1864  for (uint8_t i = 0; i < GetNBasicModes (); i++)
1865  {
1866  if (GetBasicMode (i) == mode)
1867  {
1868  return;
1869  }
1870  }
1871  m_bssBasicRateSet.push_back (mode);
1872 }
1873 
1874 uint8_t
1876 {
1877  return static_cast<uint8_t> (m_bssBasicRateSet.size ());
1878 }
1879 
1880 WifiMode
1882 {
1883  NS_ASSERT (i < GetNBasicModes ());
1884  return m_bssBasicRateSet[i];
1885 }
1886 
1887 uint32_t
1889 {
1890  uint32_t size = 0;
1891  for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
1892  {
1893  if (i->GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1894  {
1895  continue;
1896  }
1897  size++;
1898  }
1899  return size;
1900 }
1901 
1902 WifiMode
1904 {
1906  uint32_t index = 0;
1907  bool found = false;
1908  for (WifiModeListIterator j = m_bssBasicRateSet.begin (); j != m_bssBasicRateSet.end (); )
1909  {
1910  if (i == index)
1911  {
1912  found = true;
1913  }
1914  if (j->GetModulationClass () != WIFI_MOD_CLASS_ERP_OFDM)
1915  {
1916  if (found)
1917  {
1918  break;
1919  }
1920  }
1921  index++;
1922  j++;
1923  }
1924  return m_bssBasicRateSet[index];
1925 }
1926 
1927 void
1929 {
1930  NS_LOG_FUNCTION (this << +mcs.GetMcsValue ());
1931  for (uint8_t i = 0; i < GetNBasicMcs (); i++)
1932  {
1933  if (GetBasicMcs (i) == mcs)
1934  {
1935  return;
1936  }
1937  }
1938  m_bssBasicMcsSet.push_back (mcs);
1939 }
1940 
1941 uint8_t
1943 {
1944  return static_cast<uint8_t> (m_bssBasicMcsSet.size ());
1945 }
1946 
1947 WifiMode
1949 {
1950  NS_ASSERT (i < GetNBasicMcs ());
1951  return m_bssBasicMcsSet[i];
1952 }
1953 
1954 WifiMode
1956 {
1957  if (m_nonUnicastMode == WifiMode ())
1958  {
1959  if (GetNBasicModes () > 0)
1960  {
1961  return GetBasicMode (0);
1962  }
1963  else
1964  {
1965  return GetDefaultMode ();
1966  }
1967  }
1968  else
1969  {
1970  return m_nonUnicastMode;
1971  }
1972 }
1973 
1974 bool
1976  Ptr<const Packet> packet, bool normally)
1977 {
1978  return normally;
1979 }
1980 
1981 bool
1983  Ptr<const Packet> packet, bool normally)
1984 {
1985  return normally;
1986 }
1987 
1988 bool
1990  Ptr<const Packet> packet, bool normally)
1991 {
1992  return normally;
1993 }
1994 
1995 void
1996 WifiRemoteStationManager::DoReportAmpduTxStatus (WifiRemoteStation *station, uint8_t nSuccessfulMpdus, uint8_t nFailedMpdus, double rxSnr, double dataSnr)
1997 {
1998  NS_LOG_DEBUG ("DoReportAmpduTxStatus received but the manager does not handle A-MPDUs!");
1999 }
2000 
2001 WifiMode
2003 {
2004  NS_ASSERT (i < GetNSupported (station));
2005  return station->m_state->m_operationalRateSet[i];
2006 }
2007 
2008 WifiMode
2010 {
2011  NS_ASSERT (i < GetNMcsSupported (station));
2012  return station->m_state->m_operationalMcsSet[i];
2013 }
2014 
2015 WifiMode
2017 {
2018  NS_ASSERT (i < GetNNonErpSupported (station));
2019  //IEEE 802.11g standard defines that if the protection mechanism is enabled, Rts, Cts and Cts-To-Self
2020  //frames should select a rate in the BSSBasicRateSet that corresponds to an 802.11b basic rate.
2021  //This is a implemented here to avoid changes in every RAA, but should maybe be moved in case it breaks standard rules.
2022  uint32_t index = 0;
2023  bool found = false;
2024  for (WifiModeListIterator j = station->m_state->m_operationalRateSet.begin (); j != station->m_state->m_operationalRateSet.end (); )
2025  {
2026  if (i == index)
2027  {
2028  found = true;
2029  }
2030  if (j->GetModulationClass () != WIFI_MOD_CLASS_ERP_OFDM)
2031  {
2032  if (found)
2033  {
2034  break;
2035  }
2036  }
2037  index++;
2038  j++;
2039  }
2040  return station->m_state->m_operationalRateSet[index];
2041 }
2042 
2045 {
2046  return station->m_state->m_address;
2047 }
2048 
2049 uint16_t
2051 {
2052  return station->m_state->m_channelWidth;
2053 }
2054 
2055 bool
2057 {
2058  return station->m_state->m_shortGuardInterval;
2059 }
2060 
2061 uint16_t
2063 {
2064  return station->m_state->m_guardInterval;
2065 }
2066 
2067 bool
2069 {
2070  return station->m_state->m_greenfield;
2071 }
2072 
2073 bool
2075 {
2076  return station->m_state->m_aggregation;
2077 }
2078 
2079 uint8_t
2081 {
2082  return station->m_state->m_streams;
2083 }
2084 
2085 uint8_t
2087 {
2088  return station->m_state->m_ness;
2089 }
2090 
2093 {
2094  return m_wifiPhy;
2095 }
2096 
2099 {
2100  return m_wifiMac;
2101 }
2102 
2103 uint8_t
2105 {
2106  return static_cast<uint8_t> (station->m_state->m_operationalRateSet.size ());
2107 }
2108 
2109 bool
2111 {
2112  return station->m_state->m_qosSupported;
2113 }
2114 
2115 bool
2117 {
2118  return station->m_state->m_htSupported;
2119 }
2120 
2121 bool
2123 {
2124  return station->m_state->m_vhtSupported;
2125 }
2126 
2127 bool
2129 {
2130  return station->m_state->m_heSupported;
2131 }
2132 
2133 uint8_t
2135 {
2136  return static_cast<uint8_t> (station->m_state->m_operationalMcsSet.size ());
2137 }
2138 
2139 uint32_t
2141 {
2142  uint32_t size = 0;
2143  for (WifiModeListIterator i = station->m_state->m_operationalRateSet.begin (); i != station->m_state->m_operationalRateSet.end (); i++)
2144  {
2145  if (i->GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
2146  {
2147  continue;
2148  }
2149  size++;
2150  }
2151  return size;
2152 }
2153 
2154 uint16_t
2156 {
2157  return LookupState (address)->m_channelWidth;
2158 }
2159 
2160 bool
2162 {
2163  return LookupState (address)->m_shortGuardInterval;
2164 }
2165 
2166 uint8_t
2168 {
2169  return LookupState (address)->m_streams;
2170 }
2171 
2172 uint8_t
2174 {
2175  return static_cast<uint8_t> (LookupState (address)->m_operationalMcsSet.size ());
2176 }
2177 
2178 bool
2180 {
2181  return LookupState (address)->m_htSupported;
2182 }
2183 
2184 bool
2186 {
2187  return LookupState (address)->m_vhtSupported;
2188 }
2189 
2190 void
2192 {
2193  m_defaultTxPowerLevel = txPower;
2194 }
2195 
2196 uint8_t
2198 {
2199  return m_wifiPhy->GetNumberOfAntennas ();
2200 }
2201 
2202 uint8_t
2204 {
2206 }
2207 
2210 {
2211  NS_LOG_FUNCTION (this << mode << dest);
2212  WifiPreamble preamble;
2213  if (mode.GetModulationClass () == WIFI_MOD_CLASS_HE)
2214  {
2215  preamble = WIFI_PREAMBLE_HE_SU;
2216  }
2217  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
2218  {
2219  preamble = WIFI_PREAMBLE_VHT;
2220  }
2222  {
2223  //If protection for greenfield is used we go for HT_MF preamble which is the default protection for GF format defined in the standard.
2224  preamble = WIFI_PREAMBLE_HT_GF;
2225  }
2226  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
2227  {
2228  preamble = WIFI_PREAMBLE_HT_MF;
2229  }
2230  else if (GetShortPreambleEnabled ())
2231  {
2232  preamble = WIFI_PREAMBLE_SHORT;
2233  }
2234  else
2235  {
2236  preamble = WIFI_PREAMBLE_LONG;
2237  }
2238  NS_LOG_DEBUG ("selected preamble=" << preamble);
2239  return preamble;
2240 }
2241 
2243 {
2244  NS_LOG_FUNCTION (this);
2245 }
2246 
2248  : m_memoryTime (Seconds (1.0)),
2249  m_lastUpdate (Seconds (0.0)),
2250  m_failAvg (0.0)
2251 {
2252  NS_LOG_FUNCTION (this);
2253 }
2254 
2255 double
2257 {
2258  double retval = std::exp (static_cast<double> (m_lastUpdate.GetMicroSeconds () - Simulator::Now ().GetMicroSeconds ()) / m_memoryTime.GetMicroSeconds ());
2260  return retval;
2261 }
2262 
2263 void
2265 {
2266  double coefficient = CalculateAveragingCoefficient ();
2267  m_failAvg = static_cast<double> (retryCounter) / (1 + retryCounter) * (1 - coefficient) + coefficient * m_failAvg;
2268 }
2269 
2270 void
2272 {
2273  double coefficient = CalculateAveragingCoefficient ();
2274  m_failAvg = (1 - coefficient) + coefficient * m_failAvg;
2275 }
2276 
2277 double
2279 {
2280  return m_failAvg;
2281 }
2282 
2283 } //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
uint8_t GetHighestMcsSupported(void) const
Get highest MCS supported.
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
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
void SetChannelWidth(uint16_t channelWidth)
Sets the selected channelWidth (in MHz)
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...
bool GetGreenfield(void) const
Return whether Greenfield is supported.
Definition: wifi-phy.cc:596
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:85
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:65
bool GetQosSupported(Mac48Address address) const
Return whether the given station is QoS capable.
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:202
uint32_t m_fragmentationThreshold
Current threshold for fragmentation.
WifiTxVector m_rtsTxVector
TXVECTOR for data frames.
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:831
uint8_t GetHighestNssSupported(void) const
Get highest NSS supported.
bool GetShortGuardInterval(void) const
Return whether short guard interval is supported.
Definition: wifi-phy.cc:609
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:75
Time m_memoryTime
averaging coefficient depends on the memory time
virtual void SetPcfSupported(bool enable)
Enable or disable PCF capability support.
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:3507
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:1235
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:471
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:583
virtual bool DoNeedRts(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
uint8_t GetRxStbc() const
Get the receive STBC.
Tid independent remote station statistics.
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.
phy
Definition: third.py:86
TracedCallback< Mac48Address > m_macTxFinalDataFailed
The trace source fired when the transmission of a data packet has exceeded the maximum number of atte...
The attribute can be read.
Definition: type-id.h:63
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.
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.
ProtectionMode m_htProtectionMode
Protection mode for HT stations when non-HT stations are detected.
Time m_lastUpdate
when last update has occurred
void ReportFinalDataFailed(Mac48Address address, const WifiMacHeader *header)
Should be invoked after calling ReportDataFailed if NeedRetransmission returns false.
void SetRtsCtsThreshold(uint32_t threshold)
Sets the RTS threshold.
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 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.
virtual uint16_t DoGetAckTxChannelWidth(Mac48Address address, WifiMode ctsMode)
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.
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:615
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.
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1255
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.
bool GetHeSupported(const WifiRemoteStation *station) const
Return whether the given station is HE capable.
mac
Definition: third.py:92
WifiRemoteStationInfo GetInfo(Mac48Address address)
Time GetGuardInterval(void) const
Definition: wifi-phy.cc:623
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:3501
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:478
bool m_pcfSupported
Flag if PCF capability is supported.
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.
bool NeedRetransmission(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
Ptr< WifiMac > m_wifiMac
This is a pointer to the WifiMac associated with this WifiRemoteStationManager that is set on call to...
uint32_t DoGetFragmentationThreshold(void) const
Return the current fragmentation threshold.
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.
bool IsMgt(void) const
Return true if the Type is Management.
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...
uint8_t GetNess(const WifiRemoteStation *station) const
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.
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.
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:3513
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.
address
Definition: first.py:37
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...
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:256
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.
virtual uint16_t DoGetBlockAckTxChannelWidth(Mac48Address address, WifiMode ctsMode)
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:244
void SetNTx(uint8_t nTx)
Sets the number of TX antennas.
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)
uint16_t m_channelWidth
Channel width (in MHz) supported by the remote station.
virtual bool DoNeedRetransmission(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
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:1288
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.
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.
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.
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:262
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:270
bool IsHigherCodeRate(WifiMode mode) const
Definition: wifi-mode.cc:595
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.
virtual uint16_t DoGetCtsTxChannelWidth(Mac48Address address, WifiMode ctsMode)
bool HasPcfSupported(void) const
Return whether the device has PCF capability support enabled.
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
Ptr< const AttributeChecker > MakeWifiModeChecker(void)
Definition: wifi-mode.cc:687
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 m_ness
Number of streams in beamforming of the remote station.
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
virtual uint32_t GetSerializedSize(void) const
AttributeValue implementation for WifiMode.
Definition: wifi-mode.h:244
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:500
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
static uint16_t GetChannelWidthForTransmission(WifiMode mode, uint16_t maxSupportedChannelWidth)
Return the channel width that corresponds to the selected mode (instead of letting the PHY&#39;s default ...
uint8_t GetNumberOfAntennas(void) const
Definition: wifi-phy.cc:1269
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 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
uint16_t GetChannelWidthSupported(Mac48Address address) const
Return the channel width supported by the station.
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 NeedRetransmission 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 supported MCS by a destination.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915
HighLatencyRtsTxVectorTag class.
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:3495
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.
uint16_t GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the station.