41 pPlatformService_{pPlatformService},
42 pMACLayler_{pMACLayer},
45 totalUtilizationVector_.resize(u8NumCategories_);
46 localUtilizationVector_.resize(u8NumCategories_);
64 if(u8Category > u8NumCategories_)
68 "MACI %03hu %s::%s: invalid category %hhu, max is %hhu, ignore",
78 totalUtilizationVector_[u8Category] += durationMicroseconds;
81 totalUtilizationMicroseconds_ += durationMicroseconds;
85 "MACI %03hu %s::%s: category %hhu, duration %lf",
90 std::chrono::duration_cast<
DoubleSeconds>(durationMicroseconds).count());
100 if(u8Category > u8NumCategories_)
104 "MACI %03hu %s::%s: invalid category %hhu, max is %hhu, ignore",
114 localUtilizationVector_[u8Category] += durationMicroseconds;
117 totalUtilizationVector_[u8Category] += durationMicroseconds;
120 totalUtilizationMicroseconds_ += durationMicroseconds;
124 "MACI %03hu %s::%s: category %hhu, duration %lf",
129 std::chrono::duration_cast<
DoubleSeconds>(durationMicroseconds).count());
138 if(u8NumCategories_ != u8NumCategories)
142 "MACI %03hu %s::%s: change num categories from %hhu to %hhu",
150 totalUtilizationVector_.resize(u8NumCategories);
151 localUtilizationVector_.resize(u8NumCategories);
153 u8NumCategories_ = u8NumCategories;
162 EMANE::Models::IEEE80211ABG::WMMManager::resetCounters()
164 for(
auto & iter : totalUtilizationVector_)
166 iter = Microseconds::zero();
169 for(
auto & iter : localUtilizationVector_)
171 iter = Microseconds::zero();
174 totalUtilizationMicroseconds_ = Microseconds::zero();
186 if((totalUtilizationMicroseconds_ > Microseconds::zero()) && (deltaTMicroseconds > Microseconds::zero()))
189 float fActivityRatio{
getRatio(totalUtilizationMicroseconds_, deltaTMicroseconds)};
192 if(fActivityRatio > 1.0f)
194 fActivityRatio = 1.0f;
198 for(std::uint8_t u8Category = 0; u8Category < u8NumCategories_; ++u8Category)
201 vec[u8Category].first =
getRatio(totalUtilizationVector_[u8Category], totalUtilizationMicroseconds_) * fActivityRatio;
204 if(totalUtilizationVector_[u8Category] > Microseconds::zero())
207 vec[u8Category].second =
getRatio(localUtilizationVector_[u8Category], totalUtilizationVector_[u8Category]);
211 vec[u8Category].second = 0.0f;
216 "MACI %03hu %s::%s: category %hhu, [total_bw %lf, ratio %f], " 217 "usage [total %f, %3.2f%%]",
222 vec[u8Category].first,
223 vec[u8Category].second,
224 std::chrono::duration_cast<
DoubleSeconds>(totalUtilizationMicroseconds_).count(),
225 fActivityRatio * 100.0f);
UtilizationRatioVector getUtilizationRatios(const Microseconds &deltaTMicroseconds)
#define LOGGER_VERBOSE_LOGGING(logger, level, fmt, args...)
WMMManager(NEMId id, PlatformServiceProvider *pPlatformService, MACLayer *pMACLayer)
std::vector< UtilizationRatioPair > UtilizationRatioVector
void updateLocalActivity(std::uint8_t u8Category, const Microseconds &durationMicroseconds)
std::chrono::microseconds Microseconds
std::chrono::duration< double > DoubleSeconds
float getRatio(const EMANE::Microseconds &d1, const EMANE::Microseconds d2)
void setNumCategories(const std::uint8_t u8NumCategories)
std::pair< float, float > UtilizationRatioPair
void updateTotalActivity(std::uint8_t u8Category, const Microseconds &durationMicroseconds)
IEEE 80211 ABG MAC implementation.