diff --git a/src/devices/mesh/dot11s/airtime-metric.cc b/src/devices/mesh/dot11s/airtime-metric.cc index eae6cd504..9df8a9c6d 100644 --- a/src/devices/mesh/dot11s/airtime-metric.cc +++ b/src/devices/mesh/dot11s/airtime-metric.cc @@ -87,7 +87,7 @@ AirtimeLinkMetricCalculator::CalculateMetric (Mac48Address peerAddress, PtrGetStationManager ()->GetDataMode (peerAddress, &m_testHeader, m_testFrame, m_testFrame->GetSize ()); //obtain frame error rate: - double failAvg = mac->GetStationManager ()->Lookup (peerAddress, &m_testHeader)->m_state->m_info.GetFrameErrorRate (); + double failAvg = mac->GetStationManager ()->GetInfo (peerAddress).GetFrameErrorRate (); NS_ASSERT (failAvg < 1.0); //calculate metric uint32_t metric = (uint32_t)((double)(/*Overhead + payload*/ diff --git a/src/devices/wifi/wifi-net-device.h b/src/devices/wifi/wifi-net-device.h index 1e9f4fb6d..543c9b0b6 100644 --- a/src/devices/wifi/wifi-net-device.h +++ b/src/devices/wifi/wifi-net-device.h @@ -25,11 +25,11 @@ #include "ns3/packet.h" #include "ns3/traced-callback.h" #include "ns3/mac48-address.h" -#include "wifi-remote-station-manager.h" #include namespace ns3 { +class WifiRemoteStationManager; class WifiChannel; class WifiPhy; class WifiMac; diff --git a/src/devices/wifi/wifi-remote-station-manager.cc b/src/devices/wifi/wifi-remote-station-manager.cc index 571694e68..e300937d6 100644 --- a/src/devices/wifi/wifi-remote-station-manager.cc +++ b/src/devices/wifi/wifi-remote-station-manager.cc @@ -577,6 +577,13 @@ WifiRemoteStationManager::GetAckMode (Mac48Address address, WifiMode dataMode) return GetControlAnswerMode (address, dataMode); } +WifiRemoteStationInfo +WifiRemoteStationManager::GetInfo (Mac48Address address) +{ + struct WifiRemoteStationState *state = LookupState (address); + return state->m_info; +} + WifiRemoteStationState * WifiRemoteStationManager::LookupState (Mac48Address address) const { @@ -752,14 +759,14 @@ WifiRemoteStationInfo::CalculateAveragingCoefficient () void WifiRemoteStationInfo::NotifyTxSuccess (uint32_t retryCounter) { - double coefficient = CalculateAveragingCoeffitient (); + double coefficient = CalculateAveragingCoefficient (); m_failAvg = (double)retryCounter / (1 + (double) retryCounter) * (1.0 - coefficient) + coefficient * m_failAvg; } void WifiRemoteStationInfo::NotifyTxFailed () { - double coefficient = CalculateAveragingCoeffitient (); + double coefficient = CalculateAveragingCoefficient (); m_failAvg = (1.0 - coefficient) + coefficient * m_failAvg; } diff --git a/src/devices/wifi/wifi-remote-station-manager.h b/src/devices/wifi/wifi-remote-station-manager.h index 4054ca13d..f95fa6168 100644 --- a/src/devices/wifi/wifi-remote-station-manager.h +++ b/src/devices/wifi/wifi-remote-station-manager.h @@ -36,6 +36,42 @@ class WifiRemoteStationState; class WifiPhy; class WifiMacHeader; +/** + * \brief Tid independent remote station statistics + * + * Structure is similar to struct sta_info in Linux kernel (see + * net/mac80211/sta_info.h) + */ +class WifiRemoteStationInfo +{ +public: + WifiRemoteStationInfo (); + /** + * \brief Updates average frame error rate when data or RTS + * was transmitted successfully. + * \param retryCounter is slrc or ssrc value at the moment of + * success transmission. + */ + void NotifyTxSuccess (uint32_t retryCounter); + /// Updates average frame error rate when final data or RTS has failed. + void NotifyTxFailed (); + /// Returns frame error rate (probability that frame is corrupted due to transmission error). + double GetFrameErrorRate () const; +private: + /** + * \brief Calculate averaging coefficient for frame error rate. Depends on time of the last update. + * \attention Calling this method twice gives different results, + * because it resets time of last update. + */ + double CalculateAveragingCoefficient (); + ///averaging coefficient depends on the memory time + Time m_memoryTime; + ///when last update has occured + Time m_lastUpdate; + /// moving percentage of failed frames + double m_failAvg; +}; + /** * \brief hold a list of per-remote-station state. * @@ -234,8 +270,8 @@ public: * handshake. */ WifiMode GetAckMode (Mac48Address address, WifiMode dataMode); - /// Find a remote station by its remote address and TID taken from MAC header - WifiRemoteStation *Lookup (Mac48Address address, const WifiMacHeader *header) const; + + WifiRemoteStationInfo GetInfo (Mac48Address address); protected: virtual void DoDispose (void); // for convenience @@ -335,6 +371,8 @@ private: WifiRemoteStationState *LookupState (Mac48Address address) const; WifiRemoteStation *Lookup (Mac48Address address, uint8_t tid) const; + /// Find a remote station by its remote address and TID taken from MAC header + WifiRemoteStation *Lookup (Mac48Address address, const WifiMacHeader *header) const; WifiMode GetControlAnswerMode (Mac48Address address, WifiMode reqMode); uint32_t GetNFragments (Ptr packet); @@ -372,41 +410,6 @@ private: TracedCallback m_macTxFinalDataFailed; }; -/** - * \brief Tid independent remote station statistics - * - * Structure is similar to struct sta_info in Linux kernel (see - * net/mac80211/sta_info.h) - */ -class WifiRemoteStationInfo -{ -public: - WifiRemoteStationInfo (); - /** - * \brief Updates average frame error rate when data or RTS - * was transmitted successfully. - * \param retryCounter is slrc or ssrc value at the moment of - * success transmission. - */ - void NotifyTxSuccess (uint32_t retryCounter); - /// Updates average frame error rate when final data or RTS has failed. - void NotifyTxFailed (); - /// Returns frame error rate (probability that frame is corrupted due to transmission error). - double GetFrameErrorRate () const; -private: - /** - * \brief Calculate averaging coefficient for frame error rate. Depends on time of the last update. - * \attention Calling this method twice gives different results, - * because it resets time of last update. - */ - double CalculateAveragingCoefficient (); - ///averaging coefficient depends on the memory time - Time m_memoryTime; - ///when last update has occured - Time m_lastUpdate; - /// moving percentage of failed frames - double m_failAvg; -}; struct WifiRemoteStationState {