21 #include "cara-wifi-manager.h"
22 #include "ns3/assert.h"
24 #include "ns3/double.h"
25 #include "ns3/uinteger.h"
26 #include "ns3/simulator.h"
44 CaraWifiManager::GetTypeId (
void)
48 .AddConstructor<CaraWifiManager> ()
49 .AddAttribute (
"ProbeThreshold",
50 "The number of consecutive transmissions failure to activate the RTS probe.",
52 MakeUintegerAccessor (&CaraWifiManager::m_probeThreshold),
53 MakeUintegerChecker<uint32_t> ())
54 .AddAttribute (
"FailureThreshold",
55 "The number of consecutive transmissions failure to decrease the rate.",
57 MakeUintegerAccessor (&CaraWifiManager::m_failureThreshold),
58 MakeUintegerChecker<uint32_t> ())
59 .AddAttribute (
"SuccessThreshold",
60 "The minimum number of sucessfull transmissions to try a new rate.",
62 MakeUintegerAccessor (&CaraWifiManager::m_successThreshold),
63 MakeUintegerChecker<uint32_t> ())
64 .AddAttribute (
"Timeout",
65 "The 'timer' in the CARA algorithm",
67 MakeUintegerAccessor (&CaraWifiManager::m_timerTimeout),
68 MakeUintegerChecker<uint32_t> ())
73 CaraWifiManager::CaraWifiManager ()
74 : WifiRemoteStationManager ()
78 CaraWifiManager::~CaraWifiManager ()
89 station->m_success = 0;
90 station->m_failed = 0;
102 CaraWifiManager::DoReportDataFailed (WifiRemoteStation *st)
105 CaraWifiRemoteStation *station = (CaraWifiRemoteStation *) st;
108 station->m_success = 0;
109 if (station->m_failed >= m_failureThreshold)
112 if (station->m_rate != 0)
116 station->m_failed = 0;
117 station->m_timer = 0;
121 CaraWifiManager::DoReportRxOk (WifiRemoteStation *st,
122 double rxSnr, WifiMode txMode)
127 CaraWifiManager::DoReportRtsOk (WifiRemoteStation *st,
128 double ctsSnr, WifiMode ctsMode,
double rtsSnr)
134 CaraWifiManager::DoReportDataOk (WifiRemoteStation *st,
135 double ackSnr, WifiMode ackMode,
double dataSnr)
138 CaraWifiRemoteStation *station = (CaraWifiRemoteStation *) st;
140 station->m_success++;
141 station->m_failed = 0;
142 NS_LOG_DEBUG (
"self=" << station <<
" data ok success=" << station->m_success <<
", timer=" << station->m_timer);
143 if ((station->m_success == m_successThreshold
144 || station->m_timer >= m_timerTimeout))
146 if (station->m_rate < GetNSupported (station) - 1)
150 NS_LOG_DEBUG (
"self=" << station <<
" inc rate=" << station->m_rate);
151 station->m_timer = 0;
152 station->m_success = 0;
156 CaraWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *st)
161 CaraWifiManager::DoReportFinalDataFailed (WifiRemoteStation *st)
172 return GetSupported (station, station->m_rate);
180 return GetSupported (st, 0);
189 return normally || station->m_failed >= m_probeThreshold;
#define NS_LOG_FUNCTION(parameters)
virtual WifiMode DoGetRtsMode(WifiRemoteStation *station)
virtual WifiRemoteStation * DoCreateStation(void) const
virtual bool IsLowLatency(void) const
#define NS_LOG_COMPONENT_DEFINE(name)
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Hold an unsigned integer type.
hold a list of per-remote-station state.
#define NS_LOG_DEBUG(msg)
virtual WifiMode DoGetDataMode(WifiRemoteStation *station, uint32_t size)
implement the CARA rate control algorithmImplement the CARA algorithm from: J. Kim, S. Kim, S. Choi, and D. Qiao. "CARA: Collision-Aware Rate Adaptation for IEEE 802.11 WLANs."
virtual bool DoNeedRts(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
hold per-remote-station state.