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  WifiTxVector rtsTxVector;
428  WifiMode mode;
429  if (GetUseNonErpProtection () == false)
430  {
431  mode = GetSupported (station, 0);
432  }
433  else
434  {
435  mode = GetNonErpSupported (station, 0);
436  }
437  rtsTxVector = WifiTxVector (mode, GetDefaultTxPowerLevel (), GetPreambleForTransmission (mode.GetModulationClass (), GetShortPreambleEnabled ()), 800, 1, 1, 0, channelWidth, GetAggregation (station));
438  return rtsTxVector;
439 }
440 
441 bool
443  uint32_t size, bool normally)
444 {
445  NS_LOG_FUNCTION (this << st << size << normally);
446  RrpaaWifiRemoteStation *station = static_cast<RrpaaWifiRemoteStation*> (st);
447  CheckInit (station);
448  if (m_basic)
449  {
450  return normally;
451  }
452  RunAdaptiveRtsAlgorithm (station);
453  return station->m_adaptiveRtsOn;
454 }
455 
456 void
458 {
459  NS_LOG_FUNCTION (this << station);
460  Time d = Simulator::Now () - station->m_lastReset;
461  if (station->m_counter == 0 || d > m_timeout)
462  {
463  ResetCountersBasic (station);
464  }
465 }
466 
467 void
469 {
470  NS_LOG_FUNCTION (this << station);
471  WifiRrpaaThresholds thresholds = GetThresholds (station, station->m_rateIndex);
472  double bploss = (static_cast<double> (station->m_nFailed) / thresholds.m_ewnd);
473  double wploss = (static_cast<double> (station->m_counter + station->m_nFailed) / thresholds.m_ewnd);
474  NS_LOG_DEBUG ("Best loss prob= " << bploss);
475  NS_LOG_DEBUG ("Worst loss prob= " << wploss);
476  if (bploss >= thresholds.m_mtl)
477  {
478  if (station->m_powerLevel < m_maxPowerLevel)
479  {
480  NS_LOG_DEBUG ("bploss >= MTL and power < maxPower => Increase Power");
481  station->m_pdTable[station->m_rateIndex][station->m_powerLevel] /= m_gamma;
482  NS_LOG_DEBUG ("pdTable[" << +station->m_rateIndex << "][" << station->m_powerLevel << "] = " << station->m_pdTable[station->m_rateIndex][station->m_powerLevel]);
483  station->m_powerLevel++;
484  ResetCountersBasic (station);
485  }
486  else if (station->m_rateIndex != 0)
487  {
488  NS_LOG_DEBUG ("bploss >= MTL and power = maxPower => Decrease Rate");
489  station->m_pdTable[station->m_rateIndex][station->m_powerLevel] /= m_gamma;
490  NS_LOG_DEBUG ("pdTable[" << +station->m_rateIndex << "][" << station->m_powerLevel << "] = " << station->m_pdTable[station->m_rateIndex][station->m_powerLevel]);
491  station->m_rateIndex--;
492  ResetCountersBasic (station);
493  }
494  else
495  {
496  NS_LOG_DEBUG ("bploss >= MTL but already at maxPower and minRate");
497  }
498  }
499  else if (wploss <= thresholds.m_ori)
500  {
501  if (station->m_rateIndex < station->m_nRate - 1)
502  {
503  NS_LOG_DEBUG ("wploss <= ORI and rate < maxRate => Probabilistic Rate Increase");
504 
505  // Recalculate probabilities of lower rates.
506  for (uint8_t i = 0; i <= station->m_rateIndex; i++)
507  {
508  station->m_pdTable[i][station->m_powerLevel] *= m_delta;
509  if (station->m_pdTable[i][station->m_powerLevel] > 1)
510  {
511  station->m_pdTable[i][station->m_powerLevel] = 1;
512  }
513  NS_LOG_DEBUG ("pdTable[" << i << "][" << (int)station->m_powerLevel << "] = " << station->m_pdTable[i][station->m_powerLevel]);
514  }
515  double rand = m_uniformRandomVariable->GetValue (0,1);
516  if (rand < station->m_pdTable[station->m_rateIndex + 1][station->m_powerLevel])
517  {
518  NS_LOG_DEBUG ("Increase Rate");
519  station->m_rateIndex++;
520  }
521  }
522  else if (station->m_powerLevel > m_minPowerLevel)
523  {
524  NS_LOG_DEBUG ("wploss <= ORI and rate = maxRate => Probabilistic Power Decrease");
525 
526  // Recalculate probabilities of higher powers.
527  for (uint32_t i = m_maxPowerLevel; i > station->m_powerLevel; i--)
528  {
529  station->m_pdTable[station->m_rateIndex][i] *= m_delta;
530  if (station->m_pdTable[station->m_rateIndex][i] > 1)
531  {
532  station->m_pdTable[station->m_rateIndex][i] = 1;
533  }
534  NS_LOG_DEBUG ("pdTable[" << +station->m_rateIndex << "][" << i << "] = " << station->m_pdTable[station->m_rateIndex][i]);
535  }
536  double rand = m_uniformRandomVariable->GetValue (0,1);
537  if (rand < station->m_pdTable[station->m_rateIndex][station->m_powerLevel - 1])
538  {
539  NS_LOG_DEBUG ("Decrease Power");
540  station->m_powerLevel--;
541  }
542  }
543  ResetCountersBasic (station);
544  }
545  else if (bploss > thresholds.m_ori && wploss < thresholds.m_mtl)
546  {
547  if (station->m_powerLevel > m_minPowerLevel)
548  {
549  NS_LOG_DEBUG ("loss between ORI and MTL and power > minPowerLevel => Probabilistic Power Decrease");
550 
551  // Recalculate probabilities of higher powers.
552  for (uint32_t i = m_maxPowerLevel; i >= station->m_powerLevel; i--)
553  {
554  station->m_pdTable[station->m_rateIndex][i] *= m_delta;
555  if (station->m_pdTable[station->m_rateIndex][i] > 1)
556  {
557  station->m_pdTable[station->m_rateIndex][i] = 1;
558  }
559  NS_LOG_DEBUG ("pdTable[" << +station->m_rateIndex << "][" << i << "] = " << station->m_pdTable[station->m_rateIndex][i]);
560  }
561  double rand = m_uniformRandomVariable->GetValue (0,1);
562  if (rand < station->m_pdTable[station->m_rateIndex][station->m_powerLevel - 1])
563  {
564  NS_LOG_DEBUG ("Decrease Power");
565  station->m_powerLevel--;
566  }
567  ResetCountersBasic (station);
568  }
569  }
570  if (station->m_counter == 0)
571  {
572  ResetCountersBasic (station);
573  }
574 }
575 
576 void
578 {
579  NS_LOG_FUNCTION (this << station);
580  if (!station->m_adaptiveRtsOn
581  && station->m_lastFrameFail)
582  {
583  station->m_adaptiveRtsWnd += 2;
584  station->m_rtsCounter = station->m_adaptiveRtsWnd;
585  }
586  else if ((station->m_adaptiveRtsOn && station->m_lastFrameFail)
587  || (!station->m_adaptiveRtsOn && !station->m_lastFrameFail))
588  {
589  station->m_adaptiveRtsWnd = station->m_adaptiveRtsWnd / 2;
590  station->m_rtsCounter = station->m_adaptiveRtsWnd;
591  }
592  if (station->m_rtsCounter > 0)
593  {
594  station->m_adaptiveRtsOn = true;
595  station->m_rtsCounter--;
596  }
597  else
598  {
599  station->m_adaptiveRtsOn = false;
600  }
601 }
602 
605 {
606  NS_LOG_FUNCTION (this << station << +index);
607  WifiMode mode = GetSupported (station, index);
608  return GetThresholds (station, mode);
609 }
610 
611 } // namespace ns3
Hold per-remote-station state for RRPAA Wifi manager.
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.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
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 DoInitialize(void) override
Initialize() implementation.
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 Opportunistic Rate Increase threshold.
uint32_t m_rtsCounter
Counter for RTS transmission attempts.
uint8_t m_prevRateIndex
Rate index of the previous transmission.
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
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:380
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:205
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1297
void AddCalcTxTime(WifiMode mode, Time t)
Add transmission time for the given mode to an internal list.
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...
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:165
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.
WifiMode GetSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether mode associated with the specified station at the specified index. ...
WifiPreamble GetPreambleForTransmission(WifiModulationClass modulation, bool useShortPreamble)
Return the preamble to be used for the transmission.
Definition: wifi-utils.cc:116
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:47
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
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 PHY 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.
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:1353
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
void DoReportFinalDataFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
WifiRemoteStation * DoCreateStation(void) const override
bool GetHtSupported(void) const
Return whether the device has HT capability support enabled.
mac
Definition: third.py:99
bool DoNeedRts(WifiRemoteStation *st, uint32_t size, bool normally) override
static TypeId GetTypeId(void)
Register this type.
uint32_t m_adaptiveRtsWnd
Window size for the Adaptive RTS mechanism.
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:159
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:840
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.
WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station) override
RrpaaProbabilitiesTable m_pdTable
Probability table for power and rate changes.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void DoReportFinalRtsFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
void SetPreambleType(WifiPreamble preamble)
Sets the preamble type.
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.
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 .
WifiMode GetNonErpSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether non-ERP mode associated with the specified station at the specified index...
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:1354
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
bool GetAggregation(const WifiRemoteStation *station) const
Return whether the given station supports A-MPDU.
void RunBasicAlgorithm(RrpaaWifiRemoteStation *station)
Find an appropriate rate and power for the given station, using a basic algorithm.
WifiTxVector DoGetDataTxVector(WifiRemoteStation *station) override
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
uint32_t m_frameLength
Data frame length used for calculate mode TxTime (in bytes).
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.
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...
uint32_t m_ackLength
Ack frame length used for calculate mode TxTime (in bytes).
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.
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:273
void DoReportDataFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1289
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
TxTime m_calcTxTime
To hold all the calculated TxTime for all modes.
std::vector< std::pair< WifiRrpaaThresholds, WifiMode > > RrpaaThresholdsTable
List of thresholds for each mode.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:533
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model...
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
void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode) override
This method is a pure virtual method that must be implemented by the sub-class.
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:923
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
Definition: data-rate.h:329
hold per-remote-station state.
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:100
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.