This documentation is not the Latest Release.
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/wifi-phy.h"
31 #include "ns3/wifi-mac.h"
32 #include "ns3/trace-source-accessor.h"
33 #include "wifi-mac-header.h"
34 #include "wifi-mac-trailer.h"
35 
36 /***************************************************************
37  * Packet Mode Tagger
38  ***************************************************************/
39 
40 namespace ns3 {
41 
42 NS_LOG_COMPONENT_DEFINE ("WifiRemoteStationManager");
43 
45 {
46 public:
52  WifiTxVector GetDataTxVector (void) const;
53 
54  static TypeId GetTypeId (void);
55  virtual TypeId GetInstanceTypeId (void) const;
56  virtual uint32_t GetSerializedSize (void) const;
57  virtual void Serialize (TagBuffer i) const;
58  virtual void Deserialize (TagBuffer i);
59  virtual void Print (std::ostream &os) const;
60 private:
62 };
63 
65 {
66 }
67 
69  : m_dataTxVector (dataTxVector)
70 {
71 }
72 
75 {
76  return m_dataTxVector;
77 }
78 
79 TypeId
81 {
82  static TypeId tid = TypeId ("ns3::HighLatencyDataTxVectorTag")
83  .SetParent<Tag> ()
84  .SetGroupName ("Wifi")
85  .AddConstructor<HighLatencyDataTxVectorTag> ()
86  ;
87  return tid;
88 }
89 
90 TypeId
92 {
93  return GetTypeId ();
94 }
95 
96 uint32_t
98 {
99  return sizeof (WifiTxVector);
100 }
101 
102 void
104 {
105  i.Write ((uint8_t *)&m_dataTxVector, sizeof (WifiTxVector));
106 }
107 
108 void
110 {
111  i.Read ((uint8_t *)&m_dataTxVector, sizeof (WifiTxVector));
112 }
113 
114 void
115 HighLatencyDataTxVectorTag::Print (std::ostream &os) const
116 {
117  os << "Data=" << m_dataTxVector;
118 }
119 
121 {
122 public:
129  WifiTxVector GetRtsTxVector (void) const;
130 
131  static TypeId GetTypeId (void);
132  virtual TypeId GetInstanceTypeId (void) const;
133  virtual uint32_t GetSerializedSize (void) const;
134  virtual void Serialize (TagBuffer i) const;
135  virtual void Deserialize (TagBuffer i);
136  virtual void Print (std::ostream &os) const;
137 private:
139 };
140 
142 {
143 }
144 
146  : m_rtsTxVector (rtsTxVector)
147 {
148 }
149 
152 {
153  return m_rtsTxVector;
154 }
155 
156 TypeId
158 {
159  static TypeId tid = TypeId ("ns3::HighLatencyRtsTxVectorTag")
160  .SetParent<Tag> ()
161  .SetGroupName ("Wifi")
162  .AddConstructor<HighLatencyRtsTxVectorTag> ()
163  ;
164  return tid;
165 }
166 
167 TypeId
169 {
170  return GetTypeId ();
171 }
172 
173 uint32_t
175 {
176  return sizeof (WifiTxVector);
177 }
178 
179 void
181 {
182  i.Write ((uint8_t *)&m_rtsTxVector, sizeof (WifiTxVector));
183 }
184 
185 void
187 {
188  i.Read ((uint8_t *)&m_rtsTxVector, sizeof (WifiTxVector));
189 }
190 
191 void
192 HighLatencyRtsTxVectorTag::Print (std::ostream &os) const
193 {
194  os << "Rts=" << m_rtsTxVector;
195 }
196 
198 {
199 public:
201  HighLatencyCtsToSelfTxVectorTag (WifiTxVector ctsToSelfTxVector);
205  WifiTxVector GetCtsToSelfTxVector (void) const;
206 
207  static TypeId GetTypeId (void);
208  virtual TypeId GetInstanceTypeId (void) const;
209  virtual uint32_t GetSerializedSize (void) const;
210  virtual void Serialize (TagBuffer i) const;
211  virtual void Deserialize (TagBuffer i);
212  virtual void Print (std::ostream &os) const;
213 private:
215 };
216 
218 {
219 }
220 
222  : m_ctsToSelfTxVector (ctsToSelfTxVector)
223 {
224 }
225 
228 {
229  return m_ctsToSelfTxVector;
230 }
231 
232 TypeId
234 {
235  static TypeId tid = TypeId ("ns3::HighLatencyCtsToSelfTxVectorTag")
236  .SetParent<Tag> ()
237  .SetGroupName ("Wifi")
238  .AddConstructor<HighLatencyCtsToSelfTxVectorTag> ()
239  ;
240  return tid;
241 }
242 
243 TypeId
245 {
246  return GetTypeId ();
247 }
248 
249 uint32_t
251 {
252  return sizeof (WifiTxVector);
253 }
254 
255 void
257 {
258  i.Write ((uint8_t *)&m_ctsToSelfTxVector, sizeof (WifiTxVector));
259 }
260 
261 void
263 {
264  i.Read ((uint8_t *)&m_ctsToSelfTxVector, sizeof (WifiTxVector));
265 }
266 
267 void
269 {
270  os << "Cts To Self=" << m_ctsToSelfTxVector;
271 }
272 
273 } //namespace ns3
274 
275 namespace ns3 {
276 
277 NS_OBJECT_ENSURE_REGISTERED (WifiRemoteStationManager);
278 
279 TypeId
281 {
282  static TypeId tid = TypeId ("ns3::WifiRemoteStationManager")
283  .SetParent<Object> ()
284  .SetGroupName ("Wifi")
285  .AddAttribute ("IsLowLatency", "If true, we attempt to modelize a so-called low-latency device: a device"
286  " where decisions about tx parameters can be made on a per-packet basis and feedback about the"
287  " transmission of each packet is obtained before sending the next. Otherwise, we modelize a "
288  " high-latency device, that is a device where we cannot update our decision about tx parameters"
289  " after every packet transmission.",
291  BooleanValue (true), //this value is ignored because there is no setter
294  .AddAttribute ("MaxSsrc", "The maximum number of retransmission attempts for an RTS. This value"
295  " will not have any effect on some rate control algorithms.",
296  UintegerValue (7),
298  MakeUintegerChecker<uint32_t> ())
299  .AddAttribute ("MaxSlrc", "The maximum number of retransmission attempts for a DATA packet. This value"
300  " will not have any effect on some rate control algorithms.",
301  UintegerValue (7),
303  MakeUintegerChecker<uint32_t> ())
304  .AddAttribute ("RtsCtsThreshold", "If the size of the data packet + LLC header + MAC header + FCS trailer is bigger than "
305  "this value, we use an RTS/CTS handshake before sending the data, as per IEEE Std. 802.11-2012, Section 9.3.5. "
306  "This value will not have any effect on some rate control algorithms.",
307  UintegerValue (2346),
309  MakeUintegerChecker<uint32_t> ())
310  .AddAttribute ("FragmentationThreshold", "If the size of the data packet + LLC header + MAC header + FCS trailer is bigger"
311  "than this value, we fragment it such that the size of the fragments are equal or smaller "
312  "than this value, as per IEEE Std. 802.11-2012, Section 9.5. "
313  "This value will not have any effect on some rate control algorithms.",
314  UintegerValue (2346),
317  MakeUintegerChecker<uint32_t> ())
318  .AddAttribute ("NonUnicastMode", "Wifi mode used for non-unicast transmissions.",
319  WifiModeValue (),
322  .AddAttribute ("DefaultTxPowerLevel", "Default power level to be used for transmissions. "
323  "This is the power level that is used by all those WifiManagers that do not"
324  "implement TX power control.",
325  UintegerValue (0),
327  MakeUintegerChecker<uint8_t> ())
328  .AddTraceSource ("MacTxRtsFailed",
329  "The transmission of a RTS by the MAC layer has failed",
331  "ns3::Mac48Address::TracedCallback")
332  .AddTraceSource ("MacTxDataFailed",
333  "The transmission of a data packet by the MAC layer has failed",
335  "ns3::Mac48Address::TracedCallback")
336  .AddTraceSource ("MacTxFinalRtsFailed",
337  "The transmission of a RTS has exceeded the maximum number of attempts",
339  "ns3::Mac48Address::TracedCallback")
340  .AddTraceSource ("MacTxFinalDataFailed",
341  "The transmission of a data packet has exceeded the maximum number of attempts",
343  "ns3::Mac48Address::TracedCallback")
344  ;
345  return tid;
346 }
347 
349  : m_htSupported (false),
350  m_vhtSupported (false)
351 {
352 }
353 
355 {
356 }
357 
358 void
360 {
361  for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
362  {
363  delete (*i);
364  }
365  m_states.clear ();
366  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
367  {
368  delete (*i);
369  }
370  m_stations.clear ();
371 }
372 
373 void
375 {
376  //We need to track our PHY because it is the object that knows the
377  //full set of transmit rates that are supported. We need to know
378  //this in order to find the relevant mandatory rates when chosing a
379  //transmit rate for automatic control responses like
380  //acknowledgements.
381  m_wifiPhy = phy;
382  m_defaultTxMode = phy->GetMode (0);
383  if (HasHtSupported () || HasVhtSupported ())
384  {
385  m_defaultTxMcs = phy->GetMcs (0);
386  }
387  Reset ();
388 }
389 
390 void
392 {
393  //We need to track our MAC because it is the object that knows the
394  //full set of interframe spaces.
395  m_wifiMac = mac;
396  Reset ();
397 }
398 
399 void
401 {
402  m_htSupported = enable;
403 }
404 
405 void
407 {
408  m_maxSsrc = maxSsrc;
409 }
410 
411 void
413 {
414  m_maxSlrc = maxSlrc;
415 }
416 
417 void
419 {
420  m_rtsCtsThreshold = threshold;
421 }
422 
423 void
425 {
426  DoSetFragmentationThreshold (threshold);
427 }
428 
429 bool
431 {
432  return m_htSupported;
433 }
434 
435 void
437 {
438  m_vhtSupported = enable;
439 }
440 
441 bool
443 {
444  return m_vhtSupported;
445 }
446 
447 uint32_t
449 {
450  return m_maxSsrc;
451 }
452 
453 uint32_t
455 {
456  return m_maxSlrc;
457 }
458 
459 uint32_t
461 {
462  return m_rtsCtsThreshold;
463 }
464 
465 uint32_t
467 {
468  return DoGetFragmentationThreshold ();
469 }
470 
471 void
473 {
474  NS_LOG_FUNCTION (this << address);
475  NS_ASSERT (!address.IsGroup ());
476  WifiRemoteStationState *state = LookupState (address);
477  state->m_operationalRateSet.clear ();
478  state->m_operationalMcsSet.clear ();
479  AddSupportedMode (address, GetDefaultMode ());
480  AddSupportedMcs (address, GetDefaultMcs ());
481 }
482 
483 void
485 {
486  NS_LOG_FUNCTION (this << address << isShortPreambleSupported);
487  NS_ASSERT (!address.IsGroup ());
488  WifiRemoteStationState *state = LookupState (address);
489  state->m_shortPreamble = isShortPreambleSupported;
490 }
491 
492 void
494 {
495  NS_LOG_FUNCTION (this << address << mode);
496  NS_ASSERT (!address.IsGroup ());
497  WifiRemoteStationState *state = LookupState (address);
498  for (WifiModeListIterator i = state->m_operationalRateSet.begin (); i != state->m_operationalRateSet.end (); i++)
499  {
500  if ((*i) == mode)
501  {
502  //already in.
503  return;
504  }
505  }
506  state->m_operationalRateSet.push_back (mode);
507 }
508 
509 void
511 {
512  NS_ASSERT (!address.IsGroup ());
513  WifiRemoteStationState *state = LookupState (address);
514  state->m_operationalRateSet.clear ();
515  for (uint32_t i = 0; i < m_wifiPhy->GetNModes (); i++)
516  {
517  state->m_operationalRateSet.push_back (m_wifiPhy->GetMode (i));
518  }
519 }
520 
521 void
523 {
524  NS_LOG_FUNCTION (this << address << mcs);
525  NS_ASSERT (!address.IsGroup ());
526  WifiRemoteStationState *state = LookupState (address);
527  for (WifiModeListIterator i = state->m_operationalMcsSet.begin (); i != state->m_operationalMcsSet.end (); i++)
528  {
529  if ((*i) == mcs)
530  {
531  //already in.
532  return;
533  }
534  }
535  state->m_operationalMcsSet.push_back (mcs);
536 }
537 
538 bool
540 {
541  if (address.IsGroup ())
542  {
543  return false;
544  }
546 }
547 
548 bool
550 {
551  if (address.IsGroup ())
552  {
553  return true;
554  }
556 }
557 
558 bool
560 {
561  if (address.IsGroup ())
562  {
563  return false;
564  }
566 }
567 
568 void
570 {
571  NS_ASSERT (!address.IsGroup ());
573 }
574 
575 void
577 {
578  NS_ASSERT (!address.IsGroup ());
580 }
581 
582 void
584 {
585  NS_ASSERT (!address.IsGroup ());
587 }
588 
589 void
591 {
592  NS_ASSERT (!address.IsGroup ());
594 }
595 
596 void
598  Ptr<const Packet> packet, uint32_t fullPacketSize)
599 {
600  NS_LOG_FUNCTION (this << address << *header << packet << fullPacketSize);
601  if (IsLowLatency () || address.IsGroup ())
602  {
603  return;
604  }
605  WifiRemoteStation *station = Lookup (address, header);
606  WifiTxVector rts = DoGetRtsTxVector (station);
607  WifiTxVector data = DoGetDataTxVector (station, fullPacketSize);
608  WifiTxVector ctstoself = DoGetCtsToSelfTxVector ();
611  HighLatencyCtsToSelfTxVectorTag ctstoselftag;
612  //first, make sure that the tag is not here anymore.
613  ConstCast<Packet> (packet)->RemovePacketTag (datatag);
614  ConstCast<Packet> (packet)->RemovePacketTag (rtstag);
615  ConstCast<Packet> (packet)->RemovePacketTag (ctstoselftag);
616  datatag = HighLatencyDataTxVectorTag (data);
617  rtstag = HighLatencyRtsTxVectorTag (rts);
618  ctstoselftag = HighLatencyCtsToSelfTxVectorTag (ctstoself);
619  //and then, add it back
620  packet->AddPacketTag (datatag);
621  packet->AddPacketTag (rtstag);
622  packet->AddPacketTag (ctstoselftag);
623 }
624 
627  Ptr<const Packet> packet, uint32_t fullPacketSize)
628 {
629  NS_LOG_FUNCTION (this << address << *header << packet << fullPacketSize);
630  if (address.IsGroup ())
631  {
632  WifiTxVector v;
633  v.SetMode (GetNonUnicastMode ());
637  v.SetNss (1);
638  v.SetNess (0);
639  v.SetStbc (false);
640  return v;
641  }
642  if (!IsLowLatency ())
643  {
645  bool found;
646  found = ConstCast<Packet> (packet)->PeekPacketTag (datatag);
647  NS_ASSERT (found);
648  //cast found to void, to suppress 'found' set but not used
649  //compiler warning
650  (void) found;
651  return datatag.GetDataTxVector ();
652  }
653  return DoGetDataTxVector (Lookup (address, header), fullPacketSize);
654 }
655 
658  Ptr<const Packet> packet)
659 {
660  NS_LOG_FUNCTION (this << *header << packet);
661  if (!IsLowLatency ())
662  {
663  HighLatencyCtsToSelfTxVectorTag ctstoselftag;
664  bool found;
665  found = ConstCast<Packet> (packet)->PeekPacketTag (ctstoselftag);
666  NS_ASSERT (found);
667  //cast found to void, to suppress 'found' set but not used
668  //compiler warning
669  (void) found;
670  return ctstoselftag.GetCtsToSelfTxVector ();
671  }
672  return DoGetCtsToSelfTxVector ();
673 }
674 
677 {
678  return WifiTxVector (GetDefaultMode (),
680  0,
685  false,
686  false);
687 }
688 
691  Ptr<const Packet> packet)
692 {
693  NS_LOG_FUNCTION (this << address << *header << packet);
694  NS_ASSERT (!address.IsGroup ());
695  if (!IsLowLatency ())
696  {
698  bool found;
699  found = ConstCast<Packet> (packet)->PeekPacketTag (rtstag);
700  NS_ASSERT (found);
701  //cast found to void, to suppress 'found' set but not used
702  //compiler warning
703  (void) found;
704  return rtstag.GetRtsTxVector ();
705  }
706  return DoGetRtsTxVector (Lookup (address, header));
707 }
708 
709 void
711 {
712  NS_LOG_FUNCTION (this << address << *header);
713  NS_ASSERT (!address.IsGroup ());
714  WifiRemoteStation *station = Lookup (address, header);
715  station->m_ssrc++;
716  m_macTxRtsFailed (address);
717  DoReportRtsFailed (station);
718 }
719 
720 void
722 {
723  NS_LOG_FUNCTION (this << address << *header);
724  NS_ASSERT (!address.IsGroup ());
725  WifiRemoteStation *station = Lookup (address, header);
726  station->m_slrc++;
727  m_macTxDataFailed (address);
728  DoReportDataFailed (station);
729 }
730 
731 void
733  double ctsSnr, WifiMode ctsMode, double rtsSnr)
734 {
735  NS_LOG_FUNCTION (this << address << *header << ctsSnr << ctsMode << rtsSnr);
736  NS_ASSERT (!address.IsGroup ());
737  WifiRemoteStation *station = Lookup (address, header);
738  station->m_state->m_info.NotifyTxSuccess (station->m_ssrc);
739  station->m_ssrc = 0;
740  DoReportRtsOk (station, ctsSnr, ctsMode, rtsSnr);
741 }
742 
743 void
745  double ackSnr, WifiMode ackMode, double dataSnr)
746 {
747  NS_LOG_FUNCTION (this << address << *header << ackSnr << ackMode << dataSnr);
748  NS_ASSERT (!address.IsGroup ());
749  WifiRemoteStation *station = Lookup (address, header);
750  station->m_state->m_info.NotifyTxSuccess (station->m_slrc);
751  station->m_slrc = 0;
752  DoReportDataOk (station, ackSnr, ackMode, dataSnr);
753 }
754 
755 void
757 {
758  NS_LOG_FUNCTION (this << address << *header);
759  NS_ASSERT (!address.IsGroup ());
760  WifiRemoteStation *station = Lookup (address, header);
761  station->m_state->m_info.NotifyTxFailed ();
762  station->m_ssrc = 0;
763  m_macTxFinalRtsFailed (address);
764  DoReportFinalRtsFailed (station);
765 }
766 
767 void
769 {
770  NS_LOG_FUNCTION (this << address << *header);
771  NS_ASSERT (!address.IsGroup ());
772  WifiRemoteStation *station = Lookup (address, header);
773  station->m_state->m_info.NotifyTxFailed ();
774  station->m_slrc = 0;
775  m_macTxFinalDataFailed (address);
776  DoReportFinalDataFailed (station);
777 }
778 
779 void
781  double rxSnr, WifiMode txMode)
782 {
783  NS_LOG_FUNCTION (this << address << *header << rxSnr << txMode);
784  if (address.IsGroup ())
785  {
786  return;
787  }
788  WifiRemoteStation *station = Lookup (address, header);
789  DoReportRxOk (station, rxSnr, txMode);
790 }
791 
792 bool
794  Ptr<const Packet> packet)
795 {
796  NS_LOG_FUNCTION (this << address << *header << packet);
797  if (address.IsGroup ())
798  {
799  return false;
800  }
801  bool normally = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > GetRtsCtsThreshold ();
802  return DoNeedRts (Lookup (address, header), packet, normally);
803 }
804 
805 bool
807 {
808  NS_LOG_FUNCTION (this << txVector);
809  WifiMode mode = txVector.GetMode ();
810  //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
811  for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
812  {
813  if (mode == *i)
814  {
815  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
816  return false;
817  }
818  }
819  if (HasHtSupported ())
820  {
821  //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
822  for (WifiModeListIterator i = m_bssBasicMcsSet.begin (); i != m_bssBasicMcsSet.end (); i++)
823  {
824  if (mode == *i)
825  {
826  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
827  return false;
828  }
829  }
830  }
831  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true");
832  return true;
833 }
834 
835 bool
837  Ptr<const Packet> packet)
838 {
839  NS_LOG_FUNCTION (this << address << packet << *header);
840  NS_ASSERT (!address.IsGroup ());
841  WifiRemoteStation *station = Lookup (address, header);
842  bool normally = station->m_ssrc < GetMaxSsrc ();
843  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedDataRetransmission count: " << station->m_ssrc << " result: " << std::boolalpha << normally);
844  return DoNeedRtsRetransmission (station, packet, normally);
845 }
846 
847 bool
849  Ptr<const Packet> packet)
850 {
851  NS_LOG_FUNCTION (this << address << packet << *header);
852  NS_ASSERT (!address.IsGroup ());
853  WifiRemoteStation *station = Lookup (address, header);
854  bool normally = station->m_slrc < GetMaxSlrc ();
855  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedDataRetransmission count: " << station->m_slrc << " result: " << std::boolalpha << normally);
856  return DoNeedDataRetransmission (station, packet, normally);
857 }
858 
859 bool
861  Ptr<const Packet> packet)
862 {
863  NS_LOG_FUNCTION (this << address << packet << *header);
864  if (address.IsGroup ())
865  {
866  return false;
867  }
868  WifiRemoteStation *station = Lookup (address, header);
869  bool normally = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > GetFragmentationThreshold ();
870  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedFragmentation result: " << std::boolalpha << normally);
871  return DoNeedFragmentation (station, packet, normally);
872 }
873 
874 void
876 {
877  NS_LOG_FUNCTION (this << threshold);
878  if (threshold < 256)
879  {
880  /*
881  * ASN.1 encoding of the MAC and PHY MIB (256 ... 8000)
882  */
883  NS_LOG_WARN ("Fragmentation threshold should be larger than 256. Setting to 256.");
885  }
886  else
887  {
888  /*
889  * The length of each fragment shall be an even number of octets, except for the last fragment if an MSDU or
890  * MMPDU, which may be either an even or an odd number of octets.
891  */
892  if (threshold % 2 != 0)
893  {
894  NS_LOG_WARN ("Fragmentation threshold should be an even number. Setting to " << threshold - 1);
895  m_nextFragmentationThreshold = threshold - 1;
896  }
897  else
898  {
899  m_nextFragmentationThreshold = threshold;
900  }
901  }
902 }
903 
904 void
906 {
908 }
909 
910 uint32_t
912 {
914 }
915 
916 uint32_t
918 {
919  NS_LOG_FUNCTION (this << *header << packet);
920  //The number of bytes a fragment can support is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
921  uint32_t nFragments = (packet->GetSize () / (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
922 
923  //If the size of the last fragment is not 0.
924  if ((packet->GetSize () % (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH)) > 0)
925  {
926  nFragments++;
927  }
928  NS_LOG_DEBUG ("WifiRemoteStationManager::GetNFragments returning " << nFragments);
929  return nFragments;
930 }
931 
932 uint32_t
934  Ptr<const Packet> packet, uint32_t fragmentNumber)
935 {
936  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
937  NS_ASSERT (!address.IsGroup ());
938  uint32_t nFragment = GetNFragments (header, packet);
939  if (fragmentNumber >= nFragment)
940  {
941  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning 0");
942  return 0;
943  }
944  //Last fragment
945  if (fragmentNumber == nFragment - 1)
946  {
947  uint32_t lastFragmentSize = packet->GetSize () - (fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
948  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << lastFragmentSize);
949  return lastFragmentSize;
950  }
951  //All fragments but the last, the number of bytes is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
952  else
953  {
954  uint32_t fragmentSize = GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH;
955  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << fragmentSize);
956  return fragmentSize;
957  }
958 }
959 
960 uint32_t
962  Ptr<const Packet> packet, uint32_t fragmentNumber)
963 {
964  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
965  NS_ASSERT (!address.IsGroup ());
966  NS_ASSERT (fragmentNumber < GetNFragments (header, packet));
967  uint32_t fragmentOffset = fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH);
968  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentOffset returning " << fragmentOffset);
969  return fragmentOffset;
970 }
971 
972 bool
974  Ptr<const Packet> packet, uint32_t fragmentNumber)
975 {
976  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
977  NS_ASSERT (!address.IsGroup ());
978  bool isLast = fragmentNumber == (GetNFragments (header, packet) - 1);
979  NS_LOG_DEBUG ("WifiRemoteStationManager::IsLastFragment returning " << std::boolalpha << isLast);
980  return isLast;
981 }
982 
983 WifiMode
985 {
1000  NS_LOG_FUNCTION (this << address << reqMode);
1001  WifiMode mode = GetDefaultMode ();
1002  bool found = false;
1003  //First, search the BSS Basic Rate set
1004  for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
1005  {
1006  if ((!found || i->GetPhyRate (m_wifiPhy->GetChannelWidth (), m_wifiPhy->GetGuardInterval (), 1) > mode.GetPhyRate (m_wifiPhy->GetChannelWidth (), m_wifiPhy->GetGuardInterval (), 1))
1007  && (i->GetPhyRate (m_wifiPhy->GetChannelWidth (), m_wifiPhy->GetGuardInterval (), 1) <= reqMode.GetPhyRate (m_wifiPhy->GetChannelWidth (), m_wifiPhy->GetGuardInterval (), 1))
1008  && ((i->GetModulationClass () == reqMode.GetModulationClass ())
1009  || (reqMode.GetModulationClass () == WIFI_MOD_CLASS_HT)
1010  || (reqMode.GetModulationClass () == WIFI_MOD_CLASS_VHT)))
1011 
1012  {
1013  mode = *i;
1014  //We've found a potentially-suitable transmit rate, but we
1015  //need to continue and consider all the basic rates before
1016  //we can be sure we've got the right one.
1017  found = true;
1018  }
1019  }
1020  if (HasHtSupported () || HasVhtSupported ())
1021  {
1022  if (!found)
1023  {
1024  mode = GetDefaultMcs ();
1025  for (WifiModeListIterator i = m_bssBasicMcsSet.begin (); i != m_bssBasicMcsSet.end (); i++)
1026  {
1027  if ((!found || i->GetPhyRate (m_wifiPhy->GetChannelWidth (), m_wifiPhy->GetGuardInterval (), 1) > mode.GetPhyRate (m_wifiPhy->GetChannelWidth (), m_wifiPhy->GetGuardInterval (), 1))
1028  && i->GetPhyRate (m_wifiPhy->GetChannelWidth (), m_wifiPhy->GetGuardInterval (), 1) <= reqMode.GetPhyRate (m_wifiPhy->GetChannelWidth (), m_wifiPhy->GetGuardInterval (), 1))
1029  //&& thismode.GetModulationClass () == reqMode.GetModulationClass ()) //TODO: check standard
1030  {
1031  mode = *i;
1032  //We've found a potentially-suitable transmit rate, but we
1033  //need to continue and consider all the basic rates before
1034  //we can be sure we've got the right one.
1035  found = true;
1036  }
1037  }
1038  }
1039  }
1040  //If we found a suitable rate in the BSSBasicRateSet, then we are
1041  //done and can return that mode.
1042  if (found)
1043  {
1044  NS_LOG_DEBUG ("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
1045  return mode;
1046  }
1047 
1065  for (uint32_t idx = 0; idx < m_wifiPhy->GetNModes (); idx++)
1066  {
1067  WifiMode thismode = m_wifiPhy->GetMode (idx);
1068 
1069  /* If the rate:
1070  *
1071  * - is a mandatory rate for the PHY, and
1072  * - is equal to or faster than our current best choice, and
1073  * - is less than or equal to the rate of the received frame, and
1074  * - is of the same modulation class as the received frame
1075  *
1076  * ...then it's our best choice so far.
1077  */
1078  if (thismode.IsMandatory ()
1081  && ((thismode.GetModulationClass () == reqMode.GetModulationClass ())
1082  || (reqMode.GetModulationClass () == WIFI_MOD_CLASS_HT)
1083  || (reqMode.GetModulationClass () == WIFI_MOD_CLASS_HT)))
1084 
1085  {
1086  mode = thismode;
1087  //As above; we've found a potentially-suitable transmit
1088  //rate, but we need to continue and consider all the
1089  //mandatory rates before we can be sure we've got the right one.
1090  found = true;
1091  }
1092  }
1093  if (HasHtSupported () || HasVhtSupported ())
1094  {
1095  for (uint32_t idx = 0; idx < m_wifiPhy->GetNMcs (); idx++)
1096  {
1097  WifiMode thismode = m_wifiPhy->GetMcs (idx);
1098  if (thismode.IsMandatory ()
1101  && thismode.GetModulationClass () == reqMode.GetModulationClass ())
1102  {
1103  mode = thismode;
1104  //As above; we've found a potentially-suitable transmit
1105  //rate, but we need to continue and consider all the
1106  //mandatory rates before we can be sure we've got the right one.
1107  found = true;
1108  }
1109 
1110  }
1111  }
1112 
1123  if (!found)
1124  {
1125  NS_FATAL_ERROR ("Can't find response rate for " << reqMode);
1126  }
1127 
1128  NS_LOG_DEBUG ("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
1129  return mode;
1130 }
1131 
1134 {
1135  NS_ASSERT (!address.IsGroup ());
1136  WifiTxVector v;
1137  v.SetMode (GetControlAnswerMode (address, rtsMode));
1138  v.SetTxPowerLevel (DoGetCtsTxPowerLevel (address, v.GetMode ()));
1139  v.SetChannelWidth (DoGetCtsTxChannelWidth (address, v.GetMode ()));
1140  v.SetShortGuardInterval (DoGetCtsTxGuardInterval (address, v.GetMode ()));
1141  v.SetNss (DoGetCtsTxNss (address, v.GetMode ()));
1142  v.SetNess (DoGetCtsTxNess (address, v.GetMode ()));
1143  v.SetStbc (DoGetCtsTxStbc (address, v.GetMode ()));
1144  return v;
1145 }
1146 
1149 {
1150  NS_ASSERT (!address.IsGroup ());
1151  WifiTxVector v;
1152  v.SetMode (GetControlAnswerMode (address, dataMode));
1153  v.SetTxPowerLevel (DoGetAckTxPowerLevel (address, v.GetMode ()));
1154  v.SetChannelWidth (DoGetAckTxChannelWidth (address, v.GetMode ()));
1155  v.SetShortGuardInterval (DoGetAckTxGuardInterval (address, v.GetMode ()));
1156  v.SetNss (DoGetAckTxNss (address, v.GetMode ()));
1157  v.SetNess (DoGetAckTxNess (address, v.GetMode ()));
1158  v.SetStbc (DoGetAckTxStbc (address, v.GetMode ()));
1159  return v;
1160 }
1161 
1164 {
1165  NS_ASSERT (!address.IsGroup ());
1166  WifiTxVector v;
1167  v.SetMode (GetControlAnswerMode (address, blockAckReqMode));
1168  v.SetTxPowerLevel (DoGetBlockAckTxPowerLevel (address, v.GetMode ()));
1169  v.SetChannelWidth (DoGetBlockAckTxChannelWidth (address, v.GetMode ()));
1170  v.SetShortGuardInterval (DoGetBlockAckTxGuardInterval (address, v.GetMode ()));
1171  v.SetNss (DoGetBlockAckTxNss (address, v.GetMode ()));
1172  v.SetNess (DoGetBlockAckTxNess (address, v.GetMode ()));
1173  v.SetStbc (DoGetBlockAckTxStbc (address, v.GetMode ()));
1174  return v;
1175 }
1176 
1177 uint8_t
1179 {
1180  return m_defaultTxPowerLevel;
1181 }
1182 
1183 uint32_t
1185 {
1186  return m_wifiPhy->GetChannelWidth ();
1187 }
1188 
1189 bool
1191 {
1192  return m_wifiPhy->GetGuardInterval ();
1193 }
1194 
1195 uint8_t
1197 {
1198  return 1;
1199 }
1200 
1201 uint8_t
1203 {
1204  return 0;
1205 }
1206 
1207 bool
1209 {
1210  return m_wifiPhy->GetStbc ();
1211 }
1212 
1213 uint8_t
1215 {
1216  return m_defaultTxPowerLevel;
1217 }
1218 
1219 uint32_t
1221 {
1222  return m_wifiPhy->GetChannelWidth ();
1223 }
1224 
1225 bool
1227 {
1228  return m_wifiPhy->GetGuardInterval ();
1229 }
1230 
1231 uint8_t
1233 {
1234  return 1;
1235 }
1236 
1237 uint8_t
1239 {
1240  return 0;
1241 }
1242 
1243 bool
1245 {
1246  return m_wifiPhy->GetStbc ();
1247 }
1248 
1249 uint8_t
1251 {
1252  return m_defaultTxPowerLevel;
1253 }
1254 
1255 uint32_t
1257 {
1258  return m_wifiPhy->GetChannelWidth ();
1259 }
1260 
1261 bool
1263 {
1264  return m_wifiPhy->GetGuardInterval ();
1265 }
1266 
1267 uint8_t
1269 {
1270  return 1;
1271 }
1272 
1273 uint8_t
1275 {
1276  return 0;
1277 }
1278 
1279 bool
1281 {
1282  return m_wifiPhy->GetStbc ();
1283 }
1284 
1285 uint8_t
1287 {
1288  return m_defaultTxPowerLevel;
1289 }
1290 
1293 {
1294  WifiRemoteStationState *state = LookupState (address);
1295  return state->m_info;
1296 }
1297 
1300 {
1301  NS_LOG_FUNCTION (this << address);
1302  for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
1303  {
1304  if ((*i)->m_address == address)
1305  {
1306  NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning existing state");
1307  return (*i);
1308  }
1309  }
1312  state->m_address = address;
1313  state->m_operationalRateSet.push_back (GetDefaultMode ());
1314  state->m_operationalMcsSet.push_back (GetDefaultMcs ());
1317  state->m_greenfield = m_wifiPhy->GetGreenfield ();
1319  state->m_rx = 1;
1320  state->m_tx = 1;
1321  state->m_ness = 0;
1322  state->m_aggregation = false;
1323  state->m_stbc = false;
1324  const_cast<WifiRemoteStationManager *> (this)->m_states.push_back (state);
1325  NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning new state");
1326  return state;
1327 }
1328 
1331 {
1332  uint8_t tid;
1333  if (header->IsQosData ())
1334  {
1335  tid = header->GetQosTid ();
1336  }
1337  else
1338  {
1339  tid = 0;
1340  }
1341  return Lookup (address, tid);
1342 }
1343 
1346 {
1347  NS_LOG_FUNCTION (this << address << (uint16_t)tid);
1348  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1349  {
1350  if ((*i)->m_tid == tid
1351  && (*i)->m_state->m_address == address)
1352  {
1353  return (*i);
1354  }
1355  }
1356  WifiRemoteStationState *state = LookupState (address);
1357 
1358  WifiRemoteStation *station = DoCreateStation ();
1359  station->m_state = state;
1360  station->m_tid = tid;
1361  station->m_ssrc = 0;
1362  station->m_slrc = 0;
1363  const_cast<WifiRemoteStationManager *> (this)->m_stations.push_back (station);
1364  return station;
1365 }
1366 
1367 void
1369 {
1370  //Used by all stations to record HT capabilities of remote stations
1371  NS_LOG_FUNCTION (this << from << htCapabilities);
1372  WifiRemoteStationState *state;
1373  state = LookupState (from);
1374  state->m_shortGuardInterval = htCapabilities.GetShortGuardInterval20 ();
1375  if (htCapabilities.GetSupportedChannelWidth () == 1)
1376  {
1377  state->m_channelWidth = 40;
1378  }
1379  else
1380  {
1381  state->m_channelWidth = 20;
1382  }
1383  state->m_greenfield = htCapabilities.GetGreenfield ();
1384 }
1385 
1386 void
1388 {
1389  //Used by all stations to record VHT capabilities of remote stations
1390  NS_LOG_FUNCTION (this << from << vhtCapabilities);
1391  WifiRemoteStationState *state;
1392  state = LookupState (from);
1393  if (vhtCapabilities.GetSupportedChannelWidthSet () == 1)
1394  {
1395  state->m_channelWidth = 160;
1396  }
1397  else
1398  {
1399  state->m_channelWidth = 80;
1400  }
1401  //This is a workaround to enable users to force a 20 or 40 MHz channel for a VHT-compliant device,
1402  //since IEEE 802.11ac standard says that 20, 40 and 80 MHz channels are mandatory.
1403  if (m_wifiPhy->GetChannelWidth () < state->m_channelWidth)
1404  {
1406  }
1407 }
1408 
1409 bool
1411 {
1412  return LookupState (address)->m_greenfield;
1413 }
1414 
1415 bool
1417 {
1418  return LookupState (address)->m_shortPreamble;
1419 }
1420 
1421 WifiMode
1423 {
1424  return m_defaultTxMode;
1425 }
1426 
1427 WifiMode
1429 {
1430  return m_defaultTxMcs;
1431 }
1432 
1433 void
1435 {
1436  NS_LOG_FUNCTION (this);
1437  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1438  {
1439  delete (*i);
1440  }
1441  m_stations.clear ();
1442  m_bssBasicRateSet.clear ();
1443  m_bssBasicRateSet.push_back (m_defaultTxMode);
1444  m_bssBasicMcsSet.clear ();
1445  m_bssBasicMcsSet.push_back (m_defaultTxMcs);
1447 }
1448 
1449 void
1451 {
1452  NS_LOG_FUNCTION (this << mode);
1454  {
1455  NS_FATAL_ERROR ("It is not allowed to add a (V)HT rate in the BSSBasicRateSet!");
1456  }
1457  for (uint32_t i = 0; i < GetNBasicModes (); i++)
1458  {
1459  if (GetBasicMode (i) == mode)
1460  {
1461  return;
1462  }
1463  }
1464  m_bssBasicRateSet.push_back (mode);
1465 }
1466 
1467 uint32_t
1469 {
1470  return m_bssBasicRateSet.size ();
1471 }
1472 
1473 WifiMode
1475 {
1476  NS_ASSERT (i < m_bssBasicRateSet.size ());
1477  return m_bssBasicRateSet[i];
1478 }
1479 
1480 void
1482 {
1483  NS_LOG_FUNCTION (this << (uint32_t)mcs.GetMcsValue ());
1484  for (uint32_t i = 0; i < GetNBasicMcs (); i++)
1485  {
1486  if (GetBasicMcs (i) == mcs)
1487  {
1488  return;
1489  }
1490  }
1491  m_bssBasicMcsSet.push_back (mcs);
1492 }
1493 
1494 uint32_t
1496 {
1497  return m_bssBasicMcsSet.size ();
1498 }
1499 
1500 WifiMode
1502 {
1503  NS_ASSERT (i < m_bssBasicMcsSet.size ());
1504  return m_bssBasicMcsSet[i];
1505 }
1506 
1507 WifiMode
1509 {
1510  if (m_nonUnicastMode == WifiMode ())
1511  {
1512  return GetBasicMode (0);
1513  }
1514  else
1515  {
1516  return m_nonUnicastMode;
1517  }
1518 }
1519 
1520 bool
1522  Ptr<const Packet> packet, bool normally)
1523 {
1524  return normally;
1525 }
1526 
1527 bool
1529  Ptr<const Packet> packet, bool normally)
1530 {
1531  return normally;
1532 }
1533 
1534 bool
1536  Ptr<const Packet> packet, bool normally)
1537 {
1538  return normally;
1539 }
1540 
1541 bool
1543  Ptr<const Packet> packet, bool normally)
1544 {
1545  return normally;
1546 }
1547 
1548 WifiMode
1550 {
1551  NS_ASSERT (i < GetNSupported (station));
1552  return station->m_state->m_operationalRateSet[i];
1553 }
1554 
1555 WifiMode
1557 {
1558  NS_ASSERT (i < GetNMcsSupported (station));
1559  return station->m_state->m_operationalMcsSet[i];
1560 }
1561 
1562 uint32_t
1564 {
1565  return station->m_state->m_channelWidth;
1566 }
1567 
1568 bool
1570 {
1571  return station->m_state->m_shortGuardInterval;
1572 }
1573 
1574 bool
1576 {
1577  return station->m_state->m_greenfield;
1578 }
1579 
1580 bool
1582 {
1583  return station->m_state->m_shortPreamble;
1584 }
1585 
1586 bool
1588 {
1589  return station->m_state->m_aggregation;
1590 }
1591 
1592 bool
1594 {
1595  return station->m_state->m_stbc;
1596 }
1597 
1598 uint32_t
1600 {
1601  return station->m_state->m_rx;
1602 }
1603 
1604 uint32_t
1606 {
1607  return station->m_state->m_tx;
1608 }
1609 
1610 uint32_t
1612 {
1613  return station->m_state->m_ness;
1614 }
1615 
1616 uint32_t
1618 {
1619  return station->m_ssrc;
1620 }
1621 
1624 {
1625  return m_wifiPhy;
1626 }
1627 
1630 {
1631  return m_wifiMac;
1632 }
1633 
1634 uint32_t
1636 {
1637  return station->m_slrc;
1638 }
1639 
1640 uint32_t
1642 {
1643  return station->m_state->m_operationalRateSet.size ();
1644 }
1645 
1646 uint32_t
1648 {
1649  return station->m_state->m_operationalMcsSet.size ();
1650 }
1651 
1652 void
1654 {
1655  m_defaultTxPowerLevel = txPower;
1656 }
1657 
1658 uint32_t
1660 {
1662 }
1663 
1665  : m_memoryTime (Seconds (1.0)),
1666  m_lastUpdate (Seconds (0.0)),
1667  m_failAvg (0.0)
1668 {
1669 }
1670 
1671 double
1673 {
1674  double retval = std::exp ((double)(m_lastUpdate.GetMicroSeconds () - Simulator::Now ().GetMicroSeconds ())
1675  / (double)m_memoryTime.GetMicroSeconds ());
1677  return retval;
1678 }
1679 
1680 void
1682 {
1683  double coefficient = CalculateAveragingCoefficient ();
1684  m_failAvg = (double)retryCounter / (1 + (double)retryCounter) * (1.0 - coefficient) + coefficient * m_failAvg;
1685 }
1686 
1687 void
1689 {
1690  double coefficient = CalculateAveragingCoefficient ();
1691  m_failAvg = (1.0 - coefficient) + coefficient * m_failAvg;
1692 }
1693 
1694 double
1696 {
1697  return m_failAvg;
1698 }
1699 
1701 {
1702  NS_LOG_FUNCTION (this);
1703 }
1704 
1705 } //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 used 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.
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.
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 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 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.
virtual uint8_t DoGetBlockAckTxNss(Mac48Address address, WifiMode blockAckMode)
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:822
uint32_t GetMaxSsrc(void) const
Return the maximum STA short retry count (SSRC).
enum WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:375
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.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:145
uint8_t GetSupportedChannelWidth(void) const
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:62
TracedCallback< Mac48Address > m_macTxFinalRtsFailed
The trace source fired when the transmission of a RTS has exceeded the maximum number of attempts...
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:97
bool IsMandatory(void) const
Definition: wifi-mode.cc:346
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)
uint32_t GetNumberOfReceiveAntennas(const WifiRemoteStation *station) const
Return the number of receive antennas the station has.
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...
Ptr< WifiPhy > GetPhy(void) const
Return the WifiPhy.
uint64_t GetPhyRate(uint32_t channelWidth, bool isShortGuardInterval, uint8_t nss) const
Definition: wifi-mode.cc:73
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
virtual WifiTxVector DoGetDataTxVector(WifiRemoteStation *station, uint32_t size)=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...
void SetRtsCtsThreshold(uint32_t threshold)
Sets the RTS threshold.
tuple phy
Definition: third.py:86
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.
Hold an unsigned integer type.
Definition: uinteger.h:44
virtual void DoReportDataFailed(WifiRemoteStation *station)=0
This method is a pure virtual method that must be implemented by the sub-class.
uint8_t data[writeSize]
bool m_stbc
Flag if STBC is used 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:60
uint32_t m_maxSlrc
Maximum STA long retry count (SLRC)
uint8_t GetMcsValue(void) const
Definition: wifi-mode.cc:353
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.
uint32_t m_tx
Number of TX antennas of the remote station.
WifiMode m_defaultTxMode
The default transmission mode.
uint32_t GetNess(const WifiRemoteStation *station) const
void SetNss(uint8_t nss)
Sets the number of Nss refer to IEEE 802.11n Table 20-28 for explanation and range.
WifiMode GetDefaultMcs(void) const
Return the default Modulation and Coding Scheme (MCS) index.
virtual uint8_t DoGetCtsTxNss(Mac48Address address, WifiMode ctsMode)
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)
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.
void PrepareForQueue(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fullPacketSize)
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...
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.
WifiModeList::const_iterator WifiModeListIterator
An iterator for WifiModeList vector.
Definition: wifi-mode.h:207
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:195
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.
uint32_t m_rx
Number of RX antennas of the remote station.
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...
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
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.
virtual bool GetShortPlcpPreamble(void) const =0
virtual uint32_t DoGetCtsTxChannelWidth(Mac48Address address, WifiMode ctsMode)
void SetMaxSlrc(uint32_t maxSlrc)
Sets the maximum STA long retry count (SLRC).
uint32_t GetNBasicModes(void) const
Return the number of basic modes we support.
read and write tag data
Definition: tag-buffer.h:51
The attribute can be read.
Definition: type-id.h:63
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.
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.
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
virtual void DoDispose(void)
Destructor implementation.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:895
bool GetShortPreamble(const WifiRemoteStation *station) const
Return whether the station supports short PLCP preamble or not.
WifiTxVector GetDataTxVector(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fullPacketSize)
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:396
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:195
StationStates m_states
States of known stations.
WifiMode GetMode(void) const
bool NeedRts(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
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 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 used 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.
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.
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.