wifi: Make WifiAcknowledgment::acknowledgmentTime optional

...instead of relying on Time::Min() as blank value
This commit is contained in:
Stefano Avallone
2024-04-09 22:22:06 +02:00
parent d3b3ae2bcd
commit 2d9a2bb22f
8 changed files with 33 additions and 29 deletions

View File

@@ -401,7 +401,7 @@ FrameExchangeManager::SendMpduWithProtection(Ptr<WifiMpdu> mpdu, WifiTxParameter
// and SendCtsToSelf() can reuse this value.
NS_ASSERT(m_txParams.m_acknowledgment);
if (m_txParams.m_acknowledgment->acknowledgmentTime == Time::Min())
if (!m_txParams.m_acknowledgment->acknowledgmentTime.has_value())
{
CalculateAcknowledgmentTime(m_txParams.m_acknowledgment.get());
}
@@ -648,8 +648,8 @@ FrameExchangeManager::GetFrameDurationId(const WifiMacHeader& header,
NS_LOG_FUNCTION(this << header << size << &txParams << fragmentedPacket);
NS_ASSERT(txParams.m_acknowledgment &&
txParams.m_acknowledgment->acknowledgmentTime != Time::Min());
Time durationId = txParams.m_acknowledgment->acknowledgmentTime;
txParams.m_acknowledgment->acknowledgmentTime.has_value());
auto durationId = *txParams.m_acknowledgment->acknowledgmentTime;
// if the current frame is a fragment followed by another fragment, we have to
// update the Duration/ID to cover the next fragment and the corresponding Ack
@@ -706,9 +706,10 @@ FrameExchangeManager::SendRts(const WifiTxParameters& txParams)
auto rtsCtsProtection = static_cast<WifiRtsCtsProtection*>(txParams.m_protection.get());
NS_ASSERT(txParams.m_txDuration.has_value());
NS_ASSERT(txParams.m_acknowledgment->acknowledgmentTime.has_value());
rts.SetDuration(GetRtsDurationId(rtsCtsProtection->rtsTxVector,
*txParams.m_txDuration,
txParams.m_acknowledgment->acknowledgmentTime));
*txParams.m_acknowledgment->acknowledgmentTime));
Ptr<WifiMpdu> mpdu = Create<WifiMpdu>(Create<Packet>(), rts);
// After transmitting an RTS frame, the STA shall wait for a CTSTimeout interval with
@@ -807,9 +808,10 @@ FrameExchangeManager::SendCtsToSelf(const WifiTxParameters& txParams)
auto ctsToSelfProtection = static_cast<WifiCtsToSelfProtection*>(txParams.m_protection.get());
NS_ASSERT(txParams.m_txDuration.has_value());
NS_ASSERT(txParams.m_acknowledgment->acknowledgmentTime.has_value());
cts.SetDuration(GetCtsToSelfDurationId(ctsToSelfProtection->ctsTxVector,
*txParams.m_txDuration,
txParams.m_acknowledgment->acknowledgmentTime));
*txParams.m_acknowledgment->acknowledgmentTime));
ForwardMpduDown(Create<WifiMpdu>(Create<Packet>(), cts), ctsToSelfProtection->ctsTxVector);

View File

@@ -212,7 +212,7 @@ HeFrameExchangeManager::SendPsduMapWithProtection(WifiPsduMap psduMap, WifiTxPar
// can reuse this value.
NS_ASSERT(m_txParams.m_acknowledgment);
if (m_txParams.m_acknowledgment->acknowledgmentTime == Time::Min())
if (!m_txParams.m_acknowledgment->acknowledgmentTime.has_value())
{
CalculateAcknowledgmentTime(m_txParams.m_acknowledgment.get());
}
@@ -233,7 +233,7 @@ HeFrameExchangeManager::SendPsduMapWithProtection(WifiPsduMap psduMap, WifiTxPar
<< ") incompatible with BSRP Trigger Frame");
// Add a SIFS and the TB PPDU duration to the acknowledgment time of the Trigger Frame
auto txVector = trigger.GetHeTbTxVector(trigger.begin()->GetAid12());
m_txParams.m_acknowledgment->acknowledgmentTime +=
*m_txParams.m_acknowledgment->acknowledgmentTime +=
m_phy->GetSifs() + HePhy::ConvertLSigLengthToHeTbPpduDuration(trigger.GetUlLength(),
txVector,
m_phy->GetPhyBand());
@@ -361,11 +361,12 @@ HeFrameExchangeManager::SendMuRts(const WifiTxParameters& txParams)
auto mpdu = Create<WifiMpdu>(payload, hdr);
NS_ASSERT(txParams.m_txDuration.has_value());
NS_ASSERT(txParams.m_acknowledgment->acknowledgmentTime.has_value());
mpdu->GetHeader().SetDuration(
GetMuRtsDurationId(mpdu->GetSize(),
protection->muRtsTxVector,
*txParams.m_txDuration,
txParams.m_acknowledgment->acknowledgmentTime));
*txParams.m_acknowledgment->acknowledgmentTime));
// Get the TXVECTOR used by one station to send the CTS response. This is used
// to compute the preamble duration, so it does not matter which station we choose
@@ -624,7 +625,7 @@ HeFrameExchangeManager::SendPsduMap()
acknowledgment->muBarTxVector,
m_phy->GetPhyBand());
// update acknowledgmentTime to correctly set the Duration/ID
acknowledgment->acknowledgmentTime -= (m_phy->GetSifs() + txDuration);
*acknowledgment->acknowledgmentTime -= (m_phy->GetSifs() + txDuration);
m_triggerFrame->GetHeader().SetDuration(GetPsduDurationId(txDuration, m_txParams));
responseTxVector =

