wifi: Add PHY function to retrieve time until preamble detection period has elapsed

This commit is contained in:
Sébastien Deronne
2025-02-22 09:27:17 +01:00
committed by Stefano Avallone
parent bedc291ecb
commit b227e1614d
4 changed files with 53 additions and 34 deletions

View File

@@ -844,6 +844,27 @@ PhyEntity::GetReceptionStatus(Ptr<WifiMpdu> mpdu,
}
}
std::optional<Time>
PhyEntity::GetTimeToPreambleDetectionEnd() const
{
if (m_endPreambleDetectionEvents.empty())
{
return {};
}
std::optional<Time> delayUntilPreambleDetectionEnd;
for (const auto& endPreambleDetectionEvent : m_endPreambleDetectionEvents)
{
if (endPreambleDetectionEvent.IsPending())
{
delayUntilPreambleDetectionEnd =
std::max(delayUntilPreambleDetectionEnd.value_or(Time{0}),
Simulator::GetDelayLeft(endPreambleDetectionEvent));
}
}
return delayUntilPreambleDetectionEnd;
}
std::optional<Time>
PhyEntity::GetTimeToMacHdrEnd(uint16_t staId) const
{
@@ -1181,12 +1202,6 @@ PhyEntity::CancelAllEvents()
m_endOfMacHdrEvents.clear();
}
bool
PhyEntity::NoEndPreambleDetectionEvents() const
{
return m_endPreambleDetectionEvents.empty();
}
void
PhyEntity::CancelRunningEndPreambleDetectionEvents()
{

View File

@@ -400,22 +400,15 @@ class PhyEntity : public SimpleRefCount<PhyEntity>
* Cancel and clear all running events.
*/
virtual void CancelAllEvents();
/**
* @return \c true if there is no end preamble detection event running, \c false otherwise
*/
bool NoEndPreambleDetectionEvents() const;
/**
* Cancel all end preamble detection events.
*/
void CancelRunningEndPreambleDetectionEvents();
/**
* Get the remaining time to the end of the MAC header reception of the next MPDU being
* received from the given STA, if any.
*
* @param staId the STA-ID of the transmitter; equals SU_STA_ID for SU PPDUs
* @return the remaining time to the end of the MAC header reception of the next MPDU, if any
*/
/// @copydoc WifiPhy::GetTimeToPreambleDetectionEnd
virtual std::optional<Time> GetTimeToPreambleDetectionEnd() const;
/// @copydoc WifiPhy::GetTimeToMacHdrEnd
virtual std::optional<Time> GetTimeToMacHdrEnd(uint16_t staId) const;
/**

View File

@@ -1773,6 +1773,19 @@ WifiPhy::NotifyMonitorSniffTx(Ptr<const WifiPsdu> psdu,
}
}
std::optional<Time>
WifiPhy::GetTimeToPreambleDetectionEnd() const
{
for (const auto& [modClass, phyEntity] : m_phyEntities)
{
if (auto remTime = phyEntity->GetTimeToPreambleDetectionEnd())
{
return remTime;
}
}
return std::nullopt;
}
std::optional<Time>
WifiPhy::GetTimeToMacHdrEnd(uint16_t staId) const
{
@@ -1852,20 +1865,15 @@ WifiPhy::Send(const WifiConstPsduMap& psdus, const WifiTxVector& txVector)
const auto txDuration = CalculateTxDuration(psdus, txVector, GetPhyBand());
auto noEndPreambleDetectionEvent = true;
for (const auto& [mc, entity] : m_phyEntities)
{
noEndPreambleDetectionEvent =
noEndPreambleDetectionEvent && entity->NoEndPreambleDetectionEvents();
}
if (!noEndPreambleDetectionEvent && !m_currentEvent)
if (const auto timeToPreambleDetectionEnd = GetTimeToPreambleDetectionEnd();
timeToPreambleDetectionEnd && !m_currentEvent)
{
// PHY is in the initial few microseconds during which the
// start of RX has occurred but the preamble detection period
// has not elapsed
AbortCurrentReception(SIGNAL_DETECTION_ABORTED_BY_TX);
}
else if (!noEndPreambleDetectionEvent || m_currentEvent)
else if (timeToPreambleDetectionEnd || m_currentEvent)
{
AbortCurrentReception(RECEPTION_ABORTED_BY_TX);
}
@@ -1944,13 +1952,7 @@ WifiPhy::Reset()
{
NS_LOG_FUNCTION(this);
m_currentPreambleEvents.clear();
bool noEndPreambleDetectionEvent = true;
for (const auto& [mc, entity] : m_phyEntities)
{
noEndPreambleDetectionEvent =
noEndPreambleDetectionEvent && entity->NoEndPreambleDetectionEvents();
}
if (m_interference && (m_currentEvent || !noEndPreambleDetectionEvent))
if (m_interference && (m_currentEvent || GetTimeToPreambleDetectionEnd()))
{
m_interference->NotifyRxEnd(Simulator::Now(), GetCurrentFrequencyRange());
}

View File

@@ -117,7 +117,8 @@ class WifiPhy : public Object
* @return if the PHY is busy decoding the PHY header fields of a PPDU, return the TXVECTOR
* used to transmit the PPDU; otherwise, return a null optional value
*/
std::optional<std::reference_wrapper<const WifiTxVector>> GetInfoIfRxingPhyHeader() const;
virtual std::optional<std::reference_wrapper<const WifiTxVector>> GetInfoIfRxingPhyHeader()
const;
/**
* For HE receptions only, check and possibly modify the transmit power restriction state at
@@ -882,6 +883,14 @@ class WifiPhy : public Object
*/
dB_u GetRxGain() const;
/**
* Get the remaining time to preamble detection period to elapse, if preamble detection is
* ongoing.
*
* @return the remaining time to the end of the preamble detection detection period, if ongoing
*/
virtual std::optional<Time> GetTimeToPreambleDetectionEnd() const;
/**
* Get the remaining time to the end of the MAC header reception of the next MPDU being
* received from the given STA, if any.
@@ -889,7 +898,7 @@ class WifiPhy : public Object
* @param staId the STA-ID of the transmitter; equals SU_STA_ID for SU PPDUs
* @return the remaining time to the end of the MAC header reception of the next MPDU, if any
*/
std::optional<Time> GetTimeToMacHdrEnd(uint16_t staId) const;
virtual std::optional<Time> GetTimeToMacHdrEnd(uint16_t staId) const;
/**
* Sets the device this PHY is associated with.