wifi: Allow accessing start TXOP time in QosTxop

This commit is contained in:
Stefano Avallone
2023-09-20 17:12:38 +02:00
committed by Stefano Avallone
parent 637334f280
commit af0df4884a
3 changed files with 24 additions and 24 deletions

View File

@@ -126,7 +126,7 @@ QosFrameExchangeManager::PifsRecovery()
{
NS_LOG_FUNCTION(this);
NS_ASSERT(m_edca);
NS_ASSERT(m_edca->IsTxopStarted(m_linkId));
NS_ASSERT(m_edca->GetTxopStartTime(m_linkId).has_value());
// Release the channel if it has not been idle for the last PIFS interval
m_allowedWidth = std::min(
@@ -207,7 +207,7 @@ QosFrameExchangeManager::StartTransmission(Ptr<QosTxop> edca, Time txopDuration)
if (backingOff)
{
NS_ASSERT(m_edca->GetTxopLimit(m_linkId).IsStrictlyPositive());
NS_ASSERT(m_edca->IsTxopStarted(m_linkId));
NS_ASSERT(m_edca->GetTxopStartTime(m_linkId));
NS_ASSERT(!m_pifsRecovery);
NS_ASSERT(!m_initialFrame);
@@ -223,7 +223,7 @@ QosFrameExchangeManager::StartTransmission(Ptr<QosTxop> 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(m_linkId) ||
if (!m_edca->GetTxopStartTime(m_linkId) ||
(backingOff && m_edca->GetRemainingTxop(m_linkId).IsZero()))
{
// starting a new TXOP

View File

@@ -574,12 +574,12 @@ QosTxop::NotifyChannelAccessed(uint8_t linkId, Time txopDuration)
Txop::NotifyChannelAccessed(linkId);
}
bool
QosTxop::IsTxopStarted(uint8_t linkId) const
std::optional<Time>
QosTxop::GetTxopStartTime(uint8_t linkId) const
{
auto& link = GetLink(linkId);
NS_LOG_FUNCTION(this << !link.startTxop.IsZero());
return (!link.startTxop.IsZero());
NS_LOG_FUNCTION(this << link.startTxop.has_value());
return link.startTxop;
}
void
@@ -588,12 +588,12 @@ QosTxop::NotifyChannelReleased(uint8_t linkId)
NS_LOG_FUNCTION(this << +linkId);
auto& link = GetLink(linkId);
if (link.startTxop.IsStrictlyPositive())
if (link.startTxop)
{
NS_LOG_DEBUG("Terminating TXOP. Duration = " << Simulator::Now() - link.startTxop);
m_txopTrace(link.startTxop, Simulator::Now() - link.startTxop, linkId);
NS_LOG_DEBUG("Terminating TXOP. Duration = " << Simulator::Now() - *link.startTxop);
m_txopTrace(*link.startTxop, Simulator::Now() - *link.startTxop, linkId);
}
link.startTxop = Seconds(0);
link.startTxop.reset();
Txop::NotifyChannelReleased(linkId);
}
@@ -601,10 +601,10 @@ Time
QosTxop::GetRemainingTxop(uint8_t linkId) const
{
auto& link = GetLink(linkId);
NS_ASSERT(link.startTxop.IsStrictlyPositive());
NS_ASSERT(link.startTxop.has_value());
Time remainingTxop = link.txopDuration;
remainingTxop -= (Simulator::Now() - link.startTxop);
remainingTxop -= (Simulator::Now() - *link.startTxop);
if (remainingTxop.IsStrictlyNegative())
{
remainingTxop = Seconds(0);

View File

@@ -28,6 +28,8 @@
#include "ns3/traced-value.h"
#include <optional>
namespace ns3
{
@@ -324,12 +326,10 @@ class QosTxop : public Txop
uint8_t GetQosQueueSize(uint8_t tid, Mac48Address receiver) const;
/**
* 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.
* \return the TXOP start time, if a TXOP is ongoing on the given link
*/
virtual bool IsTxopStarted(uint8_t linkId) const;
virtual std::optional<Time> GetTxopStartTime(uint8_t linkId) const;
/**
* Return the remaining duration in the current TXOP on the given link.
*
@@ -429,13 +429,13 @@ class QosTxop : public Txop
/// Destructor (a virtual method is needed to make this struct polymorphic)
~QosLinkEntity() override = 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
Time muEdcaTimer{0}; //!< the MU EDCA Timer
Time muEdcaTimerStartTime{0}; //!< last start time of the MU EDCA Timer
std::optional<Time> startTxop; //!< 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
Time muEdcaTimer{0}; //!< the MU EDCA Timer
Time muEdcaTimerStartTime{0}; //!< last start time of the MU EDCA Timer
};
void DoDispose() override;