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  .SetGroupName ("Wifi")
83  .AddConstructor<HighLatencyDataTxVectorTag> ()
84  ;
85  return tid;
86 }
87 TypeId
89 {
90  return GetTypeId ();
91 }
92 uint32_t
94 {
95  return sizeof (WifiTxVector);
96 }
97 void
99 {
100  i.Write ((uint8_t *)&m_dataTxVector, sizeof (WifiTxVector));
101 }
102 void
104 {
105  i.Read ((uint8_t *)&m_dataTxVector, sizeof (WifiTxVector));
106 }
107 void
108 HighLatencyDataTxVectorTag::Print (std::ostream &os) const
109 {
110  os << "Data=" << m_dataTxVector;
111 }
112 
114 {
115 public:
122  WifiTxVector GetRtsTxVector (void) const;
123 
124  static TypeId GetTypeId (void);
125  virtual TypeId GetInstanceTypeId (void) const;
126  virtual uint32_t GetSerializedSize (void) const;
127  virtual void Serialize (TagBuffer i) const;
128  virtual void Deserialize (TagBuffer i);
129  virtual void Print (std::ostream &os) const;
130 private:
132 };
133 
135 {
136 }
138  : m_rtsTxVector (rtsTxVector)
139 {
140 }
141 
144 {
145  return m_rtsTxVector;
146 }
147 TypeId
149 {
150  static TypeId tid = TypeId ("ns3::HighLatencyRtsTxVectorTag")
151  .SetParent<Tag> ()
152  .SetGroupName ("Wifi")
153  .AddConstructor<HighLatencyRtsTxVectorTag> ()
154  ;
155  return tid;
156 }
157 TypeId
159 {
160  return GetTypeId ();
161 }
162 uint32_t
164 {
165  return sizeof (WifiTxVector);
166 }
167 void
169 {
170  i.Write ((uint8_t *)&m_rtsTxVector, sizeof (WifiTxVector));
171 }
172 void
174 {
175  i.Read ((uint8_t *)&m_rtsTxVector, sizeof (WifiTxVector));
176 }
177 void
178 HighLatencyRtsTxVectorTag::Print (std::ostream &os) const
179 {
180  os << "Rts=" << m_rtsTxVector;
181 }
182 
184 {
185 public:
187  HighLatencyCtsToSelfTxVectorTag (WifiTxVector ctsToSelfTxVector);
191  WifiTxVector GetCtsToSelfTxVector (void) const;
192 
193  static TypeId GetTypeId (void);
194  virtual TypeId GetInstanceTypeId (void) const;
195  virtual uint32_t GetSerializedSize (void) const;
196  virtual void Serialize (TagBuffer i) const;
197  virtual void Deserialize (TagBuffer i);
198  virtual void Print (std::ostream &os) const;
199 private:
201 };
202 
204 {
205 }
207  : m_ctsToSelfTxVector (ctsToSelfTxVector)
208 {
209 }
210 
213 {
214  return m_ctsToSelfTxVector;
215 }
216 TypeId
218 {
219  static TypeId tid = TypeId ("ns3::HighLatencyCtsToSelfTxVectorTag")
220  .SetParent<Tag> ()
221  .SetGroupName ("Wifi")
222  .AddConstructor<HighLatencyCtsToSelfTxVectorTag> ()
223  ;
224  return tid;
225 }
226 TypeId
228 {
229  return GetTypeId ();
230 }
231 uint32_t
233 {
234  return sizeof (WifiTxVector);
235 }
236 void
238 {
239  i.Write ((uint8_t *)&m_ctsToSelfTxVector, sizeof (WifiTxVector));
240 }
241 void
243 {
244  i.Read ((uint8_t *)&m_ctsToSelfTxVector, sizeof (WifiTxVector));
245 }
246 void
248 {
249  os << "Cts To Self=" << m_ctsToSelfTxVector;
250 }
251 
252 } // namespace ns3
253 
254 namespace ns3 {
255 
256 NS_OBJECT_ENSURE_REGISTERED (WifiRemoteStationManager);
257 
258 TypeId
260 {
261  static TypeId tid = TypeId ("ns3::WifiRemoteStationManager")
262  .SetParent<Object> ()
263  .SetGroupName ("Wifi")
264  .AddAttribute ("IsLowLatency", "If true, we attempt to modelize a so-called low-latency device: a device"
265  " where decisions about tx parameters can be made on a per-packet basis and feedback about the"
266  " transmission of each packet is obtained before sending the next. Otherwise, we modelize a "
267  " high-latency device, that is a device where we cannot update our decision about tx parameters"
268  " after every packet transmission.",
269  BooleanValue (true), // this value is ignored because there is no setter
272  .AddAttribute ("MaxSsrc", "The maximum number of retransmission attempts for an RTS. This value"
273  " will not have any effect on some rate control algorithms.",
274  UintegerValue (7),
276  MakeUintegerChecker<uint32_t> ())
277  .AddAttribute ("MaxSlrc", "The maximum number of retransmission attempts for a DATA packet. This value"
278  " will not have any effect on some rate control algorithms.",
279  UintegerValue (7),
281  MakeUintegerChecker<uint32_t> ())
282  .AddAttribute ("RtsCtsThreshold", "If the size of the data packet + LLC header + MAC header + FCS trailer is bigger than "
283  "this value, we use an RTS/CTS handshake before sending the data, as per IEEE Std. 802.11-2012, Section 9.3.5. "
284  "This value will not have any effect on some rate control algorithms.",
285  UintegerValue (2346),
287  MakeUintegerChecker<uint32_t> ())
288  .AddAttribute ("FragmentationThreshold", "If the size of the data packet + LLC header + MAC header + FCS trailer is bigger"
289  "than this value, we fragment it such that the size of the fragments are equal or smaller "
290  "than this value, as per IEEE Std. 802.11-2012, Section 9.5. "
291  "This value will not have any effect on some rate control algorithms.",
292  UintegerValue (2346),
295  MakeUintegerChecker<uint32_t> ())
296  .AddAttribute ("NonUnicastMode", "Wifi mode used for non-unicast transmissions.",
297  WifiModeValue (),
300  .AddAttribute ("DefaultTxPowerLevel", "Default power level to be used for transmissions. "
301  "This is the power level that is used by all those WifiManagers that do not"
302  "implement TX power control.",
303  UintegerValue (0),
305  MakeUintegerChecker<uint8_t> ())
306  .AddTraceSource ("MacTxRtsFailed",
307  "The transmission of a RTS by the MAC layer has failed",
309  "ns3::Mac48Address::TracedCallback")
310  .AddTraceSource ("MacTxDataFailed",
311  "The transmission of a data packet by the MAC layer has failed",
313  "ns3::Mac48Address::TracedCallback")
314  .AddTraceSource ("MacTxFinalRtsFailed",
315  "The transmission of a RTS has exceeded the maximum number of attempts",
317  "ns3::Mac48Address::TracedCallback")
318  .AddTraceSource ("MacTxFinalDataFailed",
319  "The transmission of a data packet has exceeded the maximum number of attempts",
321  "ns3::Mac48Address::TracedCallback")
322  ;
323  return tid;
324 }
325 
327  : m_htSupported (false)
328 {
329 }
330 
332 {
333 }
334 void
336 {
337  for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
338  {
339  delete (*i);
340  }
341  m_states.clear ();
342  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
343  {
344  delete (*i);
345  }
346  m_stations.clear ();
347 }
348 void
350 {
351  // We need to track our PHY because it is the object that knows the
352  // full set of transmit rates that are supported. We need to know
353  // this in order to find the relevant mandatory rates when chosing a
354  // transmit rate for automatic control responses like
355  // acknowledgements.
356  m_wifiPhy = phy;
357  m_defaultTxMode = phy->GetMode (0);
358  if(HasHtSupported())
359  {
360  m_defaultTxMcs = phy->GetMcs (0);
361  }
362  else
363  {
364  m_defaultTxMcs = 0;
365  }
366  Reset ();
367 }
368 void
370 {
371  // We need to track our MAC because it is the object that knows the
372  // full set of interframe spaces.
373  m_wifiMac = mac;
374  Reset ();
375 }
376 void
378 {
379  m_htSupported=enable;
380 }
381 
382 bool
384 {
385  return m_htSupported;
386 }
387 uint32_t
389 {
390  return m_maxSsrc;
391 }
392 uint32_t
394 {
395  return m_maxSlrc;
396 }
397 uint32_t
399 {
400  return m_rtsCtsThreshold;
401 }
402 uint32_t
404 {
405  return DoGetFragmentationThreshold ();
406 }
407 void
409 {
410  m_maxSsrc = maxSsrc;
411 }
412 void
414 {
415  m_maxSlrc = maxSlrc;
416 }
417 void
419 {
420  m_rtsCtsThreshold = threshold;
421 }
422 void
424 {
425  DoSetFragmentationThreshold (threshold);
426 }
427 
428 void
430 {
431  NS_LOG_FUNCTION (this << address);
432  NS_ASSERT (!address.IsGroup ());
433  WifiRemoteStationState *state = LookupState (address);
434  state->m_operationalRateSet.clear ();
435  state->m_operationalMcsSet.clear ();
436  AddSupportedMode (address, GetDefaultMode ());
437  AddSupportedMcs(address,GetDefaultMcs());
438 }
439 void
441 {
442  NS_LOG_FUNCTION (this << address << mode);
443  NS_ASSERT (!address.IsGroup ());
444  WifiRemoteStationState *state = LookupState (address);
445  for (WifiModeListIterator i = state->m_operationalRateSet.begin (); i != state->m_operationalRateSet.end (); i++)
446  {
447  if ((*i) == mode)
448  {
449  // already in.
450  return;
451  }
452  }
453  state->m_operationalRateSet.push_back (mode);
454 }
455 void
457 {
458  NS_ASSERT (!address.IsGroup ());
459  WifiRemoteStationState *state = LookupState (address);
460  state->m_operationalRateSet.clear ();
461  for (uint32_t i = 0; i < m_wifiPhy->GetNModes (); i++)
462  {
463  state->m_operationalRateSet.push_back ( m_wifiPhy->GetMode (i));
464  }
465 }
466 
467 /*void
468 WifiRemoteStationManager::AddBssMembershipParameters(Mac48Address address, uint32_t selector)
469 {
470  NS_ASSERT (!address.IsGroup ());
471  WifiRemoteStationState *state = LookupState (address);
472  WifiMode mode;
473  WifiModeList membershipselectormodes = m_wifiPhy->GetMembershipSelectorModes(selector);
474  for (WifiModeListIterator j = membershipselectormodes.begin (); j != membershipselectormodes.end (); j++)
475  {
476  mode=(*j);
477  for (WifiModeListIterator i = state->m_operationalRateSet.begin (); i != state->m_operationalRateSet.end (); i++)
478  {
479  if ((*i) == mode)
480  {
481  // already in.
482  break;
483  }
484  }
485  state->m_operationalRateSet.push_back (mode);
486  }
487 }*/
488 void
490 {
491  NS_LOG_FUNCTION (this << address << (uint16_t) mcs);
492  NS_ASSERT (!address.IsGroup ());
493  WifiRemoteStationState *state = LookupState (address);
494  for (WifiMcsListIterator i = state->m_operationalMcsSet.begin (); i != state->m_operationalMcsSet.end (); i++)
495  {
496  if ((*i) == mcs)
497  {
498  // already in.
499  return;
500  }
501  }
502  state->m_operationalMcsSet.push_back (mcs);
503 }
504 bool
506 {
507  if (address.IsGroup ())
508  {
509  return false;
510  }
512 }
513 bool
515 {
516  if (address.IsGroup ())
517  {
518  return true;
519  }
521 }
522 bool
524 {
525  if (address.IsGroup ())
526  {
527  return false;
528  }
530 }
531 void
533 {
534  NS_ASSERT (!address.IsGroup ());
536 }
537 void
539 {
540  NS_ASSERT (!address.IsGroup ());
542 }
543 void
545 {
546  NS_ASSERT (!address.IsGroup ());
548 }
549 void
551 {
552  NS_ASSERT (!address.IsGroup ());
554 }
555 void
557  Ptr<const Packet> packet, uint32_t fullPacketSize)
558 {
559  NS_LOG_FUNCTION (this << address << *header << packet << fullPacketSize);
560  if (IsLowLatency () || address.IsGroup ())
561  {
562  return;
563  }
564  WifiRemoteStation *station = Lookup (address, header);
565  WifiTxVector rts = DoGetRtsTxVector (station);
566  WifiTxVector data = DoGetDataTxVector (station, fullPacketSize);
567  WifiTxVector ctstoself = DoGetCtsToSelfTxVector ();
570  HighLatencyCtsToSelfTxVectorTag ctstoselftag;
571  // first, make sure that the tag is not here anymore.
572  ConstCast<Packet> (packet)->RemovePacketTag (datatag);
573  ConstCast<Packet> (packet)->RemovePacketTag (rtstag);
574  ConstCast<Packet> (packet)->RemovePacketTag (ctstoselftag);
575  datatag = HighLatencyDataTxVectorTag (data);
576  rtstag = HighLatencyRtsTxVectorTag (rts);
577  ctstoselftag = HighLatencyCtsToSelfTxVectorTag (ctstoself);
578  // and then, add it back
579  packet->AddPacketTag (datatag);
580  packet->AddPacketTag (rtstag);
581  packet->AddPacketTag (ctstoselftag);
582 }
585  Ptr<const Packet> packet, uint32_t fullPacketSize)
586 {
587  NS_LOG_FUNCTION (this << address << *header << packet << fullPacketSize);
588  if (address.IsGroup ())
589  {
590  WifiTxVector v;
591  v.SetMode (GetNonUnicastMode ());
593  v.SetShortGuardInterval (false);
594  v.SetNss (1);
595  v.SetNess (0);
596  v.SetStbc (false);
597  return v;
598  }
599  if (!IsLowLatency ())
600  {
602  bool found;
603  found = ConstCast<Packet> (packet)->PeekPacketTag (datatag);
604  NS_ASSERT (found);
605  // cast found to void, to suppress 'found' set but not used
606  // compiler warning
607  (void) found;
608  return datatag.GetDataTxVector ();
609  }
610  return DoGetDataTxVector (Lookup (address, header), fullPacketSize);
611 }
614  Ptr<const Packet> packet)
615 {
616  NS_LOG_FUNCTION (this << *header << packet);
617  if (!IsLowLatency ())
618  {
619  HighLatencyCtsToSelfTxVectorTag ctstoselftag;
620  bool found;
621  found = ConstCast<Packet> (packet)->PeekPacketTag (ctstoselftag);
622  NS_ASSERT (found);
623  // cast found to void, to suppress 'found' set but not used
624  // compiler warning
625  (void) found;
626  return ctstoselftag.GetCtsToSelfTxVector ();
627  }
628  return DoGetCtsToSelfTxVector ();
629 }
630 
633 {
635 }
636 
639  Ptr<const Packet> packet)
640 {
641  NS_LOG_FUNCTION (this << address << *header << packet);
642  NS_ASSERT (!address.IsGroup ());
643  if (!IsLowLatency ())
644  {
646  bool found;
647  found = ConstCast<Packet> (packet)->PeekPacketTag (rtstag);
648  NS_ASSERT (found);
649  // cast found to void, to suppress 'found' set but not used
650  // compiler warning
651  (void) found;
652  return rtstag.GetRtsTxVector ();
653  }
654  return DoGetRtsTxVector (Lookup (address, header));
655 }
656 void
658 {
659  NS_LOG_FUNCTION (this << address << *header);
660  NS_ASSERT (!address.IsGroup ());
661  WifiRemoteStation *station = Lookup (address, header);
662  station->m_ssrc++;
663  m_macTxRtsFailed (address);
664  DoReportRtsFailed (station);
665 }
666 void
668 {
669  NS_LOG_FUNCTION (this << address << *header);
670  NS_ASSERT (!address.IsGroup ());
671  WifiRemoteStation *station = Lookup (address, header);
672  station->m_slrc++;
673  m_macTxDataFailed (address);
674  DoReportDataFailed (station);
675 }
676 void
678  double ctsSnr, WifiMode ctsMode, double rtsSnr)
679 {
680  NS_LOG_FUNCTION (this << address << *header << ctsSnr << ctsMode << rtsSnr);
681  NS_ASSERT (!address.IsGroup ());
682  WifiRemoteStation *station = Lookup (address, header);
683  station->m_state->m_info.NotifyTxSuccess (station->m_ssrc);
684  station->m_ssrc = 0;
685  DoReportRtsOk (station, ctsSnr, ctsMode, rtsSnr);
686 }
687 void
689  double ackSnr, WifiMode ackMode, double dataSnr)
690 {
691  NS_LOG_FUNCTION (this << address << *header << ackSnr << ackMode << dataSnr);
692  NS_ASSERT (!address.IsGroup ());
693  WifiRemoteStation *station = Lookup (address, header);
694  station->m_state->m_info.NotifyTxSuccess (station->m_slrc);
695  station->m_slrc = 0;
696  DoReportDataOk (station, ackSnr, ackMode, dataSnr);
697 }
698 void
700 {
701  NS_LOG_FUNCTION (this << address << *header);
702  NS_ASSERT (!address.IsGroup ());
703  WifiRemoteStation *station = Lookup (address, header);
704  station->m_state->m_info.NotifyTxFailed ();
705  station->m_ssrc = 0;
706  m_macTxFinalRtsFailed (address);
707  DoReportFinalRtsFailed (station);
708 }
709 void
711 {
712  NS_LOG_FUNCTION (this << address << *header);
713  NS_ASSERT (!address.IsGroup ());
714  WifiRemoteStation *station = Lookup (address, header);
715  station->m_state->m_info.NotifyTxFailed ();
716  station->m_slrc = 0;
717  m_macTxFinalDataFailed (address);
718  DoReportFinalDataFailed (station);
719 }
720 void
722  double rxSnr, WifiMode txMode)
723 {
724  NS_LOG_FUNCTION (this << address << *header << rxSnr << txMode);
725  if (address.IsGroup ())
726  {
727  return;
728  }
729  WifiRemoteStation *station = Lookup (address, header);
730  DoReportRxOk (station, rxSnr, txMode);
731 }
732 bool
734  Ptr<const Packet> packet)
735 {
736  NS_LOG_FUNCTION (this << address << *header << packet);
737  if (address.IsGroup ())
738  {
739  return false;
740  }
741  bool normally = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > GetRtsCtsThreshold ();
742  return DoNeedRts (Lookup (address, header), packet, normally);
743 }
744 bool
746 {
747  NS_LOG_FUNCTION (this << txVector);
748  WifiMode mode = txVector.GetMode();
749 
750  // search the BSS Basic Rate set if the used mode in the basic set then no need for Cts to self
751  for (WifiModeListIterator i = m_bssBasicRateSet.begin ();
752  i != m_bssBasicRateSet.end (); i++)
753  {
754  if (mode == *i)
755  {
756  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
757  return false;
758  }
759  }
760  if (HasHtSupported())
761  {
762  uint8_t mcs = m_wifiPhy->WifiModeToMcs (mode);
763  for (WifiMcsListIterator i = m_bssBasicMcsSet.begin ();
764  i != m_bssBasicMcsSet.end (); i++)
765  {
766  if (mcs == *i)
767  {
768  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning false");
769  return false;
770  }
771  }
772  }
773  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedCtsToSelf returning true");
774  return true;
775 }
776 bool
778  Ptr<const Packet> packet)
779 {
780  NS_LOG_FUNCTION (this << address << packet << *header);
781  NS_ASSERT (!address.IsGroup ());
782  WifiRemoteStation *station = Lookup (address, header);
783  bool normally = station->m_ssrc < GetMaxSsrc ();
784  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedDataRetransmission count: " << station->m_ssrc << " result: " << std::boolalpha << normally);
785  return DoNeedRtsRetransmission (station, packet, normally);
786 }
787 bool
789  Ptr<const Packet> packet)
790 {
791  NS_LOG_FUNCTION (this << address << packet << *header);
792  NS_ASSERT (!address.IsGroup ());
793  WifiRemoteStation *station = Lookup (address, header);
794  bool normally = station->m_slrc < GetMaxSlrc ();
795  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedDataRetransmission count: " << station->m_slrc << " result: " << std::boolalpha << normally);
796  return DoNeedDataRetransmission (station, packet, normally);
797 }
798 bool
800  Ptr<const Packet> packet)
801 {
802  NS_LOG_FUNCTION (this << address << packet << *header);
803  if (address.IsGroup ())
804  {
805  return false;
806  }
807  WifiRemoteStation *station = Lookup (address, header);
808  bool normally = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > GetFragmentationThreshold ();
809  NS_LOG_DEBUG ("WifiRemoteStationManager::NeedFragmentation result: " << std::boolalpha << normally);
810  return DoNeedFragmentation (station, packet, normally);
811 }
812 
813 void
815 {
816  NS_LOG_FUNCTION (this << threshold);
817  if (threshold < 256)
818  {
819  /*
820  * ASN.1 encoding of the MAC and PHY MIB (256 ... 8000)
821  */
822  NS_LOG_WARN ("Fragmentation threshold should be larger than 256. Setting to 256.");
824  }
825  else
826  {
827  /*
828  * The length of each fragment shall be an even number of octets, except for the last fragment if an MSDU or
829  * MMPDU, which may be either an even or an odd number of octets.
830  */
831  if (threshold % 2 != 0)
832  {
833  NS_LOG_WARN ("Fragmentation threshold should be an even number. Setting to " << threshold - 1);
834  m_fragmentationThreshold = threshold - 1;
835  }
836  else
837  {
838  m_fragmentationThreshold = threshold;
839  }
840  }
841 }
842 
843 uint32_t
845 {
847 }
848 
849 uint32_t
851 {
852  NS_LOG_FUNCTION (this << *header << packet);
853  //The number of bytes a fragment can support is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
854  uint32_t nFragments = (packet->GetSize () / (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
855 
856  //If the size of the last fragment is not 0.
857  if ((packet->GetSize () % (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH)) > 0)
858  {
859  nFragments++;
860  }
861  NS_LOG_DEBUG ("WifiRemoteStationManager::GetNFragments returning " << nFragments);
862  return nFragments;
863 }
864 
865 uint32_t
867  Ptr<const Packet> packet, uint32_t fragmentNumber)
868 {
869  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
870  NS_ASSERT (!address.IsGroup ());
871  uint32_t nFragment = GetNFragments (header, packet);
872  if (fragmentNumber >= nFragment)
873  {
874  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning 0");
875  return 0;
876  }
877  //Last fragment
878  if (fragmentNumber == nFragment - 1)
879  {
880  uint32_t lastFragmentSize = packet->GetSize () - (fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH));
881  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << lastFragmentSize);
882  return lastFragmentSize;
883  }
884  //All fragments but the last, the number of bytes is (Threshold - WIFI_HEADER_SIZE - WIFI_FCS).
885  else
886  {
887  uint32_t fragmentSize = GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH;
888  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentSize returning " << fragmentSize);
889  return fragmentSize;
890  }
891 }
892 uint32_t
894  Ptr<const Packet> packet, uint32_t fragmentNumber)
895 {
896  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
897  NS_ASSERT (!address.IsGroup ());
898  NS_ASSERT (fragmentNumber < GetNFragments (header, packet));
899  uint32_t fragmentOffset = fragmentNumber * (GetFragmentationThreshold () - header->GetSize () - WIFI_MAC_FCS_LENGTH);
900  NS_LOG_DEBUG ("WifiRemoteStationManager::GetFragmentOffset returning " << fragmentOffset);
901  return fragmentOffset;
902 }
903 bool
905  Ptr<const Packet> packet, uint32_t fragmentNumber)
906 {
907  NS_LOG_FUNCTION (this << address << *header << packet << fragmentNumber);
908  NS_ASSERT (!address.IsGroup ());
909  bool isLast = fragmentNumber == (GetNFragments (header, packet) - 1);
910  NS_LOG_DEBUG ("WifiRemoteStationManager::IsLastFragment returning " << std::boolalpha << isLast);
911  return isLast;
912 }
913 WifiMode
915 {
930  NS_LOG_FUNCTION (this << address << reqMode);
931  WifiMode mode = GetDefaultMode ();
932  bool found = false;
933 
934  // First, search the BSS Basic Rate set
935  for (WifiModeListIterator i = m_bssBasicRateSet.begin ();
936  i != m_bssBasicRateSet.end (); i++)
937  {
938  if ((!found || i->GetPhyRate () > mode.GetPhyRate ())
939  && (i->GetPhyRate () <= reqMode.GetPhyRate ())
940  && ((i->GetModulationClass () == reqMode.GetModulationClass ())
941  || (reqMode.GetModulationClass () == WIFI_MOD_CLASS_HT)))
942  {
943  mode = *i;
944  // We've found a potentially-suitable transmit rate, but we
945  // need to continue and consider all the basic rates before
946  // we can be sure we've got the right one.
947  found = true;
948  }
949  }
950  if(HasHtSupported())
951  {
952  if (!found)
953  {
954  uint8_t mcs = GetDefaultMcs ();
955  mode = m_wifiPhy->McsToWifiMode (mcs);
956 
957  for (WifiMcsListIterator i = m_bssBasicMcsSet.begin ();
958  i != m_bssBasicMcsSet.end (); i++)
959  {
960  WifiMode thismode= m_wifiPhy->McsToWifiMode (*i);
961  if ((!found || thismode.GetPhyRate () > mode.GetPhyRate ())
962  && thismode.GetPhyRate () <= reqMode.GetPhyRate ()
963  && thismode.GetModulationClass () == reqMode.GetModulationClass ())
964  {
965  mode = thismode;
966  // We've found a potentially-suitable transmit rate, but we
967  // need to continue and consider all the basic rates before
968  // we can be sure we've got the right one.
969  found = true;
970  }
971  }
972  }
973  }
974  // If we found a suitable rate in the BSSBasicRateSet, then we are
975  // done and can return that mode.
976  if (found)
977  {
978  NS_LOG_DEBUG ("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
979  return mode;
980  }
981 
999  for (uint32_t idx = 0; idx < m_wifiPhy->GetNModes (); idx++)
1000  {
1001  WifiMode thismode = m_wifiPhy->GetMode (idx);
1002 
1003  /* If the rate:
1004  *
1005  * - is a mandatory rate for the PHY, and
1006  * - is equal to or faster than our current best choice, and
1007  * - is less than or equal to the rate of the received frame, and
1008  * - is of the same modulation class as the received frame
1009  *
1010  * ...then it's our best choice so far.
1011  */
1012  if (thismode.IsMandatory ()
1013  && (!found || thismode.GetPhyRate () > mode.GetPhyRate ())
1014  && (thismode.GetPhyRate () <= reqMode.GetPhyRate ())
1015  && ((thismode.GetModulationClass () == reqMode.GetModulationClass ()) ||
1016  (reqMode.GetModulationClass () == WIFI_MOD_CLASS_HT)))
1017  {
1018  mode = thismode;
1019  // As above; we've found a potentially-suitable transmit
1020  // rate, but we need to continue and consider all the
1021  // mandatory rates before we can be sure we've got the right
1022  // one.
1023  found = true;
1024  }
1025  }
1026  if(HasHtSupported())
1027  {
1028  for (uint32_t idx = 0; idx < m_wifiPhy->GetNMcs (); idx++)
1029  {
1030  uint8_t thismcs = m_wifiPhy->GetMcs (idx);
1031  WifiMode thismode= m_wifiPhy->McsToWifiMode (thismcs);
1032  if (thismode.IsMandatory ()
1033  && (!found || thismode.GetPhyRate () > mode.GetPhyRate ())
1034  && thismode.GetPhyRate () <= reqMode.GetPhyRate ()
1035  && thismode.GetModulationClass () == reqMode.GetModulationClass ())
1036  {
1037  mode = thismode;
1038  // As above; we've found a potentially-suitable transmit
1039  // rate, but we need to continue and consider all the
1040  // mandatory rates before we can be sure we've got the right
1041  // one.
1042  found = true;
1043  }
1044 
1045  }
1046  }
1047 
1058  if (!found)
1059  {
1060  NS_FATAL_ERROR ("Can't find response rate for " << reqMode
1061  << ". Check standard and selected rates match.");
1062  }
1063 
1064  NS_LOG_DEBUG ("WifiRemoteStationManager::GetControlAnswerMode returning " << mode);
1065  return mode;
1066 }
1067 
1070 {
1071  NS_ASSERT (!address.IsGroup ());
1072  WifiTxVector v;
1073  v.SetMode (GetControlAnswerMode (address, rtsMode));
1074  v.SetTxPowerLevel (DoGetCtsTxPowerLevel (address, v.GetMode()));
1075  v.SetShortGuardInterval (DoGetCtsTxGuardInterval(address, v.GetMode()));
1076  v.SetNss (DoGetCtsTxNss(address, v.GetMode()));
1077  v.SetNess (DoGetCtsTxNess(address, v.GetMode()));
1078  v.SetStbc (DoGetCtsTxStbc(address, v.GetMode()));
1079  return v;
1080 }
1083 {
1084  NS_ASSERT (!address.IsGroup ());
1085  WifiTxVector v;
1086  v.SetMode (GetControlAnswerMode (address, dataMode));
1087  v.SetTxPowerLevel (DoGetAckTxPowerLevel (address, v.GetMode()));
1088  v.SetShortGuardInterval(DoGetAckTxGuardInterval(address, v.GetMode()));
1089  v.SetNss(DoGetAckTxNss(address, v.GetMode()));
1090  v.SetNess(DoGetAckTxNess(address, v.GetMode()));
1091  v.SetStbc(DoGetAckTxStbc(address, v.GetMode()));
1092  return v;
1093 }
1096 {
1097  NS_ASSERT (!address.IsGroup ());
1098  WifiTxVector v;
1099  v.SetMode (GetControlAnswerMode (address, blockAckReqMode));
1100  v.SetTxPowerLevel (DoGetBlockAckTxPowerLevel (address, v.GetMode()));
1101  v.SetShortGuardInterval (DoGetBlockAckTxGuardInterval(address, v.GetMode()));
1102  v.SetNss (DoGetBlockAckTxNss(address, v.GetMode()));
1103  v.SetNess (DoGetBlockAckTxNess(address, v.GetMode()));
1104  v.SetStbc (DoGetBlockAckTxStbc(address, v.GetMode()));
1105  return v;
1106 }
1107 
1108 uint8_t
1110 {
1111  return m_defaultTxPowerLevel;
1112 }
1113 
1114 bool
1116 {
1117  return m_wifiPhy->GetGuardInterval();
1118 }
1119 
1120 uint8_t
1122 {
1123  return 1;
1124 }
1125 uint8_t
1127 {
1128  return 0;
1129 }
1130 bool
1132 {
1133  return m_wifiPhy->GetStbc();
1134 }
1135 
1136 uint8_t
1138 {
1139  return m_defaultTxPowerLevel;
1140 }
1141 
1142 bool
1144 {
1145  return m_wifiPhy->GetGuardInterval();
1146 }
1147 
1148 uint8_t
1150 {
1151  return 1;
1152 }
1153 uint8_t
1155 {
1156  return 0;
1157 }
1158 bool
1160 {
1161  return m_wifiPhy->GetStbc();
1162 }
1163 
1164 uint8_t
1166 {
1167  return m_defaultTxPowerLevel;
1168 }
1169 
1170 bool
1172 {
1173  return m_wifiPhy->GetGuardInterval();
1174 }
1175 
1176 uint8_t
1178 {
1179  return 1;
1180 }
1181 uint8_t
1183 {
1184  return 0;
1185 }
1186 bool
1188 {
1189  return m_wifiPhy->GetStbc();
1190 }
1191 
1192 
1193 uint8_t
1195 {
1196  return m_defaultTxPowerLevel;
1197 }
1198 
1199 
1202 {
1203  WifiRemoteStationState *state = LookupState (address);
1204  return state->m_info;
1205 }
1206 
1209 {
1210  NS_LOG_FUNCTION (this << address);
1211  for (StationStates::const_iterator i = m_states.begin (); i != m_states.end (); i++)
1212  {
1213  if ((*i)->m_address == address)
1214  {
1215  NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning existing state");
1216  return (*i);
1217  }
1218  }
1221  state->m_address = address;
1222  state->m_operationalRateSet.push_back (GetDefaultMode ());
1223  state->m_operationalMcsSet.push_back(GetDefaultMcs());
1226  state->m_rx=1;
1227  state->m_tx=1;
1228  state->m_ness=0;
1229  state->m_stbc=false;
1230  const_cast<WifiRemoteStationManager *> (this)->m_states.push_back (state);
1231  NS_LOG_DEBUG ("WifiRemoteStationManager::LookupState returning new state");
1232  return state;
1233 }
1236 {
1237  uint8_t tid;
1238  if (header->IsQosData ())
1239  {
1240  tid = header->GetQosTid ();
1241  }
1242  else
1243  {
1244  tid = 0;
1245  }
1246  return Lookup (address, tid);
1247 }
1250 {
1251  NS_LOG_FUNCTION (this << address << (uint16_t) tid);
1252  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1253  {
1254  if ((*i)->m_tid == tid
1255  && (*i)->m_state->m_address == address)
1256  {
1257  return (*i);
1258  }
1259  }
1260  WifiRemoteStationState *state = LookupState (address);
1261 
1262  WifiRemoteStation *station = DoCreateStation ();
1263  station->m_state = state;
1264  station->m_tid = tid;
1265  station->m_ssrc = 0;
1266  station->m_slrc = 0;
1267  // XXX
1268  const_cast<WifiRemoteStationManager *> (this)->m_stations.push_back (station);
1269  return station;
1270 
1271 }
1272 //Used by all stations to record HT capabilities of remote stations
1273 void
1275 {
1276  NS_LOG_FUNCTION (this << from << htcapabilities);
1277  WifiRemoteStationState *state;
1278  state=LookupState (from);
1279  state->m_shortGuardInterval=htcapabilities.GetShortGuardInterval20();
1280  state->m_greenfield=htcapabilities.GetGreenfield();
1281 
1282 }
1283 //Used by mac low to choose format used GF, MF or Non HT
1284 bool
1286 {
1287  return LookupState(address)->m_greenfield;
1288 }
1289 WifiMode
1291 {
1292  return m_defaultTxMode;
1293 }
1294 uint8_t
1296 {
1297  return m_defaultTxMcs;
1298 }
1299 void
1301 {
1302  NS_LOG_FUNCTION (this);
1303  for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
1304  {
1305  delete (*i);
1306  }
1307  m_stations.clear ();
1308  m_bssBasicRateSet.clear ();
1309  m_bssBasicRateSet.push_back (m_defaultTxMode);
1310  m_bssBasicMcsSet.clear();
1311  m_bssBasicMcsSet.push_back (m_defaultTxMcs);
1313 }
1314 void
1316 {
1317  NS_LOG_FUNCTION (this << mode);
1318  for (uint32_t i = 0; i < GetNBasicModes (); i++)
1319  {
1320  if (GetBasicMode (i) == mode)
1321  {
1322  return;
1323  }
1324  }
1325  m_bssBasicRateSet.push_back (mode);
1326 }
1327 uint32_t
1329 {
1330  return m_bssBasicRateSet.size ();
1331 }
1332 WifiMode
1334 {
1335  NS_ASSERT (i < m_bssBasicRateSet.size ());
1336  return m_bssBasicRateSet[i];
1337 }
1338 
1339 void
1341 {
1342  for (uint32_t i = 0; i < GetNBasicMcs (); i++)
1343  {
1344  if (GetBasicMcs (i) == mcs)
1345  {
1346  return;
1347  }
1348  }
1349  m_bssBasicMcsSet.push_back (mcs);
1350 }
1351 
1352 uint32_t
1354 {
1355  return m_bssBasicMcsSet.size ();
1356 }
1357 uint8_t
1359 {
1360  NS_ASSERT (i < m_bssBasicMcsSet.size ());
1361  return m_bssBasicMcsSet[i];
1362 }
1363 
1364 WifiMode
1366 {
1367  if (m_nonUnicastMode == WifiMode ())
1368  {
1369  return GetBasicMode (0);
1370  }
1371  else
1372  {
1373  return m_nonUnicastMode;
1374  }
1375 }
1376 
1377 bool
1379  Ptr<const Packet> packet, bool normally)
1380 {
1381  return normally;
1382 }
1383 bool
1385  Ptr<const Packet> packet, bool normally)
1386 {
1387  return normally;
1388 }
1389 bool
1391  Ptr<const Packet> packet, bool normally)
1392 {
1393  return normally;
1394 }
1395 bool
1397  Ptr<const Packet> packet, bool normally)
1398 {
1399  return normally;
1400 }
1401 
1402 WifiMode
1404 {
1405  NS_ASSERT (i < GetNSupported (station));
1406  return station->m_state->m_operationalRateSet[i];
1407 }
1408 uint8_t
1410 {
1411  NS_ASSERT (i < GetNMcsSupported (station));
1412  return station->m_state->m_operationalMcsSet[i];
1413 }
1414 bool
1416 {
1417  return station->m_state->m_shortGuardInterval;
1418 }
1419 bool
1421 {
1422  return station->m_state->m_greenfield;
1423 }
1424 bool
1426 {
1427  return station->m_state->m_stbc;
1428 }
1429 uint32_t
1431 {
1432  return station->m_state->m_rx;
1433 }
1434 uint32_t
1436 {
1437  return station->m_state->m_tx;
1438 }
1439 uint32_t
1441 {
1442  return station->m_state->m_ness;
1443 }
1444 uint32_t
1446 {
1447  return station->m_ssrc;
1448 }
1449 
1452 {
1453  return m_wifiPhy;
1454 }
1457 {
1458  return m_wifiMac;
1459 }
1460 
1461 uint32_t
1463 {
1464  return station->m_slrc;
1465 }
1466 uint32_t
1468 {
1469  return station->m_state->m_operationalRateSet.size ();
1470 }
1471 uint32_t
1473 {
1474  return station->m_state->m_operationalMcsSet.size ();
1475 }
1476 void
1478 {
1479  m_defaultTxPowerLevel = txPower;
1480 }
1481 
1482 //support 11n
1483 uint32_t
1485 {
1487 }
1488 //WifiRemoteStationInfo constructor
1490  : m_memoryTime (Seconds (1.0)),
1491  m_lastUpdate (Seconds (0.0)),
1492  m_failAvg (0.0)
1493 {
1494 }
1495 
1496 double
1498 {
1499  double retval = std::exp ((double)(m_lastUpdate.GetMicroSeconds () - Simulator::Now ().GetMicroSeconds ())
1500  / (double)m_memoryTime.GetMicroSeconds ());
1502  return retval;
1503 }
1504 
1505 void
1507 {
1508  double coefficient = CalculateAveragingCoefficient ();
1509  m_failAvg = (double)retryCounter / (1 + (double) retryCounter) * (1.0 - coefficient) + coefficient * m_failAvg;
1510 }
1511 
1512 void
1514 {
1515  double coefficient = CalculateAveragingCoefficient ();
1516  m_failAvg = (1.0 - coefficient) + coefficient * m_failAvg;
1517 }
1518 
1519 double
1521 {
1522  return m_failAvg;
1523 }
1524 
1526 {
1527  NS_LOG_FUNCTION (this);
1528 }
1529 
1530 } // 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:67
WifiMode GetNonUnicastMode(void) const
Return a mode for non-unicast packets.
static const uint16_t WIFI_MAC_FCS_LENGTH
The length in octects of the IEEE 802.11 MAC FCS field.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
uint32_t m_fragmentationThreshold
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:342
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.
HT PHY (Clause 20)
Definition: wifi-mode.h:56
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:866
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:57
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:638
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.