View | Details | Raw Unified | Return to bug 2654
Collapse All | Expand All

(-)a/src/wifi/model/rraa-wifi-manager.cc (-248 / +213 lines)
 Lines 19-24    Link Here 
19
 */
19
 */
20
20
21
#include "rraa-wifi-manager.h"
21
#include "rraa-wifi-manager.h"
22
#include "yans-wifi-phy.h"
23
#include "wifi-phy.h"
24
#include "wifi-mac.h"
22
#include "ns3/log.h"
25
#include "ns3/log.h"
23
#include "ns3/boolean.h"
26
#include "ns3/boolean.h"
24
#include "ns3/double.h"
27
#include "ns3/double.h"
 Lines 39-54   NS_LOG_COMPONENT_DEFINE ("RraaWifiManager"); Link Here 
39
 */
42
 */
40
struct RraaWifiRemoteStation : public WifiRemoteStation
43
struct RraaWifiRemoteStation : public WifiRemoteStation
41
{
44
{
42
  uint32_t m_counter;
45
  uint32_t m_counter;            //!< Counter for transmission attempts.
43
  uint32_t m_failed;
46
  uint32_t m_nFailed;            //!< Number of failed transmission attempts.
44
  uint32_t m_rtsWnd;
47
  uint32_t m_adaptiveRtsWnd;     //!< Window size for the Adaptive RTS mechanism.
45
  uint32_t m_rtsCounter;
48
  uint32_t m_rtsCounter;         //!< Counter for RTS transmission attempts.
46
  Time m_lastReset;
49
  Time m_lastReset;              //!< Time of the last reset.
47
  bool m_rtsOn;
50
  bool m_adaptiveRtsOn;          //!< Check if Adaptive RTS mechanism is on.
48
  bool m_lastFrameFail;
51
  bool m_lastFrameFail;          //!< Flag if the last frame sent has failed.
49
  bool m_initialized;
52
  bool m_initialized;            //!< For initializing variables.
50
53
51
  uint32_t m_rate;
54
  uint32_t m_nRate;              //!< Number of supported rates.
55
56
  uint32_t m_rateIndex;          //!< Current rate index.
57
58
  RraaThresholdsTable m_thresholds; //!< RRAA thresholds for this station.
52
};
59
};
53
60
54
NS_OBJECT_ENSURE_REGISTERED (RraaWifiManager);
61
NS_OBJECT_ENSURE_REGISTERED (RraaWifiManager);
 Lines 66-185   RraaWifiManager::GetTypeId (void) Link Here 
66
                   MakeBooleanAccessor (&RraaWifiManager::m_basic),
73
                   MakeBooleanAccessor (&RraaWifiManager::m_basic),
67
                   MakeBooleanChecker ())
74
                   MakeBooleanChecker ())
68
    .AddAttribute ("Timeout",
75
    .AddAttribute ("Timeout",
69
                   "Timeout for the RRAA BASIC loss estimaton block (s)",
76
                   "Timeout for the RRAA BASIC loss estimation block (s)",
70
                   TimeValue (Seconds (0.05)),
77
                   TimeValue (Seconds (0.05)),
71
                   MakeTimeAccessor (&RraaWifiManager::m_timeout),
78
                   MakeTimeAccessor (&RraaWifiManager::m_timeout),
72
                   MakeTimeChecker ())
79
                   MakeTimeChecker ())
73
    .AddAttribute ("ewndFor54mbps",
80
    .AddAttribute ("FrameLength",
74
                   "ewnd parameter for 54 Mbs data mode",
81
		   "The data frame length (in bytes) used for calculating mode TxTime.",
75
                   UintegerValue (40),
82
		   UintegerValue (1420),
76
                   MakeUintegerAccessor (&RraaWifiManager::m_ewndfor54),
83
		   MakeUintegerAccessor (&RraaWifiManager::m_frameLength),
77
                   MakeUintegerChecker<uint32_t> ())
84
		   MakeUintegerChecker <uint32_t> ())
78
    .AddAttribute ("ewndFor48mbps",
85
    .AddAttribute ("AckFrameLength",
79
                   "ewnd parameter for 48 Mbs data mode",
86
		   "The ACK frame length (in bytes) used for calculating mode TxTime.",
80
                   UintegerValue (40),
87
		   UintegerValue (14),
81
                   MakeUintegerAccessor (&RraaWifiManager::m_ewndfor48),
88
		   MakeUintegerAccessor (&RraaWifiManager::m_ackLength),
82
                   MakeUintegerChecker<uint32_t> ())
89
		   MakeUintegerChecker <uint32_t> ())
83
    .AddAttribute ("ewndFor36mbps",
90
    .AddAttribute ("Alpha",
84
                   "ewnd parameter for 36 Mbs data mode",
91
		   "Constant for calculating the MTL threshold.",
85
                   UintegerValue (40),
92
		   DoubleValue (1.25),
86
                   MakeUintegerAccessor (&RraaWifiManager::m_ewndfor36),
93
		   MakeDoubleAccessor (&RraaWifiManager::m_alpha),
87
                   MakeUintegerChecker<uint32_t> ())
94
		   MakeDoubleChecker<double> (1))
