wifi: Improve tracing of ACKed/NACKed MPDUs

This commit is contained in:
Stefano Avallone
2021-01-07 14:41:43 +01:00
committed by Stefano Avallone
parent 76b650dae6
commit bc9ddaa453
18 changed files with 107 additions and 140 deletions

View File

@@ -71,6 +71,7 @@ us a note on ns-developers mailing list.</p>
<li>The default <b>TCP congestion control</b> has been changed from NewReno to CUBIC.</li>
<li>The PHY layer of the wifi module has been refactored: the amendment-specific logic has been ported to <b>PhyEntity</b> classes and <b>WifiPpdu</b> classes.</li>
<li>The MAC layer of the wifi module has been refactored. The MacLow class has been replaced by a hierarchy of FrameExchangeManager classes, each adding support for the frame exchange sequences introduced by a given amendment.</li>
<li>The TxOkHeader and TxErrHeader trace sources of RegularWifiMac have been obsoleted and replaced by trace sources that better capture the result of a transmission: AckedMpdu (fired when an MPDU is successfully acknowledged, via either a Normal Ack or a Block Ack), NAckedMpdu (fired when an MPDU is negatively acknowledged via a Block Ack), DroppedMpdu (fired when an MPDU is dropped), MpduResponseTimeout (fired when a CTS is missing after an RTS or a Normal Ack is missing after an MPDU) and PsduResponseTimeout (fired when a BlockAck is missing after an A-MPDU or a BlockAckReq).</li>
<li>The 802.11a-like PHY configuration known as <b>Holland</b> has been removed from the wifi module. It was added in the 2005 timeframe for Wi-Fi rate control research but hasn't been used for quite some time.</li>
<li>Support for <b>Greenfield mode</b> (aka <b>HT_GF</b>) has been dropped from wifi.</li>
<li>Some wifi/src/model files were moved to <b>non-ht</b>, <b>ht</b>, <b>vht</b>, <b>he</b>, and <b>rate-control</b> subfolders.</li>

View File

@@ -35,6 +35,7 @@ New user-visible features
- (wifi) Some wifi/src/model files were moved to the relevant subfolders (non-ht, ht, vht, he, and rate-control)
- (wifi) Stations perform TXOP recovery if the transmission of a non-initial MPDU in a TXOP fails
- (wifi) Stations keep track of the TXOP holder and ignore the NAV when they receive an RTS frame from the TXOP holder
- (wifi) The TxOkHeader and TxErrHeader trace sources of RegularWifiMac have been obsoleted and replaced by trace sources that better capture the result of a transmission (AckedMpdu, NAckedMpdu, DroppedMpdu, MpduResponseTimeout and PsduResponseTimeout)
- (traffic-control) Added FqCobalt queue disc with L4S features and set associative hash.
- (traffic-control) Added FqPIE queue disc with L4S mode.

View File

@@ -39,6 +39,7 @@
#include "ns3/udp-header.h"
#include "ns3/wifi-net-device.h"
#include "ns3/adhoc-wifi-mac.h"
#include "ns3/wifi-mac-queue-item.h"
#include "ns3/string.h"
#include "ns3/pointer.h"
#include <algorithm>
@@ -725,7 +726,13 @@ RoutingProtocol::NotifyInterfaceUp (uint32_t i)
return;
}
mac->TraceConnectWithoutContext ("TxErrHeader", m_nb.GetTxErrorCallback ());
mac->TraceConnectWithoutContext ("DroppedMpdu", MakeCallback (&RoutingProtocol::NotifyTxError, this));
}
void
RoutingProtocol::NotifyTxError (WifiMacDropReason reason, Ptr<const WifiMacQueueItem> mpdu)
{
m_nb.GetTxErrorCallback ()(mpdu->GetHeader ());
}
void
@@ -742,8 +749,8 @@ RoutingProtocol::NotifyInterfaceDown (uint32_t i)
Ptr<WifiMac> mac = wifi->GetMac ()->GetObject<AdhocWifiMac> ();
if (mac != 0)
{
mac->TraceDisconnectWithoutContext ("TxErrHeader",
m_nb.GetTxErrorCallback ());
mac->TraceDisconnectWithoutContext ("DroppedMpdu",
MakeCallback (&RoutingProtocol::NotifyTxError, this));
m_nb.DelArpCache (l3->GetInterface (i)->GetArpCache ());
}
}

