LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2008 INRIA | 3 * Copyright (c) 2008 INRIA |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 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 | 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 | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> | 18 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
19 */ | 19 */ |
20 | 20 |
21 #include "regular-wifi-mac.h" | 21 #include "regular-wifi-mac.h" |
22 #include "ns3/log.h" | 22 #include "ns3/log.h" |
23 #include "ns3/pointer.h" | 23 #include "ns3/pointer.h" |
24 #include "mac-rx-middle.h" | 24 #include "mac-rx-middle.h" |
25 #include "mac-tx-middle.h" | 25 #include "mac-tx-middle.h" |
26 #include "mac-low.h" | 26 #include "mac-low.h" |
27 #include "dcf-manager.h" | 27 #include "dcf-manager.h" |
28 #include "msdu-standard-aggregator.h" | 28 #include "msdu-aggregator.h" |
29 #include "mpdu-standard-aggregator.h" | 29 #include "mpdu-aggregator.h" |
| 30 #include "wifi-utils.h" |
30 | 31 |
31 namespace ns3 { | 32 namespace ns3 { |
32 | 33 |
33 NS_LOG_COMPONENT_DEFINE ("RegularWifiMac"); | 34 NS_LOG_COMPONENT_DEFINE ("RegularWifiMac"); |
34 | 35 |
35 NS_OBJECT_ENSURE_REGISTERED (RegularWifiMac); | 36 NS_OBJECT_ENSURE_REGISTERED (RegularWifiMac); |
36 | 37 |
37 RegularWifiMac::RegularWifiMac () | 38 RegularWifiMac::RegularWifiMac () |
38 : m_htSupported (0), | 39 : m_htSupported (0), |
39 m_vhtSupported (0), | 40 m_vhtSupported (0), |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 for (EdcaQueues::const_iterator i = m_edca.begin (); i != m_edca.end (); ++i) | 130 for (EdcaQueues::const_iterator i = m_edca.begin (); i != m_edca.end (); ++i) |
130 { | 131 { |
131 i->second->SetWifiRemoteStationManager (stationManager); | 132 i->second->SetWifiRemoteStationManager (stationManager); |
132 } | 133 } |
133 } | 134 } |
134 | 135 |
135 Ptr<WifiRemoteStationManager> | 136 Ptr<WifiRemoteStationManager> |
136 RegularWifiMac::GetWifiRemoteStationManager () const | 137 RegularWifiMac::GetWifiRemoteStationManager () const |
137 { | 138 { |
138 return m_stationManager; | 139 return m_stationManager; |
| 140 } |
| 141 |
| 142 ExtendedCapabilities |
| 143 RegularWifiMac::GetExtendedCapabilities (void) const |
| 144 { |
| 145 NS_LOG_FUNCTION (this); |
| 146 ExtendedCapabilities capabilities; |
| 147 if (m_htSupported || m_vhtSupported) |
| 148 { |
| 149 if (m_htSupported) |
| 150 { |
| 151 capabilities.SetHtSupported (1); |
| 152 } |
| 153 if (m_vhtSupported) |
| 154 { |
| 155 capabilities.SetVhtSupported (1); |
| 156 } |
| 157 } |
| 158 return capabilities; |
139 } | 159 } |
140 | 160 |
141 HtCapabilities | 161 HtCapabilities |
142 RegularWifiMac::GetHtCapabilities (void) const | 162 RegularWifiMac::GetHtCapabilities (void) const |
143 { | 163 { |
144 NS_LOG_FUNCTION (this); | 164 NS_LOG_FUNCTION (this); |
145 HtCapabilities capabilities; | 165 HtCapabilities capabilities; |
146 if (m_htSupported) | 166 if (m_htSupported) |
147 { | 167 { |
148 capabilities.SetHtSupported (1); | 168 capabilities.SetHtSupported (1); |
(...skipping 23 matching lines...) Expand all Loading... |
172 capabilities.SetRxMcsBitmask (mcs.GetMcsValue ()); | 192 capabilities.SetRxMcsBitmask (mcs.GetMcsValue ()); |
173 uint8_t nss = (mcs.GetMcsValue () / 8) + 1; | 193 uint8_t nss = (mcs.GetMcsValue () / 8) + 1; |
174 NS_ASSERT (nss > 0 && nss < 5); | 194 NS_ASSERT (nss > 0 && nss < 5); |
175 uint64_t dataRate = mcs.GetDataRate (m_phy->GetChannelWidth (), m_phy-
>GetShortGuardInterval () ? 400 : 800, nss); | 195 uint64_t dataRate = mcs.GetDataRate (m_phy->GetChannelWidth (), m_phy-
>GetShortGuardInterval () ? 400 : 800, nss); |
176 if (dataRate > maxSupportedRate) | 196 if (dataRate > maxSupportedRate) |
177 { | 197 { |
178 maxSupportedRate = dataRate; | 198 maxSupportedRate = dataRate; |
179 NS_LOG_DEBUG ("Updating maxSupportedRate to " << maxSupportedRate)
; | 199 NS_LOG_DEBUG ("Updating maxSupportedRate to " << maxSupportedRate)
; |
180 } | 200 } |
181 } | 201 } |
182 capabilities.SetRxHighestSupportedDataRate ((uint16_t)(maxSupportedRate /
1e6)); //in Mbit/s | 202 capabilities.SetRxHighestSupportedDataRate (static_cast<uint16_t>(maxSuppo
rtedRate / 1e6)); //in Mbit/s |
183 capabilities.SetTxMcsSetDefined (m_phy->GetNMcs () > 0); | 203 capabilities.SetTxMcsSetDefined (m_phy->GetNMcs () > 0); |
184 capabilities.SetTxMaxNSpatialStreams (m_phy->GetMaxSupportedTxSpatialStrea
ms ()); | 204 capabilities.SetTxMaxNSpatialStreams (m_phy->GetMaxSupportedTxSpatialStrea
ms ()); |
| 205 //we do not support unequal modulations |
| 206 capabilities.SetTxRxMcsSetUnequal (0); |
| 207 capabilities.SetTxUnequalModulation (0); |
185 } | 208 } |
186 return capabilities; | 209 return capabilities; |
187 } | 210 } |
188 | 211 |
189 VhtCapabilities | 212 VhtCapabilities |
190 RegularWifiMac::GetVhtCapabilities (void) const | 213 RegularWifiMac::GetVhtCapabilities (void) const |
191 { | 214 { |
192 NS_LOG_FUNCTION (this); | 215 NS_LOG_FUNCTION (this); |
193 VhtCapabilities capabilities; | 216 VhtCapabilities capabilities; |
194 if (m_vhtSupported) | 217 if (m_vhtSupported) |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 if (mcs.GetModulationClass () != WIFI_MOD_CLASS_VHT || !mcs.IsAllowed
(m_phy->GetChannelWidth (), 1)) | 259 if (mcs.GetModulationClass () != WIFI_MOD_CLASS_VHT || !mcs.IsAllowed
(m_phy->GetChannelWidth (), 1)) |
237 { | 260 { |
238 continue; | 261 continue; |
239 } | 262 } |
240 if (mcs.GetDataRate (m_phy->GetChannelWidth ()) > maxSupportedRateLGI) | 263 if (mcs.GetDataRate (m_phy->GetChannelWidth ()) > maxSupportedRateLGI) |
241 { | 264 { |
242 maxSupportedRateLGI = mcs.GetDataRate (m_phy->GetChannelWidth ()); | 265 maxSupportedRateLGI = mcs.GetDataRate (m_phy->GetChannelWidth ()); |
243 NS_LOG_DEBUG ("Updating maxSupportedRateLGI to " << maxSupportedRa
teLGI); | 266 NS_LOG_DEBUG ("Updating maxSupportedRateLGI to " << maxSupportedRa
teLGI); |
244 } | 267 } |
245 } | 268 } |
246 capabilities.SetRxHighestSupportedLgiDataRate ((uint16_t)(maxSupportedRate
LGI / 1e6)); //in Mbit/s | 269 capabilities.SetRxHighestSupportedLgiDataRate (static_cast<uint16_t>(maxSu
pportedRateLGI / 1e6)); //in Mbit/s |
247 capabilities.SetTxHighestSupportedLgiDataRate ((uint16_t)(maxSupportedRate
LGI / 1e6)); //in Mbit/s | 270 capabilities.SetTxHighestSupportedLgiDataRate (static_cast<uint16_t>(maxSu
pportedRateLGI / 1e6)); //in Mbit/s |
248 //To be filled in once supported | 271 //To be filled in once supported |
249 capabilities.SetRxStbc (0); | 272 capabilities.SetRxStbc (0); |
250 capabilities.SetTxStbc (0); | 273 capabilities.SetTxStbc (0); |
251 } | 274 } |
252 return capabilities; | 275 return capabilities; |
253 } | 276 } |
254 | 277 |
255 HeCapabilities | 278 HeCapabilities |
256 RegularWifiMac::GetHeCapabilities (void) const | 279 RegularWifiMac::GetHeCapabilities (void) const |
257 { | 280 { |
258 NS_LOG_FUNCTION (this); | 281 NS_LOG_FUNCTION (this); |
259 HeCapabilities capabilities; | 282 HeCapabilities capabilities; |
260 if (m_heSupported) | 283 if (m_heSupported) |
261 { | 284 { |
262 capabilities.SetHeSupported (1); | 285 capabilities.SetHeSupported (1); |
263 uint8_t channelWidthSet = 0; | 286 uint8_t channelWidthSet = 0; |
264 if (m_phy->GetChannelWidth () >= 40 && m_phy->Is2_4Ghz (m_phy->GetFrequenc
y ())) | 287 if (m_phy->GetChannelWidth () >= 40 && Is2_4Ghz (m_phy->GetFrequency ())) |
265 { | 288 { |
266 channelWidthSet |= 0x01; | 289 channelWidthSet |= 0x01; |
267 } | 290 } |
268 if (m_phy->GetChannelWidth () >= 80 && m_phy->Is5Ghz (m_phy->GetFrequency
())) | 291 if (m_phy->GetChannelWidth () >= 80 && Is5Ghz (m_phy->GetFrequency ())) |
269 { | 292 { |
270 channelWidthSet |= 0x02; | 293 channelWidthSet |= 0x02; |
271 } | 294 } |
272 if (m_phy->GetChannelWidth () >= 160 && m_phy->Is5Ghz (m_phy->GetFrequency
())) | 295 if (m_phy->GetChannelWidth () >= 160 && Is5Ghz (m_phy->GetFrequency ())) |
273 { | 296 { |
274 channelWidthSet |= 0x04; | 297 channelWidthSet |= 0x04; |
275 } | 298 } |
276 capabilities.SetChannelWidthSet (channelWidthSet); | 299 capabilities.SetChannelWidthSet (channelWidthSet); |
277 uint8_t gi = 0; | 300 uint8_t gi = 0; |
278 if (m_phy->GetGuardInterval () <= NanoSeconds (1600)) | 301 if (m_phy->GetGuardInterval () <= NanoSeconds (1600)) |
279 { | 302 { |
280 //todo: We assume for now that if we support 800ns GI then 1600ns GI i
s supported as well | 303 //todo: We assume for now that if we support 800ns GI then 1600ns GI i
s supported as well |
281 gi |= 0x01; | 304 gi |= 0x01; |
282 } | 305 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 RegularWifiMac::SetBkMaxAmpduSize (uint32_t size) | 391 RegularWifiMac::SetBkMaxAmpduSize (uint32_t size) |
369 { | 392 { |
370 NS_LOG_FUNCTION (this << size); | 393 NS_LOG_FUNCTION (this << size); |
371 m_bkMaxAmpduSize = size; | 394 m_bkMaxAmpduSize = size; |
372 ConfigureAggregation (); | 395 ConfigureAggregation (); |
373 } | 396 } |
374 | 397 |
375 void | 398 void |
376 RegularWifiMac::SetVoBlockAckThreshold (uint8_t threshold) | 399 RegularWifiMac::SetVoBlockAckThreshold (uint8_t threshold) |
377 { | 400 { |
378 NS_LOG_FUNCTION (this << (uint16_t) threshold); | 401 NS_LOG_FUNCTION (this << static_cast<uint16_t> (threshold)); |
379 GetVOQueue ()->SetBlockAckThreshold (threshold); | 402 GetVOQueue ()->SetBlockAckThreshold (threshold); |
380 } | 403 } |
381 | 404 |
382 void | 405 void |
383 RegularWifiMac::SetViBlockAckThreshold (uint8_t threshold) | 406 RegularWifiMac::SetViBlockAckThreshold (uint8_t threshold) |
384 { | 407 { |
385 NS_LOG_FUNCTION (this << (uint16_t) threshold); | 408 NS_LOG_FUNCTION (this << static_cast<uint16_t> (threshold)); |
386 GetVIQueue ()->SetBlockAckThreshold (threshold); | 409 GetVIQueue ()->SetBlockAckThreshold (threshold); |
387 } | 410 } |
388 | 411 |
389 void | 412 void |
390 RegularWifiMac::SetBeBlockAckThreshold (uint8_t threshold) | 413 RegularWifiMac::SetBeBlockAckThreshold (uint8_t threshold) |
391 { | 414 { |
392 NS_LOG_FUNCTION (this << (uint16_t) threshold); | 415 NS_LOG_FUNCTION (this << static_cast<uint16_t> (threshold)); |
393 GetBEQueue ()->SetBlockAckThreshold (threshold); | 416 GetBEQueue ()->SetBlockAckThreshold (threshold); |
394 } | 417 } |
395 | 418 |
396 void | 419 void |
397 RegularWifiMac::SetBkBlockAckThreshold (uint8_t threshold) | 420 RegularWifiMac::SetBkBlockAckThreshold (uint8_t threshold) |
398 { | 421 { |
399 NS_LOG_FUNCTION (this << (uint16_t) threshold); | 422 NS_LOG_FUNCTION (this << static_cast<uint16_t> (threshold)); |
400 GetBKQueue ()->SetBlockAckThreshold (threshold); | 423 GetBKQueue ()->SetBlockAckThreshold (threshold); |
401 } | 424 } |
402 | 425 |
403 void | 426 void |
404 RegularWifiMac::SetVoBlockAckInactivityTimeout (uint16_t timeout) | 427 RegularWifiMac::SetVoBlockAckInactivityTimeout (uint16_t timeout) |
405 { | 428 { |
406 NS_LOG_FUNCTION (this << timeout); | 429 NS_LOG_FUNCTION (this << timeout); |
407 GetVOQueue ()->SetBlockAckInactivityTimeout (timeout); | 430 GetVOQueue ()->SetBlockAckInactivityTimeout (timeout); |
408 } | 431 } |
409 | 432 |
(...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1319 NS_LOG_FUNCTION (this << hdr); | 1342 NS_LOG_FUNCTION (this << hdr); |
1320 m_txErrCallback (hdr); | 1343 m_txErrCallback (hdr); |
1321 } | 1344 } |
1322 | 1345 |
1323 void | 1346 void |
1324 RegularWifiMac::ConfigureAggregation (void) | 1347 RegularWifiMac::ConfigureAggregation (void) |
1325 { | 1348 { |
1326 NS_LOG_FUNCTION (this); | 1349 NS_LOG_FUNCTION (this); |
1327 if (GetVOQueue ()->GetMsduAggregator () != 0) | 1350 if (GetVOQueue ()->GetMsduAggregator () != 0) |
1328 { | 1351 { |
1329 GetVOQueue ()->GetMsduAggregator ()->SetMaxAmsduSize (m_voMaxAmsduSize); | 1352 GetVOQueue ()->GetMsduAggregator ()->SetMaxAmsduSize (static_cast<uint16_t
>(m_voMaxAmsduSize)); |
1330 } | 1353 } |
1331 if (GetVIQueue ()->GetMsduAggregator () != 0) | 1354 if (GetVIQueue ()->GetMsduAggregator () != 0) |
1332 { | 1355 { |
1333 GetVIQueue ()->GetMsduAggregator ()->SetMaxAmsduSize (m_viMaxAmsduSize); | 1356 GetVIQueue ()->GetMsduAggregator ()->SetMaxAmsduSize (static_cast<uint16_t
>(m_viMaxAmsduSize)); |
1334 } | 1357 } |
1335 if (GetBEQueue ()->GetMsduAggregator () != 0) | 1358 if (GetBEQueue ()->GetMsduAggregator () != 0) |
1336 { | 1359 { |
1337 GetBEQueue ()->GetMsduAggregator ()->SetMaxAmsduSize (m_beMaxAmsduSize); | 1360 GetBEQueue ()->GetMsduAggregator ()->SetMaxAmsduSize (static_cast<uint16_t
>(m_beMaxAmsduSize)); |
1338 } | 1361 } |
1339 if (GetBKQueue ()->GetMsduAggregator () != 0) | 1362 if (GetBKQueue ()->GetMsduAggregator () != 0) |
1340 { | 1363 { |
1341 GetBKQueue ()->GetMsduAggregator ()->SetMaxAmsduSize (m_bkMaxAmsduSize); | 1364 GetBKQueue ()->GetMsduAggregator ()->SetMaxAmsduSize (static_cast<uint16_t
>(m_bkMaxAmsduSize)); |
1342 } | 1365 } |
1343 if (GetVOQueue ()->GetMpduAggregator () != 0) | 1366 if (GetVOQueue ()->GetMpduAggregator () != 0) |
1344 { | 1367 { |
1345 GetVOQueue ()->GetMpduAggregator ()->SetMaxAmpduSize (m_voMaxAmpduSize); | 1368 GetVOQueue ()->GetMpduAggregator ()->SetMaxAmpduSize (static_cast<uint16_t
>(m_voMaxAmpduSize)); |
1346 } | 1369 } |
1347 if (GetVIQueue ()->GetMpduAggregator () != 0) | 1370 if (GetVIQueue ()->GetMpduAggregator () != 0) |
1348 { | 1371 { |
1349 GetVIQueue ()->GetMpduAggregator ()->SetMaxAmpduSize (m_viMaxAmpduSize); | 1372 GetVIQueue ()->GetMpduAggregator ()->SetMaxAmpduSize (static_cast<uint16_t
>(m_viMaxAmpduSize)); |
1350 } | 1373 } |
1351 if (GetBEQueue ()->GetMpduAggregator () != 0) | 1374 if (GetBEQueue ()->GetMpduAggregator () != 0) |
1352 { | 1375 { |
1353 GetBEQueue ()->GetMpduAggregator ()->SetMaxAmpduSize (m_beMaxAmpduSize); | 1376 GetBEQueue ()->GetMpduAggregator ()->SetMaxAmpduSize (static_cast<uint16_t
>(m_beMaxAmpduSize)); |
1354 } | 1377 } |
1355 if (GetBKQueue ()->GetMpduAggregator () != 0) | 1378 if (GetBKQueue ()->GetMpduAggregator () != 0) |
1356 { | 1379 { |
1357 GetBKQueue ()->GetMpduAggregator ()->SetMaxAmpduSize (m_bkMaxAmpduSize); | 1380 GetBKQueue ()->GetMpduAggregator ()->SetMaxAmpduSize (static_cast<uint16_t
>(m_bkMaxAmpduSize)); |
1358 } | 1381 } |
1359 } | 1382 } |
1360 | 1383 |
1361 void | 1384 void |
1362 RegularWifiMac::EnableAggregation (void) | 1385 RegularWifiMac::EnableAggregation (void) |
1363 { | 1386 { |
1364 NS_LOG_FUNCTION (this); | 1387 NS_LOG_FUNCTION (this); |
1365 for (EdcaQueues::const_iterator i = m_edca.begin (); i != m_edca.end (); ++i) | 1388 for (EdcaQueues::const_iterator i = m_edca.begin (); i != m_edca.end (); ++i) |
1366 { | 1389 { |
1367 if (i->second->GetMsduAggregator () == 0) | 1390 if (i->second->GetMsduAggregator () == 0) |
1368 { | 1391 { |
1369 Ptr<MsduStandardAggregator> msduAggregator = CreateObject<MsduStandard
Aggregator> (); | 1392 Ptr<MsduAggregator> msduAggregator = CreateObject<MsduAggregator> (); |
1370 i->second->SetMsduAggregator (msduAggregator); | 1393 i->second->SetMsduAggregator (msduAggregator); |
1371 } | 1394 } |
1372 if (i->second->GetMpduAggregator () == 0) | 1395 if (i->second->GetMpduAggregator () == 0) |
1373 { | 1396 { |
1374 Ptr<MpduStandardAggregator> mpduAggregator = CreateObject<MpduStandard
Aggregator> (); | 1397 Ptr<MpduAggregator> mpduAggregator = CreateObject<MpduAggregator> (); |
1375 i->second->SetMpduAggregator (mpduAggregator); | 1398 i->second->SetMpduAggregator (mpduAggregator); |
1376 } | 1399 } |
1377 } | 1400 } |
1378 ConfigureAggregation (); | 1401 ConfigureAggregation (); |
1379 } | 1402 } |
1380 | 1403 |
1381 void | 1404 void |
1382 RegularWifiMac::DisableAggregation (void) | 1405 RegularWifiMac::DisableAggregation (void) |
1383 { | 1406 { |
1384 NS_LOG_FUNCTION (this); | 1407 NS_LOG_FUNCTION (this); |
1385 for (EdcaQueues::const_iterator i = m_edca.begin (); i != m_edca.end (); ++i) | 1408 for (EdcaQueues::const_iterator i = m_edca.begin (); i != m_edca.end (); ++i) |
1386 { | 1409 { |
1387 i->second->SetMsduAggregator (0); | 1410 i->second->SetMsduAggregator (0); |
1388 i->second->SetMpduAggregator (0); | 1411 i->second->SetMpduAggregator (0); |
1389 } | 1412 } |
1390 } | 1413 } |
1391 | 1414 |
1392 } //namespace ns3 | 1415 } //namespace ns3 |
LEFT | RIGHT |