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