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