tweak slightly
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu, 25 Feb 2010 15:16:53 +0100
changeset 6071 6a25c600c450
parent 6070 a971811bb21a
child 6072 75b3002b9b4d
tweak slightly
src/devices/mesh/dot11s/airtime-metric.cc
src/devices/wifi/wifi-net-device.h
src/devices/wifi/wifi-remote-station-manager.cc
src/devices/wifi/wifi-remote-station-manager.h
--- a/src/devices/mesh/dot11s/airtime-metric.cc	Thu Feb 25 14:58:23 2010 +0100
+++ b/src/devices/mesh/dot11s/airtime-metric.cc	Thu Feb 25 15:16:53 2010 +0100
@@ -87,7 +87,7 @@
   //obtain current rate:
   WifiMode mode = mac->GetStationManager ()->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*/
--- a/src/devices/wifi/wifi-net-device.h	Thu Feb 25 14:58:23 2010 +0100
+++ b/src/devices/wifi/wifi-net-device.h	Thu Feb 25 15:16:53 2010 +0100
@@ -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 <string>
 
 namespace ns3 {
 
+class WifiRemoteStationManager;
 class WifiChannel;
 class WifiPhy;
 class WifiMac;
--- a/src/devices/wifi/wifi-remote-station-manager.cc	Thu Feb 25 14:58:23 2010 +0100
+++ b/src/devices/wifi/wifi-remote-station-manager.cc	Thu Feb 25 15:16:53 2010 +0100
@@ -577,6 +577,13 @@
   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 @@
 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;
 }
 
--- a/src/devices/wifi/wifi-remote-station-manager.h	Thu Feb 25 14:58:23 2010 +0100
+++ b/src/devices/wifi/wifi-remote-station-manager.h	Thu Feb 25 15:16:53 2010 +0100
@@ -37,6 +37,42 @@
 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.
  *
  * \sa ns3::WifiRemoteStation.
@@ -234,8 +270,8 @@
    *          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 @@
 
   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<const Packet> packet);
 
@@ -372,41 +410,6 @@
   TracedCallback<Mac48Address> 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
 {