88
    .AddAttribute ("ewndFor24mbps",
95
    .AddAttribute ("Beta",
89
                   "ewnd parameter for 24 Mbs data mode",
96
		   "Constant for calculating the ORI threshold.",
90
                   UintegerValue (40),
97
		   DoubleValue (2),
91
                   MakeUintegerAccessor (&RraaWifiManager::m_ewndfor24),
98
		   MakeDoubleAccessor (&RraaWifiManager::m_beta),
92
                   MakeUintegerChecker<uint32_t> ())
99
		   MakeDoubleChecker<double> (1))
93
    .AddAttribute ("ewndFor18mbps",
100
    .AddAttribute ("Tau",
94
                   "ewnd parameter for 18 Mbs data mode",
101
		   "Constant for calculating the EWND size.",
95
                   UintegerValue (20),
102
		   DoubleValue (0.012),
96
                   MakeUintegerAccessor (&RraaWifiManager::m_ewndfor18),
103
		   MakeDoubleAccessor (&RraaWifiManager::m_tau),
97
                   MakeUintegerChecker<uint32_t> ())
104
		   MakeDoubleChecker<double> (0))
98
    .AddAttribute ("ewndFor12mbps",
99
                   "ewnd parameter for 12 Mbs data mode",
100
                   UintegerValue (20),
101
                   MakeUintegerAccessor (&RraaWifiManager::m_ewndfor12),
102
                   MakeUintegerChecker<uint32_t> ())
103
    .AddAttribute ("ewndFor9mbps",
104
                   "ewnd parameter for 9 Mbs data mode",
105
                   UintegerValue (10),
106
                   MakeUintegerAccessor (&RraaWifiManager::m_ewndfor9),
107
                   MakeUintegerChecker<uint32_t> ())
108
    .AddAttribute ("ewndFor6mbps",
109
                   "ewnd parameter for 6 Mbs data mode",
110
                   UintegerValue (6),
111
                   MakeUintegerAccessor (&RraaWifiManager::m_ewndfor6),
112
                   MakeUintegerChecker<uint32_t> ())
113
    .AddAttribute ("poriFor48mbps",
114
                   "Pori parameter for 48 Mbs data mode",
115
                   DoubleValue (0.047),
116
                   MakeDoubleAccessor (&RraaWifiManager::m_porifor48),
117
                   MakeDoubleChecker<double> ())
118
    .AddAttribute ("poriFor36mbps",
119
                   "Pori parameter for 36 Mbs data mode",
120
                   DoubleValue (0.115),
121
                   MakeDoubleAccessor (&RraaWifiManager::m_porifor36),
122
                   MakeDoubleChecker<double> ())
123
    .AddAttribute ("poriFor24mbps",
124
                   "Pori parameter for 24 Mbs data mode",
125
                   DoubleValue (0.1681),
126
                   MakeDoubleAccessor (&RraaWifiManager::m_porifor24),
127
                   MakeDoubleChecker<double> ())
128
    .AddAttribute ("poriFor18mbps",
129
                   "Pori parameter for 18 Mbs data mode",
130
                   DoubleValue (0.1325),
131
                   MakeDoubleAccessor (&RraaWifiManager::m_porifor18),
132
                   MakeDoubleChecker<double> ())
133
    .AddAttribute ("poriFor12mbps",
134
                   "Pori parameter for 12 Mbs data mode",
135
                   DoubleValue (0.1861),
136
                   MakeDoubleAccessor (&RraaWifiManager::m_porifor12),
137
                   MakeDoubleChecker<double> ())
138
    .AddAttribute ("poriFor9mbps",
139
                   "Pori parameter for 9 Mbs data mode",
140
                   DoubleValue (0.1434),
141
                   MakeDoubleAccessor (&RraaWifiManager::m_porifor9),
142
                   MakeDoubleChecker<double> ())
143
    .AddAttribute ("poriFor6mbps",
144
                   "Pori parameter for 6 Mbs data mode",
145
                   DoubleValue (0.5),
146
                   MakeDoubleAccessor (&RraaWifiManager::m_porifor6),
147
                   MakeDoubleChecker<double> ())
148
    .AddAttribute ("pmtlFor54mbps",
149
                   "Pmtl parameter for 54 Mbs data mode",
150
                   DoubleValue (0.094),
151
                   MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor54),
152
                   MakeDoubleChecker<double> ())
153
    .AddAttribute ("pmtlFor48mbps",
154
                   "Pmtl parameter for 48 Mbs data mode",
155
                   DoubleValue (0.23),
156
                   MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor48),
157
                   MakeDoubleChecker<double> ())
158
    .AddAttribute ("pmtlFor36mbps",
159
                   "Pmtl parameter for 36 Mbs data mode",
160
                   DoubleValue (0.3363),
161
                   MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor36),
162
                   MakeDoubleChecker<double> ())
163
    .AddAttribute ("pmtlFor24mbps",
164
                   "Pmtl parameter for 24 Mbs data mode",
165
                   DoubleValue (0.265),
166
                   MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor24),
