wifi: QosTxop holds per-link TXOP information

This commit is contained in:
Stefano Avallone
2022-03-01 11:55:51 +01:00
parent b0d85940bf
commit b5d158dd9d
8 changed files with 53 additions and 42 deletions

View File

@@ -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)
{

View File

@@ -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)
{

View File

@@ -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

View File

@@ -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<WifiPsdu> (Create<Packet> (), 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<QosTxop> 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<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 ()
|| (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<QosTxop> 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<QosTxop>, Time) = &QosFrameExchangeManager::StartTransmission;

View File

@@ -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<WifiMacQueue> (ac)),
m_ac (ac),
m_startTxop (Seconds (0)),
m_txopDuration (Seconds (0))
m_ac (ac)
{
NS_LOG_FUNCTION (this);
m_qosBlockedDestinations = Create<QosBlockedDestinations> ();
@@ -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);

View File

@@ -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<Time, Time> m_txopTrace; //!< TXOP trace callback
/// TracedCallback for TXOP trace typedef
typedef TracedCallback<Time /* start time */, Time /* duration */, uint8_t /* link ID*/> TxopTracedCallback;
TxopTracedCallback m_txopTrace; //!< TXOP trace callback
};
} //namespace ns3

View File

@@ -154,7 +154,7 @@ WifiDefaultAckManager::IsResponseNeeded (Ptr<const WifiMacQueueItem> mpdu,
&& (edca->GetWifiMacQueue ()->GetNPackets (tid, receiver)
- edca->GetBaManager ()->GetNBufferedPackets (receiver, tid) > 1)
&& !(edca->GetTxopLimit ().IsStrictlyPositive ()
&& edca->GetRemainingTxop () == edca->GetTxopLimit ()
&& edca->GetRemainingTxop (m_linkId) == edca->GetTxopLimit ()
&& !(txParams.m_protection && txParams.m_protection->method == WifiProtection::RTS_CTS)))
{
return false;

View File

@@ -1354,8 +1354,9 @@ class BlockAckAggregationDisabledTest : public TestCase
* Callback for the TxopTrace trace
* \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)}; ///< max TXOP duration
};
@@ -1403,7 +1404,8 @@ private:
};
void
BlockAckAggregationDisabledTest::TxopDurationTracer::Trace (Time startTime, Time duration)
BlockAckAggregationDisabledTest::TxopDurationTracer::Trace (Time startTime, Time duration,
uint8_t linkId)
{
if (duration > m_max)
{