diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 39cd67fab..eb4052b54 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -34,6 +34,7 @@ New user-visible features Bugs fixed ---------- +- Bug 1034 - No trace source for packet dropping from WifiMacQueue - Bug 2007 - uan: Remove deprecation on SetRxThresholdDb - Bug 2214 - tcp: Use of ScheduleNow only in selected part of the code - Bug 2221 - network: Remove constraint on size of ns3::Packet Tag objects diff --git a/src/wifi/model/ap-wifi-mac.cc b/src/wifi/model/ap-wifi-mac.cc index 35b3f7da4..e3f467bbe 100644 --- a/src/wifi/model/ap-wifi-mac.cc +++ b/src/wifi/model/ap-wifi-mac.cc @@ -352,6 +352,10 @@ ApWifiMac::Enqueue (Ptr packet, Mac48Address to, Mac48Address from { ForwardDown (packet, from, to); } + else + { + NotifyTxDrop (packet); + } } void diff --git a/src/wifi/model/dca-txop.cc b/src/wifi/model/dca-txop.cc index 5a8231efc..1f418ccf6 100644 --- a/src/wifi/model/dca-txop.cc +++ b/src/wifi/model/dca-txop.cc @@ -142,6 +142,23 @@ DcaTxop::SetTxFailedCallback (TxFailed callback) m_txFailedCallback = callback; } +void +DcaTxop::SetTxDroppedCallback (TxDropped callback) +{ + NS_LOG_FUNCTION (this << &callback); + m_txDroppedCallback = callback; + m_queue->TraceConnectWithoutContext ("Drop", MakeCallback (&DcaTxop::TxDroppedPacket, this)); +} + +void +DcaTxop::TxDroppedPacket (Ptr item) +{ + if (!m_txDroppedCallback.IsNull ()) + { + m_txDroppedCallback (item->GetPacket ()); + } +} + Ptr DcaTxop::GetQueue () const { diff --git a/src/wifi/model/dca-txop.h b/src/wifi/model/dca-txop.h index 05ee4055d..63e696304 100644 --- a/src/wifi/model/dca-txop.h +++ b/src/wifi/model/dca-txop.h @@ -80,6 +80,11 @@ public: * packet transmission was failed. */ typedef Callback TxFailed; + /** + * typedef for a callback to invoke when a + * packet is dropped. + */ + typedef Callback > TxDropped; /** * Check for EDCA. @@ -123,6 +128,11 @@ public: * packet transmission was completed unsuccessfully. */ void SetTxFailedCallback (TxFailed callback); + /** + * \param callback the callback to invoke when a + * packet is dropped. + */ + void SetTxDroppedCallback (TxDropped callback); /** * Return the MacLow associated with this DcaTxop. @@ -382,11 +392,20 @@ protected: * false otherwise. */ virtual bool IsLastFragment (void) const; + /** + * + * 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 item); DcfState *m_dcf; //!< the DCF state DcfManager *m_manager; //!< the DCF manager TxOk m_txOkCallback; //!< the transmit OK callback TxFailed m_txFailedCallback; //!< the transmit failed callback + TxDropped m_txDroppedCallback; //!< the packet dropped callback Ptr m_queue; //!< the wifi MAC queue MacTxMiddle *m_txMiddle; //!< the MacTxMiddle Ptr m_low; //!< the MacLow diff --git a/src/wifi/model/regular-wifi-mac.cc b/src/wifi/model/regular-wifi-mac.cc index 1ed04007d..c1753d502 100644 --- a/src/wifi/model/regular-wifi-mac.cc +++ b/src/wifi/model/regular-wifi-mac.cc @@ -59,6 +59,7 @@ RegularWifiMac::RegularWifiMac () m_dca->SetTxMiddle (m_txMiddle); m_dca->SetTxOkCallback (MakeCallback (&RegularWifiMac::TxOk, this)); m_dca->SetTxFailedCallback (MakeCallback (&RegularWifiMac::TxFailed, this)); + m_dca->SetTxDroppedCallback (MakeCallback (&RegularWifiMac::NotifyTxDrop, this)); //Construct the EDCAFs. The ordering is important - highest //priority (Table 9-1 UP-to-AC mapping; IEEE 802.11-2012) must be created @@ -425,6 +426,7 @@ 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->SetAccessCategory (ac); edca->CompleteConfig (); diff --git a/src/wifi/model/wifi-mac.cc b/src/wifi/model/wifi-mac.cc index abd2dd19c..f8ea68b4b 100644 --- a/src/wifi/model/wifi-mac.cc +++ b/src/wifi/model/wifi-mac.cc @@ -209,7 +209,7 @@ WifiMac::GetTypeId (void) MakeTraceSourceAccessor (&WifiMac::m_macTxTrace), "ns3::Packet::TracedCallback") .AddTraceSource ("MacTxDrop", - "A packet has been dropped in the MAC layer before being queued for transmission.", + "A packet has been dropped in the MAC layer before transmission.", MakeTraceSourceAccessor (&WifiMac::m_macTxDropTrace), "ns3::Packet::TracedCallback") .AddTraceSource ("MacPromiscRx",