167
                   MakeDoubleChecker<double> ())
168
    .AddAttribute ("pmtlFor18mbps",
169
                   "Pmtl parameter for 18 Mbs data mode",
170
                   DoubleValue (0.3722),
171
                   MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor18),
172
                   MakeDoubleChecker<double> ())
173
    .AddAttribute ("pmtlFor12mbps",
174
                   "Pmtl parameter for 12 Mbs data mode",
175
                   DoubleValue (0.2868),
176
                   MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor12),
177
                   MakeDoubleChecker<double> ())
178
    .AddAttribute ("pmtlFor9mbps",
179
                   "Pmtl parameter for 9 Mbs data mode",
180
                   DoubleValue (0.3932),
181
                   MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor9),
182
                   MakeDoubleChecker<double> ())
183
  ;
105
  ;
184
  return tid;
106
  return tid;
185
}
107
}
 Lines 193-227   RraaWifiManager::~RraaWifiManager () Link Here 
193
{
115
{
194
}
116
}
195
117
118
void
119
RraaWifiManager::SetupPhy (Ptr<WifiPhy> phy)
120
{
121
  NS_LOG_FUNCTION (this);
122
  uint32_t nModes = phy->GetNModes ();
123
  for (uint32_t i = 0; i < nModes; i++)
124
    {
125
      WifiMode mode = phy->GetMode (i);
126
      WifiTxVector txVector;
127
      txVector.SetMode (mode);
128
      txVector.SetPreambleType (WIFI_PREAMBLE_LONG);
129
      /* Calculate the TX Time of the data and the corresponding ACK*/
130
      Time dataTxTime = phy->CalculateTxDuration (m_frameLength, txVector, phy->GetFrequency ());
131
      Time ackTxTime = phy->CalculateTxDuration (m_ackLength, txVector, phy->GetFrequency ());
132
      NS_LOG_DEBUG ("Calculating TX times: Mode= " << mode << " DataTxTime= " << dataTxTime << " AckTxTime= " << ackTxTime);
133
      AddCalcTxTime (mode, dataTxTime + ackTxTime);
134
    }
135
  WifiRemoteStationManager::SetupPhy (phy);
136
}
137
138
void
139
RraaWifiManager::SetupMac (Ptr<WifiMac> mac)
140
{
141
  NS_LOG_FUNCTION (this);
142
  m_sifs = mac->GetSifs ();
143
  m_difs = m_sifs + 2 * mac->GetSlot ();
144
  WifiRemoteStationManager::SetupMac (mac);
145
}
146
147
Time
148
RraaWifiManager::GetCalcTxTime (WifiMode mode) const
149
{
150
  NS_LOG_FUNCTION (this << mode);
151
  for (TxTime::const_iterator i = m_calcTxTime.begin (); i != m_calcTxTime.end (); i++)
152
    {
153
      if (mode == i->second)
154
        {
155
          return i->first;
156
        }
157
    }
158
  NS_ASSERT (false);
159
  return Seconds (0);
160
}
161
162
void
163
RraaWifiManager::AddCalcTxTime (WifiMode mode, Time t)
164
{
165
  NS_LOG_FUNCTION (this << mode << t);
166
  m_calcTxTime.push_back (std::make_pair (t, mode));
167
}
168
169
Thresholds
170
RraaWifiManager::GetThresholds (RraaWifiRemoteStation *station, WifiMode mode) const
171
{
172
  NS_LOG_FUNCTION (this << station << mode);
173
  for (RraaThresholdsTable::const_iterator i = station->m_thresholds.begin (); i != station->m_thresholds.end (); i++)
174
    {
175
      if (mode == i->second)
176
        {
177
          return i->first;
178
        }
179
    }
180
  NS_ASSERT (false);
181
}
182
196
WifiRemoteStation *
183
WifiRemoteStation *
197
RraaWifiManager::DoCreateStation (void) const
184
RraaWifiManager::DoCreateStation (void) const
198
{
185
{
199
  RraaWifiRemoteStation *station = new RraaWifiRemoteStation ();
186
  RraaWifiRemoteStation *station = new RraaWifiRemoteStation ();
200
  station->m_initialized = false;
187
  station->m_initialized = false;
201
  station->m_rtsWnd = 0;
188
  station->m_adaptiveRtsWnd = 0;
202
  station->m_rtsCounter = 0;
189
  station->m_rtsCounter = 0;
203
  station->m_rtsOn = false;
190
  station->m_adaptiveRtsOn = false;
204
  station->m_lastFrameFail = false;
191
  station->m_lastFrameFail = false;
205
  return station;
192
  return station;
206
}
193
}
207
194
208
void
195
void
209
RraaWifiManager::ResetCountersBasic (RraaWifiRemoteStation *station)
196
RraaWifiManager::CheckInit (RraaWifiRemoteStation *station)
210
{
197
{
198
  NS_LOG_FUNCTION (this << station);
211
  if (!station->m_initialized)
199
  if (!station->m_initialized)
212
    {
200
    {
213
      station->m_rate = GetMaxRate (station);
201
      //Note: we appear to be doing late initialization of the table
202
      //to make sure that the set of supported rates has been initialized
203
      //before we perform our own initialization.
204
      station->m_nRate = GetNSupported (station);
205
      //Initialize at maximal rate
206
      station->m_rateIndex = GetMaxRate(station);
207
214
      station->m_initialized = true;
208
      station->m_initialized = true;
209
210
      station->m_thresholds = RraaThresholdsTable (station->m_nRate);
211
      InitThresholds (station);
212
      ResetCountersBasic (station);
213
    }
214
}
215
216
void
217
RraaWifiManager::InitThresholds (RraaWifiRemoteStation *station)
218
{
219
  NS_LOG_FUNCTION (this << station);
220
  NS_LOG_DEBUG ("InitThresholds = " << station);
221
222
  double nextCritical = 0;
223
  double nextMtl = 0;
224
  double mtl = 0;
225
  double ori = 0;
226
  for (uint32_t i = 0; i < station->m_nRate; i++)
227
    {
228
      WifiMode mode = GetSupported (station, i);
229
      Time totalTxTime = GetCalcTxTime (mode) + m_sifs + m_difs;
230
      if (i == GetMaxRate (station))
231
        {
232
          ori = 0;
233
        }
234
      else
235
        {
236
          WifiMode nextMode = GetSupported (station, i + 1);
237
          Time nextTotalTxTime = GetCalcTxTime (nextMode) + m_sifs + m_difs;
238
          nextCritical = 1 - (nextTotalTxTime.GetSeconds () / totalTxTime.GetSeconds ());
239
          nextMtl = m_alpha * nextCritical;
240
          ori = nextMtl / m_beta;
241
        }
242
      if (i == GetMinRate (station))
243
        {
244
          mtl = 1;
245
        }
246
      Thresholds th;
247
      th.m_ewnd = ceil (m_tau / totalTxTime.GetSeconds ());
248
      th.m_ori = ori;
249
      th.m_mtl = mtl;
250
      station->m_thresholds.push_back (std::make_pair (th, mode));
251
      mtl = nextMtl;
252
      NS_LOG_DEBUG (mode << " " << th.m_ewnd << " " << th.m_mtl << " " << th.m_ori);
215
    }
253
    }
216
  station->m_failed = 0;
254
}
217
  station->m_counter = GetThresholds (station, station->m_rate).ewnd;
255
256
void
257
RraaWifiManager::ResetCountersBasic (RraaWifiRemoteStation *station)
258
{
259
  NS_LOG_FUNCTION (this << station);
260
  station->m_nFailed = 0;
261
  station->m_counter = GetThresholds (station, station->m_rateIndex).m_ewnd;
218
  station->m_lastReset = Simulator::Now ();
262
  station->m_lastReset = Simulator::Now ();
219
}
263
}
220
264
221
uint32_t
265
uint32_t
222
RraaWifiManager::GetMaxRate (RraaWifiRemoteStation *station)
266
RraaWifiManager::GetMaxRate (RraaWifiRemoteStation *station)
223
{
267
{
224
  return GetNSupported (station) - 1;
268
  return station->m_nRate - 1;
225
}
269
}
226
270
227
uint32_t
271
uint32_t
 Lines 233-248   RraaWifiManager::GetMinRate (RraaWifiRemoteStation *station) Link Here 
