From 58c4f13f59ff50e76362db4908fc06ebc30feed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Wed, 9 Mar 2016 20:32:05 +0100 Subject: [PATCH] wifi: (fixes #2327) CWmin value selection based on 802.11g standard rules --- RELEASE_NOTES | 1 + examples/wireless/mixed-bg-network.cc | 14 ++--- src/wifi/model/ap-wifi-mac.cc | 6 +- src/wifi/model/regular-wifi-mac.cc | 7 +-- src/wifi/model/sta-wifi-mac.cc | 83 +++++++++++++++++---------- 5 files changed, 67 insertions(+), 44 deletions(-) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index abc3d4575..235ddff9b 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -123,6 +123,7 @@ Bugs fixed - Bug 2318 - MPDU Aggregation fails with TCP - Bug 2319 - BlockAckTimeout value is too low for 802.11n operating at 2.4 GHz - Bug 2321 - Wifi rate managers should not be triggered for each MPDU when A-MPDU is used +- Bug 2327 - CWmin value selection for 802.11g is not compliant with the standard rules Known issues ------------ diff --git a/examples/wireless/mixed-bg-network.cc b/examples/wireless/mixed-bg-network.cc index 3b4155878..5bb0911a8 100644 --- a/examples/wireless/mixed-bg-network.cc +++ b/examples/wireless/mixed-bg-network.cc @@ -235,7 +235,7 @@ int main (int argc, char *argv[]) std::cout << "Protection mode" << "\t\t" << "Slot time supported" << "\t\t" << "PLCP preamble supported" << "\t\t" << "Scenario" << "\t" << "Throughput" << std::endl; throughput = experiment.Run (false, false, false, false, isUdp, payloadSize, simulationTime); - if (throughput < 17 || throughput > 18) + if (throughput < 23 || throughput > 24) { NS_LOG_ERROR ("Obtained throughput is not in the expected boundaries!"); exit (1); @@ -251,7 +251,7 @@ int main (int argc, char *argv[]) std::cout << "Disabled" << "\t\t" << "Short" << "\t\t\t\t" << "Long" << "\t\t\t\t" << "G-only" << "\t\t" << throughput <<" Mbit/s" << std::endl; throughput = experiment.Run (false, false, false, true, isUdp, payloadSize, simulationTime); - if (throughput < 17 || throughput > 18) + if (throughput < 23 || throughput > 24) { NS_LOG_ERROR ("Obtained throughput is not in the expected boundaries!"); exit (1); @@ -259,7 +259,7 @@ int main (int argc, char *argv[]) std::cout << "Disabled" << "\t\t" << "Long" << "\t\t\t\t" << "Long" << "\t\t\t\t" << "Mixed" << "\t\t" << throughput <<" Mbit/s" << std::endl; throughput = experiment.Run (false, false, true, true, isUdp, payloadSize, simulationTime); - if (throughput < 17 || throughput > 18) + if (throughput < 23 || throughput > 24) { NS_LOG_ERROR ("Obtained throughput is not in the expected boundaries!"); exit (1); @@ -269,7 +269,7 @@ int main (int argc, char *argv[]) Config::SetDefault ("ns3::WifiRemoteStationManager::ProtectionMode", StringValue ("Rts-Cts")); throughput = experiment.Run (true, false, false, true, isUdp, payloadSize, simulationTime); - if (throughput < 9 || throughput > 10) + if (throughput < 11 || throughput > 12) { NS_LOG_ERROR ("Obtained throughput is not in the expected boundaries!"); exit (1); @@ -277,7 +277,7 @@ int main (int argc, char *argv[]) std::cout << "RTS/CTS" << "\t\t\t" << "Long" << "\t\t\t\t" << "Long" << "\t\t\t\t" << "Mixed" << "\t\t" << throughput <<" Mbit/s" << std::endl; throughput = experiment.Run (true, false, true, true, isUdp, payloadSize, simulationTime); - if (throughput < 11 || throughput > 12) + if (throughput < 13 || throughput > 14) { NS_LOG_ERROR ("Obtained throughput is not in the expected boundaries!"); exit (1); @@ -287,7 +287,7 @@ int main (int argc, char *argv[]) Config::SetDefault ("ns3::WifiRemoteStationManager::ProtectionMode", StringValue ("Cts-To-Self")); throughput = experiment.Run (true, false, false, true, isUdp, payloadSize, simulationTime); - if (throughput < 12 || throughput > 13) + if (throughput < 15 || throughput > 16) { NS_LOG_ERROR ("Obtained throughput is not in the expected boundaries!"); exit (1); @@ -295,7 +295,7 @@ int main (int argc, char *argv[]) std::cout << "CTS-TO-SELF" << "\t\t" << "Long" << "\t\t\t\t" << "Long" << "\t\t\t\t" << "Mixed" << "\t\t" << throughput <<" Mbit/s" << std::endl; throughput = experiment.Run (true, false, true, true, isUdp, payloadSize, simulationTime); - if (throughput < 14 || throughput > 15) + if (throughput < 17 || throughput > 18) { NS_LOG_ERROR ("Obtained throughput is not in the expected boundaries!"); exit (1); diff --git a/src/wifi/model/ap-wifi-mac.cc b/src/wifi/model/ap-wifi-mac.cc index b5e9105fc..3243cbbaa 100644 --- a/src/wifi/model/ap-wifi-mac.cc +++ b/src/wifi/model/ap-wifi-mac.cc @@ -577,15 +577,13 @@ ApWifiMac::SendOneBeacon (void) { if (GetShortSlotTimeEnabled () == true) { - //Enable short slot time and set cwMin to 15 + //Enable short slot time SetSlot (MicroSeconds (9)); - ConfigureContentionWindow (15, 1023); } else { - //Disable short slot time and set CWmin to 31 + //Disable short slot time SetSlot (MicroSeconds (20)); - ConfigureContentionWindow (31, 1023); } } } diff --git a/src/wifi/model/regular-wifi-mac.cc b/src/wifi/model/regular-wifi-mac.cc index e1c02169a..b79e897e8 100644 --- a/src/wifi/model/regular-wifi-mac.cc +++ b/src/wifi/model/regular-wifi-mac.cc @@ -1091,7 +1091,10 @@ RegularWifiMac::FinishConfigureStandard (enum WifiPhyStandard standard) case WIFI_PHY_STANDARD_80211ac: SetVhtSupported (true); case WIFI_PHY_STANDARD_80211n_5GHZ: + case WIFI_PHY_STANDARD_80211n_2_4GHZ: SetHtSupported (true); + case WIFI_PHY_STANDARD_80211g: + m_erpSupported = true; case WIFI_PHY_STANDARD_holland: case WIFI_PHY_STANDARD_80211a: case WIFI_PHY_STANDARD_80211_10MHZ: @@ -1099,10 +1102,6 @@ RegularWifiMac::FinishConfigureStandard (enum WifiPhyStandard standard) cwmin = 15; cwmax = 1023; break; - case WIFI_PHY_STANDARD_80211n_2_4GHZ: - SetHtSupported (true); - case WIFI_PHY_STANDARD_80211g: - m_erpSupported = true; case WIFI_PHY_STANDARD_80211b: cwmin = 31; cwmax = 1023; diff --git a/src/wifi/model/sta-wifi-mac.cc b/src/wifi/model/sta-wifi-mac.cc index 88d51e0c6..1ae2ca0e8 100644 --- a/src/wifi/model/sta-wifi-mac.cc +++ b/src/wifi/model/sta-wifi-mac.cc @@ -530,15 +530,13 @@ StaWifiMac::Receive (Ptr packet, const WifiMacHeader *hdr) } if (capabilities.IsShortSlotTime () == true) { - //enable short slot time and set cwMin to 15 + //enable short slot time SetSlot (MicroSeconds (9)); - ConfigureContentionWindow (15, 1023); } else { - //disable short slot time and set cwMin to 31 + //disable short slot time SetSlot (MicroSeconds (20)); - ConfigureContentionWindow (31, 1023); } } m_stationManager->SetShortPreambleEnabled (isShortPreambleEnabled); @@ -589,27 +587,37 @@ StaWifiMac::Receive (Ptr packet, const WifiMacHeader *hdr) bool isShortPreambleEnabled = capabilities.IsShortPreamble (); if (m_erpSupported) { - ErpInformation erpInformation = probeResp.GetErpInformation (); - if (erpInformation.GetUseProtection() == true) - { - m_stationManager->SetUseNonErpProtection (true); - } - else - { - m_stationManager->SetUseNonErpProtection (false); - } - if (capabilities.IsShortSlotTime () == true) - { - //enable short slot time and set cwMin to 15 - SetSlot (MicroSeconds (9)); - ConfigureContentionWindow (15, 1023); - } - else + bool isErpAllowed = false; + for (uint32_t i = 0; i < m_phy->GetNModes (); i++) + { + WifiMode mode = m_phy->GetMode (i); + if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM && rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth (), false, 1))) + { + isErpAllowed = true; + break; + } + } + if (!isErpAllowed) { //disable short slot time and set cwMin to 31 SetSlot (MicroSeconds (20)); ConfigureContentionWindow (31, 1023); } + else + { + ErpInformation erpInformation = probeResp.GetErpInformation (); + isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode (); + if (m_stationManager->GetShortSlotTimeEnabled ()) + { + //enable short slot time + SetSlot (MicroSeconds (9)); + } + else + { + //disable short slot time + SetSlot (MicroSeconds (20)); + } + } } m_stationManager->SetShortPreambleEnabled (isShortPreambleEnabled); m_stationManager->SetShortSlotTimeEnabled (capabilities.IsShortSlotTime ()); @@ -644,20 +652,37 @@ StaWifiMac::Receive (Ptr packet, const WifiMacHeader *hdr) bool isShortPreambleEnabled = capabilities.IsShortPreamble (); if (m_erpSupported) { - ErpInformation erpInformation = assocResp.GetErpInformation (); - isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode (); - if (m_stationManager->GetShortSlotTimeEnabled ()) - { - //enable short slot time and set cwMin to 15 - SetSlot (MicroSeconds (9)); - ConfigureContentionWindow (15, 1023); - } - else + bool isErpAllowed = false; + for (uint32_t i = 0; i < m_phy->GetNModes (); i++) + { + WifiMode mode = m_phy->GetMode (i); + if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM && rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth (), false, 1))) + { + isErpAllowed = true; + break; + } + } + if (!isErpAllowed) { //disable short slot time and set cwMin to 31 SetSlot (MicroSeconds (20)); ConfigureContentionWindow (31, 1023); } + else + { + ErpInformation erpInformation = assocResp.GetErpInformation (); + isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode (); + if (m_stationManager->GetShortSlotTimeEnabled ()) + { + //enable short slot time + SetSlot (MicroSeconds (9)); + } + else + { + //disable short slot time + SetSlot (MicroSeconds (20)); + } + } } m_stationManager->SetShortPreambleEnabled (isShortPreambleEnabled); m_stationManager->SetShortSlotTimeEnabled (capabilities.IsShortSlotTime ());