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 TypeId
256 {
257  static TypeId tid = TypeId ("ns3::WifiRemoteStationManager")
258  .SetParent<Object> ()
259  .AddAttribute ("IsLowLatency", "If true, we attempt to modelize a so-called low-latency device: a device"
260  " where decisions about tx parameters can be made on a per-packet basis and feedback about the"
261  " transmission of each packet is obtained before sending the next. Otherwise, we modelize a "
262  " high-latency device, that is a device where we cannot update our decision about tx parameters"
263  " after every packet transmission.",
264  BooleanValue (true), // this value is ignored because there is no setter
265  MakeBooleanAccessor (&WifiRemoteStationManager::IsLowLatency),
266  MakeBooleanChecker ())
267  .AddAttribute ("MaxSsrc", "The maximum number of retransmission attempts for an RTS. This value"
268  " will not have any effect on some rate control algorithms.",
269  UintegerValue (7),
270  MakeUintegerAccessor (&WifiRemoteStationManager::m_maxSsrc),
271  MakeUintegerChecker<uint32_t> ())
272  .AddAttribute ("MaxSlrc", "The maximum number of retransmission attempts for a DATA packet. This value"
273  " will not have any effect on some rate control algorithms.",
274  UintegerValue (7),
275  MakeUintegerAccessor (&WifiRemoteStationManager::m_maxSlrc),
276  MakeUintegerChecker<uint32_t> ())
277  .AddAttribute ("RtsCtsThreshold", "If the size of the data packet + LLC header + MAC header + FCS trailer is bigger than "
278  "this value, we use an RTS/CTS handshake before sending the data, as per IEEE Std. 802.11-2012, Section 9.3.5. "
279  "This value will not have any effect on some rate control algorithms.",
280  UintegerValue (2346),
281  MakeUintegerAccessor (&WifiRemoteStationManager::m_rtsCtsThreshold),
282  MakeUintegerChecker<uint32_t> ())
283  .AddAttribute ("FragmentationThreshold", "If the size of the data packet + LLC header + MAC header + FCS trailer is bigger"
284  "than this value, we fragment it such that the size of the fragments are equal or smaller "
285  "than this value, as per IEEE Std. 802.11-2012, Section 9.5. "
286  "This value will not have any effect on some rate control algorithms.",
287  UintegerValue (2346),
290  MakeUintegerChecker<uint32_t> ())
291  .AddAttribute ("NonUnicastMode", "Wifi mode used for non-unicast transmissions.",
292  WifiModeValue (),
293  MakeWifiModeAccessor (&WifiRemoteStationManager::m_nonUnicastMode),
294  MakeWifiModeChecker ())
295  .AddAttribute ("DefaultTxPowerLevel", "Default power level to be used for transmissions. "
296  "This is the power level that is used by all those WifiManagers that do not"
297  "implement TX power control.",
298  UintegerValue (0),
299  MakeUintegerAccessor (&WifiRemoteStationManager::m_defaultTxPowerLevel),
300  MakeUintegerChecker<uint8_t> ())
301  .AddTraceSource ("MacTxRtsFailed",
302  "The transmission of a RTS by the MAC layer has failed",
304  .AddTraceSource ("MacTxDataFailed",
305  "The transmission of a data packet by the MAC layer has failed",
307  .AddTraceSource ("MacTxFinalRtsFailed",
308  "The transmission of a RTS has exceeded the maximum number of attempts",
310  .AddTraceSource ("MacTxFinalDataFailed",
311  "The transmission of a data packet has exceeded the maximum number of attempts",
313  ;
314  return tid;
315 }
316 
318 {
319 }
320 
322 {
323 }
324 void
326 {
327  for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
328  {
329  delete (*i);
330  }
331  m_states.clear ();
332  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
333  {
334  delete (*i);
335  }
336  m_stations.clear ();
337 }
338 void
340 {
341  // We need to track our PHY because it is the object that knows the
342  // full set of transmit rates that are supported. We need to know
343  // this in order to find the relevant mandatory rates when chosing a
344  // transmit rate for automatic control responses like
345  // acknowledgements.
346  m_wifiPhy = phy;
347  m_defaultTxMode = phy->GetMode (0);
348  if(HasHtSupported())
349  {
350  m_defaultTxMcs = phy->GetMcs (0);
351  }
352  else
353  {
354  m_defaultTxMcs = 0;
355  }
356  Reset ();
357 }
358 void
360 {
361  m_htSupported=enable;
362 }
363 
364 bool
366 {
367  return m_htSupported;
368 }
369 uint32_t
371 {
372  return m_maxSsrc;
373 }
374 uint32_t
376 {
377  return m_maxSlrc;
378 }
379 uint32_t
381 {
382  return m_rtsCtsThreshold;
383 }
384 uint32_t
386 {
387  return DoGetFragmentationThreshold ();
388 }
389 void
391 {
392  m_maxSsrc = maxSsrc;
393 }
394 void
396 {
397  m_maxSlrc = maxSlrc;
398 }
399 void
401 {
402  m_rtsCtsThreshold = threshold;
403 }
404 void
406 {
407  DoSetFragmentationThreshold (threshold);
408 }
409 
410 void
412 {
413  NS_ASSERT (!address.IsGroup ());
414  WifiRemoteStationState *state = LookupState (address);
415  state->m_operationalRateSet.clear ();
416  state->m_operationalMcsSet.clear ();
417  AddSupportedMode (address, GetDefaultMode ());
418  AddSupportedMcs(address,GetDefaultMcs());
419 }
420 void
422 {
423  NS_ASSERT (!address.IsGroup ());
424  WifiRemoteStationState *state = LookupState (address);
425  for (WifiModeListIterator i = state->m_operationalRateSet.begin (); i != state->m_operationalRateSet.end (); i++)
426  {
427  if ((*i) == mode)
428  {
429  // already in.
430  return;
431  }
432  }
433  state->m_operationalRateSet.push_back (mode);
434 }
435 /*void
436 WifiRemoteStationManager::AddBssMembershipParameters(Mac48Address address, uint32_t selector)
437 {
438  NS_ASSERT (!address.IsGroup ());
439  WifiRemoteStationState *state = LookupState (address);
440  WifiMode mode;
441  WifiModeList membershipselectormodes = m_wifiPhy->GetMembershipSelectorModes(selector);
442  for (WifiModeListIterator j = membershipselectormodes.begin (); j != membershipselectormodes.end (); j++)
443  {
444  mode=(*j);
445  for (WifiModeListIterator i = state->m_operationalRateSet.begin (); i != state->m_operationalRateSet.end (); i++)
446  {
447  if ((*i) == mode)
448  {
449  // already in.
450  break;
451  }
452  }
453  state->m_operationalRateSet.push_back (mode);
454  }
455 }*/
456 void
458 {
459  NS_ASSERT (!address.IsGroup ());
460  WifiRemoteStationState *state = LookupState (address);
461  for (WifiMcsListIterator i = state->m_operationalMcsSet.begin (); i != state->m_operationalMcsSet.end (); i++)
462  {
463  if ((*i) == mcs)
464  {
465  // already in.
466  return;
467  }
468  }
469  state->m_operationalMcsSet.push_back (mcs);
470 }
471 bool
473 {
474  if (address.IsGroup ())
475  {
476  return false;
477  }
479 }
480 bool
482 {
483  if (address.IsGroup ())
484  {
485  return true;
486  }
488 }
489 bool
491 {
492  if (address.IsGroup ())
493  {
494  return false;
495  }
497 }
498 void
500 {
501  NS_ASSERT (!address.IsGroup ());
503 }
504 void
506 {
507  NS_ASSERT (!address.IsGroup ());
509 }
510 void
512 {
513  NS_ASSERT (!address.IsGroup ());
515 }
516 void
518 {
519  NS_ASSERT (!address.IsGroup ());
521 }
522 void
524  Ptr<const Packet> packet, uint32_t fullPacketSize)
525 {
526  if (IsLowLatency () || address.IsGroup ())
527  {
528  return;
529  }
530  WifiRemoteStation *station = Lookup (address, header);
531  WifiTxVector rts = DoGetRtsTxVector (station);
532  WifiTxVector data = DoGetDataTxVector (station, fullPacketSize);
533  WifiTxVector ctstoself = DoGetCtsToSelfTxVector ();
536  HighLatencyCtsToSelfTxVectorTag ctstoselftag;
537  // first, make sure that the tag is not here anymore.
538  ConstCast<Packet> (packet)->RemovePacketTag (datatag);
539  ConstCast<Packet> (packet)->RemovePacketTag (rtstag);
540  ConstCast<Packet> (packet)->RemovePacketTag (ctstoselftag);
541  datatag = HighLatencyDataTxVectorTag (data);
542  rtstag = HighLatencyRtsTxVectorTag (rts);
543  ctstoselftag = HighLatencyCtsToSelfTxVectorTag (ctstoself);
544  // and then, add it back
545  packet->AddPacketTag (datatag);
546  packet->AddPacketTag (rtstag);
547  packet->AddPacketTag (ctstoselftag);
548 }
551  Ptr<const Packet> packet, uint32_t fullPacketSize)
552 {
553  if (address.IsGroup ())
554  {
555  WifiTxVector v;
556  v.SetMode (GetNonUnicastMode ());
558  v.SetShortGuardInterval (false);
559  v.SetNss (1);
560  v.SetNess (0);
561  v.SetStbc (false);
562  return v;
563  }
564  if (!IsLowLatency ())
565  {
567  bool found;
568  found = ConstCast<Packet> (packet)->PeekPacketTag (datatag);
569  NS_ASSERT (found);
570  // cast found to void, to suppress 'found' set but not used
571  // compiler warning
572  (void) found;
573  return datatag.GetDataTxVector ();
574  }
575  return DoGetDataTxVector (Lookup (address, header), fullPacketSize);
576 }
579  Ptr<const Packet> packet)
580 {
581 
582  if (!IsLowLatency ())
583  {
584  HighLatencyCtsToSelfTxVectorTag ctstoselftag;
585  bool found;
586  found = ConstCast<Packet> (packet)->PeekPacketTag (ctstoselftag);
587  NS_ASSERT (found);
588  // cast found to void, to suppress 'found' set but not used
589  // compiler warning
590  (void) found;
591  return ctstoselftag.GetCtsToSelfTxVector ();
592  }
593  return DoGetCtsToSelfTxVector ();
594 }
595 
598 {
600 }
601 
604  Ptr<const Packet> packet)
605 {
606  NS_ASSERT (!address.IsGroup ());
607  if (!IsLowLatency ())
608  {
610  bool found;
611  found = ConstCast<Packet> (packet)->PeekPacketTag (rtstag);
612  NS_ASSERT (found);
613  // cast found to void, to suppress 'found' set but not used
614  // compiler warning
615  (void) found;
616  return rtstag.GetRtsTxVector ();
617  }
618  return DoGetRtsTxVector (Lookup (address, header));
619 }
620 void
622 {
623  NS_ASSERT (!address.IsGroup ());
624  WifiRemoteStation *station = Lookup (address, header);
625  station->m_ssrc++;
626  m_macTxRtsFailed (address);
627  DoReportRtsFailed (station);
628 }
629 void
631 {
632  NS_ASSERT (!address.IsGroup ());
633  WifiRemoteStation *station = Lookup (address, header);
634  station->m_slrc++;
635  m_macTxDataFailed (address);
636  DoReportDataFailed (station);
637 }
638 void
640  double ctsSnr, WifiMode ctsMode, double rtsSnr)
641 {
642  NS_ASSERT (!address.IsGroup ());
643  WifiRemoteStation *station = Lookup (address, header);
644  station->m_state->m_info.NotifyTxSuccess (station->m_ssrc);
645  station->m_ssrc = 0;
646  DoReportRtsOk (station, ctsSnr, ctsMode, rtsSnr);
647 }
648 void
650  double ackSnr, WifiMode ackMode, double dataSnr)
651 {
652  NS_ASSERT (!address.IsGroup ());
653  WifiRemoteStation *station = Lookup (address, header);
654  station->m_state->m_info.NotifyTxSuccess (station->m_slrc);
655  station->m_slrc = 0;
656  DoReportDataOk (station, ackSnr, ackMode, dataSnr);
657 }
658 void
660 {
661  NS_ASSERT (!address.IsGroup ());
662  WifiRemoteStation *station = Lookup (address, header);
663  station->m_state->m_info.NotifyTxFailed ();
664  station->m_ssrc = 0;
665  m_macTxFinalRtsFailed (address);
666  DoReportFinalRtsFailed (station);
667 }
668 void
670 {
671  NS_ASSERT (!address.IsGroup ());
672  WifiRemoteStation *station = Lookup (address, header);
673  station->m_state->m_info.NotifyTxFailed ();
674  station->m_slrc = 0;
675  m_macTxFinalDataFailed (address);
676  DoReportFinalDataFailed (station);
677 }
678 void
680  double rxSnr, WifiMode txMode)
681 {
682  if (address.IsGroup ())
683  {
684  return;
685  }
686  WifiRemoteStation *station = Lookup (address, header);
687  DoReportRxOk (station, rxSnr, txMode);
688 }
689 bool
691  Ptr<const Packet> packet)
692 {
693  if (address.IsGroup ())
694  {
695  return false;
696  }
697  bool normally = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > GetRtsCtsThreshold ();
698  return DoNeedRts (Lookup (address, header), packet, normally);
699 }
700 bool
702 {
703  WifiMode mode = txVector.GetMode();
704 
705  // search the BSS Basic Rate set if the used mode in the basic set then no need for Cts to self
706  for (WifiModeListIterator i = m_bssBasicRateSet.begin ();
707  i != m_bssBasicRateSet.end (); i++)
708  {
709  if (mode == *i)
710  {
711  return false;
712  }
713  }
714  if (HasHtSupported())
715  {
716  uint8_t mcs = m_wifiPhy->WifiModeToMcs (mode);
717  for (WifiMcsListIterator i = m_bssBasicMcsSet.begin ();
718  i != m_bssBasicMcsSet.end (); i++)
719  {
720  if (mcs == *i)
721  {
722  return false;
723  }
724  }
725  }
726  return true;
727 }
728 bool
730  Ptr<const Packet> packet)
731 {
732  NS_ASSERT (!address.IsGroup ());
733  WifiRemoteStation *station = Lookup (address, header);
734  bool normally = station->m_ssrc < GetMaxSsrc ();
735  return DoNeedRtsRetransmission (station, packet, normally);
736 }
737 bool
739  Ptr<const Packet> packet)
740 {
741  NS_ASSERT (!address.IsGroup ());
742  WifiRemoteStation *station = Lookup (address, header);
743  bool normally = station->m_slrc < GetMaxSlrc ();
744  return DoNeedDataRetransmission (station, packet, normally);
745 }
746 bool
748  Ptr<const Packet> packet)
749 {
750  if (address.IsGroup ())
751  {
752  return false;
753  }
754  WifiRemoteStation *station = Lookup (address, header);
755  bool normally = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > GetFragmentationThreshold ();
756  return DoNeedFragmentation (station, packet, normally);
757 }
758 
759 void
761 {
762  if (threshold < 256)
763  {
764  /*
765  * ASN.1 encoding of the MAC and PHY MIB (256 ... 8000)
766  */
767  NS_LOG_WARN ("Fragmentation threshold should be larger than 256. Setting to 256.");
769  }
770  else
771  {
772  /*
773  * The length of each fragment shall be an even number of octets, except for the last fragment if an MSDU or
774  * MMPDU, which may be either an even or an odd number of octets.
775  */
776  if (threshold % 2 != 0)
777  {
778  NS_LOG_WARN ("Fragmentation threshold should be an even number. Setting to " << threshold - 1);
779  m_fragmentationThreshold = threshold - 1;
780  }
781  else
782  {
783  m_fragmentationThreshold = threshold;
784  }
785  }
786 }
787 
788 uint32_t
790 {
792 }
793 
794 uint32_t
796 {
797  //The number of bytes a fragment can support is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
798  uint32_t nFragments = (packet->GetSize () / (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
799 
800  //If the size of the last fragment is not 0.
801  if ((packet->GetSize () % (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH)) > 0)
802  {
803  nFragments++;
804  }
805  return nFragments;
806 }
807 
808 uint32_t
810  Ptr<const Packet> packet, uint32_t fragmentNumber)
811 {
812  NS_ASSERT (!address.IsGroup ());
813  uint32_t nFragment = GetNFragments (header, packet);
814  if (fragmentNumber >= nFragment)
815  {
816  return 0;
817  }
818  //Last fragment
819  if (fragmentNumber == nFragment - 1)
820  {
821  uint32_t lastFragmentSize = packet->GetSize () - (fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
822  return lastFragmentSize;
823  }
824  //All fragments but the last, the number of bytes is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
825  else
826  {
827  return GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH;
828  }
829 }
830 uint32_t
832  Ptr<const Packet> packet, uint32_t fragmentNumber)
833 {
834  NS_ASSERT (!address.IsGroup ());
835  NS_ASSERT (fragmentNumber < GetNFragments (header, packet));
836  uint32_t fragmentOffset = fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH);
837  return fragmentOffset;
838 }
839 bool
841  Ptr<const Packet> packet, uint32_t fragmentNumber)
842 {
843  NS_ASSERT (!address.IsGroup ());
844  bool isLast = fragmentNumber == (GetNFragments (header, packet) - 1);
845  return isLast;
846 }
847 WifiMode
849 {
864  WifiMode mode = GetDefaultMode ();
865  bool found = false;
866 
867  // First, search the BSS Basic Rate set
868  for (WifiModeListIterator i = m_bssBasicRateSet.begin ();
869  i != m_bssBasicRateSet.end (); i++)
870  {
871  if ((!found || i->GetPhyRate () > mode.GetPhyRate ())
872  && i->GetPhyRate () <= reqMode.GetPhyRate ()
873  && i->GetModulationClass () == reqMode.GetModulationClass ())
874  {
875  mode = *i;
876  // We've found a potentially-suitable transmit rate, but we
877  // need to continue and consider all the basic rates before
878  // we can be sure we've got the right one.
879  found = true;
880  }
881  }
882  if(HasHtSupported())
883  {
884  if (!found)
885  {
886  uint8_t mcs = GetDefaultMcs ();
887  mode= m_wifiPhy->McsToWifiMode (mcs);
888  }
889  for (WifiMcsListIterator i = m_bssBasicMcsSet.begin ();
890  i != m_bssBasicMcsSet.end (); i++)
891  {
892  WifiMode thismode= m_wifiPhy->McsToWifiMode (*i);
893  if ((!found || thismode.GetPhyRate () > mode.GetPhyRate ())
894  && thismode.GetPhyRate () <= reqMode.GetPhyRate ()
895  && thismode.GetModulationClass () == reqMode.GetModulationClass ())
896  {
897  mode = thismode;
898  // We've found a potentially-suitable transmit rate, but we
899  // need to continue and consider all the basic rates before
900  // we can be sure we've got the right one.
901  found = true;
902  }
903  }
904  }
905  // If we found a suitable rate in the BSSBasicRateSet, then we are
906  // done and can return that mode.
907  if (found)
908  {
909  return mode;
910  }
911 
929  for (uint32_t idx = 0; idx < m_wifiPhy->GetNModes (); idx++)
930  {
931  WifiMode thismode = m_wifiPhy->GetMode (idx);
932 
933  /* If the rate:
934  *
935  * - is a mandatory rate for the PHY, and
936  * - is equal to or faster than our current best choice, and
937  * - is less than or equal to the rate of the received frame, and
938  * - is of the same modulation class as the received frame
939  *
940  * ...then it's our best choice so far.
941  */
942  if (thismode.IsMandatory ()
943  && (!found || thismode.GetPhyRate () > mode.GetPhyRate ())
944  && thismode.GetPhyRate () <= reqMode.GetPhyRate ()
945  && thismode.GetModulationClass () == reqMode.GetModulationClass ())
946  {
947  mode = thismode;
948  // As above; we've found a potentially-suitable transmit
949  // rate, but we need to continue and consider all the
950  // mandatory rates before we can be sure we've got the right
951  // one.
952  found = true;
953  }
954  }
955  if(HasHtSupported())
956  {
957  for (uint32_t idx = 0; idx < m_wifiPhy->GetNMcs (); idx++)
958  {
959  uint8_t thismcs = m_wifiPhy->GetMcs (idx);
960  WifiMode thismode= m_wifiPhy->McsToWifiMode (thismcs);
961  if (thismode.IsMandatory ()
962  && (!found || thismode.GetPhyRate () > mode.GetPhyRate ())
963  && thismode.GetPhyRate () <= reqMode.GetPhyRate ()
964  && thismode.GetModulationClass () == reqMode.GetModulationClass ())
965  {
966  mode = thismode;
967  // As above; we've found a potentially-suitable transmit
968  // rate, but we need to continue and consider all the
969  // mandatory rates before we can be sure we've got the right
970  // one.
971  found = true;
972  }
973 
974  }
975  }
976 
987  if (!found)
988  {
989  NS_FATAL_ERROR ("Can't find response rate for " << reqMode
990  << ". Check standard and selected rates match.");
991  }
992 
993  return mode;
994 }
995 
998 {
999  NS_ASSERT (!address.IsGroup ());
1000  WifiTxVector v;
1001  v.SetMode (GetControlAnswerMode (address, rtsMode));
1002  v.SetTxPowerLevel (DoGetCtsTxPowerLevel (address, v.GetMode()));
1003  v.SetShortGuardInterval (DoGetCtsTxGuardInterval(address, v.GetMode()));
1004  v.SetNss (DoGetCtsTxNss(address, v.GetMode()));
1005  v.SetNess (DoGetCtsTxNess(address, v.GetMode()));
1006  v.SetStbc (DoGetCtsTxStbc(address, v.GetMode()));
1007  return v;
1008 }
1011 {
1012  NS_ASSERT (!address.IsGroup ());
1013  WifiTxVector v;
1014  v.SetMode (GetControlAnswerMode (address, dataMode));
1015  v.SetTxPowerLevel (DoGetAckTxPowerLevel (address, v.GetMode()));
1016  v.SetShortGuardInterval(DoGetAckTxGuardInterval(address, v.GetMode()));
1017  v.SetNss(DoGetAckTxNss(address, v.GetMode()));
1018  v.SetNess(DoGetAckTxNess(address, v.GetMode()));
1019  v.SetStbc(DoGetAckTxStbc(address, v.GetMode()));
1020  return v;
1021 }
1024 {
1025  NS_ASSERT (!address.IsGroup ());
1026  WifiTxVector v;
1027  v.SetMode (GetControlAnswerMode (address, blockAckReqMode));
1028  v.SetTxPowerLevel (DoGetBlockAckTxPowerLevel (address, v.GetMode()));
1029  v.SetShortGuardInterval (DoGetBlockAckTxGuardInterval(address, v.GetMode()));
1030  v.SetNss (DoGetBlockAckTxNss(address, v.GetMode()));
1031  v.SetNess (DoGetBlockAckTxNess(address, v.GetMode()));
1032  v.SetStbc (DoGetBlockAckTxStbc(address, v.GetMode()));
1033  return v;
1034 }
1035 
1036 uint8_t
1038 {
1039  return m_defaultTxPowerLevel;
1040 }
1041 
1042 bool
1044 {
1045  return m_wifiPhy->GetGuardInterval();
1046 }
1047 
1048 uint8_t
1050 {
1051  return 1;
1052 }
1053 uint8_t
1055 {
1056  return 0;
1057 }
1058 bool
1060 {
1061  return m_wifiPhy->GetStbc();
1062 }
1063 
1064 uint8_t
1066 {
1067  return m_defaultTxPowerLevel;
1068 }
1069 
1070 bool
1072 {
1073  return m_wifiPhy->GetGuardInterval();
1074 }
1075 
1076 uint8_t
1078 {
1079  return 1;
1080 }
1081 uint8_t
1083 {
1084  return 0;
1085 }
1086 bool
1088 {
1089  return m_wifiPhy->GetStbc();
1090 }
1091 
1092 uint8_t
1094 {
1095  return m_defaultTxPowerLevel;
1096 }
1097 
1098 bool
1100 {
1101  return m_wifiPhy->GetGuardInterval();
1102 }
1103 
1104 uint8_t
1106 {
1107  return 1;
1108 }
1109 uint8_t
1111 {
1112  return 0;
1113 }
1114 bool
1116 {
1117  return m_wifiPhy->GetStbc();
1118 }
1119 
1120 
1121 uint8_t
1123 {
1124  return m_defaultTxPowerLevel;
1125 }
1126 
1127 
1130 {
1131  WifiRemoteStationState *state = LookupState (address);
1132  return state->m_info;
1133 }
1134 
1137 {
1138  for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
1139  {
1140  if ((*i)->m_address == address)
1141  {
1142  return (*i);
1143  }
1144  }
1147  state->m_address = address;
1148  state->m_operationalRateSet.push_back (GetDefaultMode ());
1149  state->m_operationalMcsSet.push_back(GetDefaultMcs());
1152  state->m_rx=1;
1153  state->m_tx=1;
1154  state->m_stbc=false;
1155  const_cast<WifiRemoteStationManager *> (this)->m_states.push_back (state);
1156  return state;
1157 }
1160 {
1161  uint8_t tid;
1162  if (header->IsQosData ())
1163  {
1164  tid = header->GetQosTid ();
1165  }
1166  else
1167  {
1168  tid = 0;
1169  }
1170  return Lookup (address, tid);
1171 }
1174 {
1175  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1176  {
1177  if ((*i)->m_tid == tid
1178  && (*i)->m_state->m_address == address)
1179  {
1180  return (*i);
1181  }
1182  }
1183  WifiRemoteStationState *state = LookupState (address);
1184 
1185  WifiRemoteStation *station = DoCreateStation ();
1186  station->m_state = state;
1187  station->m_tid = tid;
1188  station->m_ssrc = 0;
1189  station->m_slrc = 0;
1190  // XXX
1191  const_cast<WifiRemoteStationManager *> (this)->m_stations.push_back (station);
1192  return station;
1193 
1194 }
1195 //Used by all stations to record HT capabilities of remote stations
1196 void
1198 {
1199  WifiRemoteStationState *state;
1200  state=LookupState (from);
1201  state->m_shortGuardInterval=htcapabilities.GetShortGuardInterval20();
1202  state->m_greenfield=htcapabilities.GetGreenfield();
1203 
1204 }
1205 //Used by mac low to choose format used GF, MF or Non HT
1206 bool
1208 {
1209  return LookupState(address)->m_greenfield;
1210 }
1211 WifiMode
1213 {
1214  return m_defaultTxMode;
1215 }
1216 uint8_t
1218 {
1219  return m_defaultTxMcs;
1220 }
1221 void
1223 {
1224  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1225  {
1226  delete (*i);
1227  }
1228  m_stations.clear ();
1229  m_bssBasicRateSet.clear ();
1230  m_bssBasicRateSet.push_back (m_defaultTxMode);
1231  m_bssBasicMcsSet.clear();
1232  m_bssBasicMcsSet.push_back (m_defaultTxMcs);
1234 }
1235 void
1237 {
1238  for (uint32_t i = 0; i < GetNBasicModes (); i++)
1239  {
1240  if (GetBasicMode (i) == mode)
1241  {
1242  return;
1243  }
1244  }
1245  m_bssBasicRateSet.push_back (mode);
1246 }
1247 uint32_t
1249 {
1250  return m_bssBasicRateSet.size ();
1251 }
1252 WifiMode
1254 {
1255  NS_ASSERT (i < m_bssBasicRateSet.size ());
1256  return m_bssBasicRateSet[i];
1257 }
1258 
1259 void
1261 {
1262  for (uint32_t i = 0; i < GetNBasicMcs (); i++)
1263  {
1264  if (GetBasicMcs (i) == mcs)
1265  {
1266  return;
1267  }
1268  }
1269  m_bssBasicMcsSet.push_back (mcs);
1270 }
1271 
1272 uint32_t
1274 {
1275  return m_bssBasicMcsSet.size ();
1276 }
1277 uint8_t
1279 {
1280  NS_ASSERT (i < m_bssBasicMcsSet.size ());
1281  return m_bssBasicMcsSet[i];
1282 }
1283 
1284 WifiMode
1286 {
1287  if (m_nonUnicastMode == WifiMode ())
1288  {
1289  return GetBasicMode (0);
1290  }
1291  else
1292  {
1293  return m_nonUnicastMode;
1294  }
1295 }
1296 
1297 bool
1299  Ptr<const Packet> packet, bool normally)
1300 {
1301  return normally;
1302 }
1303 bool
1305  Ptr<const Packet> packet, bool normally)
1306 {
1307  return normally;
1308 }
1309 bool
1311  Ptr<const Packet> packet, bool normally)
1312 {
1313  return normally;
1314 }
1315 bool
1317  Ptr<const Packet> packet, bool normally)
1318 {
1319  return normally;
1320 }
1321 
1322 WifiMode
1324 {
1325  NS_ASSERT (i < GetNSupported (station));
1326  return station->m_state->m_operationalRateSet[i];
1327 }
1328 uint8_t
1330 {
1331  NS_ASSERT (i < GetNMcsSupported (station));
1332  return station->m_state->m_operationalMcsSet[i];
1333 }
1334 bool
1336 {
1337  return station->m_state->m_shortGuardInterval;
1338 }
1339 bool
1341 {
1342  return station->m_state->m_greenfield;
1343 }
1344 bool
1346 {
1347  return station->m_state->m_stbc;
1348 }
1349 uint32_t
1351 {
1352  return station->m_state->m_rx;
1353 }
1354 uint32_t
1356 {
1357  return station->m_state->m_tx;
1358 }
1359 uint32_t
1361 {
1362  return station->m_ssrc;
1363 }
1364 uint32_t
1366 {
1367  return station->m_slrc;
1368 }
1369 uint32_t
1371 {
1372  return station->m_state->m_operationalRateSet.size ();
1373 }
1374 uint32_t
1376 {
1377  return station->m_state->m_operationalMcsSet.size ();
1378 }
1379 void
1381 {
1382  m_defaultTxPowerLevel = txPower;
1383 }
1384 
1385 //support 11n
1386 uint32_t
1388 {
1390 }
1391 //WifiRemoteStationInfo constructor
1393  : m_memoryTime (Seconds (1.0)),
1394  m_lastUpdate (Seconds (0.0)),
1395  m_failAvg (0.0)
1396 {
1397 }
1398 
1399 double
1401 {
1402  double retval = std::exp ((double)(m_lastUpdate.GetMicroSeconds () - Simulator::Now ().GetMicroSeconds ())
1403  / (double)m_memoryTime.GetMicroSeconds ());
1405  return retval;
1406 }
1407 
1408 void
1410 {
1411  double coefficient = CalculateAveragingCoefficient ();
1412  m_failAvg = (double)retryCounter / (1 + (double) retryCounter) * (1.0 - coefficient) + coefficient * m_failAvg;
1413 }
1414 
1415 void
1417 {
1418  double coefficient = CalculateAveragingCoefficient ();
1419  m_failAvg = (1.0 - coefficient) + coefficient * m_failAvg;
1420 }
1421 
1422 double
1424 {
1425  return m_failAvg;
1426 }
1427 } // 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)
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition: object-base.h:38
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)
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:61
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:170
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
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:744
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.
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:95
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. ...
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:289
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.
enum ns3::WifiRemoteStationState::@92 m_state
State of the station.
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)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:203
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)
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:64
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:610
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.