233
void
277
void
234
RraaWifiManager::DoReportRtsFailed (WifiRemoteStation *st)
278
RraaWifiManager::DoReportRtsFailed (WifiRemoteStation *st)
235
{
279
{
280
  NS_LOG_FUNCTION (this << st);
236
}
281
}
237
282
238
void
283
void
239
RraaWifiManager::DoReportDataFailed (WifiRemoteStation *st)
284
RraaWifiManager::DoReportDataFailed (WifiRemoteStation *st)
240
{
285
{
286
  NS_LOG_FUNCTION (this << st);
241
  RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st;
287
  RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st;
242
  station->m_lastFrameFail = true;
288
  station->m_lastFrameFail = true;
243
  CheckTimeout (station);
289
  CheckTimeout (station);
244
  station->m_counter--;
290
  station->m_counter--;
245
  station->m_failed++;
291
  station->m_nFailed++;
246
  RunBasicAlgorithm (station);
292
  RunBasicAlgorithm (station);
247
}
293
}
248
294
 Lines 250-261   void Link Here 
250
RraaWifiManager::DoReportRxOk (WifiRemoteStation *st,
296
RraaWifiManager::DoReportRxOk (WifiRemoteStation *st,
251
                               double rxSnr, WifiMode txMode)
297
                               double rxSnr, WifiMode txMode)
252
{
298
{
299
  NS_LOG_FUNCTION (this << st << rxSnr << txMode);
253
}
300
}
254
301
255
void
302
void
256
RraaWifiManager::DoReportRtsOk (WifiRemoteStation *st,
303
RraaWifiManager::DoReportRtsOk (WifiRemoteStation *st,
257
                                double ctsSnr, WifiMode ctsMode, double rtsSnr)
304
                                double ctsSnr, WifiMode ctsMode, double rtsSnr)
