|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |