A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
22 #include "ns3/simulator.h"
23 #include "ns3/assert.h"
24 #include "ns3/log.h"
25 #include "ns3/tag.h"
26 #include "ns3/boolean.h"
27 #include "ns3/double.h"
28 #include "ns3/uinteger.h"
29 #include "ns3/wifi-phy.h"
30 #include "ns3/trace-source-accessor.h"
31 #include "wifi-mac-header.h"
32 #include "wifi-mac-trailer.h"
33 
34 NS_LOG_COMPONENT_DEFINE ("WifiRemoteStationManager");
35 
36 
37 /***************************************************************
38  * Packet Mode Tagger
39  ***************************************************************/
40 
41 namespace ns3 {
42 
44 {
45 public:
51  WifiTxVector GetDataTxVector (void) const;
52 
53  static TypeId GetTypeId (void);
54  virtual TypeId GetInstanceTypeId (void) const;
55  virtual uint32_t GetSerializedSize (void) const;
56  virtual void Serialize (TagBuffer i) const;
57  virtual void Deserialize (TagBuffer i);
58  virtual void Print (std::ostream &os) const;
59 private:
61 };
62 
64 {
65 }
67  : m_dataTxVector (dataTxVector)
68 {
69 }
70 
73 {
74  return m_dataTxVector;
75 }
76 TypeId
78 {
79  static TypeId tid = TypeId ("ns3::HighLatencyDataTxVectorTag")
80  .SetParent<Tag> ()
81  .AddConstructor<HighLatencyDataTxVectorTag> ()
82  ;
83  return tid;
84 }
85 TypeId
87 {
88  return GetTypeId ();
89 }
90 uint32_t
92 {
93  return sizeof (WifiTxVector);
94 }
95 void
97 {
98  i.Write ((uint8_t *)&m_dataTxVector, sizeof (WifiTxVector));
99 }
100 void
102 {
103  i.Read ((uint8_t *)&m_dataTxVector, sizeof (WifiTxVector));
104 }
105 void
106 HighLatencyDataTxVectorTag::Print (std::ostream &os) const
107 {
108  os << "Data=" << m_dataTxVector;
109 }
110 
112 {
113 public:
120  WifiTxVector GetRtsTxVector (void) const;
121 
122  static TypeId GetTypeId (void);
123  virtual TypeId GetInstanceTypeId (void) const;
124  virtual uint32_t GetSerializedSize (void) const;
125  virtual void Serialize (TagBuffer i) const;
126  virtual void Deserialize (TagBuffer i);
127  virtual void Print (std::ostream &os) const;
128 private:
130 };
131 
133 {
134 }
136  : m_rtsTxVector (rtsTxVector)
137 {
138 }
139 
142 {
143  return m_rtsTxVector;
144 }
145 TypeId
147 {
148  static TypeId tid = TypeId ("ns3::HighLatencyRtsTxVectorTag")
149  .SetParent<Tag> ()
150  .AddConstructor<HighLatencyRtsTxVectorTag> ()
151  ;
152  return tid;
153 }
154 TypeId
156 {
157  return GetTypeId ();
158 }
159 uint32_t
161 {
162  return sizeof (WifiTxVector);
163 }
164 void
166 {
167  i.Write ((uint8_t *)&m_rtsTxVector, sizeof (WifiTxVector));
168 }
169 void
171 {
172  i.Read ((uint8_t *)&m_rtsTxVector, sizeof (WifiTxVector));
173 }
174 void
175 HighLatencyRtsTxVectorTag::Print (std::ostream &os) const
176 {
177  os << "Rts=" << m_rtsTxVector;
178 }
179 
181 {
182 public:
184  HighLatencyCtsToSelfTxVectorTag (WifiTxVector ctsToSelfTxVector);
188  WifiTxVector GetCtsToSelfTxVector (void) const;
189 
190  static TypeId GetTypeId (void);
191  virtual TypeId GetInstanceTypeId (void) const;
192  virtual uint32_t GetSerializedSize (void) const;
193  virtual void Serialize (TagBuffer i) const;
194  virtual void Deserialize (TagBuffer i);
195  virtual void Print (std::ostream &os) const;
196 private:
198 };
199 
201 {
202 }
204  : m_ctsToSelfTxVector (ctsToSelfTxVector)
205 {
206 }
207 
210 {
211  return m_ctsToSelfTxVector;
212 }
213 TypeId
215 {
216  static TypeId tid = TypeId ("ns3::HighLatencyCtsToSelfTxVectorTag")
217  .SetParent<Tag> ()
218  .AddConstructor<HighLatencyCtsToSelfTxVectorTag> ()
219  ;
220  return tid;
221 }
222 TypeId
224 {
225  return GetTypeId ();
226 }
227 uint32_t
229 {
230  return sizeof (WifiTxVector);
231 }
232 void
234 {
235  i.Write ((uint8_t *)&m_ctsToSelfTxVector, sizeof (WifiTxVector));
236 }
237 void
239 {
240  i.Read ((uint8_t *)&m_ctsToSelfTxVector, sizeof (WifiTxVector));
241 }
242 void
244 {
245  os << "Cts To Self=" << m_ctsToSelfTxVector;
246 }
247 
248 } // namespace ns3
249 
250 namespace ns3 {
251 
252 NS_OBJECT_ENSURE_REGISTERED (WifiRemoteStationManager)
253  ;
254 
255 TypeId
257 {
258  static TypeId tid = TypeId ("ns3::WifiRemoteStationManager")
259  .SetParent<Object> ()
260  .AddAttribute ("IsLowLatency", "If true, we attempt to modelize a so-called low-latency device: a device"
261  " where decisions about tx parameters can be made on a per-packet basis and feedback about the"
262  " transmission of each packet is obtained before sending the next. Otherwise, we modelize a "
263  " high-latency device, that is a device where we cannot update our decision about tx parameters"
264  " after every packet transmission.",
265  BooleanValue (true), // this value is ignored because there is no setter
266  MakeBooleanAccessor (&WifiRemoteStationManager::IsLowLatency),
267  MakeBooleanChecker ())
268  .AddAttribute ("MaxSsrc", "The maximum number of retransmission attempts for an RTS. This value"
269  " will not have any effect on some rate control algorithms.",
270  UintegerValue (7),
271  MakeUintegerAccessor (&WifiRemoteStationManager::m_maxSsrc),
272  MakeUintegerChecker<uint32_t> ())
273  .AddAttribute ("MaxSlrc", "The maximum number of retransmission attempts for a DATA packet. This value"
274  " will not have any effect on some rate control algorithms.",
275  UintegerValue (7),
276  MakeUintegerAccessor (&WifiRemoteStationManager::m_maxSlrc),
277  MakeUintegerChecker<uint32_t> ())
278  .AddAttribute ("RtsCtsThreshold", "If the size of the data packet + LLC header + MAC header + FCS trailer is bigger than "
279  "this value, we use an RTS/CTS handshake before sending the data, as per IEEE Std. 802.11-2007, Section 9.2.6. "
280  "This value will not have any effect on some rate control algorithms.",
281  UintegerValue (2346),
282  MakeUintegerAccessor (&WifiRemoteStationManager::m_rtsCtsThreshold),
283  MakeUintegerChecker<uint32_t> ())
284  .AddAttribute ("FragmentationThreshold", "If the size of the data packet + LLC header + MAC header + FCS trailer is bigger"
285  "than this value, we fragment it such that the size of the fragments are equal or smaller "
286  "than this value, as per IEEE Std. 802.11-2007, Section 9.4. "
287  "This value will not have any effect on some rate control algorithms.",
288  UintegerValue (2346),
291  MakeUintegerChecker<uint32_t> ())
292  .AddAttribute ("NonUnicastMode", "Wifi mode used for non-unicast transmissions.",
293  WifiModeValue (),
294  MakeWifiModeAccessor (&WifiRemoteStationManager::m_nonUnicastMode),
295  MakeWifiModeChecker ())
296  .AddAttribute ("DefaultTxPowerLevel", "Default power level to be used for transmissions. "
297  "This is the power level that is used by all those WifiManagers that do not"
298  "implement TX power control.",
299  UintegerValue (0),
300  MakeUintegerAccessor (&WifiRemoteStationManager::m_defaultTxPowerLevel),
301  MakeUintegerChecker<uint8_t> ())
302  .AddTraceSource ("MacTxRtsFailed",
303  "The transmission of a RTS by the MAC layer has failed",
305  .AddTraceSource ("MacTxDataFailed",
306  "The transmission of a data packet by the MAC layer has failed",
308  .AddTraceSource ("MacTxFinalRtsFailed",
309  "The transmission of a RTS has exceeded the maximum number of attempts",
311  .AddTraceSource ("MacTxFinalDataFailed",
312  "The transmission of a data packet has exceeded the maximum number of attempts",
314  ;
315  return tid;
316 }
317 
319 {
320 }
321 
323 {
324 }
325 void
327 {
328  for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
329  {
330  delete (*i);
331  }
332  m_states.clear ();
333  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
334  {
335  delete (*i);
336  }
337  m_stations.clear ();
338 }
339 void
341 {
342  // We need to track our PHY because it is the object that knows the
343  // full set of transmit rates that are supported. We need to know
344  // this in order to find the relevant mandatory rates when chosing a
345  // transmit rate for automatic control responses like
346  // acknowledgements.
347  m_wifiPhy = phy;
348  m_defaultTxMode = phy->GetMode (0);
349  if(HasHtSupported())
350  {
351  m_defaultTxMcs = phy->GetMcs (0);
352  }
353  else
354  {
355  m_defaultTxMcs = 0;
356  }
357  Reset ();
358 }
359 void
361 {
362  m_htSupported=enable;
363 }
364 
365 bool
367 {
368  return m_htSupported;
369 }
370 uint32_t
372 {
373  return m_maxSsrc;
374 }
375 uint32_t
377 {
378  return m_maxSlrc;
379 }
380 uint32_t
382 {
383  return m_rtsCtsThreshold;
384 }
385 uint32_t
387 {
388  return DoGetFragmentationThreshold ();
389 }
390 void
392 {
393  m_maxSsrc = maxSsrc;
394 }
395 void
397 {
398  m_maxSlrc = maxSlrc;
399 }
400 void
402 {
403  m_rtsCtsThreshold = threshold;
404 }
405 void
407 {
408  DoSetFragmentationThreshold (threshold);
409 }
410 
411 void
413 {
414  NS_ASSERT (!address.IsGroup ());
415  WifiRemoteStationState *state = LookupState (address);
416  state->m_operationalRateSet.clear ();
417  state->m_operationalMcsSet.clear ();
418  AddSupportedMode (address, GetDefaultMode ());
419  AddSupportedMcs(address,GetDefaultMcs());
420 }
421 void
423 {
424  NS_ASSERT (!address.IsGroup ());
425  WifiRemoteStationState *state = LookupState (address);
426  for (WifiModeListIterator i = state->m_operationalRateSet.begin (); i != state->m_operationalRateSet.end (); i++)
427  {
428  if ((*i) == mode)
429  {
430  // already in.
431  return;
432  }
433  }
434  state->m_operationalRateSet.push_back (mode);
435 }
436 /*void
437 WifiRemoteStationManager::AddBssMembershipParameters(Mac48Address address, uint32_t selector)
438 {
439  NS_ASSERT (!address.IsGroup ());
440  WifiRemoteStationState *state = LookupState (address);
441  WifiMode mode;
442  WifiModeList membershipselectormodes = m_wifiPhy->GetMembershipSelectorModes(selector);
443  for (WifiModeListIterator j = membershipselectormodes.begin (); j != membershipselectormodes.end (); j++)
444  {
445  mode=(*j);
446  for (WifiModeListIterator i = state->m_operationalRateSet.begin (); i != state->m_operationalRateSet.end (); i++)
447  {
448  if ((*i) == mode)
449  {
450  // already in.
451  break;
452  }
453  }
454  state->m_operationalRateSet.push_back (mode);
455  }
456 }*/
457 void
459 {
460  NS_ASSERT (!address.IsGroup ());
461  WifiRemoteStationState *state = LookupState (address);
462  for (WifiMcsListIterator i = state->m_operationalMcsSet.begin (); i != state->m_operationalMcsSet.end (); i++)
463  {
464  if ((*i) == mcs)
465  {
466  // already in.
467  return;
468  }
469  }
470  state->m_operationalMcsSet.push_back (mcs);
471 }
472 bool
474 {
475  if (address.IsGroup ())
476  {
477  return false;
478  }
480 }
481 bool
483 {
484  if (address.IsGroup ())
485  {
486  return true;
487  }
489 }
490 bool
492 {
493  if (address.IsGroup ())
494  {
495  return false;
496  }
498 }
499 void
501 {
502  NS_ASSERT (!address.IsGroup ());
504 }
505 void
507 {
508  NS_ASSERT (!address.IsGroup ());
510 }
511 void
513 {
514  NS_ASSERT (!address.IsGroup ());
516 }
517 void
519 {
520  NS_ASSERT (!address.IsGroup ());
522 }
523 void
525  Ptr<const Packet> packet, uint32_t fullPacketSize)
526 {
527  if (IsLowLatency () || address.IsGroup ())
528  {
529  return;
530  }
531  WifiRemoteStation *station = Lookup (address, header);
532  WifiTxVector rts = DoGetRtsTxVector (station);
533  WifiTxVector data = DoGetDataTxVector (station, fullPacketSize);
534  WifiTxVector ctstoself = DoGetCtsToSelfTxVector ();
537  HighLatencyCtsToSelfTxVectorTag ctstoselftag;
538  // first, make sure that the tag is not here anymore.
539  ConstCast<Packet> (packet)->RemovePacketTag (datatag);
540  ConstCast<Packet> (packet)->RemovePacketTag (rtstag);
541  ConstCast<Packet> (packet)->RemovePacketTag (ctstoselftag);
542  datatag = HighLatencyDataTxVectorTag (data);
543  rtstag = HighLatencyRtsTxVectorTag (rts);
544  ctstoselftag = HighLatencyCtsToSelfTxVectorTag (ctstoself);
545  // and then, add it back
546  packet->AddPacketTag (datatag);
547  packet->AddPacketTag (rtstag);
548  packet->AddPacketTag (ctstoselftag);
549 }
552  Ptr<const Packet> packet, uint32_t fullPacketSize)
553 {
554  if (address.IsGroup ())
555  {
556  WifiTxVector v;
557  v.SetMode (GetNonUnicastMode ());
559  v.SetShortGuardInterval (false);
560  v.SetNss (1);
561  v.SetNess (0);
562  v.SetStbc (false);
563  return v;
564  }
565  if (!IsLowLatency ())
566  {
568  bool found;
569  found = ConstCast<Packet> (packet)->PeekPacketTag (datatag);
570  NS_ASSERT (found);
571  // cast found to void, to suppress 'found' set but not used
572  // compiler warning
573  (void) found;
574  return datatag.GetDataTxVector ();
575  }
576  return DoGetDataTxVector (Lookup (address, header), fullPacketSize);
577 }
580  Ptr<const Packet> packet)
581 {
582 
583  if (!IsLowLatency ())
584  {
585  HighLatencyCtsToSelfTxVectorTag ctstoselftag;
586  bool found;
587  found = ConstCast<Packet> (packet)->PeekPacketTag (ctstoselftag);
588  NS_ASSERT (found);
589  // cast found to void, to suppress 'found' set but not used
590  // compiler warning
591  (void) found;
592  return ctstoselftag.GetCtsToSelfTxVector ();
593  }
594  return DoGetCtsToSelfTxVector ();
595 }
596 
599 {
601 }
602 
605  Ptr<const Packet> packet)
606 {
607  NS_ASSERT (!address.IsGroup ());
608  if (!IsLowLatency ())
609  {
611  bool found;
612  found = ConstCast<Packet> (packet)->PeekPacketTag (rtstag);
613  NS_ASSERT (found);
614  // cast found to void, to suppress 'found' set but not used
615  // compiler warning
616  (void) found;
617  return rtstag.GetRtsTxVector ();
618  }
619  return DoGetRtsTxVector (Lookup (address, header));
620 }
621 void
623 {
624  NS_ASSERT (!address.IsGroup ());
625  WifiRemoteStation *station = Lookup (address, header);
626  station->m_ssrc++;
627  m_macTxRtsFailed (address);
628  DoReportRtsFailed (station);
629 }
630 void
632 {
633  NS_ASSERT (!address.IsGroup ());
634  WifiRemoteStation *station = Lookup (address, header);
635  station->m_slrc++;
636  m_macTxDataFailed (address);
637  DoReportDataFailed (station);
638 }
639 void
641  double ctsSnr, WifiMode ctsMode, double rtsSnr)
642 {
643  NS_ASSERT (!address.IsGroup ());
644  WifiRemoteStation *station = Lookup (address, header);
645  station->m_state->m_info.NotifyTxSuccess (station->m_ssrc);
646  station->m_ssrc = 0;
647  DoReportRtsOk (station, ctsSnr, ctsMode, rtsSnr);
648 }
649 void
651  double ackSnr, WifiMode ackMode, double dataSnr)
652 {
653  NS_ASSERT (!address.IsGroup ());
654  WifiRemoteStation *station = Lookup (address, header);
655  station->m_state->m_info.NotifyTxSuccess (station->m_slrc);
656  station->m_slrc = 0;
657  DoReportDataOk (station, ackSnr, ackMode, dataSnr);
658 }
659 void
661 {
662  NS_ASSERT (!address.IsGroup ());
663  WifiRemoteStation *station = Lookup (address, header);
664  station->m_state->m_info.NotifyTxFailed ();
665  station->m_ssrc = 0;
666  m_macTxFinalRtsFailed (address);
667  DoReportFinalRtsFailed (station);
668 }
669 void
671 {
672  NS_ASSERT (!address.IsGroup ());
673  WifiRemoteStation *station = Lookup (address, header);
674  station->m_state->m_info.NotifyTxFailed ();
675  station->m_slrc = 0;
676  m_macTxFinalDataFailed (address);
677  DoReportFinalDataFailed (station);
678 }
679 void
681  double rxSnr, WifiMode txMode)
682 {
683  if (address.IsGroup ())
684  {
685  return;
686  }
687  WifiRemoteStation *station = Lookup (address, header);
688  DoReportRxOk (station, rxSnr, txMode);
689 }
690 bool
692  Ptr<const Packet> packet)
693 {
694  if (address.IsGroup ())
695  {
696  return false;
697  }
698  bool normally = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > GetRtsCtsThreshold ();
699  return DoNeedRts (Lookup (address, header), packet, normally);
700 }
701 bool
703 {
704  WifiMode mode = txVector.GetMode();
705 
706  // search the BSS Basic Rate set if the used mode in the basic set then no need for Cts to self
707  for (WifiModeListIterator i = m_bssBasicRateSet.begin ();
708  i != m_bssBasicRateSet.end (); i++)
709  {
710  if (mode == *i)
711  {
712  return false;
713  }
714  }
715  if (HasHtSupported())
716  {
717  uint8_t mcs = m_wifiPhy->WifiModeToMcs (mode);
718  for (WifiMcsListIterator i = m_bssBasicMcsSet.begin ();
719  i != m_bssBasicMcsSet.end (); i++)
720  {
721  if (mcs == *i)
722  {
723  return false;
724  }
725  }
726  }
727  return true;
728 }
729 bool
731  Ptr<const Packet> packet)
732 {
733  NS_ASSERT (!address.IsGroup ());
734  WifiRemoteStation *station = Lookup (address, header);
735  bool normally = station->m_ssrc < GetMaxSsrc ();
736  return DoNeedRtsRetransmission (station, packet, normally);
737 }
738 bool
740  Ptr<const Packet> packet)
741 {
742  NS_ASSERT (!address.IsGroup ());
743  WifiRemoteStation *station = Lookup (address, header);
744  bool normally = station->m_slrc < GetMaxSlrc ();
745  return DoNeedDataRetransmission (station, packet, normally);
746 }
747 bool
749  Ptr<const Packet> packet)
750 {
751  if (address.IsGroup ())
752  {
753  return false;
754  }
755  WifiRemoteStation *station = Lookup (address, header);
756  bool normally = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > GetFragmentationThreshold ();
757  return DoNeedFragmentation (station, packet, normally);
758 }
759 
760 void
762 {
763  if (threshold < 256)
764  {
765  /*
766  * ASN.1 encoding of the MAC and PHY MIB (256 ... 8000)
767  */
768  NS_LOG_WARN ("Fragmentation threshold should be larger than 256. Setting to 256.");
770  }
771  else
772  {
773  /*
774  * The length of each fragment shall be an even number of octets, except for the last fragment if an MSDU or
775  * MMPDU, which may be either an even or an odd number of octets.
776  */
777  if (threshold % 2 != 0)
778  {
779  NS_LOG_WARN ("Fragmentation threshold should be an even number. Setting to " << threshold - 1);
780  m_fragmentationThreshold = threshold - 1;
781  }
782  else
783  {
784  m_fragmentationThreshold = threshold;
785  }
786  }
787 }
788 
789 uint32_t
791 {
793 }
794 
795 uint32_t
797 {
798  //The number of bytes a fragment can support is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
799  uint32_t nFragments = (packet->GetSize () / (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
800 
801  //If the size of the last fragment is not 0.
802  if ((packet->GetSize () % (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH)) > 0)
803  {
804  nFragments++;
805  }
806  return nFragments;
807 }
808 
809 uint32_t
811  Ptr<const Packet> packet, uint32_t fragmentNumber)
812 {
813  NS_ASSERT (!address.IsGroup ());
814  uint32_t nFragment = GetNFragments (header, packet);
815  if (fragmentNumber >= nFragment)
816  {
817  return 0;
818  }
819  //Last fragment
820  if (fragmentNumber == nFragment - 1)
821  {
822  uint32_t lastFragmentSize = packet->GetSize () - (fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
823  return lastFragmentSize;
824  }
825  //All fragments but the last, the number of bytes is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
826  else
827  {
828  return GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH;
829  }
830 }
831 uint32_t
833  Ptr<const Packet> packet, uint32_t fragmentNumber)
834 {
835  NS_ASSERT (!address.IsGroup ());
836  NS_ASSERT (fragmentNumber < GetNFragments (header, packet));
837  uint32_t fragmentOffset = fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH);
838  return fragmentOffset;
839 }
840 bool
842  Ptr<const Packet> packet, uint32_t fragmentNumber)
843 {
844  NS_ASSERT (!address.IsGroup ());
845  bool isLast = fragmentNumber == (GetNFragments (header, packet) - 1);
846  return isLast;
847 }
848 WifiMode
850 {
865  WifiMode mode = GetDefaultMode ();
866  bool found = false;
867 
868  // First, search the BSS Basic Rate set
869  for (WifiModeListIterator i = m_bssBasicRateSet.begin ();
870  i != m_bssBasicRateSet.end (); i++)
871  {
872  if ((!found || i->GetPhyRate () > mode.GetPhyRate ())
873  && i->GetPhyRate () <= reqMode.GetPhyRate ()
874  && i->GetModulationClass () == reqMode.GetModulationClass ())
875  {
876  mode = *i;
877  // We've found a potentially-suitable transmit rate, but we
878  // need to continue and consider all the basic rates before
879  // we can be sure we've got the right one.
880  found = true;
881  }
882  }
883  if(HasHtSupported())
884  {
885  if (!found)
886  {
887  uint8_t mcs = GetDefaultMcs ();
888  mode= m_wifiPhy->McsToWifiMode (mcs);
889  }
890  for (WifiMcsListIterator i = m_bssBasicMcsSet.begin ();
891  i != m_bssBasicMcsSet.end (); i++)
892  {
893  WifiMode thismode= m_wifiPhy->McsToWifiMode (*i);
894  if ((!found || thismode.GetPhyRate () > mode.GetPhyRate ())
895  && thismode.GetPhyRate () <= reqMode.GetPhyRate ()
896  && thismode.GetModulationClass () == reqMode.GetModulationClass ())
897  {
898  mode = thismode;
899  // We've found a potentially-suitable transmit rate, but we
900  // need to continue and consider all the basic rates before
901  // we can be sure we've got the right one.
902  found = true;
903  }
904  }
905  }
906  // If we found a suitable rate in the BSSBasicRateSet, then we are
907  // done and can return that mode.
908  if (found)
909  {
910  return mode;
911  }
912 
930  for (uint32_t idx = 0; idx < m_wifiPhy->GetNModes (); idx++)
931  {
932  WifiMode thismode = m_wifiPhy->GetMode (idx);
933 
934  /* If the rate:
935  *
936  * - is a mandatory rate for the PHY, and
937  * - is equal to or faster than our current best choice, and
938  * - is less than or equal to the rate of the received frame, and
939  * - is of the same modulation class as the received frame
940  *
941  * ...then it's our best choice so far.
942  */
943  if (thismode.IsMandatory ()
944  && (!found || thismode.GetPhyRate () > mode.GetPhyRate ())
945  && thismode.GetPhyRate () <= reqMode.GetPhyRate ()
946  && thismode.GetModulationClass () == reqMode.GetModulationClass ())
947  {
948  mode = thismode;
949  // As above; we've found a potentially-suitable transmit
950  // rate, but we need to continue and consider all the
951  // mandatory rates before we can be sure we've got the right
952  // one.
953  found = true;
954  }
955  }
956  if(HasHtSupported())
957  {
958  for (uint32_t idx = 0; idx < m_wifiPhy->GetNMcs (); idx++)
959  {
960  uint8_t thismcs = m_wifiPhy->GetMcs (idx);
961  WifiMode thismode= m_wifiPhy->McsToWifiMode (thismcs);
962  if (thismode.IsMandatory ()
963  && (!found || thismode.GetPhyRate () > mode.GetPhyRate ())
964  && thismode.GetPhyRate () <= reqMode.GetPhyRate ()
965  && thismode.GetModulationClass () == reqMode.GetModulationClass ())
966  {
967  mode = thismode;
968  // As above; we've found a potentially-suitable transmit
969  // rate, but we need to continue and consider all the
970  // mandatory rates before we can be sure we've got the right
971  // one.
972  found = true;
973  }
974 
975  }
976  }
977 
988  if (!found)
989  {
990  NS_FATAL_ERROR ("Can't find response rate for " << reqMode
991  << ". Check standard and selected rates match.");
992  }
993 
994  return mode;
995 }
996 
999 {
1000  NS_ASSERT (!address.IsGroup ());
1001  WifiTxVector v;
1002  v.SetMode (GetControlAnswerMode (address, rtsMode));
1003  v.SetTxPowerLevel (DoGetCtsTxPowerLevel (address, v.GetMode()));
1004  v.SetShortGuardInterval (DoGetCtsTxGuardInterval(address, v.GetMode()));
1005  v.SetNss (DoGetCtsTxNss(address, v.GetMode()));
1006  v.SetNess (DoGetCtsTxNess(address, v.GetMode()));
1007  v.SetStbc (DoGetCtsTxStbc(address, v.GetMode()));
1008  return v;
1009 }
1012 {
1013  NS_ASSERT (!address.IsGroup ());
1014  WifiTxVector v;
1015  v.SetMode (GetControlAnswerMode (address, dataMode));
1016  v.SetTxPowerLevel (DoGetAckTxPowerLevel (address, v.GetMode()));
1017  v.SetShortGuardInterval(DoGetAckTxGuardInterval(address, v.GetMode()));
1018  v.SetNss(DoGetAckTxNss(address, v.GetMode()));
1019  v.SetNess(DoGetAckTxNess(address, v.GetMode()));
1020  v.SetStbc(DoGetAckTxStbc(address, v.GetMode()));
1021  return v;
1022 }
1025 {
1026  NS_ASSERT (!address.IsGroup ());
1027  WifiTxVector v;
1028  v.SetMode (GetControlAnswerMode (address, blockAckReqMode));
1029  v.SetTxPowerLevel (DoGetBlockAckTxPowerLevel (address, v.GetMode()));
1030  v.SetShortGuardInterval (DoGetBlockAckTxGuardInterval(address, v.GetMode()));
1031  v.SetNss (DoGetBlockAckTxNss(address, v.GetMode()));
1032  v.SetNess (DoGetBlockAckTxNess(address, v.GetMode()));
1033  v.SetStbc (DoGetBlockAckTxStbc(address, v.GetMode()));
1034  return v;
1035 }
1036 
1037 uint8_t
1039 {
1040  return m_defaultTxPowerLevel;
1041 }
1042 
1043 bool
1045 {
1046  return m_wifiPhy->GetGuardInterval();
1047 }
1048 
1049 uint8_t
1051 {
1052  return 1;
1053 }
1054 uint8_t
1056 {
1057  return 0;
1058 }
1059 bool
1061 {
1062  return m_wifiPhy->GetStbc();
1063 }
1064 
1065 uint8_t
1067 {
1068  return m_defaultTxPowerLevel;
1069 }
1070 
1071 bool
1073 {
1074  return m_wifiPhy->GetGuardInterval();
1075 }
1076 
1077 uint8_t
1079 {
1080  return 1;
1081 }
1082 uint8_t
1084 {
1085  return 0;
1086 }
1087 bool
1089 {
1090  return m_wifiPhy->GetStbc();
1091 }
1092 
1093 uint8_t
1095 {
1096  return m_defaultTxPowerLevel;
1097 }
1098 
1099 bool
1101 {
1102  return m_wifiPhy->GetGuardInterval();
1103 }
1104 
1105 uint8_t
1107 {
1108  return 1;
1109 }
1110 uint8_t
1112 {
1113  return 0;
1114 }
1115 bool
1117 {
1118  return m_wifiPhy->GetStbc();
1119 }
1120 
1121 
1122 uint8_t
1124 {
1125  return m_defaultTxPowerLevel;
1126 }
1127 
1128 
1131 {
1132  WifiRemoteStationState *state = LookupState (address);
1133  return state->m_info;
1134 }
1135 
1138 {
1139  for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
1140  {
1141  if ((*i)->m_address == address)
1142  {
1143  return (*i);
1144  }
1145  }
1148  state->m_address = address;
1149  state->m_operationalRateSet.push_back (GetDefaultMode ());
1150  state->m_operationalMcsSet.push_back(GetDefaultMcs());
1153  state->m_rx=1;
1154  state->m_tx=1;
1155  state->m_stbc=false;
1156  const_cast<WifiRemoteStationManager *> (this)->m_states.push_back (state);
1157  return state;
1158 }
1161 {
1162  uint8_t tid;
1163  if (header->IsQosData ())
1164  {
1165  tid = header->GetQosTid ();
1166  }
1167  else
1168  {
1169  tid = 0;
1170  }
1171  return Lookup (address, tid);
1172 }
1175 {
1176  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1177  {
1178  if ((*i)->m_tid == tid
1179  && (*i)->m_state->m_address == address)
1180  {
1181  return (*i);
1182  }
1183  }
1184  WifiRemoteStationState *state = LookupState (address);
1185 
1186  WifiRemoteStation *station = DoCreateStation ();
1187  station->m_state = state;
1188  station->m_tid = tid;
1189  station->m_ssrc = 0;
1190  station->m_slrc = 0;
1191  // XXX
1192  const_cast<WifiRemoteStationManager *> (this)->m_stations.push_back (station);
1193  return station;
1194 
1195 }
1196 //Used by all stations to record HT capabilities of remote stations
1197 void
1199 {
1200  WifiRemoteStationState *state;
1201  state=LookupState (from);
1202  state->m_shortGuardInterval=htcapabilities.GetShortGuardInterval20();
1203  state->m_greenfield=htcapabilities.GetGreenfield();
1204 
1205 }
1206 //Used by mac low to choose format used GF, MF or Non HT
1207 bool
1209 {
1210  return LookupState(address)->m_greenfield;
1211 }
1212 WifiMode
1214 {
1215  return m_defaultTxMode;
1216 }
1217 uint8_t
1219 {
1220  return m_defaultTxMcs;
1221 }
1222 void
1224 {
1225  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1226  {
1227  delete (*i);
1228  }
1229  m_stations.clear ();
1230  m_bssBasicRateSet.clear ();
1231  m_bssBasicRateSet.push_back (m_defaultTxMode);
1232  m_bssBasicMcsSet.clear();
1233  m_bssBasicMcsSet.push_back (m_defaultTxMcs);
1235 }
1236 void
1238 {
1239  for (uint32_t i = 0; i < GetNBasicModes (); i++)
1240  {
1241  if (GetBasicMode (i) == mode)
1242  {
1243  return;
1244  }
1245  }
1246  m_bssBasicRateSet.push_back (mode);
1247 }
1248 uint32_t
1250 {
1251  return m_bssBasicRateSet.size ();
1252 }
1253 WifiMode
1255 {
1256  NS_ASSERT (i < m_bssBasicRateSet.size ());
1257  return m_bssBasicRateSet[i];
1258 }
1259 
1260 void
1262 {
1263  for (uint32_t i = 0; i < GetNBasicMcs (); i++)
1264  {
1265  if (GetBasicMcs (i) == mcs)
1266  {
1267  return;
1268  }
1269  }
1270  m_bssBasicMcsSet.push_back (mcs);
1271 }
1272 
1273 uint32_t
1275 {
1276  return m_bssBasicMcsSet.size ();
1277 }
1278 uint8_t
1280 {
1281  NS_ASSERT (i < m_bssBasicMcsSet.size ());
1282  return m_bssBasicMcsSet[i];
1283 }
1284 
1285 WifiMode
1287 {
1288  if (m_nonUnicastMode == WifiMode ())
1289  {
1290  return GetBasicMode (0);
1291  }
1292  else
1293  {
1294  return m_nonUnicastMode;
1295  }
1296 }
1297 
1298 bool
1300  Ptr<const Packet> packet, bool normally)
1301 {
1302  return normally;
1303 }
1304 bool
1306  Ptr<const Packet> packet, bool normally)
1307 {
1308  return normally;
1309 }
1310 bool
1312  Ptr<const Packet> packet, bool normally)
1313 {
1314  return normally;
1315 }
1316 bool
1318  Ptr<const Packet> packet, bool normally)
1319 {
1320  return normally;
1321 }
1322 
1323 WifiMode
1325 {
1326  NS_ASSERT (i < GetNSupported (station));
1327  return station->m_state->m_operationalRateSet[i];
1328 }
1329 uint8_t
1331 {
1332  NS_ASSERT (i < GetNMcsSupported (station));
1333  return station->m_state->m_operationalMcsSet[i];
1334 }
1335 bool
1337 {
1338  return station->m_state->m_shortGuardInterval;
1339 }
1340 bool
1342 {
1343  return station->m_state->m_greenfield;
1344 }
1345 bool
1347 {
1348  return station->m_state->m_stbc;
1349 }
1350 uint32_t
1352 {
1353  return station->m_state->m_rx;
1354 }
1355 uint32_t
1357 {
1358  return station->m_state->m_tx;
1359 }
1360 uint32_t
1362 {
1363  return station->m_ssrc;
1364 }
1365 uint32_t
1367 {
1368  return station->m_slrc;
1369 }
1370 uint32_t
1372 {
1373  return station->m_state->m_operationalRateSet.size ();
1374 }
1375 uint32_t
1377 {
1378  return station->m_state->m_operationalMcsSet.size ();
1379 }
1380 void
1382 {
1383  m_defaultTxPowerLevel = txPower;
1384 }
1385 
1386 //support 11n
1387 uint32_t
1389 {
1391 }
1392 //WifiRemoteStationInfo constructor
1394  : m_memoryTime (Seconds (1.0)),
1395  m_lastUpdate (Seconds (0.0)),
1396  m_failAvg (0.0)
1397 {
1398 }
1399 
1400 double
1402 {
1403  double retval = std::exp ((double)(m_lastUpdate.GetMicroSeconds () - Simulator::Now ().GetMicroSeconds ())
1404  / (double)m_memoryTime.GetMicroSeconds ());
1406  return retval;
1407 }
1408 
1409 void
1411 {
1412  double coefficient = CalculateAveragingCoefficient ();
1413  m_failAvg = (double)retryCounter / (1 + (double) retryCounter) * (1.0 - coefficient) + coefficient * m_failAvg;
1414 }
1415 
1416 void
1418 {
1419  double coefficient = CalculateAveragingCoefficient ();
1420  m_failAvg = (1.0 - coefficient) + coefficient * m_failAvg;
1421 }
1422 
1423 double
1425 {
1426  return m_failAvg;
1427 }
1428 } // 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
virtual uint8_t DoGetAckTxNess(Mac48Address address, WifiMode ackMode)
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.
virtual void Print(std::ostream &os) const
bool GetGreenfieldSupported(Mac48Address address) const
Return whether the station supports Greenfield or not.
Hold a bool native type.
Definition: boolean.h:38
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)
uint8_t GetDefaultMcs(void) const
Return the default Modulation and Coding Scheme (MCS) index.
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...
virtual uint8_t DoGetBlockAckTxNss(Mac48Address address, WifiMode blockAckMode)
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition: packet.cc:841
uint32_t GetMaxSsrc(void) const
Return the maximum STA short retry count (SSRC).
enum WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:115
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)
enum ns3::WifiRemoteStationState::@90 m_state
State of the station.
#define NS_ASSERT(condition)
Definition: assert.h:64
WifiMode GetNonUnicastMode(void) const
Return a mode for non-unicast packets.
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
static const uint16_t WIFI_MAC_FCS_LENGTH
The length in octects of the IEEE 802.11 MAC FCS field.
uint32_t m_fragmentationThreshold
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
Definition: packet.h:650
uint8_t GetMcsSupported(const WifiRemoteStation *station, uint32_t i) const
Return the MCS index supported by the specified station at the specified index.
bool GetGreenfield(const WifiRemoteStation *station) const
Return whether the station supports Greenfield or not.
Mac48Address m_address
Mac48Address of the remote station.
virtual uint8_t GetMcs(uint8_t mcs) const =0
The WifiPhy::GetMcs() method is used (e.g., by a WifiRemoteStationManager) to determine the set of tr...
Time m_memoryTime
averaging coefficient depends on the memory time
bool IsLastFragment(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fragmentNumber)
WifiMcsList::const_iterator WifiMcsListIterator
An iterator for WifiMcsList vector.
Definition: wifi-mode.h:201
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...
virtual uint32_t WifiModeToMcs(WifiMode mode)=0
For a given WifiMode finds the corresponding MCS value and returns it as defined in the IEEE 802...
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:91
bool IsMandatory(void) const
Definition: wifi-mode.cc:104
virtual bool DoNeedRts(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
uint32_t GetNumberOfReceiveAntennas(const WifiRemoteStation *station) const
Return the number of receive antenna 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. ...
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:72
WifiRemoteStationState * LookupState(Mac48Address address) const
Return the state of the station associated with the given address.
WifiRemoteStationState * m_state
Remote station state.
double m_failAvg
moving percentage of failed frames
WifiTxVector GetCtsToSelfTxVector(const WifiMacHeader *header, Ptr< const Packet > packet)
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...
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 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.
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
Definition: nstime.h:291
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.
virtual bool DoNeedRtsRetransmission(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
Hold an unsigned integer type.
Definition: uinteger.h:46
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.
uint32_t m_maxSlrc
Maximum STA long retry count (SLRC)
uint8_t GetShortGuardInterval20(void) const
void NotifyTxSuccess(uint32_t retryCounter)
Updates average frame error rate when data or RTS was transmitted successfully.
uint32_t DoGetFragmentationThreshold(void) const
Return the current fragmentation threshold.
virtual bool GetGuardInterval(void) const =0
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 antennae of the remote station.
WifiMode m_defaultTxMode
The default transmission mode.
void SetNss(uint8_t nss)
Sets the number of Nss refer to IEEE802.11n Table 20-28 for explanation and range.
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.
uint8_t m_defaultTxMcs
The default transmission modulation-coding scheme (MCS)
void PrepareForQueue(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fullPacketSize)
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 TraceSourceAccessor > MakeTraceSourceAccessor(T a)
uint64_t GetPhyRate(void) const
Definition: wifi-mode.cc:73
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
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:192
virtual uint32_t GetSerializedSize(void) const
an EUI-48 address
Definition: mac48-address.h:41
TracedCallback< Mac48Address > m_macTxRtsFailed
The trace source fired when the transmission of a single RTS has failed.
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.
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 time".
Definition: simulator.cc:180
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 antennae of the remote station.
double GetFrameErrorRate() const
Return frame error rate (probability that frame is corrupted due to transmission error).
virtual TypeId GetInstanceTypeId(void) const
virtual void Serialize(TagBuffer i) const
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.
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.
void AddSupportedMcs(Mac48Address address, uint8_t mcs)
Record the MCS index supported by the 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)
Definition: log.h:280
uint8_t GetBasicMcs(uint32_t i) const
Return the MCS at the given list index.
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
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
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)
NS_LOG_COMPONENT_DEFINE("WifiRemoteStationManager")
void SetNess(uint8_t ness)
Sets the Ness number refer to IEEE802.11n Table 20-6 for explanation.
void Read(uint8_t *buffer, uint32_t size)
Definition: tag-buffer.cc:176
void AddBasicMcs(uint8_t mcs)
Add a given Modulation and Coding Scheme (MCS) index to the set of basic MCS.
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.
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:63
tuple address
Definition: first.py:37
virtual uint32_t GetSerializedSize(void) const
hold objects of type ns3::WifiMode
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.
virtual void DoReportFinalDataFailed(WifiRemoteStation *station)=0
This method is a pure virtual method that must be implemented by the sub-class.
virtual WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station)=0
a unique identifier for an interface.
Definition: type-id.h:49
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.
virtual WifiMode McsToWifiMode(uint8_t mcs)=0
For a given MCS finds the corresponding WifiMode and returns it as defined in the IEEE 802...
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611
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.
Implements the IEEE 802.11 MAC header.
virtual uint8_t DoGetBlockAckTxPowerLevel(Mac48Address address, WifiMode blockAckMode)
virtual void DoReportDataOk(WifiRemoteStation *station, double ackSnr, WifiMode ackMode, double dataSnr)=0
This method is a pure virtual method that must be implemented by the sub-class.