diff --git a/src/devices/mesh/dot11s/airtime-metric.cc b/src/devices/mesh/dot11s/airtime-metric.cc index 13117c53c..706591d19 100644 --- a/src/devices/mesh/dot11s/airtime-metric.cc +++ b/src/devices/mesh/dot11s/airtime-metric.cc @@ -27,10 +27,11 @@ uint32_t AirtimeLinkMetricCalculator::CalculateMetric(Mac48Address peerAddress, Ptr mac) { WifiRemoteStation * station = mac->GetStationManager ()->Lookup(peerAddress); + NS_ASSERT(station != 0); Ptr test_frame = Create (test_length); uint32_t rate = station->GetDataMode(test_frame, test_length+header_length).GetDataRate (); - uint32_t payload_nanosec = (uint32_t)((double)(test_length*8)*1e9 / ((double)rate)); - uint32_t metric = (uint32_t)(((double)(payload_nanosec + overhead_nanosec))/102.4); + uint32_t payload_nanosec = (uint32_t) ((double) (test_length * 8) * 1e9 / ((double)rate)); + uint32_t metric = (uint32_t) (((double) (payload_nanosec + overhead_nanosec)) / 102.4 * (station->GetAvgSlrc () + 1)); return metric; } } //namespace dot11s diff --git a/src/devices/wifi/wifi-remote-station-manager.cc b/src/devices/wifi/wifi-remote-station-manager.cc index 1d0a88482..7d2f2e535 100644 --- a/src/devices/wifi/wifi-remote-station-manager.cc +++ b/src/devices/wifi/wifi-remote-station-manager.cc @@ -421,7 +421,9 @@ WifiRemoteStation::GetTypeId (void) WifiRemoteStation::WifiRemoteStation () : m_state (BRAND_NEW), m_ssrc (0), - m_slrc (0) + m_slrc (0), + m_avgSlrcCoefficient(0.9), + m_avgSlrc (0.0) {} WifiRemoteStation::~WifiRemoteStation () {} @@ -545,7 +547,11 @@ WifiRemoteStation::GetAckMode (WifiMode dataMode) { return GetControlAnswerMode (dataMode); } - +double +WifiRemoteStation::GetAvgSlrc () +{ + return m_avgSlrc; +} uint32_t WifiRemoteStation::GetNSupportedModes (void) const { @@ -700,6 +706,7 @@ WifiRemoteStation::ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr) void WifiRemoteStation::ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr) { + m_avgSlrc = m_avgSlrc * m_avgSlrcCoefficient + (double) m_slrc * (1 - m_avgSlrcCoefficient); m_slrc = 0; DoReportDataOk (ackSnr, ackMode, dataSnr); } diff --git a/src/devices/wifi/wifi-remote-station-manager.h b/src/devices/wifi/wifi-remote-station-manager.h index 00e23f485..8c2edb7b0 100644 --- a/src/devices/wifi/wifi-remote-station-manager.h +++ b/src/devices/wifi/wifi-remote-station-manager.h @@ -257,7 +257,7 @@ public: * handshake. */ WifiMode GetAckMode (WifiMode dataMode); - + double GetAvgSlrc (); private: typedef std::vector SupportedModes; virtual Ptr GetManager (void) const = 0; @@ -286,6 +286,13 @@ private: SupportedModes m_modes; TracedValue m_ssrc; TracedValue m_slrc; + ///\name needed to calculate average SLRC + ///\{ + ///\brief the coefficient: we valculate averages slrc as + //m_avgSlrc = m_avgSlr*coefficient + m_slrc*(1-coefficient); + double m_avgSlrcCoefficient; + double m_avgSlrc; + ///\} }; } // namespace ns3