From da41f6dd64dbe5550942b595334d15a2ab48f3fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Sat, 5 Sep 2015 12:00:44 +0200 Subject: [PATCH] Remove unnecessary if conditions in ap-wifi-mac and sta-wifi-mac --- src/wifi/model/ap-wifi-mac.cc | 28 ++++------------------------ src/wifi/model/sta-wifi-mac.cc | 16 +++------------- 2 files changed, 7 insertions(+), 37 deletions(-) diff --git a/src/wifi/model/ap-wifi-mac.cc b/src/wifi/model/ap-wifi-mac.cc index 1a166fbc6..6703f9586 100644 --- a/src/wifi/model/ap-wifi-mac.cc +++ b/src/wifi/model/ap-wifi-mac.cc @@ -315,12 +315,7 @@ ApWifiMac::GetSupportedRates (void) const for (uint32_t i = 0; i < m_phy->GetNModes (); i++) { WifiMode mode = m_phy->GetMode (i); - uint32_t channelWidth = m_phy->GetChannelWidth (); - if (channelWidth >= 40) - { - channelWidth = 20; - } - rates.AddSupportedRate (mode.GetDataRate (channelWidth, false, 1)); + rates.AddSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth (), false, 1)); //Add rates that are part of the BSSBasicRateSet (manufacturer dependent!) //here we choose to add the mandatory rates to the BSSBasicRateSet, //exept for 802.11b where we assume that only the non HR-DSSS rates are part of the BSSBasicRateSet @@ -333,12 +328,7 @@ ApWifiMac::GetSupportedRates (void) const for (uint32_t j = 0; j < m_stationManager->GetNBasicModes (); j++) { WifiMode mode = m_stationManager->GetBasicMode (j); - uint32_t channelWidth = m_phy->GetChannelWidth (); - if (channelWidth >= 40) - { - channelWidth = 20; - } - rates.SetBasicRate (mode.GetDataRate (channelWidth, false, 1)); + rates.SetBasicRate (mode.GetDataRate (m_phy->GetChannelWidth (), false, 1)); } return rates; @@ -645,12 +635,7 @@ ApWifiMac::Receive (Ptr packet, const WifiMacHeader *hdr) for (uint32_t i = 0; i < m_stationManager->GetNBasicModes (); i++) { WifiMode mode = m_stationManager->GetBasicMode (i); - uint32_t channelWidth = m_phy->GetChannelWidth (); - if (channelWidth >= 40) - { - channelWidth = 20; - } - if (!rates.IsSupportedRate (mode.GetDataRate (channelWidth, false, 1))) + if (!rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth (), false, 1))) { problem = true; break; @@ -698,12 +683,7 @@ ApWifiMac::Receive (Ptr packet, const WifiMacHeader *hdr) for (uint32_t j = 0; j < m_phy->GetNModes (); j++) { WifiMode mode = m_phy->GetMode (j); - uint32_t channelWidth = m_phy->GetChannelWidth (); - if (channelWidth >= 40) - { - channelWidth = 20; - } - if (rates.IsSupportedRate (mode.GetDataRate (channelWidth, false, 1))) + if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth (), false, 1))) { m_stationManager->AddSupportedMode (from, mode); } diff --git a/src/wifi/model/sta-wifi-mac.cc b/src/wifi/model/sta-wifi-mac.cc index 5bfa0b9da..dce8ce634 100644 --- a/src/wifi/model/sta-wifi-mac.cc +++ b/src/wifi/model/sta-wifi-mac.cc @@ -581,15 +581,10 @@ StaWifiMac::Receive (Ptr packet, const WifiMacHeader *hdr) for (uint32_t i = 0; i < m_phy->GetNModes (); i++) { WifiMode mode = m_phy->GetMode (i); - uint32_t channelWidth = m_phy->GetChannelWidth (); - if (channelWidth >= 40) - { - channelWidth = 20; - } - if (rates.IsSupportedRate (mode.GetDataRate (channelWidth, false, 1))) + if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth (), false, 1))) { m_stationManager->AddSupportedMode (hdr->GetAddr2 (), mode); - if (rates.IsBasicRate (mode.GetDataRate (channelWidth, false, 1))) + if (rates.IsBasicRate (mode.GetDataRate (m_phy->GetChannelWidth (), false, 1))) { m_stationManager->AddBasicMode (mode); } @@ -655,12 +650,7 @@ StaWifiMac::GetSupportedRates (void) const for (uint32_t i = 0; i < m_phy->GetNModes (); i++) { WifiMode mode = m_phy->GetMode (i); - uint32_t channelWidth = m_phy->GetChannelWidth (); - if (channelWidth >= 40) - { - channelWidth = 20; - } - rates.AddSupportedRate (mode.GetDataRate (channelWidth, false, 1)); + rates.AddSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth (), false, 1)); } return rates; }