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.",
290  BooleanValue (true), //this value is ignored because there is no setter
293  .AddAttribute ("MaxSsrc", "The maximum number of retransmission attempts for an RTS. This value"
294  " will not have any effect on some rate control algorithms.",
295  UintegerValue (7),
297  MakeUintegerChecker<uint32_t> ())
298  .AddAttribute ("MaxSlrc", "The maximum number of retransmission attempts for a DATA packet. This value"
299  " will not have any effect on some rate control algorithms.",
300  UintegerValue (7),
302  MakeUintegerChecker<uint32_t> ())
303  .AddAttribute ("RtsCtsThreshold", "If the size of the data packet + LLC header + MAC header + FCS trailer is bigger than "
304  "this value, we use an RTS/CTS handshake before sending the data, as per IEEE Std. 802.11-2012, Section 9.3.5. "
305  "This value will not have any effect on some rate control algorithms.",
306  UintegerValue (2346),
308  MakeUintegerChecker<uint32_t> ())
309  .AddAttribute ("FragmentationThreshold", "If the size of the data packet + LLC header + MAC header + FCS trailer is bigger"
310  "than this value, we fragment it such that the size of the fragments are equal or smaller "
311  "than this value, as per IEEE Std. 802.11-2012, Section 9.5. "
312  "This value will not have any effect on some rate control algorithms.",
313  UintegerValue (2346),
316  MakeUintegerChecker<uint32_t> ())
317  .AddAttribute ("NonUnicastMode", "Wifi mode used for non-unicast transmissions.",
318  WifiModeValue (),
321  .AddAttribute ("DefaultTxPowerLevel", "Default power level to be used for transmissions. "
322  "This is the power level that is used by all those WifiManagers that do not"
323  "implement TX power control.",
324  UintegerValue (0),
326  MakeUintegerChecker<uint8_t> ())
327  .AddTraceSource ("MacTxRtsFailed",
328  "The transmission of a RTS by the MAC layer has failed",
330  "ns3::Mac48Address::TracedCallback")
331  .AddTraceSource ("MacTxDataFailed",
332  "The transmission of a data packet by the MAC layer has failed",
334  "ns3::Mac48Address::TracedCallback")
335  .AddTraceSource ("MacTxFinalRtsFailed",
336  "The transmission of a RTS has exceeded the maximum number of attempts",
338  "ns3::Mac48Address::TracedCallback")
339  .AddTraceSource ("MacTxFinalDataFailed",
340  "The transmission of a data packet has exceeded the maximum number of attempts",
342  "ns3::Mac48Address::TracedCallback")
343  ;
344  return tid;
345 }
346 
348  : m_htSupported (false),
349  m_vhtSupported (false)
350 {
351 }
352 
354 {
355 }
356 
357 void
359 {
360  for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
361  {
362  delete (*i);
363  }
364  m_states.clear ();
365  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
366  {
367  delete (*i);
368  }
369  m_stations.clear ();
370 }
371 
372 void
374 {
375  //We need to track our PHY because it is the object that knows the
376  //full set of transmit rates that are supported. We need to know
377  //this in order to find the relevant mandatory rates when chosing a
378  //transmit rate for automatic control responses like
379  //acknowledgements.
380  m_wifiPhy = phy;
381  m_defaultTxMode = phy->GetMode (0);
382  if (HasHtSupported () || HasVhtSupported ())
383  {
384  m_defaultTxMcs = phy->GetMcs (0);
385  }
386  Reset ();
387 }
388 
389 void
391 {
392  //We need to track our MAC because it is the object that knows the
393  //full set of interframe spaces.
394  m_wifiMac = mac;
395  Reset ();
396 }
397 
398 void
400 {
401  m_htSupported = enable;
402 }
403 
404 void
406 {
407  m_maxSsrc = maxSsrc;
408 }
409 
410 void
412 {
413  m_maxSlrc = maxSlrc;
414 }
415 
416 void
418 {
419  m_rtsCtsThreshold = threshold;
420 }
421 
422 void
424 {
425  DoSetFragmentationThreshold (threshold);
426 }
427 
428 bool
430 {
431  return m_htSupported;
432 }
433 
434 void
436 {
437  m_vhtSupported = enable;
438 }
439 
440 bool
442 {
443  return m_vhtSupported;
444 }
445 
446 uint32_t
448 {
449  return m_maxSsrc;
450 }
451 
452 uint32_t
454 {
455  return m_maxSlrc;
456 }
457 
458 uint32_t
460 {
461  return m_rtsCtsThreshold;
462 }
463 
464 uint32_t
466 {
467  return DoGetFragmentationThreshold ();
468 }
469 
470 void
472 {
473  NS_LOG_FUNCTION (this << address);
474  NS_ASSERT (!address.IsGroup ());
475  WifiRemoteStationState *state = LookupState (address);
476  state->m_operationalRateSet.clear ();
477  state->m_operationalMcsSet.clear ();
478  AddSupportedMode (address, GetDefaultMode ());
479  AddSupportedMcs (address, GetDefaultMcs ());
480 }
481 
482 void
484 {
485  NS_LOG_FUNCTION (this << address << mode);
486  NS_ASSERT (!address.IsGroup ());
487  WifiRemoteStationState *state = LookupState (address);
488  for (WifiModeListIterator i = state->m_operationalRateSet.begin (); i != state->m_operationalRateSet.end (); i++)
489  {
490  if ((*i) == mode)
491  {
492  //already in.
493  return;
494  }
495  }
496  state->m_operationalRateSet.push_back (mode);
497 }
498 
499 void
501 {
502  NS_ASSERT (!address.IsGroup ());
503  WifiRemoteStationState *state = LookupState (address);
504  state->m_operationalRateSet.clear ();
505  for (uint32_t i = 0; i < m_wifiPhy->GetNModes (); i++)
506  {
507  state->m_operationalRateSet.push_back (m_wifiPhy->GetMode (i));
508  }
509 }
510 
511 void
513 {
514  NS_LOG_FUNCTION (this << address << mcs);
515  NS_ASSERT (!address.IsGroup ());
516  WifiRemoteStationState *state = LookupState (address);
517  for (WifiModeListIterator i = state->m_operationalMcsSet.begin (); i != state->m_operationalMcsSet.end (); i++)
518  {
519  if ((*i) == mcs)
520  {
521  //already in.
522  return;
523  }
524  }
525  state->m_operationalMcsSet.push_back (mcs);
526 }
527 
528 bool
530 {
531  if (address.IsGroup ())
532  {
533  return false;
534  }
536 }
537 
538 bool
540 {
541  if (address.IsGroup ())
542  {
543  return true;
544  }
546 }
547 
548 bool
550 {
551  if (address.IsGroup ())
552  {
553  return false;
554  }
556 }
557 
558 void
560 {
561  NS_ASSERT (!address.IsGroup ());
563 }
564 
565 void
567 {
568  NS_ASSERT (!address.IsGroup ());
570 }
571 
572 void
574 {
575  NS_ASSERT (!address.IsGroup ());
577 }
578 
579 void
581 {
582  NS_ASSERT (!address.IsGroup ());
584 }
585 
586 void
588  Ptr<const Packet> packet, uint32_t fullPacketSize)
589 {
590  NS_LOG_FUNCTION (this << address << *header << packet << fullPacketSize);
591  if (IsLowLatency () || address.IsGroup ())
592  {
593  return;
594  }
595  WifiRemoteStation *station = Lookup (address, header);
596  WifiTxVector rts = DoGetRtsTxVector (station);
597  WifiTxVector data = DoGetDataTxVector (station, fullPacketSize);
598  WifiTxVector ctstoself = DoGetCtsToSelfTxVector ();
601  HighLatencyCtsToSelfTxVectorTag ctstoselftag;
602  //first, make sure that the tag is not here anymore.
603  ConstCast<Packet> (packet)->RemovePacketTag (datatag);
604  ConstCast<Packet> (packet)->RemovePacketTag (rtstag);
605  ConstCast<Packet> (packet)->RemovePacketTag (ctstoselftag);
606  datatag = HighLatencyDataTxVectorTag (data);
607  rtstag = HighLatencyRtsTxVectorTag (rts);
608  ctstoselftag = HighLatencyCtsToSelfTxVectorTag (ctstoself);
609  //and then, add it back
610  packet->AddPacketTag (datatag);
611  packet->AddPacketTag (rtstag);
612  packet->AddPacketTag (ctstoselftag);
613 }
614 
617  Ptr<const Packet> packet, uint32_t fullPacketSize)
618 {
619  NS_LOG_FUNCTION (this << address << *header << packet << fullPacketSize);
620  if (address.IsGroup ())
621  {
622  WifiTxVector v;
623  v.SetMode (GetNonUnicastMode ());
627  v.SetNss (1);
628  v.SetNess (0);
629  v.SetStbc (false);
630  return v;
631  }
632  if (!IsLowLatency ())
633  {
635  bool found;
636  found = ConstCast<Packet> (packet)->PeekPacketTag (datatag);
637  NS_ASSERT (found);
638  //cast found to void, to suppress 'found' set but not used
639  //compiler warning
640  (void) found;
641  return datatag.GetDataTxVector ();
642  }
643  return DoGetDataTxVector (Lookup (address, header), fullPacketSize);
644 }
645 
648  Ptr<const Packet> packet)
649 {
650  NS_LOG_FUNCTION (this << *header << packet);
651  if (!IsLowLatency ())
652  {
653  HighLatencyCtsToSelfTxVectorTag ctstoselftag;
654  bool found;
655  found = ConstCast<Packet> (packet)->PeekPacketTag (ctstoselftag);
656  NS_ASSERT (found);
657  //cast found to void, to suppress 'found' set but not used
658  //compiler warning
659  (void) found;
660  return ctstoselftag.GetCtsToSelfTxVector ();
661  }
662  return DoGetCtsToSelfTxVector ();
663 }
664 
667 {
668  return WifiTxVector (GetDefaultMode (),
670  0,
675  false,
676  false);
677 }
678 
681  Ptr<const Packet> packet)
682 {
683  NS_LOG_FUNCTION (this << address << *header << packet);
684  NS_ASSERT (!address.IsGroup ());
685  if (!IsLowLatency ())
686  {
688  bool found;
689  found = ConstCast<Packet> (packet)->PeekPacketTag (rtstag);
690  NS_ASSERT (found);
691  //cast found to void, to suppress 'found' set but not used
692  //compiler warning
693  (void) found;
694  return rtstag.GetRtsTxVector ();
695  }
696  return DoGetRtsTxVector (Lookup (address, header));
697 }
698 
699 void
701 {
702  NS_LOG_FUNCTION (this << address << *header);
703  NS_ASSERT (!address.IsGroup ());
704  WifiRemoteStation *station = Lookup (address, header);
705  station->m_ssrc++;
706  m_macTxRtsFailed (address);
707  DoReportRtsFailed (station);
708 }
709 
710 void
712 {
713  NS_LOG_FUNCTION (this << address << *header);
714  NS_ASSERT (!address.IsGroup ());
715  WifiRemoteStation *station = Lookup (address, header);
716  station->m_slrc++;
717  m_macTxDataFailed (address);
718  DoReportDataFailed (station);
719 }
720 
721 void
723  double ctsSnr, WifiMode ctsMode, double rtsSnr)
724 {
725  NS_LOG_FUNCTION (this << address << *header << ctsSnr << ctsMode << rtsSnr);
726  NS_ASSERT (!address.IsGroup ());
727  WifiRemoteStation *station = Lookup (address, header);
728  station->m_state->m_info.NotifyTxSuccess (station->m_ssrc);
729  station->m_ssrc = 0;
730  DoReportRtsOk (station, ctsSnr, ctsMode, rtsSnr);
731 }
732 
733 void
735  double ackSnr, WifiMode ackMode, double dataSnr)
736 {
737  NS_LOG_FUNCTION (this << address << *header << ackSnr << ackMode << dataSnr);
738  NS_ASSERT (!address.IsGroup ());
739  WifiRemoteStation *station = Lookup (address, header);
740  station->m_state->m_info.NotifyTxSuccess (station->m_slrc);
741  station->m_slrc = 0;
742  DoReportDataOk (station, ackSnr, ackMode, dataSnr);
743 }
744 
745 void
747 {
748  NS_LOG_FUNCTION (this << address << *header);
749  NS_ASSERT (!address.IsGroup ());
750  WifiRemoteStation *station = Lookup (address, header);
751  station->m_state->m_info.NotifyTxFailed ();
752  station->m_ssrc = 0;
753  m_macTxFinalRtsFailed (address);
754  DoReportFinalRtsFailed (station);
755 }
756 
757 void
759 {
760  NS_LOG_FUNCTION (this << address << *header);
761  NS_ASSERT (!address.IsGroup ());
762  WifiRemoteStation *station = Lookup (address, header);
763  station->m_state->m_info.NotifyTxFailed ();
764  station->m_slrc = 0;
765  m_macTxFinalDataFailed (address);
766  DoReportFinalDataFailed (station);
767 }
768 
769 void
771  double rxSnr, WifiMode txMode)
772 {
773  NS_LOG_FUNCTION (this << address << *header << rxSnr << txMode);
774  if (address.IsGroup ())
775  {
776  return;
777  }
778  WifiRemoteStation *station = Lookup (address, header);
779  DoReportRxOk (station, rxSnr, txMode);
780 }
781 
782 bool
784  Ptr<const Packet> packet)
785 {
786  NS_LOG_FUNCTION (this << address << *header << packet);
787  if (address.IsGroup ())
788  {
789  return false;
790  }
791  bool normally = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > GetRtsCtsThreshold ();
792  return DoNeedRts (Lookup (address, header), packet, normally);
793 }
794 
795 bool
797 {
798  NS_LOG_FUNCTION (this << txVector);
799  WifiMode mode = txVector.GetMode ();
800  //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
801  for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
802  {
803  if (mode == *i)
804  {
805  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
806  return false;
807  }
808  }
809  if (HasHtSupported ())
810  {
811  //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
812  for (WifiModeListIterator i = m_bssBasicMcsSet.begin (); i != m_bssBasicMcsSet.end (); i++)
813  {
814  if (mode == *i)
815  {
816  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
817  return false;
818  }
819  }
820  }
821  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true");
822  return true;
823 }
824 
825 bool
827  Ptr<const Packet> packet)
828 {
829  NS_LOG_FUNCTION (this << address << packet << *header);
830  NS_ASSERT (!address.IsGroup ());
831  WifiRemoteStation *station = Lookup (address, header);
832  bool normally = station->m_ssrc < GetMaxSsrc ();
833  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedDataRetransmission count: " << station->m_ssrc << " result: " << std::boolalpha << normally);
834  return DoNeedRtsRetransmission (station, packet, normally);
835 }
836 
837 bool
839  Ptr<const Packet> packet)
840 {
841  NS_LOG_FUNCTION (this << address << packet << *header);
842  NS_ASSERT (!address.IsGroup ());
843  WifiRemoteStation *station = Lookup (address, header);
844  bool normally = station->m_slrc < GetMaxSlrc ();
845  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedDataRetransmission count: " << station->m_slrc << " result: " << std::boolalpha << normally);
846  return DoNeedDataRetransmission (station, packet, normally);
847 }
848 
849 bool
851  Ptr<const Packet> packet)
852 {
853  NS_LOG_FUNCTION (this << address << packet << *header);
854  if (address.IsGroup ())
855  {
856  return false;
857  }
858  WifiRemoteStation *station = Lookup (address, header);
859  bool normally = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > GetFragmentationThreshold ();
860  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedFragmentation result: " << std::boolalpha << normally);
861  return DoNeedFragmentation (station, packet, normally);
862 }
863 
864 void
866 {
867  NS_LOG_FUNCTION (this << threshold);
868  if (threshold < 256)
869  {
870  /*
871  * ASN.1 encoding of the MAC and PHY MIB (256 ... 8000)
872  */
873  NS_LOG_WARN ("Fragmentation threshold should be larger than 256. Setting to 256.");
875  }
876  else
877  {
878  /*
879  * The length of each fragment shall be an even number of octets, except for the last fragment if an MSDU or
880  * MMPDU, which may be either an even or an odd number of octets.
881  */
882  if (threshold % 2 != 0)
883  {
884  NS_LOG_WARN ("Fragmentation threshold should be an even number. Setting to " << threshold - 1);
885  m_nextFragmentationThreshold = threshold - 1;
886  }
887  else
888  {
889  m_nextFragmentationThreshold = threshold;
890  }
891  }
892 }
893 
894 void
896 {
898 }
899 
900 uint32_t
902 {
904 }
905 
906 uint32_t
908 {
909  NS_LOG_FUNCTION (this << *header << packet);
910  //The number of bytes a fragment can support is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
911  uint32_t nFragments = (packet->GetSize () / (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
912 
913  //If the size of the last fragment is not 0.
914  if ((packet->GetSize () % (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH)) > 0)
915  {
916  nFragments++;
917  }
918  NS_LOG_DEBUG ("WifiRemoteStationManager::GetNFragments returning " << nFragments);
919  return nFragments;
920 }
921 
922 uint32_t
924  Ptr<const Packet> packet, uint32_t fragmentNumber)
925 {
926  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
927  NS_ASSERT (!address.IsGroup ());
928  uint32_t nFragment = GetNFragments (header, packet);
929  if (fragmentNumber >= nFragment)
930  {
931  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning 0");
932  return 0;
933  }
934  //Last fragment
935  if (fragmentNumber == nFragment - 1)
936  {
937  uint32_t lastFragmentSize = packet->GetSize () - (fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
938  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << lastFragmentSize);
939  return lastFragmentSize;
940  }
941  //All fragments but the last, the number of bytes is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
942  else
943  {
944  uint32_t fragmentSize = GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH;
945  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << fragmentSize);
946  return fragmentSize;
947  }
948 }
949 
950 uint32_t
952  Ptr<const Packet> packet, uint32_t fragmentNumber)
953 {
954  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
955  NS_ASSERT (!address.IsGroup ());
956  NS_ASSERT (fragmentNumber < GetNFragments (header, packet));
957  uint32_t fragmentOffset = fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH);
958  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentOffset returning " << fragmentOffset);
959  return fragmentOffset;
960 }
961 
962 bool
964  Ptr<const Packet> packet, uint32_t fragmentNumber)
965 {
966  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
967  NS_ASSERT (!address.IsGroup ());
968  bool isLast = fragmentNumber == (GetNFragments (header, packet) - 1);
969  NS_LOG_DEBUG ("WifiRemoteStationManager::IsLastFragment returning " << std::boolalpha << isLast);
970  return isLast;
971 }
972 
973 WifiMode
975 {
990  NS_LOG_FUNCTION (this << address << reqMode);
991  WifiMode mode = GetDefaultMode ();
992  bool found = false;
993  //First, search the BSS Basic Rate set
994  for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++)
995  {
996  if ((!found || i->GetPhyRate (m_wifiPhy->GetChannelWidth (), m_wifiPhy->GetGuardInterval (), 1) > mode.GetPhyRate (m_wifiPhy->GetChannelWidth (), m_wifiPhy->GetGuardInterval (), 1))
997  && (i->GetPhyRate (m_wifiPhy->GetChannelWidth (), m_wifiPhy->GetGuardInterval (), 1) <= reqMode.GetPhyRate (m_wifiPhy->GetChannelWidth (), m_wifiPhy->GetGuardInterval (), 1))
998  && ((i->GetModulationClass () == reqMode.GetModulationClass ())
999  || (reqMode.GetModulationClass () == WIFI_MOD_CLASS_HT)
1000  || (reqMode.GetModulationClass () == WIFI_MOD_CLASS_VHT)))
1001 
1002  {
1003  mode = *i;
1004  //We've found a potentially-suitable transmit rate, but we
1005  //need to continue and consider all the basic rates before
1006  //we can be sure we've got the right one.
1007  found = true;
1008  }
1009  }
1010  if (HasHtSupported () || HasVhtSupported ())
1011  {
1012  if (!found)
1013  {
1014  mode = GetDefaultMcs ();
1015  for (WifiModeListIterator i = m_bssBasicMcsSet.begin (); i != m_bssBasicMcsSet.end (); i++)
1016  {
1017  if ((!found || i->GetPhyRate (m_wifiPhy->GetChannelWidth (), m_wifiPhy->GetGuardInterval (), 1) > mode.GetPhyRate (m_wifiPhy->GetChannelWidth (), m_wifiPhy->GetGuardInterval (), 1))
1018  && i->GetPhyRate (m_wifiPhy->GetChannelWidth (), m_wifiPhy->GetGuardInterval (), 1) <= reqMode.GetPhyRate (m_wifiPhy->GetChannelWidth (), m_wifiPhy->GetGuardInterval (), 1))
1019  //&& thismode.GetModulationClass () == reqMode.GetModulationClass ()) //TODO: check standard
1020  {
1021  mode = *i;
1022  //We've found a potentially-suitable transmit rate, but we
1023  //need to continue and consider all the basic rates before
1024  //we can be sure we've got the right one.
1025  found = true;
1026  }
1027  }
1028  }
1029  }
1030  //If we found a suitable rate in the BSSBasicRateSet, then we are
1031  //done and can return that mode.
1032  if (found)
1033  {
1034  NS_LOG_DEBUG ("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
1035  return mode;
1036  }
1037 
1055  for (uint32_t idx = 0; idx < m_wifiPhy->GetNModes (); idx++)
1056  {
1057  WifiMode thismode = m_wifiPhy->GetMode (idx);
1058 
1059  /* If the rate:
1060  *
1061  * - is a mandatory rate for the PHY, and
1062  * - is equal to or faster than our current best choice, and
1063  * - is less than or equal to the rate of the received frame, and
1064  * - is of the same modulation class as the received frame
1065  *
1066  * ...then it's our best choice so far.
1067  */
1068  if (thismode.IsMandatory ()
1071  && ((thismode.GetModulationClass () == reqMode.GetModulationClass ())
1072  || (reqMode.GetModulationClass () == WIFI_MOD_CLASS_HT)
1073  || (reqMode.GetModulationClass () == WIFI_MOD_CLASS_HT)))
1074 
1075  {
1076  mode = thismode;
1077  //As above; we've found a potentially-suitable transmit
1078  //rate, but we need to continue and consider all the
1079  //mandatory rates before we can be sure we've got the right one.
1080  found = true;
1081  }
1082  }
1083  if (HasHtSupported () || HasVhtSupported ())
1084  {
1085  for (uint32_t idx = 0; idx < m_wifiPhy->GetNMcs (); idx++)
1086  {
1087  WifiMode thismode = m_wifiPhy->GetMcs (idx);
1088  if (thismode.IsMandatory ()
1091  && thismode.GetModulationClass () == reqMode.GetModulationClass ())
1092  {
1093  mode = thismode;
1094  //As above; we've found a potentially-suitable transmit
1095  //rate, but we need to continue and consider all the
1096  //mandatory rates before we can be sure we've got the right one.
1097  found = true;
1098  }
1099 
1100  }
1101  }
1102 
1113  if (!found)
1114  {
1115  NS_FATAL_ERROR ("Can't find response rate for " << reqMode);
1116  }
1117 
1118  NS_LOG_DEBUG ("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
1119  return mode;
1120 }
1121 
1124 {
1125  NS_ASSERT (!address.IsGroup ());
1126  WifiTxVector v;
1127  v.SetMode (GetControlAnswerMode (address, rtsMode));
1128  v.SetTxPowerLevel (DoGetCtsTxPowerLevel (address, v.GetMode ()));
1129  v.SetChannelWidth (DoGetCtsTxChannelWidth (address, v.GetMode ()));
1130  v.SetShortGuardInterval (DoGetCtsTxGuardInterval (address, v.GetMode ()));
1131  v.SetNss (DoGetCtsTxNss (address, v.GetMode ()));
1132  v.SetNess (DoGetCtsTxNess (address, v.GetMode ()));
1133  v.SetStbc (DoGetCtsTxStbc (address, v.GetMode ()));
1134  return v;
1135 }
1136 
1139 {
1140  NS_ASSERT (!address.IsGroup ());
1141  WifiTxVector v;
1142  v.SetMode (GetControlAnswerMode (address, dataMode));
1143  v.SetTxPowerLevel (DoGetAckTxPowerLevel (address, v.GetMode ()));
1144  v.SetChannelWidth (DoGetAckTxChannelWidth (address, v.GetMode ()));
1145  v.SetShortGuardInterval (DoGetAckTxGuardInterval (address, v.GetMode ()));
1146  v.SetNss (DoGetAckTxNss (address, v.GetMode ()));
1147  v.SetNess (DoGetAckTxNess (address, v.GetMode ()));
1148  v.SetStbc (DoGetAckTxStbc (address, v.GetMode ()));
1149  return v;
1150 }
1151 
1154 {
1155  NS_ASSERT (!address.IsGroup ());
1156  WifiTxVector v;
1157  v.SetMode (GetControlAnswerMode (address, blockAckReqMode));
1158  v.SetTxPowerLevel (DoGetBlockAckTxPowerLevel (address, v.GetMode ()));
1159  v.SetChannelWidth (DoGetBlockAckTxChannelWidth (address, v.GetMode ()));
1160  v.SetShortGuardInterval (DoGetBlockAckTxGuardInterval (address, v.GetMode ()));
1161  v.SetNss (DoGetBlockAckTxNss (address, v.GetMode ()));
1162  v.SetNess (DoGetBlockAckTxNess (address, v.GetMode ()));
1163  v.SetStbc (DoGetBlockAckTxStbc (address, v.GetMode ()));
1164  return v;
1165 }
1166 
1167 uint8_t
1169 {
1170  return m_defaultTxPowerLevel;
1171 }
1172 
1173 uint32_t
1175 {
1176  return m_wifiPhy->GetChannelWidth ();
1177 }
1178 
1179 bool
1181 {
1182  return m_wifiPhy->GetGuardInterval ();
1183 }
1184 
1185 uint8_t
1187 {
1188  return 1;
1189 }
1190 
1191 uint8_t
1193 {
1194  return 0;
1195 }
1196 
1197 bool
1199 {
1200  return m_wifiPhy->GetStbc ();
1201 }
1202 
1203 uint8_t
1205 {
1206  return m_defaultTxPowerLevel;
1207 }
1208 
1209 uint32_t
1211 {
1212  return m_wifiPhy->GetChannelWidth ();
1213 }
1214 
1215 bool
1217 {
1218  return m_wifiPhy->GetGuardInterval ();
1219 }
1220 
1221 uint8_t
1223 {
1224  return 1;
1225 }
1226 
1227 uint8_t
1229 {
1230  return 0;
1231 }
1232 
1233 bool
1235 {
1236  return m_wifiPhy->GetStbc ();
1237 }
1238 
1239 uint8_t
1241 {
1242  return m_defaultTxPowerLevel;
1243 }
1244 
1245 uint32_t
1247 {
1248  return m_wifiPhy->GetChannelWidth ();
1249 }
1250 
1251 bool
1253 {
1254  return m_wifiPhy->GetGuardInterval ();
1255 }
1256 
1257 uint8_t
1259 {
1260  return 1;
1261 }
1262 
1263 uint8_t
1265 {
1266  return 0;
1267 }
1268 
1269 bool
1271 {
1272  return m_wifiPhy->GetStbc ();
1273 }
1274 
1275 uint8_t
1277 {
1278  return m_defaultTxPowerLevel;
1279 }
1280 
1283 {
1284  WifiRemoteStationState *state = LookupState (address);
1285  return state->m_info;
1286 }
1287 
1290 {
1291  NS_LOG_FUNCTION (this << address);
1292  for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
1293  {
1294  if ((*i)->m_address == address)
1295  {
1296  NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning existing state");
1297  return (*i);
1298  }
1299  }
1302  state->m_address = address;
1303  state->m_operationalRateSet.push_back (GetDefaultMode ());
1304  state->m_operationalMcsSet.push_back (GetDefaultMcs ());
1307  state->m_greenfield = m_wifiPhy->GetGreenfield ();
1308  state->m_rx = 1;
1309  state->m_tx = 1;
1310  state->m_ness = 0;
1311  state->m_aggregation = false;
1312  state->m_stbc = false;
1313  const_cast<WifiRemoteStationManager *> (this)->m_states.push_back (state);
1314  NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning new state");
1315  return state;
1316 }
1317 
1320 {
1321  uint8_t tid;
1322  if (header->IsQosData ())
1323  {
1324  tid = header->GetQosTid ();
1325  }
1326  else
1327  {
1328  tid = 0;
1329  }
1330  return Lookup (address, tid);
1331 }
1332 
1335 {
1336  NS_LOG_FUNCTION (this << address << (uint16_t)tid);
1337  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1338  {
1339  if ((*i)->m_tid == tid
1340  && (*i)->m_state->m_address == address)
1341  {
1342  return (*i);
1343  }
1344  }
1345  WifiRemoteStationState *state = LookupState (address);
1346 
1347  WifiRemoteStation *station = DoCreateStation ();
1348  station->m_state = state;
1349  station->m_tid = tid;
1350  station->m_ssrc = 0;
1351  station->m_slrc = 0;
1352  const_cast<WifiRemoteStationManager *> (this)->m_stations.push_back (station);
1353  return station;
1354 }
1355 
1356 void
1358 {
1359  //Used by all stations to record HT capabilities of remote stations
1360  NS_LOG_FUNCTION (this << from << htCapabilities);
1361  WifiRemoteStationState *state;
1362  state = LookupState (from);
1363  state->m_shortGuardInterval = htCapabilities.GetShortGuardInterval20 ();
1364  if (htCapabilities.GetSupportedChannelWidth () == 1)
1365  {
1366  state->m_channelWidth = 40;
1367  }
1368  else
1369  {
1370  state->m_channelWidth = 20;
1371  }
1372  state->m_greenfield = htCapabilities.GetGreenfield ();
1373 }
1374 
1375 void
1377 {
1378  //Used by all stations to record VHT capabilities of remote stations
1379  NS_LOG_FUNCTION (this << from << vhtCapabilities);
1380  WifiRemoteStationState *state;
1381  state = LookupState (from);
1382  if (vhtCapabilities.GetSupportedChannelWidthSet () == 1)
1383  {
1384  state->m_channelWidth = 160;
1385  }
1386  else
1387  {
1388  state->m_channelWidth = 80;
1389  }
1390  //This is a workaround to enable users to force a 20 or 40 MHz channel for a VHT-compliant device,
1391  //since IEEE 802.11ac standard says that 20, 40 and 80 MHz channels are mandatory.
1392  if (m_wifiPhy->GetChannelWidth () < state->m_channelWidth)
1393  {
1395  }
1396 }
1397 
1398 bool
1400 {
1401  return LookupState (address)->m_greenfield;
1402 }
1403 
1404 WifiMode
1406 {
1407  return m_defaultTxMode;
1408 }
1409 
1410 WifiMode
1412 {
1413  return m_defaultTxMcs;
1414 }
1415 
1416 void
1418 {
1419  NS_LOG_FUNCTION (this);
1420  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1421  {
1422  delete (*i);
1423  }
1424  m_stations.clear ();
1425  m_bssBasicRateSet.clear ();
1426  m_bssBasicRateSet.push_back (m_defaultTxMode);
1427  m_bssBasicMcsSet.clear ();
1428  m_bssBasicMcsSet.push_back (m_defaultTxMcs);
1430 }
1431 
1432 void
1434 {
1435  NS_LOG_FUNCTION (this << mode);
1437  {
1438  NS_FATAL_ERROR ("It is not allowed to add a (V)HT rate in the BSSBasicRateSet!");
1439  }
1440  for (uint32_t i = 0; i < GetNBasicModes (); i++)
1441  {
1442  if (GetBasicMode (i) == mode)
1443  {
1444  return;
1445  }
1446  }
1447  m_bssBasicRateSet.push_back (mode);
1448 }
1449 
1450 uint32_t
1452 {
1453  return m_bssBasicRateSet.size ();
1454 }
1455 
1456 WifiMode
1458 {
1459  NS_ASSERT (i < m_bssBasicRateSet.size ());
1460  return m_bssBasicRateSet[i];
1461 }
1462 
1463 void
1465 {
1466  NS_LOG_FUNCTION (this << (uint32_t)mcs.GetMcsValue ());
1467  for (uint32_t i = 0; i < GetNBasicMcs (); i++)
1468  {
1469  if (GetBasicMcs (i) == mcs)
1470  {
1471  return;
1472  }
1473  }
1474  m_bssBasicMcsSet.push_back (mcs);
1475 }
1476 
1477 uint32_t
1479 {
1480  return m_bssBasicMcsSet.size ();
1481 }
1482 
1483 WifiMode
1485 {
1486  NS_ASSERT (i < m_bssBasicMcsSet.size ());
1487  return m_bssBasicMcsSet[i];
1488 }
1489 
1490 WifiMode
1492 {
1493  if (m_nonUnicastMode == WifiMode ())
1494  {
1495  return GetBasicMode (0);
1496  }
1497  else
1498  {
1499  return m_nonUnicastMode;
1500  }
1501 }
1502 
1503 bool
1505  Ptr<const Packet> packet, bool normally)
1506 {
1507  return normally;
1508 }
1509 
1510 bool
1512  Ptr<const Packet> packet, bool normally)
1513 {
1514  return normally;
1515 }
1516 
1517 bool
1519  Ptr<const Packet> packet, bool normally)
1520 {
1521  return normally;
1522 }
1523 
1524 bool
1526  Ptr<const Packet> packet, bool normally)
1527 {
1528  return normally;
1529 }
1530 
1531 WifiMode
1533 {
1534  NS_ASSERT (i < GetNSupported (station));
1535  return station->m_state->m_operationalRateSet[i];
1536 }
1537 
1538 WifiMode
1540 {
1541  NS_ASSERT (i < GetNMcsSupported (station));
1542  return station->m_state->m_operationalMcsSet[i];
1543 }
1544 
1545 uint32_t
1547 {
1548  return station->m_state->m_channelWidth;
1549 }
1550 
1551 bool
1553 {
1554  return station->m_state->m_shortGuardInterval;
1555 }
1556 
1557 bool
1559 {
1560  return station->m_state->m_greenfield;
1561 }
1562 
1563 bool
1565 {
1566  return station->m_state->m_aggregation;
1567 }
1568 
1569 bool
1571 {
1572  return station->m_state->m_stbc;
1573 }
1574 
1575 uint32_t
1577 {
1578  return station->m_state->m_rx;
1579 }
1580 
1581 uint32_t
1583 {
1584  return station->m_state->m_tx;
1585 }
1586 
1587 uint32_t
1589 {
1590  return station->m_state->m_ness;
1591 }
1592 
1593 uint32_t
1595 {
1596  return station->m_ssrc;
1597 }
1598 
1601 {
1602  return m_wifiPhy;
1603 }
1604 
1607 {
1608  return m_wifiMac;
1609 }
1610 
1611 uint32_t
1613 {
1614  return station->m_slrc;
1615 }
1616 
1617 uint32_t
1619 {
1620  return station->m_state->m_operationalRateSet.size ();
1621 }
1622 
1623 uint32_t
1625 {
1626  return station->m_state->m_operationalMcsSet.size ();
1627 }
1628 
1629 void
1631 {
1632  m_defaultTxPowerLevel = txPower;
1633 }
1634 
1635 uint32_t
1637 {
1639 }
1640 
1642  : m_memoryTime (Seconds (1.0)),
1643  m_lastUpdate (Seconds (0.0)),
1644  m_failAvg (0.0)
1645 {
1646 }
1647 
1648 double
1650 {
1651  double retval = std::exp ((double)(m_lastUpdate.GetMicroSeconds () - Simulator::Now ().GetMicroSeconds ())
1652  / (double)m_memoryTime.GetMicroSeconds ());
1654  return retval;
1655 }
1656 
1657 void
1659 {
1660  double coefficient = CalculateAveragingCoefficient ();
1661  m_failAvg = (double)retryCounter / (1 + (double)retryCounter) * (1.0 - coefficient) + coefficient * m_failAvg;
1662 }
1663 
1664 void
1666 {
1667  double coefficient = CalculateAveragingCoefficient ();
1668  m_failAvg = (1.0 - coefficient) + coefficient * m_failAvg;
1669 }
1670 
1671 double
1673 {
1674  return m_failAvg;
1675 }
1676 
1678 {
1679  NS_LOG_FUNCTION (this);
1680 }
1681 
1682 } //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
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.
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 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
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
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 green field 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.