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 
318 NS_OBJECT_ENSURE_REGISTERED (WifiRemoteStationManager);
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 ());
589  state->m_shortPreamble = isShortPreambleSupported;
590 }
591 
592 void
594 {
595  NS_LOG_FUNCTION (this << address << isShortSlotTimeSupported);
596  NS_ASSERT (!address.IsGroup ());
598  state->m_shortSlotTime = isShortSlotTimeSupported;
599 }
600 
601 void
603 {
604  NS_LOG_FUNCTION (this << address << mode);
605  NS_ASSERT (!address.IsGroup ());
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 ());
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 ());
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 ());
654  state->m_operationalMcsSet.clear ();
655 }
656 
657 void
659 {
660  NS_LOG_FUNCTION (this << address << mcs);
661  NS_ASSERT (!address.IsGroup ());
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 {
678 }
679 
680 bool
682 {
684 }
685 
686 bool
688 {
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 (!header->IsMgt () && address.IsGroup ())
804  {
805  WifiMode mode = GetNonUnicastMode ();
806  WifiTxVector v;
807  v.SetMode (mode);
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++;
931  DoReportRtsFailed (station);
932 }
933 
934 void
936  uint32_t packetSize)
937 {
938  NS_LOG_FUNCTION (this << address << *header);
939  NS_ASSERT (!address.IsGroup ());
940  WifiRemoteStation *station = Lookup (address, header);
941  bool longMpdu = (packetSize + header->GetSize () + WIFI_MAC_FCS_LENGTH) > m_rtsCtsThreshold;
942  if (longMpdu)
943  {
944  station->m_slrc++;
945  }
946  else
947  {
948  station->m_ssrc++;
949  }
951  DoReportDataFailed (station);
952 }
953 
954 void
956  double ctsSnr, WifiMode ctsMode, double rtsSnr)
957 {
958  NS_LOG_FUNCTION (this << address << *header << ctsSnr << ctsMode << rtsSnr);
959  NS_ASSERT (!address.IsGroup ());
960  WifiRemoteStation *station = Lookup (address, header);
961  station->m_state->m_info.NotifyTxSuccess (station->m_ssrc);
962  station->m_ssrc = 0;
963  DoReportRtsOk (station, ctsSnr, ctsMode, rtsSnr);
964 }
965 
966 void
968  double ackSnr, WifiMode ackMode, double dataSnr,
969  uint32_t packetSize)
970 {
971  NS_LOG_FUNCTION (this << address << *header << ackSnr << ackMode << dataSnr);
972  NS_ASSERT (!address.IsGroup ());
973  WifiRemoteStation *station = Lookup (address, header);
974  bool longMpdu = (packetSize + header->GetSize () + WIFI_MAC_FCS_LENGTH) > m_rtsCtsThreshold;
975  if (longMpdu)
976  {
977  station->m_state->m_info.NotifyTxSuccess (station->m_slrc);
978  station->m_slrc = 0;
979  }
980  else
981  {
982  station->m_state->m_info.NotifyTxSuccess (station->m_ssrc);
983  station->m_ssrc = 0;
984  }
985  DoReportDataOk (station, ackSnr, ackMode, dataSnr);
986 }
987 
988 void
990 {
991  NS_LOG_FUNCTION (this << address << *header);
992  NS_ASSERT (!address.IsGroup ());
993  WifiRemoteStation *station = Lookup (address, header);
994  station->m_state->m_info.NotifyTxFailed ();
995  station->m_ssrc = 0;
997  DoReportFinalRtsFailed (station);
998 }
999 
1000 void
1002  uint32_t packetSize)
1003 {
1004  NS_LOG_FUNCTION (this << address << *header);
1005  NS_ASSERT (!address.IsGroup ());
1006  WifiRemoteStation *station = Lookup (address, header);
1007  station->m_state->m_info.NotifyTxFailed ();
1008  bool longMpdu = (packetSize + header->GetSize () + WIFI_MAC_FCS_LENGTH) > m_rtsCtsThreshold;
1009  if (longMpdu)
1010  {
1011  station->m_slrc = 0;
1012  }
1013  else
1014  {
1015  station->m_ssrc = 0;
1016  }
1018  DoReportFinalDataFailed (station);
1019 }
1020 
1021 void
1023  double rxSnr, WifiMode txMode)
1024 {
1025  NS_LOG_FUNCTION (this << address << *header << rxSnr << txMode);
1026  if (address.IsGroup ())
1027  {
1028  return;
1029  }
1030  WifiRemoteStation *station = Lookup (address, header);
1031  DoReportRxOk (station, rxSnr, txMode);
1032 }
1033 
1034 void
1036  uint8_t nSuccessfulMpdus, uint8_t nFailedMpdus,
1037  double rxSnr, double dataSnr)
1038 {
1039  NS_LOG_FUNCTION (this << address << +tid << +nSuccessfulMpdus << +nFailedMpdus << rxSnr << dataSnr);
1040  NS_ASSERT (!address.IsGroup ());
1041  WifiRemoteStation *station = Lookup (address, tid);
1042  for (uint8_t i = 0; i < nFailedMpdus; i++)
1043  {
1045  }
1046  DoReportAmpduTxStatus (station, nSuccessfulMpdus, nFailedMpdus, rxSnr, dataSnr);
1047 }
1048 
1049 bool
1051  Ptr<const Packet> packet, WifiTxVector txVector)
1052 {
1053  WifiMode mode = txVector.GetMode ();
1054  NS_LOG_FUNCTION (this << address << *header << packet << mode);
1055  if (address.IsGroup ())
1056  {
1057  return false;
1058  }
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::NeedRTS returning true to protect non-ERP stations");
1067  return true;
1068  }
1069  else if (m_htProtectionMode == RTS_CTS
1070  && ((mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
1071  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT))
1074  {
1075  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedRTS returning true to protect non-HT stations");
1076  return true;
1077  }
1078  bool normally = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > m_rtsCtsThreshold;
1079  return DoNeedRts (Lookup (address, header), packet, normally);
1080 }
1081 
1082 bool
1084 {
1085  WifiMode mode = txVector.GetMode ();
1086  NS_LOG_FUNCTION (this << mode);
1089  || (mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
1090  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
1091  || (mode.GetModulationClass () == WIFI_MOD_CLASS_HE))
1093  {
1094  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true to protect non-ERP stations");
1095  return true;
1096  }
1097  else if (m_htProtectionMode == CTS_TO_SELF
1098  && ((mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
1099  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT))
1102  {
1103  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true to protect non-HT stations");
1104  return true;
1105  }
1106  else if (!m_useNonErpProtection)
1107  {
1108  //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
1109  for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
1110  {
1111  if (mode == *i)
1112  {
1113  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
1114  return false;
1115  }
1116  }
1117  if (HasHtSupported ())
1118  {
1119  //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
1120  for (WifiModeListIterator i = m_bssBasicMcsSet.begin (); i != m_bssBasicMcsSet.end (); i++)
1121  {
1122  if (mode == *i)
1123  {
1124  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
1125  return false;
1126  }
1127  }
1128  }
1129  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true");
1130  return true;
1131  }
1132  return false;
1133 }
1134 
1135 void
1137 {
1138  NS_LOG_FUNCTION (this << enable);
1139  m_useNonErpProtection = enable;
1140 }
1141 
1142 bool
1144 {
1145  return m_useNonErpProtection;
1146 }
1147 
1148 void
1150 {
1151  NS_LOG_FUNCTION (this << enable);
1152  m_useNonHtProtection = enable;
1153 }
1154 
1155 bool
1157 {
1158  return m_useNonHtProtection;
1159 }
1160 
1161 void
1163 {
1164  NS_LOG_FUNCTION (this << enable);
1165  m_useGreenfieldProtection = enable;
1166 }
1167 
1168 bool
1170 {
1172 }
1173 
1174 bool
1176  Ptr<const Packet> packet)
1177 {
1178  NS_LOG_FUNCTION (this << address << packet << *header);
1179  NS_ASSERT (!address.IsGroup ());
1180  WifiRemoteStation *station = Lookup (address, header);
1181  bool longMpdu = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > m_rtsCtsThreshold;
1182  uint32_t retryCount, maxRetryCount;
1183  if (longMpdu)
1184  {
1185  retryCount = station->m_slrc;
1186  maxRetryCount = m_maxSlrc;
1187  }
1188  else
1189  {
1190  retryCount = station->m_ssrc;
1191  maxRetryCount = m_maxSsrc;
1192  }
1193  bool normally = retryCount < maxRetryCount;
1194  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedRetransmission count: " << retryCount << " result: " << std::boolalpha << normally);
1195  return DoNeedRetransmission (station, packet, normally);
1196 }
1197 
1198 bool
1200  Ptr<const Packet> packet)
1201 {
1202  NS_LOG_FUNCTION (this << address << packet << *header);
1203  if (address.IsGroup ())
1204  {
1205  return false;
1206  }
1207  WifiRemoteStation *station = Lookup (address, header);
1208  bool normally = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > GetFragmentationThreshold ();
1209  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedFragmentation result: " << std::boolalpha << normally);
1210  return DoNeedFragmentation (station, packet, normally);
1211 }
1212 
1213 void
1215 {
1216  NS_LOG_FUNCTION (this << threshold);
1217  if (threshold < 256)
1218  {
1219  /*
1220  * ASN.1 encoding of the MAC and PHY MIB (256 ... 8000)
1221  */
1222  NS_LOG_WARN ("Fragmentation threshold should be larger than 256. Setting to 256.");
1224  }
1225  else
1226  {
1227  /*
1228  * The length of each fragment shall be an even number of octets, except for the last fragment if an MSDU or
1229  * MMPDU, which may be either an even or an odd number of octets.
1230  */
1231  if (threshold % 2 != 0)
1232  {
1233  NS_LOG_WARN ("Fragmentation threshold should be an even number. Setting to " << threshold - 1);
1234  m_nextFragmentationThreshold = threshold - 1;
1235  }
1236  else
1237  {
1238  m_nextFragmentationThreshold = threshold;
1239  }
1240  }
1241 }
1242 
1243 void
1245 {
1247 }
1248 
1249 uint32_t
1251 {
1252  return m_fragmentationThreshold;
1253 }
1254 
1255 uint32_t
1257 {
1258  NS_LOG_FUNCTION (this << *header << packet);
1259  //The number of bytes a fragment can support is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
1260  uint32_t nFragments = (packet->GetSize () / (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
1261 
1262  //If the size of the last fragment is not 0.
1263  if ((packet->GetSize () % (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH)) > 0)
1264  {
1265  nFragments++;
1266  }
1267  NS_LOG_DEBUG ("WifiRemoteStationManager::GetNFragments returning " << nFragments);
1268  return nFragments;
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  uint32_t nFragment = GetNFragments (header, packet);
1278  if (fragmentNumber >= nFragment)
1279  {
1280  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning 0");
1281  return 0;
1282  }
1283  //Last fragment
1284  if (fragmentNumber == nFragment - 1)
1285  {
1286  uint32_t lastFragmentSize = packet->GetSize () - (fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
1287  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << lastFragmentSize);
1288  return lastFragmentSize;
1289  }
1290  //All fragments but the last, the number of bytes is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
1291  else
1292  {
1293  uint32_t fragmentSize = GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH;
1294  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << fragmentSize);
1295  return fragmentSize;
1296  }
1297 }
1298 
1299 uint32_t
1301  Ptr<const Packet> packet, uint32_t fragmentNumber)
1302 {
1303  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
1304  NS_ASSERT (!address.IsGroup ());
1305  NS_ASSERT (fragmentNumber < GetNFragments (header, packet));
1306  uint32_t fragmentOffset = fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH);
1307  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentOffset returning " << fragmentOffset);
1308  return fragmentOffset;
1309 }
1310 
1311 bool
1313  Ptr<const Packet> packet, uint32_t fragmentNumber)
1314 {
1315  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
1316  NS_ASSERT (!address.IsGroup ());
1317  bool isLast = fragmentNumber == (GetNFragments (header, packet) - 1);
1318  NS_LOG_DEBUG ("WifiRemoteStationManager::IsLastFragment returning " << std::boolalpha << isLast);
1319  return isLast;
1320 }
1321 
1322 bool
1324 {
1325  switch (modClassReq)
1326  {
1327  case WIFI_MOD_CLASS_DSSS:
1328  return (modClassAnswer == WIFI_MOD_CLASS_DSSS);
1330  return (modClassAnswer == WIFI_MOD_CLASS_DSSS || modClassAnswer == WIFI_MOD_CLASS_HR_DSSS);
1332  return (modClassAnswer == WIFI_MOD_CLASS_DSSS || modClassAnswer == WIFI_MOD_CLASS_HR_DSSS || modClassAnswer == WIFI_MOD_CLASS_ERP_OFDM);
1333  case WIFI_MOD_CLASS_OFDM:
1334  return (modClassAnswer == WIFI_MOD_CLASS_OFDM);
1335  case WIFI_MOD_CLASS_HT:
1336  case WIFI_MOD_CLASS_VHT:
1337  case WIFI_MOD_CLASS_HE:
1338  return true;
1339  default:
1340  NS_FATAL_ERROR ("Modulation class not defined");
1341  return false;
1342  }
1343 }
1344 
1345 WifiMode
1347 {
1362  NS_LOG_FUNCTION (this << address << reqMode);
1363  WifiMode mode = GetDefaultMode ();
1364  bool found = false;
1365  //First, search the BSS Basic Rate set
1366  for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
1367  {
1368  if ((!found || i->IsHigherDataRate (mode))
1369  && (!i->IsHigherDataRate (reqMode))
1370  && (IsAllowedControlAnswerModulationClass (reqMode.GetModulationClass (), i->GetModulationClass ())))
1371  {
1372  mode = *i;
1373  //We've found a potentially-suitable transmit rate, but we
1374  //need to continue and consider all the basic rates before
1375  //we can be sure we've got the right one.
1376  found = true;
1377  }
1378  }
1379  if (HasHtSupported () || HasVhtSupported () || HasHeSupported ())
1380  {
1381  if (!found)
1382  {
1383  mode = GetDefaultMcs ();
1384  for (WifiModeListIterator i = m_bssBasicMcsSet.begin (); i != m_bssBasicMcsSet.end (); i++)
1385  {
1386  if ((!found || i->IsHigherDataRate (mode))
1387  && (!i->IsHigherDataRate (reqMode))
1388  && (i->GetModulationClass () == reqMode.GetModulationClass ()))
1389  {
1390  mode = *i;
1391  //We've found a potentially-suitable transmit rate, but we
1392  //need to continue and consider all the basic rates before
1393  //we can be sure we've got the right one.
1394  found = true;
1395  }
1396  }
1397  }
1398  }
1399  //If we found a suitable rate in the BSSBasicRateSet, then we are
1400  //done and can return that mode.
1401  if (found)
1402  {
1403  NS_LOG_DEBUG ("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
1404  return mode;
1405  }
1406 
1424  for (uint8_t idx = 0; idx < m_wifiPhy->GetNModes (); idx++)
1425  {
1426  WifiMode thismode = m_wifiPhy->GetMode (idx);
1427  /* If the rate:
1428  *
1429  * - is a mandatory rate for the PHY, and
1430  * - is equal to or faster than our current best choice, and
1431  * - is less than or equal to the rate of the received frame, and
1432  * - is of the same modulation class as the received frame
1433  *
1434  * ...then it's our best choice so far.
1435  */
1436  if (thismode.IsMandatory ()
1437  && (!found || thismode.IsHigherDataRate (mode))
1438  && (!thismode.IsHigherDataRate (reqMode))
1440  {
1441  mode = thismode;
1442  //As above; we've found a potentially-suitable transmit
1443  //rate, but we need to continue and consider all the
1444  //mandatory rates before we can be sure we've got the right one.
1445  found = true;
1446  }
1447  }
1448  if (HasHtSupported () || HasVhtSupported () || HasHeSupported ())
1449  {
1450  for (uint8_t idx = 0; idx < m_wifiPhy->GetNMcs (); idx++)
1451  {
1452  WifiMode thismode = m_wifiPhy->GetMcs (idx);
1453  if (thismode.IsMandatory ()
1454  && (!found || thismode.IsHigherDataRate (mode))
1455  && (!thismode.IsHigherCodeRate (reqMode))
1456  && (thismode.GetModulationClass () == reqMode.GetModulationClass ()))
1457  {
1458  mode = thismode;
1459  //As above; we've found a potentially-suitable transmit
1460  //rate, but we need to continue and consider all the
1461  //mandatory rates before we can be sure we've got the right one.
1462  found = true;
1463  }
1464  }
1465  }
1466 
1477  if (!found)
1478  {
1479  NS_FATAL_ERROR ("Can't find response rate for " << reqMode);
1480  }
1481 
1482  NS_LOG_DEBUG ("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
1483  return mode;
1484 }
1485 
1488 {
1489  NS_ASSERT (!address.IsGroup ());
1490  WifiMode ctsMode = GetControlAnswerMode (address, rtsMode);
1491  WifiTxVector v;
1492  v.SetMode (ctsMode);
1497  v.SetNss (DoGetCtsTxNss (address, ctsMode));
1498  v.SetNess (DoGetCtsTxNess (address, ctsMode));
1499  v.SetStbc (m_wifiPhy->GetStbc ());
1500  return v;
1501 }
1502 
1505 {
1506  NS_ASSERT (!address.IsGroup ());
1507  WifiMode ackMode = GetControlAnswerMode (address, dataMode);
1508  WifiTxVector v;
1509  v.SetMode (ackMode);
1514  v.SetNss (DoGetAckTxNss (address, ackMode));
1515  v.SetNess (DoGetAckTxNess (address, ackMode));
1516  v.SetStbc (m_wifiPhy->GetStbc ());
1517  return v;
1518 }
1519 
1522 {
1523  NS_ASSERT (!address.IsGroup ());
1524  WifiMode blockAckMode = GetControlAnswerMode (address, blockAckReqMode);
1525  WifiTxVector v;
1526  v.SetMode (blockAckMode);
1531  v.SetNss (DoGetBlockAckTxNss (address, blockAckMode));
1532  v.SetNess (DoGetBlockAckTxNess (address, blockAckMode));
1533  v.SetStbc (m_wifiPhy->GetStbc ());
1534  return v;
1535 }
1536 
1537 uint8_t
1539 {
1540  return m_defaultTxPowerLevel;
1541 }
1542 
1543 uint16_t
1545 {
1546  return m_wifiPhy->GetChannelWidth ();
1547 }
1548 
1549 uint16_t
1551 {
1553 }
1554 
1555 uint8_t
1557 {
1558  return 1;
1559 }
1560 
1561 uint8_t
1563 {
1564  return 0;
1565 }
1566 
1567 uint8_t
1569 {
1570  return m_defaultTxPowerLevel;
1571 }
1572 
1573 uint16_t
1575 {
1576  return m_wifiPhy->GetChannelWidth ();
1577 }
1578 
1579 uint16_t
1581 {
1583 }
1584 
1585 uint8_t
1587 {
1588  return 1;
1589 }
1590 
1591 uint8_t
1593 {
1594  return 0;
1595 }
1596 
1597 uint8_t
1599 {
1600  return m_defaultTxPowerLevel;
1601 }
1602 
1603 uint16_t
1605 {
1606  return m_wifiPhy->GetChannelWidth ();
1607 }
1608 
1609 uint16_t
1611 {
1613 }
1614 
1615 uint8_t
1617 {
1618  return 1;
1619 }
1620 
1621 uint8_t
1623 {
1624  return 0;
1625 }
1626 
1627 uint8_t
1629 {
1630  return m_defaultTxPowerLevel;
1631 }
1632 
1635 {
1637  return state->m_info;
1638 }
1639 
1642 {
1643  NS_LOG_FUNCTION (this << address);
1644  for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
1645  {
1646  if ((*i)->m_address == address)
1647  {
1648  NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning existing state");
1649  return (*i);
1650  }
1651  }
1654  state->m_address = address;
1655  state->m_operationalRateSet.push_back (GetDefaultMode ());
1656  state->m_operationalMcsSet.push_back (GetDefaultMcs ());
1659  state->m_guardInterval = static_cast<uint16_t> (m_wifiPhy->GetGuardInterval ().GetNanoSeconds ());
1660  state->m_greenfield = m_wifiPhy->GetGreenfield ();
1661  state->m_streams = 1;
1662  state->m_ness = 0;
1663  state->m_aggregation = false;
1664  state->m_stbc = false;
1665  state->m_ldpc = false;
1666  state->m_qosSupported = false;
1667  state->m_htSupported = false;
1668  state->m_vhtSupported = false;
1669  state->m_heSupported = false;
1670  const_cast<WifiRemoteStationManager *> (this)->m_states.push_back (state);
1671  NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning new state");
1672  return state;
1673 }
1674 
1677 {
1678  uint8_t tid;
1679  if (header->IsQosData ())
1680  {
1681  tid = header->GetQosTid ();
1682  }
1683  else
1684  {
1685  tid = 0;
1686  }
1687  return Lookup (address, tid);
1688 }
1689 
1692 {
1693  NS_LOG_FUNCTION (this << address << +tid);
1694  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1695  {
1696  if ((*i)->m_tid == tid
1697  && (*i)->m_state->m_address == address)
1698  {
1699  return (*i);
1700  }
1701  }
1703 
1704  WifiRemoteStation *station = DoCreateStation ();
1705  station->m_state = state;
1706  station->m_tid = tid;
1707  station->m_ssrc = 0;
1708  station->m_slrc = 0;
1709  const_cast<WifiRemoteStationManager *> (this)->m_stations.push_back (station);
1710  return station;
1711 }
1712 
1713 void
1715 {
1716  NS_LOG_FUNCTION (this << from << qosSupported);
1717  WifiRemoteStationState *state;
1718  state = LookupState (from);
1719  state->m_qosSupported = qosSupported;
1720 }
1721 
1722 void
1724 {
1725  //Used by all stations to record HT capabilities of remote stations
1726  NS_LOG_FUNCTION (this << from << htCapabilities);
1727  WifiRemoteStationState *state;
1728  state = LookupState (from);
1729  state->m_shortGuardInterval = htCapabilities.GetShortGuardInterval20 ();
1730  if (htCapabilities.GetSupportedChannelWidth () == 1)
1731  {
1732  state->m_channelWidth = 40;
1733  }
1734  else
1735  {
1736  state->m_channelWidth = 20;
1737  }
1738  SetQosSupport (from, true);
1739  state->m_greenfield = htCapabilities.GetGreenfield ();
1740  state->m_streams = htCapabilities.GetRxHighestSupportedAntennas ();
1741  for (uint8_t j = 0; j < m_wifiPhy->GetNMcs (); j++)
1742  {
1743  WifiMode mcs = m_wifiPhy->GetMcs (j);
1744  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HT && htCapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1745  {
1746  AddSupportedMcs (from, mcs);
1747  }
1748  }
1749  state->m_htSupported = true;
1750 }
1751 
1752 void
1754 {
1755  //Used by all stations to record VHT capabilities of remote stations
1756  NS_LOG_FUNCTION (this << from << vhtCapabilities);
1757  WifiRemoteStationState *state;
1758  state = LookupState (from);
1759  if (vhtCapabilities.GetSupportedChannelWidthSet () == 1)
1760  {
1761  state->m_channelWidth = 160;
1762  }
1763  else
1764  {
1765  state->m_channelWidth = 80;
1766  }
1767  //This is a workaround to enable users to force a 20 or 40 MHz channel for a VHT-compliant device,
1768  //since IEEE 802.11ac standard says that 20, 40 and 80 MHz channels are mandatory.
1769  if (m_wifiPhy->GetChannelWidth () < state->m_channelWidth)
1770  {
1772  }
1773  state->m_ldpc = (vhtCapabilities.GetRxLdpc () != 0);
1774  state->m_stbc = (vhtCapabilities.GetTxStbc () != 0 || vhtCapabilities.GetRxStbc () != 0);
1775  for (uint8_t i = 1; i <= m_wifiPhy->GetMaxSupportedTxSpatialStreams (); i++)
1776  {
1777  for (uint8_t j = 0; j < m_wifiPhy->GetNMcs (); j++)
1778  {
1779  WifiMode mcs = m_wifiPhy->GetMcs (j);
1780  if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtCapabilities.IsSupportedMcs (mcs.GetMcsValue (), i))
1781  {
1782  AddSupportedMcs (from, mcs);
1783  }
1784  }
1785  }
1786  state->m_vhtSupported = true;
1787 }
1788 
1789 void
1791 {
1792  //Used by all stations to record HE capabilities of remote stations
1793  NS_LOG_FUNCTION (this << from << heCapabilities);
1794  WifiRemoteStationState *state;
1795  state = LookupState (from);
1796  if (Is5Ghz (m_wifiPhy->GetFrequency ()))
1797  {
1798  if (heCapabilities.GetChannelWidthSet () & 0x04)
1799  {
1800  state->m_channelWidth = 160;
1801  }
1802  else if (heCapabilities.GetChannelWidthSet () & 0x02)
1803  {
1804  state->m_channelWidth = 80;
1805  }
1806  //For other cases at 5 GHz, the supported channel width is set by the VHT capabilities
1807  }
1808  else if (Is2_4Ghz (m_wifiPhy->GetFrequency ()))
1809  {
1810  if (heCapabilities.GetChannelWidthSet () & 0x01)
1811  {
1812  state->m_channelWidth = 40;
1813  }
1814  else
1815  {
1816  state->m_channelWidth = 20;
1817  }
1818  }
1819  if (heCapabilities.GetHeLtfAndGiForHePpdus () >= 2)
1820  {
1821  state->m_guardInterval = 800;
1822  }
1823  else if (heCapabilities.GetHeLtfAndGiForHePpdus () == 1)
1824  {
1825  state->m_guardInterval = 1600;
1826  }
1827  else
1828  {
1829  state->m_guardInterval = 3200;
1830  }
1831  for (uint8_t i = 1; i <= m_wifiPhy->GetMaxSupportedTxSpatialStreams (); i++)
1832  {
1833  for (uint8_t j = 0; j < m_wifiPhy->GetNMcs (); j++)
1834  {
1835  WifiMode mcs = m_wifiPhy->GetMcs (j);
1837  && heCapabilities.GetHighestNssSupported () >= i
1838  && heCapabilities.GetHighestMcsSupported () >= j)
1839  {
1840  AddSupportedMcs (from, mcs);
1841  }
1842  }
1843  }
1844  state->m_heSupported = true;
1845  SetQosSupport (from, true);
1846 }
1847 
1848 bool
1850 {
1851  return LookupState (address)->m_greenfield;
1852 }
1853 
1854 WifiMode
1856 {
1857  return m_defaultTxMode;
1858 }
1859 
1860 WifiMode
1862 {
1863  return m_defaultTxMcs;
1864 }
1865 
1866 void
1868 {
1869  NS_LOG_FUNCTION (this);
1870  for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
1871  {
1872  delete (*i);
1873  }
1874  m_states.clear ();
1875  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1876  {
1877  delete (*i);
1878  }
1879  m_stations.clear ();
1880  m_bssBasicRateSet.clear ();
1881  m_bssBasicMcsSet.clear ();
1882 }
1883 
1884 void
1886 {
1887  NS_LOG_FUNCTION (this << mode);
1889  {
1890  NS_FATAL_ERROR ("It is not allowed to add a (V)HT rate in the BSSBasicRateSet!");
1891  }
1892  for (uint8_t i = 0; i < GetNBasicModes (); i++)
1893  {
1894  if (GetBasicMode (i) == mode)
1895  {
1896  return;
1897  }
1898  }
1899  m_bssBasicRateSet.push_back (mode);
1900 }
1901 
1902 uint8_t
1904 {
1905  return static_cast<uint8_t> (m_bssBasicRateSet.size ());
1906 }
1907 
1908 WifiMode
1910 {
1911  NS_ASSERT (i < GetNBasicModes ());
1912  return m_bssBasicRateSet[i];
1913 }
1914 
1915 uint32_t
1917 {
1918  uint32_t size = 0;
1919  for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
1920  {
1921  if (i->GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1922  {
1923  continue;
1924  }
1925  size++;
1926  }
1927  return size;
1928 }
1929 
1930 WifiMode
1932 {
1934  uint32_t index = 0;
1935  bool found = false;
1936  for (WifiModeListIterator j = m_bssBasicRateSet.begin (); j != m_bssBasicRateSet.end (); )
1937  {
1938  if (i == index)
1939  {
1940  found = true;
1941  }
1942  if (j->GetModulationClass () != WIFI_MOD_CLASS_ERP_OFDM)
1943  {
1944  if (found)
1945  {
1946  break;
1947  }
1948  }
1949  index++;
1950  j++;
1951  }
1952  return m_bssBasicRateSet[index];
1953 }
1954 
1955 void
1957 {
1958  NS_LOG_FUNCTION (this << +mcs.GetMcsValue ());
1959  for (uint8_t i = 0; i < GetNBasicMcs (); i++)
1960  {
1961  if (GetBasicMcs (i) == mcs)
1962  {
1963  return;
1964  }
1965  }
1966  m_bssBasicMcsSet.push_back (mcs);
1967 }
1968 
1969 uint8_t
1971 {
1972  return static_cast<uint8_t> (m_bssBasicMcsSet.size ());
1973 }
1974 
1975 WifiMode
1977 {
1978  NS_ASSERT (i < GetNBasicMcs ());
1979  return m_bssBasicMcsSet[i];
1980 }
1981 
1982 WifiMode
1984 {
1985  if (m_nonUnicastMode == WifiMode ())
1986  {
1987  if (GetNBasicModes () > 0)
1988  {
1989  return GetBasicMode (0);
1990  }
1991  else
1992  {
1993  return GetDefaultMode ();
1994  }
1995  }
1996  else
1997  {
1998  return m_nonUnicastMode;
1999  }
2000 }
2001 
2002 bool
2004  Ptr<const Packet> packet, bool normally)
2005 {
2006  return normally;
2007 }
2008 
2009 bool
2011  Ptr<const Packet> packet, bool normally)
2012 {
2013  return normally;
2014 }
2015 
2016 bool
2018  Ptr<const Packet> packet, bool normally)
2019 {
2020  return normally;
2021 }
2022 
2023 void
2024 WifiRemoteStationManager::DoReportAmpduTxStatus (WifiRemoteStation *station, uint8_t nSuccessfulMpdus, uint8_t nFailedMpdus, double rxSnr, double dataSnr)
2025 {
2026  NS_LOG_DEBUG ("DoReportAmpduTxStatus received but the manager does not handle A-MPDUs!");
2027 }
2028 
2029 WifiMode
2031 {
2032  NS_ASSERT (i < GetNSupported (station));
2033  return station->m_state->m_operationalRateSet[i];
2034 }
2035 
2036 WifiMode
2038 {
2039  NS_ASSERT (i < GetNMcsSupported (station));
2040  return station->m_state->m_operationalMcsSet[i];
2041 }
2042 
2043 WifiMode
2045 {
2046  NS_ASSERT (i < GetNNonErpSupported (station));
2047  //IEEE 802.11g standard defines that if the protection mechanism is enabled, Rts, Cts and Cts-To-Self
2048  //frames should select a rate in the BSSBasicRateSet that corresponds to an 802.11b basic rate.
2049  //This is a implemented here to avoid changes in every RAA, but should maybe be moved in case it breaks standard rules.
2050  uint32_t index = 0;
2051  bool found = false;
2052  for (WifiModeListIterator j = station->m_state->m_operationalRateSet.begin (); j != station->m_state->m_operationalRateSet.end (); )
2053  {
2054  if (i == index)
2055  {
2056  found = true;
2057  }
2058  if (j->GetModulationClass () != WIFI_MOD_CLASS_ERP_OFDM)
2059  {
2060  if (found)
2061  {
2062  break;
2063  }
2064  }
2065  index++;
2066  j++;
2067  }
2068  return station->m_state->m_operationalRateSet[index];
2069 }
2070 
2073 {
2074  return station->m_state->m_address;
2075 }
2076 
2077 uint16_t
2079 {
2080  return station->m_state->m_channelWidth;
2081 }
2082 
2083 bool
2085 {
2086  return station->m_state->m_shortGuardInterval;
2087 }
2088 
2089 uint16_t
2091 {
2092  return station->m_state->m_guardInterval;
2093 }
2094 
2095 bool
2097 {
2098  return station->m_state->m_greenfield;
2099 }
2100 
2101 bool
2103 {
2104  return station->m_state->m_aggregation;
2105 }
2106 
2107 uint8_t
2109 {
2110  return station->m_state->m_streams;
2111 }
2112 
2113 uint8_t
2115 {
2116  return station->m_state->m_ness;
2117 }
2118 
2121 {
2122  return m_wifiPhy;
2123 }
2124 
2127 {
2128  return m_wifiMac;
2129 }
2130 
2131 uint8_t
2133 {
2134  return static_cast<uint8_t> (station->m_state->m_operationalRateSet.size ());
2135 }
2136 
2137 bool
2139 {
2140  return station->m_state->m_qosSupported;
2141 }
2142 
2143 bool
2145 {
2146  return station->m_state->m_htSupported;
2147 }
2148 
2149 bool
2151 {
2152  return station->m_state->m_vhtSupported;
2153 }
2154 
2155 bool
2157 {
2158  return station->m_state->m_heSupported;
2159 }
2160 
2161 uint8_t
2163 {
2164  return static_cast<uint8_t> (station->m_state->m_operationalMcsSet.size ());
2165 }
2166 
2167 uint32_t
2169 {
2170  uint32_t size = 0;
2171  for (WifiModeListIterator i = station->m_state->m_operationalRateSet.begin (); i != station->m_state->m_operationalRateSet.end (); i++)
2172  {
2173  if (i->GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
2174  {
2175  continue;
2176  }
2177  size++;
2178  }
2179  return size;
2180 }
2181 
2182 uint16_t
2184 {
2186 }
2187 
2188 bool
2190 {
2192 }
2193 
2194 uint8_t
2196 {
2197  return LookupState (address)->m_streams;
2198 }
2199 
2200 uint8_t
2202 {
2203  return static_cast<uint8_t> (LookupState (address)->m_operationalMcsSet.size ());
2204 }
2205 
2206 bool
2208 {
2209  return LookupState (address)->m_htSupported;
2210 }
2211 
2212 bool
2214 {
2216 }
2217 
2218 void
2220 {
2221  m_defaultTxPowerLevel = txPower;
2222 }
2223 
2224 uint8_t
2226 {
2227  return m_wifiPhy->GetNumberOfAntennas ();
2228 }
2229 
2230 uint8_t
2232 {
2234 }
2235 
2238 {
2239  NS_LOG_FUNCTION (this << mode << dest);
2240  WifiPreamble preamble;
2241  if (mode.GetModulationClass () == WIFI_MOD_CLASS_HE)
2242  {
2243  preamble = WIFI_PREAMBLE_HE_SU;
2244  }
2245  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
2246  {
2247  preamble = WIFI_PREAMBLE_VHT;
2248  }
2250  {
2251  //If protection for greenfield is used we go for HT_MF preamble which is the default protection for GF format defined in the standard.
2252  preamble = WIFI_PREAMBLE_HT_GF;
2253  }
2254  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
2255  {
2256  preamble = WIFI_PREAMBLE_HT_MF;
2257  }
2258  else if (GetShortPreambleEnabled ())
2259  {
2260  preamble = WIFI_PREAMBLE_SHORT;
2261  }
2262  else
2263  {
2264  preamble = WIFI_PREAMBLE_LONG;
2265  }
2266  NS_LOG_DEBUG ("selected preamble=" << preamble);
2267  return preamble;
2268 }
2269 
2271 {
2272  NS_LOG_FUNCTION (this);
2273 }
2274 
2276  : m_memoryTime (Seconds (1.0)),
2277  m_lastUpdate (Seconds (0.0)),
2278  m_failAvg (0.0)
2279 {
2280  NS_LOG_FUNCTION (this);
2281 }
2282 
2283 double
2285 {
2286  double retval = std::exp (static_cast<double> (m_lastUpdate.GetMicroSeconds () - Simulator::Now ().GetMicroSeconds ()) / m_memoryTime.GetMicroSeconds ());
2288  return retval;
2289 }
2290 
2291 void
2293 {
2294  double coefficient = CalculateAveragingCoefficient ();
2295  m_failAvg = static_cast<double> (retryCounter) / (1 + retryCounter) * (1 - coefficient) + coefficient * m_failAvg;
2296 }
2297 
2298 void
2300 {
2301  double coefficient = CalculateAveragingCoefficient ();
2302  m_failAvg = (1 - coefficient) + coefficient * m_failAvg;
2303 }
2304 
2305 double
2307 {
2308  return m_failAvg;
2309 }
2310 
2311 } //namespace ns3
enum ns3::WifiRemoteStationState::@76 m_state
State of the station.
uint8_t GetNMcsSupported(Mac48Address address) const
Return the number of MCS supported by the station.
uint8_t GetGreenfield(void) const
Return the green field.
bool HasVhtSupported(void) const
Return whether the device has VHT capability support enabled.
virtual void Print(std::ostream &os) const
virtual uint8_t DoGetAckTxNss(Mac48Address address, WifiMode ackMode)
bool m_useNonHtProtection
flag if protection for non-HT stations against HT transmissions is enabled
uint32_t m_ssrc
STA short retry count.
bool GetRifsPermitted(void) const
Return whether the device can use RIFS.
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
uint8_t GetChannelWidthSet(void) const
Get channel width set.
bool m_vhtSupported
Flag if VHT capability is supported.
virtual uint8_t DoGetAckTxNess(Mac48Address address, WifiMode ackMode)
HighLatencyDataTxVectorTag class.
void AddSupportedMcs(Mac48Address address, WifiMode mcs)
Record the MCS index supported by the station.
uint32_t GetNFragments(const WifiMacHeader *header, Ptr< const Packet > packet)
Return the number of fragments needed for the given packet.
Ptr< WifiMac > GetMac(void) const
Return the WifiMac.
void SetDefaultTxPowerLevel(uint8_t txPower)
Set the default transmission power level.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
uint8_t GetNSupported(const WifiRemoteStation *station) const
Return the number of modes supported by the given station.
ERP-OFDM PHY (19.5)
Definition: wifi-mode.h:54
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...
uint32_t m_rtsCtsThreshold
Threshold for RTS/CTS.
bool m_shortSlotTimeEnabled
flag if short slot time is enabled
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:3523
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
void SetChannelWidth(uint16_t channelWidth)
Sets the selected channelWidth (in MHz)
bool GetShortPreambleSupported(Mac48Address address) const
Return whether the station supports short PLCP preamble or not.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:831
void ReportFinalDataFailed(Mac48Address address, const WifiMacHeader *header, uint32_t packetSize)
Should be invoked after calling ReportDataFailed if NeedRetransmission returns false.
void AddAllSupportedMcs(Mac48Address address)
Invoked in a STA or AP to store all of the MCS supported by a destination which is also supported loc...
bool m_vhtSupported
Flag if VHT is supported by the station.
bool GetShortGuardInterval(void) const
Return whether short guard interval is supported.
Definition: wifi-phy.cc:617
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.
bool GetGreenfield(void) const
Return whether Greenfield is supported.
Definition: wifi-phy.cc:604
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:68
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.
bool Is2_4Ghz(double frequency)
Definition: wifi-utils.cc:56
uint32_t GetSize(void) const
Return the size of the WifiMacHeader in octets.
void ReportDataOk(Mac48Address address, const WifiMacHeader *header, double ackSnr, WifiMode ackMode, double dataSnr, uint32_t packetSize)
Should be invoked whenever we receive the Ack associated to a data packet we just sent...
uint8_t GetTxStbc() const
Get the transmit STBC.
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
virtual void Serialize(TagBuffer i) const
static const uint16_t WIFI_MAC_FCS_LENGTH
The length in octects of the IEEE 802.11 MAC FCS field.
WifiMode GetDefaultMcs(void) const
Return the default Modulation and Coding Scheme (MCS) index.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h: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.
WifiMode GetNonUnicastMode(void) const
Return a mode for non-unicast packets.
WifiMode GetBasicMcs(uint8_t i) const
Return the MCS at the given list index.
Mac48Address m_address
Mac48Address of the remote station.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
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:62
Time m_memoryTime
averaging coefficient depends on the memory time
virtual void SetPcfSupported(bool enable)
Enable or disable PCF capability support.
bool GetUseNonHtProtection(void) const
Return whether the device supports protection of non-HT stations.
bool IsLastFragment(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fragmentNumber)
uint16_t GetGuardInterval(const WifiRemoteStation *station) const
Return the HE guard interval duration supported by the station.
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
uint32_t GetFragmentationThreshold(void) const
Return the fragmentation threshold.
bool GetUseGreenfieldProtection(void) const
Return whether protection for stations that do not support HT greenfield format is enabled...
WifiTxVector m_ctsToSelfTxVector
TXVECTOR for CTS-to-self frames.
WifiMode GetSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether mode associated with the specified station at the specified index. ...
bool IsAllowedControlAnswerModulationClass(WifiModulationClass modClassReq, WifiModulationClass modClassAnswer) const
Return whether the modulation class of the selected mode for the control answer frame is allowed...
uint8_t GetNBasicMcs(void) const
Return the number of basic MCS index.
uint32_t GetNNonErpSupported(const WifiRemoteStation *station) const
Return the number of non-ERP modes supported by the given station.
bool GetGreenfieldSupported(Mac48Address address) const
Return whether the station supports Greenfield or not.
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
uint8_t GetSupportedChannelWidth(void) const
Return the supported channel width.
virtual bool DoNeedRts(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
bool GetStbc(void) const
Return whether STBC is supported.
Definition: wifi-phy.cc:591
Tid independent remote station statistics.
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.
bool IsMandatory(void) const
Definition: wifi-mode.cc:471
void RecordDisassociated(Mac48Address address)
Records that the STA was disassociated.
uint8_t GetRxStbc() const
Get the receive STBC.
phy
Definition: third.py:86
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
TracedCallback< Mac48Address > m_macTxFinalDataFailed
The trace source fired when the transmission of a data packet has exceeded the maximum number of atte...
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1263
The attribute can be read.
Definition: type-id.h:63
void SetShortSlotTimeEnabled(bool enable)
Enable or disable short slot 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:3517
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Definition: wifi-preamble.h:30
uint8_t GetNumberOfSupportedStreams(Mac48Address address) const
Return the number of spatial streams supported by the station.
bool GetShortPreambleEnabled(void) const
Return whether the device uses short PLCP preambles.
static TypeId GetTypeId(void)
Get the type ID.
virtual void SetVhtSupported(bool enable)
Enable or disable VHT capability support.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
bool GetGreenfield(const WifiRemoteStation *station) const
Return whether the station supports Greenfield or not.
ProtectionMode m_htProtectionMode
Protection mode for HT stations when non-HT stations are detected.
uint8_t GetRxHighestSupportedAntennas(void) const
Return the receive highest supported antennas.
bool GetVhtSupported(Mac48Address address) const
Return whether the station supports VHT or not.
Time m_lastUpdate
when last update has occurred
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
WifiRemoteStationState * LookupState(Mac48Address address) const
Return the state of the station associated with the given address.
WifiMode m_defaultTxMcs
The default transmission modulation-coding scheme (MCS)
bool IsSupportedMcs(uint8_t mcs) const
Return the is MCS supported flag.
virtual void DoReportRtsOk(WifiRemoteStation *station, double ctsSnr, WifiMode ctsMode, double rtsSnr)=0
This method is a pure virtual method that must be implemented by the sub-class.
Ptr< WifiPhy > m_wifiPhy
This is a pointer to the WifiPhy associated with this WifiRemoteStationManager that is set on call to...
double CalculateAveragingCoefficient()
Calculate averaging coefficient for frame error rate.
double GetFrameErrorRate() const
Return frame error rate (probability that frame is corrupted due to transmission error).
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.
bool GetShortSlotTimeSupported(Mac48Address address) const
Return whether the station supports short ERP slot time or not.
The IEEE 802.11ac VHT Capabilities.
void SetGuardInterval(uint16_t guardInterval)
Sets the guard interval duration (in nanoseconds)
bool m_useNonErpProtection
flag if protection for non-ERP stations against ERP transmissions is enabled
Hold an unsigned integer type.
Definition: uinteger.h:44
virtual void DoReportDataFailed(WifiRemoteStation *station)=0
This method is a pure virtual method that must be implemented by the sub-class.
uint8_t GetSupportedChannelWidthSet() const
Get the supported channel width set.
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.
void AddStationHtCapabilities(Mac48Address from, HtCapabilities htcapabilities)
Records HT capabilities of the remote station.
mac
Definition: third.py:92
WifiRemoteStationInfo GetInfo(Mac48Address address)
uint8_t GetQosTid(void) const
Return the Traffic ID of a QoS header.
void SetMaxSsrc(uint32_t maxSsrc)
Sets the maximum STA short retry count (SSRC).
WifiMode GetMode(void) const
HT PHY (Clause 20)
Definition: wifi-mode.h:58
uint32_t m_maxSlrc
Maximum STA long retry count (SLRC)
bool m_pcfSupported
Flag if PCF capability is supported.
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 GetNNonErpBasicModes(void) const
Return the number of non-ERP basic modes we support.
WifiMode GetNonErpBasicMode(uint8_t i) const
Return a basic mode from the set of basic modes that is not an ERP mode.
void AddStationHeCapabilities(Mac48Address from, HeCapabilities hecapabilities)
Records HE capabilities of the remote station.
bool IsAssociated(Mac48Address address) const
Return whether the station associated.
virtual void SetupPhy(const Ptr< WifiPhy > phy)
Set up PHY associated with this device since it is the object that knows the full set of transmit rat...
hold a list of per-remote-station state.
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:500
WifiMode GetControlAnswerMode(Mac48Address address, WifiMode reqMode)
Get control answer mode function.
bool GetQosSupported(Mac48Address address) const
Return whether the given station is QoS capable.
WifiMode GetDefaultMode(void) const
Return the default transmission mode.
void SetQosSupport(Mac48Address from, bool qosSupported)
Records QoS support of the remote station.
WifiMode m_defaultTxMode
The default transmission mode.
void SetNss(uint8_t nss)
Sets the number of Nss refer to IEEE 802.11n Table 20-28 for explanation and range.
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.
virtual void SetHtSupported(bool enable)
Enable or disable HT capability support.
virtual uint8_t DoGetAckTxPowerLevel(Mac48Address address, WifiMode ackMode)
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:363
tag a set of bytes in a packet
Definition: tag.h:36
uint32_t GetFragmentOffset(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fragmentNumber)
bool GetShortSlotTimeEnabled(void) const
Return whether the device uses short slot time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool HasHeSupported(void) const
Return whether the device has HE capability support enabled.
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:367
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...
uint16_t GetFrequency(void) const
Definition: wifi-phy.cc:1243
void SetPreambleType(WifiPreamble preamble)
Sets the preamble type.
uint8_t GetNumberOfAntennas(void) const
Definition: wifi-phy.cc:1277
void AddSupportedMode(Mac48Address address, WifiMode mode)
Invoked in a STA or AP to store the set of modes supported by a destination which is also supported l...
WifiModeList m_operationalRateSet
This member is the list of WifiMode objects that comprise the OperationalRateSet parameter for this r...
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
uint32_t GetFragmentSize(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fragmentNumber)
bool HasPcfSupported(void) const
Return whether the device has PCF capability support enabled.
void DoSetFragmentationThreshold(uint32_t threshold)
Actually sets the fragmentation threshold, it also checks the validity of the given threshold...
bool IsHigherCodeRate(WifiMode mode) const
Definition: wifi-mode.cc:595
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)
virtual bool IsLowLatency(void) const =0
Mac48Address GetAddress(const WifiRemoteStation *station) const
Return the address of the station.
WifiMode GetNonErpSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether non-ERP mode associated with the specified station at the specified index...
void SetTxPowerLevel(uint8_t powerlevel)
Sets the selected transmission power level.
Ptr< const AttributeAccessor > MakeWifiModeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: wifi-mode.h:244
uint8_t GetRxLdpc() const
Get the receive LDPC.
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.
virtual uint16_t DoGetCtsTxGuardInterval(Mac48Address address, WifiMode ctsMode)
bool GetAggregation(const WifiRemoteStation *station) const
Return whether the given station supports A-MPDU.
uint16_t m_channelWidth
Channel width (in MHz) supported by the remote station.
bool HasHtSupported(void) const
Return whether the device has HT capability support enabled.
virtual bool DoNeedRetransmission(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
uint8_t GetHighestMcsSupported(void) const
Get highest MCS supported.
virtual void Print(std::ostream &os) 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.
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
uint8_t GetNModes(void) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
Definition: wifi-phy.cc:3505
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.
HighLatencyCtsToSelfTxVectorTag class.
uint8_t GetNBasicModes(void) const
Return the number of basic modes we support.
uint8_t GetHeLtfAndGiForHePpdus(void) const
Get HE LTF and GI for HE PDPUs.
bool GetHeSupported(const WifiRemoteStation *station) const
Return whether the given station is HE capable.
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
WifiMode GetMode(uint8_t mode) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
Definition: wifi-phy.cc:3511
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.
Ptr< WifiPhy > GetPhy(void) const
Return the WifiPhy.
void ReportDataFailed(Mac48Address address, const WifiMacHeader *header, uint32_t packetSize)
Should be invoked whenever the AckTimeout associated to a transmission attempt expires.
read and write tag data
Definition: tag-buffer.h:51
WifiTxVector GetDataTxVector(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
bool IsMgt(void) const
Return true if the Type is Management.
WifiModulationClass
This enumeration defines the modulation classes per (Table 9-4 "Modulation classes"; IEEE 802...
Definition: wifi-mode.h:36
bool GetHtSupported(Mac48Address address) const
Return whether the station supports HT or not.
A struct that holds information about each remote station.
WifiModeList m_operationalMcsSet
operational MCS set
static TypeId GetTypeId(void)
Get the type ID.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition: packet.cc:852
void AddSupportedErpSlotTime(Mac48Address address, bool isShortSlotTimeSupported)
Record whether the short ERP slot time is supported by the station.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:262
void SetFragmentationThreshold(uint32_t threshold)
Sets a fragmentation threshold.
void Reset(void)
Reset the station, invoked in a STA upon dis-association or in an AP upon reboot. ...
bool GetUseNonErpProtection(void) const
Return whether the device supports protection of non-ERP stations.
uint32_t m_maxSsrc
Maximum STA short retry count (SSRC)
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:270
virtual void DoDispose(void)
Destructor implementation.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1014
OFDM PHY (Clause 17)
Definition: wifi-mode.h:56
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
uint8_t GetShortGuardInterval20(void) const
Return the short guard interval 20 value.
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)
virtual void Serialize(TagBuffer i) const
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)
WifiRemoteStation * Lookup(Mac48Address address, uint8_t tid) const
Return the station associated with the given address and TID.
void Read(uint8_t *buffer, uint32_t size)
Definition: tag-buffer.cc:176
bool IsQosData(void) const
Return true if the Type is DATA and Subtype is one of the possible values for QoS DATA...
Ptr< const AttributeChecker > MakeWifiModeChecker(void)
Definition: wifi-mode.cc:687
virtual void SetHeSupported(bool enable)
Enable or disable HE capability support.
uint8_t m_ness
Number of streams in beamforming of the remote station.
static const uint32_t packetSize
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
AttributeValue implementation for WifiMode.
Definition: wifi-mode.h:244
bool GetShortGuardInterval(Mac48Address address) const
Return whether the station supports HT/VHT short guard interval.
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.
bool IsWaitAssocTxOk(Mac48Address address) const
Return whether we are waiting for an ACK for the association response we sent.
void SetShortPreambleEnabled(bool enable)
Enable or disable short PLCP preambles.
bool IsSupportedMcs(uint8_t mcs, uint8_t Nss) const
Get the is MCS supported.
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 ...
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.
WifiMode GetBasicMode(uint8_t i) const
Return a basic mode from the set of basic modes.
uint32_t m_slrc
STA long retry count.
void AddAllSupportedModes(Mac48Address address)
Invoked in a STA or AP to store all of the modes supported by a destination which is also supported l...
virtual WifiTxVector DoGetDataTxVector(WifiRemoteStation *station)=0
The IEEE 802.11ax HE Capabilities.
uint8_t GetMcsValue(void) const
Definition: wifi-mode.cc:478
virtual void DoReportFinalDataFailed(WifiRemoteStation *station)=0
This method is a pure virtual method that must be implemented by the sub-class.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: uinteger.h:45
virtual WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station)=0
bool IsBrandNew(Mac48Address address) const
Return whether the station state is brand new.
uint8_t GetMaxSupportedTxSpatialStreams(void) const
Definition: wifi-phy.cc:1296
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.
bool IsHigherDataRate(WifiMode mode) const
Definition: wifi-mode.cc:615
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.
uint8_t GetHighestNssSupported(void) const
Get highest NSS supported.
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
WifiMode GetMcsSupported(const WifiRemoteStation *station, uint8_t i) const
Return the WifiMode supported by the specified station at the specified index.
uint16_t GetChannelWidthSupported(Mac48Address address) const
Return the channel width supported by the station.
virtual uint8_t DoGetBlockAckTxPowerLevel(Mac48Address address, WifiMode blockAckMode)
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.
virtual uint32_t GetSerializedSize(void) const
virtual void Print(std::ostream &os) const
uint16_t GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the station.
uint8_t GetNess(const WifiRemoteStation *station) const
uint16_t m_guardInterval
HE Guard interval duration (in nanoseconds) supported by the remote station.
uint32_t DoGetFragmentationThreshold(void) const
Return the current fragmentation threshold.
Time GetGuardInterval(void) const
Definition: wifi-phy.cc:631