A Discrete-Event Network Simulator
API
ideal-wifi-manager.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2006 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 <algorithm>
22 #include "ns3/log.h"
23 #include "ideal-wifi-manager.h"
24 #include "ns3/wifi-phy.h"
25 
26 namespace ns3 {
27 
35 {
38  uint16_t m_lastNssObserved;
39  double m_lastSnrCached;
40  uint8_t m_lastNss;
42  uint16_t m_lastChannelWidth;
43 };
44 
46 static const double CACHE_INITIAL_VALUE = -100;
47 
49 
50 NS_LOG_COMPONENT_DEFINE ("IdealWifiManager");
51 
52 TypeId
54 {
55  static TypeId tid = TypeId ("ns3::IdealWifiManager")
57  .SetGroupName ("Wifi")
58  .AddConstructor<IdealWifiManager> ()
59  .AddAttribute ("BerThreshold",
60  "The maximum Bit Error Rate acceptable at any transmission mode",
61  DoubleValue (1e-6),
63  MakeDoubleChecker<double> ())
64  .AddTraceSource ("Rate",
65  "Traced value for rate changes (b/s)",
67  "ns3::TracedValueCallback::Uint64")
68  ;
69  return tid;
70 }
71 
73  : m_currentRate (0)
74 {
75  NS_LOG_FUNCTION (this);
76 }
77 
79 {
80  NS_LOG_FUNCTION (this);
81 }
82 
83 void
85 {
86  NS_LOG_FUNCTION (this << phy);
88 }
89 
90 uint16_t
92 {
98  {
99  return 22;
100  }
101  else
102  {
103  return 20;
104  }
105 }
106 
107 void
109 {
110  NS_LOG_FUNCTION (this);
112 }
113 
114 void
116 {
117  m_thresholds.clear ();
118  WifiMode mode;
119  WifiTxVector txVector;
120  uint8_t nss = 1;
121  for (const auto & mode : GetPhy ()->GetModeList ())
122  {
124  txVector.SetNss (nss);
125  txVector.SetMode (mode);
126  NS_LOG_DEBUG ("Adding mode = " << mode.GetUniqueName ());
127  AddSnrThreshold (txVector, GetPhy ()->CalculateSnr (txVector, m_ber));
128  }
129  // Add all MCSes
130  if (GetHtSupported ())
131  {
132  for (const auto & mode : GetPhy ()->GetMcsList ())
133  {
134  for (uint16_t j = 20; j <= GetPhy ()->GetChannelWidth (); j *= 2)
135  {
136  txVector.SetChannelWidth (j);
137  if (mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
138  {
139  uint16_t guardInterval = GetShortGuardIntervalSupported () ? 400 : 800;
140  txVector.SetGuardInterval (guardInterval);
141  //derive NSS from the MCS index
142  nss = (mode.GetMcsValue () / 8) + 1;
143  NS_LOG_DEBUG ("Adding mode = " << mode.GetUniqueName () <<
144  " channel width " << j <<
145  " nss " << +nss <<
146  " GI " << guardInterval);
147  txVector.SetNss (nss);
148  txVector.SetMode (mode);
149  AddSnrThreshold (txVector, GetPhy ()->CalculateSnr (txVector, m_ber));
150  }
151  else //VHT or HE
152  {
153  uint16_t guardInterval;
154  if (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
155  {
156  guardInterval = GetShortGuardIntervalSupported () ? 400 : 800;
157  }
158  else
159  {
160  guardInterval = GetGuardInterval ();
161  }
162  txVector.SetGuardInterval (guardInterval);
163  for (uint8_t k = 1; k <= GetPhy ()->GetMaxSupportedTxSpatialStreams (); k++)
164  {
165  if (mode.IsAllowed (j, k))
166  {
167  NS_LOG_DEBUG ("Adding mode = " << mode.GetUniqueName () <<
168  " channel width " << j <<
169  " nss " << +k <<
170  " GI " << guardInterval);
171  txVector.SetNss (k);
172  txVector.SetMode (mode);
173  AddSnrThreshold (txVector, GetPhy ()->CalculateSnr (txVector, m_ber));
174  }
175  else
176  {
177  NS_LOG_DEBUG ("Mode = " << mode.GetUniqueName () << " disallowed");
178  }
179  }
180  }
181  }
182  }
183  }
184 }
185 
186 double
188 {
189  NS_LOG_FUNCTION (this << txVector);
190  auto it = std::find_if (m_thresholds.begin (), m_thresholds.end (),
191  [&txVector] (const std::pair<double, WifiTxVector>& p) -> bool {
192  return ((txVector.GetMode () == p.second.GetMode ()) && (txVector.GetNss () == p.second.GetNss ()) && (txVector.GetChannelWidth () == p.second.GetChannelWidth ()));
193  }
194  );
195  if (it == m_thresholds.end ())
196  {
197  //This means capabilities have changed in runtime, hence rebuild SNR thresholds
199  it = std::find_if (m_thresholds.begin (), m_thresholds.end (),
200  [&txVector] (const std::pair<double, WifiTxVector>& p) -> bool {
201  return ((txVector.GetMode () == p.second.GetMode ()) && (txVector.GetNss () == p.second.GetNss ()) && (txVector.GetChannelWidth () == p.second.GetChannelWidth ()));
202  }
203  );
204  NS_ASSERT_MSG (it != m_thresholds.end (), "SNR threshold not found");
205  }
206  return it->first;
207 }
208 
209 void
211 {
212  NS_LOG_FUNCTION (this << txVector.GetMode ().GetUniqueName () << txVector.GetChannelWidth () << snr);
213  m_thresholds.push_back (std::make_pair (snr, txVector));
214 }
215 
218 {
219  NS_LOG_FUNCTION (this);
221  Reset (station);
222  return station;
223 }
224 
225 void
227 {
228  NS_LOG_FUNCTION (this << station);
229  IdealWifiRemoteStation *st = static_cast<IdealWifiRemoteStation*> (station);
230  st->m_lastSnrObserved = 0.0;
232  st->m_lastNssObserved = 1;
234  st->m_lastMode = GetDefaultMode ();
235  st->m_lastChannelWidth = 0;
236  st->m_lastNss = 1;
237 }
238 
239 void
241 {
242  NS_LOG_FUNCTION (this << station << rxSnr << txMode);
243 }
244 
245 void
247 {
248  NS_LOG_FUNCTION (this << station);
249 }
250 
251 void
253 {
254  NS_LOG_FUNCTION (this << station);
255 }
256 
257 void
259  double ctsSnr, WifiMode ctsMode, double rtsSnr)
260 {
261  NS_LOG_FUNCTION (this << st << ctsSnr << ctsMode.GetUniqueName () << rtsSnr);
262  IdealWifiRemoteStation *station = static_cast<IdealWifiRemoteStation*> (st);
263  station->m_lastSnrObserved = rtsSnr;
264  station->m_lastChannelWidthObserved = GetPhy ()->GetChannelWidth () >= 40 ? 20 : GetPhy ()->GetChannelWidth ();
265  station->m_lastNssObserved = 1;
266 }
267 
268 void
270  double dataSnr, uint16_t dataChannelWidth, uint8_t dataNss)
271 {
272  NS_LOG_FUNCTION (this << st << ackSnr << ackMode.GetUniqueName () << dataSnr << dataChannelWidth << +dataNss);
273  IdealWifiRemoteStation *station = static_cast<IdealWifiRemoteStation*> (st);
274  if (dataSnr == 0)
275  {
276  NS_LOG_WARN ("DataSnr reported to be zero; not saving this report.");
277  return;
278  }
279  station->m_lastSnrObserved = dataSnr;
280  station->m_lastChannelWidthObserved = dataChannelWidth;
281  station->m_lastNssObserved = dataNss;
282 }
283 
284 void
285 IdealWifiManager::DoReportAmpduTxStatus (WifiRemoteStation *st, uint16_t nSuccessfulMpdus, uint16_t nFailedMpdus,
286  double rxSnr, double dataSnr, uint16_t dataChannelWidth, uint8_t dataNss)
287 {
288  NS_LOG_FUNCTION (this << st << nSuccessfulMpdus << nFailedMpdus << rxSnr << dataSnr << dataChannelWidth << +dataNss);
289  IdealWifiRemoteStation *station = static_cast<IdealWifiRemoteStation*> (st);
290  if (dataSnr == 0)
291  {
292  NS_LOG_WARN ("DataSnr reported to be zero; not saving this report.");
293  return;
294  }
295  station->m_lastSnrObserved = dataSnr;
296  station->m_lastChannelWidthObserved = dataChannelWidth;
297  station->m_lastNssObserved = dataNss;
298 }
299 
300 void
302 {
303  NS_LOG_FUNCTION (this << station);
304  Reset (station);
305 }
306 
307 void
309 {
310  NS_LOG_FUNCTION (this << station);
311  Reset (station);
312 }
313 
316 {
317  NS_LOG_FUNCTION (this << st);
318  IdealWifiRemoteStation *station = static_cast<IdealWifiRemoteStation*> (st);
319  //We search within the Supported rate set the mode with the
320  //highest data rate for which the SNR threshold is smaller than m_lastSnr
321  //to ensure correct packet delivery.
322  WifiMode maxMode = GetDefaultMode ();
323  WifiTxVector txVector;
324  WifiMode mode;
325  uint64_t bestRate = 0;
326  uint8_t selectedNss = 1;
327  uint16_t guardInterval;
328  uint16_t channelWidth = std::min (GetChannelWidth (station), GetPhy ()->GetChannelWidth ());
329  txVector.SetChannelWidth (channelWidth);
330  if ((station->m_lastSnrCached != CACHE_INITIAL_VALUE) && (station->m_lastSnrObserved == station->m_lastSnrCached) && (channelWidth == station->m_lastChannelWidth))
331  {
332  // SNR has not changed, so skip the search and use the last mode selected
333  maxMode = station->m_lastMode;
334  selectedNss = station->m_lastNss;
335  NS_LOG_DEBUG ("Using cached mode = " << maxMode.GetUniqueName () <<
336  " last snr observed " << station->m_lastSnrObserved <<
337  " cached " << station->m_lastSnrCached <<
338  " channel width " << station->m_lastChannelWidth <<
339  " nss " << +selectedNss);
340  }
341  else
342  {
343  if (GetHtSupported () && GetHtSupported (st))
344  {
345  for (uint8_t i = 0; i < GetNMcsSupported (station); i++)
346  {
347  mode = GetMcsSupported (station, i);
348  txVector.SetMode (mode);
349  if (mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
350  {
351  guardInterval = static_cast<uint16_t> (std::max (GetShortGuardIntervalSupported (station) ? 400 : 800, GetShortGuardIntervalSupported () ? 400 : 800));
352  txVector.SetGuardInterval (guardInterval);
353  // If the node and peer are both VHT capable, only search VHT modes
354  if (GetVhtSupported () && GetVhtSupported (station))
355  {
356  continue;
357  }
358  // If the node and peer are both HE capable, only search HE modes
359  if (GetHeSupported () && GetHeSupported (station))
360  {
361  continue;
362  }
363  // Derive NSS from the MCS index. There is a different mode for each possible NSS value.
364  uint8_t nss = (mode.GetMcsValue () / 8) + 1;
365  txVector.SetNss (nss);
366  if (!txVector.IsValid ()
368  {
369  NS_LOG_DEBUG ("Skipping mode " << mode.GetUniqueName () <<
370  " nss " << +nss <<
371  " width " << txVector.GetChannelWidth ());
372  continue;
373  }
374  double threshold = GetSnrThreshold (txVector);
375  uint64_t dataRate = mode.GetDataRate (txVector.GetChannelWidth (), txVector.GetGuardInterval (), nss);
376  NS_LOG_DEBUG ("Testing mode " << mode.GetUniqueName () <<
377  " data rate " << dataRate <<
378  " threshold " << threshold << " last snr observed " <<
379  station->m_lastSnrObserved << " cached " <<
380  station->m_lastSnrCached);
381  double snr = GetLastObservedSnr (station, channelWidth, nss);
382  if (dataRate > bestRate && threshold < snr)
383  {
384  NS_LOG_DEBUG ("Candidate mode = " << mode.GetUniqueName () <<
385  " data rate " << dataRate <<
386  " threshold " << threshold <<
387  " channel width " << channelWidth <<
388  " snr " << snr);
389  bestRate = dataRate;
390  maxMode = mode;
391  selectedNss = nss;
392  }
393  }
394  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
395  {
396  guardInterval = static_cast<uint16_t> (std::max (GetShortGuardIntervalSupported (station) ? 400 : 800, GetShortGuardIntervalSupported () ? 400 : 800));
397  txVector.SetGuardInterval (guardInterval);
398  // If the node and peer are both HE capable, only search HE modes
399  if (GetHeSupported () && GetHeSupported (station))
400  {
401  continue;
402  }
403  // If the node and peer are not both VHT capable, only search HT modes
404  if (!GetVhtSupported () || !GetVhtSupported (station))
405  {
406  continue;
407  }
408  for (uint8_t nss = 1; nss <= std::min (GetMaxNumberOfTransmitStreams (), GetNumberOfSupportedStreams (station)); nss++)
409  {
410  txVector.SetNss (nss);
411  if (!txVector.IsValid ())
412  {
413  NS_LOG_DEBUG ("Skipping mode " << mode.GetUniqueName () <<
414  " nss " << +nss <<
415  " width " << txVector.GetChannelWidth ());
416  continue;
417  }
418  double threshold = GetSnrThreshold (txVector);
419  uint64_t dataRate = mode.GetDataRate (txVector.GetChannelWidth (), txVector.GetGuardInterval (), nss);
420  NS_LOG_DEBUG ("Testing mode = " << mode.GetUniqueName () <<
421  " data rate " << dataRate <<
422  " threshold " << threshold << " last snr observed " <<
423  station->m_lastSnrObserved << " cached " <<
424  station->m_lastSnrCached);
425  double snr = GetLastObservedSnr (station, channelWidth, nss);
426  if (dataRate > bestRate && threshold < snr)
427  {
428  NS_LOG_DEBUG ("Candidate mode = " << mode.GetUniqueName () <<
429  " data rate " << dataRate <<
430  " channel width " << channelWidth <<
431  " snr " << snr);
432  bestRate = dataRate;
433  maxMode = mode;
434  selectedNss = nss;
435  }
436  }
437  }
438  else //HE
439  {
440  guardInterval = std::max (GetGuardInterval (station), GetGuardInterval ());
441  txVector.SetGuardInterval (guardInterval);
442  // If the node and peer are not both HE capable, only search (V)HT modes
443  if (!GetHeSupported () || !GetHeSupported (station))
444  {
445  continue;
446  }
447  for (uint8_t nss = 1; nss <= std::min (GetMaxNumberOfTransmitStreams (), GetNumberOfSupportedStreams (station)); nss++)
448  {
449  txVector.SetNss (nss);
450  if (!txVector.IsValid ())
451  {
452  NS_LOG_DEBUG ("Skipping mode " << mode.GetUniqueName () <<
453  " nss " << +nss <<
454  " width " << +txVector.GetChannelWidth ());
455  continue;
456  }
457  double threshold = GetSnrThreshold (txVector);
458  uint64_t dataRate = mode.GetDataRate (txVector.GetChannelWidth (), txVector.GetGuardInterval (), nss);
459  NS_LOG_DEBUG ("Testing mode = " << mode.GetUniqueName () <<
460  " data rate " << dataRate <<
461  " threshold " << threshold << " last snr observed " <<
462  station->m_lastSnrObserved << " cached " <<
463  station->m_lastSnrCached);
464  double snr = GetLastObservedSnr (station, channelWidth, nss);
465  if (dataRate > bestRate && threshold < snr)
466  {
467  NS_LOG_DEBUG ("Candidate mode = " << mode.GetUniqueName () <<
468  " data rate " << dataRate <<
469  " threshold " << threshold <<
470  " channel width " << channelWidth <<
471  " snr " << snr);
472  bestRate = dataRate;
473  maxMode = mode;
474  selectedNss = nss;
475  }
476  }
477  }
478  }
479  }
480  else
481  {
482  // Non-HT selection
483  selectedNss = 1;
484  for (uint8_t i = 0; i < GetNSupported (station); i++)
485  {
486  mode = GetSupported (station, i);
487  txVector.SetMode (mode);
488  txVector.SetNss (selectedNss);
489  uint16_t channelWidth = GetChannelWidthForNonHtMode (mode);
490  txVector.SetChannelWidth (channelWidth);
491  double threshold = GetSnrThreshold (txVector);
492  uint64_t dataRate = mode.GetDataRate (txVector.GetChannelWidth (), txVector.GetGuardInterval (), txVector.GetNss ());
493  NS_LOG_DEBUG ("mode = " << mode.GetUniqueName () <<
494  " threshold " << threshold <<
495  " last snr observed " <<
496  station->m_lastSnrObserved);
497  double snr = GetLastObservedSnr (station, channelWidth, 1);
498  if (dataRate > bestRate && threshold < snr)
499  {
500  NS_LOG_DEBUG ("Candidate mode = " << mode.GetUniqueName () <<
501  " data rate " << dataRate <<
502  " threshold " << threshold <<
503  " snr " << snr);
504  bestRate = dataRate;
505  maxMode = mode;
506  }
507  }
508  }
509  NS_LOG_DEBUG ("Updating cached values for station to " << maxMode.GetUniqueName () << " snr " << station->m_lastSnrObserved);
510  station->m_lastSnrCached = station->m_lastSnrObserved;
511  station->m_lastMode = maxMode;
512  station->m_lastNss = selectedNss;
513  }
514  NS_LOG_DEBUG ("Found maxMode: " << maxMode << " channelWidth: " << channelWidth << " nss: " << +selectedNss);
515  station->m_lastChannelWidth = channelWidth;
516  if (maxMode.GetModulationClass () == WIFI_MOD_CLASS_HE)
517  {
518  guardInterval = std::max (GetGuardInterval (station), GetGuardInterval ());
519  }
520  else if ((maxMode.GetModulationClass () == WIFI_MOD_CLASS_HT) || (maxMode.GetModulationClass () == WIFI_MOD_CLASS_VHT))
521  {
522  guardInterval = static_cast<uint16_t> (std::max (GetShortGuardIntervalSupported (station) ? 400 : 800, GetShortGuardIntervalSupported () ? 400 : 800));
523  }
524  else
525  {
526  guardInterval = 800;
527  }
528  if (m_currentRate != maxMode.GetDataRate (channelWidth, guardInterval, selectedNss))
529  {
530  NS_LOG_DEBUG ("New datarate: " << maxMode.GetDataRate (channelWidth, guardInterval, selectedNss));
531  m_currentRate = maxMode.GetDataRate (channelWidth, guardInterval, selectedNss);
532  }
533  return WifiTxVector (maxMode, GetDefaultTxPowerLevel (), GetPreambleForTransmission (maxMode.GetModulationClass (), GetShortPreambleEnabled ()), guardInterval, GetNumberOfAntennas (), selectedNss, 0, GetChannelWidthForTransmission (maxMode, channelWidth), GetAggregation (station));
534 }
535 
538 {
539  NS_LOG_FUNCTION (this << st);
540  IdealWifiRemoteStation *station = static_cast<IdealWifiRemoteStation*> (st);
541  //We search within the Basic rate set the mode with the highest
542  //SNR threshold possible which is smaller than m_lastSnr to
543  //ensure correct packet delivery.
544  double maxThreshold = 0.0;
545  WifiTxVector txVector;
546  WifiMode mode;
547  uint8_t nss = 1;
548  WifiMode maxMode = GetDefaultMode ();
549  //RTS is sent in a non-HT frame
550  for (uint8_t i = 0; i < GetNBasicModes (); i++)
551  {
552  mode = GetBasicMode (i);
553  txVector.SetMode (mode);
554  txVector.SetNss (nss);
556  double threshold = GetSnrThreshold (txVector);
557  if (threshold > maxThreshold && threshold < station->m_lastSnrObserved)
558  {
559  maxThreshold = threshold;
560  maxMode = mode;
561  }
562  }
564 }
565 
566 double
567 IdealWifiManager::GetLastObservedSnr (IdealWifiRemoteStation *station, uint16_t channelWidth, uint8_t nss) const
568 {
569  double snr = station->m_lastSnrObserved;
570  if (channelWidth != station->m_lastChannelWidthObserved)
571  {
572  snr /= (static_cast<double> (channelWidth) / station->m_lastChannelWidthObserved);
573  }
574  if (nss != station->m_lastNssObserved)
575  {
576  snr /= (static_cast<double> (nss) / station->m_lastNssObserved);
577  }
578  NS_LOG_DEBUG ("Last observed SNR is " << station->m_lastSnrObserved <<
579  " for channel width " << station->m_lastChannelWidthObserved <<
580  " and nss " << +station->m_lastNssObserved <<
581  "; computed SNR is " << snr <<
582  " for channel width " << channelWidth <<
583  " and nss " << +nss);
584  return snr;
585 }
586 
587 } //namespace ns3
uint8_t GetNMcsSupported(Mac48Address address) const
Return the number of MCS supported by the station.
bool GetVhtSupported(void) const
Return whether the device has VHT capability support enabled.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
uint8_t GetNSupported(const WifiRemoteStation *station) const
Return the number of modes supported by the given station.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
static const double CACHE_INITIAL_VALUE
To avoid using the cache before a valid value has been cached.
uint16_t m_lastNssObserved
Number of spatial streams of most recently reported packet sent to the remote station.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
void SetChannelWidth(uint16_t channelWidth)
Sets the selected channelWidth (in MHz)
#define min(a, b)
Definition: 80211b.c:42
uint16_t m_lastChannelWidth
Channel width (in MHz) most recently used to the remote station.
void SetupPhy(const Ptr< WifiPhy > phy) override
Set up PHY associated with this device since it is the object that knows the full set of transmit rat...
bool IsAllowed(uint16_t channelWidth, uint8_t nss) const
Definition: wifi-mode.cc:60
bool GetHeSupported(void) const
Return whether the device has HE capability support enabled.
#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
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
void DoReportFinalRtsFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
uint16_t m_lastChannelWidthObserved
Channel width (in MHz) of most recently reported packet sent to the remote station.
uint16_t GetGuardInterval(void) const
hold per-remote-station state for Ideal Wifi manager.
void DoReportDataFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
uint8_t GetNss(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the number of spatial streams.
WifiMode GetSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether mode associated with the specified station at the specified index. ...
WifiPreamble GetPreambleForTransmission(WifiModulationClass modulation, bool useShortPreamble)
Return the preamble to be used for the transmission.
Definition: wifi-utils.cc:116
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:47
uint8_t m_lastNss
Number of spatial streams most recently used to the remote station.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
phy
Definition: third.py:93
WifiMode GetMode(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the selected payload transmission mode...
HR/DSSS (Clause 16)
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1233
double GetLastObservedSnr(IdealWifiRemoteStation *station, uint16_t channelWidth, uint8_t nss) const
Convenience function to get the last observed SNR from a given station for a given channel width and ...
uint8_t GetNumberOfSupportedStreams(Mac48Address address) const
Return the number of spatial streams supported by the station.
bool GetShortPreambleEnabled(void) const
Return whether the device uses short PHY preambles.
static TypeId GetTypeId(void)
Get the type ID.
uint16_t GetChannelWidthForNonHtMode(WifiMode mode) const
Convenience function for selecting a channel width for non-HT mode.
double m_ber
The maximum Bit Error Rate acceptable at any transmission mode.
WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station) override
bool IsValid(void) const
The standard disallows certain combinations of WifiMode, number of spatial streams, and channel widths.
#define max(a, b)
Definition: 80211b.c:43
double GetSnrThreshold(WifiTxVector txVector)
Return the minimum SNR needed to successfully transmit data with this WifiTxVector at the specified B...
void DoReportAmpduTxStatus(WifiRemoteStation *station, uint16_t nSuccessfulMpdus, uint16_t nFailedMpdus, double rxSnr, double dataSnr, uint16_t dataChannelWidth, uint8_t dataNss) override
Typically called per A-MPDU, either when a Block ACK was successfully received or when a BlockAckTime...
void SetGuardInterval(uint16_t guardInterval)
Sets the guard interval duration (in nanoseconds)
void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode) override
This method is a pure virtual method that must be implemented by the sub-class.
void BuildSnrThresholds(void)
Construct the vector of minimum SNRs needed to successfully transmit for all possible combinations (r...
bool GetHtSupported(void) const
Return whether the device has HT capability support enabled.
WifiRemoteStation * DoCreateStation(void) const override
Thresholds m_thresholds
List of WifiTxVector and the minimum SNR pair.
double m_lastSnrObserved
SNR of most recently reported packet sent to the remote station.
virtual void SetupPhy(const Ptr< WifiPhy > phy)
Set up PHY associated with this device since it is the object that knows the full set of transmit rat...
hold a list of per-remote-station state.
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:159
std::string GetUniqueName(void) const
Definition: wifi-mode.cc:122
WifiMode GetDefaultMode(void) const
Return the default transmission mode.
void SetNss(uint8_t nss)
Sets the number of Nss.
TracedValue< uint64_t > m_currentRate
Trace rate changes.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void DoReportRtsOk(WifiRemoteStation *station, double ctsSnr, WifiMode ctsMode, double rtsSnr) override
This method is a pure virtual method that must be implemented by the sub-class.
uint16_t GetChannelWidthForTransmission(WifiMode mode, uint16_t maxSupportedChannelWidth)
Return the channel width that corresponds to the selected mode (instead of letting the PHY&#39;s default ...
Definition: wifi-utils.cc:97
void DoReportFinalDataFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
WifiTxVector DoGetDataTxVector(WifiRemoteStation *station) override
bool GetShortGuardIntervalSupported(void) const
Return whether the device has SGI support enabled.
bool GetAggregation(const WifiRemoteStation *station) const
Return whether the given station supports A-MPDU.
double m_lastSnrCached
SNR most recently used to select a rate.
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
void DoInitialize(void) override
Initialize() implementation.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:88
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: double.h:42
uint8_t GetNBasicModes(void) const
Return the number of basic modes we support.
Ptr< WifiPhy > GetPhy(void) const
Return the WifiPhy.
uint16_t GetGuardInterval(void) const
Return the supported HE guard interval duration (in nanoseconds).
void DoReportRtsFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:265
void Reset(void)
Reset the station, invoked in a STA upon dis-association or in an AP upon reboot. ...
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
Ideal rate control algorithmThis class implements an &#39;ideal&#39; rate control algorithm similar to RBAR i...
WifiMode m_lastMode
Mode most recently used to the remote station.
uint16_t GetChannelWidth(void) const
void DoReportDataOk(WifiRemoteStation *station, double ackSnr, WifiMode ackMode, double dataSnr, uint16_t dataChannelWidth, uint8_t dataNss) override
This method is a pure virtual method that must be implemented by the sub-class.
WifiMode GetBasicMode(uint8_t i) const
Return a basic mode from the set of basic modes.
This class can be used to hold variables of floating point type such as &#39;double&#39; or &#39;float&#39;...
Definition: double.h:41
uint8_t GetMcsValue(void) const
Definition: wifi-mode.cc:137
uint8_t GetMaxSupportedTxSpatialStreams(void) const
Definition: wifi-phy.cc:1403
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
hold per-remote-station state.
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:100
WifiMode GetMcsSupported(const WifiRemoteStation *station, uint8_t i) const
Return the WifiMode supported by the specified station at the specified index.
void AddSnrThreshold(WifiTxVector txVector, double snr)
Adds a pair of WifiTxVector and the minimum SNR for that given vector to the list.
uint16_t GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the station.