Statistics helper for tracking outcomes of data MPDU transmissions. More...
#include "wifi-tx-stats-helper.h"
Classes | |
struct | MpduRecord |
Structure for recording information about an individual data MPDU transmission. More... | |
struct | TupleHash |
Hash function for the tuples used in unordered_maps. More... | |
Public Types | |
using | CountPerNodeDevice_t |
std::unordered_map of {nodeId, deviceId} tuple to counter value | |
using | CountPerNodeDeviceLink_t |
std::unordered_map of {nodeId, deviceId, linkId} tuple to counter value | |
using | MpduRecordsPerNodeDevice_t |
std::unordered_map of {nodeId, deviceId} tuple to a list of MPDU records | |
using | MpduRecordsPerNodeDeviceLink_t |
std::unordered_map of {nodeId, deviceId, linkId} tuple to a list of MPDU records | |
enum | MultiLinkSuccessType : uint8_t { FIRST_LINK_IN_SET , ALL_LINKS } |
When Multi-Link Operation (MLO) is used, it is possible for MPDUs to be sent on multiple links concurrently. More... | |
Public Member Functions | |
WifiTxStatsHelper () | |
Default constructor; start time initialized to zero and stop time to Time::Max() | |
WifiTxStatsHelper (Time startTime, Time stopTime) | |
Construct a helper with start and stop times. | |
void | Enable (const NetDeviceContainer &devices) |
Enables trace collection for all WifiNetDevices in the specified NetDeviceContainer. | |
void | Enable (const NodeContainer &nodes) |
Enables trace collection for all nodes and WifiNetDevices in the specified NodeContainer. | |
Time | GetDuration () const |
Return the duration since the helper was started or reset. | |
const MpduRecordsPerNodeDevice_t & | GetFailureRecords () const |
Return a hash map of MPDU records for failed transmissions. | |
uint64_t | GetFailures () const |
Return the count of failed MPDU transmissions across all enabled devices. | |
uint64_t | GetFailures (WifiMacDropReason reason) const |
Return the count of failed MPDU transmissions due to given drop reason across all enabled devices. | |
CountPerNodeDevice_t | GetFailuresByNodeDevice () const |
Return the counts of failed MPDU transmissions in a hash map. | |
CountPerNodeDevice_t | GetFailuresByNodeDevice (WifiMacDropReason reason) const |
Return the counts of failed MPDU transmissions due to given drop reason in a hash map. | |
uint64_t | GetRetransmissions () const |
Return the count of MPDU retransmissions across all enabled devices. | |
CountPerNodeDevice_t | GetRetransmissionsByNodeDevice () const |
Return the counts of MPDU retransmissions in a hash map. | |
uint64_t | GetSuccesses () const |
Return the count of successful MPDU transmissions across all enabled devices. | |
CountPerNodeDevice_t | GetSuccessesByNodeDevice () const |
Return the counts of successful MPDU transmissions in a hash map. | |
CountPerNodeDeviceLink_t | GetSuccessesByNodeDeviceLink (WifiTxStatsHelper::MultiLinkSuccessType type=FIRST_LINK_IN_SET) const |
Return the counts of successful MPDU transmissions in a hash map. | |
const MpduRecordsPerNodeDeviceLink_t | GetSuccessRecords (WifiTxStatsHelper::MultiLinkSuccessType type=FIRST_LINK_IN_SET) const |
Return a hash map of successful MPDU records. | |
void | Reset () |
Clear the data structures for all completed successful and failed MpduRecords. | |
void | Start (Time startTime) |
Set the start time for statistics collection. | |
void | Stop (Time stopTime) |
Set the stop time for statistics collection. | |
Private Member Functions | |
void | NotifyAcked (uint32_t nodeId, uint32_t deviceId, Ptr< const WifiMpdu > mpdu) |
Callback for the WifiMac::AckedMpdu trace. | |
void | NotifyMacDropped (uint32_t nodeId, uint32_t deviceId, WifiMacDropReason reason, Ptr< const WifiMpdu > mpdu) |
Callback for the WifiMac::DroppedMpdu trace. | |
void | NotifyMacEnqueue (uint32_t nodeId, uint32_t deviceId, Ptr< const WifiMpdu > mpdu) |
Callback for the WifiMacQueue::Enqueue trace. | |
void | NotifyTxStart (uint32_t nodeId, uint32_t deviceId, Ptr< const Packet > pkt, Watt_u) |
Callback for the WifiPhy::PhyTxBegin trace. | |
Private Attributes | |
MpduRecordsPerNodeDevice_t | m_failureMap |
The nested map of failed MPDUs. | |
std::map< uint64_t, MpduRecord > | m_inflightMap |
In-flight MPDUs; key is a Packet UID. | |
Time | m_startTime |
The start time for recording statistics. | |
Time | m_stopTime {Time::Max()} |
The stop time for recording statistics. | |
MpduRecordsPerNodeDevice_t | m_successMap |
The nested map of successful MPDUs. | |
Statistics helper for tracking outcomes of data MPDU transmissions.
This helper may be used to track statistics of all data MPDU transmissions on a given Node, WifiNetDevice, or even link granularity (for MLO operation), including counts of the number of successfully acknowledged MPDUs, the number of retransmissions (if any) of those successfully acknowledged MPDUs, and the number of failed MPDUs (by drop reason). The helper can also be used to access timestamped data about how long the MPDU was enqueued and how long it took to complete acknowledgement (or failure) once the first transmission of it was attempted. For failed MPDUs, their WifiMacDropReason can be accessed.
Definition at line 49 of file wifi-tx-stats-helper.h.
std::unordered_map of {nodeId, deviceId} tuple to counter value
Definition at line 190 of file wifi-tx-stats-helper.h.
std::unordered_map of {nodeId, deviceId, linkId} tuple to counter value
Definition at line 185 of file wifi-tx-stats-helper.h.
std::unordered_map of {nodeId, deviceId} tuple to a list of MPDU records
Definition at line 200 of file wifi-tx-stats-helper.h.
std::unordered_map of {nodeId, deviceId, linkId} tuple to a list of MPDU records
Definition at line 195 of file wifi-tx-stats-helper.h.
enum ns3::WifiTxStatsHelper::MultiLinkSuccessType : uint8_t |
When Multi-Link Operation (MLO) is used, it is possible for MPDUs to be sent on multiple links concurrently.
When such an MPDU is acked, a question arises as to how to count the number of successes (only one success, or success on each link). The ACK does not convey which transmission on which link triggered the event. Therefore, two policies are defined for how to count a successful event. 1) FIRST_LINK_IN_SET: Count the success on the first link of the set of in-flight links 2) ALL_LINKS: Count the success on all links in the in-flight link set
Enumerator | |
---|---|
FIRST_LINK_IN_SET | |
ALL_LINKS |
Definition at line 61 of file wifi-tx-stats-helper.h.
ns3::WifiTxStatsHelper::WifiTxStatsHelper | ( | ) |
Default constructor; start time initialized to zero and stop time to Time::Max()
Definition at line 27 of file wifi-tx-stats-helper.cc.
References NS_LOG_FUNCTION.
Construct a helper with start and stop times.
Only those MPDUs enqueued between the start and stop times will be counted.
startTime | The measurement start time |
stopTime | The measurement stop time |
Definition at line 32 of file wifi-tx-stats-helper.cc.
References ns3::Time::As(), NS_ASSERT_MSG, NS_LOG_FUNCTION, ns3::Time::S, and stopTime.
void ns3::WifiTxStatsHelper::Enable | ( | const NetDeviceContainer & | devices | ) |
Enables trace collection for all WifiNetDevices in the specified NetDeviceContainer.
devices | The NetDeviceContainer to which traces are to be connected. |
Definition at line 57 of file wifi-tx-stats-helper.cc.
References ns3::AC_BE_NQOS, ns3::DynamicCast(), ns3::MakeCallback(), NotifyAcked(), NotifyMacDropped(), NotifyMacEnqueue(), NotifyTxStart(), NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_INFO, and ns3::wifiAcList.
void ns3::WifiTxStatsHelper::Enable | ( | const NodeContainer & | nodes | ) |
Enables trace collection for all nodes and WifiNetDevices in the specified NodeContainer.
nodes | The NodeContainer to which traces are to be connected. |
Definition at line 42 of file wifi-tx-stats-helper.cc.
References ns3::NetDeviceContainer::Add(), Enable(), nodes, and NS_LOG_FUNCTION.
Referenced by WifiTxStatsHelperTest::DoRun(), Enable(), and Experiment::Run().
Time ns3::WifiTxStatsHelper::GetDuration | ( | ) | const |
Return the duration since the helper was started or reset.
Definition at line 318 of file wifi-tx-stats-helper.cc.
References m_startTime, and ns3::Now().
const WifiTxStatsHelper::MpduRecordsPerNodeDevice_t & ns3::WifiTxStatsHelper::GetFailureRecords | ( | ) | const |
Return a hash map of MPDU records for failed transmissions.
The return type is an std::unordered_map, and the keys are tuples of {node ID, device ID}. The value returned by indexing the tuple is the list of MPDU records of the MPDUs that failed.
Definition at line 358 of file wifi-tx-stats-helper.cc.
References m_failureMap.
Referenced by WifiTxStatsHelperTest::CheckResults().
uint64_t ns3::WifiTxStatsHelper::GetFailures | ( | ) | const |
Return the count of failed MPDU transmissions across all enabled devices.
Definition at line 274 of file wifi-tx-stats-helper.cc.
References m_failureMap.
Referenced by WifiTxStatsHelperTest::CheckResults().
uint64_t ns3::WifiTxStatsHelper::GetFailures | ( | WifiMacDropReason | reason | ) | const |
Return the count of failed MPDU transmissions due to given drop reason across all enabled devices.
reason | Reason for dropping the MPDU |
Definition at line 285 of file wifi-tx-stats-helper.cc.
References m_failureMap, and NS_ASSERT_MSG.
WifiTxStatsHelper::CountPerNodeDevice_t ns3::WifiTxStatsHelper::GetFailuresByNodeDevice | ( | ) | const |
Return the counts of failed MPDU transmissions in a hash map.
The return type is an std::unordered_map, and the keys are tuples of {node ID, device ID}. The value returned by indexing the tuple is the count of failed MPDU transmissions.
The number of failures are only stored with the granularity of per-device, since in a multi-link scenario, some retransmissions (that lead to eventual failure) may occur on different links.
Definition at line 200 of file wifi-tx-stats-helper.cc.
References m_failureMap.
Referenced by WifiTxStatsHelperTest::CheckResults(), and Experiment::Run().
WifiTxStatsHelper::CountPerNodeDevice_t ns3::WifiTxStatsHelper::GetFailuresByNodeDevice | ( | WifiMacDropReason | reason | ) | const |
Return the counts of failed MPDU transmissions due to given drop reason in a hash map.
reason | Reason for dropping the MPDU |
The return type is an std::unordered_map, and the keys are tuples of {node ID, device ID}. The value returned by indexing the tuple is the count of failed MPDU transmissions due to the reason given.
The number of failures are only stored with the granularity of per-device, since in a multi-link scenario, some retransmissions (that lead to eventual failure) may occur on different links.
Definition at line 211 of file wifi-tx-stats-helper.cc.
References m_failureMap, and NS_ASSERT_MSG.
uint64_t ns3::WifiTxStatsHelper::GetRetransmissions | ( | ) | const |
Return the count of MPDU retransmissions across all enabled devices.
Definition at line 304 of file wifi-tx-stats-helper.cc.
References m_successMap.
Referenced by WifiTxStatsHelperTest::CheckResults().
WifiTxStatsHelper::CountPerNodeDevice_t ns3::WifiTxStatsHelper::GetRetransmissionsByNodeDevice | ( | ) | const |
Return the counts of MPDU retransmissions in a hash map.
The return type is an std::unordered_map, and the keys are tuples of {node ID, device ID}. The value returned by indexing the tuple is the count of MPDU retransmissions of those MPDUs that were successfully acked.
The number of retransmissions are only stored with the granularity of per-device, since in a multi-link scenario, some retransmissions may be sent on different links.
Definition at line 239 of file wifi-tx-stats-helper.cc.
References m_successMap.
Referenced by WifiTxStatsHelperTest::CheckResults(), and Experiment::Run().
uint64_t ns3::WifiTxStatsHelper::GetSuccesses | ( | ) | const |
Return the count of successful MPDU transmissions across all enabled devices.
Definition at line 263 of file wifi-tx-stats-helper.cc.
References m_successMap.
Referenced by WifiTxStatsHelperTest::CheckResults().
WifiTxStatsHelper::CountPerNodeDevice_t ns3::WifiTxStatsHelper::GetSuccessesByNodeDevice | ( | ) | const |
Return the counts of successful MPDU transmissions in a hash map.
The return type is an std::unordered_map, and the keys are tuples of {node ID, device ID}. The value returned by indexing the tuple is the count of successful MPDU transmissions.
If Multi-Link Operation (MLO) is configured, a variant of this method is available that returns an unordered_map indexed by a tuple that includes the Link ID, for more granular statistics reporting.
If Multi-Link Operation (MLO) is configured, and MPDUs are sent on multiple links in parallel, this method will count one success for any such acknowledged MPDU (even if it was successfully received on more than one link).
Definition at line 141 of file wifi-tx-stats-helper.cc.
References m_successMap.
Referenced by WifiTxStatsHelperTest::CheckResults(), and Experiment::Run().
WifiTxStatsHelper::CountPerNodeDeviceLink_t ns3::WifiTxStatsHelper::GetSuccessesByNodeDeviceLink | ( | WifiTxStatsHelper::MultiLinkSuccessType | type = FIRST_LINK_IN_SET | ) | const |
Return the counts of successful MPDU transmissions in a hash map.
type | how the statistics handle a successful MPDU transmitted on multiple links |
The return type is an std::unordered_map, and the keys are tuples of {node ID, device ID, link ID}. The value returned by indexing the tuple is the count of successful MPDU transmissions.
The link ID corresponds to the link for which the MPDU was successfully acknowledged, regardless of the links that may have been used in earlier transmissions of the MPDU.
For a similar method that does not use Link IDs in the key,
Definition at line 152 of file wifi-tx-stats-helper.cc.
References FIRST_LINK_IN_SET, m_successMap, and NS_ASSERT_MSG.
Referenced by WifiTxStatsHelperTest::CheckResults().
const WifiTxStatsHelper::MpduRecordsPerNodeDeviceLink_t ns3::WifiTxStatsHelper::GetSuccessRecords | ( | WifiTxStatsHelper::MultiLinkSuccessType | type = FIRST_LINK_IN_SET | ) | const |
Return a hash map of successful MPDU records.
type | how the statistics handle a successful MPDU transmitted on multiple links |
The return type is an std::unordered_map, and the keys are tuples of {node ID, device ID, link ID}. The value returned by indexing the tuple is the list of MPDU records of the MPDUs that were successfully acked.
Definition at line 324 of file wifi-tx-stats-helper.cc.
References FIRST_LINK_IN_SET, m_successMap, and NS_ASSERT_MSG.
Referenced by WifiTxStatsHelperTest::CheckResults().
|
private |
Callback for the WifiMac::AckedMpdu trace.
nodeId | the Node ID triggering the trace |
deviceId | the Node ID triggering the trace |
mpdu | The MPDU acked |
Definition at line 422 of file wifi-tx-stats-helper.cc.
References m_inflightMap, m_stopTime, m_successMap, ns3::Now(), NS_ASSERT_MSG, NS_LOG_DEBUG, NS_LOG_FUNCTION, and NS_LOG_INFO.
Referenced by Enable().
|
private |
Callback for the WifiMac::DroppedMpdu trace.
nodeId | the Node ID triggering the trace |
deviceId | the Node ID triggering the trace |
reason | Reason for dropping the MPDU |
mpdu | The MPDU dropped |
Definition at line 455 of file wifi-tx-stats-helper.cc.
References m_failureMap, m_inflightMap, m_stopTime, ns3::Now(), NS_LOG_DEBUG, NS_LOG_FUNCTION, and NS_LOG_INFO.
Referenced by Enable().
|
private |
Callback for the WifiMacQueue::Enqueue trace.
nodeId | the Node ID triggering the trace |
deviceId | the Node ID triggering the trace |
mpdu | The MPDU enqueued |
Definition at line 364 of file wifi-tx-stats-helper.cc.
References m_inflightMap, ns3::WifiTxStatsHelper::MpduRecord::m_nodeId, m_stopTime, ns3::Simulator::Now(), NS_LOG_DEBUG, NS_LOG_FUNCTION, and NS_LOG_INFO.
Referenced by Enable().
|
private |
Callback for the WifiPhy::PhyTxBegin trace.
nodeId | the Node ID triggering the trace |
deviceId | the Node ID triggering the trace |
pkt | The frame being sent |
Definition at line 393 of file wifi-tx-stats-helper.cc.
References m_inflightMap, m_stopTime, ns3::Now(), NS_LOG_DEBUG, NS_LOG_FUNCTION, and NS_LOG_INFO.
Referenced by Enable().
void ns3::WifiTxStatsHelper::Reset | ( | ) |
Clear the data structures for all completed successful and failed MpduRecords.
Definition at line 132 of file wifi-tx-stats-helper.cc.
References m_failureMap, m_startTime, m_successMap, ns3::Now(), and NS_LOG_FUNCTION.
void ns3::WifiTxStatsHelper::Start | ( | Time | startTime | ) |
Set the start time for statistics collection.
No MPDUs enqueued before startTime will be included in the statistics.
startTime | The measurement start time |
Definition at line 112 of file wifi-tx-stats-helper.cc.
References ns3::Time::As(), m_startTime, m_stopTime, ns3::Now(), NS_ASSERT_MSG, NS_LOG_FUNCTION, and ns3::Time::S.
Referenced by WifiTxStatsHelperTest::DoRun(), and Experiment::Run().
void ns3::WifiTxStatsHelper::Stop | ( | Time | stopTime | ) |
Set the stop time for statistics collection.
No MPDUs enqueued after stopTime elapses will be included in statistics. However, MPDUs that were enqueued before stopTime (and after startTime) will be included in the statistics if they are dequeued before the statistics are queried by the user.
stopTime | The measurement stop time |
Definition at line 122 of file wifi-tx-stats-helper.cc.
References m_startTime, m_stopTime, ns3::Now(), NS_ASSERT_MSG, NS_LOG_FUNCTION, ns3::Time::S, and stopTime.
Referenced by WifiTxStatsHelperTest::DoRun(), and Experiment::Run().
|
private |
The nested map of failed MPDUs.
Definition at line 381 of file wifi-tx-stats-helper.h.
Referenced by GetFailureRecords(), GetFailures(), GetFailures(), GetFailuresByNodeDevice(), GetFailuresByNodeDevice(), NotifyMacDropped(), and Reset().
|
private |
In-flight MPDUs; key is a Packet UID.
Definition at line 382 of file wifi-tx-stats-helper.h.
Referenced by NotifyAcked(), NotifyMacDropped(), NotifyMacEnqueue(), and NotifyTxStart().
|
private |
The start time for recording statistics.
Definition at line 383 of file wifi-tx-stats-helper.h.
Referenced by GetDuration(), Reset(), Start(), and Stop().
The stop time for recording statistics.
Definition at line 384 of file wifi-tx-stats-helper.h.
Referenced by NotifyAcked(), NotifyMacDropped(), NotifyMacEnqueue(), NotifyTxStart(), Start(), and Stop().
|
private |
The nested map of successful MPDUs.
Definition at line 380 of file wifi-tx-stats-helper.h.
Referenced by GetRetransmissions(), GetRetransmissionsByNodeDevice(), GetSuccesses(), GetSuccessesByNodeDevice(), GetSuccessesByNodeDeviceLink(), GetSuccessRecords(), NotifyAcked(), and Reset().