21 #include "onoe-wifi-manager.h"
22 #include "ns3/simulator.h"
24 #include "ns3/uinteger.h"
32 Time m_nextModeUpdate;
33 uint32_t m_shortRetry;
46 OnoeWifiManager::GetTypeId (
void)
50 .AddConstructor<OnoeWifiManager> ()
51 .AddAttribute (
"UpdatePeriod",
52 "The interval between decisions about rate control changes",
54 MakeTimeAccessor (&OnoeWifiManager::m_updatePeriod),
56 .AddAttribute (
"RaiseThreshold",
"Attempt to raise the rate if we hit that threshold",
58 MakeUintegerAccessor (&OnoeWifiManager::m_raiseThreshold),
59 MakeUintegerChecker<uint32_t> ())
60 .AddAttribute (
"AddCreditThreshold",
"Add credit threshold",
62 MakeUintegerAccessor (&OnoeWifiManager::m_addCreditThreshold),
63 MakeUintegerChecker<uint32_t> ())
68 OnoeWifiManager::OnoeWifiManager ()
76 station->m_shortRetry = 0;
77 station->m_longRetry = 0;
79 station->m_tx_err = 0;
80 station->m_tx_retr = 0;
81 station->m_tx_upper = 0;
82 station->m_txrate = 0;
91 OnoeWifiManager::DoReportRtsFailed (WifiRemoteStation *st)
93 OnoeWifiRemoteStation *station = (OnoeWifiRemoteStation *)st;
94 station->m_shortRetry++;
97 OnoeWifiManager::DoReportDataFailed (WifiRemoteStation *st)
99 OnoeWifiRemoteStation *station = (OnoeWifiRemoteStation *)st;
100 station->m_longRetry++;
103 OnoeWifiManager::DoReportRtsOk (WifiRemoteStation *station,
104 double ctsSnr, WifiMode ctsMode,
double rtsSnr)
108 OnoeWifiManager::DoReportDataOk (WifiRemoteStation *st,
109 double ackSnr, WifiMode ackMode,
double dataSnr)
111 OnoeWifiRemoteStation *station = (OnoeWifiRemoteStation *)st;
112 UpdateRetry (station);
116 OnoeWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *st)
118 OnoeWifiRemoteStation *station = (OnoeWifiRemoteStation *)st;
119 UpdateRetry (station);
123 OnoeWifiManager::DoReportFinalDataFailed (WifiRemoteStation *st)
125 OnoeWifiRemoteStation *station = (OnoeWifiRemoteStation *)st;
126 UpdateRetry (station);
130 OnoeWifiManager::UpdateRetry (OnoeWifiRemoteStation *station)
132 station->m_tx_retr += station->m_shortRetry + station->m_longRetry;
133 station->m_shortRetry = 0;
134 station->m_longRetry = 0;
151 enough = (station->m_tx_ok + station->m_tx_err >= 10);
154 if (station->m_tx_err > 0 && station->m_tx_ok == 0)
160 if (enough && station->m_tx_ok < station->m_tx_retr)
166 if (enough && station->m_tx_err == 0
167 && station->m_tx_retr < (station->m_tx_ok * m_addCreditThreshold) / 100)
172 NS_LOG_DEBUG (
this <<
" ok " << station->m_tx_ok <<
" err " << station->m_tx_err <<
" retr " << station->m_tx_retr <<
173 " upper " << station->m_tx_upper <<
" dir " << dir);
175 nrate = station->m_txrate;
179 if (enough && station->m_tx_upper > 0)
181 station->m_tx_upper--;
189 station->m_tx_upper = 0;
193 if (++station->m_tx_upper < m_raiseThreshold)
197 station->m_tx_upper = 0;
198 if (nrate + 1 < GetNSupported (station))
205 if (nrate != station->m_txrate)
207 NS_ASSERT (nrate < GetNSupported (station));
208 station->m_txrate = nrate;
209 station->m_tx_ok = station->m_tx_err = station->m_tx_retr = station->m_tx_upper = 0;
213 station->m_tx_ok = station->m_tx_err = station->m_tx_retr = 0;
224 NS_ASSERT (station->m_txrate < GetNSupported (station));
226 if (station->m_longRetry < 4)
228 rateIndex = station->m_txrate;
230 else if (station->m_longRetry < 6)
232 if (station->m_txrate > 0)
234 rateIndex = station->m_txrate - 1;
238 rateIndex = station->m_txrate;
241 else if (station->m_longRetry < 8)
243 if (station->m_txrate > 1)
245 rateIndex = station->m_txrate - 2;
249 rateIndex = station->m_txrate;
254 if (station->m_txrate > 2)
256 rateIndex = station->m_txrate - 3;
260 rateIndex = station->m_txrate;
263 return GetSupported (station, rateIndex);
271 return GetSupported (station, 0);
an implementation of the rate control algorithm developed by Atsushi Onoe
void UpdateMode(OnoeWifiRemoteStation *station)
#define NS_ASSERT(condition)
#define NS_LOG_COMPONENT_DEFINE(name)
virtual bool IsLowLatency(void) const
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
hold objects of type ns3::Time
Hold an unsigned integer type.
hold a list of per-remote-station state.
virtual WifiRemoteStation * DoCreateStation(void) const
virtual WifiMode DoGetDataMode(WifiRemoteStation *station, uint32_t size)
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
#define NS_LOG_DEBUG(msg)
virtual WifiMode DoGetRtsMode(WifiRemoteStation *station)
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
hold per-remote-station state.