A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
minstrel-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) 2009 Duy Nguyen
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: Duy Nguyen <duy@soe.ucsc.edu>
19
*
20
* Some Comments:
21
*
22
* 1) Segment Size is declared for completeness but not used because it has
23
* to do more with the requirement of the specific hardware.
24
*
25
* 2) By default, Minstrel applies the multi-rate retry(the core of Minstrel
26
* algorithm). Otherwise, please use ConstantRateWifiManager instead.
27
*
28
* http://linuxwireless.org/en/developers/Documentation/mac80211/RateControl/minstrel
29
*/
30
31
#include "
minstrel-wifi-manager.h
"
32
#include "
wifi-phy.h
"
33
#include "ns3/simulator.h"
34
#include "ns3/log.h"
35
#include "ns3/uinteger.h"
36
#include "ns3/double.h"
37
#include "ns3/wifi-mac.h"
38
#include "ns3/assert.h"
39
#include <vector>
40
41
NS_LOG_COMPONENT_DEFINE
(
"MinstrelWifiManager"
);
42
43
44
namespace
ns3 {
45
46
47
struct
MinstrelWifiRemoteStation
:
public
WifiRemoteStation
48
{
49
Time
m_nextStatsUpdate
;
50
57
uint32_t
m_col
,
m_index
;
58
uint32_t
m_maxTpRate
;
59
uint32_t
m_maxTpRate2
;
60
uint32_t
m_maxProbRate
;
61
62
int
m_packetCount
;
63
int
m_sampleCount
;
64
65
bool
m_isSampling
;
66
uint32_t
m_sampleRate
;
67
bool
m_sampleRateSlower
;
68
uint32_t
m_currentRate
;
69
70
uint32_t
m_shortRetry
;
71
uint32_t
m_longRetry
;
72
uint32_t
m_retry
;
73
uint32_t
m_err
;
74
uint32_t
m_txrate
;
75
76
bool
m_initialized
;
77
};
78
79
NS_OBJECT_ENSURE_REGISTERED
(
MinstrelWifiManager
);
80
81
TypeId
82
MinstrelWifiManager::GetTypeId
(
void
)
83
{
84
static
TypeId
tid =
TypeId
(
"ns3::MinstrelWifiManager"
)
85
.
SetParent
<
WifiRemoteStationManager
> ()
86
.AddConstructor<MinstrelWifiManager> ()
87
.AddAttribute (
"UpdateStatistics"
,
88
"The interval between updating statistics table "
,
89
TimeValue
(
Seconds
(0.1)),
90
MakeTimeAccessor (&
MinstrelWifiManager::m_updateStats
),
91
MakeTimeChecker ())
92
.AddAttribute (
"LookAroundRate"
,
93
"the percentage to try other rates"
,
94
DoubleValue
(10),
95
MakeDoubleAccessor (&
MinstrelWifiManager::m_lookAroundRate
),
96
MakeDoubleChecker<double> ())
97
.AddAttribute (
"EWMA"
,
98
"EWMA level"
,
99
DoubleValue
(75),
100
MakeDoubleAccessor (&
MinstrelWifiManager::m_ewmaLevel
),
101
MakeDoubleChecker<double> ())
102
.AddAttribute (
"SegmentSize"
,
103
"The largest allowable segment size packet"
,
104
DoubleValue
(6000),
105
MakeDoubleAccessor (&
MinstrelWifiManager::m_segmentSize
),
106
MakeDoubleChecker <double> ())
107
.AddAttribute (
"SampleColumn"
,
108
"The number of columns used for sampling"
,
109
DoubleValue
(10),
110
MakeDoubleAccessor (&
MinstrelWifiManager::m_sampleCol
),
111
MakeDoubleChecker <double> ())
112
.AddAttribute (
"PacketLength"
,
113
"The packet length used for calculating mode TxTime"
,
114
DoubleValue
(1200),
115
MakeDoubleAccessor (&
MinstrelWifiManager::m_pktLen
),
116
MakeDoubleChecker <double> ())
117
;
118
return
tid;
119
}
120
121
MinstrelWifiManager::MinstrelWifiManager
()
122
{
123
m_uniformRandomVariable
= CreateObject<UniformRandomVariable> ();
124
125
m_nsupported
= 0;
126
}
127
128
MinstrelWifiManager::~MinstrelWifiManager
()
129
{
130
}
131
132
void
133
MinstrelWifiManager::SetupPhy
(
Ptr<WifiPhy>
phy)
134
{
135
uint32_t nModes = phy->
GetNModes
();
136
for
(uint32_t i = 0; i < nModes; i++)
137
{
138
WifiMode
mode = phy->
GetMode
(i);
139
AddCalcTxTime
(mode, phy->
CalculateTxDuration
(
m_pktLen
, mode,
WIFI_PREAMBLE_LONG
));
140
}
141
WifiRemoteStationManager::SetupPhy
(phy);
142
}
143
144
int64_t
145
MinstrelWifiManager::AssignStreams
(int64_t stream)
146
{
147
NS_LOG_FUNCTION
(
this
<< stream);
148
m_uniformRandomVariable
->
SetStream
(stream);
149
return
1;
150
}
151
152
Time
153
MinstrelWifiManager::GetCalcTxTime
(
WifiMode
mode)
const
154
{
155
156
for
(TxTime::const_iterator i =
m_calcTxTime
.begin (); i !=
m_calcTxTime
.end (); i++)
157
{
158
if
(mode == i->second)
159
{
160
return
i->first;
161
}
162
}
163
NS_ASSERT
(
false
);
164
return
Seconds
(0);
165
}
166
167
void
168
MinstrelWifiManager::AddCalcTxTime
(
WifiMode
mode,
Time
t)
169
{
170
m_calcTxTime
.push_back (std::make_pair (t, mode));
171
}
172
173
WifiRemoteStation
*
174
MinstrelWifiManager::DoCreateStation
(
void
)
const
175
{
176
MinstrelWifiRemoteStation
*station =
new
MinstrelWifiRemoteStation
();
177
178
station->
m_nextStatsUpdate
=
Simulator::Now
() +
m_updateStats
;
179
station->
m_col
= 0;
180
station->
m_index
= 0;
181
station->
m_maxTpRate
= 0;
182
station->
m_maxTpRate2
= 0;
183
station->
m_maxProbRate
= 0;
184
station->
m_packetCount
= 0;
185
station->
m_sampleCount
= 0;
186
station->
m_isSampling
=
false
;
187
station->
m_sampleRate
= 0;
188
station->
m_sampleRateSlower
=
false
;
189
station->
m_currentRate
= 0;
190
station->
m_shortRetry
= 0;
191
station->
m_longRetry
= 0;
192
station->
m_retry
= 0;
193
station->
m_err
= 0;
194
station->
m_txrate
= 0;
195
station->
m_initialized
=
false
;
196
197
return
station;
198
}
199
200
void
201
MinstrelWifiManager::CheckInit
(
MinstrelWifiRemoteStation
*station)
202
{
203
if
(!station->
m_initialized
&&
GetNSupported
(station) > 1)
204
{
205
// Note: we appear to be doing late initialization of the table
206
// to make sure that the set of supported rates has been initialized
207
// before we perform our own initialization.
208
m_nsupported
=
GetNSupported
(station);
209
m_minstrelTable
=
MinstrelRate
(
m_nsupported
);
210
m_sampleTable
=
SampleRate
(
m_nsupported
, std::vector<uint32_t> (
m_sampleCol
));
211
InitSampleTable
(station);
212
RateInit
(station);
213
station->
m_initialized
=
true
;
214
}
215
}
216
217
void
218
MinstrelWifiManager::DoReportRxOk
(
WifiRemoteStation
*st,
219
double
rxSnr,
WifiMode
txMode)
220
{
221
NS_LOG_DEBUG
(
"DoReportRxOk m_txrate="
<< ((
MinstrelWifiRemoteStation
*)st)->m_txrate);
222
}
223
224
void
225
MinstrelWifiManager::DoReportRtsFailed
(
WifiRemoteStation
*st)
226
{
227
MinstrelWifiRemoteStation
*station = (
MinstrelWifiRemoteStation
*)st;
228
NS_LOG_DEBUG
(
"DoReportRtsFailed m_txrate="
<< station->
m_txrate
);
229
230
station->
m_shortRetry
++;
231
}
232
233
void
234
MinstrelWifiManager::DoReportRtsOk
(
WifiRemoteStation
*st,
double
ctsSnr,
WifiMode
ctsMode,
double
rtsSnr)
235
{
236
NS_LOG_DEBUG
(
"self="
<< st <<
" rts ok"
);
237
}
238
239
void
240
MinstrelWifiManager::DoReportFinalRtsFailed
(
WifiRemoteStation
*st)
241
{
242
MinstrelWifiRemoteStation
*station = (
MinstrelWifiRemoteStation
*)st;
243
UpdateRetry
(station);
244
station->
m_err
++;
245
}
246
247
void
248
MinstrelWifiManager::DoReportDataFailed
(
WifiRemoteStation
*st)
249
{
250
MinstrelWifiRemoteStation
*station = (
MinstrelWifiRemoteStation
*)st;
267
CheckInit
(station);
268
if
(!station->
m_initialized
)
269
{
270
return
;
271
}
272
273
station->
m_longRetry
++;
274
275
NS_LOG_DEBUG
(
"DoReportDataFailed "
<< station <<
"\t rate "
<< station->
m_txrate
<<
"\tlongRetry \t"
<< station->
m_longRetry
);
276
278
if
(!station->
m_isSampling
)
279
{
281
if
(station->
m_longRetry
<
m_minstrelTable
[station->
m_txrate
].adjustedRetryCount)
282
{
283
;
284
}
285
287
else
if
(station->
m_longRetry
<= (
m_minstrelTable
[station->
m_txrate
].adjustedRetryCount +
288
m_minstrelTable
[station->
m_maxTpRate
].adjustedRetryCount))
289
{
290
station->
m_txrate
= station->
m_maxTpRate2
;
291
}
292
294
else
if
(station->
m_longRetry
<= (
m_minstrelTable
[station->
m_txrate
].adjustedRetryCount +
295
m_minstrelTable
[station->
m_maxTpRate2
].adjustedRetryCount +
296
m_minstrelTable
[station->
m_maxTpRate
].adjustedRetryCount))
297
{
298
station->
m_txrate
= station->
m_maxProbRate
;
299
}
300
302
else
if
(station->
m_longRetry
> (
m_minstrelTable
[station->
m_txrate
].adjustedRetryCount +
303
m_minstrelTable
[station->
m_maxTpRate2
].adjustedRetryCount +
304
m_minstrelTable
[station->
m_maxTpRate
].adjustedRetryCount))
305
{
306
station->
m_txrate
= 0;
307
}
308
}
309
311
else
312
{
314
if
(station->
m_sampleRateSlower
)
315
{
317
if
(station->
m_longRetry
<
m_minstrelTable
[station->
m_txrate
].adjustedRetryCount)
318
{
319
;
320
}
321
323
else
if
(station->
m_longRetry
<= (
m_minstrelTable
[station->
m_txrate
].adjustedRetryCount +
324
m_minstrelTable
[station->
m_maxTpRate
].adjustedRetryCount))
325
{
326
station->
m_txrate
= station->
m_sampleRate
;
327
}
328
330
else
if
(station->
m_longRetry
<= (
m_minstrelTable
[station->
m_txrate
].adjustedRetryCount +
331
m_minstrelTable
[station->
m_sampleRate
].adjustedRetryCount +
332
m_minstrelTable
[station->
m_maxTpRate
].adjustedRetryCount ))
333
{
334
station->
m_txrate
= station->
m_maxProbRate
;
335
}
336
338
else
if
(station->
m_longRetry
> (
m_minstrelTable
[station->
m_txrate
].adjustedRetryCount +
339
m_minstrelTable
[station->
m_sampleRate
].adjustedRetryCount +
340
m_minstrelTable
[station->
m_maxTpRate
].adjustedRetryCount))
341
{
342
station->
m_txrate
= 0;
343
}
344
}
345
347
else
348
{
350
if
(station->
m_longRetry
<
m_minstrelTable
[station->
m_txrate
].adjustedRetryCount)
351
{
352
;
353
}
354
356
else
if
(station->
m_longRetry
<= (
m_minstrelTable
[station->
m_txrate
].adjustedRetryCount +
357
m_minstrelTable
[station->
m_sampleRate
].adjustedRetryCount))
358
{
359
station->
m_txrate
= station->
m_maxTpRate
;
360
}
361
363
else
if
(station->
m_longRetry
<= (
m_minstrelTable
[station->
m_txrate
].adjustedRetryCount +
364
m_minstrelTable
[station->
m_maxTpRate
].adjustedRetryCount +
365
m_minstrelTable
[station->
m_sampleRate
].adjustedRetryCount))
366
{
367
station->
m_txrate
= station->
m_maxProbRate
;
368
}
369
371
else
if
(station->
m_longRetry
> (
m_minstrelTable
[station->
m_txrate
].adjustedRetryCount +
372
m_minstrelTable
[station->
m_maxTpRate
].adjustedRetryCount +
373
m_minstrelTable
[station->
m_sampleRate
].adjustedRetryCount))
374
{
375
station->
m_txrate
= 0;
376
}
377
}
378
}
379
}
380
381
void
382
MinstrelWifiManager::DoReportDataOk
(
WifiRemoteStation
*st,
383
double
ackSnr,
WifiMode
ackMode,
double
dataSnr)
384
{
385
MinstrelWifiRemoteStation
*station = (
MinstrelWifiRemoteStation
*) st;
386
387
station->
m_isSampling
=
false
;
388
station->
m_sampleRateSlower
=
false
;
389
390
CheckInit
(station);
391
if
(!station->
m_initialized
)
392
{
393
return
;
394
}
395
396
m_minstrelTable
[station->
m_txrate
].numRateSuccess++;
397
m_minstrelTable
[station->
m_txrate
].numRateAttempt++;
398
399
UpdateRetry
(station);
400
401
m_minstrelTable
[station->
m_txrate
].numRateAttempt += station->
m_retry
;
402
station->
m_packetCount
++;
403
404
if
(
m_nsupported
>= 1)
405
{
406
station->
m_txrate
=
FindRate
(station);
407
}
408
}
409
410
void
411
MinstrelWifiManager::DoReportFinalDataFailed
(
WifiRemoteStation
*st)
412
{
413
MinstrelWifiRemoteStation
*station = (
MinstrelWifiRemoteStation
*) st;
414
NS_LOG_DEBUG
(
"DoReportFinalDataFailed m_txrate="
<< station->
m_txrate
);
415
416
station->
m_isSampling
=
false
;
417
station->
m_sampleRateSlower
=
false
;
418
419
UpdateRetry
(station);
420
421
m_minstrelTable
[station->
m_txrate
].numRateAttempt += station->
m_retry
;
422
station->
m_err
++;
423
424
if
(
m_nsupported
>= 1)
425
{
426
station->
m_txrate
=
FindRate
(station);
427
}
428
}
429
430
void
431
MinstrelWifiManager::UpdateRetry
(
MinstrelWifiRemoteStation
*station)
432
{
433
station->
m_retry
= station->
m_shortRetry
+ station->
m_longRetry
;
434
station->
m_shortRetry
= 0;
435
station->
m_longRetry
= 0;
436
}
437
438
WifiMode
439
MinstrelWifiManager::DoGetDataMode
(
WifiRemoteStation
*st,
440
uint32_t size)
441
{
442
MinstrelWifiRemoteStation
*station = (
MinstrelWifiRemoteStation
*) st;
443
if
(!station->
m_initialized
)
444
{
445
CheckInit
(station);
446
448
station->
m_txrate
=
m_nsupported
/ 2;
449
}
450
UpdateStats
(station);
451
return
GetSupported
(station, station->
m_txrate
);
452
}
453
454
WifiMode
455
MinstrelWifiManager::DoGetRtsMode
(
WifiRemoteStation
*st)
456
{
457
MinstrelWifiRemoteStation
*station = (
MinstrelWifiRemoteStation
*) st;
458
NS_LOG_DEBUG
(
"DoGetRtsMode m_txrate="
<< station->
m_txrate
);
459
460
return
GetSupported
(station, 0);
461
}
462
463
bool
464
MinstrelWifiManager::IsLowLatency
(
void
)
const
465
{
466
return
true
;
467
}
468
uint32_t
469
MinstrelWifiManager::GetNextSample
(
MinstrelWifiRemoteStation
*station)
470
{
471
uint32_t bitrate;
472
bitrate =
m_sampleTable
[station->
m_index
][station->
m_col
];
473
station->
m_index
++;
474
476
if
(station->
m_index
> (
m_nsupported
- 2))
477
{
478
station->
m_index
= 0;
479
station->
m_col
++;
480
if
(station->
m_col
>=
m_sampleCol
)
481
{
482
station->
m_col
= 0;
483
}
484
}
485
return
bitrate;
486
}
487
488
uint32_t
489
MinstrelWifiManager::FindRate
(
MinstrelWifiRemoteStation
*station)
490
{
491
NS_LOG_DEBUG
(
"FindRate "
<<
"packet="
<< station->
m_packetCount
);
492
493
if
((station->
m_sampleCount
+ station->
m_packetCount
) == 0)
494
{
495
return
0;
496
}
497
498
499
uint32_t idx;
500
502
int
coinFlip =
m_uniformRandomVariable
->
GetInteger
(0, 100) % 2;
503
509
if
( (((100 * station->
m_sampleCount
) / (station->
m_sampleCount
+ station->
m_packetCount
)) <
m_lookAroundRate
)
510
&& (coinFlip == 1) )
511
{
512
514
idx =
GetNextSample
(station);
515
516
521
if
(idx != station->
m_maxTpRate
&& idx != station->
m_txrate
)
522
{
523
525
station->
m_sampleCount
++;
526
528
station->
m_isSampling
=
true
;
529
531
if
(station->
m_packetCount
>= 10000)
532
{
533
station->
m_sampleCount
= 0;
534
station->
m_packetCount
= 0;
535
}
536
538
if
(idx >=
m_nsupported
)
539
{
540
NS_LOG_DEBUG
(
"ALERT!!! ERROR"
);
541
}
542
544
station->
m_sampleRate
= idx;
545
546
if
(station->
m_sampleRate
== station->
m_maxTpRate
)
547
{
548
station->
m_sampleRate
= station->
m_maxTpRate2
;
549
}
550
552
station->
m_sampleRateSlower
=
553
(
m_minstrelTable
[idx].perfectTxTime >
m_minstrelTable
[station->
m_maxTpRate
].perfectTxTime);
554
556
if
(station->
m_sampleRateSlower
)
557
{
558
idx = station->
m_maxTpRate
;
559
}
560
}
561
562
}
563
565
else
566
{
567
idx = station->
m_maxTpRate
;
568
}
569
570
571
NS_LOG_DEBUG
(
"FindRate "
<<
"sample rate="
<< idx);
572
573
return
idx;
574
}
575
576
void
577
MinstrelWifiManager::UpdateStats
(
MinstrelWifiRemoteStation
*station)
578
{
579
if
(
Simulator::Now
() < station->
m_nextStatsUpdate
)
580
{
581
return
;
582
}
583
584
if
(!station->
m_initialized
)
585
{
586
return
;
587
}
588
NS_LOG_DEBUG
(
"Updating stats="
<<
this
);
589
590
station->
m_nextStatsUpdate
=
Simulator::Now
() +
m_updateStats
;
591
592
Time
txTime;
593
uint32_t tempProb;
594
595
for
(uint32_t i = 0; i <
m_nsupported
; i++)
596
{
597
599
txTime =
m_minstrelTable
[i].perfectTxTime;
600
602
if
(txTime.
GetMicroSeconds
() == 0)
603
{
604
txTime =
Seconds
(1);
605
}
606
607
NS_LOG_DEBUG
(
"m_txrate="
<< station->
m_txrate
<<
608
"\t attempt="
<<
m_minstrelTable
[i].numRateAttempt <<
609
"\t success="
<<
m_minstrelTable
[i].numRateSuccess);
610
612
if
(
m_minstrelTable
[i].numRateAttempt)
613
{
618
tempProb = (
m_minstrelTable
[i].numRateSuccess * 18000) /
m_minstrelTable
[i].numRateAttempt;
619
621
m_minstrelTable
[i].successHist +=
m_minstrelTable
[i].numRateSuccess;
622
m_minstrelTable
[i].attemptHist +=
m_minstrelTable
[i].numRateAttempt;
623
m_minstrelTable
[i].prob = tempProb;
624
626
tempProb =
static_cast<
uint32_t
>
(((tempProb * (100 -
m_ewmaLevel
)) + (
m_minstrelTable
[i].ewmaProb *
m_ewmaLevel
) ) / 100);
627
628
m_minstrelTable
[i].ewmaProb = tempProb;
629
631
m_minstrelTable
[i].throughput = tempProb * (1000000 / txTime.
GetMicroSeconds
());
632
633
}
634
636
m_minstrelTable
[i].prevNumRateAttempt =
m_minstrelTable
[i].numRateAttempt;
637
m_minstrelTable
[i].prevNumRateSuccess =
m_minstrelTable
[i].numRateSuccess;
638
m_minstrelTable
[i].numRateSuccess = 0;
639
m_minstrelTable
[i].numRateAttempt = 0;
640
642
if
((
m_minstrelTable
[i].ewmaProb > 17100) || (
m_minstrelTable
[i].ewmaProb < 1800))
643
{
648
m_minstrelTable
[i].adjustedRetryCount =
m_minstrelTable
[i].retryCount >> 1;
649
if
(
m_minstrelTable
[i].adjustedRetryCount > 2)
650
{
651
m_minstrelTable
[i].adjustedRetryCount = 2;
652
}
653
}
654
else
655
{
656
m_minstrelTable
[i].adjustedRetryCount =
m_minstrelTable
[i].retryCount;
657
}
658
660
if
(
m_minstrelTable
[i].adjustedRetryCount == 0)
661
{
662
m_minstrelTable
[i].adjustedRetryCount = 1;
663
}
664
}
665
666
667
uint32_t max_prob = 0, index_max_prob = 0, max_tp = 0, index_max_tp = 0, index_max_tp2 = 0;
668
670
for
(uint32_t i = 0; i <
m_nsupported
; i++)
671
{
672
NS_LOG_DEBUG
(
"throughput"
<<
m_minstrelTable
[i].throughput <<
673
"\n ewma"
<<
m_minstrelTable
[i].ewmaProb);
674
675
if
(max_tp <
m_minstrelTable
[i].throughput)
676
{
677
index_max_tp = i;
678
max_tp =
m_minstrelTable
[i].throughput;
679
}
680
681
if
(max_prob <
m_minstrelTable
[i].ewmaProb)
682
{
683
index_max_prob = i;
684
max_prob =
m_minstrelTable
[i].ewmaProb;
685
}
686
}
687
688
689
max_tp = 0;
691
for
(uint32_t i = 0; i <
m_nsupported
; i++)
692
{
693
if
((i != index_max_tp) && (max_tp <
m_minstrelTable
[i].throughput))
694
{
695
index_max_tp2 = i;
696
max_tp =
m_minstrelTable
[i].throughput;
697
}
698
}
699
700
station->
m_maxTpRate
= index_max_tp;
701
station->
m_maxTpRate2
= index_max_tp2;
702
station->
m_maxProbRate
= index_max_prob;
703
station->
m_currentRate
= index_max_tp;
704
705
if
(index_max_tp > station->
m_txrate
)
706
{
707
station->
m_txrate
= index_max_tp;
708
}
709
710
NS_LOG_DEBUG
(
"max tp="
<< index_max_tp <<
"\nmax tp2="
<< index_max_tp2 <<
"\nmax prob="
<< index_max_prob);
711
713
RateInit
(station);
714
}
715
716
void
717
MinstrelWifiManager::RateInit
(
MinstrelWifiRemoteStation
*station)
718
{
719
NS_LOG_DEBUG
(
"RateInit="
<< station);
720
721
for
(uint32_t i = 0; i <
m_nsupported
; i++)
722
{
723
m_minstrelTable
[i].numRateAttempt = 0;
724
m_minstrelTable
[i].numRateSuccess = 0;
725
m_minstrelTable
[i].prob = 0;
726
m_minstrelTable
[i].ewmaProb = 0;
727
m_minstrelTable
[i].prevNumRateAttempt = 0;
728
m_minstrelTable
[i].prevNumRateSuccess = 0;
729
m_minstrelTable
[i].successHist = 0;
730
m_minstrelTable
[i].attemptHist = 0;
731
m_minstrelTable
[i].throughput = 0;
732
m_minstrelTable
[i].perfectTxTime =
GetCalcTxTime
(
GetSupported
(station, i));
733
m_minstrelTable
[i].retryCount = 1;
734
m_minstrelTable
[i].adjustedRetryCount = 1;
735
}
736
}
737
738
void
739
MinstrelWifiManager::InitSampleTable
(
MinstrelWifiRemoteStation
*station)
740
{
741
NS_LOG_DEBUG
(
"InitSampleTable="
<<
this
);
742
743
station->
m_col
= station->
m_index
= 0;
744
746
uint32_t numSampleRates =
m_nsupported
;
747
748
uint32_t newIndex;
749
for
(uint32_t col = 0; col <
m_sampleCol
; col++)
750
{
751
for
(uint32_t i = 0; i < numSampleRates; i++ )
752
{
753
758
int
uv =
m_uniformRandomVariable
->
GetInteger
(0, numSampleRates);
759
newIndex = (i + uv) % numSampleRates;
760
762
while
(
m_sampleTable
[newIndex][col] != 0)
763
{
764
newIndex = (newIndex + 1) %
m_nsupported
;
765
}
766
m_sampleTable
[newIndex][col] = i;
767
768
}
769
}
770
}
771
772
void
773
MinstrelWifiManager::PrintSampleTable
(
MinstrelWifiRemoteStation
*station)
774
{
775
NS_LOG_DEBUG
(
"PrintSampleTable="
<< station);
776
777
uint32_t numSampleRates =
m_nsupported
;
778
for
(uint32_t i = 0; i < numSampleRates; i++)
779
{
780
for
(uint32_t j = 0; j <
m_sampleCol
; j++)
781
{
782
std::cout <<
m_sampleTable
[i][j] <<
"\t"
;
783
}
784
std::cout << std::endl;
785
}
786
}
787
788
void
789
MinstrelWifiManager::PrintTable
(
MinstrelWifiRemoteStation
*station)
790
{
791
NS_LOG_DEBUG
(
"PrintTable="
<< station);
792
793
for
(uint32_t i = 0; i <
m_nsupported
; i++)
794
{
795
std::cout <<
"index("
<< i <<
") = "
<<
m_minstrelTable
[i].perfectTxTime <<
"\n"
;
796
}
797
}
798
799
}
// namespace ns3
800
801
802
803
804
src
wifi
model
minstrel-wifi-manager.cc
Generated on Tue May 14 2013 11:08:35 for ns-3 by
1.8.1.2