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_ASSERT (!address.IsGroup ());
573  WifiRemoteStationState *state = LookupState (address);
574  state->m_operationalRateSet.clear ();
575  for (uint32_t i = 0; i < m_wifiPhy->GetNModes (); i++)
576  {
577  state->m_operationalRateSet.push_back (m_wifiPhy->GetMode (i));
578  }
579 }
580 
581 void
583 {
584  NS_ASSERT (!address.IsGroup ());
585  WifiRemoteStationState *state = LookupState (address);
586  state->m_operationalMcsSet.clear ();
587  for (uint32_t i = 0; i < m_wifiPhy->GetNMcs (); i++)
588  {
589  state->m_operationalMcsSet.push_back (m_wifiPhy->GetMcs (i));
590  }
591 }
592 
593 void
595 {
596  NS_LOG_FUNCTION (this << address << mcs);
597  NS_ASSERT (!address.IsGroup ());
598  WifiRemoteStationState *state = LookupState (address);
599  for (WifiModeListIterator i = state->m_operationalMcsSet.begin (); i != state->m_operationalMcsSet.end (); i++)
600  {
601  if ((*i) == mcs)
602  {
603  //already in.
604  return;
605  }
606  }
607  state->m_operationalMcsSet.push_back (mcs);
608 }
609 
610 bool
612 {
613  return LookupState (address)->m_shortPreamble;
614 }
615 
616 bool
618 {
619  return LookupState (address)->m_shortSlotTime;
620 }
621 
622 bool
624 {
625  if (address.IsGroup ())
626  {
627  return false;
628  }
630 }
631 
632 bool
634 {
635  if (address.IsGroup ())
636  {
637  return true;
638  }
640 }
641 
642 bool
644 {
645  if (address.IsGroup ())
646  {
647  return false;
648  }
650 }
651 
652 void
654 {
655  NS_ASSERT (!address.IsGroup ());
657 }
658 
659 void
661 {
662  NS_ASSERT (!address.IsGroup ());
664 }
665 
666 void
668 {
669  NS_ASSERT (!address.IsGroup ());
671 }
672 
673 void
675 {
676  NS_ASSERT (!address.IsGroup ());
678 }
679 
680 void
682 {
683  NS_LOG_FUNCTION (this << address << *header << packet);
684  if (IsLowLatency () || address.IsGroup ())
685  {
686  return;
687  }
688  WifiRemoteStation *station = Lookup (address, header);
689  WifiTxVector rts = DoGetRtsTxVector (station);
690  WifiTxVector data = DoGetDataTxVector (station);
691  WifiTxVector ctstoself = DoGetCtsToSelfTxVector ();
694  HighLatencyCtsToSelfTxVectorTag ctstoselftag;
695  //first, make sure that the tag is not here anymore.
696  ConstCast<Packet> (packet)->RemovePacketTag (datatag);
697  ConstCast<Packet> (packet)->RemovePacketTag (rtstag);
698  ConstCast<Packet> (packet)->RemovePacketTag (ctstoselftag);
699  datatag = HighLatencyDataTxVectorTag (data);
700  rtstag = HighLatencyRtsTxVectorTag (rts);
701  ctstoselftag = HighLatencyCtsToSelfTxVectorTag (ctstoself);
702  //and then, add it back
703  packet->AddPacketTag (datatag);
704  packet->AddPacketTag (rtstag);
705  packet->AddPacketTag (ctstoselftag);
706 }
707 
710 {
711  NS_LOG_FUNCTION (this << address << *header << packet);
712  if (address.IsGroup ())
713  {
714  WifiTxVector v;
715  v.SetMode (GetNonUnicastMode ());
719  v.SetNss (1);
720  v.SetNess (0);
721  v.SetStbc (false);
722  return v;
723  }
724  if (!IsLowLatency ())
725  {
727  bool found;
728  found = ConstCast<Packet> (packet)->PeekPacketTag (datatag);
729  NS_ASSERT (found);
730  //cast found to void, to suppress 'found' set but not used
731  //compiler warning
732  (void) found;
733  return datatag.GetDataTxVector ();
734  }
735  return DoGetDataTxVector (Lookup (address, header));
736 }
737 
740  Ptr<const Packet> packet)
741 {
742  NS_LOG_FUNCTION (this << *header << packet);
743  if (!IsLowLatency ())
744  {
745  HighLatencyCtsToSelfTxVectorTag ctstoselftag;
746  bool found;
747  found = ConstCast<Packet> (packet)->PeekPacketTag (ctstoselftag);
748  NS_ASSERT (found);
749  //cast found to void, to suppress 'found' set but not used
750  //compiler warning
751  (void) found;
752  return ctstoselftag.GetCtsToSelfTxVector ();
753  }
754  return DoGetCtsToSelfTxVector ();
755 }
756 
759 {
760  return WifiTxVector (GetDefaultMode (),
762  0,
767  false,
768  false);
769 }
770 
773  Ptr<const Packet> packet)
774 {
775  NS_LOG_FUNCTION (this << address << *header << packet);
776  NS_ASSERT (!address.IsGroup ());
777  if (!IsLowLatency ())
778  {
780  bool found;
781  found = ConstCast<Packet> (packet)->PeekPacketTag (rtstag);
782  NS_ASSERT (found);
783  //cast found to void, to suppress 'found' set but not used
784  //compiler warning
785  (void) found;
786  return rtstag.GetRtsTxVector ();
787  }
788  return DoGetRtsTxVector (Lookup (address, header));
789 }
790 
791 void
793 {
794  NS_LOG_FUNCTION (this << address << *header);
795  NS_ASSERT (!address.IsGroup ());
796  WifiRemoteStation *station = Lookup (address, header);
797  station->m_ssrc++;
798  m_macTxRtsFailed (address);
799  DoReportRtsFailed (station);
800 }
801 
802 void
804 {
805  NS_LOG_FUNCTION (this << address << *header);
806  NS_ASSERT (!address.IsGroup ());
807  WifiRemoteStation *station = Lookup (address, header);
808  station->m_slrc++;
809  m_macTxDataFailed (address);
810  DoReportDataFailed (station);
811 }
812 
813 void
815  double ctsSnr, WifiMode ctsMode, double rtsSnr)
816 {
817  NS_LOG_FUNCTION (this << address << *header << ctsSnr << ctsMode << rtsSnr);
818  NS_ASSERT (!address.IsGroup ());
819  WifiRemoteStation *station = Lookup (address, header);
820  station->m_state->m_info.NotifyTxSuccess (station->m_ssrc);
821  station->m_ssrc = 0;
822  DoReportRtsOk (station, ctsSnr, ctsMode, rtsSnr);
823 }
824 
825 void
827  double ackSnr, WifiMode ackMode, double dataSnr)
828 {
829  NS_LOG_FUNCTION (this << address << *header << ackSnr << ackMode << dataSnr);
830  NS_ASSERT (!address.IsGroup ());
831  WifiRemoteStation *station = Lookup (address, header);
832  station->m_state->m_info.NotifyTxSuccess (station->m_slrc);
833  station->m_slrc = 0;
834  DoReportDataOk (station, ackSnr, ackMode, dataSnr);
835 }
836 
837 void
839 {
840  NS_LOG_FUNCTION (this << address << *header);
841  NS_ASSERT (!address.IsGroup ());
842  WifiRemoteStation *station = Lookup (address, header);
843  station->m_state->m_info.NotifyTxFailed ();
844  station->m_ssrc = 0;
845  m_macTxFinalRtsFailed (address);
846  DoReportFinalRtsFailed (station);
847 }
848 
849 void
851 {
852  NS_LOG_FUNCTION (this << address << *header);
853  NS_ASSERT (!address.IsGroup ());
854  WifiRemoteStation *station = Lookup (address, header);
855  station->m_state->m_info.NotifyTxFailed ();
856  station->m_slrc = 0;
857  m_macTxFinalDataFailed (address);
858  DoReportFinalDataFailed (station);
859 }
860 
861 void
863  double rxSnr, WifiMode txMode)
864 {
865  NS_LOG_FUNCTION (this << address << *header << rxSnr << txMode);
866  if (address.IsGroup ())
867  {
868  return;
869  }
870  WifiRemoteStation *station = Lookup (address, header);
871  DoReportRxOk (station, rxSnr, txMode);
872 }
873 
874 void
876  uint32_t nSuccessfulMpdus, uint32_t nFailedMpdus, double rxSnr, double dataSnr)
877 {
878  NS_LOG_FUNCTION (this << address << (uint16_t)tid << nSuccessfulMpdus << nFailedMpdus << rxSnr << dataSnr);
879  NS_ASSERT (!address.IsGroup ());
880  WifiRemoteStation *station = Lookup (address, tid);
881  DoReportAmpduTxStatus (station, nSuccessfulMpdus, nFailedMpdus, rxSnr, dataSnr);
882 }
883 
884 bool
886  Ptr<const Packet> packet, WifiTxVector txVector)
887 {
888  WifiMode mode = txVector.GetMode ();
889  NS_LOG_FUNCTION (this << address << *header << packet << mode);
892  || (mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
893  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT))
895  {
896  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedRTS returning true to protect non-ERP stations");
897  return true;
898  }
899  if (address.IsGroup ())
900  {
901  return false;
902  }
903  bool normally = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > GetRtsCtsThreshold ();
904  return DoNeedRts (Lookup (address, header), packet, normally);
905 }
906 
907 bool
909 {
910  WifiMode mode = txVector.GetMode ();
911  NS_LOG_FUNCTION (this << mode);
914  || (mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
915  || (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT))
917  {
918  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true to protect non-ERP stations");
919  return true;
920  }
921  else if (!m_useNonErpProtection)
922  {
923  //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
924  for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
925  {
926  if (mode == *i)
927  {
928  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
929  return false;
930  }
931  }
932  if (HasHtSupported ())
933  {
934  //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
935  for (WifiModeListIterator i = m_bssBasicMcsSet.begin (); i != m_bssBasicMcsSet.end (); i++)
936  {
937  if (mode == *i)
938  {
939  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
940  return false;
941  }
942  }
943  }
944  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true");
945  return true;
946  }
947  return false;
948 }
949 
950 void
952 {
953  m_useNonErpProtection = enable;
954 }
955 
956 bool
958 {
959  return m_useNonErpProtection;
960 }
961 
962 bool
964  Ptr<const Packet> packet)
965 {
966  NS_LOG_FUNCTION (this << address << packet << *header);
967  NS_ASSERT (!address.IsGroup ());
968  WifiRemoteStation *station = Lookup (address, header);
969  bool normally = station->m_ssrc < GetMaxSsrc ();
970  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedDataRetransmission count: " << station->m_ssrc << " result: " << std::boolalpha << normally);
971  return DoNeedRtsRetransmission (station, packet, normally);
972 }
973 
974 bool
976  Ptr<const Packet> packet)
977 {
978  NS_LOG_FUNCTION (this << address << packet << *header);
979  NS_ASSERT (!address.IsGroup ());
980  WifiRemoteStation *station = Lookup (address, header);
981  bool normally = station->m_slrc < GetMaxSlrc ();
982  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedDataRetransmission count: " << station->m_slrc << " result: " << std::boolalpha << normally);
983  return DoNeedDataRetransmission (station, packet, normally);
984 }
985 
986 bool
988  Ptr<const Packet> packet)
989 {
990  NS_LOG_FUNCTION (this << address << packet << *header);
991  if (address.IsGroup ())
992  {
993  return false;
994  }
995  WifiRemoteStation *station = Lookup (address, header);
996  bool normally = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > GetFragmentationThreshold ();
997  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedFragmentation result: " << std::boolalpha << normally);
998  return DoNeedFragmentation (station, packet, normally);
999 }
1000 
1001 void
1003 {
1004  NS_LOG_FUNCTION (this << threshold);
1005  if (threshold < 256)
1006  {
1007  /*
1008  * ASN.1 encoding of the MAC and PHY MIB (256 ... 8000)
1009  */
1010  NS_LOG_WARN ("Fragmentation threshold should be larger than 256. Setting to 256.");
1012  }
1013  else
1014  {
1015  /*
1016  * The length of each fragment shall be an even number of octets, except for the last fragment if an MSDU or
1017  * MMPDU, which may be either an even or an odd number of octets.
1018  */
1019  if (threshold % 2 != 0)
1020  {
1021  NS_LOG_WARN ("Fragmentation threshold should be an even number. Setting to " << threshold - 1);
1022  m_nextFragmentationThreshold = threshold - 1;
1023  }
1024  else
1025  {
1026  m_nextFragmentationThreshold = threshold;
1027  }
1028  }
1029 }
1030 
1031 void
1033 {
1035 }
1036 
1037 uint32_t
1039 {
1040  return m_fragmentationThreshold;
1041 }
1042 
1043 uint32_t
1045 {
1046  NS_LOG_FUNCTION (this << *header << packet);
1047  //The number of bytes a fragment can support is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
1048  uint32_t nFragments = (packet->GetSize () / (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
1049 
1050  //If the size of the last fragment is not 0.
1051  if ((packet->GetSize () % (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH)) > 0)
1052  {
1053  nFragments++;
1054  }
1055  NS_LOG_DEBUG ("WifiRemoteStationManager::GetNFragments returning " << nFragments);
1056  return nFragments;
1057 }
1058 
1059 uint32_t
1061  Ptr<const Packet> packet, uint32_t fragmentNumber)
1062 {
1063  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
1064  NS_ASSERT (!address.IsGroup ());
1065  uint32_t nFragment = GetNFragments (header, packet);
1066  if (fragmentNumber >= nFragment)
1067  {
1068  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning 0");
1069  return 0;
1070  }
1071  //Last fragment
1072  if (fragmentNumber == nFragment - 1)
1073  {
1074  uint32_t lastFragmentSize = packet->GetSize () - (fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
1075  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << lastFragmentSize);
1076  return lastFragmentSize;
1077  }
1078  //All fragments but the last, the number of bytes is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
1079  else
1080  {
1081  uint32_t fragmentSize = GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH;
1082  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << fragmentSize);
1083  return fragmentSize;
1084  }
1085 }
1086 
1087 uint32_t
1089  Ptr<const Packet> packet, uint32_t fragmentNumber)
1090 {
1091  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
1092  NS_ASSERT (!address.IsGroup ());
1093  NS_ASSERT (fragmentNumber < GetNFragments (header, packet));
1094  uint32_t fragmentOffset = fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH);
1095  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentOffset returning " << fragmentOffset);
1096  return fragmentOffset;
1097 }
1098 
1099 bool
1101  Ptr<const Packet> packet, uint32_t fragmentNumber)
1102 {
1103  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
1104  NS_ASSERT (!address.IsGroup ());
1105  bool isLast = fragmentNumber == (GetNFragments (header, packet) - 1);
1106  NS_LOG_DEBUG ("WifiRemoteStationManager::IsLastFragment returning " << std::boolalpha << isLast);
1107  return isLast;
1108 }
1109 
1110 bool
1112 {
1113  switch (modClassReq)
1114  {
1115  case WIFI_MOD_CLASS_DSSS:
1116  return (modClassAnswer == WIFI_MOD_CLASS_DSSS);
1118  return (modClassAnswer == WIFI_MOD_CLASS_DSSS || modClassAnswer == WIFI_MOD_CLASS_HR_DSSS);
1120  return (modClassAnswer == WIFI_MOD_CLASS_DSSS || modClassAnswer == WIFI_MOD_CLASS_HR_DSSS || modClassAnswer == WIFI_MOD_CLASS_ERP_OFDM);
1121  case WIFI_MOD_CLASS_OFDM:
1122  return (modClassAnswer == WIFI_MOD_CLASS_OFDM);
1123  case WIFI_MOD_CLASS_HT:
1124  case WIFI_MOD_CLASS_VHT:
1125  return true;
1126  default:
1127  NS_FATAL_ERROR ("Modulation class not defined");
1128  return false;
1129  }
1130 }
1131 
1132 WifiMode
1134 {
1149  NS_LOG_FUNCTION (this << address << reqMode);
1150  WifiMode mode = GetDefaultMode ();
1151  bool found = false;
1152  //First, search the BSS Basic Rate set
1153  for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
1154  {
1155  if ((!found || i->IsHigherDataRate (mode))
1156  && (!i->IsHigherDataRate (reqMode))
1157  && (IsAllowedControlAnswerModulationClass (reqMode.GetModulationClass (), i->GetModulationClass ())))
1158  {
1159  mode = *i;
1160  //We've found a potentially-suitable transmit rate, but we
1161  //need to continue and consider all the basic rates before
1162  //we can be sure we've got the right one.
1163  found = true;
1164  }
1165  }
1166  if (HasHtSupported () || HasVhtSupported ())
1167  {
1168  if (!found)
1169  {
1170  mode = GetDefaultMcs ();
1171  for (WifiModeListIterator i = m_bssBasicMcsSet.begin (); i != m_bssBasicMcsSet.end (); i++)
1172  {
1173  if ((!found || i->IsHigherDataRate (mode))
1174  && (!i->IsHigherDataRate (reqMode))
1175  && (i->GetModulationClass () == reqMode.GetModulationClass ()))
1176  {
1177  mode = *i;
1178  //We've found a potentially-suitable transmit rate, but we
1179  //need to continue and consider all the basic rates before
1180  //we can be sure we've got the right one.
1181  found = true;
1182  }
1183  }
1184  }
1185  }
1186  //If we found a suitable rate in the BSSBasicRateSet, then we are
1187  //done and can return that mode.
1188  if (found)
1189  {
1190  NS_LOG_DEBUG ("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
1191  return mode;
1192  }
1193 
1211  for (uint32_t idx = 0; idx < m_wifiPhy->GetNModes (); idx++)
1212  {
1213  WifiMode thismode = m_wifiPhy->GetMode (idx);
1214  /* If the rate:
1215  *
1216  * - is a mandatory rate for the PHY, and
1217  * - is equal to or faster than our current best choice, and
1218  * - is less than or equal to the rate of the received frame, and
1219  * - is of the same modulation class as the received frame
1220  *
1221  * ...then it's our best choice so far.
1222  */
1223  if (thismode.IsMandatory ()
1224  && (!found || thismode.IsHigherDataRate (mode))
1225  && (!thismode.IsHigherDataRate (reqMode))
1227  {
1228  mode = thismode;
1229  //As above; we've found a potentially-suitable transmit
1230  //rate, but we need to continue and consider all the
1231  //mandatory rates before we can be sure we've got the right one.
1232  found = true;
1233  }
1234  }
1235  if (HasHtSupported () || HasVhtSupported ())
1236  {
1237  for (uint32_t idx = 0; idx < m_wifiPhy->GetNMcs (); idx++)
1238  {
1239  WifiMode thismode = m_wifiPhy->GetMcs (idx);
1240  if (thismode.IsMandatory ()
1241  && (!found || thismode.IsHigherDataRate (mode))
1242  && (!thismode.IsHigherCodeRate(reqMode))
1243  && (thismode.GetModulationClass () == reqMode.GetModulationClass ()))
1244  {
1245  mode = thismode;
1246  //As above; we've found a potentially-suitable transmit
1247  //rate, but we need to continue and consider all the
1248  //mandatory rates before we can be sure we've got the right one.
1249  found = true;
1250  }
1251 
1252  }
1253  }
1254 
1265  if (!found)
1266  {
1267  NS_FATAL_ERROR ("Can't find response rate for " << reqMode);
1268  }
1269 
1270  NS_LOG_DEBUG ("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
1271  return mode;
1272 }
1273 
1276 {
1277  NS_ASSERT (!address.IsGroup ());
1278  WifiTxVector v;
1279  v.SetMode (GetControlAnswerMode (address, rtsMode));
1280  v.SetTxPowerLevel (DoGetCtsTxPowerLevel (address, v.GetMode ()));
1281  v.SetChannelWidth (DoGetCtsTxChannelWidth (address, v.GetMode ()));
1282  v.SetShortGuardInterval (DoGetCtsTxGuardInterval (address, v.GetMode ()));
1283  v.SetNss (DoGetCtsTxNss (address, v.GetMode ()));
1284  v.SetNess (DoGetCtsTxNess (address, v.GetMode ()));
1285  v.SetStbc (DoGetCtsTxStbc (address, v.GetMode ()));
1286  return v;
1287 }
1288 
1291 {
1292  NS_ASSERT (!address.IsGroup ());
1293  WifiTxVector v;
1294  v.SetMode (GetControlAnswerMode (address, dataMode));
1295  v.SetTxPowerLevel (DoGetAckTxPowerLevel (address, v.GetMode ()));
1296  v.SetChannelWidth (DoGetAckTxChannelWidth (address, v.GetMode ()));
1297  v.SetShortGuardInterval (DoGetAckTxGuardInterval (address, v.GetMode ()));
1298  v.SetNss (DoGetAckTxNss (address, v.GetMode ()));
1299  v.SetNess (DoGetAckTxNess (address, v.GetMode ()));
1300  v.SetStbc (DoGetAckTxStbc (address, v.GetMode ()));
1301  return v;
1302 }
1303 
1306 {
1307  NS_ASSERT (!address.IsGroup ());
1308  WifiTxVector v;
1309  v.SetMode (GetControlAnswerMode (address, blockAckReqMode));
1310  v.SetTxPowerLevel (DoGetBlockAckTxPowerLevel (address, v.GetMode ()));
1311  v.SetChannelWidth (DoGetBlockAckTxChannelWidth (address, v.GetMode ()));
1312  v.SetShortGuardInterval (DoGetBlockAckTxGuardInterval (address, v.GetMode ()));
1313  v.SetNss (DoGetBlockAckTxNss (address, v.GetMode ()));
1314  v.SetNess (DoGetBlockAckTxNess (address, v.GetMode ()));
1315  v.SetStbc (DoGetBlockAckTxStbc (address, v.GetMode ()));
1316  return v;
1317 }
1318 
1319 uint8_t
1321 {
1322  return m_defaultTxPowerLevel;
1323 }
1324 
1325 uint32_t
1327 {
1328  return m_wifiPhy->GetChannelWidth ();
1329 }
1330 
1331 bool
1333 {
1334  return m_wifiPhy->GetGuardInterval ();
1335 }
1336 
1337 uint8_t
1339 {
1340  return 1;
1341 }
1342 
1343 uint8_t
1345 {
1346  return 0;
1347 }
1348 
1349 bool
1351 {
1352  return m_wifiPhy->GetStbc ();
1353 }
1354 
1355 uint8_t
1357 {
1358  return m_defaultTxPowerLevel;
1359 }
1360 
1361 uint32_t
1363 {
1364  return m_wifiPhy->GetChannelWidth ();
1365 }
1366 
1367 bool
1369 {
1370  return m_wifiPhy->GetGuardInterval ();
1371 }
1372 
1373 uint8_t
1375 {
1376  return 1;
1377 }
1378 
1379 uint8_t
1381 {
1382  return 0;
1383 }
1384 
1385 bool
1387 {
1388  return m_wifiPhy->GetStbc ();
1389 }
1390 
1391 uint8_t
1393 {
1394  return m_defaultTxPowerLevel;
1395 }
1396 
1397 uint32_t
1399 {
1400  return m_wifiPhy->GetChannelWidth ();
1401 }
1402 
1403 bool
1405 {
1406  return m_wifiPhy->GetGuardInterval ();
1407 }
1408 
1409 uint8_t
1411 {
1412  return 1;
1413 }
1414 
1415 uint8_t
1417 {
1418  return 0;
1419 }
1420 
1421 bool
1423 {
1424  return m_wifiPhy->GetStbc ();
1425 }
1426 
1427 uint8_t
1429 {
1430  return m_defaultTxPowerLevel;
1431 }
1432 
1435 {
1436  WifiRemoteStationState *state = LookupState (address);
1437  return state->m_info;
1438 }
1439 
1442 {
1443  NS_LOG_FUNCTION (this << address);
1444  for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
1445  {
1446  if ((*i)->m_address == address)
1447  {
1448  NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning existing state");
1449  return (*i);
1450  }
1451  }
1454  state->m_address = address;
1455  state->m_operationalRateSet.push_back (GetDefaultMode ());
1456  state->m_operationalMcsSet.push_back (GetDefaultMcs ());
1459  state->m_greenfield = m_wifiPhy->GetGreenfield ();
1460  state->m_rx = 1;
1461  state->m_ness = 0;
1462  state->m_aggregation = false;
1463  state->m_stbc = false;
1464  state->m_htSupported = false;
1465  state->m_vhtSupported = false;
1466  const_cast<WifiRemoteStationManager *> (this)->m_states.push_back (state);
1467  NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning new state");
1468  return state;
1469 }
1470 
1473 {
1474  uint8_t tid;
1475  if (header->IsQosData ())
1476  {
1477  tid = header->GetQosTid ();
1478  }
1479  else
1480  {
1481  tid = 0;
1482  }
1483  return Lookup (address, tid);
1484 }
1485 
1488 {
1489  NS_LOG_FUNCTION (this << address << (uint16_t)tid);
1490  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1491  {
1492  if ((*i)->m_tid == tid
1493  && (*i)->m_state->m_address == address)
1494  {
1495  return (*i);
1496  }
1497  }
1498  WifiRemoteStationState *state = LookupState (address);
1499 
1500  WifiRemoteStation *station = DoCreateStation ();
1501  station->m_state = state;
1502  station->m_tid = tid;
1503  station->m_ssrc = 0;
1504  station->m_slrc = 0;
1505  const_cast<WifiRemoteStationManager *> (this)->m_stations.push_back (station);
1506  return station;
1507 }
1508 
1509 void
1511 {
1512  //Used by all stations to record HT capabilities of remote stations
1513  NS_LOG_FUNCTION (this << from << htCapabilities);
1514  WifiRemoteStationState *state;
1515  state = LookupState (from);
1516  state->m_shortGuardInterval = htCapabilities.GetShortGuardInterval20 ();
1517  if (htCapabilities.GetSupportedChannelWidth () == 1)
1518  {
1519  state->m_channelWidth = 40;
1520  }
1521  else
1522  {
1523  state->m_channelWidth = 20;
1524  }
1525  state->m_htSupported = true;
1526  state->m_greenfield = htCapabilities.GetGreenfield ();
1527  state->m_rx = htCapabilities.GetRxHighestSupportedAntennas ();
1528 }
1529 
1530 void
1532 {
1533  //Used by all stations to record VHT capabilities of remote stations
1534  NS_LOG_FUNCTION (this << from << vhtCapabilities);
1535  WifiRemoteStationState *state;
1536  state = LookupState (from);
1537  if (vhtCapabilities.GetSupportedChannelWidthSet () == 1)
1538  {
1539  state->m_channelWidth = 160;
1540  }
1541  else
1542  {
1543  state->m_channelWidth = 80;
1544  }
1545  //This is a workaround to enable users to force a 20 or 40 MHz channel for a VHT-compliant device,
1546  //since IEEE 802.11ac standard says that 20, 40 and 80 MHz channels are mandatory.
1547  if (m_wifiPhy->GetChannelWidth () < state->m_channelWidth)
1548  {
1550  }
1551  state->m_vhtSupported = true;
1552 }
1553 
1554 bool
1556 {
1557  return LookupState (address)->m_greenfield;
1558 }
1559 
1560 WifiMode
1562 {
1563  return m_defaultTxMode;
1564 }
1565 
1566 WifiMode
1568 {
1569  return m_defaultTxMcs;
1570 }
1571 
1572 void
1574 {
1575  NS_LOG_FUNCTION (this);
1576  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1577  {
1578  delete (*i);
1579  }
1580  m_stations.clear ();
1581  m_bssBasicRateSet.clear ();
1582  m_bssBasicRateSet.push_back (m_defaultTxMode);
1583  m_bssBasicMcsSet.clear ();
1584  m_bssBasicMcsSet.push_back (m_defaultTxMcs);
1586 }
1587 
1588 void
1590 {
1591  NS_LOG_FUNCTION (this << mode);
1593  {
1594  NS_FATAL_ERROR ("It is not allowed to add a (V)HT rate in the BSSBasicRateSet!");
1595  }
1596  for (uint32_t i = 0; i < GetNBasicModes (); i++)
1597  {
1598  if (GetBasicMode (i) == mode)
1599  {
1600  return;
1601  }
1602  }
1603  m_bssBasicRateSet.push_back (mode);
1604 }
1605 
1606 uint32_t
1608 {
1609  return m_bssBasicRateSet.size ();
1610 }
1611 
1612 WifiMode
1614 {
1615  NS_ASSERT (i < GetNBasicModes ());
1616  return m_bssBasicRateSet[i];
1617 }
1618 
1619 uint32_t
1621 {
1622  uint32_t size = 0;
1623  for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
1624  {
1625  if (i->GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1626  {
1627  continue;
1628  }
1629  size++;
1630  }
1631  return size;
1632 }
1633 
1634 WifiMode
1636 {
1638  uint32_t index = 0;
1639  bool found = false;
1640  for (WifiModeListIterator j = m_bssBasicRateSet.begin (); j != m_bssBasicRateSet.end (); )
1641  {
1642  if (i == index)
1643  {
1644  found = true;
1645  }
1646  if (j->GetModulationClass () != WIFI_MOD_CLASS_ERP_OFDM)
1647  {
1648  if (found)
1649  {
1650  break;
1651  }
1652  }
1653  index++;
1654  j++;
1655  }
1656  return m_bssBasicRateSet[index];
1657 }
1658 
1659 void
1661 {
1662  NS_LOG_FUNCTION (this << (uint32_t)mcs.GetMcsValue ());
1663  for (uint32_t i = 0; i < GetNBasicMcs (); i++)
1664  {
1665  if (GetBasicMcs (i) == mcs)
1666  {
1667  return;
1668  }
1669  }
1670  m_bssBasicMcsSet.push_back (mcs);
1671 }
1672 
1673 uint32_t
1675 {
1676  return m_bssBasicMcsSet.size ();
1677 }
1678 
1679 WifiMode
1681 {
1682  NS_ASSERT (i < GetNBasicMcs ());
1683  return m_bssBasicMcsSet[i];
1684 }
1685 
1686 WifiMode
1688 {
1689  if (m_nonUnicastMode == WifiMode ())
1690  {
1691  return GetBasicMode (0);
1692  }
1693  else
1694  {
1695  return m_nonUnicastMode;
1696  }
1697 }
1698 
1699 bool
1701  Ptr<const Packet> packet, bool normally)
1702 {
1703  return normally;
1704 }
1705 
1706 bool
1708  Ptr<const Packet> packet, bool normally)
1709 {
1710  return normally;
1711 }
1712 
1713 bool
1715  Ptr<const Packet> packet, bool normally)
1716 {
1717  return normally;
1718 }
1719 
1720 bool
1722  Ptr<const Packet> packet, bool normally)
1723 {
1724  return normally;
1725 }
1726 
1727 void
1728 WifiRemoteStationManager::DoReportAmpduTxStatus (WifiRemoteStation *station, uint32_t nSuccessfulMpdus, uint32_t nFailedMpdus, double rxSnr, double dataSnr)
1729 {
1730  NS_LOG_DEBUG ("DoReportAmpduTxStatus received but the manager does not handle A-MPDUs!");
1731 }
1732 
1733 WifiMode
1735 {
1736  NS_ASSERT (i < GetNSupported (station));
1737  return station->m_state->m_operationalRateSet[i];
1738 }
1739 
1740 WifiMode
1742 {
1743  NS_ASSERT (i < GetNMcsSupported (station));
1744  return station->m_state->m_operationalMcsSet[i];
1745 }
1746 
1747 WifiMode
1749 {
1750  NS_ASSERT (i < GetNNonErpSupported (station));
1751  //IEEE 802.11g standard defines that if the protection mechanism is enabled, Rts, Cts and Cts-To-Self
1752  //frames should select a rate in the BSSBasicRateSet that corresponds to an 802.11b basic rate.
1753  //This is a implemented here to avoid changes in every RAA, but should maybe be moved in case it breaks standard rules.
1754  uint32_t index = 0;
1755  bool found = false;
1756  for (WifiModeListIterator j = station->m_state->m_operationalRateSet.begin (); j != station->m_state->m_operationalRateSet.end (); )
1757  {
1758  if (i == index)
1759  {
1760  found = true;
1761  }
1762  if (j->GetModulationClass () != WIFI_MOD_CLASS_ERP_OFDM)
1763  {
1764  if (found)
1765  {
1766  break;
1767  }
1768  }
1769  index++;
1770  j++;
1771  }
1772  return station->m_state->m_operationalRateSet[index];
1773 }
1774 
1775 uint32_t
1777 {
1778  return station->m_state->m_channelWidth;
1779 }
1780 
1781 bool
1783 {
1784  return station->m_state->m_shortGuardInterval;
1785 }
1786 
1787 bool
1789 {
1790  return station->m_state->m_greenfield;
1791 }
1792 
1793 bool
1795 {
1796  return station->m_state->m_aggregation;
1797 }
1798 
1799 bool
1801 {
1802  return station->m_state->m_stbc;
1803 }
1804 
1805 uint8_t
1807 {
1808  return station->m_state->m_rx;
1809 }
1810 
1811 uint32_t
1813 {
1814  return station->m_state->m_ness;
1815 }
1816 
1817 uint32_t
1819 {
1820  return station->m_ssrc;
1821 }
1822 
1825 {
1826  return m_wifiPhy;
1827 }
1828 
1831 {
1832  return m_wifiMac;
1833 }
1834 
1835 uint32_t
1837 {
1838  return station->m_slrc;
1839 }
1840 
1841 uint32_t
1843 {
1844  return station->m_state->m_operationalRateSet.size ();
1845 }
1846 
1847 bool
1849 {
1850  return station->m_state->m_htSupported;
1851 }
1852 
1853 bool
1855 {
1856  return station->m_state->m_vhtSupported;
1857 }
1858 
1859 uint32_t
1861 {
1862  return station->m_state->m_operationalMcsSet.size ();
1863 }
1864 
1865 uint32_t
1867 {
1868  uint32_t size = 0;
1869  for (WifiModeListIterator i = station->m_state->m_operationalRateSet.begin (); i != station->m_state->m_operationalRateSet.end (); i++)
1870  {
1871  if (i->GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1872  {
1873  continue;
1874  }
1875  size++;
1876  }
1877  return size;
1878 }
1879 
1880 void
1882 {
1883  m_defaultTxPowerLevel = txPower;
1884 }
1885 
1886 uint32_t
1888 {
1890 }
1891 
1893  : m_memoryTime (Seconds (1.0)),
1894  m_lastUpdate (Seconds (0.0)),
1895  m_failAvg (0.0)
1896 {
1897 }
1898 
1899 double
1901 {
1902  double retval = std::exp ((double)(m_lastUpdate.GetMicroSeconds () - Simulator::Now ().GetMicroSeconds ())
1903  / (double)m_memoryTime.GetMicroSeconds ());
1905  return retval;
1906 }
1907 
1908 void
1910 {
1911  double coefficient = CalculateAveragingCoefficient ();
1912  m_failAvg = (double)retryCounter / (1 + (double)retryCounter) * (1.0 - coefficient) + coefficient * m_failAvg;
1913 }
1914 
1915 void
1917 {
1918  double coefficient = CalculateAveragingCoefficient ();
1919  m_failAvg = (1.0 - coefficient) + coefficient * m_failAvg;
1920 }
1921 
1922 double
1924 {
1925  return m_failAvg;
1926 }
1927 
1929 {
1930  NS_LOG_FUNCTION (this);
1931 }
1932 
1933 } //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.
virtual uint32_t GetNumberOfTransmitAntennas(void) const =0
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.
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...
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.
virtual uint32_t GetNModes(void) const =0
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
enum ns3::WifiRemoteStationState::@95 m_state
State of the station.
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:386
virtual uint8_t GetNMcs(void) const =0
The WifiPhy::GetNMcs() method is used (e.g., by a WifiRemoteStationManager) to determine the set of t...
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:786
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:145
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
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:357
bool GetAggregation(const WifiRemoteStation *station) const
Return whether the given station supports A-MPDU.
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.
virtual WifiMode GetMcs(uint8_t mcs) const =0
The WifiPhy::GetMcs() method is used (e.g., by a WifiRemoteStationManager) to determine the set of tr...
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 uint32_t GetChannelWidth(void) const =0
void SetVhtSupported(bool enable)
Enable or disable VHT capability support.
virtual bool DoGetAckTxStbc(Mac48Address address, WifiMode ackMode)
virtual bool GetStbc(void) const =0
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.
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:472
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:364
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.
virtual bool GetGuardInterval(void) const =0
uint32_t m_channelWidth
Channel width (in MHz) supported by the remote station.
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...
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
uint32_t GetFragmentOffset(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fragmentNumber)
bool IsWaitAssocTxOk(Mac48Address address) const
Return whether we are waiting for an ACK for the association response we sent.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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:237
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
virtual WifiMode GetMode(uint32_t mode) const =0
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
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:225
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:223
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
#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:452
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:543
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:225
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:826
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.
virtual bool GetGreenfield(void) const =0
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.
bool GetShortPreambleSupported(Mac48Address address) const
Return whether the station supports short PLCP preamble or not.