View File

@@ -42,6 +42,10 @@
#include <map>
namespace ns3 {
class WifiMacQueueItem;
enum WifiMacDropReason : uint8_t; // opaque enum declaration
namespace aodv {
/**
* \ingroup aodv
@@ -180,6 +184,14 @@ public:
protected:
virtual void DoInitialize (void);
private:
/**
* Notify that an MPDU was dropped.
*
* \param reason the reason why the MPDU was dropped
* \param mpdu the dropped MPDU
*/
void NotifyTxError (WifiMacDropReason reason, Ptr<const WifiMacQueueItem> mpdu);
// Protocol parameters.
uint32_t m_rreqRetries; ///< Maximum number of retransmissions of RREQ with TTL = NetDiameter to discover a route
uint16_t m_ttlStart; ///< Initial TTL value for RREQ.

View File

@@ -49,18 +49,18 @@ void
PeerManagementProtocolMac::SetParent (Ptr<MeshWifiInterfaceMac> parent)
{
m_parent = parent;
m_parent->TraceConnectWithoutContext ("TxErrHeader", MakeCallback (&PeerManagementProtocolMac::TxError, this));
m_parent->TraceConnectWithoutContext ("TxOkHeader", MakeCallback (&PeerManagementProtocolMac::TxOk, this));
m_parent->TraceConnectWithoutContext ("DroppedMpdu", MakeCallback (&PeerManagementProtocolMac::TxError, this));
m_parent->TraceConnectWithoutContext ("AckedMpdu", MakeCallback (&PeerManagementProtocolMac::TxOk, this));
}
void
PeerManagementProtocolMac::TxError (WifiMacHeader const &hdr)
PeerManagementProtocolMac::TxError (WifiMacDropReason reason, Ptr<const WifiMacQueueItem> mpdu)
{
m_protocol->TransmissionFailure (m_ifIndex, hdr.GetAddr1 ());
m_protocol->TransmissionFailure (m_ifIndex, mpdu->GetHeader ().GetAddr1 ());
}
void
PeerManagementProtocolMac::TxOk (WifiMacHeader const &hdr)
PeerManagementProtocolMac::TxOk (Ptr <const WifiMacQueueItem> mpdu)
{
m_protocol->TransmissionSuccess (m_ifIndex, hdr.GetAddr1 ());
m_protocol->TransmissionSuccess (m_ifIndex, mpdu->GetHeader ().GetAddr1 ());
}
bool
PeerManagementProtocolMac::Receive (Ptr<Packet> const_packet, const WifiMacHeader & header)

View File

@@ -25,6 +25,8 @@
namespace ns3 {
class MeshWifiInterfaceMac;
class WifiMacQueueItem;
enum WifiMacDropReason : uint8_t; // opaque enum declaration
namespace dot11s {
class PeerManagementProtocol;
class IeConfiguration;
@@ -146,14 +148,15 @@ private:
// \}
/**
* Closes link when a proper number of successive transmissions have failed
* \param hdr the header
* \param reason the reason why the MPDU was dropped
* \param mpdu the dropped MPDU
*/
void TxError (WifiMacHeader const &hdr);
void TxError (WifiMacDropReason reason, Ptr<const WifiMacQueueItem> mpdu);
/**
* Transmit OK function
* \param hdr the header
* \param mpdu the MPDU
*/
void TxOk (WifiMacHeader const &hdr);
void TxOk (Ptr <const WifiMacQueueItem> mpdu);
// BCA functionality
/**
* Set beacon shift function

View File

@@ -97,7 +97,6 @@ ApWifiMac::ApWifiMac ()
m_beaconTxop->SetMaxCw (0);
m_beaconTxop->SetChannelAccessManager (m_channelAccessManager);
m_beaconTxop->SetTxMiddle (m_txMiddle);
m_beaconTxop->SetTxOkCallback (MakeCallback (&ApWifiMac::TxOk, this));
//Let the lower layers know that we are acting as an AP.
SetTypeOfStation (AP);
@@ -863,10 +862,10 @@ ApWifiMac::SendOneBeacon (void)
}
void
ApWifiMac::TxOk (const WifiMacHeader &hdr)
ApWifiMac::TxOk (Ptr<const WifiMacQueueItem> mpdu)
{
NS_LOG_FUNCTION (this);
RegularWifiMac::TxOk (hdr);
NS_LOG_FUNCTION (this << *mpdu);
const WifiMacHeader& hdr = mpdu->GetHeader ();
if ((hdr.IsAssocResp () || hdr.IsReassocResp ())
&& m_stationManager->IsWaitAssocTxOk (hdr.GetAddr1 ()))
{
@@ -876,10 +875,10 @@ ApWifiMac::TxOk (const WifiMacHeader &hdr)
}
void
ApWifiMac::TxFailed (const WifiMacHeader &hdr)
ApWifiMac::TxFailed (uint8_t timeoutReason, Ptr<const WifiMacQueueItem> mpdu, const WifiTxVector& txVector)
{
NS_LOG_FUNCTION (this);
RegularWifiMac::TxFailed (hdr);
NS_LOG_FUNCTION (this << +timeoutReason << *mpdu << txVector);
const WifiMacHeader& hdr = mpdu->GetHeader ();
if ((hdr.IsAssocResp () || hdr.IsReassocResp ())
&& m_stationManager->IsWaitAssocTxOk (hdr.GetAddr1 ()))
@@ -1433,6 +1432,8 @@ ApWifiMac::DoInitialize (void)
m_beaconEvent = Simulator::ScheduleNow (&ApWifiMac::SendOneBeacon, this);
}
}
NS_ABORT_IF (!TraceConnectWithoutContext ("AckedMpdu", MakeCallback (&ApWifiMac::TxOk, this)));
NS_ABORT_IF (!TraceConnectWithoutContext ("MpduResponseTimeout", MakeCallback (&ApWifiMac::TxFailed, this)));
RegularWifiMac::DoInitialize ();
}

View File

@@ -167,18 +167,20 @@ private:
* was an association response to the receiver, we record that
* the receiver is now associated with us.
*
* \param hdr the header of the packet that we successfully sent
* \param mpdu the MPDU that we successfully sent
*/
void TxOk (const WifiMacHeader &hdr);
void TxOk (Ptr<const WifiMacQueueItem> mpdu);
/**
* The packet we sent was successfully received by the receiver
* (i.e. we did not receive an Ack from the receiver). If the packet
* was an association response to the receiver, we record that
* the receiver is not associated with us yet.
*
* \param hdr the header of the packet that we failed to sent
* \param timeoutReason the reason why the TX timer was started (\see WifiTxTimer::Reason)
* \param mpdu the MPDU that we failed to sent
* \param txVector the TX vector used to send the MPDU
*/
void TxFailed (const WifiMacHeader &hdr);
void TxFailed (uint8_t timeoutReason, Ptr<const WifiMacQueueItem> mpdu, const WifiTxVector& txVector);
/**
* This method is called to de-aggregate an A-MSDU and forward the

View File

@@ -517,7 +517,7 @@ BlockAckManager::NotifyGotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac4
nSuccessfulMpdus++;
if (!m_txOkCallback.IsNull ())
{
m_txOkCallback ((*queueIt)->GetHeader ());
m_txOkCallback (*queueIt);
}
}
else if (!QosUtilsIsOldPacket (currentStartingSeq, currentSeq))
@@ -525,7 +525,7 @@ BlockAckManager::NotifyGotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac4
nFailedMpdus++;
if (!m_txFailedCallback.IsNull ())
{
m_txFailedCallback ((*queueIt)->GetHeader ());
m_txFailedCallback (*queueIt);
}
InsertInRetryQueue (*queueIt);
}

View File

@@ -364,15 +364,13 @@ public:
uint16_t GetOriginatorStartingSequence (Mac48Address recipient, uint8_t tid) const;
/**
* typedef for a callback to invoke when a
* packet transmission was completed successfully.
* typedef for a callback to invoke when an MPDU is successfully ack'ed.
*/
typedef Callback <void, const WifiMacHeader&> TxOk;
typedef Callback <void, Ptr<const WifiMacQueueItem>> TxOk;
/**
* typedef for a callback to invoke when a
* packet transmission was failed.
* typedef for a callback to invoke when an MPDU is negatively ack'ed.
*/
typedef Callback <void, const WifiMacHeader&> TxFailed;
typedef Callback <void, Ptr<const WifiMacQueueItem>> TxFailed;
/**
* \param callback the callback to invoke when a
* packet transmission was completed successfully.

View File

@@ -197,6 +197,13 @@ FrameExchangeManager::SetDroppedMpduCallback (DroppedMpdu callback)
m_droppedMpduCallback = callback;
}
void
FrameExchangeManager::SetAckedMpduCallback (AckedMpdu callback)
{
NS_LOG_FUNCTION (this << &callback);
m_ackedMpduCallback = callback;
}
void
FrameExchangeManager::SetPromisc (void)
{
@@ -776,7 +783,6 @@ FrameExchangeManager::NormalAckTimeout (Ptr<WifiMacQueueItem> mpdu, const WifiTx
NS_LOG_DEBUG ("Missed Ack, discard MPDU");
NotifyPacketDiscarded (mpdu);
m_mac->GetWifiRemoteStationManager ()->ReportFinalDataFailed (mpdu);
m_mac->TxFailed (mpdu->GetHeader ());
m_dcf->ResetCw ();
}
else
@@ -1117,7 +1123,10 @@ FrameExchangeManager::NotifyReceivedNormalAck (Ptr<WifiMacQueueItem> mpdu)
NS_LOG_FUNCTION (this << *mpdu);
// inform the MAC that the transmission was successful
m_mac->TxOk (mpdu->GetHeader ());
if (!m_ackedMpduCallback.IsNull ())
{
m_ackedMpduCallback (mpdu);
}
}
void

View File

@@ -61,6 +61,10 @@ public:
* typedef for a callback to invoke when an MPDU is dropped.
*/
typedef Callback <void, WifiMacDropReason, Ptr<const WifiMacQueueItem>> DroppedMpdu;
/**
* typedef for a callback to invoke when an MPDU is successfully acknowledged.
*/
typedef Callback <void, Ptr<const WifiMacQueueItem>> AckedMpdu;
/**
* Request the FrameExchangeManager to start a frame exchange sequence.
@@ -149,6 +153,12 @@ public:
* \param callback the callback to invoke when an MPDU is dropped
*/
virtual void SetDroppedMpduCallback (DroppedMpdu callback);
/**
* Set the callback to invoke when an MPDU is successfully acked.
*
* \param callback the callback to invoke when an MPDU is successfully acked
*/
void SetAckedMpduCallback (AckedMpdu callback);
/**
* Enable promiscuous mode.
*/
@@ -369,6 +379,7 @@ protected:
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
AckedMpdu m_ackedMpduCallback; //!< the acknowledged MPDU callback
/**
* Forward an MPDU down to the PHY layer.

View File

@@ -102,8 +102,6 @@ QosTxop::QosTxop ()
m_baManager->SetQueue (m_queue);
m_baManager->SetBlockDestinationCallback (MakeCallback (&QosBlockedDestinations::Block, m_qosBlockedDestinations));
m_baManager->SetUnblockDestinationCallback (MakeCallback (&QosBlockedDestinations::Unblock, m_qosBlockedDestinations));
m_baManager->SetTxOkCallback (MakeCallback (&QosTxop::BaTxOk, this));
m_baManager->SetTxFailedCallback (MakeCallback (&QosTxop::BaTxFailed, this));
}
QosTxop::~QosTxop ()
@@ -740,26 +738,6 @@ QosTxop::DoInitialize (void)
GenerateBackoff ();
}
void
QosTxop::BaTxOk (const WifiMacHeader &hdr)
{
NS_LOG_FUNCTION (this << hdr);
if (!m_txOkCallback.IsNull ())
{
m_txOkCallback (hdr);
}
}
void
QosTxop::BaTxFailed (const WifiMacHeader &hdr)
{
NS_LOG_FUNCTION (this << hdr);
if (!m_txFailedCallback.IsNull ())
{
m_txFailedCallback (hdr);
}
}
void
QosTxop::AddBaResponseTimeout (Mac48Address recipient, uint8_t tid)
{

View File

@@ -400,19 +400,6 @@ public:
*/
void AssignSequenceNumber (Ptr<WifiMacQueueItem> mpdu) const;
/**
* The packet we sent was successfully received by the receiver.
*
* \param hdr the header of the packet that we successfully sent.
*/
void BaTxOk (const WifiMacHeader &hdr);
/**
* The packet we sent was successfully received by the receiver.
*
* \param hdr the header of the packet that we failed to sent.
*/
void BaTxFailed (const WifiMacHeader &hdr);
/**
* Set the Queue Size subfield of the QoS Control field of the given QoS data frame.
*

View File

@@ -60,8 +60,6 @@ RegularWifiMac::RegularWifiMac ()
m_txop = CreateObject<Txop> ();
m_txop->SetChannelAccessManager (m_channelAccessManager);
m_txop->SetTxMiddle (m_txMiddle);
m_txop->SetTxOkCallback (MakeCallback (&RegularWifiMac::TxOk, this));
m_txop->SetTxFailedCallback (MakeCallback (&RegularWifiMac::TxFailed, this));
m_txop->SetDroppedMpduCallback (MakeCallback (&DroppedMpduTracedCallback::operator(),
&m_droppedMpduCallback));
@@ -159,6 +157,8 @@ RegularWifiMac::SetupFrameExchangeManager (void)
&m_psduResponseTimeoutCallback));
m_feManager->SetDroppedMpduCallback (MakeCallback (&DroppedMpduTracedCallback::operator(),
&m_droppedMpduCallback));
m_feManager->SetAckedMpduCallback (MakeCallback (&MpduTracedCallback::operator(),
&m_ackedMpduCallback));
m_channelAccessManager->SetupFrameExchangeManager (m_feManager);
if (GetQosSupported ())
{
@@ -468,8 +468,10 @@ RegularWifiMac::SetupEdcaQueue (AcIndex ac)
Ptr<QosTxop> edca = CreateObject<QosTxop> ();
edca->SetChannelAccessManager (m_channelAccessManager);
edca->SetTxMiddle (m_txMiddle);
edca->SetTxOkCallback (MakeCallback (&RegularWifiMac::TxOk, this));
edca->SetTxFailedCallback (MakeCallback (&RegularWifiMac::TxFailed, this));
edca->GetBaManager ()->SetTxOkCallback (MakeCallback (&MpduTracedCallback::operator(),
&m_ackedMpduCallback));
edca->GetBaManager ()->SetTxFailedCallback (MakeCallback (&MpduTracedCallback::operator(),
&m_nackedMpduCallback));
edca->SetDroppedMpduCallback (MakeCallback (&DroppedMpduTracedCallback::operator(),
&m_droppedMpduCallback));
edca->SetAccessCategory (ac);
@@ -1088,11 +1090,25 @@ RegularWifiMac::GetTypeId (void)
.AddTraceSource ("TxOkHeader",
"The header of successfully transmitted packet.",
MakeTraceSourceAccessor (&RegularWifiMac::m_txOkCallback),
"ns3::WifiMacHeader::TracedCallback")
"ns3::WifiMacHeader::TracedCallback",
TypeId::OBSOLETE,
"Use the AckedMpdu trace instead.")
.AddTraceSource ("TxErrHeader",
"The header of unsuccessfully transmitted packet.",
MakeTraceSourceAccessor (&RegularWifiMac::m_txErrCallback),
"ns3::WifiMacHeader::TracedCallback")
"ns3::WifiMacHeader::TracedCallback",
TypeId::OBSOLETE,
"Depending on the failure type, use the NAckedMpdu trace, the "
"DroppedMpdu trace or one of the traces associated with TX timeouts.")
.AddTraceSource ("AckedMpdu",
"An MPDU that was successfully acknowledged, via either a "
"Normal Ack or a Block Ack.",
MakeTraceSourceAccessor (&RegularWifiMac::m_ackedMpduCallback),
"ns3::WifiMacQueueItem::TracedCallback")
.AddTraceSource ("NAckedMpdu",
"An MPDU that was negatively acknowledged via a Block Ack.",
MakeTraceSourceAccessor (&RegularWifiMac::m_nackedMpduCallback),
"ns3::WifiMacQueueItem::TracedCallback")
.AddTraceSource ("DroppedMpdu",
"An MPDU that was dropped for the given reason (see WifiMacDropReason).",
MakeTraceSourceAccessor (&RegularWifiMac::m_droppedMpduCallback),
@@ -1173,18 +1189,4 @@ RegularWifiMac::ConfigureContentionWindow (uint32_t cwMin, uint32_t cwMax)
}
}
void
RegularWifiMac::TxOk (const WifiMacHeader &hdr)
{
NS_LOG_FUNCTION (this << hdr);
m_txOkCallback (hdr);
}
void
RegularWifiMac::TxFailed (const WifiMacHeader &hdr)
{
NS_LOG_FUNCTION (this << hdr);
m_txErrCallback (hdr);
}
} //namespace ns3

View File

@@ -89,21 +89,6 @@ public:
// Should be implemented by child classes
virtual void Enqueue (Ptr<Packet> packet, Mac48Address to) = 0;
/**
* The packet we sent was successfully received by the receiver
* (i.e. we received an Ack from the receiver).
*
* \param hdr the header of the packet that we successfully sent
*/
virtual void TxOk (const WifiMacHeader &hdr);
/**
* The packet we sent was successfully received by the receiver
* (i.e. we did not receive an Ack from the receiver).
*
* \param hdr the header of the packet that we failed to sent
*/
virtual void TxFailed (const WifiMacHeader &hdr);
/**
* Get the Frame Exchange Manager
*
@@ -466,6 +451,12 @@ private:
TracedCallback<const WifiMacHeader &> m_txOkCallback; ///< transmit OK callback
TracedCallback<const WifiMacHeader &> m_txErrCallback; ///< transmit error callback
/// TracedCallback for acked/nacked MPDUs typedef
typedef TracedCallback<Ptr<const WifiMacQueueItem>> MpduTracedCallback;
MpduTracedCallback m_ackedMpduCallback; ///< ack'ed MPDU callback
MpduTracedCallback m_nackedMpduCallback; ///< nack'ed MPDU callback
/**
* TracedCallback signature for MPDU drop events.
*

View File

@@ -135,20 +135,6 @@ Txop::SetWifiRemoteStationManager (const Ptr<WifiRemoteStationManager> remoteMan
m_stationManager = remoteManager;
}
void
Txop::SetTxOkCallback (TxOk callback)
{
NS_LOG_FUNCTION (this << &callback);
m_txOkCallback = callback;
}
void
Txop::SetTxFailedCallback (TxFailed callback)
{
NS_LOG_FUNCTION (this << &callback);
m_txFailedCallback = callback;
}
void
Txop::SetDroppedMpduCallback (DroppedMpdu callback)
{

View File

@@ -76,16 +76,6 @@ public:
*/
static TypeId GetTypeId (void);
/**
* typedef for a callback to invoke when a
* packet transmission was completed successfully.
*/
typedef Callback <void, const WifiMacHeader&> TxOk;
/**
* typedef for a callback to invoke when a
* packet transmission was failed.
*/
typedef Callback <void, const WifiMacHeader&> TxFailed;
/**
* typedef for a callback to invoke when an MPDU is dropped.
*/
@@ -127,16 +117,6 @@ public:
*/
void SetTxMiddle (const Ptr<MacTxMiddle> txMiddle);
/**
* \param callback the callback to invoke when a
* packet transmission was completed successfully.
*/
void SetTxOkCallback (TxOk callback);
/**
* \param callback the callback to invoke when a
* packet transmission was completed unsuccessfully.
*/
void SetTxFailedCallback (TxFailed callback);
/**
* \param callback the callback to invoke when an MPDU is dropped
*/
@@ -342,8 +322,6 @@ protected:
void UpdateBackoffSlotsNow (uint32_t nSlots, Time backoffUpdateBound);
Ptr<ChannelAccessManager> m_channelAccessManager; //!< the channel access manager
TxOk m_txOkCallback; //!< the transmit OK callback
TxFailed m_txFailedCallback; //!< the transmit failed callback
DroppedMpdu m_droppedMpduCallback; //!< the dropped MPDU callback
Ptr<WifiMacQueue> m_queue; //!< the wifi MAC queue
Ptr<MacTxMiddle> m_txMiddle; //!< the MacTxMiddle