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 Time
181 {
182  NS_LOG_FUNCTION (this << mode);
183  for (TxTime::const_iterator i = m_calcTxTime.begin (); i != m_calcTxTime.end (); i++)
184  {
185  if (mode == i->second)
186  {
187  return i->first;
188  }
189  }
190  NS_ASSERT (false);
191  return Seconds (0);
192 }
193 
194 void
196 {
197  NS_LOG_FUNCTION (this << mode << t);
198  m_calcTxTime.push_back (std::make_pair (t, mode));
199 }
200 
203 {
204  NS_LOG_FUNCTION (this << station << mode);
205  struct WifiRrpaaThresholds threshold;
206  for (RrpaaThresholdsTable::const_iterator i = station->m_thresholds.begin (); i != station->m_thresholds.end (); i++)
207  {
208  if (mode == i->second)
209  {
210  return i->first;
211  }
212  }
213  NS_ABORT_MSG ("No thresholds for mode " << mode << " found");
214  return threshold; // Silence compiler warning
215 }
216 
219 {
220  NS_LOG_FUNCTION (this);
222  station->m_adaptiveRtsWnd = 0;
223  station->m_rtsCounter = 0;
224  station->m_adaptiveRtsOn = false;
225  station->m_lastFrameFail = false;
226  station->m_initialized = false;
227  return station;
228 }
229 
230 void
232 {
233  NS_LOG_FUNCTION (this << station);
234  if (!station->m_initialized)
235  {
236  //Note: we appear to be doing late initialization of the table
237  //to make sure that the set of supported rates has been initialized
238  //before we perform our own initialization.
239  station->m_nRate = GetNSupported (station);
240  //Initialize at minimal rate and maximal power.
241  station->m_prevRateIndex = 0;
242  station->m_rateIndex = 0;
244  station->m_powerLevel = m_maxPowerLevel;
245  WifiMode mode = GetSupported (station, 0);
246  uint16_t channelWidth = GetChannelWidth (station);
247  DataRate rate = DataRate (mode.GetDataRate (channelWidth));
248  double power = GetPhy ()->GetPowerDbm (station->m_powerLevel);
249  m_rateChange (rate, rate, station->m_state->m_address);
250  m_powerChange (power, power, station->m_state->m_address);
251 
252  station->m_pdTable = RrpaaProbabilitiesTable (station->m_nRate, std::vector<double> (m_nPowerLevels));
253  NS_LOG_DEBUG ("Initializing pdTable");
254  for (uint8_t i = 0; i < station->m_nRate; i++)
255  {
256  for (uint8_t j = 0; j < m_nPowerLevels; j++)
257  {
258  station->m_pdTable[i][j] = 1;
259  }
260  }
261 
262  station->m_initialized = true;
263 
264  station->m_thresholds = RrpaaThresholdsTable (station->m_nRate);
265  InitThresholds (station);
266  ResetCountersBasic (station);
267  }
268 }
269 
270 void
272 {
273  NS_LOG_FUNCTION (this << station);
274  double nextCritical = 0;
275  double nextMtl = 0;
276  double mtl = 0;
277  double ori = 0;
278  for (uint8_t i = 0; i < station->m_nRate; i++)
279  {
280  WifiMode mode = GetSupported (station, i);
281  Time totalTxTime = GetCalcTxTime (mode) + m_sifs + m_difs;
282  if (i == station->m_nRate - 1)
283  {
284  ori = 0;
285  }
286  else
287  {
288  WifiMode nextMode = GetSupported (station, i + 1);
289  Time nextTotalTxTime = GetCalcTxTime (nextMode) + m_sifs + m_difs;
290  nextCritical = 1 - (nextTotalTxTime.GetSeconds () / totalTxTime.GetSeconds ());
291  nextMtl = m_alpha * nextCritical;
292  ori = nextMtl / m_beta;
293  }
294  if (i == 0)
295  {
296  mtl = nextMtl;
297  }
299  th.m_ewnd = static_cast<uint32_t> (ceil (m_tau / totalTxTime.GetSeconds ()));
300  th.m_ori = ori;
301  th.m_mtl = mtl;
302  station->m_thresholds.push_back (std::make_pair (th, mode));
303  mtl = nextMtl;
304  NS_LOG_DEBUG (mode << " " << th.m_ewnd << " " << th.m_mtl << " " << th.m_ori);
305  }
306 }
307 
308 void
310 {
311  NS_LOG_FUNCTION (this << station);
312  station->m_nFailed = 0;
313  station->m_counter = GetThresholds (station, station->m_rateIndex).m_ewnd;
314  station->m_lastReset = Simulator::Now ();
315 }
316 
317 void
319 {
320  NS_LOG_FUNCTION (this << st);
321 }
322 
323 void
325 {
326  NS_LOG_FUNCTION (this << st);
328  CheckInit (station);
329  station->m_lastFrameFail = true;
330  CheckTimeout (station);
331  station->m_counter--;
332  station->m_nFailed++;
333  RunBasicAlgorithm (station);
334 }
335 
336 void
338  double rxSnr, WifiMode txMode)
339 {
340  NS_LOG_FUNCTION (this << st << rxSnr << txMode);
341 }
342 
343 void
345  double ctsSnr, WifiMode ctsMode, double rtsSnr)
346 {
347  NS_LOG_FUNCTION (this << st << ctsSnr << ctsMode << rtsSnr);
348 }
349 
350 void
352  double ackSnr, WifiMode ackMode, double dataSnr)
353 {
354  NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr);
356  CheckInit (station);
357  station->m_lastFrameFail = false;
358  CheckTimeout (station);
359  station->m_counter--;
360  RunBasicAlgorithm (station);
361 }
362 void
364 {
365  NS_LOG_FUNCTION (this << st);
366 }
367 void
369 {
370  NS_LOG_FUNCTION (this << st);
371 }
372 
375 {
376  NS_LOG_FUNCTION (this << st);
378  uint16_t channelWidth = GetChannelWidth (station);
379  if (channelWidth > 20 && channelWidth != 22)
380  {
381  //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac
382  channelWidth = 20;
383  }
384  CheckInit (station);
385  WifiMode mode = GetSupported (station, station->m_rateIndex);
386  DataRate rate = DataRate (mode.GetDataRate (channelWidth));
387  DataRate prevRate = DataRate (GetSupported (station, station->m_prevRateIndex).GetDataRate (channelWidth));
388  double power = GetPhy ()->GetPowerDbm (station->m_powerLevel);
389  double prevPower = GetPhy ()->GetPowerDbm (station->m_prevPowerLevel);
390  if (station->m_prevRateIndex != station->m_rateIndex)
391  {
392  m_rateChange (prevRate, rate, station->m_state->m_address);
393  station->m_prevRateIndex = station->m_rateIndex;
394  }
395  if (station->m_prevPowerLevel != station->m_powerLevel)
396  {
397  m_powerChange (prevPower, power, station->m_state->m_address);
398  station->m_prevPowerLevel = station->m_powerLevel;
399  }
400  return WifiTxVector (mode, station->m_powerLevel, GetPreambleForTransmission (mode, GetAddress (station)), 800, 1, 1, 0, channelWidth, GetAggregation (station), false);
401 }
404 {
405  NS_LOG_FUNCTION (this << st);
407  uint16_t channelWidth = GetChannelWidth (station);
408  if (channelWidth > 20 && channelWidth != 22)
409  {
410  //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac
411  channelWidth = 20;
412  }
413  WifiTxVector rtsTxVector;
414  WifiMode mode;
415  if (GetUseNonErpProtection () == false)
416  {
417  mode = GetSupported (station, 0);
418  }
419  else
420  {
421  mode = GetNonErpSupported (station, 0);
422  }
423  rtsTxVector = WifiTxVector (mode, GetDefaultTxPowerLevel (), GetPreambleForTransmission (mode, GetAddress (st)), 800, 1, 1, 0, channelWidth, GetAggregation (station), false);
424  return rtsTxVector;
425 }
426 
427 bool
429  Ptr<const Packet> packet, bool normally)
430 {
431  NS_LOG_FUNCTION (this << st << packet << normally);
433  CheckInit (station);
434  if (m_basic)
435  {
436  return normally;
437  }
438  RunAdaptiveRtsAlgorithm (station);
439  return station->m_adaptiveRtsOn;
440 }
441 
442 void
444 {
445  NS_LOG_FUNCTION (this << station);
446  Time d = Simulator::Now () - station->m_lastReset;
447  if (station->m_counter == 0 || d > m_timeout)
448  {
449  ResetCountersBasic (station);
450  }
451 }
452 
453 void
455 {
456  NS_LOG_FUNCTION (this << station);
457  WifiRrpaaThresholds thresholds = GetThresholds (station, station->m_rateIndex);
458  double bploss = (static_cast<double> (station->m_nFailed) / thresholds.m_ewnd);
459  double wploss = (static_cast<double> (station->m_counter + station->m_nFailed) / thresholds.m_ewnd);
460  NS_LOG_DEBUG ("Best loss prob= " << bploss);
461  NS_LOG_DEBUG ("Worst loss prob= " << wploss);
462  if (bploss >= thresholds.m_mtl)
463  {
464  if (station->m_powerLevel < m_maxPowerLevel)
465  {
466  NS_LOG_DEBUG ("bploss >= MTL and power < maxPower => Increase Power");
467  station->m_pdTable[station->m_rateIndex][station->m_powerLevel] /= m_gamma;
468  NS_LOG_DEBUG ("pdTable[" << +station->m_rateIndex << "][" << station->m_powerLevel << "] = " << station->m_pdTable[station->m_rateIndex][station->m_powerLevel]);
469  station->m_powerLevel++;
470  ResetCountersBasic (station);
471  }
472  else if (station->m_rateIndex != 0)
473  {
474  NS_LOG_DEBUG ("bploss >= MTL and power = maxPower => Decrease Rate");
475  station->m_pdTable[station->m_rateIndex][station->m_powerLevel] /= m_gamma;
476  NS_LOG_DEBUG ("pdTable[" << +station->m_rateIndex << "][" << station->m_powerLevel << "] = " << station->m_pdTable[station->m_rateIndex][station->m_powerLevel]);
477  station->m_rateIndex--;
478  ResetCountersBasic (station);
479  }
480  else
481  {
482  NS_LOG_DEBUG ("bploss >= MTL but already at maxPower and minRate");
483  }
484  }
485  else if (wploss <= thresholds.m_ori)
486  {
487  if (station->m_rateIndex < station->m_nRate - 1)
488  {
489  NS_LOG_DEBUG ("wploss <= ORI and rate < maxRate => Probabilistic Rate Increase");
490 
491  // Recalculate probabilities of lower rates.
492  for (uint8_t i = 0; i <= station->m_rateIndex; i++)
493  {
494  station->m_pdTable[i][station->m_powerLevel] *= m_delta;
495  if (station->m_pdTable[i][station->m_powerLevel] > 1)
496  {
497  station->m_pdTable[i][station->m_powerLevel] = 1;
498  }
499  NS_LOG_DEBUG ("pdTable[" << i << "][" << (int)station->m_powerLevel << "] = " << station->m_pdTable[i][station->m_powerLevel]);
500  }
501  double rand = m_uniformRandomVariable->GetValue (0,1);
502  if (rand < station->m_pdTable[station->m_rateIndex + 1][station->m_powerLevel])
503  {
504  NS_LOG_DEBUG ("Increase Rate");
505  station->m_rateIndex++;
506  }
507  }
508  else if (station->m_powerLevel > m_minPowerLevel)
509  {
510  NS_LOG_DEBUG ("wploss <= ORI and rate = maxRate => Probabilistic Power Decrease");
511 
512  // Recalculate probabilities of higher powers.
513  for (uint32_t i = m_maxPowerLevel; i > station->m_powerLevel; i--)
514  {
515  station->m_pdTable[station->m_rateIndex][i] *= m_delta;
516  if (station->m_pdTable[station->m_rateIndex][i] > 1)
517  {
518  station->m_pdTable[station->m_rateIndex][i] = 1;
519  }
520  NS_LOG_DEBUG ("pdTable[" << +station->m_rateIndex << "][" << i << "] = " << station->m_pdTable[station->m_rateIndex][i]);
521  }
522  double rand = m_uniformRandomVariable->GetValue (0,1);
523  if (rand < station->m_pdTable[station->m_rateIndex][station->m_powerLevel - 1])
524  {
525  NS_LOG_DEBUG ("Decrease Power");
526  station->m_powerLevel--;
527  }
528  }
529  ResetCountersBasic (station);
530  }
531  else if (bploss > thresholds.m_ori && wploss < thresholds.m_mtl)
532  {
533  if (station->m_powerLevel > m_minPowerLevel)
534  {
535  NS_LOG_DEBUG ("loss between ORI and MTL and power > minPowerLevel => Probabilistic Power Decrease");
536 
537  // Recalculate probabilities of higher powers.
538  for (uint32_t i = m_maxPowerLevel; i >= station->m_powerLevel; i--)
539  {
540  station->m_pdTable[station->m_rateIndex][i] *= m_delta;
541  if (station->m_pdTable[station->m_rateIndex][i] > 1)
542  {
543  station->m_pdTable[station->m_rateIndex][i] = 1;
544  }
545  NS_LOG_DEBUG ("pdTable[" << +station->m_rateIndex << "][" << i << "] = " << station->m_pdTable[station->m_rateIndex][i]);
546  }
547  double rand = m_uniformRandomVariable->GetValue (0,1);
548  if (rand < station->m_pdTable[station->m_rateIndex][station->m_powerLevel - 1])
549  {
550  NS_LOG_DEBUG ("Decrease Power");
551  station->m_powerLevel--;
552  }
553  ResetCountersBasic (station);
554  }
555  }
556  if (station->m_counter == 0)
557  {
558  ResetCountersBasic (station);
559  }
560 }
561 
562 void
564 {
565  NS_LOG_FUNCTION (this << station);
566  if (!station->m_adaptiveRtsOn
567  && station->m_lastFrameFail)
568  {
569  station->m_adaptiveRtsWnd += 2;
570  station->m_rtsCounter = station->m_adaptiveRtsWnd;
571  }
572  else if ((station->m_adaptiveRtsOn && station->m_lastFrameFail)
573  || (!station->m_adaptiveRtsOn && !station->m_lastFrameFail))
574  {
575  station->m_adaptiveRtsWnd = station->m_adaptiveRtsWnd / 2;
576  station->m_rtsCounter = station->m_adaptiveRtsWnd;
577  }
578  if (station->m_rtsCounter > 0)
579  {
580  station->m_adaptiveRtsOn = true;
581  station->m_rtsCounter--;
582  }
583  else
584  {
585  station->m_adaptiveRtsOn = false;
586  }
587 }
588 
591 {
592  NS_LOG_FUNCTION (this << station << +rate);
593  WifiMode mode = GetSupported (station, rate);
594  return GetThresholds (station, mode);
595 }
596 
597 bool
599 {
600  return true;
601 }
602 
603 void
605 {
606  //HT is not supported by this algorithm.
607  if (enable)
608  {
609  NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HT rates");
610  }
611 }
612 
613 void
615 {
616  //VHT is not supported by this algorithm.
617  if (enable)
618  {
619  NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support VHT rates");
620  }
621 }
622 
623 void
625 {
626  //HE is not supported by this algorithm.
627  if (enable)
628  {
629  NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HE rates");
630  }
631 }
632 
633 } // 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
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.
#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:202
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1022
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.
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:86
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.
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:1076
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.
mac
Definition: third.py:92
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 SetHtSupported(bool enable)
Enable or disable HT capability support.
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).
double GetPowerDbm(uint8_t power) const
Get the power of the given power level in dBm.
Definition: wifi-phy.cc:700
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.
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:1077
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:249
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:270
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1014
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)
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 &#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:156
void CheckTimeout(RrpaaWifiRemoteStation *station)
Check if the counter should be reset.
double m_gamma
Gamma value for RRPAA (value for pdTable decrements).
uint16_t GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the station.
std::vector< std::vector< double > > RrpaaProbabilitiesTable
List of probabilities.