258
{
305
{
306
  NS_LOG_FUNCTION (this << st << ctsSnr << ctsMode << rtsSnr);
259
  NS_LOG_DEBUG ("self=" << st << " rts ok");
307
  NS_LOG_DEBUG ("self=" << st << " rts ok");
260
}
308
}
261
309
 Lines 263-268   void Link Here 
263
RraaWifiManager::DoReportDataOk (WifiRemoteStation *st,
311
RraaWifiManager::DoReportDataOk (WifiRemoteStation *st,
264
                                 double ackSnr, WifiMode ackMode, double dataSnr)
312
                                 double ackSnr, WifiMode ackMode, double dataSnr)
265
{
313
{
314
  NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr);
266
  RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st;
315
  RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st;
267
  station->m_lastFrameFail = false;
316
  station->m_lastFrameFail = false;
268
  CheckTimeout (station);
317
  CheckTimeout (station);
 Lines 273-288   RraaWifiManager::DoReportDataOk (WifiRemoteStation *st, Link Here 
273
void
322
void
274
RraaWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *st)
323
RraaWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *st)
275
{
324
{
325
  NS_LOG_FUNCTION (this << st);
276
}
326
}
277
327
278
void
328
void
279
RraaWifiManager::DoReportFinalDataFailed (WifiRemoteStation *st)
329
RraaWifiManager::DoReportFinalDataFailed (WifiRemoteStation *st)
280
{
330
{
331
  NS_LOG_FUNCTION (this << st);
281
}
332
}
282
333
283
WifiTxVector
334
WifiTxVector
284
RraaWifiManager::DoGetDataTxVector (WifiRemoteStation *st)
335
RraaWifiManager::DoGetDataTxVector (WifiRemoteStation *st)
285
{
336
{
337
  NS_LOG_FUNCTION (this << st);
286
  RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st;
338
  RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st;
287
  uint32_t channelWidth = GetChannelWidth (station);
339
  uint32_t channelWidth = GetChannelWidth (station);
288
  if (channelWidth > 20 && channelWidth != 22)
340
  if (channelWidth > 20 && channelWidth != 22)
 Lines 290-306   RraaWifiManager::DoGetDataTxVector (WifiRemoteStation *st) Link Here 
290
      //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac
342
      //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac
291
      channelWidth = 20;
343
      channelWidth = 20;
292
    }
344
    }
293
  if (!station->m_initialized)
345
  CheckInit (station);
294
    {
346
  WifiMode mode = GetSupported (station, station->m_rateIndex);
295
      ResetCountersBasic (station);
296
    }
297
  WifiMode mode = GetSupported (station, station->m_rate);
298
  return WifiTxVector (mode, GetDefaultTxPowerLevel (), GetLongRetryCount (station), GetPreambleForTransmission (mode, GetAddress (station)), 800, 1, 1, 0, channelWidth, GetAggregation (station), false);
347
  return WifiTxVector (mode, GetDefaultTxPowerLevel (), GetLongRetryCount (station), GetPreambleForTransmission (mode, GetAddress (station)), 800, 1, 1, 0, channelWidth, GetAggregation (station), false);
299
}
348
}
300
349
301
WifiTxVector
350
WifiTxVector
302
RraaWifiManager::DoGetRtsTxVector (WifiRemoteStation *st)
351
RraaWifiManager::DoGetRtsTxVector (WifiRemoteStation *st)
303
{
352
{
353
  NS_LOG_FUNCTION (this << st);
304
  RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st;
354
  RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st;
305
  uint32_t channelWidth = GetChannelWidth (station);
355
  uint32_t channelWidth = GetChannelWidth (station);
306
  if (channelWidth > 20 && channelWidth != 22)
356
  if (channelWidth > 20 && channelWidth != 22)
 Lines 312-324   RraaWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) Link Here 
312
  WifiMode mode;
362
  WifiMode mode;
313
  if (GetUseNonErpProtection () == false)
363
  if (GetUseNonErpProtection () == false)
314
    {
364
    {
315
      mode = GetSupported (st, 0);
365
      mode = GetSupported (station, 0);
316
    }
366
    }
317
  else
367
  else
318
    {
368
    {
319
      mode = GetNonErpSupported (st, 0);
369
      mode = GetNonErpSupported (station, 0);
320
    }
370
    }
321
  rtsTxVector = WifiTxVector (mode, GetDefaultTxPowerLevel (), GetShortRetryCount (st), GetPreambleForTransmission (mode, GetAddress (st)), 800, 1, 1, 0, channelWidth, GetAggregation (station), false);
371
  rtsTxVector = WifiTxVector (mode, GetDefaultTxPowerLevel (), GetShortRetryCount (station), GetPreambleForTransmission (mode, GetAddress (station)), 800, 1, 1, 0, channelWidth, GetAggregation (station), false);
322
  return rtsTxVector;
372
  return rtsTxVector;
323
}
373
}
324
374
 Lines 326-343   bool Link Here 
326
RraaWifiManager::DoNeedRts (WifiRemoteStation *st,
376
RraaWifiManager::DoNeedRts (WifiRemoteStation *st,
327
                            Ptr<const Packet> packet, bool normally)
377
                            Ptr<const Packet> packet, bool normally)
