11#ifndef WIFI_TX_STATS_HELPER_H
12#define WIFI_TX_STATS_HELPER_H
14#include "ns3/nstime.h"
15#include "ns3/object.h"
16#include "ns3/qos-utils.h"
17#include "ns3/type-id.h"
18#include "ns3/wifi-mac.h"
19#include "ns3/wifi-types.h"
20#include "ns3/wifi-utils.h"
32class NetDeviceContainer;
147 template <
typename T>
150 seed ^= std::hash<T>{}(value) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
158 template <
typename Tuple,
size_t Index = 0>
161 if constexpr (Index < std::tuple_size<Tuple>::value)
178 template <
typename... Args>
186 std::unordered_map<std::tuple<uint32_t, uint32_t, uint8_t>,
191 std::unordered_map<std::tuple<uint32_t, uint32_t>,
196 std::unordered_map<std::tuple<uint32_t, uint32_t, uint8_t>,
197 std::list<MpduRecord>,
201 std::unordered_map<std::tuple<uint32_t, uint32_t>,
202 std::list<MpduRecord>,
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
static Time Max()
Maximum representable Time Not to be confused with Max(Time,Time).
Statistics helper for tracking outcomes of data MPDU transmissions.
Time m_stopTime
The stop time for recording statistics.
MpduRecordsPerNodeDevice_t m_successMap
The nested map of successful MPDUs.
void Reset()
Clear the data structures for all completed successful and failed MpduRecords.
std::unordered_map< std::tuple< uint32_t, uint32_t >, std::list< MpduRecord >, TupleHash > MpduRecordsPerNodeDevice_t
std::unordered_map of {nodeId, deviceId} tuple to a list of MPDU records
std::map< uint64_t, MpduRecord > m_inflightMap
In-flight MPDUs; key is a Packet UID.
void NotifyAcked(uint32_t nodeId, uint32_t deviceId, Ptr< const WifiMpdu > mpdu)
Callback for the WifiMac::AckedMpdu trace.
CountPerNodeDeviceLink_t GetSuccessesByNodeDeviceLink(WifiTxStatsHelper::MultiLinkSuccessType type=FIRST_LINK_IN_SET) const
Return the counts of successful MPDU transmissions in a hash map.
MultiLinkSuccessType
When Multi-Link Operation (MLO) is used, it is possible for MPDUs to be sent on multiple links concur...
void Stop(Time stopTime)
Set the stop time for statistics collection.
void NotifyTxStart(uint32_t nodeId, uint32_t deviceId, Ptr< const Packet > pkt, Watt_u)
Callback for the WifiPhy::PhyTxBegin trace.
uint64_t GetFailures() const
Return the count of failed MPDU transmissions across all enabled devices.
WifiTxStatsHelper()
Default constructor; start time initialized to zero and stop time to Time::Max()
Time m_startTime
The start time for recording statistics.
void NotifyMacEnqueue(uint32_t nodeId, uint32_t deviceId, Ptr< const WifiMpdu > mpdu)
Callback for the WifiMacQueue::Enqueue trace.
std::unordered_map< std::tuple< uint32_t, uint32_t, uint8_t >, uint64_t, TupleHash > CountPerNodeDeviceLink_t
std::unordered_map of {nodeId, deviceId, linkId} tuple to counter value
CountPerNodeDevice_t GetFailuresByNodeDevice() const
Return the counts of failed MPDU transmissions in a hash map.
std::unordered_map< std::tuple< uint32_t, uint32_t >, uint64_t, TupleHash > CountPerNodeDevice_t
std::unordered_map of {nodeId, deviceId} tuple to counter value
const MpduRecordsPerNodeDeviceLink_t GetSuccessRecords(WifiTxStatsHelper::MultiLinkSuccessType type=FIRST_LINK_IN_SET) const
Return a hash map of successful MPDU records.
const MpduRecordsPerNodeDevice_t & GetFailureRecords() const
Return a hash map of MPDU records for failed transmissions.
CountPerNodeDevice_t GetSuccessesByNodeDevice() const
Return the counts of successful MPDU transmissions in a hash map.
MpduRecordsPerNodeDevice_t m_failureMap
The nested map of failed MPDUs.
uint64_t GetSuccesses() const
Return the count of successful MPDU transmissions across all enabled devices.
void NotifyMacDropped(uint32_t nodeId, uint32_t deviceId, WifiMacDropReason reason, Ptr< const WifiMpdu > mpdu)
Callback for the WifiMac::DroppedMpdu trace.
void Enable(const NodeContainer &nodes)
Enables trace collection for all nodes and WifiNetDevices in the specified NodeContainer.
CountPerNodeDevice_t GetRetransmissionsByNodeDevice() const
Return the counts of MPDU retransmissions in a hash map.
uint64_t GetRetransmissions() const
Return the count of MPDU retransmissions across all enabled devices.
void Start(Time startTime)
Set the start time for statistics collection.
std::unordered_map< std::tuple< uint32_t, uint32_t, uint8_t >, std::list< MpduRecord >, TupleHash > MpduRecordsPerNodeDeviceLink_t
std::unordered_map of {nodeId, deviceId, linkId} tuple to a list of MPDU records
Time GetDuration() const
Return the duration since the helper was started or reset.
WifiMacDropReason
The reason why an MPDU was dropped.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static constexpr uint8_t WIFI_TID_UNDEFINED
Invalid TID identifier.
Structure for recording information about an individual data MPDU transmission.
uint32_t m_deviceId
The sending device ID.
uint32_t m_nodeId
The sending node ID.
uint64_t m_mpduSeqNum
The MPDU sequence number.
Time m_ackTime
The time at which the MPDU was acknowledged.
uint32_t m_retransmissions
A count of the number of retransmissions of the MPDU.
Time m_enqueueTime
The enqueue time (time that the packet was added to a WifiMacQueue)
std::set< uint8_t > m_successLinkIdSet
If acked, the set of in-flight link ID(s)
std::optional< WifiMacDropReason > m_dropReason
If failed, the drop reason.
std::optional< Time > m_dropTime
The time of removal from the WifiMacQueue, if failed.
Time m_txStartTime
The time at which the MPDU was first transmitted.
uint8_t m_tid
The TID for the MPDU.
Hash function for the tuples used in unordered_maps.
size_t operator()(const std::tuple< Args... > &tuple) const
Operator overload for calculating hash of tuple.
size_t tuple_hash(const Tuple &tuple) const
Hash function for tuples of arbitrary size.
void hash_combine(size_t &seed, const T &value) const
Combines two hash values into one (similar to boost::hash_combine)