tweak slightly

This commit is contained in:
Mathieu Lacage committed 2010-02-25 15:16:53 +01:00
1 parent f5ceee4b8e
commit cfda5b1d27
4 files changed
+51 -41

No files matched your search

+1 -1
View File
@@ -87,7 +87,7 @@ AirtimeLinkMetricCalculator::CalculateMetric (Mac48Address peerAddress, Ptr<Mesh
//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*/
+1 -1
View File
@@ -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;
@@ -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;
}
+40 -37
View File
@@ -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<const Packet> packet);
@@ -372,41 +410,6 @@ private:
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
{