View File

@@ -348,7 +348,8 @@ RrMultiUserScheduler::TrySendingBsrpTf()
// TryAddMpdu only considers the time to transmit the Trigger Frame
NS_ASSERT(m_txParams.m_protection && m_txParams.m_protection->protectionTime.has_value());
NS_ASSERT(m_txParams.m_acknowledgment &&
m_txParams.m_acknowledgment->acknowledgmentTime.IsZero());
m_txParams.m_acknowledgment->acknowledgmentTime.has_value() &&
m_txParams.m_acknowledgment->acknowledgmentTime->IsZero());
NS_ASSERT(m_txParams.m_txDuration.has_value());
if (*m_txParams.m_protection->protectionTime + *m_txParams.m_txDuration // BSRP TF tx time
@@ -458,13 +459,13 @@ RrMultiUserScheduler::TrySendingBasicTf()
// TryAddMpdu only considers the time to transmit the Trigger Frame
NS_ASSERT(m_txParams.m_protection && m_txParams.m_protection->protectionTime.has_value());
NS_ASSERT(m_txParams.m_acknowledgment &&
m_txParams.m_acknowledgment->acknowledgmentTime != Time::Min());
m_txParams.m_acknowledgment->acknowledgmentTime.has_value());
NS_ASSERT(m_txParams.m_txDuration.has_value());
maxDuration = Min(maxDuration,
m_availableTime - *m_txParams.m_protection->protectionTime -
*m_txParams.m_txDuration - m_apMac->GetWifiPhy(m_linkId)->GetSifs() -
m_txParams.m_acknowledgment->acknowledgmentTime);
*m_txParams.m_acknowledgment->acknowledgmentTime);
if (maxDuration.IsNegative())
{
NS_LOG_DEBUG("Remaining TXOP duration is not enough for UL MU exchange");

View File

@@ -885,8 +885,8 @@ HtFrameExchangeManager::GetPsduDurationId(Time txDuration, const WifiTxParameter
if (m_edca->GetTxopLimit(m_linkId).IsZero())
{
NS_ASSERT(txParams.m_acknowledgment &&
txParams.m_acknowledgment->acknowledgmentTime != Time::Min());
return txParams.m_acknowledgment->acknowledgmentTime;
txParams.m_acknowledgment->acknowledgmentTime.has_value());
return *txParams.m_acknowledgment->acknowledgmentTime;
}
// under multiple protection settings, if the TXOP limit is not null, Duration/ID
@@ -920,7 +920,7 @@ HtFrameExchangeManager::SendPsduWithProtection(Ptr<WifiPsdu> psdu, WifiTxParamet
// and SendCtsToSelf() can reuse this value.
NS_ASSERT(m_txParams.m_acknowledgment);
if (m_txParams.m_acknowledgment->acknowledgmentTime == Time::Min())
if (!m_txParams.m_acknowledgment->acknowledgmentTime.has_value())
{
CalculateAcknowledgmentTime(m_txParams.m_acknowledgment.get());
}
@@ -1232,7 +1232,7 @@ HtFrameExchangeManager::TryAggregateMsdu(Ptr<const WifiMpdu> msdu,
// check if aggregating the given MSDU requires a different acknowledgment method
NS_ASSERT(txParams.m_acknowledgment);
Time acknowledgmentTime = txParams.m_acknowledgment->acknowledgmentTime;
auto acknowledgmentTime = txParams.m_acknowledgment->acknowledgmentTime;
std::unique_ptr<WifiAcknowledgment> acknowledgment;
acknowledgment = GetAckManager()->TryAggregateMsdu(msdu, txParams);
@@ -1248,12 +1248,12 @@ HtFrameExchangeManager::TryAggregateMsdu(Ptr<const WifiMpdu> msdu,
txParams.m_acknowledgment.swap(acknowledgment);
acknowledgmentSwapped = true;
}
NS_ASSERT(acknowledgmentTime != Time::Min());
NS_ASSERT(acknowledgmentTime.has_value());
Time ppduDurationLimit = Time::Min();
if (availableTime != Time::Min())
{
ppduDurationLimit = availableTime - *protectionTime - acknowledgmentTime;
ppduDurationLimit = availableTime - *protectionTime - *acknowledgmentTime;
}
if (!IsWithinLimitsIfAggregateMsdu(msdu, txParams, ppduDurationLimit))

View File

@@ -359,7 +359,7 @@ QosFrameExchangeManager::TryAddMpdu(Ptr<const WifiMpdu> mpdu,
NS_LOG_DEBUG("protection time=" << *protectionTime);
// check if adding the given MPDU requires a different acknowledgment method
Time acknowledgmentTime = Time::Min(); // uninitialized
std::optional<Time> acknowledgmentTime; // uninitialized
if (txParams.m_acknowledgment)
{
acknowledgmentTime = txParams.m_acknowledgment->acknowledgmentTime;
@@ -379,13 +379,13 @@ QosFrameExchangeManager::TryAddMpdu(Ptr<const WifiMpdu> mpdu,
txParams.m_acknowledgment.swap(acknowledgment);
acknowledgmentSwapped = true;
}
NS_ASSERT(acknowledgmentTime != Time::Min());
NS_LOG_DEBUG("acknowledgment time=" << acknowledgmentTime);
NS_ASSERT(acknowledgmentTime.has_value());
NS_LOG_DEBUG("acknowledgment time=" << *acknowledgmentTime);
Time ppduDurationLimit = Time::Min();
if (availableTime != Time::Min())
{
ppduDurationLimit = availableTime - *protectionTime - acknowledgmentTime;
ppduDurationLimit = availableTime - *protectionTime - *acknowledgmentTime;
}
if (!IsWithinLimitsIfAddMpdu(mpdu, txParams, ppduDurationLimit))
@@ -483,7 +483,7 @@ QosFrameExchangeManager::GetFrameDurationId(const WifiMacHeader& header,
}
NS_ASSERT(txParams.m_acknowledgment &&
txParams.m_acknowledgment->acknowledgmentTime != Time::Min());
txParams.m_acknowledgment->acknowledgmentTime.has_value());
// under multiple protection settings, if the TXOP limit is not null, Duration/ID
// is set to cover the remaining TXOP time (Sec. 9.2.5.2 of 802.11-2016).
@@ -491,7 +491,7 @@ QosFrameExchangeManager::GetFrameDurationId(const WifiMacHeader& header,
// of 802.11-2016)
return std::max(m_edca->GetRemainingTxop(m_linkId) -
m_phy->CalculateTxDuration(size, txParams.m_txVector, m_phy->GetPhyBand()),
txParams.m_acknowledgment->acknowledgmentTime);
*txParams.m_acknowledgment->acknowledgmentTime);
}
Time

View File

@@ -31,8 +31,7 @@ namespace ns3
*/
WifiAcknowledgment::WifiAcknowledgment(Method m)
: method(m),
acknowledgmentTime(Time::Min()) // uninitialized
: method(m)
{
}

View File

@@ -29,6 +29,7 @@
#include <map>
#include <memory>
#include <optional>
namespace ns3
{
@@ -101,8 +102,8 @@ struct WifiAcknowledgment
*/
virtual void Print(std::ostream& os) const = 0;
const Method method; //!< acknowledgment method
Time acknowledgmentTime; //!< time required by the acknowledgment method
const Method method; //!< acknowledgment method
std::optional<Time> acknowledgmentTime; //!< time required by the acknowledgment method
private:
/**

View File

@@ -194,7 +194,7 @@ TestMultiUserScheduler::SelectTxFormat()
(m_availableTime != Time::Min() &&
*m_txParams.m_protection->protectionTime + *m_txParams.m_txDuration // TF tx time
+ m_apMac->GetWifiPhy()->GetSifs() + duration +
m_txParams.m_acknowledgment->acknowledgmentTime >
*m_txParams.m_acknowledgment->acknowledgmentTime >
m_availableTime))
{
NS_LOG_DEBUG("Remaining TXOP duration is not enough for BSRP TF exchange");