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 <iostream>
23 #include "ns3/simulator.h"
24 #include "ns3/assert.h"
25 #include "ns3/log.h"
26 #include "ns3/tag.h"
27 #include "ns3/boolean.h"
28 #include "ns3/double.h"
29 #include "ns3/uinteger.h"
30 #include "ns3/enum.h"
31 #include "ns3/wifi-phy.h"
32 #include "ns3/wifi-mac.h"
33 #include "ns3/trace-source-accessor.h"
34 #include "wifi-mac-header.h"
35 #include "wifi-mac-trailer.h"
36 
37 /***************************************************************
38  * Packet Mode Tagger
39  ***************************************************************/
40 
41 namespace ns3 {
42 
43 NS_LOG_COMPONENT_DEFINE ("WifiRemoteStationManager");
44 
46 {
47 public:
53  WifiTxVector GetDataTxVector (void) const;
54 
55  static TypeId GetTypeId (void);
56  virtual TypeId GetInstanceTypeId (void) const;
57  virtual uint32_t GetSerializedSize (void) const;
58  virtual void Serialize (TagBuffer i) const;
59  virtual void Deserialize (TagBuffer i);
60  virtual void Print (std::ostream &os) const;
61 private:
63 };
64 
66 {
67 }
68 
70  : m_dataTxVector (dataTxVector)
71 {
72 }
73 
76 {
77  return m_dataTxVector;
78 }
79 
80 TypeId
82 {
83  static TypeId tid = TypeId ("ns3::HighLatencyDataTxVectorTag")
84  .SetParent<Tag> ()
85  .SetGroupName ("Wifi")
86  .AddConstructor<HighLatencyDataTxVectorTag> ()
87  ;
88  return tid;
89 }
90 
91 TypeId
93 {
94  return GetTypeId ();
95 }
96 
97 uint32_t
99 {
100  return sizeof (WifiTxVector);
101 }
102 
103 void
105 {
106  i.Write ((uint8_t *)&m_dataTxVector, sizeof (WifiTxVector));
107 }
108 
109 void
111 {
112  i.Read ((uint8_t *)&m_dataTxVector, sizeof (WifiTxVector));
113 }
114 
115 void
116 HighLatencyDataTxVectorTag::Print (std::ostream &os) const
117 {
118  os << "Data=" << m_dataTxVector;
119 }
120 
122 {
123 public:
130  WifiTxVector GetRtsTxVector (void) const;
131 
132  static TypeId GetTypeId (void);
133  virtual TypeId GetInstanceTypeId (void) const;
134  virtual uint32_t GetSerializedSize (void) const;
135  virtual void Serialize (TagBuffer i) const;
136  virtual void Deserialize (TagBuffer i);
137  virtual void Print (std::ostream &os) const;
138 private:
140 };
141 
143 {
144 }
145 
147  : m_rtsTxVector (rtsTxVector)
148 {
149 }
150 
153 {
154  return m_rtsTxVector;
155 }
156 
157 TypeId
159 {
160  static TypeId tid = TypeId ("ns3::HighLatencyRtsTxVectorTag")
161  .SetParent<Tag> ()
162  .SetGroupName ("Wifi")
163  .AddConstructor<HighLatencyRtsTxVectorTag> ()
164  ;
165  return tid;
166 }
167 
168 TypeId
170 {
171  return GetTypeId ();
172 }
173 
174 uint32_t
176 {
177  return sizeof (WifiTxVector);
178 }
179 
180 void
182 {
183  i.Write ((uint8_t *)&m_rtsTxVector, sizeof (WifiTxVector));
184 }
185 
186 void
188 {
189  i.Read ((uint8_t *)&m_rtsTxVector, sizeof (WifiTxVector));
190 }
191 
192 void
193 HighLatencyRtsTxVectorTag::Print (std::ostream &os) const
194 {
195  os << "Rts=" << m_rtsTxVector;
196 }
197 
199 {
200 public:
202  HighLatencyCtsToSelfTxVectorTag (WifiTxVector ctsToSelfTxVector);
206  WifiTxVector GetCtsToSelfTxVector (void) const;
207 
208  static TypeId GetTypeId (void);
209  virtual TypeId GetInstanceTypeId (void) const;
210  virtual uint32_t GetSerializedSize (void) const;
211  virtual void Serialize (TagBuffer i) const;
212  virtual void Deserialize (TagBuffer i);
213  virtual void Print (std::ostream &os) const;
214 private:
216 };
217 
219 {
220 }
221 
223  : m_ctsToSelfTxVector (ctsToSelfTxVector)
224 {
225 }
226 
229 {
230  return m_ctsToSelfTxVector;
231 }
232 
233 TypeId
235 {
236  static TypeId tid = TypeId ("ns3::HighLatencyCtsToSelfTxVectorTag")
237  .SetParent<Tag> ()
238  .SetGroupName ("Wifi")
239  .AddConstructor<HighLatencyCtsToSelfTxVectorTag> ()
240  ;
241  return tid;
242 }
243 
244 TypeId
246 {
247  return GetTypeId ();
248 }
249 
250 uint32_t
252 {
253  return sizeof (WifiTxVector);
254 }
255 
256 void
258 {
259  i.Write ((uint8_t *)&m_ctsToSelfTxVector, sizeof (WifiTxVector));
260 }
261 
262 void
264 {
265  i.Read ((uint8_t *)&m_ctsToSelfTxVector, sizeof (WifiTxVector));
266 }
267 
268 void
270 {
271  os << "Cts To Self=" << m_ctsToSelfTxVector;
272 }
273 
274 } //namespace ns3
275 
276 namespace ns3 {
277 
278 NS_OBJECT_ENSURE_REGISTERED (WifiRemoteStationManager);
279 
280 TypeId
282 {
283  static TypeId tid = TypeId ("ns3::WifiRemoteStationManager")
284  .SetParent<Object> ()
285  .SetGroupName ("Wifi")
286  .AddAttribute ("IsLowLatency",
287  "If true, we attempt to modelize a so-called low-latency device: "
288  "a device where decisions about tx parameters can be made on a per-packet basis and "
289  "feedback about the transmission of each packet is obtained before sending the next. "
290  "Otherwise, we modelize a high-latency device, that is a device where we cannot update "
291  "our decision about tx parameters after every packet transmission.",
293  BooleanValue (true), //this value is ignored because there is no setter
296  .AddAttribute ("MaxSsrc",
297  "The maximum number of retransmission attempts for an RTS. "
298  " This value will not have any effect on some rate control algorithms.",
299  UintegerValue (7),
301  MakeUintegerChecker<uint32_t> ())
302  .AddAttribute ("MaxSlrc",
303  "The maximum number of retransmission attempts for a DATA packet. "
304  "This value will not have any effect on some rate control algorithms.",
305  UintegerValue (7),
307  MakeUintegerChecker<uint32_t> ())
308  .AddAttribute ("RtsCtsThreshold",
309  "If the size of the PSDU is bigger than this value, we use an RTS/CTS handshake before sending the data frame."
310  "This value will not have any effect on some rate control algorithms.",
311  UintegerValue (65535),
313  MakeUintegerChecker<uint32_t> ())
314  .AddAttribute ("FragmentationThreshold",
315  "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. "
316  "This value does not apply when it is carried in an A-MPDU. "
317  "This value will not have any effect on some rate control algorithms.",
318  UintegerValue (2346),
321  MakeUintegerChecker<uint32_t> ())
322  .AddAttribute ("NonUnicastMode",
323  "Wifi mode used for non-unicast transmissions.",
324  WifiModeValue (),
327  .AddAttribute ("DefaultTxPowerLevel",
328  "Default power level to be used for transmissions. "
329  "This is the power level that is used by all those WifiManagers that do not implement TX power control.",
330  UintegerValue (0),
332  MakeUintegerChecker<uint8_t> ())
333  .AddAttribute ("ProtectionMode",
334  "Protection mode used when non-ERP STAs are connected to an ERP AP: Rts-Cts or Cts-To-Self",
340  .AddTraceSource ("MacTxRtsFailed",
341  "The transmission of a RTS by the MAC layer has failed",
343  "ns3::Mac48Address::TracedCallback")
344  .AddTraceSource ("MacTxDataFailed",
345  "The transmission of a data packet by the MAC layer has failed",
347  "ns3::Mac48Address::TracedCallback")
348  .AddTraceSource ("MacTxFinalRtsFailed",
349  "The transmission of a RTS has exceeded the maximum number of attempts",
351  "ns3::Mac48Address::TracedCallback")
352  .AddTraceSource ("MacTxFinalDataFailed",
353  "The transmission of a data packet has exceeded the maximum number of attempts",
355  "ns3::Mac48Address::TracedCallback")
356  ;
357  return tid;
358 }
359 
361  : m_htSupported (false),
362  m_vhtSupported (false),
363  m_useNonErpProtection (false),
364  m_shortPreambleEnabled (false),
365  m_shortSlotTimeEnabled (false)
366 {
367 }
368 
370 {
371 }
372 
373 void
375 {
376  for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
377  {
378  delete (*i);
379  }
380  m_states.clear ();
381  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
382  {
383  delete (*i);
384  }
385  m_stations.clear ();
386 }
387 
388 void
390 {
391  //We need to track our PHY because it is the object that knows the
392  //full set of transmit rates that are supported. We need to know
393  //this in order to find the relevant mandatory rates when chosing a
394  //transmit rate for automatic control responses like
395  //acknowledgements.
396  m_wifiPhy = phy;
397  m_defaultTxMode = phy->GetMode (0);
398  if (HasHtSupported () || HasVhtSupported ())
399  {
400  m_defaultTxMcs = phy->GetMcs (0);
401  }
402  Reset ();
403 }
404 
405 void
407 {
408  //We need to track our MAC because it is the object that knows the
409  //full set of interframe spaces.
410  m_wifiMac = mac;
411  Reset ();
412 }
413 
414 void
416 {
417  m_htSupported = enable;
418 }
419 
420 void
422 {
423  m_maxSsrc = maxSsrc;
424 }
425 
426 void
428 {
429  m_maxSlrc = maxSlrc;
430 }
431 
432 void
434 {
435  m_rtsCtsThreshold = threshold;
436 }
437 
438 void
440 {
441  DoSetFragmentationThreshold (threshold);
442 }
443 
444 void
446 {
447  m_protectionMode = mode;
448 }
449 
450 void
452 {
453  m_shortPreambleEnabled = enable;
454 }
455 
456 void
458 {
459  m_shortSlotTimeEnabled = enable;
460 }
461 
462 bool
464 {
465  return m_shortSlotTimeEnabled;
466 }
467 
468 bool
470 {
471  return m_shortPreambleEnabled;
472 }
473 
476 {
477  return m_protectionMode;
478 }
479 
480 bool
482 {
483  return m_htSupported;
484 }
485 
486 void
488 {
489  m_vhtSupported = enable;
490 }
491 
492 bool
494 {
495  return m_vhtSupported;
496 }
497 
498 uint32_t
500 {
501  return m_maxSsrc;
502 }
503 
504 uint32_t
506 {
507  return m_maxSlrc;
508 }
509 
510 uint32_t
512 {
513  return m_rtsCtsThreshold;
514 }
515 
516 uint32_t
518 {
519  return DoGetFragmentationThreshold ();
520 }
521 
522 void
524 {
525  NS_LOG_FUNCTION (this << address);
526  NS_ASSERT (!address.IsGroup ());
527  WifiRemoteStationState *state = LookupState (address);
528  state->m_operationalRateSet.clear ();
529  state->m_operationalMcsSet.clear ();
530  AddSupportedMode (address, GetDefaultMode ());
531  AddSupportedMcs (address, GetDefaultMcs ());
532 }
533 
534 void
536 {
537  NS_LOG_FUNCTION (this << address << isShortPreambleSupported);
538  NS_ASSERT (!address.IsGroup ());
539  WifiRemoteStationState *state = LookupState (address);
540  state->m_shortPreamble = isShortPreambleSupported;
541 }
542 
543 void
545 {
546  NS_LOG_FUNCTION (this << address << isShortSlotTimeSupported);
547  NS_ASSERT (!address.IsGroup ());
548  WifiRemoteStationState *state = LookupState (address);
549  state->m_shortSlotTime = isShortSlotTimeSupported;
550 }
551 
552 void
554 {
555  NS_LOG_FUNCTION (this << address << mode);
556  NS_ASSERT (!address.IsGroup ());
557  WifiRemoteStationState *state = LookupState (address);
558  for (WifiModeListIterator i = state->m_operationalRateSet.begin (); i != state->m_operationalRateSet.end (); i++)
559  {
560  if ((*i) == mode)
561  {
562  //already in.
563  return;
564  }
565  }
566  state->m_operationalRateSet.push_back (mode);
567 }
568 
569 void
571 {
572  NS_LOG_FUNCTION (this << address);
573  NS_ASSERT (!address.IsGroup ());
574  WifiRemoteStationState *state = LookupState (address);
575  state->m_operationalRateSet.clear ();
576  for (uint32_t i = 0; i < m_wifiPhy->GetNModes (); i++)
577  {
578  state->m_operationalRateSet.push_back (m_wifiPhy->GetMode (i));
579  if (m_wifiPhy->GetMode (i).IsMandatory ())
580  {
582  }
583  }
584 }
585 
586 void
588 {
589  NS_LOG_FUNCTION (this << address);
590  NS_ASSERT (!address.IsGroup ());
591  WifiRemoteStationState *state = LookupState (address);
592  state->m_operationalMcsSet.clear ();
593  for (uint32_t i = 0; i < m_wifiPhy->GetNMcs (); i++)
594  {
595  state->m_operationalMcsSet.push_back (m_wifiPhy->GetMcs (i));
596  }
597 }
598 
599 void
601 {
602  NS_LOG_FUNCTION (this << address << mcs);
603  NS_ASSERT (!address.IsGroup ());
604  WifiRemoteStationState *state = LookupState (address);
605  for (WifiModeListIterator i = state->m_operationalMcsSet.begin (); i != state->m_operationalMcsSet.end (); i++)
606  {
607  if ((*i) == mcs)
608  {
609  //already in.
610  return;
611  }
612  }
613  state->m_operationalMcsSet.push_back (mcs);
614 }
615 
616 bool
618 {
619  return LookupState (address)->m_shortPreamble;
620 }
621 
622 bool
624 {
625  return LookupState (address)->m_shortSlotTime;
626 }
627 
628 bool
630 {
631  if (address.IsGroup ())
632  {
633  return false;
634  }
636 }
637 
638 bool
640 {
641  if (address.IsGroup ())
642  {
643  return true;
644  }
646 }
647 
648 bool
650 {
651  if (address.IsGroup ())
652  {
653  return false;
654  }
656 }
657 
658 void
660 {
661  NS_ASSERT (!address.IsGroup ());
663 }
664 
665 void
667 {
668  NS_ASSERT (!address.IsGroup ());
670 }
671 
672 void
674 {
675  NS_ASSERT (!address.IsGroup ());
677 }
678 
679 void
681 {
682  NS_ASSERT (!address.IsGroup ());
684 }
685 
686 void
688 {
689  NS_LOG_FUNCTION (this << address << *header << packet);
690  if (IsLowLatency () || address.IsGroup ())
691  {
692  return;
693  }
694  WifiRemoteStation *station = Lookup (address, header);
695  WifiTxVector rts = DoGetRtsTxVector (station);
696  WifiTxVector data = DoGetDataTxVector (station);
697  WifiTxVector ctstoself = DoGetCtsToSelfTxVector ();
700  HighLatencyCtsToSelfTxVectorTag ctstoselftag;
701  //first, make sure that the tag is not here anymore.
702  ConstCast<Packet> (packet)->RemovePacketTag (datatag);
703  ConstCast<Packet> (packet)->RemovePacketTag (rtstag);
704  ConstCast<Packet> (packet)->RemovePacketTag (ctstoselftag);
705  datatag = HighLatencyDataTxVectorTag (data);
706  rtstag = HighLatencyRtsTxVectorTag (rts);
707  ctstoselftag = HighLatencyCtsToSelfTxVectorTag (ctstoself);
708  //and then, add it back
709  packet->AddPacketTag (datatag);
710  packet->AddPacketTag (rtstag);
711  packet->AddPacketTag (ctstoselftag);
712 }
713 
716 {
717  NS_LOG_FUNCTION (this << address << *header << packet);
718  if (address.IsGroup ())
719  {
720  WifiTxVector v;
721  v.SetMode (GetNonUnicastMode ());
725  v.SetNss (1);
726  v.SetNess (0);
727  v.SetStbc (false);
728  return v;
729  }
730  if (!IsLowLatency ())
731  {
733  bool found;
734  found = ConstCast<Packet> (packet)->PeekPacketTag (datatag);
735  NS_ASSERT (found);
736  //cast found to void, to suppress 'found' set but not used
737  //compiler warning
738  (void) found;
739  return datatag.GetDataTxVector ();
740  }
741  return DoGetDataTxVector (Lookup (address, header));
742 }
743 
746  Ptr<const Packet> packet)
747 {
748  NS_LOG_FUNCTION (this << *header << packet);
749  if (!IsLowLatency ())
750  {
751  HighLatencyCtsToSelfTxVectorTag ctstoselftag;
752  bool found;
753  found = ConstCast<Packet> (packet)->PeekPacketTag (ctstoselftag);
754  NS_ASSERT (found);
755  //cast found to void, to suppress 'found' set but not used
756  //compiler warning
757  (void) found;
758  return ctstoselftag.GetCtsToSelfTxVector ();
759  }
760  return DoGetCtsToSelfTxVector ();
761 }
762 
765 {
766  return WifiTxVector (GetDefaultMode (),
768  0,
773  false,
774  false);
775 }
776 
779  Ptr<const Packet> packet)
780 {
781  NS_LOG_FUNCTION (this << address << *header << packet);
782  NS_ASSERT (!address.IsGroup ());
783  if (!IsLowLatency ())
784  {
786  bool found;
787  found = ConstCast<Packet> (packet)->PeekPacketTag (rtstag);
788  NS_ASSERT (found);
789  //cast found to void, to suppress 'found' set but not used
790  //compiler warning
791  (void) found;
792  return rtstag.GetRtsTxVector ();
793  }
794  return DoGetRtsTxVector (Lookup (address, header));
795 }
796 
797 void
799 {
800  NS_LOG_FUNCTION (this << address << *header);
801  NS_ASSERT (!address.IsGroup ());
802  WifiRemoteStation *station = Lookup (address, header);
803  station->m_ssrc++;
804  m_macTxRtsFailed (address);
805  DoReportRtsFailed (station);
806 }
807 
808 void
810 {
811  NS_LOG_FUNCTION (this << address << *header);
812  NS_ASSERT (!address.IsGroup ());
813  WifiRemoteStation *station = Lookup (address, header);
814  station->m_slrc++;
815  m_macTxDataFailed (address);
816  DoReportDataFailed (station);
817 }
818 
819 void
821  double ctsSnr, WifiMode ctsMode, double rtsSnr)
822 {
823  NS_LOG_FUNCTION (this << address << *header << ctsSnr << ctsMode << rtsSnr);
824  NS_ASSERT (!address.IsGroup ());
825  WifiRemoteStation *station = Lookup (address, header);
826  station->m_state->m_info.NotifyTxSuccess (station->m_ssrc);
827  station->m_ssrc = 0;
828  DoReportRtsOk (station, ctsSnr, ctsMode, rtsSnr);
829 }
830 
831 void
833  double ackSnr, WifiMode ackMode, double dataSnr)
834 {
835  NS_LOG_FUNCTION (this << address << *header << ackSnr << ackMode << dataSnr);
836  NS_ASSERT (!address.IsGroup ());
837  WifiRemoteStation *station = Lookup (address, header);
838  station->m_state->m_info.NotifyTxSuccess (station->m_slrc);
839  station->m_slrc = 0;
840  DoReportDataOk (station, ackSnr, ackMode, dataSnr);
841 }
842 
843 void
845 {
846  NS_LOG_FUNCTION (this << address << *header);
847  NS_ASSERT (!address.IsGroup ());
848  WifiRemoteStation *station = Lookup (address, header);
849  station->m_state->m_info.NotifyTxFailed ();
850  station->m_ssrc = 0;
851  m_macTxFinalRtsFailed (address);
852  DoReportFinalRtsFailed (station);
853 }
854 
855 void
857 {
858  NS_LOG_FUNCTION (this << address << *header);
859  NS_ASSERT (!address.IsGroup ());
860  WifiRemoteStation *station = Lookup (address, header);
861  station->m_state->m_info.NotifyTxFailed ();
862  station->m_slrc = 0;
863  m_macTxFinalDataFailed (address);
864  DoReportFinalDataFailed (station);
865 }
866 
867 void
869  double rxSnr, WifiMode txMode)
870 {
871  NS_LOG_FUNCTION (this << address << *header << rxSnr << txMode);
872  if (address.IsGroup ())
873  {
874  return;
875  }
876  WifiRemoteStation *station = Lookup (address, header);
877  DoReportRxOk (station, rxSnr, txMode);
878 }
879 
880 void
882  uint32_t nSuccessfulMpdus, uint32_t nFailedMpdus, double rxSnr, double dataSnr)
883 {
884  NS_LOG_FUNCTION (this << address << (uint16_t)tid << nSuccessfulMpdus << nFailedMpdus << rxSnr << dataSnr);
885  NS_ASSERT (!address.IsGroup ());
886  WifiRemoteStation *station = Lookup (address, tid);
887  DoReportAmpduTxStatus (station, nSuccessfulMpdus, nFailedMpdus, rxSnr, dataSnr);
888 }
889 
890 bool
892  Ptr<const Packet> packet, WifiTxVector txVector)
893 {
894  WifiMode mode = txVector.GetMode ();
895  NS_LOG_FUNCTION (this << address << *header << packet << mode);
898  || (mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
899  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT))
901  {
902  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedRTS returning true to protect non-ERP stations");
903  return true;
904  }
905  if (address.IsGroup ())
906  {
907  return false;
908  }
909  bool normally = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > GetRtsCtsThreshold ();
910  return DoNeedRts (Lookup (address, header), packet, normally);
911 }
912 
913 bool
915 {
916  WifiMode mode = txVector.GetMode ();
917  NS_LOG_FUNCTION (this << mode);
920  || (mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
921  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT))
923  {
924  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true to protect non-ERP stations");
925  return true;
926  }
927  else if (!m_useNonErpProtection)
928  {
929  //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
930  for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
931  {
932  if (mode == *i)
933  {
934  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
935  return false;
936  }
937  }
938  if (HasHtSupported ())
939  {
940  //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
941  for (WifiModeListIterator i = m_bssBasicMcsSet.begin (); i != m_bssBasicMcsSet.end (); i++)
942  {
943  if (mode == *i)
944  {
945  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
946  return false;
947  }
948  }
949  }
950  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true");
951  return true;
952  }
953  return false;
954 }
955 
956 void
958 {
959  m_useNonErpProtection = enable;
960 }
961 
962 bool
964 {
965  return m_useNonErpProtection;
966 }
967 
968 bool
970  Ptr<const Packet> packet)
971 {
972  NS_LOG_FUNCTION (this << address << packet << *header);
973  NS_ASSERT (!address.IsGroup ());
974  WifiRemoteStation *station = Lookup (address, header);
975  bool normally = station->m_ssrc < GetMaxSsrc ();
976  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedDataRetransmission count: " << station->m_ssrc << " result: " << std::boolalpha << normally);
977  return DoNeedRtsRetransmission (station, packet, normally);
978 }
979 
980 bool
982  Ptr<const Packet> packet)
983 {
984  NS_LOG_FUNCTION (this << address << packet << *header);
985  NS_ASSERT (!address.IsGroup ());
986  WifiRemoteStation *station = Lookup (address, header);
987  bool normally = station->m_slrc < GetMaxSlrc ();
988  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedDataRetransmission count: " << station->m_slrc << " result: " << std::boolalpha << normally);
989  return DoNeedDataRetransmission (station, packet, normally);
990 }
991 
992 bool
994  Ptr<const Packet> packet)
995 {
996  NS_LOG_FUNCTION (this << address << packet << *header);
997  if (address.IsGroup ())
998  {
999  return false;
1000  }
1001  WifiRemoteStation *station = Lookup (address, header);
1002  bool normally = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > GetFragmentationThreshold ();
1003  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedFragmentation result: " << std::boolalpha << normally);
1004  return DoNeedFragmentation (station, packet, normally);
1005 }
1006 
1007 void
1009 {
1010  NS_LOG_FUNCTION (this << threshold);
1011  if (threshold < 256)
1012  {
1013  /*
1014  * ASN.1 encoding of the MAC and PHY MIB (256 ... 8000)
1015  */
1016  NS_LOG_WARN ("Fragmentation threshold should be larger than 256. Setting to 256.");
1018  }
1019  else
1020  {
1021  /*
1022  * The length of each fragment shall be an even number of octets, except for the last fragment if an MSDU or
1023  * MMPDU, which may be either an even or an odd number of octets.
1024  */
1025  if (threshold % 2 != 0)
1026  {
1027  NS_LOG_WARN ("Fragmentation threshold should be an even number. Setting to " << threshold - 1);
1028  m_nextFragmentationThreshold = threshold - 1;
1029  }
1030  else
1031  {
1032  m_nextFragmentationThreshold = threshold;
1033  }
1034  }
1035 }
1036 
1037 void
1039 {
1041 }
1042 
1043 uint32_t
1045 {
1046  return m_fragmentationThreshold;
1047 }
1048 
1049 uint32_t
1051 {
1052  NS_LOG_FUNCTION (this << *header << packet);
1053  //The number of bytes a fragment can support is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
1054  uint32_t nFragments = (packet->GetSize () / (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
1055 
1056  //If the size of the last fragment is not 0.
1057  if ((packet->GetSize () % (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH)) > 0)
1058  {
1059  nFragments++;
1060  }
1061  NS_LOG_DEBUG ("WifiRemoteStationManager::GetNFragments returning " << nFragments);
1062  return nFragments;
1063 }
1064 
1065 uint32_t
1067  Ptr<const Packet> packet, uint32_t fragmentNumber)
1068 {
1069  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
1070  NS_ASSERT (!address.IsGroup ());
1071  uint32_t nFragment = GetNFragments (header, packet);
1072  if (fragmentNumber >= nFragment)
1073  {
1074  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning 0");
1075  return 0;
1076  }
1077  //Last fragment
1078  if (fragmentNumber == nFragment - 1)
1079  {
1080  uint32_t lastFragmentSize = packet->GetSize () - (fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
1081  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << lastFragmentSize);
1082  return lastFragmentSize;
1083  }
1084  //All fragments but the last, the number of bytes is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
1085  else
1086  {
1087  uint32_t fragmentSize = GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH;
1088  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << fragmentSize);
1089  return fragmentSize;
1090  }
1091 }
1092 
1093 uint32_t
1095  Ptr<const Packet> packet, uint32_t fragmentNumber)
1096 {
1097  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
1098  NS_ASSERT (!address.IsGroup ());
1099  NS_ASSERT (fragmentNumber < GetNFragments (header, packet));
1100  uint32_t fragmentOffset = fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH);
1101  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentOffset returning " << fragmentOffset);
1102  return fragmentOffset;
1103 }
1104 
1105 bool
1107  Ptr<const Packet> packet, uint32_t fragmentNumber)
1108 {
1109  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
1110  NS_ASSERT (!address.IsGroup ());
1111  bool isLast = fragmentNumber == (GetNFragments (header, packet) - 1);
1112  NS_LOG_DEBUG ("WifiRemoteStationManager::IsLastFragment returning " << std::boolalpha << isLast);
1113  return isLast;
1114 }
1115 
1116 bool
1118 {
1119  switch (modClassReq)
1120  {
1121  case WIFI_MOD_CLASS_DSSS:
1122  return (modClassAnswer == WIFI_MOD_CLASS_DSSS);
1124  return (modClassAnswer == WIFI_MOD_CLASS_DSSS || modClassAnswer == WIFI_MOD_CLASS_HR_DSSS);
1126  return (modClassAnswer == WIFI_MOD_CLASS_DSSS || modClassAnswer == WIFI_MOD_CLASS_HR_DSSS || modClassAnswer == WIFI_MOD_CLASS_ERP_OFDM);
1127  case WIFI_MOD_CLASS_OFDM:
1128  return (modClassAnswer == WIFI_MOD_CLASS_OFDM);
1129  case WIFI_MOD_CLASS_HT:
1130  case WIFI_MOD_CLASS_VHT:
1131  return true;
1132  default:
1133  NS_FATAL_ERROR ("Modulation class not defined");
1134  return false;
1135  }
1136 }
1137 
1138 WifiMode
1140 {
1155  NS_LOG_FUNCTION (this << address << reqMode);
1156  WifiMode mode = GetDefaultMode ();
1157  bool found = false;
1158  //First, search the BSS Basic Rate set
1159  for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
1160  {
1161  if ((!found || i->IsHigherDataRate (mode))
1162  && (!i->IsHigherDataRate (reqMode))
1163  && (IsAllowedControlAnswerModulationClass (reqMode.GetModulationClass (), i->GetModulationClass ())))
1164  {
1165  mode = *i;
1166  //We've found a potentially-suitable transmit rate, but we
1167  //need to continue and consider all the basic rates before
1168  //we can be sure we've got the right one.
1169  found = true;
1170  }
1171  }
1172  if (HasHtSupported () || HasVhtSupported ())
1173  {
1174  if (!found)
1175  {
1176  mode = GetDefaultMcs ();
1177  for (WifiModeListIterator i = m_bssBasicMcsSet.begin (); i != m_bssBasicMcsSet.end (); i++)
1178  {
1179  if ((!found || i->IsHigherDataRate (mode))
1180  && (!i->IsHigherDataRate (reqMode))
1181  && (i->GetModulationClass () == reqMode.GetModulationClass ()))
1182  {
1183  mode = *i;
1184  //We've found a potentially-suitable transmit rate, but we
1185  //need to continue and consider all the basic rates before
1186  //we can be sure we've got the right one.
1187  found = true;
1188  }
1189  }
1190  }
1191  }
1192  //If we found a suitable rate in the BSSBasicRateSet, then we are
1193  //done and can return that mode.
1194  if (found)
1195  {
1196  NS_LOG_DEBUG ("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
1197  return mode;
1198  }
1199 
1217  for (uint32_t idx = 0; idx < m_wifiPhy->GetNModes (); idx++)
1218  {
1219  WifiMode thismode = m_wifiPhy->GetMode (idx);
1220  /* If the rate:
1221  *
1222  * - is a mandatory rate for the PHY, and
1223  * - is equal to or faster than our current best choice, and
1224  * - is less than or equal to the rate of the received frame, and
1225  * - is of the same modulation class as the received frame
1226  *
1227  * ...then it's our best choice so far.
1228  */
1229  if (thismode.IsMandatory ()
1230  && (!found || thismode.IsHigherDataRate (mode))
1231  && (!thismode.IsHigherDataRate (reqMode))
1233  {
1234  mode = thismode;
1235  //As above; we've found a potentially-suitable transmit
1236  //rate, but we need to continue and consider all the
1237  //mandatory rates before we can be sure we've got the right one.
1238  found = true;
1239  }
1240  }
1241  if (HasHtSupported () || HasVhtSupported ())
1242  {
1243  for (uint32_t idx = 0; idx < m_wifiPhy->GetNMcs (); idx++)
1244  {
1245  WifiMode thismode = m_wifiPhy->GetMcs (idx);
1246  if (thismode.IsMandatory ()
1247  && (!found || thismode.IsHigherDataRate (mode))
1248  && (!thismode.IsHigherCodeRate(reqMode))
1249  && (thismode.GetModulationClass () == reqMode.GetModulationClass ()))
1250  {
1251  mode = thismode;
1252  //As above; we've found a potentially-suitable transmit
1253  //rate, but we need to continue and consider all the
1254  //mandatory rates before we can be sure we've got the right one.
1255  found = true;
1256  }
1257 
1258  }
1259  }
1260 
1271  if (!found)
1272  {
1273  NS_FATAL_ERROR ("Can't find response rate for " << reqMode);
1274  }
1275 
1276  NS_LOG_DEBUG ("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
1277  return mode;
1278 }
1279 
1282 {
1283  NS_ASSERT (!address.IsGroup ());
1284  WifiTxVector v;
1285  v.SetMode (GetControlAnswerMode (address, rtsMode));
1286  v.SetTxPowerLevel (DoGetCtsTxPowerLevel (address, v.GetMode ()));
1287  v.SetChannelWidth (DoGetCtsTxChannelWidth (address, v.GetMode ()));
1288  v.SetShortGuardInterval (DoGetCtsTxGuardInterval (address, v.GetMode ()));
1289  v.SetNss (DoGetCtsTxNss (address, v.GetMode ()));
1290  v.SetNess (DoGetCtsTxNess (address, v.GetMode ()));
1291  v.SetStbc (DoGetCtsTxStbc (address, v.GetMode ()));
1292  return v;
1293 }
1294 
1297 {
1298  NS_ASSERT (!address.IsGroup ());
1299  WifiTxVector v;
1300  v.SetMode (GetControlAnswerMode (address, dataMode));
1301  v.SetTxPowerLevel (DoGetAckTxPowerLevel (address, v.GetMode ()));
1302  v.SetChannelWidth (DoGetAckTxChannelWidth (address, v.GetMode ()));
1303  v.SetShortGuardInterval (DoGetAckTxGuardInterval (address, v.GetMode ()));
1304  v.SetNss (DoGetAckTxNss (address, v.GetMode ()));
1305  v.SetNess (DoGetAckTxNess (address, v.GetMode ()));
1306  v.SetStbc (DoGetAckTxStbc (address, v.GetMode ()));
1307  return v;
1308 }
1309 
1312 {
1313  NS_ASSERT (!address.IsGroup ());
1314  WifiTxVector v;
1315  v.SetMode (GetControlAnswerMode (address, blockAckReqMode));
1316  v.SetTxPowerLevel (DoGetBlockAckTxPowerLevel (address, v.GetMode ()));
1317  v.SetChannelWidth (DoGetBlockAckTxChannelWidth (address, v.GetMode ()));
1318  v.SetShortGuardInterval (DoGetBlockAckTxGuardInterval (address, v.GetMode ()));
1319  v.SetNss (DoGetBlockAckTxNss (address, v.GetMode ()));
1320  v.SetNess (DoGetBlockAckTxNess (address, v.GetMode ()));
1321  v.SetStbc (DoGetBlockAckTxStbc (address, v.GetMode ()));
1322  return v;
1323 }
1324 
1325 uint8_t
1327 {
1328  return m_defaultTxPowerLevel;
1329 }
1330 
1331 uint32_t
1333 {
1334  return m_wifiPhy->GetChannelWidth ();
1335 }
1336 
1337 bool
1339 {
1340  return m_wifiPhy->GetGuardInterval ();
1341 }
1342 
1343 uint8_t
1345 {
1346  return 1;
1347 }
1348 
1349 uint8_t
1351 {
1352  return 0;
1353 }
1354 
1355 bool
1357 {
1358  return m_wifiPhy->GetStbc ();
1359 }
1360 
1361 uint8_t
1363 {
1364  return m_defaultTxPowerLevel;
1365 }
1366 
1367 uint32_t
1369 {
1370  return m_wifiPhy->GetChannelWidth ();
1371 }
1372 
1373 bool
1375 {
1376  return m_wifiPhy->GetGuardInterval ();
1377 }
1378 
1379 uint8_t
1381 {
1382  return 1;
1383 }
1384 
1385 uint8_t
1387 {
1388  return 0;
1389 }
1390 
1391 bool
1393 {
1394  return m_wifiPhy->GetStbc ();
1395 }
1396 
1397 uint8_t
1399 {
1400  return m_defaultTxPowerLevel;
1401 }
1402 
1403 uint32_t
1405 {
1406  return m_wifiPhy->GetChannelWidth ();
1407 }
1408 
1409 bool
1411 {
1412  return m_wifiPhy->GetGuardInterval ();
1413 }
1414 
1415 uint8_t
1417 {
1418  return 1;
1419 }
1420 
1421 uint8_t
1423 {
1424  return 0;
1425 }
1426 
1427 bool
1429 {
1430  return m_wifiPhy->GetStbc ();
1431 }
1432 
1433 uint8_t
1435 {
1436  return m_defaultTxPowerLevel;
1437 }
1438 
1441 {
1442  WifiRemoteStationState *state = LookupState (address);
1443  return state->m_info;
1444 }
1445 
1448 {
1449  NS_LOG_FUNCTION (this << address);
1450  for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
1451  {
1452  if ((*i)->m_address == address)
1453  {
1454  NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning existing state");
1455  return (*i);
1456  }
1457  }
1460  state->m_address = address;
1461  state->m_operationalRateSet.push_back (GetDefaultMode ());
1462  state->m_operationalMcsSet.push_back (GetDefaultMcs ());
1465  state->m_greenfield = m_wifiPhy->GetGreenfield ();
1466  state->m_rx = 1;
1467  state->m_ness = 0;
1468  state->m_aggregation = false;
1469  state->m_stbc = false;
1470  state->m_htSupported = false;
1471  state->m_vhtSupported = false;
1472  const_cast<WifiRemoteStationManager *> (this)->m_states.push_back (state);
1473  NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning new state");
1474  return state;
1475 }
1476 
1479 {
1480  uint8_t tid;
1481  if (header->IsQosData ())
1482  {
1483  tid = header->GetQosTid ();
1484  }
1485  else
1486  {
1487  tid = 0;
1488  }
1489  return Lookup (address, tid);
1490 }
1491 
1494 {
1495  NS_LOG_FUNCTION (this << address << (uint16_t)tid);
1496  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1497  {
1498  if ((*i)->m_tid == tid
1499  && (*i)->m_state->m_address == address)
1500  {
1501  return (*i);
1502  }
1503  }
1504  WifiRemoteStationState *state = LookupState (address);
1505 
1506  WifiRemoteStation *station = DoCreateStation ();
1507  station->m_state = state;
1508  station->m_tid = tid;
1509  station->m_ssrc = 0;
1510  station->m_slrc = 0;
1511  const_cast<WifiRemoteStationManager *> (this)->m_stations.push_back (station);
1512  return station;
1513 }
1514 
1515 void
1517 {
1518  //Used by all stations to record HT capabilities of remote stations
1519  NS_LOG_FUNCTION (this << from << htCapabilities);
1520  WifiRemoteStationState *state;
1521  state = LookupState (from);
1522  state->m_shortGuardInterval = htCapabilities.GetShortGuardInterval20 ();
1523  if (htCapabilities.GetSupportedChannelWidth () == 1)
1524  {
1525  state->m_channelWidth = 40;
1526  }
1527  else
1528  {
1529  state->m_channelWidth = 20;
1530  }
1531  state->m_htSupported = true;
1532  state->m_greenfield = htCapabilities.GetGreenfield ();
1533  state->m_rx = htCapabilities.GetRxHighestSupportedAntennas ();
1534 }
1535 
1536 void
1538 {
1539  //Used by all stations to record VHT capabilities of remote stations
1540  NS_LOG_FUNCTION (this << from << vhtCapabilities);
1541  WifiRemoteStationState *state;
1542  state = LookupState (from);
1543  if (vhtCapabilities.GetSupportedChannelWidthSet () == 1)
1544  {
1545  state->m_channelWidth = 160;
1546  }
1547  else
1548  {
1549  state->m_channelWidth = 80;
1550  }
1551  //This is a workaround to enable users to force a 20 or 40 MHz channel for a VHT-compliant device,
1552  //since IEEE 802.11ac standard says that 20, 40 and 80 MHz channels are mandatory.
1553  if (m_wifiPhy->GetChannelWidth () < state->m_channelWidth)
1554  {
1556  }
1557  state->m_vhtSupported = true;
1558 }
1559 
1560 bool
1562 {
1563  return LookupState (address)->m_greenfield;
1564 }
1565 
1566 WifiMode
1568 {
1569  return m_defaultTxMode;
1570 }
1571 
1572 WifiMode
1574 {
1575  return m_defaultTxMcs;
1576 }
1577 
1578 void
1580 {
1581  NS_LOG_FUNCTION (this);
1582  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1583  {
1584  delete (*i);
1585  }
1586  m_stations.clear ();
1587  m_bssBasicRateSet.clear ();
1588  m_bssBasicRateSet.push_back (m_defaultTxMode);
1589  m_bssBasicMcsSet.clear ();
1590  m_bssBasicMcsSet.push_back (m_defaultTxMcs);
1592 }
1593 
1594 void
1596 {
1597  NS_LOG_FUNCTION (this << mode);
1599  {
1600  NS_FATAL_ERROR ("It is not allowed to add a (V)HT rate in the BSSBasicRateSet!");
1601  }
1602  for (uint32_t i = 0; i < GetNBasicModes (); i++)
1603  {
1604  if (GetBasicMode (i) == mode)
1605  {
1606  return;
1607  }
1608  }
1609  m_bssBasicRateSet.push_back (mode);
1610 }
1611 
1612 uint32_t
1614 {
1615  return m_bssBasicRateSet.size ();
1616 }
1617 
1618 WifiMode
1620 {
1621  NS_ASSERT (i < GetNBasicModes ());
1622  return m_bssBasicRateSet[i];
1623 }
1624 
1625 uint32_t
1627 {
1628  uint32_t size = 0;
1629  for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
1630  {
1631  if (i->GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1632  {
1633  continue;
1634  }
1635  size++;
1636  }
1637  return size;
1638 }
1639 
1640 WifiMode
1642 {
1644  uint32_t index = 0;
1645  bool found = false;
1646  for (WifiModeListIterator j = m_bssBasicRateSet.begin (); j != m_bssBasicRateSet.end (); )
1647  {
1648  if (i == index)
1649  {
1650  found = true;
1651  }
1652  if (j->GetModulationClass () != WIFI_MOD_CLASS_ERP_OFDM)
1653  {
1654  if (found)
1655  {
1656  break;
1657  }
1658  }
1659  index++;
1660  j++;
1661  }
1662  return m_bssBasicRateSet[index];
1663 }
1664 
1665 void
1667 {
1668  NS_LOG_FUNCTION (this << (uint32_t)mcs.GetMcsValue ());
1669  for (uint32_t i = 0; i < GetNBasicMcs (); i++)
1670  {
1671  if (GetBasicMcs (i) == mcs)
1672  {
1673  return;
1674  }
1675  }
1676  m_bssBasicMcsSet.push_back (mcs);
1677 }
1678 
1679 uint32_t
1681 {
1682  return m_bssBasicMcsSet.size ();
1683 }
1684 
1685 WifiMode
1687 {
1688  NS_ASSERT (i < GetNBasicMcs ());
1689  return m_bssBasicMcsSet[i];
1690 }
1691 
1692 WifiMode
1694 {
1695  if (m_nonUnicastMode == WifiMode ())
1696  {
1697  return GetBasicMode (0);
1698  }
1699  else
1700  {
1701  return m_nonUnicastMode;
1702  }
1703 }
1704 
1705 bool
1707  Ptr<const Packet> packet, bool normally)
1708 {
1709  return normally;
1710 }
1711 
1712 bool
1714  Ptr<const Packet> packet, bool normally)
1715 {
1716  return normally;
1717 }
1718 
1719 bool
1721  Ptr<const Packet> packet, bool normally)
1722 {
1723  return normally;
1724 }
1725 
1726 bool
1728  Ptr<const Packet> packet, bool normally)
1729 {
1730  return normally;
1731 }
1732 
1733 void
1734 WifiRemoteStationManager::DoReportAmpduTxStatus (WifiRemoteStation *station, uint32_t nSuccessfulMpdus, uint32_t nFailedMpdus, double rxSnr, double dataSnr)
1735 {
1736  NS_LOG_DEBUG ("DoReportAmpduTxStatus received but the manager does not handle A-MPDUs!");
1737 }
1738 
1739 WifiMode
1741 {
1742  NS_ASSERT (i < GetNSupported (station));
1743  return station->m_state->m_operationalRateSet[i];
1744 }
1745 
1746 WifiMode
1748 {
1749  NS_ASSERT (i < GetNMcsSupported (station));
1750  return station->m_state->m_operationalMcsSet[i];
1751 }
1752 
1753 WifiMode
1755 {
1756  NS_ASSERT (i < GetNNonErpSupported (station));
1757  //IEEE 802.11g standard defines that if the protection mechanism is enabled, Rts, Cts and Cts-To-Self
1758  //frames should select a rate in the BSSBasicRateSet that corresponds to an 802.11b basic rate.
1759  //This is a implemented here to avoid changes in every RAA, but should maybe be moved in case it breaks standard rules.
1760  uint32_t index = 0;
1761  bool found = false;
1762  for (WifiModeListIterator j = station->m_state->m_operationalRateSet.begin (); j != station->m_state->m_operationalRateSet.end (); )
1763  {
1764  if (i == index)
1765  {
1766  found = true;
1767  }
1768  if (j->GetModulationClass () != WIFI_MOD_CLASS_ERP_OFDM)
1769  {
1770  if (found)
1771  {
1772  break;
1773  }
1774  }
1775  index++;
1776  j++;
1777  }
1778  return station->m_state->m_operationalRateSet[index];
1779 }
1780 
1781 uint32_t
1783 {
1784  return station->m_state->m_channelWidth;
1785 }
1786 
1787 bool
1789 {
1790  return station->m_state->m_shortGuardInterval;
1791 }
1792 
1793 bool
1795 {
1796  return station->m_state->m_greenfield;
1797 }
1798 
1799 bool
1801 {
1802  return station->m_state->m_aggregation;
1803 }
1804 
1805 bool
1807 {
1808  return station->m_state->m_stbc;
1809 }
1810 
1811 uint8_t
1813 {
1814  return station->m_state->m_rx;
1815 }
1816 
1817 uint32_t
1819 {
1820  return station->m_state->m_ness;
1821 }
1822 
1823 uint32_t
1825 {
1826  return station->m_ssrc;
1827 }
1828 
1831 {
1832  return m_wifiPhy;
1833 }
1834 
1837 {
1838  return m_wifiMac;
1839 }
1840 
1841 uint32_t
1843 {
1844  return station->m_slrc;
1845 }
1846 
1847 uint32_t
1849 {
1850  return station->m_state->m_operationalRateSet.size ();
1851 }
1852 
1853 bool
1855 {
1856  return station->m_state->m_htSupported;
1857 }
1858 
1859 bool
1861 {
1862  return station->m_state->m_vhtSupported;
1863 }
1864 
1865 uint32_t
1867 {
1868  return station->m_state->m_operationalMcsSet.size ();
1869 }
1870 
1871 uint32_t
1873 {
1874  uint32_t size = 0;
1875  for (WifiModeListIterator i = station->m_state->m_operationalRateSet.begin (); i != station->m_state->m_operationalRateSet.end (); i++)
1876  {
1877  if (i->GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1878  {
1879  continue;
1880  }
1881  size++;
1882  }
1883  return size;
1884 }
1885 
1886 void
1888 {
1889  m_defaultTxPowerLevel = txPower;
1890 }
1891 
1892 uint32_t
1894 {
1896 }
1897 
1899  : m_memoryTime (Seconds (1.0)),
1900  m_lastUpdate (Seconds (0.0)),
1901  m_failAvg (0.0)
1902 {
1903 }
1904 
1905 double
1907 {
1908  double retval = std::exp ((double)(m_lastUpdate.GetMicroSeconds () - Simulator::Now ().GetMicroSeconds ())
1909  / (double)m_memoryTime.GetMicroSeconds ());
1911  return retval;
1912 }
1913 
1914 void
1916 {
1917  double coefficient = CalculateAveragingCoefficient ();
1918  m_failAvg = (double)retryCounter / (1 + (double)retryCounter) * (1.0 - coefficient) + coefficient * m_failAvg;
1919 }
1920 
1921 void
1923 {
1924  double coefficient = CalculateAveragingCoefficient ();
1925  m_failAvg = (1.0 - coefficient) + coefficient * m_failAvg;
1926 }
1927 
1928 double
1930 {
1931  return m_failAvg;
1932 }
1933 
1935 {
1936  NS_LOG_FUNCTION (this);
1937 }
1938 
1939 } //namespace ns3
virtual uint8_t DoGetAckTxNss(Mac48Address address, WifiMode ackMode)
uint32_t GetNSupported(const WifiRemoteStation *station) const
Return the number of modes supported by the given station.
uint32_t m_ssrc
STA short retry count.
bool m_shortPreamble
Flag if short PLCP preamble is supported by the remote station.
void Write(const uint8_t *buffer, uint32_t size)
Definition: tag-buffer.cc:125
bool m_vhtSupported
Flag if VHT capability is supported.
virtual uint8_t DoGetAckTxNess(Mac48Address address, WifiMode ackMode)
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.
void SetShortGuardInterval(bool guardinterval)
Sets if short gurad interval is being used.
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:58
AttributeValue implementation for Boolean.
Definition: boolean.h:34
bool m_shortGuardInterval
Flag if short guard interval is supported by the remote station.
virtual bool GetGuardInterval(void) const
Return whether guard interval is being used.
Definition: wifi-phy.cc:579
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
bool NeedDataRetransmission(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
uint8_t GetSupportedChannelWidthSet() const
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...
virtual bool GetGreenfield(void) const
Return whether Greenfield is supported.
Definition: wifi-phy.cc:566
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)
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:81
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:824
uint32_t GetMaxSsrc(void) const
Return the maximum STA short retry count (SSRC).
enum WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:379
virtual bool DoGetAckTxGuardInterval(Mac48Address address, WifiMode ackMode)
WifiTxVector GetCtsTxVector(Mac48Address address, WifiMode rtsMode)
virtual uint8_t DoGetBlockAckTxNess(Mac48Address address, WifiMode blockAckMode)
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
WifiMode GetNonUnicastMode(void) const
Return a mode for non-unicast packets.
static const uint16_t WIFI_MAC_FCS_LENGTH
The length in octects of the IEEE 802.11 MAC FCS field.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
uint32_t m_fragmentationThreshold
Current threshold for fragmentation.
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:792
bool GetGreenfield(const WifiRemoteStation *station) const
Return whether the station supports Greenfield or not.
Mac48Address m_address
Mac48Address of the remote station.
void ReportAmpduTxStatus(Mac48Address address, uint8_t tid, uint32_t nSuccessfulMpdus, uint32_t nFailedMpdus, double rxSnr, double dataSnr)
Typically called per A-MPDU, either when a Block ACK was successfully received or when a BlockAckTime...
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
uint8_t GetSupportedChannelWidth(void) const
bool NeedRts(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, WifiTxVector txVector)
void UpdateFragmentationThreshold(void)
Typically called to update the fragmentation threshold at the start of a new transmission.
Time m_memoryTime
averaging coefficient depends on the memory time
virtual 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:2862
bool IsLastFragment(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fragmentNumber)
WifiMode GetMcsSupported(const WifiRemoteStation *station, uint32_t i) const
Return the WifiMode supported by the specified station at the specified index.
VHT PHY (Clause 22)
Definition: wifi-mode.h:64
bool IsAllowedControlAnswerModulationClass(enum WifiModulationClass modClassReq, enum WifiModulationClass modClassAnswer) const
Return whether the modulation class of the selected mode for the control answer frame is allowed...
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:52
bool IsBrandNew(Mac48Address address) const
Return whether the station state is brand new.
virtual void Serialize(TagBuffer i) const
virtual void SetupPhy(Ptr< WifiPhy > phy)
Set up PHY associated with this device since it is the object that knows the full set of transmit rat...
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:99
bool m_shortPreambleEnabled
flag if short PLCP preamble is enabled
bool IsMandatory(void) const
Definition: wifi-mode.cc:350
bool GetAggregation(const WifiRemoteStation *station) const
Return whether the given station supports A-MPDU.
virtual bool GetStbc(void) const
Return whether STBC is supported.
Definition: wifi-phy.cc:553
virtual bool DoNeedRts(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
Tid independent remote station statistics.
WifiMode GetSupported(const WifiRemoteStation *station, uint32_t i) const
Return whether mode associated with the specified station at the specified index. ...
WifiRemoteStationState * LookupState(Mac48Address address) const
Return the state of the station associated with the given address.
WifiRemoteStationState * m_state
Remote station state.
void SetChannelWidth(uint32_t channelWidth)
Sets the selected channelWidth (in MHz)
double m_failAvg
moving percentage of failed frames
WifiTxVector GetCtsToSelfTxVector(const WifiMacHeader *header, Ptr< const Packet > packet)
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
void RecordDisassociated(Mac48Address address)
Records that the STA was disassociated.
TracedCallback< Mac48Address > m_macTxFinalDataFailed
The trace source fired when the transmission of a data packet has exceeded the maximum number of atte...
void SetShortSlotTimeEnabled(bool enable)
Enable or disable short slot time.
Ptr< WifiPhy > GetPhy(void) const
Return the WifiPhy.
bool GetStbc(const WifiRemoteStation *station) const
Return whether the given station supports space-time block coding (STBC).
uint8_t GetQosTid(void) const
Return the Traffic ID of a QoS header.
virtual bool DoNeedDataRetransmission(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
virtual void SetVhtSupported(bool enable)
Enable or disable VHT capability support.
virtual bool DoGetAckTxStbc(Mac48Address address, WifiMode ackMode)
Time m_lastUpdate
when last update has occured
void ReportFinalDataFailed(Mac48Address address, const WifiMacHeader *header)
Should be invoked after calling ReportDataFailed if NeedDataRetransmission returns false...
uint8_t m_rx
Number of supported RX streams by the remote station.
void SetRtsCtsThreshold(uint32_t threshold)
Sets the RTS threshold.
tuple phy
Definition: third.py:86
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:349
double CalculateAveragingCoefficient()
Calculate averaging coefficient for frame error rate.
virtual bool DoGetCtsTxGuardInterval(Mac48Address address, WifiMode ctsMode)
uint8_t GetGreenfield(void) const
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.
enum ns3::WifiRemoteStationState::@87 m_state
State of the station.
The IEEE 802.11ac VHT Capabilities.
virtual bool DoNeedRtsRetransmission(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
bool IsHigherDataRate(WifiMode mode) const
Definition: wifi-mode.cc:465
bool m_useNonErpProtection
flag if protection for non-ERP stations against ERP transmissions is enabled
Hold an unsigned integer type.
Definition: uinteger.h:44
WifiMode GetNonErpSupported(const WifiRemoteStation *station, uint32_t i) const
Return whether non-ERP mode associated with the specified station at the specified index...
virtual void DoReportDataFailed(WifiRemoteStation *station)=0
This method is a pure virtual method that must be implemented by the sub-class.
uint8_t data[writeSize]
bool m_stbc
Flag if STBC is supported by the remote station.
void RecordGotAssocTxFailed(Mac48Address address)
Records that we missed an ACK for the association response we sent.
WifiMode GetBasicMode(uint32_t i) const
Return a basic mode from the set of basic modes.
uint32_t GetFragmentationThreshold(void) const
Return the fragmentation threshold.
void AddStationHtCapabilities(Mac48Address from, HtCapabilities htcapabilities)
Records HT capabilities of the remote station.
WifiRemoteStationInfo GetInfo(Mac48Address address)
void SetMaxSsrc(uint32_t maxSsrc)
Sets the maximum STA short retry count (SSRC).
uint32_t GetRtsCtsThreshold(void) const
Return the RTS threshold.
HT PHY (Clause 20)
Definition: wifi-mode.h:62
uint32_t m_maxSlrc
Maximum STA long retry count (SLRC)
uint8_t GetMcsValue(void) const
Definition: wifi-mode.cc:357
uint8_t GetShortGuardInterval20(void) const
void NotifyTxSuccess(uint32_t retryCounter)
Updates average frame error rate when data or RTS was transmitted successfully.
Ptr< WifiMac > m_wifiMac
This is a pointer to the WifiMac associated with this WifiRemoteStationManager that is set on call to...
uint32_t DoGetFragmentationThreshold(void) const
Return the current fragmentation threshold.
uint32_t m_channelWidth
Channel width (in MHz) supported by the remote station.
virtual uint32_t GetNModes(void) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
Definition: wifi-phy.cc:2850
tuple mac
Definition: third.py:92
hold a list of per-remote-station state.
virtual void Print(std::ostream &os) const
WifiMode GetControlAnswerMode(Mac48Address address, WifiMode reqMode)
uint32_t GetNBasicMcs(void) const
Return the number of basic MCS index.
WifiMode m_defaultTxMode
The default transmission mode.
uint32_t GetNess(const WifiRemoteStation *station) const
void SetNss(uint8_t nss)
Sets the number of Nss refer to IEEE 802.11n Table 20-28 for explanation and range.
WifiMode GetDefaultMcs(void) const
Return the default Modulation and Coding Scheme (MCS) index.
virtual void DoReportAmpduTxStatus(WifiRemoteStation *station, uint32_t nSuccessfulMpdus, uint32_t nFailedMpdus, double rxSnr, double dataSnr)
Typically called per A-MPDU, either when a Block ACK was successfully received or when a BlockAckTime...
virtual uint8_t DoGetCtsTxNss(Mac48Address address, WifiMode ctsMode)
WifiModeList m_bssBasicRateSet
This member is the list of WifiMode objects that comprise the BSSBasicRateSet parameter.
void ReportDataOk(Mac48Address address, const WifiMacHeader *header, double ackSnr, WifiMode ackMode, double dataSnr)
Should be invoked whenever we receive the Ack associated to a data packet we just sent...
virtual void SetHtSupported(bool enable)
Enable or disable HT capability support.
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
virtual 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:2868
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.
virtual uint32_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1157
Every class exported by the ns3 library is enclosed in the ns3 namespace.
WifiTxVector DoGetCtsToSelfTxVector(void)
Since CTS-to-self parameters are not dependent on the station, it is implemented in wifiremote statio...
uint32_t GetNNonErpSupported(const WifiRemoteStation *station) const
Return the number of non-ERP modes supported by the given station.
void AddSupportedMode(Mac48Address address, WifiMode mode)
Invoked in a STA or AP to store the set of modes supported by a destination which is also supported l...
bool IsGroup(void) const
WifiModeList m_operationalRateSet
This member is the list of WifiMode objects that comprise the OperationalRateSet parameter for this r...
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
uint32_t GetFragmentSize(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fragmentNumber)
void DoSetFragmentationThreshold(uint32_t threshold)
Actually sets the fragmentation threshold, it also checks the validity of the given threshold...
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:238
virtual uint32_t GetSerializedSize(void) const
bool m_aggregation
Flag if MPDU aggregation is used by the remote station.
an EUI-48 address
Definition: mac48-address.h:43
WifiMode GetBasicMcs(uint32_t i) const
Return the MCS at the given list index.
TracedCallback< Mac48Address > m_macTxRtsFailed
The trace source fired when the transmission of a single RTS has failed.
bool HasVhtSupported(void) const
Return whether the device has VHT capability support enabled.
bool IsAssociated(Mac48Address address) const
Return whether the station associated.
virtual bool IsLowLatency(void) const =0
void SetTxPowerLevel(uint8_t powerlevel)
Sets the selected transmission power level.
Ptr< const AttributeAccessor > MakeWifiModeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: wifi-mode.h:226
ProtectionMode m_protectionMode
Protection mode for ERP stations when non-ERP stations are detected.
bool GetShortGuardInterval(const WifiRemoteStation *station) const
Return whether the given station supports short guard interval.
Stations m_stations
Information for each known stations.
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:224
void ReportRtsOk(Mac48Address address, const WifiMacHeader *header, double ctsSnr, WifiMode ctsMode, double rtsSnr)
Should be invoked whenever we receive the Cts associated to an RTS we just sent.
TracedCallback< Mac48Address > m_macTxDataFailed
The trace source fired when the transmission of a single data packet has failed.
virtual void SetupMac(Ptr< WifiMac > mac)
Set up MAC associated with this device since it is the object that knows the full set of timing param...
WifiMode GetNonErpBasicMode(uint32_t i) const
Return a basic mode from the set of basic modes that is not an ERP mode.
double GetFrameErrorRate() const
Return frame error rate (probability that frame is corrupted due to transmission error).
virtual uint32_t DoGetBlockAckTxChannelWidth(Mac48Address address, WifiMode ctsMode)
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
virtual void Serialize(TagBuffer i) const
uint8_t GetNumberOfSupportedRxAntennas(const WifiRemoteStation *station) const
Return the number of receive antennas the station has.
void AddBasicMcs(WifiMode mcs)
Add a given Modulation and Coding Scheme (MCS) index to the set of basic MCS.
void AddSupportedPlcpPreamble(Mac48Address address, bool isShortPreambleSupported)
Record whether the short PLCP preamble is supported by the station.
bool HasHtSupported(void) const
Return whether the device has HT capability support enabled.
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
virtual bool DoNeedFragmentation(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
void NotifyTxFailed()
Updates average frame error rate when final data or RTS has failed.
bool NeedCtsToSelf(WifiTxVector txVector)
Return if we need to do Cts-to-self before sending a DATA.
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 uint32_t DoGetCtsTxChannelWidth(Mac48Address address, WifiMode ctsMode)
void SetMaxSlrc(uint32_t maxSlrc)
Sets the maximum STA long retry count (SLRC).
bool m_htSupported
Flag if HT is supported by the station.
uint32_t GetNBasicModes(void) const
Return the number of basic modes we support.
read and write tag data
Definition: tag-buffer.h:51
WifiTxVector GetDataTxVector(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
bool GetShortSlotTimeSupported(Mac48Address address) const
Return whether the station supports short ERP slot time or not.
bool GetShortPreambleEnabled(void) const
Return whether the device uses short PLCP preambles.
The attribute can be read.
Definition: type-id.h:63
WifiModulationClass
This enumeration defines the modulation classes per (Table 9-4 "Modulation classes"; IEEE 802...
Definition: wifi-mode.h:40
A struct that holds information about each remote station.
uint32_t GetLongRetryCount(const WifiRemoteStation *station) const
Return the long retry limit of the given station.
bool IsQosData(void) const
Return true if the Type is DATA and Subtype is one of the possible values for QoS DATA...
virtual bool DoGetCtsTxStbc(Mac48Address address, WifiMode ctsMode)
uint32_t GetNMcsSupported(const WifiRemoteStation *station) const
Return the number of MCS supported by the given station.
void AddSupportedErpSlotTime(Mac48Address address, bool isShortSlotTimeSupported)
Record whether the short ERP slot time is supported by the station.
WifiMode GetDefaultMode(void) const
Return the default transmission mode.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:228
void SetFragmentationThreshold(uint32_t threshold)
Sets a fragmentation threshold.
bool GetVhtSupported(const WifiRemoteStation *station) const
Return whether the given station is VHT capable.
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)
virtual bool DoGetBlockAckTxGuardInterval(Mac48Address address, WifiMode blockAckMode)
virtual void Serialize(TagBuffer i) const
virtual uint32_t GetNumberOfTransmitAntennas(void) const
Definition: wifi-phy.cc:1176
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:236
bool IsHigherCodeRate(WifiMode mode) const
Definition: wifi-mode.cc:445
virtual void DoDispose(void)
Destructor implementation.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:895
OFDM PHY (Clause 17)
Definition: wifi-mode.h:60
void ReportRxOk(Mac48Address address, const WifiMacHeader *header, double rxSnr, WifiMode txMode)
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.
uint32_t GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the station.
void Read(uint8_t *buffer, uint32_t size)
Definition: tag-buffer.cc:176
virtual bool DoGetBlockAckTxStbc(Mac48Address address, WifiMode blockAckMode)
bool NeedRtsRetransmission(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
uint32_t GetShortRetryCount(const WifiRemoteStation *station) const
Return the short retry limit of the given station.
Ptr< const AttributeChecker > MakeWifiModeChecker(void)
Definition: wifi-mode.cc:536
uint8_t GetRxHighestSupportedAntennas(void) const
bool m_shortSlotTime
Flag if short ERP slot time is supported by the remote station.
virtual uint8_t DoGetCtsTxNess(Mac48Address address, WifiMode ctsMode)
WifiTxVector GetRtsTxVector(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
A base class which provides memory management and object aggregation.
Definition: object.h:87
tuple address
Definition: first.py:37
virtual uint32_t GetSerializedSize(void) const
AttributeValue implementation for WifiMode.
Definition: wifi-mode.h:226
StationStates m_states
States of known stations.
void SetShortPreambleEnabled(bool enable)
Enable or disable short PLCP preambles.
WifiMode GetMode(void) const
WifiTxVector GetBlockAckTxVector(Mac48Address address, WifiMode dataMode)
virtual uint8_t DoGetCtsTxPowerLevel(Mac48Address address, WifiMode ctsMode)
virtual void Print(std::ostream &os) const
uint32_t GetMaxSlrc(void) const
Return the maximum STA long retry count (SLRC).
uint32_t m_slrc
STA long retry count.
void AddAllSupportedModes(Mac48Address address)
Invoked in a STA or AP to store all of the modes supported by a destination which is also supported l...
virtual uint32_t DoGetAckTxChannelWidth(Mac48Address address, WifiMode ctsMode)
virtual WifiTxVector DoGetDataTxVector(WifiRemoteStation *station)=0
void SetProtectionMode(ProtectionMode mode)
Sets the protection mode.
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
void ReportFinalRtsFailed(Mac48Address address, const WifiMacHeader *header)
Should be invoked after calling ReportRtsFailed if NeedRtsRetransmission returns false.
WifiTxVector GetAckTxVector(Mac48Address address, WifiMode dataMode)
bool m_greenfield
Flag if greenfield is supported by the remote station.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:904
uint32_t m_ness
Number of streams in beamforming of the remote station.
ProtectionMode GetProtectionMode(void) const
Return the protection mode.
virtual void DoReportFinalRtsFailed(WifiRemoteStation *station)=0
This method is a pure virtual method that must be implemented by the sub-class.
hold per-remote-station state.
virtual WifiRemoteStation * DoCreateStation(void) const =0
void RecordGotAssocTxOk(Mac48Address address)
Records that we got an ACK for the association response we sent.
void AddStationVhtCapabilities(Mac48Address from, VhtCapabilities vhtcapabilities)
Records VHT capabilities of the remote station.
Implements the IEEE 802.11 MAC header.
bool GetHtSupported(const WifiRemoteStation *station) const
Return whether the given station is HT capable.
DSSS PHY (Clause 15)
Definition: wifi-mode.h:50
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.
virtual WifiMode GetMode(uint32_t mode) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
Definition: wifi-phy.cc:2856
bool GetShortPreambleSupported(Mac48Address address) const
Return whether the station supports short PLCP preamble or not.