21 #include "rraa-wifi-manager.h"
22 #include "ns3/assert.h"
24 #include "ns3/boolean.h"
25 #include "ns3/double.h"
26 #include "ns3/uinteger.h"
27 #include "ns3/simulator.h"
38 uint32_t m_rtsCounter;
50 RraaWifiManager::GetTypeId (
void)
54 .AddConstructor<RraaWifiManager> ()
55 .AddAttribute (
"Basic",
56 "If true the RRAA-BASIC algorithm will be used, otherwise the RRAA wil be used",
58 MakeBooleanAccessor (&RraaWifiManager::m_basic),
59 MakeBooleanChecker ())
60 .AddAttribute (
"Timeout",
61 "Timeout for the RRAA BASIC loss estimaton block (s)",
63 MakeTimeAccessor (&RraaWifiManager::m_timeout),
65 .AddAttribute (
"ewndFor54mbps",
66 "ewnd parameter for 54 Mbs data mode",
68 MakeUintegerAccessor (&RraaWifiManager::m_ewndfor54),
69 MakeUintegerChecker<uint32_t> ())
70 .AddAttribute (
"ewndFor48mbps",
71 "ewnd parameter for 48 Mbs data mode",
73 MakeUintegerAccessor (&RraaWifiManager::m_ewndfor48),
74 MakeUintegerChecker<uint32_t> ())
75 .AddAttribute (
"ewndFor36mbps",
76 "ewnd parameter for 36 Mbs data mode",
78 MakeUintegerAccessor (&RraaWifiManager::m_ewndfor36),
79 MakeUintegerChecker<uint32_t> ())
80 .AddAttribute (
"ewndFor24mbps",
81 "ewnd parameter for 24 Mbs data mode",
83 MakeUintegerAccessor (&RraaWifiManager::m_ewndfor24),
84 MakeUintegerChecker<uint32_t> ())
85 .AddAttribute (
"ewndFor18mbps",
86 "ewnd parameter for 18 Mbs data mode",
88 MakeUintegerAccessor (&RraaWifiManager::m_ewndfor18),
89 MakeUintegerChecker<uint32_t> ())
90 .AddAttribute (
"ewndFor12mbps",
91 "ewnd parameter for 12 Mbs data mode",
93 MakeUintegerAccessor (&RraaWifiManager::m_ewndfor12),
94 MakeUintegerChecker<uint32_t> ())
95 .AddAttribute (
"ewndFor9mbps",
96 "ewnd parameter for 9 Mbs data mode",
98 MakeUintegerAccessor (&RraaWifiManager::m_ewndfor9),
99 MakeUintegerChecker<uint32_t> ())
100 .AddAttribute (
"ewndFor6mbps",
101 "ewnd parameter for 6 Mbs data mode",
103 MakeUintegerAccessor (&RraaWifiManager::m_ewndfor6),
104 MakeUintegerChecker<uint32_t> ())
105 .AddAttribute (
"poriFor48mbps",
106 "Pori parameter for 48 Mbs data mode",
108 MakeDoubleAccessor (&RraaWifiManager::m_porifor48),
109 MakeDoubleChecker<double> ())
110 .AddAttribute (
"poriFor36mbps",
111 "Pori parameter for 36 Mbs data mode",
113 MakeDoubleAccessor (&RraaWifiManager::m_porifor36),
114 MakeDoubleChecker<double> ())
115 .AddAttribute (
"poriFor24mbps",
116 "Pori parameter for 24 Mbs data mode",
118 MakeDoubleAccessor (&RraaWifiManager::m_porifor24),
119 MakeDoubleChecker<double> ())
120 .AddAttribute (
"poriFor18mbps",
121 "Pori parameter for 18 Mbs data mode",
123 MakeDoubleAccessor (&RraaWifiManager::m_porifor18),
124 MakeDoubleChecker<double> ())
125 .AddAttribute (
"poriFor12mbps",
126 "Pori parameter for 12 Mbs data mode",
128 MakeDoubleAccessor (&RraaWifiManager::m_porifor12),
129 MakeDoubleChecker<double> ())
130 .AddAttribute (
"poriFor9mbps",
131 "Pori parameter for 9 Mbs data mode",
133 MakeDoubleAccessor (&RraaWifiManager::m_porifor9),
134 MakeDoubleChecker<double> ())
135 .AddAttribute (
"poriFor6mbps",
136 "Pori parameter for 6 Mbs data mode",
138 MakeDoubleAccessor (&RraaWifiManager::m_porifor6),
139 MakeDoubleChecker<double> ())
140 .AddAttribute (
"pmtlFor54mbps",
141 "Pmtl parameter for 54 Mbs data mode",
143 MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor54),
144 MakeDoubleChecker<double> ())
145 .AddAttribute (
"pmtlFor48mbps",
146 "Pmtl parameter for 48 Mbs data mode",
148 MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor48),
149 MakeDoubleChecker<double> ())
150 .AddAttribute (
"pmtlFor36mbps",
151 "Pmtl parameter for 36 Mbs data mode",
153 MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor36),
154 MakeDoubleChecker<double> ())
155 .AddAttribute (
"pmtlFor24mbps",
156 "Pmtl parameter for 24 Mbs data mode",
158 MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor24),
159 MakeDoubleChecker<double> ())
160 .AddAttribute (
"pmtlFor18mbps",
161 "Pmtl parameter for 18 Mbs data mode",
163 MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor18),
164 MakeDoubleChecker<double> ())
165 .AddAttribute (
"pmtlFor12mbps",
166 "Pmtl parameter for 12 Mbs data mode",
168 MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor12),
169 MakeDoubleChecker<double> ())
170 .AddAttribute (
"pmtlFor9mbps",
171 "Pmtl parameter for 9 Mbs data mode",
173 MakeDoubleAccessor (&RraaWifiManager::m_pmtlfor9),
174 MakeDoubleChecker<double> ())
180 RraaWifiManager::RraaWifiManager ()
183 RraaWifiManager::~RraaWifiManager ()
192 station->m_initialized =
false;
193 station->m_rtsWnd = 0;
194 station->m_rtsCounter = 0;
195 station->m_rtsOn =
false;
196 station->m_lastFrameFail =
false;
203 if (!station->m_initialized)
205 station->m_rate = GetMaxRate (station);
206 station->m_initialized =
true;
208 station->m_failed = 0;
209 station->m_counter = GetThresholds (station, station->m_rate).ewnd;
214 RraaWifiManager::GetMaxRate (RraaWifiRemoteStation *station)
216 return GetNSupported (station) - 1;
219 RraaWifiManager::GetMinRate (RraaWifiRemoteStation *station)
226 RraaWifiManager::DoReportRtsFailed (WifiRemoteStation *st)
231 RraaWifiManager::DoReportDataFailed (WifiRemoteStation *st)
233 RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st;
234 station->m_lastFrameFail =
true;
235 CheckTimeout (station);
236 station->m_counter--;
238 RunBasicAlgorithm (station);
241 RraaWifiManager::DoReportRxOk (WifiRemoteStation *st,
242 double rxSnr, WifiMode txMode)
246 RraaWifiManager::DoReportRtsOk (WifiRemoteStation *st,
247 double ctsSnr, WifiMode ctsMode,
double rtsSnr)
252 RraaWifiManager::DoReportDataOk (WifiRemoteStation *st,
253 double ackSnr, WifiMode ackMode,
double dataSnr)
255 RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st;
256 station->m_lastFrameFail =
false;
257 CheckTimeout (station);
258 station->m_counter--;
259 RunBasicAlgorithm (station);
262 RraaWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *st)
266 RraaWifiManager::DoReportFinalDataFailed (WifiRemoteStation *st)
275 if (!station->m_initialized)
277 ResetCountersBasic (station);
279 return GetSupported (station, station->m_rate);
284 return GetSupported (st, 0);
297 return station->m_rtsOn;
304 if (station->m_counter == 0 || d > m_timeout)
306 ResetCountersBasic (station);
311 RraaWifiManager::RunBasicAlgorithm (RraaWifiRemoteStation *station)
313 ThresholdsItem thresholds = GetThresholds (station, station->m_rate);
314 double ploss = (double) station->m_failed / (
double) thresholds.ewnd;
315 if (station->m_counter == 0
316 || ploss > thresholds.pmtl)
318 if (station->m_rate > GetMinRate (station)
319 && ploss > thresholds.pmtl)
323 else if (station->m_rate < GetMaxRate (station)
324 && ploss < thresholds.pori)
328 ResetCountersBasic (station);
333 RraaWifiManager::ARts (RraaWifiRemoteStation *station)
335 if (!station->m_rtsOn
336 && station->m_lastFrameFail)
339 station->m_rtsCounter = station->m_rtsWnd;
341 else if ((station->m_rtsOn && station->m_lastFrameFail)
342 || (!station->m_rtsOn && !station->m_lastFrameFail))
344 station->m_rtsWnd = station->m_rtsWnd / 2;
345 station->m_rtsCounter = station->m_rtsWnd;
347 if (station->m_rtsCounter > 0)
349 station->m_rtsOn =
true;
350 station->m_rtsCounter--;
354 station->m_rtsOn =
false;
358 struct RraaWifiManager::ThresholdsItem
359 RraaWifiManager::GetThresholds (RraaWifiRemoteStation *station,
362 WifiMode mode = GetSupported (station, rate);
363 return GetThresholds (mode);
366 struct RraaWifiManager::ThresholdsItem
367 RraaWifiManager::GetThresholds (WifiMode mode) const
369 switch (mode.GetDataRate () / 1000000)
373 ThresholdsItem mode54 = {
383 ThresholdsItem mode48 = {
393 ThresholdsItem mode36 = {
403 ThresholdsItem mode24 = {
413 ThresholdsItem mode18 = {
423 ThresholdsItem mode12 = {
433 ThresholdsItem mode9 = {
443 ThresholdsItem mode6 = {
452 NS_ASSERT_MSG (
false,
"Thresholds for an unknown mode are asked (" << mode <<
")");
453 return ThresholdsItem ();
virtual WifiMode DoGetDataMode(WifiRemoteStation *station, uint32_t size)
#define NS_LOG_COMPONENT_DEFINE(name)
virtual bool DoNeedRts(WifiRemoteStation *st, Ptr< const Packet > packet, bool normally)
virtual bool IsLowLatency(void) const
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
virtual WifiRemoteStation * DoCreateStation(void) const
hold objects of type ns3::Time
Hold an unsigned integer type.
hold a list of per-remote-station state.
Robust Rate Adaptation AlgorithmThis is an implementation of RRAA as described in "Robust rate adapta...
#define NS_ASSERT_MSG(condition, message)
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
#define NS_LOG_DEBUG(msg)
Hold an floating point type.
a unique identifier for an interface.
virtual WifiMode DoGetRtsMode(WifiRemoteStation *station)
TypeId SetParent(TypeId tid)
hold per-remote-station state.