diff --git a/src/wifi/examples/wifi-manager-example.cc b/src/wifi/examples/wifi-manager-example.cc index ece206433..1d9dc2e0f 100644 --- a/src/wifi/examples/wifi-manager-example.cc +++ b/src/wifi/examples/wifi-manager-example.cc @@ -80,13 +80,6 @@ RateChange (uint64_t oldVal, uint64_t newVal) g_intervalRate = newVal; } -void -RateChangeMinstrelHt (uint64_t newVal, Mac48Address dest) -{ - NS_LOG_DEBUG ("Change to " << newVal); - g_intervalRate = newVal; -} - /// Step structure struct Step { @@ -383,14 +376,8 @@ int main (int argc, char *argv[]) wifi.AssignStreams (serverDevice, 100); wifi.AssignStreams (clientDevice, 100); - if (wifiManager == "MinstrelHt") - { - Config::ConnectWithoutContext ("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/RemoteStationManager/$ns3::MinstrelHtWifiManager/RateChange", MakeCallback (&RateChangeMinstrelHt)); - } - else - { - Config::ConnectWithoutContext ("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/RemoteStationManager/$ns3::" + wifiManager + "WifiManager/Rate", MakeCallback (&RateChange)); - } + Config::ConnectWithoutContext ("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/RemoteStationManager/$ns3::" + wifiManager + "WifiManager/Rate", MakeCallback (&RateChange)); + // Configure the mobility. MobilityHelper mobility; Ptr positionAlloc = CreateObject (); diff --git a/src/wifi/model/minstrel-ht-wifi-manager.cc b/src/wifi/model/minstrel-ht-wifi-manager.cc index 7db608b25..785f4a268 100644 --- a/src/wifi/model/minstrel-ht-wifi-manager.cc +++ b/src/wifi/model/minstrel-ht-wifi-manager.cc @@ -114,17 +114,18 @@ MinstrelHtWifiManager::GetTypeId (void) BooleanValue (false), MakeBooleanAccessor (&MinstrelHtWifiManager::m_printStats), MakeBooleanChecker ()) - .AddTraceSource ("RateChange", - "The transmission rate has changed", - MakeTraceSourceAccessor (&MinstrelHtWifiManager::m_rateChange), - "ns3::MinstrelHtWifiManager::RateChangeTracedCallback") + .AddTraceSource ("Rate", + "Traced value for rate changes (b/s)", + MakeTraceSourceAccessor (&MinstrelHtWifiManager::m_currentRate), + "ns3::TracedValueCallback::Uint64") ; return tid; } MinstrelHtWifiManager::MinstrelHtWifiManager () : m_numGroups (0), - m_numRates (0) + m_numRates (0), + m_currentRate (0) { NS_LOG_FUNCTION (this); m_uniformRandomVariable = CreateObject (); @@ -841,13 +842,12 @@ MinstrelHtWifiManager::DoGetDataTxVector (WifiRemoteStation *st) if (!station->m_isHt) { WifiTxVector vector = m_legacyManager->GetDataTxVector (station); - uint64_t dataRate = vector.GetMode ().GetDataRate (vector); - if (!station->m_isSampling) + if (m_currentRate != dataRate && !station->m_isSampling) { - m_rateChange (dataRate, station->m_state->m_address); + NS_LOG_DEBUG ("New datarate: " << dataRate); + m_currentRate = dataRate; } - return vector; } else @@ -870,13 +870,13 @@ MinstrelHtWifiManager::DoGetDataTxVector (WifiRemoteStation *st) " Station capabilities: (" << GetNumberOfSupportedStreams (station) << "," << GetShortGuardInterval (station) << "," << GetChannelWidth (station) << ")"); } - - uint64_t dataRate = GetMcsSupported (station, mcsIndex).GetDataRate (group.chWidth, group.sgi ? 400 : 800, group.streams); - if (!station->m_isSampling) - { - m_rateChange (dataRate, station->m_state->m_address); - } WifiMode mode = GetMcsSupported (station, mcsIndex); + uint64_t dataRate = mode.GetDataRate (group.chWidth, group.sgi ? 400 : 800, group.streams); + if (m_currentRate != dataRate && !station->m_isSampling) + { + NS_LOG_DEBUG ("New datarate: " << dataRate); + m_currentRate = dataRate; + } return WifiTxVector (mode, GetDefaultTxPowerLevel (), GetPreambleForTransmission (mode, GetAddress (station)), group.sgi ? 400 : 800, GetNumberOfAntennas (), group.streams, GetNess (station), GetChannelWidthForTransmission (mode, group.chWidth), GetAggregation (station) && !station->m_isSampling, false); } } diff --git a/src/wifi/model/minstrel-ht-wifi-manager.h b/src/wifi/model/minstrel-ht-wifi-manager.h index 29a967296..3cfab003e 100644 --- a/src/wifi/model/minstrel-ht-wifi-manager.h +++ b/src/wifi/model/minstrel-ht-wifi-manager.h @@ -602,10 +602,7 @@ private: Ptr m_uniformRandomVariable; //!< Provides uniform random variables. - /** - * The trace source fired when the transmission rate change. - */ - TracedCallback m_rateChange; + TracedValue m_currentRate; //!< Trace rate changes }; } // namespace ns3