21 #include "ideal-wifi-manager.h"
23 #include "ns3/assert.h"
24 #include "ns3/double.h"
37 IdealWifiManager::GetTypeId (
void)
41 .AddConstructor<IdealWifiManager> ()
42 .AddAttribute (
"BerThreshold",
43 "The maximum Bit Error Rate acceptable at any transmission mode",
45 MakeDoubleAccessor (&IdealWifiManager::m_ber),
46 MakeDoubleChecker<double> ())
51 IdealWifiManager::IdealWifiManager ()
54 IdealWifiManager::~IdealWifiManager ()
59 IdealWifiManager::SetupPhy (Ptr<WifiPhy> phy)
61 uint32_t nModes = phy->GetNModes ();
62 for (uint32_t i = 0; i < nModes; i++)
64 WifiMode mode = phy->GetMode (i);
65 AddModeSnrThreshold (mode, phy->CalculateSnr (mode, m_ber));
68 WifiRemoteStationManager::SetupPhy (phy);
72 IdealWifiManager::GetSnrThreshold (WifiMode mode)
const
74 for (Thresholds::const_iterator i = m_thresholds.begin (); i != m_thresholds.end (); i++)
76 if (mode == i->second)
86 IdealWifiManager::AddModeSnrThreshold (WifiMode mode,
double snr)
88 m_thresholds.push_back (std::make_pair (snr,mode));
95 station->m_lastSnr = 0.0;
106 IdealWifiManager::DoReportRtsFailed (WifiRemoteStation *station)
110 IdealWifiManager::DoReportDataFailed (WifiRemoteStation *station)
114 IdealWifiManager::DoReportRtsOk (WifiRemoteStation *st,
115 double ctsSnr, WifiMode ctsMode,
double rtsSnr)
117 IdealWifiRemoteStation *station = (IdealWifiRemoteStation *)st;
118 station->m_lastSnr = rtsSnr;
121 IdealWifiManager::DoReportDataOk (WifiRemoteStation *st,
122 double ackSnr, WifiMode ackMode,
double dataSnr)
124 IdealWifiRemoteStation *station = (IdealWifiRemoteStation *)st;
125 station->m_lastSnr = dataSnr;
128 IdealWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *station)
132 IdealWifiManager::DoReportFinalDataFailed (WifiRemoteStation *station)
143 double maxThreshold = 0.0;
144 WifiMode maxMode = GetDefaultMode ();
145 for (uint32_t i = 0; i < GetNSupported (station); i++)
147 WifiMode mode = GetSupported (station, i);
148 double threshold = GetSnrThreshold (mode);
149 if (threshold > maxThreshold
150 && threshold < station->m_lastSnr)
152 maxThreshold = threshold;
165 double maxThreshold = 0.0;
166 WifiMode maxMode = GetDefaultMode ();
167 for (uint32_t i = 0; i < GetNBasicModes (); i++)
170 double threshold = GetSnrThreshold (mode);
171 if (threshold > maxThreshold
172 && threshold < station->m_lastSnr)
174 maxThreshold = threshold;
virtual bool IsLowLatency(void) const
virtual WifiMode DoGetRtsMode(WifiRemoteStation *station)
#define NS_ASSERT(condition)
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
virtual WifiMode DoGetDataMode(WifiRemoteStation *station, uint32_t size)
hold a list of per-remote-station state.
virtual WifiRemoteStation * DoCreateStation(void) const
Ideal rate control algorithmThis class implements an 'ideal' rate control algorithm similar to RBAR i...
Hold an floating point type.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
hold per-remote-station state.