47 ACCEPT_COLUMN_NEM = 0,
48 ACCEPT_COLUMN_NUM_BYTES_TX = 1,
49 ACCEPT_COLUMN_NUM_BYTES_RX = 2,
73 DROP_COLUMN_REG_ID = 2,
74 DROP_COLUMN_DST_MAC = 3,
75 DROP_COLUMN_QUEUE_OVERFLOW = 4,
76 DROP_COLUMN_BAD_CONTROL = 5,
77 DROP_COLUMN_BAD_SPECTRUM_QUERY = 6,
78 DROP_COLUMN_FLOW_CONTROL = 7,
79 DROP_COLUMN_TOO_BIG = 8,
80 DROP_COLUMN_TOO_LONG = 9,
81 DROP_COLUMN_FREQUENCY = 10,
82 DROP_COLUMN_SLOT_ERROR = 11,
83 DROP_COLUMN_MISS_FRAGMENT = 12
93 for(
int queueIndex = 0; queueIndex < QUEUE_COUNT; ++queueIndex)
95 broadcastAcceptTables_[queueIndex] =
96 statisticRegistrar.
registerTable<
NEMId>(
"BroadcastByteAcceptTable" + std::to_string(queueIndex),
100 std::lock_guard<std::mutex> m(mutexBroadcastPacketAcceptTable_);
101 broadcastAcceptInfos_[queueIndex].clear();
104 "Broadcast bytes accepted");
106 unicastAcceptTables_[queueIndex] =
107 statisticRegistrar.
registerTable<
NEMId>(
"UnicastByteAcceptTable" + std::to_string(queueIndex),
111 std::lock_guard<std::mutex> m(mutexUnicastPacketAcceptTable_);
112 unicastAcceptInfos_[queueIndex].clear();
115 "Unicast bytes accepted");
117 broadcastDropTables_[queueIndex] =
118 statisticRegistrar.
registerTable<
NEMId>(
"BroadcastByteDropTable" + std::to_string(queueIndex),
122 std::lock_guard<std::mutex> m(mutexBroadcastPacketDropTable_);
123 broadcastDropInfos_[queueIndex].clear();
126 "Broadcast bytes dropped");
128 unicastDropTables_[queueIndex] =
129 statisticRegistrar.
registerTable<
NEMId>(
"UnicastByteDropTable" + std::to_string(queueIndex),
133 std::lock_guard<std::mutex> m(mutexUnicastPacketDropTable_);
134 unicastDropInfos_[queueIndex].clear();
137 "Unicast bytes dropped");
156 for(
const auto & component : components)
159 component.getDestination(),
160 component.getPriority(),
161 component.getData().size(),
174 TableArray * pAcceptTables{};
175 TableArray * pDropTables{};
177 AcceptInfoArrary * pAcceptInfos{};
178 DropInfoArrary * pDropInfos{};
180 std::mutex * pMutexAcceptTable = {};
181 std::mutex * pMutexDropTable = {};
185 pAcceptTables = &broadcastAcceptTables_;
186 pDropTables = &broadcastDropTables_;
188 pAcceptInfos = &broadcastAcceptInfos_;
189 pDropInfos = &broadcastDropInfos_;
191 pMutexAcceptTable = &mutexBroadcastPacketAcceptTable_;
192 pMutexDropTable = &mutexBroadcastPacketDropTable_;
196 pAcceptTables = &unicastAcceptTables_;
197 pDropTables = &unicastDropTables_;
199 pAcceptInfos = &unicastAcceptInfos_;
200 pDropInfos = &unicastDropInfos_;
202 pMutexAcceptTable = &mutexUnicastPacketAcceptTable_;
203 pMutexDropTable = &mutexUnicastPacketDropTable_;
211 std::lock_guard<std::mutex> m(*pMutexAcceptTable);
213 auto iter = (*pAcceptInfos)[u8QueueIndex].find(src);
215 if(iter == (*pAcceptInfos)[u8QueueIndex].end())
217 iter = (*pAcceptInfos)[u8QueueIndex].insert({
src,{}}).first;
220 (*pAcceptTables)[u8QueueIndex]->addRow(src,
226 auto &
bytes = std::get<ACCEPT_COLUMN_NUM_BYTES_RX-1>(iter->second);
230 (*pAcceptTables)[u8QueueIndex]->setCell(src,
231 ACCEPT_COLUMN_NUM_BYTES_RX,
236 std::lock_guard<std::mutex> m(*pMutexDropTable);
238 auto iter = (*pDropInfos)[u8QueueIndex].find(src);
240 if(iter == (*pDropInfos)[u8QueueIndex].end())
242 iter = (*pDropInfos)[u8QueueIndex].insert({
src,{}}).first;
244 (*pDropTables)[u8QueueIndex]->addRow(src,
264 auto &
bytes = std::get<DROP_COLUMN_BAD_CONTROL-1>(iter->second);
268 (*pDropTables)[u8QueueIndex]->setCell(src,
269 DROP_COLUMN_BAD_CONTROL,
277 auto &
bytes = std::get<DROP_COLUMN_SLOT_ERROR-1>(iter->second);
281 (*pDropTables)[u8QueueIndex]->setCell(src,
282 DROP_COLUMN_SLOT_ERROR,
289 auto &
bytes = std::get<DROP_COLUMN_MISS_FRAGMENT-1>(iter->second);
293 (*pDropTables)[u8QueueIndex]->setCell(src,
294 DROP_COLUMN_MISS_FRAGMENT,
301 auto &
bytes = std::get<DROP_COLUMN_BAD_SPECTRUM_QUERY-1>(iter->second);
305 (*pDropTables)[u8QueueIndex]->setCell(src,
306 DROP_COLUMN_BAD_SPECTRUM_QUERY,
313 auto &
bytes = std::get<DROP_COLUMN_SINR-1>(iter->second);
317 (*pDropTables)[u8QueueIndex]->setCell(src,
325 auto &
bytes = std::get<DROP_COLUMN_REG_ID-1>(iter->second);
329 (*pDropTables)[u8QueueIndex]->setCell(src,
337 auto &
bytes = std::get<DROP_COLUMN_DST_MAC-1>(iter->second);
341 (*pDropTables)[u8QueueIndex]->setCell(src,
348 auto &
bytes = std::get<DROP_COLUMN_TOO_LONG-1>(iter->second);
352 (*pDropTables)[u8QueueIndex]->setCell(src,
353 DROP_COLUMN_TOO_LONG,
359 auto &
bytes = std::get<DROP_COLUMN_FREQUENCY-1>(iter->second);
363 (*pDropTables)[u8QueueIndex]->setCell(src,
364 DROP_COLUMN_FREQUENCY,
382 TableArray * pAcceptTables{};
383 TableArray * pDropTables{};
385 AcceptInfoArrary * pAcceptInfos{};
386 DropInfoArrary * pDropInfos{};
388 std::mutex * pMutexAcceptTable = {};
389 std::mutex * pMutexDropTable = {};
393 pAcceptTables = &broadcastAcceptTables_;
394 pDropTables = &broadcastDropTables_;
396 pAcceptInfos = &broadcastAcceptInfos_;
397 pDropInfos = &broadcastDropInfos_;
399 pMutexAcceptTable = &mutexBroadcastPacketAcceptTable_;
400 pMutexDropTable = &mutexBroadcastPacketDropTable_;
404 pAcceptTables = &unicastAcceptTables_;
405 pDropTables = &unicastDropTables_;
407 pAcceptInfos = &unicastAcceptInfos_;
408 pDropInfos = &unicastDropInfos_;
410 pMutexAcceptTable = &mutexUnicastPacketAcceptTable_;
411 pMutexDropTable = &mutexUnicastPacketDropTable_;
420 std::lock_guard<std::mutex> m(*pMutexAcceptTable);
422 auto iter = (*pAcceptInfos)[u8QueueIndex].find(src);
424 if(iter == (*pAcceptInfos)[u8QueueIndex].end())
426 iter = (*pAcceptInfos)[u8QueueIndex].insert({
src,{}}).first;
429 (*pAcceptTables)[u8QueueIndex]->addRow(src,
435 auto &
bytes = std::get<ACCEPT_COLUMN_NUM_BYTES_TX-1>(iter->second);
439 (*pAcceptTables)[u8QueueIndex]->setCell(src,
440 ACCEPT_COLUMN_NUM_BYTES_TX,
445 std::lock_guard<std::mutex> m(*pMutexDropTable);
447 auto iter = (*pDropInfos)[u8QueueIndex].find(src);
449 if(iter == (*pDropInfos)[u8QueueIndex].end())
451 iter = (*pDropInfos)[u8QueueIndex].insert({
src,{}}).first;
453 (*pDropTables)[u8QueueIndex]->addRow(src,
473 auto &
bytes = std::get<DROP_COLUMN_TOO_BIG-1>(iter->second);
477 (*pDropTables)[u8QueueIndex]->setCell(src,
484 auto &
bytes = std::get<DROP_COLUMN_QUEUE_OVERFLOW-1>(iter->second);
488 (*pDropTables)[u8QueueIndex]->setCell(src,
489 DROP_COLUMN_QUEUE_OVERFLOW,
495 auto &
bytes = std::get<DROP_COLUMN_FLOW_CONTROL-1>(iter->second);
499 (*pDropTables)[u8QueueIndex]->setCell(src,
500 DROP_COLUMN_FLOW_CONTROL,
515 for(
const auto & component : components)
518 component.getDestination(),
519 component.getPriority(),
520 component.getData().size(),
void outbound(NEMId src, NEMId dst, Priority priority, size_t size, OutboundAction action) override
void inbound(NEMId src, const MessageComponent &component, InboundAction action) override
A StatisticTablePublisher produces two dimensional tables of Anys.
constexpr NEMId NEM_BROADCAST_MAC_ADDRESS
struct EtherAddrBytes bytes
Priority getPriority() const
The StatisticRegistrar allows NEM layers to register statistics and statistic tables. Statistics and Statistic tables are owned by the emulator framework and a borrowed reference is returned to the registering NEM layer.
std::vector< std::string > StatisticTableLabels
std::list< MessageComponent > MessageComponents
StatisticTable< Key, Compare, scolumn > * registerTable(const std::string &sName, const StatisticTableLabels &labels, const StatisticProperties &properties=StatisticProperties::NONE, const std::string &sDescription="")
NEMId getDestination() const
const Data & getData() const
~PacketStatusPublisherImpl()
PacketStatusPublisherImpl()
void registerStatistics(StatisticRegistrar ®istrar)
std::uint8_t priorityToQueue(Priority priority)
The Any class can contain an instance of one of any type in its support type set. ...
Holds a message component that may be all or part of a data or control message.