A Discrete-Event Network Simulator
API
rrpaa-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) 2017 Universidad de la República - Uruguay
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: Matías Richart <mrichart@fing.edu.uy>
19  */
20 
21 #include "rrpaa-wifi-manager.h"
22 #include "yans-wifi-phy.h"
23 #include "wifi-phy.h"
24 #include "wifi-mac.h"
25 #include "ns3/assert.h"
26 #include "ns3/log.h"
27 #include "ns3/boolean.h"
28 #include "ns3/double.h"
29 #include "ns3/uinteger.h"
30 #include "ns3/simulator.h"
31 #include <cmath>
32 
33 NS_LOG_COMPONENT_DEFINE ("RrpaaWifiManager");
34 
35 namespace ns3 {
36 
44 {
45  uint32_t m_counter;
46  uint32_t m_nFailed;
47  uint32_t m_adaptiveRtsWnd;
48  uint32_t m_rtsCounter;
53  uint8_t m_nRate;
54  uint8_t m_prevRateIndex;
55  uint8_t m_rateIndex;
56  uint8_t m_prevPowerLevel;
57  uint8_t m_powerLevel;
60 };
61 
63 
64 TypeId
66 {
67  static TypeId tid = TypeId ("ns3::RrpaaWifiManager")
69  .SetGroupName ("Wifi")
70  .AddConstructor<RrpaaWifiManager> ()
71  .AddAttribute ("Basic",
72  "If true the RRAA-BASIC algorithm will be used, otherwise the RRAA will be used.",
73  BooleanValue (true),
76  .AddAttribute ("Timeout",
77  "Timeout for the RRAA-BASIC loss estimation block (s).",
78  TimeValue (MilliSeconds (500)),
80  MakeTimeChecker ())
81  .AddAttribute ("FrameLength",
82  "The data frame length (in bytes) used for calculating mode TxTime.",
83  UintegerValue (1420),
85  MakeUintegerChecker <uint32_t> ())
86  .AddAttribute ("AckFrameLength",
87  "The ACK frame length (in bytes) used for calculating mode TxTime.",
88  UintegerValue (14),
90  MakeUintegerChecker <uint32_t> ())
91  .AddAttribute ("Alpha",
92  "Constant for calculating the MTL threshold.",
93  DoubleValue (1.25),
95  MakeDoubleChecker<double> (1))
96  .AddAttribute ("Beta",
97  "Constant for calculating the ORI threshold.",
98  DoubleValue (2),
100  MakeDoubleChecker<double> (1))
101  .AddAttribute ("Tau",
102  "Constant for calculating the EWND size.",
103  DoubleValue (0.015),
105  MakeDoubleChecker<double> (0))
106  .AddAttribute ("Gamma",
107  "Constant for Probabilistic Decision Table decrements.",
108  DoubleValue (2),
110  MakeDoubleChecker<double> (1))
111  .AddAttribute ("Delta",
112  "Constant for Probabilistic Decision Table increments.",
113  DoubleValue (1.0905),
115  MakeDoubleChecker<double> (1))
116  .AddTraceSource ("RateChange",
117  "The transmission rate has change.",
119  "ns3::WifiRemoteStationManager::RateChangeTracedCallback")
120  .AddTraceSource ("PowerChange",
121  "The transmission power has change.",
123  "ns3::WifiRemoteStationManager::PowerChangeTracedCallback")
124  ;
125  return tid;
126 }
127 
128 
130 {
131  NS_LOG_FUNCTION (this);
132  m_uniformRandomVariable = CreateObject<UniformRandomVariable> ();
133 }
134 
136 {
137  NS_LOG_FUNCTION (this);
138 }
139 
140 int64_t
142 {
143  NS_LOG_FUNCTION (this << stream);
145  return 1;
146 }
147 
148 void
150 {
151  NS_LOG_FUNCTION (this << phy);
152  m_nPowerLevels = phy->GetNTxPower ();
154  m_minPowerLevel = 0;
155  uint8_t nModes = phy->GetNModes ();
156  for (uint8_t i = 0; i < nModes; i++)
157  {
158  WifiMode mode = phy->GetMode (i);
159  WifiTxVector txVector;
160  txVector.SetMode (mode);
162  /* Calculate the TX Time of the data and the corresponding ACK*/
163  Time dataTxTime = phy->CalculateTxDuration (m_frameLength, txVector, phy->GetFrequency ());
164  Time ackTxTime = phy->CalculateTxDuration (m_ackLength, txVector, phy->GetFrequency ());
165  NS_LOG_DEBUG ("Calculating TX times: Mode= " << mode << " DataTxTime= " << dataTxTime << " AckTxTime= " << ackTxTime);
166  AddCalcTxTime (mode, dataTxTime + ackTxTime);
167  }
169 }
170 
171 void
173 {
174  NS_LOG_FUNCTION (this << mac);
175  m_sifs = mac->GetSifs ();
176  m_difs = m_sifs + 2 * mac->GetSlot ();
178 }
179 
180 Time
182 {
183  NS_LOG_FUNCTION (this << mode);
184  for (TxTime::const_iterator i = m_calcTxTime.begin (); i != m_calcTxTime.end (); i++)
185  {
186  if (mode == i->second)
187  {
188  return i->first;
189  }
190  }
191  NS_ASSERT (false);
192  return Seconds (0);
193 }
194 
195 void
197 {
198  NS_LOG_FUNCTION (this << mode << t);
199  m_calcTxTime.push_back (std::make_pair (t, mode));
200 }
201 
204 {
205  NS_LOG_FUNCTION (this << station << mode);
206  struct WifiRrpaaThresholds threshold;
207  for (RrpaaThresholdsTable::const_iterator i = station->m_thresholds.begin (); i != station->m_thresholds.end (); i++)
208  {
209  if (mode == i->second)
210  {
211  return i->first;
212  }
213  }
214  NS_ABORT_MSG ("No thresholds for mode " << mode << " found");
215  return threshold; // Silence compiler warning
216 }
217 
220 {
221  NS_LOG_FUNCTION (this);
223  station->m_adaptiveRtsWnd = 0;
224  station->m_rtsCounter = 0;
225  station->m_adaptiveRtsOn = false;
226  station->m_lastFrameFail = false;
227  station->m_initialized = false;
228  return station;
229 }
230 
231 void
233 {
234  NS_LOG_FUNCTION (this << station);
235  if (!station->m_initialized)
236  {
237  //Note: we appear to be doing late initialization of the table
238  //to make sure that the set of supported rates has been initialized
239  //before we perform our own initialization.
240  station->m_nRate = GetNSupported (station);
241  //Initialize at minimal rate and maximal power.
242  station->m_prevRateIndex = 0;
243  station->m_rateIndex = 0;
245  station->m_powerLevel = m_maxPowerLevel;
246  WifiMode mode = GetSupported (station, 0);
247  uint8_t channelWidth = GetChannelWidth (station);
248  DataRate rate = DataRate (mode.GetDataRate (channelWidth));
249  double power = GetPhy ()->GetPowerDbm (station->m_powerLevel);
250  m_rateChange (rate, rate, station->m_state->m_address);
251  m_powerChange (power, power, station->m_state->m_address);
252 
253  station->m_pdTable = RrpaaProbabilitiesTable (station->m_nRate, std::vector<double> (m_nPowerLevels));
254  NS_LOG_DEBUG ("Initializing pdTable");
255  for (uint8_t i = 0; i < station->m_nRate; i++)
256  {
257  for (uint8_t j = 0; j < m_nPowerLevels; j++)
258  {
259  station->m_pdTable[i][j] = 1;
260  }
261  }
262 
263  station->m_initialized = true;
264 
265  station->m_thresholds = RrpaaThresholdsTable (station->m_nRate);
266  InitThresholds (station);
267  ResetCountersBasic (station);
268  }
269 }
270 
271 void
273 {
274  NS_LOG_FUNCTION (this << station);
275  double nextCritical = 0;
276  double nextMtl = 0;
277  double mtl = 0;
278  double ori = 0;
279  for (uint8_t i = 0; i < station->m_nRate; i++)
280  {
281  WifiMode mode = GetSupported (station, i);
282  Time totalTxTime = GetCalcTxTime (mode) + m_sifs + m_difs;
283  if (i == station->m_nRate - 1)
284  {
285  ori = 0;
286  }
287  else
288  {
289  WifiMode nextMode = GetSupported (station, i + 1);
290  Time nextTotalTxTime = GetCalcTxTime (nextMode) + m_sifs + m_difs;
291  nextCritical = 1 - (nextTotalTxTime.GetSeconds () / totalTxTime.GetSeconds ());
292  nextMtl = m_alpha * nextCritical;
293  ori = nextMtl / m_beta;
294  }
295  if (i == 0)
296  {
297  mtl = nextMtl;
298  }
300  th.m_ewnd = ceil (m_tau / totalTxTime.GetSeconds ());
301  th.m_ori = ori;
302  th.m_mtl = mtl;
303  station->m_thresholds.push_back (std::make_pair (th, mode));
304  mtl = nextMtl;
305  NS_LOG_DEBUG (mode << " " << th.m_ewnd << " " << th.m_mtl << " " << th.m_ori);
306  }
307 }
308 
309 void
311 {
312  NS_LOG_FUNCTION (this << station);
313  station->m_nFailed = 0;
314  station->m_counter = GetThresholds (station, station->m_rateIndex).m_ewnd;
315  station->m_lastReset = Simulator::Now ();
316 }
317 
318 void
320 {
321  NS_LOG_FUNCTION (this << st);
322 }
323 
324 void
326 {
327  NS_LOG_FUNCTION (this << st);
329  CheckInit (station);
330  station->m_lastFrameFail = true;
331  CheckTimeout (station);
332  station->m_counter--;
333  station->m_nFailed++;
334  RunBasicAlgorithm (station);
335 }
336 
337 void
339  double rxSnr, WifiMode txMode)
340 {
341  NS_LOG_FUNCTION (this << st << rxSnr << txMode);
342 }
343 
344 void
346  double ctsSnr, WifiMode ctsMode, double rtsSnr)
347 {
348  NS_LOG_FUNCTION (this << st << ctsSnr << ctsMode << rtsSnr);
349 }
350 
351 void
353  double ackSnr, WifiMode ackMode, double dataSnr)
354 {
355  NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr);
357  CheckInit (station);
358  station->m_lastFrameFail = false;
359  CheckTimeout (station);
360  station->m_counter--;
361  RunBasicAlgorithm (station);
362 }
363 void
365 {
366  NS_LOG_FUNCTION (this << st);
367 }
368 void
370 {
371  NS_LOG_FUNCTION (this << st);
372 }
373 
376 {
377  NS_LOG_FUNCTION (this << st);
379  uint8_t channelWidth = GetChannelWidth (station);
380  if (channelWidth > 20 && channelWidth != 22)
381  {
382  //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac
383  channelWidth = 20;
384  }
385  CheckInit (station);
386  WifiMode mode = GetSupported (station, station->m_rateIndex);
387  DataRate rate = DataRate (mode.GetDataRate (channelWidth));
388  DataRate prevRate = DataRate (GetSupported (station, station->m_prevRateIndex).GetDataRate (channelWidth));
389  double power = GetPhy ()->GetPowerDbm (station->m_powerLevel);
390  double prevPower = GetPhy ()->GetPowerDbm (station->m_prevPowerLevel);
391  if (station->m_prevRateIndex != station->m_rateIndex)
392  {
393  m_rateChange (prevRate, rate, station->m_state->m_address);
394  station->m_prevRateIndex = station->m_rateIndex;
395  }
396  if (station->m_prevPowerLevel != station->m_powerLevel)
397  {
398  m_powerChange (prevPower, power, station->m_state->m_address);
399  station->m_prevPowerLevel = station->m_powerLevel;
400  }
401  return WifiTxVector (mode, station->m_powerLevel, GetPreambleForTransmission (mode, GetAddress (station)), 800, 1, 1, 0, channelWidth, GetAggregation (station), false);
402 }
405 {
406  NS_LOG_FUNCTION (this << st);
408  uint8_t channelWidth = GetChannelWidth (station);
409  if (channelWidth > 20 && channelWidth != 22)
410  {
411  //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac
412  channelWidth = 20;
413  }
414  WifiTxVector rtsTxVector;
415  WifiMode mode;
416  if (GetUseNonErpProtection () == false)
417  {
418  mode = GetSupported (station, 0);
419  }
420  else
421  {
422  mode = GetNonErpSupported (station, 0);
423  }
424  rtsTxVector = WifiTxVector (mode, GetDefaultTxPowerLevel (), GetPreambleForTransmission (mode, GetAddress (st)), 800, 1, 1, 0, channelWidth, GetAggregation (station), false);
425  return rtsTxVector;
426 }
427 
428 bool
430  Ptr<const Packet> packet, bool normally)
431 {
432  NS_LOG_FUNCTION (this << st << packet << normally);
434  CheckInit (station);
435  if (m_basic)
436  {
437  return normally;
438  }
439  RunAdaptiveRtsAlgorithm (station);
440  return station->m_adaptiveRtsOn;
441 }
442 
443 void
445 {
446  NS_LOG_FUNCTION (this << station);
447  Time d = Simulator::Now () - station->m_lastReset;
448  if (station->m_counter == 0 || d > m_timeout)
449  {
450  ResetCountersBasic (station);
451  }
452 }
453 
454 void
456 {
457  NS_LOG_FUNCTION (this << station);
458  WifiRrpaaThresholds thresholds = GetThresholds (station, station->m_rateIndex);
459  double bploss = (static_cast<double> (station->m_nFailed) / thresholds.m_ewnd);
460  double wploss = (static_cast<double> (station->m_counter + station->m_nFailed) / thresholds.m_ewnd);
461  NS_LOG_DEBUG ("Best loss prob= " << bploss);
462  NS_LOG_DEBUG ("Worst loss prob= " << wploss);
463  if (bploss >= thresholds.m_mtl)
464  {
465  if (station->m_powerLevel < m_maxPowerLevel)
466  {
467  NS_LOG_DEBUG ("bploss >= MTL and power < maxPower => Increase Power");
468  station->m_pdTable[station->m_rateIndex][station->m_powerLevel] /= m_gamma;
469  NS_LOG_DEBUG ("pdTable[" << +station->m_rateIndex << "][" << station->m_powerLevel << "] = " << station->m_pdTable[station->m_rateIndex][station->m_powerLevel]);
470  station->m_powerLevel++;
471  ResetCountersBasic (station);
472  }
473  else if (station->m_rateIndex != 0)
474  {
475  NS_LOG_DEBUG ("bploss >= MTL and power = maxPower => Decrease Rate");
476  station->m_pdTable[station->m_rateIndex][station->m_powerLevel] /= m_gamma;
477  NS_LOG_DEBUG ("pdTable[" << +station->m_rateIndex << "][" << station->m_powerLevel << "] = " << station->m_pdTable[station->m_rateIndex][station->m_powerLevel]);
478  station->m_rateIndex--;
479  ResetCountersBasic (station);
480  }
481  else
482  {
483  NS_LOG_DEBUG ("bploss >= MTL but already at maxPower and minRate");
484  }
485  }
486  else if (wploss <= thresholds.m_ori)
487  {
488  if (station->m_rateIndex < station->m_nRate - 1)
489  {
490  NS_LOG_DEBUG ("wploss <= ORI and rate < maxRate => Probabilistic Rate Increase");
491 
492  // Recalculate probabilities of lower rates.
493  for (uint8_t i = 0; i <= station->m_rateIndex; i++)
494  {
495  station->m_pdTable[i][station->m_powerLevel] *= m_delta;
496  if (station->m_pdTable[i][station->m_powerLevel] > 1)
497  {
498  station->m_pdTable[i][station->m_powerLevel] = 1;
499  }
500  NS_LOG_DEBUG ("pdTable[" << i << "][" << (int)station->m_powerLevel << "] = " << station->m_pdTable[i][station->m_powerLevel]);
501  }
502  double rand = m_uniformRandomVariable->GetValue (0,1);
503  if (rand < station->m_pdTable[station->m_rateIndex + 1][station->m_powerLevel])
504  {
505  NS_LOG_DEBUG ("Increase Rate");
506  station->m_rateIndex++;
507  }
508  }
509  else if (station->m_powerLevel > m_minPowerLevel)
510  {
511  NS_LOG_DEBUG ("wploss <= ORI and rate = maxRate => Probabilistic Power Decrease");
512 
513  // Recalculate probabilities of higher powers.
514  for (uint32_t i = m_maxPowerLevel; i > station->m_powerLevel; i--)
515  {
516  station->m_pdTable[station->m_rateIndex][i] *= m_delta;
517  if (station->m_pdTable[station->m_rateIndex][i] > 1)
518  {
519  station->m_pdTable[station->m_rateIndex][i] = 1;
520  }
521  NS_LOG_DEBUG ("pdTable[" << +station->m_rateIndex << "][" << i << "] = " << station->m_pdTable[station->m_rateIndex][i]);
522  }
523  double rand = m_uniformRandomVariable->GetValue (0,1);
524  if (rand < station->m_pdTable[station->m_rateIndex][station->m_powerLevel - 1])
525  {
526  NS_LOG_DEBUG ("Decrease Power");
527  station->m_powerLevel--;
528  }
529  }
530  ResetCountersBasic (station);
531  }
532  else if (bploss > thresholds.m_ori && wploss < thresholds.m_mtl)
533  {
534  if (station->m_powerLevel > m_minPowerLevel)
535  {
536  NS_LOG_DEBUG ("loss between ORI and MTL and power > minPowerLevel => Probabilistic Power Decrease");
537 
538  // Recalculate probabilities of higher powers.
539  for (uint32_t i = m_maxPowerLevel; i >= station->m_powerLevel; i--)
540  {
541  station->m_pdTable[station->m_rateIndex][i] *= m_delta;
542  if (station->m_pdTable[station->m_rateIndex][i] > 1)
543  {
544  station->m_pdTable[station->m_rateIndex][i] = 1;
545  }
546  NS_LOG_DEBUG ("pdTable[" << +station->m_rateIndex << "][" << i << "] = " << station->m_pdTable[station->m_rateIndex][i]);
547  }
548  double rand = m_uniformRandomVariable->GetValue (0,1);
549  if (rand < station->m_pdTable[station->m_rateIndex][station->m_powerLevel - 1])
550  {
551  NS_LOG_DEBUG ("Decrease Power");
552  station->m_powerLevel--;
553  }
554  ResetCountersBasic (station);
555  }
556  }
557  if (station->m_counter == 0)
558  {
559  ResetCountersBasic (station);
560  }
561 }
562 
563 void
565 {
566  NS_LOG_FUNCTION (this << station);
567  if (!station->m_adaptiveRtsOn
568  && station->m_lastFrameFail)
569  {
570  station->m_adaptiveRtsWnd += 2;
571  station->m_rtsCounter = station->m_adaptiveRtsWnd;
572  }
573  else if ((station->m_adaptiveRtsOn && station->m_lastFrameFail)
574  || (!station->m_adaptiveRtsOn && !station->m_lastFrameFail))
575  {
576  station->m_adaptiveRtsWnd = station->m_adaptiveRtsWnd / 2;
577  station->m_rtsCounter = station->m_adaptiveRtsWnd;
578  }
579  if (station->m_rtsCounter > 0)
580  {
581  station->m_adaptiveRtsOn = true;
582  station->m_rtsCounter--;
583  }
584  else
585  {
586  station->m_adaptiveRtsOn = false;
587  }
588 }
589 
592 {
593  NS_LOG_FUNCTION (this << station << +rate);
594  WifiMode mode = GetSupported (station, rate);
595  return GetThresholds (station, mode);
596 }
597 
598 bool
600 {
601  return true;
602 }
603 
604 void
606 {
607  //HT is not supported by this algorithm.
608  if (enable)
609  {
610  NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HT rates");
611  }
612 }
613 
614 void
616 {
617  //VHT is not supported by this algorithm.
618  if (enable)
619  {
620  NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support VHT rates");
621  }
622 }
623 
624 void
626 {
627  //HE is not supported by this algorithm.
628  if (enable)
629  {
630  NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HE rates");
631  }
632 }
633 
634 } // namespace ns3
uint8_t GetNTxPower(void) const
Return the number of available transmission power levels.
Definition: wifi-phy.cc:543
virtual void DoReportRtsOk(WifiRemoteStation *station, double ctsSnr, WifiMode ctsMode, double rtsSnr)
This method is a pure virtual method that must be implemented by the sub-class.
Hold per-remote-station state for RRPAA Wifi manager.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
uint8_t m_nPowerLevels
Number of power levels.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
AttributeValue implementation for Boolean.
Definition: boolean.h:36
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition: abort.h:50
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Time m_lastReset
Time of the last reset.
void CheckInit(RrpaaWifiRemoteStation *station)
Check for initializations.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
double m_ori
The Oportunistic Rate Increase threshold.
uint32_t m_rtsCounter
Counter for RTS transmission attempts.
uint8_t m_prevRateIndex
Rate index of the previous transmission.
virtual void SetupMac(const Ptr< WifiMac > mac)
Set up MAC associated with this device since it is the object that knows the full set of timing param...
bool GetUseNonErpProtection(void) const
Return whether the device supports protection of non-ERP stations.
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:84
Time m_sifs
Value of SIFS configured in the device.
uint8_t m_minPowerLevel
Differently form rate, power levels do not depend on the remote station.
#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:201
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1015
void AddCalcTxTime(WifiMode mode, Time t)
Add transmission time for the given mode to an internal list.
Mac48Address m_address
Mac48Address of the remote station.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
bool m_basic
If using the basic algorithm (without RTS/CTS).
virtual void DoReportRtsFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
uint32_t m_counter
Counter for transmission attempts.
uint16_t GetFrequency(void) const
Definition: wifi-phy.cc:1260
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:97
bool GetAggregation(const WifiRemoteStation *station) const
Return whether the given station supports A-MPDU.
RrpaaThresholdsTable m_thresholds
Rrpaa thresholds for this station.
uint8_t m_rateIndex
Current rate index.
WifiRemoteStationState * m_state
Remote station state.
virtual WifiRemoteStation * DoCreateStation(void) const
bool m_lastFrameFail
Flag if the last frame sent has failed.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
virtual bool IsLowLatency(void) const
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:446
virtual void DoReportFinalDataFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
Class for representing data rates.
Definition: data-rate.h:88
uint32_t m_ewnd
The Estimation Window size.
Ptr< WifiPhy > GetPhy(void) const
Return the WifiPhy.
Time CalculateTxDuration(uint32_t size, WifiTxVector txVector, uint16_t frequency)
Definition: wifi-phy.cc:2301
double GetPowerDbm(uint8_t power) const
Get the power of the given power level in dBm.
Definition: wifi-phy.cc:716
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:355
void ResetCountersBasic(RrpaaWifiRemoteStation *station)
Reset the counters of the given station.
double m_beta
Beta value for RRPAA (value for calculating ORI threshold).
uint8_t m_powerLevel
Current power level.
tuple phy
Definition: third.py:86
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Ptr< UniformRandomVariable > m_uniformRandomVariable
Provides uniform random variables for probabilistic changes.
Time m_timeout
Timeout for the RRAA BASIC loss estimation block.
AttributeValue implementation for Time.
Definition: nstime.h:1069
double m_tau
Tau value for RRPAA (value for calculating EWND size).
Time m_difs
Value of DIFS configured in the device.
Hold an unsigned integer type.
Definition: uinteger.h:44
WifiPreamble GetPreambleForTransmission(WifiMode mode, Mac48Address dest)
Return the preamble to be used for the transmission.
uint64_t GetDataRate(uint8_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:143
uint8_t GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the station.
Time GetCalcTxTime(WifiMode mode) const
Get the estimated TxTime of a packet with a given mode.
WifiMode GetMode(uint8_t mode) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
Definition: wifi-phy.cc:3576
static TypeId GetTypeId(void)
Register this type.
uint32_t m_adaptiveRtsWnd
Window size for the Adaptive RTS mechanism.
virtual void DoReportFinalRtsFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
Mac48Address GetAddress(const WifiRemoteStation *station) const
Return the address of the station.
double m_mtl
The Maximum Tolerable Loss threshold.
virtual void SetHtSupported(bool enable)
Enable or disable HT capability support.
tuple mac
Definition: third.py:92
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.
double m_delta
Delta value for RRPAA (value for pdTable increments).
uint32_t m_nFailed
Number of failed transmission attempts.
TracedCallback< double, double, Mac48Address > m_powerChange
The trace source fired when the transmission power change.
TracedCallback< DataRate, DataRate, Mac48Address > m_rateChange
The trace source fired when the transmission rate change.
RrpaaProbabilitiesTable m_pdTable
Probability table for power and rate changes.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetPreambleType(WifiPreamble preamble)
Sets the preamble type.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
uint8_t m_prevPowerLevel
Power level of the previous transmission.
bool m_adaptiveRtsOn
Check if Adaptive RTS mechanism is on.
WifiRrpaaThresholds GetThresholds(RrpaaWifiRemoteStation *station, WifiMode mode) const
Get the thresholds for the given station and mode.
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
virtual bool DoNeedRts(WifiRemoteStation *st, Ptr< const Packet > packet, bool normally)
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: nstime.h:1070
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:249
virtual void DoReportDataOk(WifiRemoteStation *station, double ackSnr, WifiMode ackMode, double dataSnr)
This method is a pure virtual method that must be implemented by the sub-class.
void RunBasicAlgorithm(RrpaaWifiRemoteStation *station)
Find an appropriate rate and power for the given station, using a basic algorithm.
WifiMode GetSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether mode associated with the specified station at the specified index. ...
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
uint32_t m_frameLength
Data frame length used for calculate mode TxTime.
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
void InitThresholds(RrpaaWifiRemoteStation *station)
Initialize the thresholds internal list for the given station.
uint8_t m_maxPowerLevel
Maximal power level.
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...
uint32_t m_ackLength
Ack frame length used for calculate mode TxTime.
virtual void SetupMac(const Ptr< WifiMac > mac)
Set up MAC associated with this device since it is the object that knows the full set of timing param...
Robust Rate and Power Adaptation Algorithm.
WifiMode GetNonErpSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether non-ERP mode associated with the specified station at the specified index...
virtual WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station)
double m_alpha
Alpha value for RRPAA (value for calculating MTL threshold)
bool m_initialized
For initializing variables.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:269
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1007
TxTime m_calcTxTime
To hold all the calculated TxTime for all modes.
virtual void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode)
This method is a pure virtual method that must be implemented by the sub-class.
std::vector< std::pair< WifiRrpaaThresholds, WifiMode > > RrpaaThresholdsTable
List of thresholds for each mode.
uint8_t GetNSupported(const WifiRemoteStation *station) const
Return the number of modes supported by the given station.
virtual void DoReportDataFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
virtual WifiTxVector DoGetDataTxVector(WifiRemoteStation *station)
virtual void SetHeSupported(bool enable)
Enable or disable HE capability support.
virtual void SetVhtSupported(bool enable)
Enable or disable VHT capability support.
uint8_t m_nRate
Number of supported rates.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Definition: double.h:41
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
void RunAdaptiveRtsAlgorithm(RrpaaWifiRemoteStation *station)
Run an enhanced algorithm which activates the use of RTS for the given station if the conditions are ...
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:914
hold per-remote-station state.
void CheckTimeout(RrpaaWifiRemoteStation *station)
Check if the counter should be reseted.
double m_gamma
Gamma value for RRPAA (value for pdTable decrements).
uint8_t GetNModes(void) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
Definition: wifi-phy.cc:3570
std::vector< std::vector< double > > RrpaaProbabilitiesTable
List of probabilities.