328
{
378
{
379
  NS_LOG_FUNCTION (this << st << packet << normally);
329
  RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st;
380
  RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st;
381
  CheckInit (station);
330
  if (m_basic)
382
  if (m_basic)
331
    {
383
    {
332
      return normally;
384
      return normally;
333
    }
385
    }
334
  ARts (station);
386
  ARts (station);
335
  return station->m_rtsOn;
387
  return station->m_adaptiveRtsOn;
336
}
388
}
337
389
338
void
390
void
339
RraaWifiManager::CheckTimeout (RraaWifiRemoteStation *station)
391
RraaWifiManager::CheckTimeout (RraaWifiRemoteStation *station)
340
{
392
{
393
  NS_LOG_FUNCTION (this << station);
341
  Time d = Simulator::Now () - station->m_lastReset;
394
  Time d = Simulator::Now () - station->m_lastReset;
342
  if (station->m_counter == 0 || d > m_timeout)
395
  if (station->m_counter == 0 || d > m_timeout)
343
    {
396
    {
 Lines 348-367   RraaWifiManager::CheckTimeout (RraaWifiRemoteStation *station) Link Here 
348
void
401
void
349
RraaWifiManager::RunBasicAlgorithm (RraaWifiRemoteStation *station)
402
RraaWifiManager::RunBasicAlgorithm (RraaWifiRemoteStation *station)
350
{
403
{
351
  ThresholdsItem thresholds = GetThresholds (station, station->m_rate);
404
  NS_LOG_FUNCTION (this << station);
352
  double ploss = (double) station->m_failed / (double) thresholds.ewnd;
405
  Thresholds thresholds = GetThresholds (station, station->m_rateIndex);
406
  double ploss = (double) station->m_nFailed / (double) thresholds.m_ewnd;
353
  if (station->m_counter == 0
407
  if (station->m_counter == 0
354
      || ploss > thresholds.pmtl)
408
      || ploss > thresholds.m_mtl)
355
    {
409
    {
356
      if (station->m_rate > GetMinRate (station)
410
      if (station->m_rateIndex > GetMinRate (station)
357
          && ploss > thresholds.pmtl)
411
          && ploss > thresholds.m_mtl)
358
        {
412
        {
359
          station->m_rate--;
413
          station->m_rateIndex--;
360
        }
414
        }
361
      else if (station->m_rate < GetMaxRate (station)
415
      else if (station->m_rateIndex < GetMaxRate (station)
362
               && ploss < thresholds.pori)
416
               && ploss < thresholds.m_ori)
363
        {
417
        {
364
          station->m_rate++;
418
          station->m_rateIndex++;
365
        }
419
        }
366
      ResetCountersBasic (station);
420
      ResetCountersBasic (station);
367
    }
421
    }
 Lines 370-494   RraaWifiManager::RunBasicAlgorithm (RraaWifiRemoteStation *station) Link Here 
370
void
424
void
371
RraaWifiManager::ARts (RraaWifiRemoteStation *station)
425
RraaWifiManager::ARts (RraaWifiRemoteStation *station)
372
{
426
{
373
  if (!station->m_rtsOn
427
  if (!station->m_adaptiveRtsOn
374
      && station->m_lastFrameFail)
428
      && station->m_lastFrameFail)
375
    {
429
    {
376
      station->m_rtsWnd++;
430
      station->m_adaptiveRtsWnd++;
377
      station->m_rtsCounter = station->m_rtsWnd;
431
      station->m_rtsCounter = station->m_adaptiveRtsWnd;
378
    }
432
    }
379
  else if ((station->m_rtsOn && station->m_lastFrameFail)
433
  else if ((station->m_adaptiveRtsOn && station->m_lastFrameFail)
380
           || (!station->m_rtsOn && !station->m_lastFrameFail))
434
           || (!station->m_adaptiveRtsOn && !station->m_lastFrameFail))
381
    {
435
    {
382
      station->m_rtsWnd = station->m_rtsWnd / 2;
436
      station->m_adaptiveRtsWnd = station->m_adaptiveRtsWnd / 2;
383
      station->m_rtsCounter = station->m_rtsWnd;
437
      station->m_rtsCounter = station->m_adaptiveRtsWnd;
384
    }
438
    }
385
  if (station->m_rtsCounter > 0)
439
  if (station->m_rtsCounter > 0)
386
    {
440
    {
387
      station->m_rtsOn = true;
441
      station->m_adaptiveRtsOn = true;
388
      station->m_rtsCounter--;
442
      station->m_rtsCounter--;
389
    }
443
    }
390
  else
444
  else
391
    {
445
    {
392
      station->m_rtsOn = false;
446
      station->m_adaptiveRtsOn = false;
393
    }
447
    }
394
}
448
}
395
449
396
RraaWifiManager::ThresholdsItem
450
Thresholds
397
RraaWifiManager::GetThresholds (RraaWifiRemoteStation *station,
451
RraaWifiManager::GetThresholds (RraaWifiRemoteStation *station,
398
                                uint32_t rate) const
452
                                 uint32_t rate) const
399
{
453
{
454
  NS_LOG_FUNCTION (this << station << rate);
400
  WifiMode mode = GetSupported (station, rate);
455
  WifiMode mode = GetSupported (station, rate);
401
  return GetThresholds (mode, station);
456
  return GetThresholds (station, mode);
402
}
403
404
RraaWifiManager::ThresholdsItem
405
RraaWifiManager::GetThresholds (WifiMode mode, RraaWifiRemoteStation *station) const
406
{
407
  switch (mode.GetDataRate (GetChannelWidth (station)) / 1000000)
408
    {
409
    case 54:
410
      {
411
        ThresholdsItem mode54 = {
412
          54000000,
413
          0.0,
414
          m_pmtlfor54,
415
          m_ewndfor54
416
        };
417
        return mode54;
418
      } break;
419
    case 48:
420
      {
421
        ThresholdsItem mode48 = {
422
          48000000,
423
          m_porifor48,
424
          m_pmtlfor48,
425
          m_ewndfor48
426
        };
427
        return mode48;
428
      } break;
429
    case 36:
430
      {
431
        ThresholdsItem mode36 = {
432
          36000000,
433
          m_porifor36,
434
          m_pmtlfor36,
435
          m_ewndfor36
436
        };
437
        return mode36;
438
      } break;
439
    case 24:
440
      {
441
        ThresholdsItem mode24 = {
442
          24000000,
443
          m_porifor24,
444
          m_pmtlfor24,
445
          m_ewndfor24
446
        };
447
        return mode24;
448
      } break;
449
    case 18:
450
      {
451
        ThresholdsItem mode18 = {
452
          18000000,
453
          m_porifor18,
454
          m_pmtlfor18,
455
          m_ewndfor18
456
        };
457
        return mode18;
458
      } break;
459
    case 12:
460
      {
461
        ThresholdsItem mode12 = {
462
          12000000,
463
          m_porifor12,
464
          m_pmtlfor12,
465
          m_ewndfor12
466
        };
467
        return mode12;
468
      } break;
469
    case 9:
470
      {
471
        ThresholdsItem mode9 =  {
472
          9000000,
473
          m_porifor9,
474
          m_pmtlfor9,
475
          m_ewndfor9
476
        };
477
        return mode9;
478
      } break;
479
    case 6:
480
      {
481
        ThresholdsItem mode6 =  {
482
          6000000,
483
          m_porifor6,
484
          1.0,
485
          m_ewndfor6
486
        };
487
        return mode6;
488
      } break;
489
    }
490
  NS_ASSERT_MSG (false, "Thresholds for an unknown mode are asked (" << mode << ")");
491
  return ThresholdsItem ();
492
}
457
}
493
458
494
bool
459
bool
(-)a/src/wifi/model/rraa-wifi-manager.h (-34 / +73 lines)
 Lines 21-26    Link Here 
21
#ifndef RRAA_WIFI_MANAGER_H
21
#ifndef RRAA_WIFI_MANAGER_H
22
#define RRAA_WIFI_MANAGER_H
22
#define RRAA_WIFI_MANAGER_H
23
23
24
#include "ns3/nstime.h"
24
#include "wifi-remote-station-manager.h"
25
#include "wifi-remote-station-manager.h"
25
26
26
namespace ns3 {
27
namespace ns3 {
 Lines 40-45   struct RraaWifiRemoteStation; Link Here 
40
 * exit if the user tries to configure this RAA with a Wi-Fi MAC
41
 * exit if the user tries to configure this RAA with a Wi-Fi MAC
41
 * that has VhtSupported, HtSupported or HeSupported set.
42
 * that has VhtSupported, HtSupported or HeSupported set.
42
 */
43
 */
44
45
/**
46
 * For each rate there is a Opportunistic Rate Increase threshold,
47
 * a Maximum Tolerable Loss threshold and an Evaluation Window.
48
 */
49
struct Thresholds
50
{
51
  double m_ori;
52
  double m_mtl;
53
  uint32_t m_ewnd;
54
};
55
56
/**
57
 * List of thresholds for each mode.
58
 */
59
typedef std::vector<std::pair<Thresholds, WifiMode> > RraaThresholdsTable;
60
61
43
class RraaWifiManager : public WifiRemoteStationManager
62
class RraaWifiManager : public WifiRemoteStationManager
44
{
63
{
45
public:
64
public:
 Lines 49-66   public: Link Here 
49
  virtual ~RraaWifiManager ();
68
  virtual ~RraaWifiManager ();
50
69
51
  // Inherited from WifiRemoteStationManager
70
  // Inherited from WifiRemoteStationManager
71
  virtual void SetupPhy (Ptr<WifiPhy> phy);
72
  virtual void SetupMac (Ptr<WifiMac> mac);
52
  virtual void SetHtSupported (bool enable);
73
  virtual void SetHtSupported (bool enable);
53
  virtual void SetVhtSupported (bool enable);
74
  virtual void SetVhtSupported (bool enable);
54
  virtual void SetHeSupported (bool enable);
75
  virtual void SetHeSupported (bool enable);
55
76
56
private:
77
private:
57
  struct ThresholdsItem
58
  {
59
    uint32_t datarate;
60
    double pori;
61
    double pmtl;
62
    uint32_t ewnd;
63
  };
64
78
65
  //overriden from base class
79
  //overriden from base class
66
  virtual WifiRemoteStation * DoCreateStation (void) const;
80
  virtual WifiRemoteStation * DoCreateStation (void) const;
 Lines 81-86   private: Link Here 
81
  virtual bool IsLowLatency (void) const;
95
  virtual bool IsLowLatency (void) const;
82
96
83
  /**
97
  /**
98
   * Check for initializations.
99
   * \param station The remote station.
100
   */
101
  void CheckInit (RraaWifiRemoteStation *station);
102
  /**
84
   * Return the index for the maximum transmission rate for
103
   * Return the index for the maximum transmission rate for
85
   * the given station.
104
   * the given station.
86
   *
105
   *
 Lines 123-171   private: Link Here 
123
   * \param station
142
   * \param station
124
   */
143
   */
125
  void ResetCountersBasic (RraaWifiRemoteStation *station);
144
  void ResetCountersBasic (RraaWifiRemoteStation *station);
145
126
  /**
146
  /**
127
   * Get a threshold for the given mode.
147
   * Initialize the thresholds internal list for the given station.
128
   *
148
   *
129
   * \param mode
130
   * \param station
149
   * \param station
150
   */
151
  void InitThresholds (RraaWifiRemoteStation *station);
152
153
  /**
154
   * Get the thresholds for the given station and mode.
155
   *
156
   * \param station
157
   * \param mode
131
   *
158
   *
132
   * \return threshold
159
   * \return threshold
133
   */
160
   */
134
  ThresholdsItem GetThresholds (WifiMode mode, RraaWifiRemoteStation *station) const;
161
  Thresholds GetThresholds (RraaWifiRemoteStation *station, WifiMode mode) const;
162
135
  /**
163
  /**
136
   * Get a threshold for the given station and mode index.
164
   * Get the thresholds for the given station and mode index.
137
   *
165
   *
138
   * \param station
166
   * \param station
139
   * \param rate
167
   * \param rate
140
   *
168
   *
141
   * \return threshold
169
   * \return threshold
142
   */
170
   */
143
  ThresholdsItem GetThresholds (RraaWifiRemoteStation *station, uint32_t rate) const;
171
  Thresholds GetThresholds (RraaWifiRemoteStation *station, uint32_t rate) const;
172
173
  /**
174
   * Get the estimated TxTime of a packet with a given mode.
175
   *
176
   * \param mode
177
   *
178
   * \return time
179
   */
180
  Time GetCalcTxTime (WifiMode mode) const;
181
  /**
182
   * Add transmission time for the given mode to an internal list.
183
   *
184
   * \param mode Wi-Fi mode
185
   * \param t transmission time
186
   */
187
  void AddCalcTxTime (WifiMode mode, Time t);
188
189
  /**
190
   * typedef for a vector of a pair of Time, WifiMode.
191
   * Essentially a list for WifiMode and its corresponding transmission time
192
   * to transmit a reference packet.
193
   */
194
  typedef std::vector<std::pair<Time,WifiMode> > TxTime;
195
196
  TxTime m_calcTxTime;     //!< To hold all the calculated TxTime for all modes.
197
  Time m_sifs;             //!< Value of SIFS configured in the device.
198
  Time m_difs;             //!< Value of DIFS configured in the device.
199
200
  uint32_t m_frameLength;  //!< Data frame length used for calculate mode TxTime.
201
  uint32_t m_ackLength;    //!< Ack frame length used for calculate mode TxTime.
144
202
145
  bool m_basic;
203
  bool m_basic;
146
  Time m_timeout;
204
  Time m_timeout;
147
  uint32_t m_ewndfor54;
205
  double m_alpha;          //!< Alpha value for RRAA (value for calculating MTL threshold)
148
  uint32_t m_ewndfor48;
206
  double m_beta;           //!< Beta value for RRAA (value for calculating ORI threshold).
149
  uint32_t m_ewndfor36;
207
  double m_tau;            //!< Tau value for RRAA (value for calculating EWND size).
150
  uint32_t m_ewndfor24;
151
  uint32_t m_ewndfor18;
152
  uint32_t m_ewndfor12;
153
  uint32_t m_ewndfor9;
154
  uint32_t m_ewndfor6;
155
  double m_porifor48;
156
  double m_porifor36;
157
  double m_porifor24;
158
  double m_porifor18;
159
  double m_porifor12;
160
  double m_porifor9;
161
  double m_porifor6;
162
  double m_pmtlfor54;
163
  double m_pmtlfor48;
164
  double m_pmtlfor36;
165
  double m_pmtlfor24;
166
  double m_pmtlfor18;
167
  double m_pmtlfor12;
168
  double m_pmtlfor9;
169
};
208
};
170
209
171
} //namespace ns3
210
} //namespace ns3

Return to bug 2654