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 "wifi-phy.h"
30 #include "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 RRAA-BASIC algorithm will be used, otherwise the RRAA will be used.",
72  BooleanValue (true),
75  .AddAttribute ("Timeout",
76  "Timeout for the RRAA-BASIC loss estimation block (s).",
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_nPowerLevels = phy->GetNTxPower ();
153  m_minPowerLevel = 0;
154  uint8_t nModes = phy->GetNModes ();
155  for (uint8_t i = 0; i < nModes; i++)
156  {
157  WifiMode mode = phy->GetMode (i);
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->GetFrequency ());
163  Time ackTxTime = phy->CalculateTxDuration (m_ackLength, txVector, phy->GetFrequency ());
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);
174  m_sifs = mac->GetSifs ();
175  m_difs = m_sifs + 2 * mac->GetSlot ();
177 }
178 
179 void
181 {
182  NS_LOG_FUNCTION (this);
183  if (GetHtSupported ())
184  {
185  NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HT rates");
186  }
187  if (GetVhtSupported ())
188  {
189  NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support VHT rates");
190  }
191  if (GetHeSupported ())
192  {
193  NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HE rates");
194  }
195 }
196 
197 Time
199 {
200  NS_LOG_FUNCTION (this << mode);
201  for (TxTime::const_iterator i = m_calcTxTime.begin (); i != m_calcTxTime.end (); i++)
202  {
203  if (mode == i->second)
204  {
205  return i->first;
206  }
207  }
208  NS_ASSERT (false);
209  return Seconds (0);
210 }
211 
212 void
214 {
215  NS_LOG_FUNCTION (this << mode << t);
216  m_calcTxTime.push_back (std::make_pair (t, mode));
217 }
218 
221 {
222  NS_LOG_FUNCTION (this << station << mode);
223  struct WifiRrpaaThresholds threshold;
224  for (RrpaaThresholdsTable::const_iterator i = station->m_thresholds.begin (); i != station->m_thresholds.end (); i++)
225  {
226  if (mode == i->second)
227  {
228  return i->first;
229  }
230  }
231  NS_ABORT_MSG ("No thresholds for mode " << mode << " found");
232  return threshold; // Silence compiler warning
233 }
234 
237 {
238  NS_LOG_FUNCTION (this);
240  station->m_adaptiveRtsWnd = 0;
241  station->m_rtsCounter = 0;
242  station->m_adaptiveRtsOn = false;
243  station->m_lastFrameFail = false;
244  station->m_initialized = false;
245  return station;
246 }
247 
248 void
250 {
251  NS_LOG_FUNCTION (this << station);
252  if (!station->m_initialized)
253  {
254  //Note: we appear to be doing late initialization of the table
255  //to make sure that the set of supported rates has been initialized
256  //before we perform our own initialization.
257  station->m_nRate = GetNSupported (station);
258  //Initialize at minimal rate and maximal power.
259  station->m_prevRateIndex = 0;
260  station->m_rateIndex = 0;
262  station->m_powerLevel = m_maxPowerLevel;
263  WifiMode mode = GetSupported (station, 0);
264  uint16_t channelWidth = GetChannelWidth (station);
265  DataRate rate = DataRate (mode.GetDataRate (channelWidth));
266  double power = GetPhy ()->GetPowerDbm (station->m_powerLevel);
267  m_rateChange (rate, rate, station->m_state->m_address);
268  m_powerChange (power, power, station->m_state->m_address);
269 
270  station->m_pdTable = RrpaaProbabilitiesTable (station->m_nRate, std::vector<double> (m_nPowerLevels));
271  NS_LOG_DEBUG ("Initializing pdTable");
272  for (uint8_t i = 0; i < station->m_nRate; i++)
273  {
274  for (uint8_t j = 0; j < m_nPowerLevels; j++)
275  {
276  station->m_pdTable[i][j] = 1;
277  }
278  }
279 
280  station->m_initialized = true;
281 
282  station->m_thresholds = RrpaaThresholdsTable (station->m_nRate);
283  InitThresholds (station);
284  ResetCountersBasic (station);
285  }
286 }
287 
288 void
290 {
291  NS_LOG_FUNCTION (this << station);
292  double nextCritical = 0;
293  double nextMtl = 0;
294  double mtl = 0;
295  double ori = 0;
296  for (uint8_t i = 0; i < station->m_nRate; i++)
297  {
298  WifiMode mode = GetSupported (station, i);
299  Time totalTxTime = GetCalcTxTime (mode) + m_sifs + m_difs;
300  if (i == station->m_nRate - 1)
301  {
302  ori = 0;
303  }
304  else
305  {
306  WifiMode nextMode = GetSupported (station, i + 1);
307  Time nextTotalTxTime = GetCalcTxTime (nextMode) + m_sifs + m_difs;
308  nextCritical = 1 - (nextTotalTxTime.GetSeconds () / totalTxTime.GetSeconds ());
309  nextMtl = m_alpha * nextCritical;
310  ori = nextMtl / m_beta;
311  }
312  if (i == 0)
313  {
314  mtl = nextMtl;
315  }
317  th.m_ewnd = static_cast<uint32_t> (ceil (m_tau / totalTxTime.GetSeconds ()));
318  th.m_ori = ori;
319  th.m_mtl = mtl;
320  station->m_thresholds.push_back (std::make_pair (th, mode));
321  mtl = nextMtl;
322  NS_LOG_DEBUG (mode << " " << th.m_ewnd << " " << th.m_mtl << " " << th.m_ori);
323  }
324 }
325 
326 void
328 {
329  NS_LOG_FUNCTION (this << station);
330  station->m_nFailed = 0;
331  station->m_counter = GetThresholds (station, station->m_rateIndex).m_ewnd;
332  station->m_lastReset = Simulator::Now ();
333 }
334 
335 void
337 {
338  NS_LOG_FUNCTION (this << st);
339 }
340 
341 void
343 {
344  NS_LOG_FUNCTION (this << st);
346  CheckInit (station);
347  station->m_lastFrameFail = true;
348  CheckTimeout (station);
349  station->m_counter--;
350  station->m_nFailed++;
351  RunBasicAlgorithm (station);
352 }
353 
354 void
356  double rxSnr, WifiMode txMode)
357 {
358  NS_LOG_FUNCTION (this << st << rxSnr << txMode);
359 }
360 
361 void
363  double ctsSnr, WifiMode ctsMode, double rtsSnr)
364 {
365  NS_LOG_FUNCTION (this << st << ctsSnr << ctsMode << rtsSnr);
366 }
367 
368 void
370  double ackSnr, WifiMode ackMode, double dataSnr)
371 {
372  NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr);
374  CheckInit (station);
375  station->m_lastFrameFail = false;
376  CheckTimeout (station);
377  station->m_counter--;
378  RunBasicAlgorithm (station);
379 }
380 void
382 {
383  NS_LOG_FUNCTION (this << st);
384 }
385 void
387 {
388  NS_LOG_FUNCTION (this << st);
389 }
390 
393 {
394  NS_LOG_FUNCTION (this << st);
396  uint16_t channelWidth = GetChannelWidth (station);
397  if (channelWidth > 20 && channelWidth != 22)
398  {
399  channelWidth = 20;
400  }
401  CheckInit (station);
402  WifiMode mode = GetSupported (station, station->m_rateIndex);
403  DataRate rate = DataRate (mode.GetDataRate (channelWidth));
404  DataRate prevRate = DataRate (GetSupported (station, station->m_prevRateIndex).GetDataRate (channelWidth));
405  double power = GetPhy ()->GetPowerDbm (station->m_powerLevel);
406  double prevPower = GetPhy ()->GetPowerDbm (station->m_prevPowerLevel);
407  if (station->m_prevRateIndex != station->m_rateIndex)
408  {
409  m_rateChange (prevRate, rate, station->m_state->m_address);
410  station->m_prevRateIndex = station->m_rateIndex;
411  }
412  if (station->m_prevPowerLevel != station->m_powerLevel)
413  {
414  m_powerChange (prevPower, power, station->m_state->m_address);
415  station->m_prevPowerLevel = station->m_powerLevel;
416  }
417  return WifiTxVector (mode, station->m_powerLevel, GetPreambleForTransmission (mode.GetModulationClass (), GetShortPreambleEnabled (), UseGreenfieldForDestination (GetAddress (station))), 800, 1, 1, 0, channelWidth, GetAggregation (station), false);
418 }
421 {
422  NS_LOG_FUNCTION (this << st);
424  uint16_t channelWidth = GetChannelWidth (station);
425  if (channelWidth > 20 && channelWidth != 22)
426  {
427  channelWidth = 20;
428  }
429  WifiTxVector rtsTxVector;
430  WifiMode mode;
431  if (GetUseNonErpProtection () == false)
432  {
433  mode = GetSupported (station, 0);
434  }
435  else
436  {
437  mode = GetNonErpSupported (station, 0);
438  }
439  rtsTxVector = WifiTxVector (mode, GetDefaultTxPowerLevel (), GetPreambleForTransmission (mode.GetModulationClass (), GetShortPreambleEnabled (), UseGreenfieldForDestination (GetAddress (station))), 800, 1, 1, 0, channelWidth, GetAggregation (station), false);
440  return rtsTxVector;
441 }
442 
443 bool
445  Ptr<const Packet> packet, bool normally)
446 {
447  NS_LOG_FUNCTION (this << st << packet << normally);
449  CheckInit (station);
450  if (m_basic)
451  {
452  return normally;
453  }
454  RunAdaptiveRtsAlgorithm (station);
455  return station->m_adaptiveRtsOn;
456 }
457 
458 void
460 {
461  NS_LOG_FUNCTION (this << station);
462  Time d = Simulator::Now () - station->m_lastReset;
463  if (station->m_counter == 0 || d > m_timeout)
464  {
465  ResetCountersBasic (station);
466  }
467 }
468 
469 void
471 {
472  NS_LOG_FUNCTION (this << station);
473  WifiRrpaaThresholds thresholds = GetThresholds (station, station->m_rateIndex);
474  double bploss = (static_cast<double> (station->m_nFailed) / thresholds.m_ewnd);
475  double wploss = (static_cast<double> (station->m_counter + station->m_nFailed) / thresholds.m_ewnd);
476  NS_LOG_DEBUG ("Best loss prob= " << bploss);
477  NS_LOG_DEBUG ("Worst loss prob= " << wploss);
478  if (bploss >= thresholds.m_mtl)
479  {
480  if (station->m_powerLevel < m_maxPowerLevel)
481  {
482  NS_LOG_DEBUG ("bploss >= MTL and power < maxPower => Increase Power");
483  station->m_pdTable[station->m_rateIndex][station->m_powerLevel] /= m_gamma;
484  NS_LOG_DEBUG ("pdTable[" << +station->m_rateIndex << "][" << station->m_powerLevel << "] = " << station->m_pdTable[station->m_rateIndex][station->m_powerLevel]);
485  station->m_powerLevel++;
486  ResetCountersBasic (station);
487  }
488  else if (station->m_rateIndex != 0)
489  {
490  NS_LOG_DEBUG ("bploss >= MTL and power = maxPower => Decrease Rate");
491  station->m_pdTable[station->m_rateIndex][station->m_powerLevel] /= m_gamma;
492  NS_LOG_DEBUG ("pdTable[" << +station->m_rateIndex << "][" << station->m_powerLevel << "] = " << station->m_pdTable[station->m_rateIndex][station->m_powerLevel]);
493  station->m_rateIndex--;
494  ResetCountersBasic (station);
495  }
496  else
497  {
498  NS_LOG_DEBUG ("bploss >= MTL but already at maxPower and minRate");
499  }
500  }
501  else if (wploss <= thresholds.m_ori)
502  {
503  if (station->m_rateIndex < station->m_nRate - 1)
504  {
505  NS_LOG_DEBUG ("wploss <= ORI and rate < maxRate => Probabilistic Rate Increase");
506 
507  // Recalculate probabilities of lower rates.
508  for (uint8_t i = 0; i <= station->m_rateIndex; i++)
509  {
510  station->m_pdTable[i][station->m_powerLevel] *= m_delta;
511  if (station->m_pdTable[i][station->m_powerLevel] > 1)
512  {
513  station->m_pdTable[i][station->m_powerLevel] = 1;
514  }
515  NS_LOG_DEBUG ("pdTable[" << i << "][" << (int)station->m_powerLevel << "] = " << station->m_pdTable[i][station->m_powerLevel]);
516  }
517  double rand = m_uniformRandomVariable->GetValue (0,1);
518  if (rand < station->m_pdTable[station->m_rateIndex + 1][station->m_powerLevel])
519  {
520  NS_LOG_DEBUG ("Increase Rate");
521  station->m_rateIndex++;
522  }
523  }
524  else if (station->m_powerLevel > m_minPowerLevel)
525  {
526  NS_LOG_DEBUG ("wploss <= ORI and rate = maxRate => Probabilistic Power Decrease");
527 
528  // Recalculate probabilities of higher powers.
529  for (uint32_t i = m_maxPowerLevel; i > station->m_powerLevel; i--)
530  {
531  station->m_pdTable[station->m_rateIndex][i] *= m_delta;
532  if (station->m_pdTable[station->m_rateIndex][i] > 1)
533  {
534  station->m_pdTable[station->m_rateIndex][i] = 1;
535  }
536  NS_LOG_DEBUG ("pdTable[" << +station->m_rateIndex << "][" << i << "] = " << station->m_pdTable[station->m_rateIndex][i]);
537  }
538  double rand = m_uniformRandomVariable->GetValue (0,1);
539  if (rand < station->m_pdTable[station->m_rateIndex][station->m_powerLevel - 1])
540  {
541  NS_LOG_DEBUG ("Decrease Power");
542  station->m_powerLevel--;
543  }
544  }
545  ResetCountersBasic (station);
546  }
547  else if (bploss > thresholds.m_ori && wploss < thresholds.m_mtl)
548  {
549  if (station->m_powerLevel > m_minPowerLevel)
550  {
551  NS_LOG_DEBUG ("loss between ORI and MTL and power > minPowerLevel => Probabilistic Power Decrease");
552 
553  // Recalculate probabilities of higher powers.
554  for (uint32_t i = m_maxPowerLevel; i >= station->m_powerLevel; i--)
555  {
556  station->m_pdTable[station->m_rateIndex][i] *= m_delta;
557  if (station->m_pdTable[station->m_rateIndex][i] > 1)
558  {
559  station->m_pdTable[station->m_rateIndex][i] = 1;
560  }
561  NS_LOG_DEBUG ("pdTable[" << +station->m_rateIndex << "][" << i << "] = " << station->m_pdTable[station->m_rateIndex][i]);
562  }
563  double rand = m_uniformRandomVariable->GetValue (0,1);
564  if (rand < station->m_pdTable[station->m_rateIndex][station->m_powerLevel - 1])
565  {
566  NS_LOG_DEBUG ("Decrease Power");
567  station->m_powerLevel--;
568  }
569  ResetCountersBasic (station);
570  }
571  }
572  if (station->m_counter == 0)
573  {
574  ResetCountersBasic (station);
575  }
576 }
577 
578 void
580 {
581  NS_LOG_FUNCTION (this << station);
582  if (!station->m_adaptiveRtsOn
583  && station->m_lastFrameFail)
584  {
585  station->m_adaptiveRtsWnd += 2;
586  station->m_rtsCounter = station->m_adaptiveRtsWnd;
587  }
588  else if ((station->m_adaptiveRtsOn && station->m_lastFrameFail)
589  || (!station->m_adaptiveRtsOn && !station->m_lastFrameFail))
590  {
591  station->m_adaptiveRtsWnd = station->m_adaptiveRtsWnd / 2;
592  station->m_rtsCounter = station->m_adaptiveRtsWnd;
593  }
594  if (station->m_rtsCounter > 0)
595  {
596  station->m_adaptiveRtsOn = true;
597  station->m_rtsCounter--;
598  }
599  else
600  {
601  station->m_adaptiveRtsOn = false;
602  }
603 }
604 
607 {
608  NS_LOG_FUNCTION (this << station << +rate);
609  WifiMode mode = GetSupported (station, rate);
610  return GetThresholds (station, mode);
611 }
612 
613 bool
615 {
616  return true;
617 }
618 
619 } // namespace ns3
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
bool GetVhtSupported(void) const
Return whether the device has VHT capability support enabled.
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.
uint8_t GetNSupported(const WifiRemoteStation *station) const
Return the number of modes supported by the given station.
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...
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.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:355
uint8_t m_minPowerLevel
Differently form rate, power levels do not depend on the remote station.
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
WifiRrpaaThresholds GetThresholds(RrpaaWifiRemoteStation *station, WifiMode mode) const
Get the thresholds for the given station and mode.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:204
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1070
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.
WifiPreamble GetPreambleForTransmission(WifiModulationClass modulation, bool useShortPreamble, bool useGreenfield)
Return the preamble to be used for the transmission.
Definition: wifi-utils.cc:128
virtual bool IsLowLatency(void) const
WifiMode GetSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether mode associated with the specified station at the specified index. ...
uint32_t m_counter
Counter for transmission attempts.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:97
RrpaaThresholdsTable m_thresholds
Rrpaa thresholds for this station.
uint8_t m_rateIndex
Current rate index.
WifiRemoteStationState * m_state
Remote station state.
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.
phy
Definition: third.py:93
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.
bool GetShortPreambleEnabled(void) const
Return whether the device uses short PLCP preambles.
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.
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:1124
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
bool GetHtSupported(void) const
Return whether the device has HT capability support enabled.
mac
Definition: third.py:99
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.
double m_mtl
The Maximum Tolerable Loss threshold.
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:494
double m_delta
Delta value for RRPAA (value for pdTable increments).
double GetPowerDbm(uint8_t power) const
Get the power of the given power level in dBm.
Definition: wifi-phy.cc:794
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.
Time GetCalcTxTime(WifiMode mode) const
Get the estimated TxTime of a packet with a given mode.
bool UseGreenfieldForDestination(Mac48Address dest) const
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
Mac48Address GetAddress(const WifiRemoteStation *station) const
Return the address of the station.
WifiMode GetNonErpSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether non-ERP mode associated with the specified station at the specified index...
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:1125
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:193
bool GetAggregation(const WifiRemoteStation *station) const
Return whether the given station supports A-MPDU.
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.
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.
Ptr< WifiPhy > GetPhy(void) const
Return the WifiPhy.
virtual WifiRemoteStation * DoCreateStation(void) const
virtual WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station)
bool GetUseNonErpProtection(void) const
Return whether the device supports protection of non-ERP stations.
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:272
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1062
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.
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)
uint8_t m_nRate
Number of supported rates.
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
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:915
hold per-remote-station state.
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:150
void CheckTimeout(RrpaaWifiRemoteStation *station)
Check if the counter should be reset.
double m_gamma
Gamma value for RRPAA (value for pdTable decrements).
void DoInitialize(void)
Initialize() implementation.
uint16_t GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the station.
std::vector< std::vector< double > > RrpaaProbabilitiesTable
List of probabilities.