A Discrete-Event Network Simulator
API
wifi-remote-station-manager.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2006,2007 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 
21 #include <iostream>
23 #include "ns3/simulator.h"
24 #include "ns3/assert.h"
25 #include "ns3/log.h"
26 #include "ns3/tag.h"
27 #include "ns3/boolean.h"
28 #include "ns3/double.h"
29 #include "ns3/uinteger.h"
30 #include "ns3/wifi-phy.h"
31 #include "ns3/wifi-mac.h"
32 #include "ns3/trace-source-accessor.h"
33 #include "wifi-mac-header.h"
34 #include "wifi-mac-trailer.h"
35 
36 /***************************************************************
37  * Packet Mode Tagger
38  ***************************************************************/
39 
40 namespace ns3 {
41 
42 NS_LOG_COMPONENT_DEFINE ("WifiRemoteStationManager");
43 
45 {
46 public:
52  WifiTxVector GetDataTxVector (void) const;
53 
54  static TypeId GetTypeId (void);
55  virtual TypeId GetInstanceTypeId (void) const;
56  virtual uint32_t GetSerializedSize (void) const;
57  virtual void Serialize (TagBuffer i) const;
58  virtual void Deserialize (TagBuffer i);
59  virtual void Print (std::ostream &os) const;
60 private:
62 };
63 
65 {
66 }
68  : m_dataTxVector (dataTxVector)
69 {
70 }
71 
74 {
75  return m_dataTxVector;
76 }
77 TypeId
79 {
80  static TypeId tid = TypeId ("ns3::HighLatencyDataTxVectorTag")
81  .SetParent<Tag> ()
82  .AddConstructor<HighLatencyDataTxVectorTag> ()
83  ;
84  return tid;
85 }
86 TypeId
88 {
89  return GetTypeId ();
90 }
91 uint32_t
93 {
94  return sizeof (WifiTxVector);
95 }
96 void
98 {
99  i.Write ((uint8_t *)&m_dataTxVector, sizeof (WifiTxVector));
100 }
101 void
103 {
104  i.Read ((uint8_t *)&m_dataTxVector, sizeof (WifiTxVector));
105 }
106 void
107 HighLatencyDataTxVectorTag::Print (std::ostream &os) const
108 {
109  os << "Data=" << m_dataTxVector;
110 }
111 
113 {
114 public:
121  WifiTxVector GetRtsTxVector (void) const;
122 
123  static TypeId GetTypeId (void);
124  virtual TypeId GetInstanceTypeId (void) const;
125  virtual uint32_t GetSerializedSize (void) const;
126  virtual void Serialize (TagBuffer i) const;
127  virtual void Deserialize (TagBuffer i);
128  virtual void Print (std::ostream &os) const;
129 private:
131 };
132 
134 {
135 }
137  : m_rtsTxVector (rtsTxVector)
138 {
139 }
140 
143 {
144  return m_rtsTxVector;
145 }
146 TypeId
148 {
149  static TypeId tid = TypeId ("ns3::HighLatencyRtsTxVectorTag")
150  .SetParent<Tag> ()
151  .AddConstructor<HighLatencyRtsTxVectorTag> ()
152  ;
153  return tid;
154 }
155 TypeId
157 {
158  return GetTypeId ();
159 }
160 uint32_t
162 {
163  return sizeof (WifiTxVector);
164 }
165 void
167 {
168  i.Write ((uint8_t *)&m_rtsTxVector, sizeof (WifiTxVector));
169 }
170 void
172 {
173  i.Read ((uint8_t *)&m_rtsTxVector, sizeof (WifiTxVector));
174 }
175 void
176 HighLatencyRtsTxVectorTag::Print (std::ostream &os) const
177 {
178  os << "Rts=" << m_rtsTxVector;
179 }
180 
182 {
183 public:
185  HighLatencyCtsToSelfTxVectorTag (WifiTxVector ctsToSelfTxVector);
189  WifiTxVector GetCtsToSelfTxVector (void) const;
190 
191  static TypeId GetTypeId (void);
192  virtual TypeId GetInstanceTypeId (void) const;
193  virtual uint32_t GetSerializedSize (void) const;
194  virtual void Serialize (TagBuffer i) const;
195  virtual void Deserialize (TagBuffer i);
196  virtual void Print (std::ostream &os) const;
197 private:
199 };
200 
202 {
203 }
205  : m_ctsToSelfTxVector (ctsToSelfTxVector)
206 {
207 }
208 
211 {
212  return m_ctsToSelfTxVector;
213 }
214 TypeId
216 {
217  static TypeId tid = TypeId ("ns3::HighLatencyCtsToSelfTxVectorTag")
218  .SetParent<Tag> ()
219  .AddConstructor<HighLatencyCtsToSelfTxVectorTag> ()
220  ;
221  return tid;
222 }
223 TypeId
225 {
226  return GetTypeId ();
227 }
228 uint32_t
230 {
231  return sizeof (WifiTxVector);
232 }
233 void
235 {
236  i.Write ((uint8_t *)&m_ctsToSelfTxVector, sizeof (WifiTxVector));
237 }
238 void
240 {
241  i.Read ((uint8_t *)&m_ctsToSelfTxVector, sizeof (WifiTxVector));
242 }
243 void
245 {
246  os << "Cts To Self=" << m_ctsToSelfTxVector;
247 }
248 
249 } // namespace ns3
250 
251 namespace ns3 {
252 
253 NS_OBJECT_ENSURE_REGISTERED (WifiRemoteStationManager);
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
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),
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),
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-2012, Section 9.3.5. "
280  "This value will not have any effect on some rate control algorithms.",
281  UintegerValue (2346),
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-2012, Section 9.5. "
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 (),
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),
301  MakeUintegerChecker<uint8_t> ())
302  .AddTraceSource ("MacTxRtsFailed",
303  "The transmission of a RTS by the MAC layer has failed",
305  "ns3::Mac48Address::TracedCallback")
306  .AddTraceSource ("MacTxDataFailed",
307  "The transmission of a data packet by the MAC layer has failed",
309  "ns3::Mac48Address::TracedCallback")
310  .AddTraceSource ("MacTxFinalRtsFailed",
311  "The transmission of a RTS has exceeded the maximum number of attempts",
313  "ns3::Mac48Address::TracedCallback")
314  .AddTraceSource ("MacTxFinalDataFailed",
315  "The transmission of a data packet has exceeded the maximum number of attempts",
317  "ns3::Mac48Address::TracedCallback")
318  ;
319  return tid;
320 }
321 
323 {
324 }
325 
327 {
328 }
329 void
331 {
332  for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
333  {
334  delete (*i);
335  }
336  m_states.clear ();
337  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
338  {
339  delete (*i);
340  }
341  m_stations.clear ();
342 }
343 void
345 {
346  // We need to track our PHY because it is the object that knows the
347  // full set of transmit rates that are supported. We need to know
348  // this in order to find the relevant mandatory rates when chosing a
349  // transmit rate for automatic control responses like
350  // acknowledgements.
351  m_wifiPhy = phy;
352  m_defaultTxMode = phy->GetMode (0);
353  if(HasHtSupported())
354  {
355  m_defaultTxMcs = phy->GetMcs (0);
356  }
357  else
358  {
359  m_defaultTxMcs = 0;
360  }
361  Reset ();
362 }
363 void
365 {
366  // We need to track our MAC because it is the object that knows the
367  // full set of interframe spaces.
368  m_wifiMac = mac;
369  Reset ();
370 }
371 void
373 {
374  m_htSupported=enable;
375 }
376 
377 bool
379 {
380  return m_htSupported;
381 }
382 uint32_t
384 {
385  return m_maxSsrc;
386 }
387 uint32_t
389 {
390  return m_maxSlrc;
391 }
392 uint32_t
394 {
395  return m_rtsCtsThreshold;
396 }
397 uint32_t
399 {
400  return DoGetFragmentationThreshold ();
401 }
402 void
404 {
405  m_maxSsrc = maxSsrc;
406 }
407 void
409 {
410  m_maxSlrc = maxSlrc;
411 }
412 void
414 {
415  m_rtsCtsThreshold = threshold;
416 }
417 void
419 {
420  DoSetFragmentationThreshold (threshold);
421 }
422 
423 void
425 {
426  NS_LOG_FUNCTION (this << address);
427  NS_ASSERT (!address.IsGroup ());
428  WifiRemoteStationState *state = LookupState (address);
429  state->m_operationalRateSet.clear ();
430  state->m_operationalMcsSet.clear ();
431  AddSupportedMode (address, GetDefaultMode ());
432  AddSupportedMcs(address,GetDefaultMcs());
433 }
434 void
436 {
437  NS_LOG_FUNCTION (this << address << mode);
438  NS_ASSERT (!address.IsGroup ());
439  WifiRemoteStationState *state = LookupState (address);
440  for (WifiModeListIterator i = state->m_operationalRateSet.begin (); i != state->m_operationalRateSet.end (); i++)
441  {
442  if ((*i) == mode)
443  {
444  // already in.
445  return;
446  }
447  }
448  state->m_operationalRateSet.push_back (mode);
449 }
450 void
452 {
453  NS_ASSERT (!address.IsGroup ());
454  WifiRemoteStationState *state = LookupState (address);
455  state->m_operationalRateSet.clear ();
456  for (uint32_t i = 0; i < m_wifiPhy->GetNModes (); i++)
457  {
458  state->m_operationalRateSet.push_back ( m_wifiPhy->GetMode (i));
459  }
460 }
461 
462 /*void
463 WifiRemoteStationManager::AddBssMembershipParameters(Mac48Address address, uint32_t selector)
464 {
465  NS_ASSERT (!address.IsGroup ());
466  WifiRemoteStationState *state = LookupState (address);
467  WifiMode mode;
468  WifiModeList membershipselectormodes = m_wifiPhy->GetMembershipSelectorModes(selector);
469  for (WifiModeListIterator j = membershipselectormodes.begin (); j != membershipselectormodes.end (); j++)
470  {
471  mode=(*j);
472  for (WifiModeListIterator i = state->m_operationalRateSet.begin (); i != state->m_operationalRateSet.end (); i++)
473  {
474  if ((*i) == mode)
475  {
476  // already in.
477  break;
478  }
479  }
480  state->m_operationalRateSet.push_back (mode);
481  }
482 }*/
483 void
485 {
486  NS_LOG_FUNCTION (this << address << (uint16_t) mcs);
487  NS_ASSERT (!address.IsGroup ());
488  WifiRemoteStationState *state = LookupState (address);
489  for (WifiMcsListIterator i = state->m_operationalMcsSet.begin (); i != state->m_operationalMcsSet.end (); i++)
490  {
491  if ((*i) == mcs)
492  {
493  // already in.
494  return;
495  }
496  }
497  state->m_operationalMcsSet.push_back (mcs);
498 }
499 bool
501 {
502  if (address.IsGroup ())
503  {
504  return false;
505  }
507 }
508 bool
510 {
511  if (address.IsGroup ())
512  {
513  return true;
514  }
516 }
517 bool
519 {
520  if (address.IsGroup ())
521  {
522  return false;
523  }
525 }
526 void
528 {
529  NS_ASSERT (!address.IsGroup ());
531 }
532 void
534 {
535  NS_ASSERT (!address.IsGroup ());
537 }
538 void
540 {
541  NS_ASSERT (!address.IsGroup ());
543 }
544 void
546 {
547  NS_ASSERT (!address.IsGroup ());
549 }
550 void
552  Ptr<const Packet> packet, uint32_t fullPacketSize)
553 {
554  NS_LOG_FUNCTION (this << address << *header << packet << fullPacketSize);
555  if (IsLowLatency () || address.IsGroup ())
556  {
557  return;
558  }
559  WifiRemoteStation *station = Lookup (address, header);
560  WifiTxVector rts = DoGetRtsTxVector (station);
561  WifiTxVector data = DoGetDataTxVector (station, fullPacketSize);
562  WifiTxVector ctstoself = DoGetCtsToSelfTxVector ();
565  HighLatencyCtsToSelfTxVectorTag ctstoselftag;
566  // first, make sure that the tag is not here anymore.
567  ConstCast<Packet> (packet)->RemovePacketTag (datatag);
568  ConstCast<Packet> (packet)->RemovePacketTag (rtstag);
569  ConstCast<Packet> (packet)->RemovePacketTag (ctstoselftag);
570  datatag = HighLatencyDataTxVectorTag (data);
571  rtstag = HighLatencyRtsTxVectorTag (rts);
572  ctstoselftag = HighLatencyCtsToSelfTxVectorTag (ctstoself);
573  // and then, add it back
574  packet->AddPacketTag (datatag);
575  packet->AddPacketTag (rtstag);
576  packet->AddPacketTag (ctstoselftag);
577 }
580  Ptr<const Packet> packet, uint32_t fullPacketSize)
581 {
582  NS_LOG_FUNCTION (this << address << *header << packet << fullPacketSize);
583  if (address.IsGroup ())
584  {
585  WifiTxVector v;
586  v.SetMode (GetNonUnicastMode ());
588  v.SetShortGuardInterval (false);
589  v.SetNss (1);
590  v.SetNess (0);
591  v.SetStbc (false);
592  return v;
593  }
594  if (!IsLowLatency ())
595  {
597  bool found;
598  found = ConstCast<Packet> (packet)->PeekPacketTag (datatag);
599  NS_ASSERT (found);
600  // cast found to void, to suppress 'found' set but not used
601  // compiler warning
602  (void) found;
603  return datatag.GetDataTxVector ();
604  }
605  return DoGetDataTxVector (Lookup (address, header), fullPacketSize);
606 }
609  Ptr<const Packet> packet)
610 {
611  NS_LOG_FUNCTION (this << *header << packet);
612  if (!IsLowLatency ())
613  {
614  HighLatencyCtsToSelfTxVectorTag ctstoselftag;
615  bool found;
616  found = ConstCast<Packet> (packet)->PeekPacketTag (ctstoselftag);
617  NS_ASSERT (found);
618  // cast found to void, to suppress 'found' set but not used
619  // compiler warning
620  (void) found;
621  return ctstoselftag.GetCtsToSelfTxVector ();
622  }
623  return DoGetCtsToSelfTxVector ();
624 }
625 
628 {
630 }
631 
634  Ptr<const Packet> packet)
635 {
636  NS_LOG_FUNCTION (this << address << *header << packet);
637  NS_ASSERT (!address.IsGroup ());
638  if (!IsLowLatency ())
639  {
641  bool found;
642  found = ConstCast<Packet> (packet)->PeekPacketTag (rtstag);
643  NS_ASSERT (found);
644  // cast found to void, to suppress 'found' set but not used
645  // compiler warning
646  (void) found;
647  return rtstag.GetRtsTxVector ();
648  }
649  return DoGetRtsTxVector (Lookup (address, header));
650 }
651 void
653 {
654  NS_LOG_FUNCTION (this << address << *header);
655  NS_ASSERT (!address.IsGroup ());
656  WifiRemoteStation *station = Lookup (address, header);
657  station->m_ssrc++;
658  m_macTxRtsFailed (address);
659  DoReportRtsFailed (station);
660 }
661 void
663 {
664  NS_LOG_FUNCTION (this << address << *header);
665  NS_ASSERT (!address.IsGroup ());
666  WifiRemoteStation *station = Lookup (address, header);
667  station->m_slrc++;
668  m_macTxDataFailed (address);
669  DoReportDataFailed (station);
670 }
671 void
673  double ctsSnr, WifiMode ctsMode, double rtsSnr)
674 {
675  NS_LOG_FUNCTION (this << address << *header << ctsSnr << ctsMode << rtsSnr);
676  NS_ASSERT (!address.IsGroup ());
677  WifiRemoteStation *station = Lookup (address, header);
678  station->m_state->m_info.NotifyTxSuccess (station->m_ssrc);
679  station->m_ssrc = 0;
680  DoReportRtsOk (station, ctsSnr, ctsMode, rtsSnr);
681 }
682 void
684  double ackSnr, WifiMode ackMode, double dataSnr)
685 {
686  NS_LOG_FUNCTION (this << address << *header << ackSnr << ackMode << dataSnr);
687  NS_ASSERT (!address.IsGroup ());
688  WifiRemoteStation *station = Lookup (address, header);
689  station->m_state->m_info.NotifyTxSuccess (station->m_slrc);
690  station->m_slrc = 0;
691  DoReportDataOk (station, ackSnr, ackMode, dataSnr);
692 }
693 void
695 {
696  NS_LOG_FUNCTION (this << address << *header);
697  NS_ASSERT (!address.IsGroup ());
698  WifiRemoteStation *station = Lookup (address, header);
699  station->m_state->m_info.NotifyTxFailed ();
700  station->m_ssrc = 0;
701  m_macTxFinalRtsFailed (address);
702  DoReportFinalRtsFailed (station);
703 }
704 void
706 {
707  NS_LOG_FUNCTION (this << address << *header);
708  NS_ASSERT (!address.IsGroup ());
709  WifiRemoteStation *station = Lookup (address, header);
710  station->m_state->m_info.NotifyTxFailed ();
711  station->m_slrc = 0;
712  m_macTxFinalDataFailed (address);
713  DoReportFinalDataFailed (station);
714 }
715 void
717  double rxSnr, WifiMode txMode)
718 {
719  NS_LOG_FUNCTION (this << address << *header << rxSnr << txMode);
720  if (address.IsGroup ())
721  {
722  return;
723  }
724  WifiRemoteStation *station = Lookup (address, header);
725  DoReportRxOk (station, rxSnr, txMode);
726 }
727 bool
729  Ptr<const Packet> packet)
730 {
731  NS_LOG_FUNCTION (this << address << *header << packet);
732  if (address.IsGroup ())
733  {
734  return false;
735  }
736  bool normally = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > GetRtsCtsThreshold ();
737  return DoNeedRts (Lookup (address, header), packet, normally);
738 }
739 bool
741 {
742  NS_LOG_FUNCTION (this << txVector);
743  WifiMode mode = txVector.GetMode();
744 
745  // search the BSS Basic Rate set if the used mode in the basic set then no need for Cts to self
746  for (WifiModeListIterator i = m_bssBasicRateSet.begin ();
747  i != m_bssBasicRateSet.end (); i++)
748  {
749  if (mode == *i)
750  {
751  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
752  return false;
753  }
754  }
755  if (HasHtSupported())
756  {
757  uint8_t mcs = m_wifiPhy->WifiModeToMcs (mode);
758  for (WifiMcsListIterator i = m_bssBasicMcsSet.begin ();
759  i != m_bssBasicMcsSet.end (); i++)
760  {
761  if (mcs == *i)
762  {
763  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
764  return false;
765  }
766  }
767  }
768  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true");
769  return true;
770 }
771 bool
773  Ptr<const Packet> packet)
774 {
775  NS_LOG_FUNCTION (this << address << packet << *header);
776  NS_ASSERT (!address.IsGroup ());
777  WifiRemoteStation *station = Lookup (address, header);
778  bool normally = station->m_ssrc < GetMaxSsrc ();
779  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedDataRetransmission count: " << station->m_ssrc << " result: " << std::boolalpha << normally);
780  return DoNeedRtsRetransmission (station, packet, normally);
781 }
782 bool
784  Ptr<const Packet> packet)
785 {
786  NS_LOG_FUNCTION (this << address << packet << *header);
787  NS_ASSERT (!address.IsGroup ());
788  WifiRemoteStation *station = Lookup (address, header);
789  bool normally = station->m_slrc < GetMaxSlrc ();
790  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedDataRetransmission count: " << station->m_slrc << " result: " << std::boolalpha << normally);
791  return DoNeedDataRetransmission (station, packet, normally);
792 }
793 bool
795  Ptr<const Packet> packet)
796 {
797  NS_LOG_FUNCTION (this << address << packet << *header);
798  if (address.IsGroup ())
799  {
800  return false;
801  }
802  WifiRemoteStation *station = Lookup (address, header);
803  bool normally = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > GetFragmentationThreshold ();
804  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedFragmentation result: " << std::boolalpha << normally);
805  return DoNeedFragmentation (station, packet, normally);
806 }
807 
808 void
810 {
811  NS_LOG_FUNCTION (this << threshold);
812  if (threshold < 256)
813  {
814  /*
815  * ASN.1 encoding of the MAC and PHY MIB (256 ... 8000)
816  */
817  NS_LOG_WARN ("Fragmentation threshold should be larger than 256. Setting to 256.");
819  }
820  else
821  {
822  /*
823  * The length of each fragment shall be an even number of octets, except for the last fragment if an MSDU or
824  * MMPDU, which may be either an even or an odd number of octets.
825  */
826  if (threshold % 2 != 0)
827  {
828  NS_LOG_WARN ("Fragmentation threshold should be an even number. Setting to " << threshold - 1);
829  m_fragmentationThreshold = threshold - 1;
830  }
831  else
832  {
833  m_fragmentationThreshold = threshold;
834  }
835  }
836 }
837 
838 uint32_t
840 {
842 }
843 
844 uint32_t
846 {
847  NS_LOG_FUNCTION (this << *header << packet);
848  //The number of bytes a fragment can support is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
849  uint32_t nFragments = (packet->GetSize () / (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
850 
851  //If the size of the last fragment is not 0.
852  if ((packet->GetSize () % (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH)) > 0)
853  {
854  nFragments++;
855  }
856  NS_LOG_DEBUG ("WifiRemoteStationManager::GetNFragments returning " << nFragments);
857  return nFragments;
858 }
859 
860 uint32_t
862  Ptr<const Packet> packet, uint32_t fragmentNumber)
863 {
864  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
865  NS_ASSERT (!address.IsGroup ());
866  uint32_t nFragment = GetNFragments (header, packet);
867  if (fragmentNumber >= nFragment)
868  {
869  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning 0");
870  return 0;
871  }
872  //Last fragment
873  if (fragmentNumber == nFragment - 1)
874  {
875  uint32_t lastFragmentSize = packet->GetSize () - (fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
876  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << lastFragmentSize);
877  return lastFragmentSize;
878  }
879  //All fragments but the last, the number of bytes is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
880  else
881  {
882  uint32_t fragmentSize = GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH;
883  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << fragmentSize);
884  return fragmentSize;
885  }
886 }
887 uint32_t
889  Ptr<const Packet> packet, uint32_t fragmentNumber)
890 {
891  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
892  NS_ASSERT (!address.IsGroup ());
893  NS_ASSERT (fragmentNumber < GetNFragments (header, packet));
894  uint32_t fragmentOffset = fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH);
895  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentOffset returning " << fragmentOffset);
896  return fragmentOffset;
897 }
898 bool
900  Ptr<const Packet> packet, uint32_t fragmentNumber)
901 {
902  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
903  NS_ASSERT (!address.IsGroup ());
904  bool isLast = fragmentNumber == (GetNFragments (header, packet) - 1);
905  NS_LOG_DEBUG ("WifiRemoteStationManager::IsLastFragment returning " << std::boolalpha << isLast);
906  return isLast;
907 }
908 WifiMode
910 {
925  NS_LOG_FUNCTION (this << address << reqMode);
926  WifiMode mode = GetDefaultMode ();
927  bool found = false;
928 
929  // First, search the BSS Basic Rate set
930  for (WifiModeListIterator i = m_bssBasicRateSet.begin ();
931  i != m_bssBasicRateSet.end (); i++)
932  {
933  if ((!found || i->GetPhyRate () > mode.GetPhyRate ())
934  && i->GetPhyRate () <= reqMode.GetPhyRate ()
935  && i->GetModulationClass () == reqMode.GetModulationClass ())
936  {
937  mode = *i;
938  // We've found a potentially-suitable transmit rate, but we
939  // need to continue and consider all the basic rates before
940  // we can be sure we've got the right one.
941  found = true;
942  }
943  }
944  if(HasHtSupported())
945  {
946  if (!found)
947  {
948  uint8_t mcs = GetDefaultMcs ();
949  mode= m_wifiPhy->McsToWifiMode (mcs);
950  }
951  for (WifiMcsListIterator i = m_bssBasicMcsSet.begin ();
952  i != m_bssBasicMcsSet.end (); i++)
953  {
954  WifiMode thismode= m_wifiPhy->McsToWifiMode (*i);
955  if ((!found || thismode.GetPhyRate () > mode.GetPhyRate ())
956  && thismode.GetPhyRate () <= reqMode.GetPhyRate ()
957  && thismode.GetModulationClass () == reqMode.GetModulationClass ())
958  {
959  mode = thismode;
960  // We've found a potentially-suitable transmit rate, but we
961  // need to continue and consider all the basic rates before
962  // we can be sure we've got the right one.
963  found = true;
964  }
965  }
966  }
967  // If we found a suitable rate in the BSSBasicRateSet, then we are
968  // done and can return that mode.
969  if (found)
970  {
971  return mode;
972  }
973 
991  for (uint32_t idx = 0; idx < m_wifiPhy->GetNModes (); idx++)
992  {
993  WifiMode thismode = m_wifiPhy->GetMode (idx);
994 
995  /* If the rate:
996  *
997  * - is a mandatory rate for the PHY, and
998  * - is equal to or faster than our current best choice, and
999  * - is less than or equal to the rate of the received frame, and
1000  * - is of the same modulation class as the received frame
1001  *
1002  * ...then it's our best choice so far.
1003  */
1004  if (thismode.IsMandatory ()
1005  && (!found || thismode.GetPhyRate () > mode.GetPhyRate ())
1006  && thismode.GetPhyRate () <= reqMode.GetPhyRate ()
1007  && thismode.GetModulationClass () == reqMode.GetModulationClass ())
1008  {
1009  mode = thismode;
1010  // As above; we've found a potentially-suitable transmit
1011  // rate, but we need to continue and consider all the
1012  // mandatory rates before we can be sure we've got the right
1013  // one.
1014  found = true;
1015  }
1016  }
1017  if(HasHtSupported())
1018  {
1019  for (uint32_t idx = 0; idx < m_wifiPhy->GetNMcs (); idx++)
1020  {
1021  uint8_t thismcs = m_wifiPhy->GetMcs (idx);
1022  WifiMode thismode= m_wifiPhy->McsToWifiMode (thismcs);
1023  if (thismode.IsMandatory ()
1024  && (!found || thismode.GetPhyRate () > mode.GetPhyRate ())
1025  && thismode.GetPhyRate () <= reqMode.GetPhyRate ()
1026  && thismode.GetModulationClass () == reqMode.GetModulationClass ())
1027  {
1028  mode = thismode;
1029  // As above; we've found a potentially-suitable transmit
1030  // rate, but we need to continue and consider all the
1031  // mandatory rates before we can be sure we've got the right
1032  // one.
1033  found = true;
1034  }
1035 
1036  }
1037  }
1038 
1049  if (!found)
1050  {
1051  NS_FATAL_ERROR ("Can't find response rate for " << reqMode
1052  << ". Check standard and selected rates match.");
1053  }
1054 
1055  NS_LOG_DEBUG ("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
1056  return mode;
1057 }
1058 
1061 {
1062  NS_ASSERT (!address.IsGroup ());
1063  WifiTxVector v;
1064  v.SetMode (GetControlAnswerMode (address, rtsMode));
1065  v.SetTxPowerLevel (DoGetCtsTxPowerLevel (address, v.GetMode()));
1066  v.SetShortGuardInterval (DoGetCtsTxGuardInterval(address, v.GetMode()));
1067  v.SetNss (DoGetCtsTxNss(address, v.GetMode()));
1068  v.SetNess (DoGetCtsTxNess(address, v.GetMode()));
1069  v.SetStbc (DoGetCtsTxStbc(address, v.GetMode()));
1070  return v;
1071 }
1074 {
1075  NS_ASSERT (!address.IsGroup ());
1076  WifiTxVector v;
1077  v.SetMode (GetControlAnswerMode (address, dataMode));
1078  v.SetTxPowerLevel (DoGetAckTxPowerLevel (address, v.GetMode()));
1079  v.SetShortGuardInterval(DoGetAckTxGuardInterval(address, v.GetMode()));
1080  v.SetNss(DoGetAckTxNss(address, v.GetMode()));
1081  v.SetNess(DoGetAckTxNess(address, v.GetMode()));
1082  v.SetStbc(DoGetAckTxStbc(address, v.GetMode()));
1083  return v;
1084 }
1087 {
1088  NS_ASSERT (!address.IsGroup ());
1089  WifiTxVector v;
1090  v.SetMode (GetControlAnswerMode (address, blockAckReqMode));
1091  v.SetTxPowerLevel (DoGetBlockAckTxPowerLevel (address, v.GetMode()));
1092  v.SetShortGuardInterval (DoGetBlockAckTxGuardInterval(address, v.GetMode()));
1093  v.SetNss (DoGetBlockAckTxNss(address, v.GetMode()));
1094  v.SetNess (DoGetBlockAckTxNess(address, v.GetMode()));
1095  v.SetStbc (DoGetBlockAckTxStbc(address, v.GetMode()));
1096  return v;
1097 }
1098 
1099 uint8_t
1101 {
1102  return m_defaultTxPowerLevel;
1103 }
1104 
1105 bool
1107 {
1108  return m_wifiPhy->GetGuardInterval();
1109 }
1110 
1111 uint8_t
1113 {
1114  return 1;
1115 }
1116 uint8_t
1118 {
1119  return 0;
1120 }
1121 bool
1123 {
1124  return m_wifiPhy->GetStbc();
1125 }
1126 
1127 uint8_t
1129 {
1130  return m_defaultTxPowerLevel;
1131 }
1132 
1133 bool
1135 {
1136  return m_wifiPhy->GetGuardInterval();
1137 }
1138 
1139 uint8_t
1141 {
1142  return 1;
1143 }
1144 uint8_t
1146 {
1147  return 0;
1148 }
1149 bool
1151 {
1152  return m_wifiPhy->GetStbc();
1153 }
1154 
1155 uint8_t
1157 {
1158  return m_defaultTxPowerLevel;
1159 }
1160 
1161 bool
1163 {
1164  return m_wifiPhy->GetGuardInterval();
1165 }
1166 
1167 uint8_t
1169 {
1170  return 1;
1171 }
1172 uint8_t
1174 {
1175  return 0;
1176 }
1177 bool
1179 {
1180  return m_wifiPhy->GetStbc();
1181 }
1182 
1183 
1184 uint8_t
1186 {
1187  return m_defaultTxPowerLevel;
1188 }
1189 
1190 
1193 {
1194  WifiRemoteStationState *state = LookupState (address);
1195  return state->m_info;
1196 }
1197 
1200 {
1201  NS_LOG_FUNCTION (this << address);
1202  for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
1203  {
1204  if ((*i)->m_address == address)
1205  {
1206  NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning existing state");
1207  return (*i);
1208  }
1209  }
1212  state->m_address = address;
1213  state->m_operationalRateSet.push_back (GetDefaultMode ());
1214  state->m_operationalMcsSet.push_back(GetDefaultMcs());
1217  state->m_rx=1;
1218  state->m_tx=1;
1219  state->m_ness=0;
1220  state->m_stbc=false;
1221  const_cast<WifiRemoteStationManager *> (this)->m_states.push_back (state);
1222  NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning new state");
1223  return state;
1224 }
1227 {
1228  uint8_t tid;
1229  if (header->IsQosData ())
1230  {
1231  tid = header->GetQosTid ();
1232  }
1233  else
1234  {
1235  tid = 0;
1236  }
1237  return Lookup (address, tid);
1238 }
1241 {
1242  NS_LOG_FUNCTION (this << address << (uint16_t) tid);
1243  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1244  {
1245  if ((*i)->m_tid == tid
1246  && (*i)->m_state->m_address == address)
1247  {
1248  return (*i);
1249  }
1250  }
1251  WifiRemoteStationState *state = LookupState (address);
1252 
1253  WifiRemoteStation *station = DoCreateStation ();
1254  station->m_state = state;
1255  station->m_tid = tid;
1256  station->m_ssrc = 0;
1257  station->m_slrc = 0;
1258  // XXX
1259  const_cast<WifiRemoteStationManager *> (this)->m_stations.push_back (station);
1260  return station;
1261 
1262 }
1263 //Used by all stations to record HT capabilities of remote stations
1264 void
1266 {
1267  NS_LOG_FUNCTION (this << from << htcapabilities);
1268  WifiRemoteStationState *state;
1269  state=LookupState (from);
1270  state->m_shortGuardInterval=htcapabilities.GetShortGuardInterval20();
1271  state->m_greenfield=htcapabilities.GetGreenfield();
1272 
1273 }
1274 //Used by mac low to choose format used GF, MF or Non HT
1275 bool
1277 {
1278  return LookupState(address)->m_greenfield;
1279 }
1280 WifiMode
1282 {
1283  return m_defaultTxMode;
1284 }
1285 uint8_t
1287 {
1288  return m_defaultTxMcs;
1289 }
1290 void
1292 {
1293  NS_LOG_FUNCTION (this);
1294  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1295  {
1296  delete (*i);
1297  }
1298  m_stations.clear ();
1299  m_bssBasicRateSet.clear ();
1300  m_bssBasicRateSet.push_back (m_defaultTxMode);
1301  m_bssBasicMcsSet.clear();
1302  m_bssBasicMcsSet.push_back (m_defaultTxMcs);
1304 }
1305 void
1307 {
1308  NS_LOG_FUNCTION (this << mode);
1309  for (uint32_t i = 0; i < GetNBasicModes (); i++)
1310  {
1311  if (GetBasicMode (i) == mode)
1312  {
1313  return;
1314  }
1315  }
1316  m_bssBasicRateSet.push_back (mode);
1317 }
1318 uint32_t
1320 {
1321  return m_bssBasicRateSet.size ();
1322 }
1323 WifiMode
1325 {
1326  NS_ASSERT (i < m_bssBasicRateSet.size ());
1327  return m_bssBasicRateSet[i];
1328 }
1329 
1330 void
1332 {
1333  for (uint32_t i = 0; i < GetNBasicMcs (); i++)
1334  {
1335  if (GetBasicMcs (i) == mcs)
1336  {
1337  return;
1338  }
1339  }
1340  m_bssBasicMcsSet.push_back (mcs);
1341 }
1342 
1343 uint32_t
1345 {
1346  return m_bssBasicMcsSet.size ();
1347 }
1348 uint8_t
1350 {
1351  NS_ASSERT (i < m_bssBasicMcsSet.size ());
1352  return m_bssBasicMcsSet[i];
1353 }
1354 
1355 WifiMode
1357 {
1358  if (m_nonUnicastMode == WifiMode ())
1359  {
1360  return GetBasicMode (0);
1361  }
1362  else
1363  {
1364  return m_nonUnicastMode;
1365  }
1366 }
1367 
1368 bool
1370  Ptr<const Packet> packet, bool normally)
1371 {
1372  return normally;
1373 }
1374 bool
1376  Ptr<const Packet> packet, bool normally)
1377 {
1378  return normally;
1379 }
1380 bool
1382  Ptr<const Packet> packet, bool normally)
1383 {
1384  return normally;
1385 }
1386 bool
1388  Ptr<const Packet> packet, bool normally)
1389 {
1390  return normally;
1391 }
1392 
1393 WifiMode
1395 {
1396  NS_ASSERT (i < GetNSupported (station));
1397  return station->m_state->m_operationalRateSet[i];
1398 }
1399 uint8_t
1401 {
1402  NS_ASSERT (i < GetNMcsSupported (station));
1403  return station->m_state->m_operationalMcsSet[i];
1404 }
1405 bool
1407 {
1408  return station->m_state->m_shortGuardInterval;
1409 }
1410 bool
1412 {
1413  return station->m_state->m_greenfield;
1414 }
1415 bool
1417 {
1418  return station->m_state->m_stbc;
1419 }
1420 uint32_t
1422 {
1423  return station->m_state->m_rx;
1424 }
1425 uint32_t
1427 {
1428  return station->m_state->m_tx;
1429 }
1430 uint32_t
1432 {
1433  return station->m_state->m_ness;
1434 }
1435 uint32_t
1437 {
1438  return station->m_ssrc;
1439 }
1440 
1443 {
1444  return m_wifiPhy;
1445 }
1448 {
1449  return m_wifiMac;
1450 }
1451 
1452 uint32_t
1454 {
1455  return station->m_slrc;
1456 }
1457 uint32_t
1459 {
1460  return station->m_state->m_operationalRateSet.size ();
1461 }
1462 uint32_t
1464 {
1465  return station->m_state->m_operationalMcsSet.size ();
1466 }
1467 void
1469 {
1470  m_defaultTxPowerLevel = txPower;
1471 }
1472 
1473 //support 11n
1474 uint32_t
1476 {
1478 }
1479 //WifiRemoteStationInfo constructor
1481  : m_memoryTime (Seconds (1.0)),
1482  m_lastUpdate (Seconds (0.0)),
1483  m_failAvg (0.0)
1484 {
1485 }
1486 
1487 double
1489 {
1490  double retval = std::exp ((double)(m_lastUpdate.GetMicroSeconds () - Simulator::Now ().GetMicroSeconds ())
1491  / (double)m_memoryTime.GetMicroSeconds ());
1493  return retval;
1494 }
1495 
1496 void
1498 {
1499  double coefficient = CalculateAveragingCoefficient ();
1500  m_failAvg = (double)retryCounter / (1 + (double) retryCounter) * (1.0 - coefficient) + coefficient * m_failAvg;
1501 }
1502 
1503 void
1505 {
1506  double coefficient = CalculateAveragingCoefficient ();
1507  m_failAvg = (1.0 - coefficient) + coefficient * m_failAvg;
1508 }
1509 
1510 double
1512 {
1513  return m_failAvg;
1514 }
1515 
1517 {
1518  NS_LOG_FUNCTION (this);
1519 }
1520 
1521 } // 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.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
virtual void Print(std::ostream &os) const
bool GetGreenfieldSupported(Mac48Address address) const
Return whether the station supports Greenfield or not.
AttributeValue implementation for Boolean.
Definition: boolean.h:34
bool m_shortGuardInterval
Flag if short guard interval is supported by the remote station.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
uint32_t m_rtsCtsThreshold
Threshold for RTS/CTS.
bool NeedDataRetransmission(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
uint8_t 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)
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: boolean.h:81
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition: packet.cc:836
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:201
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:766
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:100
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:198
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:93
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)
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
void RecordDisassociated(Mac48Address address)
Records that the STA was disassociated.
TracedCallback< Mac48Address > m_macTxFinalDataFailed
The trace source fired when the transmission of a data packet has exceeded the maximum number of atte...
Ptr< WifiPhy > GetPhy(void) const
Return the WifiPhy.
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
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:335
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)
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Hold an unsigned integer type.
Definition: uinteger.h:44
virtual void DoReportDataFailed(WifiRemoteStation *station)=0
This method is a pure virtual method that must be implemented by the sub-class.
uint8_t data[writeSize]
bool m_stbc
Flag if STBC is used by the remote station.
void RecordGotAssocTxFailed(Mac48Address address)
Records that we missed an ACK for the association response we sent.
WifiMode GetBasicMode(uint32_t i) const
Return a basic mode from the set of basic modes.
uint32_t GetFragmentationThreshold(void) const
Return the fragmentation threshold.
void AddStationHtCapabilities(Mac48Address from, HtCapabilities htcapabilities)
Records HT capabilities of the remote station.
WifiRemoteStationInfo GetInfo(Mac48Address address)
void SetMaxSsrc(uint32_t maxSsrc)
Sets the maximum STA short retry count (SSRC).
uint32_t GetRtsCtsThreshold(void) const
Return the RTS threshold.
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.
Ptr< WifiMac > m_wifiMac
This is a pointer to the WifiMac associated with this WifiRemoteStationManager that is set on call to...
uint32_t DoGetFragmentationThreshold(void) const
Return the current fragmentation threshold.
virtual bool GetGuardInterval(void) const =0
hold a list of per-remote-station state.
virtual void Print(std::ostream &os) const
WifiMode GetControlAnswerMode(Mac48Address address, WifiMode reqMode)
uint32_t GetNBasicMcs(void) const
Return the number of basic MCS index.
uint32_t m_tx
Number of TX antennas of the remote station.
WifiMode m_defaultTxMode
The default transmission mode.
uint32_t GetNess(const WifiRemoteStation *station) const
void SetNss(uint8_t nss)
Sets the number of Nss refer to IEEE 802.11n Table 20-28 for explanation and range.
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)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
WifiTxVector DoGetCtsToSelfTxVector(void)
Since CTS-to-self parameters are not dependent on the station, it is implemented in wifiremote statio...
void AddSupportedMode(Mac48Address address, WifiMode mode)
Invoked in a STA or AP to store the set of modes supported by a destination which is also supported l...
bool IsGroup(void) const
WifiModeList m_operationalRateSet
This member is the list of WifiMode objects that comprise the OperationalRateSet parameter for this r...
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
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
Get the most derived TypeId for this Object.
void AddBasicMode(WifiMode mode)
Invoked in a STA upon association to store the set of rates which belong to the BSSBasicRateSet of th...
bool m_htSupported
Flag if HT capability is supported.
WifiModeList::const_iterator WifiModeListIterator
An iterator for WifiModeList vector.
Definition: wifi-mode.h:189
virtual uint32_t GetSerializedSize(void) const
an EUI-48 address
Definition: mac48-address.h:43
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.
Ptr< const AttributeAccessor > MakeWifiModeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: wifi-mode.h:177
bool GetShortGuardInterval(const WifiRemoteStation *station) const
Return whether the given station supports short guard interval.
Stations m_stations
Information for each known stations.
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:223
void ReportRtsOk(Mac48Address address, const WifiMacHeader *header, double ctsSnr, WifiMode ctsMode, double rtsSnr)
Should be invoked whenever we receive the Cts associated to an RTS we just sent.
TracedCallback< Mac48Address > m_macTxDataFailed
The trace source fired when the transmission of a single data packet has failed.
uint32_t m_rx
Number of RX antennas of the remote station.
virtual void SetupMac(Ptr< WifiMac > mac)
Set up MAC associated with this device since it is the object that knows the full set of timing param...
double GetFrameErrorRate() const
Return frame error rate (probability that frame is corrupted due to transmission error).
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
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:228
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
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:236
virtual void DoDispose(void)
Destructor implementation.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:859
WifiTxVector GetDataTxVector(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fullPacketSize)
void ReportRxOk(Mac48Address address, const WifiMacHeader *header, double rxSnr, WifiMode txMode)
bool NeedFragmentation(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
void SetNess(uint8_t ness)
Sets the Ness number refer to IEEE 802.11n Table 20-6 for explanation.
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.
Ptr< const AttributeChecker > MakeWifiModeChecker(void)
Definition: wifi-mode.cc:133
virtual uint8_t DoGetCtsTxNess(Mac48Address address, WifiMode ctsMode)
WifiTxVector GetRtsTxVector(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
A base class which provides memory management and object aggregation.
Definition: object.h:87
tuple address
Definition: first.py:37
virtual uint32_t GetSerializedSize(void) const
AttributeValue implementation for WifiMode.
Definition: wifi-mode.h:177
StationStates m_states
States of known stations.
WifiMode GetMode(void) const
bool NeedRts(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
WifiTxVector GetBlockAckTxVector(Mac48Address address, WifiMode dataMode)
virtual uint8_t DoGetCtsTxPowerLevel(Mac48Address address, WifiMode ctsMode)
virtual void Print(std::ostream &os) const
uint32_t GetMaxSlrc(void) const
Return the maximum STA long retry count (SLRC).
uint32_t m_slrc
STA long retry count.
void AddAllSupportedModes(Mac48Address address)
Invoked in a STA or AP to store all of the modes supported by a destination which is also supported l...
virtual void DoReportFinalDataFailed(WifiRemoteStation *station)=0
This method is a pure virtual method that must be implemented by the sub-class.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: uinteger.h:45
virtual WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station)=0
a unique identifier for an interface.
Definition: type-id.h:51
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:631
uint32_t m_ness
Number of streams in beamforming of the remote station.
virtual void DoReportFinalRtsFailed(WifiRemoteStation *station)=0
This method is a pure virtual method that must be implemented by the sub-class.
virtual bool GetGreenfield(void) const =0
hold per-remote-station state.
virtual WifiRemoteStation * DoCreateStation(void) const =0
void RecordGotAssocTxOk(Mac48Address address)
Records that we got an ACK for the association response we sent.
Implements the IEEE 802.11 MAC header.
virtual uint8_t DoGetBlockAckTxPowerLevel(Mac48Address address, WifiMode blockAckMode)
Ptr< WifiMac > GetMac(void) const
Return the WifiMac.
virtual void DoReportDataOk(WifiRemoteStation *station, double ackSnr, WifiMode ackMode, double dataSnr)=0
This method is a pure virtual method that must be implemented by the sub-class.