wifi: Improve tracing of dropped MPDUs

This commit is contained in:
Stefano Avallone
2021-01-06 12:42:59 +01:00
committed by Stefano Avallone
parent 816bdb8d5b
commit 76b650dae6
11 changed files with 103 additions and 46 deletions

View File

@@ -190,6 +190,13 @@ FrameExchangeManager::SetBssid (Mac48Address bssid)
m_bssid = bssid;
}
void
FrameExchangeManager::SetDroppedMpduCallback (DroppedMpdu callback)
{
NS_LOG_FUNCTION (this << &callback);
m_droppedMpduCallback = callback;
}
void
FrameExchangeManager::SetPromisc (void)
{
@@ -211,7 +218,10 @@ FrameExchangeManager::GetWifiTxTimer (void) const
void
FrameExchangeManager::NotifyPacketDiscarded (Ptr<const WifiMacQueueItem> mpdu)
{
m_mac->NotifyTxDrop (mpdu->GetPacket ());
if (!m_droppedMpduCallback.IsNull ())
{
m_droppedMpduCallback (WIFI_MAC_DROP_REACHED_RETRY_LIMIT, mpdu);
}
}
void

View File

@@ -57,6 +57,11 @@ public:
FrameExchangeManager ();
virtual ~FrameExchangeManager ();
/**
* typedef for a callback to invoke when an MPDU is dropped.
*/
typedef Callback <void, WifiMacDropReason, Ptr<const WifiMacQueueItem>> DroppedMpdu;
/**
* Request the FrameExchangeManager to start a frame exchange sequence.
*
@@ -138,6 +143,12 @@ public:
* \param bssid the BSSID
*/
virtual void SetBssid (Mac48Address bssid);
/**
* Set the callback to invoke when an MPDU is dropped.
*
* \param callback the callback to invoke when an MPDU is dropped
*/
virtual void SetDroppedMpduCallback (DroppedMpdu callback);
/**
* Enable promiscuous mode.
*/
@@ -306,8 +317,8 @@ protected:
virtual void RetransmitMpduAfterMissedCts (Ptr<WifiMacQueueItem> mpdu) const;
/**
* Pass the packet included in the given MPDU to the
* packet dropped callback.
* Pass the given MPDU, discarded because of the max retry limit was reached,
* to the MPDU dropped callback.
*
* \param mpdu the discarded MPDU
*/
@@ -357,6 +368,7 @@ protected:
Mac48Address m_bssid; //!< BSSID address (Mac48Address)
Time m_navEnd; //!< NAV expiration time
bool m_promisc; //!< Flag if the device is operating in promiscuous mode
DroppedMpdu m_droppedMpduCallback; //!< the dropped MPDU callback
/**
* Forward an MPDU down to the PHY layer.

View File

@@ -144,6 +144,16 @@ QosTxop::SetQosFrameExchangeManager (const Ptr<QosFrameExchangeManager> qosFem)
m_qosFem = qosFem;
}
void
QosTxop::SetDroppedMpduCallback (DroppedMpdu callback)
{
NS_LOG_FUNCTION (this << &callback);
Txop::SetDroppedMpduCallback (callback);
m_baManager->GetRetransmitQueue ()->TraceConnectWithoutContext ("Expired",
m_droppedMpduCallback
.Bind (WIFI_MAC_DROP_EXPIRED_LIFETIME));
}
Ptr<BlockAckManager>
QosTxop::GetBaManager (void)
{
@@ -507,9 +517,9 @@ QosTxop::NotifyInternalCollision (void)
{
NS_LOG_DEBUG ("reset DCF");
m_stationManager->ReportFinalDataFailed (mpdu);
if (!m_txDroppedCallback.IsNull ())
if (!m_droppedMpduCallback.IsNull ())
{
m_txDroppedCallback (mpdu->GetPacket ());
m_droppedMpduCallback (WIFI_MAC_DROP_REACHED_RETRY_LIMIT, mpdu);
}
ResetCw ();
// We have to discard mpdu, but first we have to determine whether mpdu

View File

@@ -105,6 +105,7 @@ public:
void NotifyInternalCollision (void);
virtual void NotifyChannelAccessed (Time txopDuration);
void NotifyChannelReleased (void);
void SetDroppedMpduCallback (DroppedMpdu callback);
/**
* Set type of station with the given type.

View File

@@ -62,7 +62,8 @@ RegularWifiMac::RegularWifiMac ()
m_txop->SetTxMiddle (m_txMiddle);
m_txop->SetTxOkCallback (MakeCallback (&RegularWifiMac::TxOk, this));
m_txop->SetTxFailedCallback (MakeCallback (&RegularWifiMac::TxFailed, this));
m_txop->SetTxDroppedCallback (MakeCallback (&RegularWifiMac::NotifyTxDrop, this));
m_txop->SetDroppedMpduCallback (MakeCallback (&DroppedMpduTracedCallback::operator(),
&m_droppedMpduCallback));
//Construct the EDCAFs. The ordering is important - highest
//priority (Table 9-1 UP-to-AC mapping; IEEE 802.11-2012) must be created
@@ -156,6 +157,8 @@ RegularWifiMac::SetupFrameExchangeManager (void)
&m_mpduResponseTimeoutCallback));
m_feManager->GetWifiTxTimer ().SetPsduResponseTimeoutCallback (MakeCallback (&PsduResponseTimeoutTracedCallback::operator(),
&m_psduResponseTimeoutCallback));
m_feManager->SetDroppedMpduCallback (MakeCallback (&DroppedMpduTracedCallback::operator(),
&m_droppedMpduCallback));
m_channelAccessManager->SetupFrameExchangeManager (m_feManager);
if (GetQosSupported ())
{
@@ -467,7 +470,8 @@ RegularWifiMac::SetupEdcaQueue (AcIndex ac)
edca->SetTxMiddle (m_txMiddle);
edca->SetTxOkCallback (MakeCallback (&RegularWifiMac::TxOk, this));
edca->SetTxFailedCallback (MakeCallback (&RegularWifiMac::TxFailed, this));
edca->SetTxDroppedCallback (MakeCallback (&RegularWifiMac::NotifyTxDrop, this));
edca->SetDroppedMpduCallback (MakeCallback (&DroppedMpduTracedCallback::operator(),
&m_droppedMpduCallback));
edca->SetAccessCategory (ac);
edca->CompleteConfig ();
@@ -1089,6 +1093,10 @@ RegularWifiMac::GetTypeId (void)
"The header of unsuccessfully transmitted packet.",
MakeTraceSourceAccessor (&RegularWifiMac::m_txErrCallback),
"ns3::WifiMacHeader::TracedCallback")
.AddTraceSource ("DroppedMpdu",
"An MPDU that was dropped for the given reason (see WifiMacDropReason).",
MakeTraceSourceAccessor (&RegularWifiMac::m_droppedMpduCallback),
"ns3::RegularWifiMac::DroppedMpduCallback")
.AddTraceSource ("MpduResponseTimeout",
"An MPDU whose response was not received before the timeout, along with "
"an identifier of the type of timeout (see WifiTxTimer::Reason) and the "

View File

@@ -466,6 +466,22 @@ private:
TracedCallback<const WifiMacHeader &> m_txOkCallback; ///< transmit OK callback
TracedCallback<const WifiMacHeader &> m_txErrCallback; ///< transmit error callback
/**
* TracedCallback signature for MPDU drop events.
*
* \param reason the reason why the MPDU was dropped (\see WifiMacDropReason)
* \param mpdu the dropped MPDU
*/
typedef void (* DroppedMpduCallback)(WifiMacDropReason reason, Ptr<const WifiMacQueueItem> mpdu);
/// TracedCallback for MPDU drop events typedef
typedef TracedCallback<WifiMacDropReason, Ptr<const WifiMacQueueItem>> DroppedMpduTracedCallback;
/**
* This trace indicates that an MPDU was dropped for the given reason.
*/
DroppedMpduTracedCallback m_droppedMpduCallback;
/**
* TracedCallback signature for MPDU response timeout events.
*

View File

@@ -150,20 +150,14 @@ Txop::SetTxFailedCallback (TxFailed callback)
}
void
Txop::SetTxDroppedCallback (TxDropped callback)
Txop::SetDroppedMpduCallback (DroppedMpdu callback)
{
NS_LOG_FUNCTION (this << &callback);
m_txDroppedCallback = callback;
m_queue->TraceConnectWithoutContext ("Drop", MakeCallback (&Txop::TxDroppedPacket, this));
}
void
Txop::TxDroppedPacket (Ptr<const WifiMacQueueItem> item)
{
if (!m_txDroppedCallback.IsNull ())
{
m_txDroppedCallback (item->GetPacket ());
}
m_droppedMpduCallback = callback;
m_queue->TraceConnectWithoutContext ("DropBeforeEnqueue",
m_droppedMpduCallback.Bind (WIFI_MAC_DROP_FAILED_ENQUEUE));
m_queue->TraceConnectWithoutContext ("Expired",
m_droppedMpduCallback.Bind (WIFI_MAC_DROP_EXPIRED_LIFETIME));
}
Ptr<WifiMacQueue >

View File

@@ -35,6 +35,7 @@ class WifiMacQueueItem;
class UniformRandomVariable;
class CtrlBAckResponseHeader;
class WifiRemoteStationManager;
enum WifiMacDropReason : uint8_t; // opaque enum declaration
/**
* \brief Handle packet fragmentation and retransmissions
@@ -86,10 +87,9 @@ public:
*/
typedef Callback <void, const WifiMacHeader&> TxFailed;
/**
* typedef for a callback to invoke when a
* packet is dropped.
* typedef for a callback to invoke when an MPDU is dropped.
*/
typedef Callback <void, Ptr<const Packet> > TxDropped;
typedef Callback <void, WifiMacDropReason, Ptr<const WifiMacQueueItem> > DroppedMpdu;
/**
* Enumeration for channel access status
@@ -138,10 +138,9 @@ public:
*/
void SetTxFailedCallback (TxFailed callback);
/**
* \param callback the callback to invoke when a
* packet is dropped.
* \param callback the callback to invoke when an MPDU is dropped
*/
void SetTxDroppedCallback (TxDropped callback);
virtual void SetDroppedMpduCallback (DroppedMpdu callback);
/**
* Return the packet queue associated with this Txop.
@@ -342,19 +341,10 @@ protected:
*/
void UpdateBackoffSlotsNow (uint32_t nSlots, Time backoffUpdateBound);
/**
*
* Pass the packet included in the wifi MAC queue item to the
* packet dropped callback.
*
* \param item the wifi MAC queue item.
*/
void TxDroppedPacket (Ptr<const WifiMacQueueItem> item);
Ptr<ChannelAccessManager> m_channelAccessManager; //!< the channel access manager
TxOk m_txOkCallback; //!< the transmit OK callback
TxFailed m_txFailedCallback; //!< the transmit failed callback
TxDropped m_txDroppedCallback; //!< the packet dropped callback
DroppedMpdu m_droppedMpduCallback; //!< the dropped MPDU callback
Ptr<WifiMacQueue> m_queue; //!< the wifi MAC queue
Ptr<MacTxMiddle> m_txMiddle; //!< the MacTxMiddle
Ptr<WifiRemoteStationManager> m_stationManager; //!< the wifi remote station manager

View File

@@ -51,7 +51,10 @@ WifiMac::GetTypeId (void)
MakeTraceSourceAccessor (&WifiMac::m_macTxTrace),
"ns3::Packet::TracedCallback")
.AddTraceSource ("MacTxDrop",
"A packet has been dropped in the MAC layer before transmission.",
"A packet has been dropped in the MAC layer before being queued for transmission. "
"This trace source is fired, e.g., when an AP's MAC receives from the upper layer "
"a packet destined to a station that is not associated with the AP or a STA's MAC "
"receives a packet from the upper layer while it is not associated with any AP.",
MakeTraceSourceAccessor (&WifiMac::m_macTxDropTrace),
"ns3::Packet::TracedCallback")
.AddTraceSource ("MacPromiscRx",

View File

@@ -34,6 +34,18 @@ class HtConfiguration;
class VhtConfiguration;
class HeConfiguration;
/**
* \ingroup wifi
* \enum WifiMacDropReason
* \brief The reason why an MPDU was dropped
*/
enum WifiMacDropReason : uint8_t
{
WIFI_MAC_DROP_FAILED_ENQUEUE = 0,
WIFI_MAC_DROP_EXPIRED_LIFETIME,
WIFI_MAC_DROP_REACHED_RETRY_LIMIT
};
/**
* \brief base class for all MAC-level wifi objects.
* \ingroup wifi
@@ -186,9 +198,9 @@ public:
/**
* \param packet the packet being dropped
*
* Public method used to fire a MacTxDrop trace. Implemented for encapsulation purposes.
* This trace indicates that the packet was dropped before it was transmitted
* (e.g. when a STA is not associated with an AP).
* Public method used to fire a MacTxDrop trace.
* This trace indicates that the packet was dropped before it was queued for
* transmission (e.g. when a STA is not associated with an AP).
*/
void NotifyTxDrop (Ptr<const Packet> packet);
/**
@@ -258,7 +270,7 @@ private:
TracedCallback<Ptr<const Packet> > m_macTxTrace;
/**
* The trace source fired when packets coming into the "top" of the device
* are dropped at the MAC layer during transmission.
* are dropped at the MAC layer before being queued for transmission.
*
* \see class CallBackTraceSource
*/

View File

@@ -59,12 +59,13 @@ public:
AmpduAggregationTest ();
private:
/*
* Fired when the MAC discards a packet.
/**
* Fired when the MAC discards an MPDU.
*
* \param packet the discarded packet
* \param reason the reason why the MPDU was discarded
* \param mpdu the discarded MPDU
*/
void PacketDiscarded (Ptr<const Packet> packet);
void MpduDiscarded (WifiMacDropReason reason, Ptr<const WifiMacQueueItem> mpdu);
virtual void DoRun (void);
Ptr<WifiNetDevice> m_device; ///<WifiNetDevice
@@ -82,7 +83,7 @@ AmpduAggregationTest::AmpduAggregationTest ()
}
void
AmpduAggregationTest::PacketDiscarded (Ptr<const Packet> packet)
AmpduAggregationTest::MpduDiscarded (WifiMacDropReason, Ptr<const WifiMacQueueItem>)
{
m_discarded = true;
}
@@ -295,7 +296,7 @@ AmpduAggregationTest::DoRun (void)
NS_TEST_EXPECT_MSG_EQ (mpduList.empty (), true, "no MPDU aggregation should be performed if there is no agreement");
m_manager->SetMaxSsrc (0); //set to 0 in order to fake that the maximum number of retries has been reached
m_mac->TraceConnectWithoutContext ("MacTxDrop", MakeCallback (&AmpduAggregationTest::PacketDiscarded, this));
m_mac->TraceConnectWithoutContext ("DroppedMpdu", MakeCallback (&AmpduAggregationTest::MpduDiscarded, this));
htFem->m_dcf = m_mac->GetBEQueue ();
htFem->NormalAckTimeout (item, txParams.m_txVector);