From b5d158dd9dc72a90ef42d319ae3244f334eb7070 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Tue, 1 Mar 2022 11:55:51 +0100 Subject: [PATCH] wifi: QosTxop holds per-link TXOP information --- examples/wireless/wifi-80211e-txop.cc | 5 +-- examples/wireless/wifi-txop-aggregation.cc | 5 +-- .../model/ht/ht-frame-exchange-manager.cc | 2 +- src/wifi/model/qos-frame-exchange-manager.cc | 20 +++++------ src/wifi/model/qos-txop.cc | 36 ++++++++++--------- src/wifi/model/qos-txop.h | 19 ++++++---- src/wifi/model/wifi-default-ack-manager.cc | 2 +- src/wifi/test/block-ack-test-suite.cc | 6 ++-- 8 files changed, 53 insertions(+), 42 deletions(-) diff --git a/examples/wireless/wifi-80211e-txop.cc b/examples/wireless/wifi-80211e-txop.cc index e4c4d2262..a279d81fb 100644 --- a/examples/wireless/wifi-80211e-txop.cc +++ b/examples/wireless/wifi-80211e-txop.cc @@ -75,13 +75,14 @@ struct TxopDurationTracer * * \param startTime TXOP start time * \param duration TXOP duration + * \param linkId the ID of the link */ - void Trace (Time startTime, Time duration); + void Trace (Time startTime, Time duration, uint8_t linkId); Time m_max {Seconds (0)}; //!< maximum TXOP duration }; void -TxopDurationTracer::Trace (Time startTime, Time duration) +TxopDurationTracer::Trace (Time startTime, Time duration, uint8_t linkId) { if (duration > m_max) { diff --git a/examples/wireless/wifi-txop-aggregation.cc b/examples/wireless/wifi-txop-aggregation.cc index 3152bb408..5fabc2b22 100644 --- a/examples/wireless/wifi-txop-aggregation.cc +++ b/examples/wireless/wifi-txop-aggregation.cc @@ -84,13 +84,14 @@ struct TxopDurationTracer * * \param startTime TXOP start time * \param duration TXOP duration + * \param linkId the ID of the link */ - void Trace (Time startTime, Time duration); + void Trace (Time startTime, Time duration, uint8_t linkId); Time m_max {Seconds (0)}; //!< maximum TXOP duration }; void -TxopDurationTracer::Trace (Time startTime, Time duration) +TxopDurationTracer::Trace (Time startTime, Time duration, uint8_t linkId) { if (duration > m_max) { diff --git a/src/wifi/model/ht/ht-frame-exchange-manager.cc b/src/wifi/model/ht/ht-frame-exchange-manager.cc index 3d3cd3179..dd5f44a60 100644 --- a/src/wifi/model/ht/ht-frame-exchange-manager.cc +++ b/src/wifi/model/ht/ht-frame-exchange-manager.cc @@ -702,7 +702,7 @@ HtFrameExchangeManager::GetPsduDurationId (Time txDuration, const WifiTxParamete // is set to cover the remaining TXOP time (Sec. 9.2.5.2 of 802.11-2016). // The TXOP holder may exceed the TXOP limit in some situations (Sec. 10.22.2.8 // of 802.11-2016) - return std::max (m_edca->GetRemainingTxop () - txDuration, Seconds (0)); + return std::max (m_edca->GetRemainingTxop (m_linkId) - txDuration, Seconds (0)); } void diff --git a/src/wifi/model/qos-frame-exchange-manager.cc b/src/wifi/model/qos-frame-exchange-manager.cc index 7d00d92ed..3ecbd52cb 100644 --- a/src/wifi/model/qos-frame-exchange-manager.cc +++ b/src/wifi/model/qos-frame-exchange-manager.cc @@ -101,7 +101,7 @@ QosFrameExchangeManager::SendCfEndIfNeeded (void) cfEndTxVector, m_phy->GetPhyBand ()); // Send the CF-End frame if the remaining duration is long enough to transmit this frame - if (m_edca->GetRemainingTxop () > txDuration) + if (m_edca->GetRemainingTxop (m_linkId) > txDuration) { NS_LOG_DEBUG ("Send CF-End frame"); m_phy->Send (Create (Create (), cfEnd), cfEndTxVector); @@ -119,7 +119,7 @@ QosFrameExchangeManager::PifsRecovery (void) { NS_LOG_FUNCTION (this); NS_ASSERT (m_edca != 0); - NS_ASSERT (m_edca->IsTxopStarted ()); + NS_ASSERT (m_edca->IsTxopStarted (m_linkId)); // Release the channel if it has not been idle for the last PIFS interval if (m_channelAccessManager->GetAccessGrantStart () - m_phy->GetSifs () @@ -196,7 +196,7 @@ QosFrameExchangeManager::StartTransmission (Ptr edca, Time txopDuration if (backingOff) { NS_ASSERT (m_edca->GetTxopLimit ().IsStrictlyPositive ()); - NS_ASSERT (m_edca->IsTxopStarted ()); + NS_ASSERT (m_edca->IsTxopStarted (m_linkId)); NS_ASSERT (!m_pifsRecovery); NS_ASSERT (!m_initialFrame); @@ -212,8 +212,8 @@ QosFrameExchangeManager::StartTransmission (Ptr edca, Time txopDuration // TXOP. In such a case, we assume that a new TXOP is being started if it // elapsed more than TXOPlimit since the start of the paused TXOP. Note // that GetRemainingTxop returns 0 iff Now - TXOPstart >= TXOPlimit - if (!m_edca->IsTxopStarted () - || (backingOff && m_edca->GetRemainingTxop ().IsZero ())) + if (!m_edca->IsTxopStarted (m_linkId) + || (backingOff && m_edca->GetRemainingTxop (m_linkId).IsZero ())) { // starting a new TXOP m_edca->NotifyChannelAccessed (m_linkId, txopDuration); @@ -234,7 +234,7 @@ QosFrameExchangeManager::StartTransmission (Ptr edca, Time txopDuration // We are continuing a TXOP, check if we can transmit another frame NS_ASSERT (!m_initialFrame); - if (!StartFrameExchange (m_edca, m_edca->GetRemainingTxop (), false)) + if (!StartFrameExchange (m_edca, m_edca->GetRemainingTxop (m_linkId), false)) { NS_LOG_DEBUG ("Not enough remaining TXOP time"); return SendCfEndIfNeeded (); @@ -461,7 +461,7 @@ QosFrameExchangeManager::GetFrameDurationId (const WifiMacHeader& header, uint32 // is set to cover the remaining TXOP time (Sec. 9.2.5.2 of 802.11-2016). // The TXOP holder may exceed the TXOP limit in some situations (Sec. 10.22.2.8 // of 802.11-2016) - return std::max (m_edca->GetRemainingTxop () + return std::max (m_edca->GetRemainingTxop (m_linkId) - m_phy->CalculateTxDuration (size, txParams.m_txVector, m_phy->GetPhyBand ()), txParams.m_acknowledgment->acknowledgmentTime); } @@ -486,7 +486,7 @@ QosFrameExchangeManager::GetRtsDurationId (const WifiTxVector& rtsTxVector, Time // is set to cover the remaining TXOP time (Sec. 9.2.5.2 of 802.11-2016). // The TXOP holder may exceed the TXOP limit in some situations (Sec. 10.22.2.8 // of 802.11-2016) - return std::max (m_edca->GetRemainingTxop () + return std::max (m_edca->GetRemainingTxop (m_linkId) - m_phy->CalculateTxDuration (GetRtsSize (), rtsTxVector, m_phy->GetPhyBand ()), Seconds (0)); } @@ -512,7 +512,7 @@ QosFrameExchangeManager::GetCtsToSelfDurationId (const WifiTxVector& ctsTxVector // is set to cover the remaining TXOP time (Sec. 9.2.5.2 of 802.11-2016). // The TXOP holder may exceed the TXOP limit in some situations (Sec. 10.22.2.8 // of 802.11-2016) - return std::max (m_edca->GetRemainingTxop () + return std::max (m_edca->GetRemainingTxop (m_linkId) - m_phy->CalculateTxDuration (GetCtsSize (), ctsTxVector, m_phy->GetPhyBand ()), Seconds (0)); } @@ -547,7 +547,7 @@ QosFrameExchangeManager::TransmissionSucceeded (void) } if (m_edca->GetTxopLimit ().IsStrictlyPositive () - && m_edca->GetRemainingTxop () > m_phy->GetSifs ()) + && m_edca->GetRemainingTxop (m_linkId) > m_phy->GetSifs ()) { NS_LOG_DEBUG ("Schedule another transmission in a SIFS"); bool (QosFrameExchangeManager::*fp) (Ptr, Time) = &QosFrameExchangeManager::StartTransmission; diff --git a/src/wifi/model/qos-txop.cc b/src/wifi/model/qos-txop.cc index b866c8a45..51441502b 100644 --- a/src/wifi/model/qos-txop.cc +++ b/src/wifi/model/qos-txop.cc @@ -85,16 +85,14 @@ QosTxop::GetTypeId (void) .AddTraceSource ("TxopTrace", "Trace source for TXOP start and duration times", MakeTraceSourceAccessor (&QosTxop::m_txopTrace), - "ns3::TracedValueCallback::Time") + "ns3::QosTxop::TxopTracedCallback") ; return tid; } QosTxop::QosTxop (AcIndex ac) : Txop (CreateObject (ac)), - m_ac (ac), - m_startTxop (Seconds (0)), - m_txopDuration (Seconds (0)) + m_ac (ac) { NS_LOG_FUNCTION (this); m_qosBlockedDestinations = Create (); @@ -536,38 +534,42 @@ QosTxop::NotifyChannelAccessed (uint8_t linkId, Time txopDuration) NS_LOG_FUNCTION (this << +linkId << txopDuration); NS_ASSERT (txopDuration != Time::Min ()); - m_startTxop = Simulator::Now (); - m_txopDuration = txopDuration; + GetLink (linkId).startTxop = Simulator::Now (); + GetLink (linkId).txopDuration = txopDuration; Txop::NotifyChannelAccessed (linkId); } bool -QosTxop::IsTxopStarted (void) const +QosTxop::IsTxopStarted (uint8_t linkId) const { - NS_LOG_FUNCTION (this << !m_startTxop.IsZero ()); - return (!m_startTxop.IsZero ()); + auto& link = GetLink (linkId); + NS_LOG_FUNCTION (this << !link.startTxop.IsZero ()); + return (!link.startTxop.IsZero ()); } void QosTxop::NotifyChannelReleased (uint8_t linkId) { NS_LOG_FUNCTION (this << +linkId); + auto& link = GetLink (linkId); - if (m_startTxop.IsStrictlyPositive ()) + if (link.startTxop.IsStrictlyPositive ()) { - NS_LOG_DEBUG ("Terminating TXOP. Duration = " << Simulator::Now () - m_startTxop); - m_txopTrace (m_startTxop, Simulator::Now () - m_startTxop); + NS_LOG_DEBUG ("Terminating TXOP. Duration = " << Simulator::Now () - link.startTxop); + m_txopTrace (link.startTxop, Simulator::Now () - link.startTxop, linkId); } - m_startTxop = Seconds (0); + link.startTxop = Seconds (0); Txop::NotifyChannelReleased (linkId); } Time -QosTxop::GetRemainingTxop (void) const +QosTxop::GetRemainingTxop (uint8_t linkId) const { - NS_ASSERT (m_startTxop.IsStrictlyPositive ()); - Time remainingTxop = m_txopDuration; - remainingTxop -= (Simulator::Now () - m_startTxop); + auto& link = GetLink (linkId); + NS_ASSERT (link.startTxop.IsStrictlyPositive ()); + + Time remainingTxop = link.txopDuration; + remainingTxop -= (Simulator::Now () - link.startTxop); if (remainingTxop.IsStrictlyNegative ()) { remainingTxop = Seconds (0); diff --git a/src/wifi/model/qos-txop.h b/src/wifi/model/qos-txop.h index 3de46a58a..d76029278 100644 --- a/src/wifi/model/qos-txop.h +++ b/src/wifi/model/qos-txop.h @@ -352,17 +352,19 @@ public: uint8_t GetQosQueueSize (uint8_t tid, Mac48Address receiver) const; /** - * Return true if a TXOP has started. + * Return true if a TXOP has started on the given link. * + * \param linkId the ID of the given link * \return true if a TXOP has started, false otherwise. */ - virtual bool IsTxopStarted (void) const; + virtual bool IsTxopStarted (uint8_t linkId) const; /** - * Return the remaining duration in the current TXOP. + * Return the remaining duration in the current TXOP on the given link. * + * \param linkId the ID of the given link * \return the remaining duration in the current TXOP. */ - virtual Time GetRemainingTxop (void) const; + virtual Time GetRemainingTxop (uint8_t linkId) const; /** * Set the minimum contention window size to use while the MU EDCA Timer @@ -455,6 +457,8 @@ protected: /// Destructor (a virtual method is needed to make this struct polymorphic) virtual ~QosLinkEntity () = default; + Time startTxop {0}; //!< the start TXOP time + Time txopDuration {0}; //!< the duration of a TXOP uint32_t muCwMin {0}; //!< the MU CW minimum uint32_t muCwMax {0}; //!< the MU CW maximum uint8_t muAifsn {0}; //!< the MU AIFSN @@ -495,13 +499,14 @@ private: this value. If this value is 0, block ack is never used. When A-MPDU is enabled, block ack mechanism is used regardless of this value) */ uint16_t m_blockAckInactivityTimeout; //!< the BlockAck inactivity timeout value (in TUs, i.e. blocks of 1024 microseconds) - Time m_startTxop; //!< the start TXOP time - Time m_txopDuration; //!< the duration of a TXOP Time m_addBaResponseTimeout; //!< timeout for ADDBA response Time m_failedAddBaTimeout; //!< timeout after failed BA agreement bool m_useExplicitBarAfterMissedBlockAck; //!< flag whether explicit BlockAckRequest should be sent upon missed BlockAck Response - TracedCallback m_txopTrace; //!< TXOP trace callback + /// TracedCallback for TXOP trace typedef + typedef TracedCallback