27 #include "ns3/ap-wifi-mac.h"
28 #include "ns3/assert.h"
29 #include "ns3/interference-helper.h"
31 #include "ns3/simulator.h"
32 #include "ns3/sta-wifi-mac.h"
33 #include "ns3/vht-configuration.h"
34 #include "ns3/wifi-net-device.h"
35 #include "ns3/wifi-phy.h"
36 #include "ns3/wifi-psdu.h"
37 #include "ns3/wifi-utils.h"
80 m_trigVector(std::nullopt),
81 m_trigVectorExpirationTime(std::nullopt),
82 m_currentTxVector(std::nullopt),
84 m_lastPer20MHzDurations()
155 uint8_t smallestMcs = 5;
158 smallestMcs =
std::min(smallestMcs, info.second.mcs);
193 uint8_t nExtensionLtf )
const
206 NS_ABORT_MSG_IF(nDataLtf > 8,
"Unsupported number of LTFs " << +nDataLtf <<
" for HE");
207 NS_ABORT_MSG_IF(nExtensionLtf > 0,
"No extension LTFs expected for HE");
208 return stfDuration + ltfDuration * nDataLtf;
231 auto numSymbols = ceil((sigBSize) / ndbps);
233 return FemtoSeconds(
static_cast<uint64_t
>(numSymbols * symbolDuration.GetFemtoSeconds()));
249 floor(
static_cast<double>((ppduDuration - preambleDuration).GetNanoSeconds() -
250 (sigExtension * 1000)) /
252 return preambleDuration + (nSymbols * tSymbol) +
MicroSeconds(sigExtension);
255 std::pair<uint16_t, Time>
265 uint16_t length = ((ceil((
static_cast<double>(ppduDuration.
GetNanoSeconds() - (20 * 1000) -
266 (sigExtension * 1000)) /
271 return {length, ppduDuration};
283 Time calculatedDuration =
284 MicroSeconds(((ceil(
static_cast<double>(length + 3 +
m) / 3)) * 4) + 20 + sigExtension);
317 NS_ASSERT(gi == 800 || gi == 1600 || gi == 3200);
340 return Create<HePpdu>(psdus,
356 const auto& txVector = ppdu->GetTxVector();
357 auto hePpdu = DynamicCast<const HePpdu>(ppdu);
359 const auto psdFlag = hePpdu->GetTxPsdFlag();
368 NS_LOG_INFO(
"Switch to OFDMA part (already started? "
369 << (ofdmaStarted ?
"Y" :
"N") <<
") "
370 <<
"and schedule OFDMA payload reception in "
385 NS_LOG_INFO(
"Consider OFDMA part of the PPDU as interference since device dropped the "
397 ppdu->GetTxDuration());
407 beginOfdmaPayloadRxEvent.second.Cancel();
421 endMpduEvent.Cancel();
441 beginOfdmaPayloadRxEvent.second.Cancel();
454 auto uidPreamblePair = std::make_pair(ppdu->GetUid(), ppdu->GetPreamble());
456 auto it = currentPreambleEvents.find(uidPreamblePair);
460 const auto& txVector = ppdu->GetTxVector();
469 rxDuration = ppdu->GetTxDuration();
471 if (it != currentPreambleEvents.end())
476 << ppdu->GetUid() <<
" from STA-ID " << ppdu->GetStaId()
477 <<
" and BSS color " << +txVector.GetBssColor());
481 NS_LOG_DEBUG(
"Received another response to a trigger frame " << ppdu->GetUid());
494 if (heConfiguration->GetMaxTbPpduDelay().IsStrictlyPositive())
496 maxDelay =
Min(maxDelay, heConfiguration->GetMaxTbPpduDelay());
516 NS_LOG_DEBUG(
"Drop packet because already receiving another HE TB PPDU");
523 "Drop packet because already receiving another response to a trigger frame");
533 << ppdu->GetUid() <<
" from STA-ID " << ppdu->GetStaId()
534 <<
" and BSS color " << +txVector.GetBssColor());
538 NS_LOG_DEBUG(
"Received response to a trigger frame for UID " << ppdu->GetUid());
546 const auto& txVector = ppdu->GetTxVector();
554 if (it == currentPreambleEvents.end())
561 "Update received power of the event associated to these UL transmissions with UID "
576 auto hePpdu = DynamicCast<const HePpdu>(ppdu);
586 uint8_t bssColor = 0;
592 bssColor = heConfiguration->GetBssColor();
603 return ppdu->GetStaId();
608 if (
mac &&
mac->IsAssociated())
610 return mac->GetAssociationId();
650 if (myBssColor != 0 && rxBssColor != 0 && myBssColor != rxBssColor)
653 << +rxBssColor <<
") does not match the device's (" << +myBssColor
654 <<
"). The PPDU is filtered.");
676 NS_LOG_DEBUG(
"No valid TRIGVECTOR, the PHY was not expecting a TB PPDU");
687 NS_LOG_DEBUG(
"Received channel width different than in TRIGVECTOR");
693 <<
") different than in TRIGVECTOR ("
697 uint16_t staId = ppdu->GetStaId();
701 NS_LOG_DEBUG(
"TB PPDU received from un unexpected STA ID");
720 "No PSDU addressed to that PHY in the received MU PPDU. The PPDU is filtered.");
760 "No PSDU addressed to that PHY in the received MU PPDU. The PPDU is filtered.");
764 if (event->GetTxVector().IsDlMu())
774 event->GetPpdu()->GetUid();
796 if (info.first == staId)
798 nss = info.second.nss;
806 NS_LOG_DEBUG(
"Packet reception could not be started because not enough RX antennas");
811 NS_LOG_DEBUG(
"Drop packet because it was sent using an unsupported mode ("
822 const auto& txVector =
event->GetTxVector();
824 if (!txVector.IsMu())
832 if (txVector.IsDlMu())
834 Time payloadDuration =
837 return payloadDuration;
853 Time timeToEndRx = payloadDuration + maxOffset;
857 NS_LOG_DEBUG(
"Ignore HE TB PPDU payload received by STA but keep state in Rx");
866 beginOfdmaPayloadRxEvent.second.Cancel();
875 m_statusPerMpduMap.insert({std::make_pair(ppdu->GetUid(), staId), std::vector<bool>()});
881 NS_ASSERT(beginOfdmaPayloadRxEvent.second.IsRunning());
893 const std::vector<bool>& statusPerMpdu)
896 m_state->NotifyRxPsduSucceeded(psdu, rxSignalInfo, txVector, staId, statusPerMpdu);
911 m_state->NotifyRxPsduFailed(psdu, snr);
914 m_state->SwitchFromRxEndError();
947 m_state->SwitchFromRxEndError();
968 auto it = rxPowersW.end();
971 it = std::max_element(
974 [](
const std::pair<WifiSpectrumBand, double>& p1,
975 const std::pair<WifiSpectrumBand, double>& p2) { return p1.second < p2.second; });
990 Time payloadDuration =
998 m_statusPerMpduMap.insert({std::make_pair(ppdu->GetUid(), staId), std::vector<bool>()});
1003 std::pair<uint16_t, WifiSpectrumBand>
1006 if (txVector.
IsMu())
1024 NS_ASSERT(channelWidth <= m_wifiPhy->GetChannelWidth());
1044 NS_ASSERT(channelWidth <= m_wifiPhy->GetChannelWidth());
1065 NS_ASSERT(channelWidth <= m_wifiPhy->GetChannelWidth());
1080 std::make_pair(groupPreamble.front().first, groupPreamble.back().second);
1121 return channelWidth;
1142 const uint16_t ppduBw = ppdu->GetTxVector().GetChannelWidth();
1144 uint16_t bw = ppduBw;
1160 if (ccaIndication.has_value())
1162 NS_LOG_DEBUG(
"CCA busy for " << ccaIndication.value().second <<
" during "
1163 << ccaIndication.value().first.As(
Time::S));
1164 NotifyCcaBusy(ccaIndication.value().first, ccaIndication.value().second, per20MHzDurations);
1195 const std::vector<Time>& per20MHzDurations)
1198 m_state->SwitchMaybeToCcaBusy(duration, channelType, per20MHzDurations);
1218 std::vector<Time> per20MhzDurations{};
1221 for (
auto index : indices)
1230 double ccaThresholdDbm = -62;
1235 const uint16_t subchannelMinFreq =
1237 const uint16_t subchannelMaxFreq = subchannelMinFreq + 20;
1238 const uint16_t ppduBw = ppdu->GetTxVector().GetChannelWidth();
1240 if (ppduBw <= m_wifiPhy->GetChannelWidth() &&
1241 ppdu->DoesOverlapChannel(subchannelMinFreq, subchannelMaxFreq))
1243 std::optional<double> obssPdLevel{std::nullopt};
1259 obssPdLevel.has_value() ?
std::max(-72.0, obssPdLevel.value()) : -72.0;
1270 obssPdLevel.has_value() ?
std::max(-72.0, obssPdLevel.value() + 3) : -72.0;
1281 obssPdLevel.has_value() ?
std::max(-69.0, obssPdLevel.value() + 6) : -69.0;
1292 delayUntilCcaEnd =
std::max(delayUntilCcaEnd, ppduCcaDuration);
1294 per20MhzDurations.push_back(delayUntilCcaEnd);
1297 return per20MhzDurations;
1323 auto hePpdu = DynamicCast<const HePpdu>(ppdu);
1334 const auto& txVector = ppdu->GetTxVector();
1336 uint16_t channelWidth = txVector.GetChannelWidth();
1337 NS_LOG_FUNCTION(
this << centerFrequency << channelWidth << txPowerW << txVector);
1338 const auto& puncturedSubchannels = txVector.GetInactiveSubchannels();
1339 if (!puncturedSubchannels.empty())
1342 const auto& indices =
1344 const auto p20IndexInBitmap = p20Index - *(indices.cbegin());
1346 !puncturedSubchannels.at(p20IndexInBitmap));
1349 switch (ppdu->GetType())
1355 const uint16_t staId =
GetStaId(ppdu);
1358 channelWidth = (ruWidth < 20) ? 20 : ruWidth;
1364 std::get<0>(txMaskRejectionParams),
1365 std::get<1>(txMaskRejectionParams),
1366 std::get<2>(txMaskRejectionParams),
1367 puncturedSubchannels);
1388 std::get<0>(txMaskRejectionParams),
1389 std::get<1>(txMaskRejectionParams),
1390 std::get<2>(txMaskRejectionParams),
1391 puncturedSubchannels);
1400 std::get<0>(txMaskRejectionParams),
1401 std::get<1>(txMaskRejectionParams),
1402 std::get<2>(txMaskRejectionParams),
1403 puncturedSubchannels);
1408 NS_ASSERT(puncturedSubchannels.empty());
1414 std::get<0>(txMaskRejectionParams),
1415 std::get<1>(txMaskRejectionParams),
1416 std::get<2>(txMaskRejectionParams));
1431 if (nonOfdmaWidth != currentWidth)
1437 uint16_t startingFrequency = centerFrequency - (currentWidth / 2);
1446 return centerFrequency;
1453 const auto& txVector = ppdu->GetTxVector();
1460 auto nonOfdmaTxPowerDbm =
1465 auto hePpdu = DynamicCast<const HePpdu>(ppdu);
1475 auto nonOfdmaTxPowerSpectrum =
1480 nonOfdmaTxPowerSpectrum,
1481 "non-OFDMA transmission");
1484 auto ofdmaDuration = ppdu->GetTxDuration() - nonOfdmaDuration;
1485 auto ofdmaTxPowerSpectrum =
1492 ofdmaTxPowerSpectrum,
1508 auto hePpdu = DynamicCast<const HePpdu>(ppdu);
1511 Transmit(ofdmaDuration, ppdu, txPowerDbm, txPowerSpectrum,
"OFDMA transmission");
1526 for (
auto& staIdPsdu : psduMap)
1532 NS_ABORT_MSG_IF(userInfoMap.find(staIdPsdu.first) == userInfoMap.end(),
1533 "STA-ID in psduMap (" << staIdPsdu.first
1534 <<
") should be referenced in txVector");
1540 if (current > maxDuration)
1542 maxDuration = current;
1552 for (uint8_t i = 0; i < 12; ++i)
1563 return GetHeMcs##x();
1580 NS_ABORT_MSG(
"Inexistent index (" << +index <<
") requested for HE");
1586 #define GET_HE_MCS(x) \
1587 WifiMode HePhy::GetHeMcs##x() \
1589 static WifiMode mcs = CreateHeMcs(x); \
1654 uint64_t dataRate =
GetDataRate(mcsValue, channelWidth, guardInterval, nss);
1662 if (txVector.
IsMu())
1676 if (txVector.
IsMu())
1689 NS_ASSERT(guardInterval == 800 || guardInterval == 1600 || guardInterval == 3200);
1701 switch (channelWidth)
1739 switch (constellationSize)
1744 dataRate = 54000000;
1748 NS_FATAL_ERROR(
"Trying to get reference rate for a MCS with wrong combination of "
1749 "coding rate and modulation");
1794 auto commonFieldSize = 4 + 6 ;
1797 commonFieldSize += 8;
1801 commonFieldSize += 8 * (bw / 40) + 1 ;
1805 auto maxNumStaPerContentChannel =
1806 std::max(numStaPerContentChannel.first, numStaPerContentChannel.second);
1807 auto maxNumUserBlockFields = maxNumStaPerContentChannel /
1809 std::size_t userSpecificFieldSize =
1810 maxNumUserBlockFields * (2 * 21 + 4 + 6 );
1811 if (maxNumStaPerContentChannel % 2 != 0)
1813 userSpecificFieldSize += 21 + 4 + 6 ;
1816 return commonFieldSize + userSpecificFieldSize;
1831 if (ppdu->GetTxVector().IsUlMu() &&
mac &&
mac->GetTypeOfStation() ==
AP)
1850 rxPpdu = ppdu->Copy();
1856 auto hePpdu = DynamicCast<const HePpdu>(rxPpdu);
1861 else if (
auto txVector = ppdu->GetTxVector();
1867 if (txVector.GetChannelWidth() != triggerChannelWidth)
1869 txVector.SetChannelWidth(triggerChannelWidth);
1870 ppdu->UpdateTxVector(txVector);
Constructor class for HE modes.
bool IsNull() const
Check for null implementation.
std::optional< WifiTxVector > m_trigVector
the TRIGVECTOR
Time GetLSigDuration(WifiPreamble preamble) const override
static Time ConvertLSigLengthToHeTbPpduDuration(uint16_t length, const WifiTxVector &txVector, WifiPhyBand band)
void StartReceiveOfdmaPayload(Ptr< Event > event)
Start receiving the PSDU (i.e.
uint64_t GetCurrentHeTbPpduUid() const
Ptr< Event > DoGetEvent(Ptr< const WifiPpdu > ppdu, RxPowerWattPerChannelBand &rxPowersW) override
Get the event corresponding to the incoming PPDU.
void CancelAllEvents() override
Cancel and clear all running events.
WifiSpectrumBand GetNonOfdmaBand(const WifiTxVector &txVector, uint16_t staId) const
Get the band used to transmit the non-OFDMA part of an HE TB PPDU.
void SetObssPdAlgorithm(const Ptr< ObssPdAlgorithm > algorithm)
Sets the OBSS-PD algorithm.
static void InitializeModes()
Initialize all HE modes.
static uint32_t GetSigBFieldSize(const WifiTxVector &txVector)
Get variable length HE SIG-B field size based on TX Vector.
void DoAbortCurrentReception(WifiPhyRxfailureReason reason) override
Perform amendment-specific actions before aborting the current reception.
Time CalculateTxDuration(WifiConstPsduMap psduMap, const WifiTxVector &txVector, WifiPhyBand band) const override
std::pair< uint16_t, WifiSpectrumBand > GetChannelWidthAndBand(const WifiTxVector &txVector, uint16_t staId) const override
Get the channel width and band to use (will be overloaded by child classes).
void StartTxOfdma(Ptr< const WifiPpdu > ppdu, double txPowerDbm, Ptr< SpectrumValue > txPowerSpectrum, Time ofdmaDuration)
Start the transmission of the OFDMA part of the MU PPDU.
virtual PhyFieldRxStatus ProcessSigB(Ptr< Event > event, PhyFieldRxStatus status)
Process SIG-B, perform amendment-specific actions, and provide an updated status of the reception.
std::optional< WifiTxVector > m_currentTxVector
If the STA is an AP STA, this holds the TXVECTOR of the PPDU that has been sent.
Time GetSigBDuration(const WifiTxVector &txVector) const override
static WifiMode CreateHeMcs(uint8_t index)
Create and return the HE MCS corresponding to the provided index.
static WifiMode GetHeMcs(uint8_t index)
Return the HE MCS corresponding to the provided index.
void BuildModeList() override
Build mode list.
WifiConstPsduMap GetWifiConstPsduMap(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector) const override
Get a WifiConstPsduMap from a PSDU and the TXVECTOR to use to send the PSDU.
uint16_t GetNonOfdmaWidth(HeRu::RuSpec ru) const
Get the width in MHz of the non-OFDMA portion of an HE TB PPDU.
static uint64_t CalculateNonHtReferenceRate(WifiCodeRate codeRate, uint16_t constellationSize)
Return the rate (in bps) of the non-HT Reference Rate which corresponds to the supplied code rate and...
std::map< uint16_t, EventId > m_beginOfdmaPayloadRxEvents
the beginning of the OFDMA payload reception events (indexed by STA-ID)
void SetEndOfHeSigACallback(EndOfHeSigACallback callback)
Set a callback for a end of HE-SIG-A.
uint64_t m_previouslyTxPpduUid
UID of the previously sent PPDU, used by AP to recognize response HE TB PPDUs.
static WifiCodeRate GetCodeRate(uint8_t mcsValue)
Return the coding rate corresponding to the supplied HE MCS index.
void StartTx(Ptr< const WifiPpdu > ppdu) override
This function is called by SpectrumWifiPhy to send the PPDU while performing amendment-specific actio...
PhyFieldRxStatus ProcessSig(Ptr< Event > event, PhyFieldRxStatus status, WifiPpduField field) override
Process SIG-A or SIG-B, perform amendment-specific actions, and provide an updated status of the rece...
WifiSpectrumBand GetRuBandForRx(const WifiTxVector &txVector, uint16_t staId) const
Get the band in the RX spectrum associated with the RU used by the PSDU transmitted to/by a given STA...
EndOfHeSigACallback m_endOfHeSigACallback
end of HE-SIG-A callback
Ptr< const WifiPsdu > GetAddressedPsduInPpdu(Ptr< const WifiPpdu > ppdu) const override
Get the PSDU addressed to that PHY in a PPDU (useful for MU PPDU).
WifiMode GetSigMode(WifiPpduField field, const WifiTxVector &txVector) const override
Get the WifiMode for the SIG field specified by the PPDU field.
const PpduFormats & GetPpduFormats() const override
Return the PPDU formats of the PHY.
uint64_t ObtainNextUid(const WifiTxVector &txVector) override
Obtain the next UID for the PPDU to transmit.
static uint64_t GetPhyRateFromTxVector(const WifiTxVector &txVector, uint16_t staId=SU_STA_ID)
Return the PHY rate corresponding to the supplied TXVECTOR for the STA-ID.
Ptr< ObssPdAlgorithm > m_obssPdAlgorithm
OBSS-PD algorithm.
bool CanStartRx(Ptr< const WifiPpdu > ppdu, uint16_t txChannelWidth) const override
Determine whether the PHY shall issue a PHY-RXSTART.indication primitive in response to a given PPDU.
uint16_t GetCenterFrequencyForNonOfdmaPart(const WifiTxVector &txVector, uint16_t staId) const
Get the center frequency of the non-OFDMA part of the current TxVector for the given STA-ID.
virtual Time CalculateNonOfdmaDurationForHeTb(const WifiTxVector &txVector) const
uint8_t GetBssColor() const
static Time GetValidPpduDuration(Time ppduDuration, const WifiTxVector &txVector, WifiPhyBand band)
Given a PPDU duration value, the TXVECTOR used to transmit the PPDU and the PHY band,...
uint8_t GetNumberBccEncoders(const WifiTxVector &txVector) const override
static bool IsAllowed(const WifiTxVector &txVector)
Check whether the combination in TXVECTOR is allowed.
std::size_t m_rxHeTbPpdus
Number of successfully received HE TB PPDUS.
~HePhy() override
Destructor for HE PHY.
Ptr< WifiPpdu > BuildPpdu(const WifiConstPsduMap &psdus, const WifiTxVector &txVector, Time ppduDuration) override
Build amendment-specific PPDU.
void NotifyEndOfHeSigA(HeSigAParameters params)
Fire a EndOfHeSigA callback (if connected) once HE-SIG-A field has been received.
static uint64_t GetDataRate(uint8_t mcsValue, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
Return the data rate corresponding to the supplied HE MCS index, channel width, guard interval,...
virtual Time CalculateNonOfdmaDurationForHeMu(const WifiTxVector &txVector) const
void RxPayloadSucceeded(Ptr< const WifiPsdu > psdu, RxSignalInfo rxSignalInfo, const WifiTxVector &txVector, uint16_t staId, const std::vector< bool > &statusPerMpdu) override
Perform amendment-specific actions when the payload is successfully received.
static uint64_t GetPhyRate(uint8_t mcsValue, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
Return the PHY rate corresponding to the supplied HE MCS index, channel width, guard interval,...
uint64_t m_currentMuPpduUid
UID of the HE MU or HE TB PPDU being received.
uint32_t GetMaxPsduSize() const override
Get the maximum PSDU size in bytes.
static const PpduFormats m_hePpduFormats
HE PPDU formats.
static uint64_t GetDataRateFromTxVector(const WifiTxVector &txVector, uint16_t staId=SU_STA_ID)
Return the data rate corresponding to the supplied TXVECTOR for the STA-ID.
std::vector< Time > GetPer20MHzDurations(const Ptr< const WifiPpdu > ppdu)
Compute the per-20 MHz CCA durations vector that indicates for how long each 20 MHz subchannel (corre...
void RxPayloadFailed(Ptr< const WifiPsdu > psdu, double snr, const WifiTxVector &txVector) override
Perform amendment-specific actions when the payload is unsuccessfuly received.
double GetCcaThreshold(const Ptr< const WifiPpdu > ppdu, WifiChannelListType channelType) const override
Return the CCA threshold in dBm for a given channel type.
Ptr< const WifiPpdu > GetRxPpduFromTxPpdu(Ptr< const WifiPpdu > ppdu) override
The WifiPpdu from the TX PHY is received by each RX PHY attached to the same channel.
HePhy(bool buildModeList=true)
Constructor for HE PHY.
bool IsConfigSupported(Ptr< const WifiPpdu > ppdu) const override
Checks if the signaled configuration (excluding bandwidth) is supported by the PHY.
uint16_t GetStaId(const Ptr< const WifiPpdu > ppdu) const override
Return the STA ID that has been assigned to the station this PHY belongs to.
static Time GetSymbolDuration(Time guardInterval)
void SetTrigVector(const WifiTxVector &trigVector, Time validity)
Set the TRIGVECTOR and the associated expiration time.
static std::pair< uint16_t, Time > ConvertHeTbPpduDurationToLSigLength(Time ppduDuration, const WifiTxVector &txVector, WifiPhyBand band)
Compute the L-SIG length value corresponding to the given HE TB PPDU duration.
static uint64_t GetNonHtReferenceRate(uint8_t mcsValue)
Calculate the rate in bps of the non-HT Reference Rate corresponding to the supplied HE MCS index.
WifiSpectrumBand GetRuBandForTx(const WifiTxVector &txVector, uint16_t staId) const
Get the band in the TX spectrum associated with the RU used by the PSDU transmitted to/by a given STA...
WifiMode GetSigBMode(const WifiTxVector &txVector) const override
void SwitchMaybeToCcaBusy(const Ptr< const WifiPpdu > ppdu) override
Check if PHY state should move to CCA busy state based on current state of interference tracker.
Time DoStartReceivePayload(Ptr< Event > event) override
Start receiving the PSDU (i.e.
void StartReceivePreamble(Ptr< const WifiPpdu > ppdu, RxPowerWattPerChannelBand &rxPowersW, Time rxDuration) override
Start receiving the PHY preamble of a PPDU (i.e.
virtual PhyFieldRxStatus ProcessSigA(Ptr< Event > event, PhyFieldRxStatus status)
Process SIG-A, perform amendment-specific actions, and provide an updated status of the reception.
std::optional< Time > m_trigVectorExpirationTime
expiration time of the TRIGVECTOR
void DoEndReceivePayload(Ptr< const WifiPpdu > ppdu) override
Perform amendment-specific actions at the end of the reception of the payload.
void DoResetReceive(Ptr< Event > event) override
Perform amendment-specific actions before resetting PHY at the end of the PPDU under reception after ...
WifiMode GetSigAMode() const override
Time GetSigADuration(WifiPreamble preamble) const override
Time GetTrainingDuration(const WifiTxVector &txVector, uint8_t nDataLtf, uint8_t nExtensionLtf=0) const override
std::vector< Time > m_lastPer20MHzDurations
Hold the last per-20 MHz CCA durations vector.
void NotifyCcaBusy(const Ptr< const WifiPpdu > ppdu, Time duration, WifiChannelListType channelType) override
Notify PHY state helper to switch to CCA busy state,.
Ptr< SpectrumValue > GetTxPowerSpectralDensity(double txPowerW, Ptr< const WifiPpdu > ppdu) const override
uint16_t GetMeasurementChannelWidth(const Ptr< const WifiPpdu > ppdu) const override
Return the channel width used to measure the RSSI.
static uint16_t GetConstellationSize(uint8_t mcsValue)
Return the constellation size corresponding to the supplied HE MCS index.
TxPsdFlag
The transmit power spectral density flag, namely used to correctly build PSDs for pre-HE and HE porti...
@ PSD_HE_PORTION
HE portion of an HE PPDU.
@ PSD_NON_HE_PORTION
Non-HE portion of an HE PPDU.
std::size_t GetIndex() const
Get the RU index.
RuType GetRuType() const
Get the RU type.
std::size_t GetPhyIndex(uint16_t bw, uint8_t p20Index) const
Get the RU PHY index.
static RuSpec FindOverlappingRu(uint16_t bw, RuSpec referenceRu, RuType searchedRuType)
Find the RU allocation of the given RU type overlapping the given reference RU allocation.
static uint16_t GetBandwidth(RuType ruType)
Get the approximate bandwidth occupied by a RU.
static SubcarrierGroup GetSubcarrierGroup(uint16_t bw, RuType ruType, std::size_t phyIndex)
Get the subcarrier group of the RU having the given PHY index among all the RUs of the given type (nu...
std::vector< SubcarrierRange > SubcarrierGroup
a vector of subcarrier ranges defining a subcarrier group
std::pair< int16_t, int16_t > SubcarrierRange
(lowest index, highest index) pair defining a subcarrier range
static RuType GetRuType(uint16_t bandwidth)
Get the RU corresponding to the approximate bandwidth.
static uint64_t CalculatePhyRate(WifiCodeRate codeRate, uint64_t dataRate)
Return the PHY rate corresponding to the supplied code rate and data rate.
uint8_t m_bssMembershipSelector
the BSS membership selector
uint8_t m_maxMcsIndexPerSs
the maximum MCS index per spatial stream as defined by the standard
static uint64_t CalculateDataRate(Time symbolDuration, uint16_t usableSubCarriers, uint16_t numberOfBitsPerSubcarrier, double codingRate, uint8_t nss)
Calculates data rate from the supplied parameters.
static double GetCodeRatio(WifiCodeRate codeRate)
Convert WifiCodeRate to a ratio, e.g., code ratio of WIFI_CODE_RATE_1_2 is 0.5.
uint8_t m_maxSupportedMcsIndexPerSs
the maximum supported MCS index per spatial stream
double GetObssPdLevel() const
static uint16_t GetUsableSubcarriers()
uint16_t GetMeasurementChannelWidth(const Ptr< const WifiPpdu > ppdu) const override
Return the channel width used to measure the RSSI.
void NotifyPayloadBegin(const WifiTxVector &txVector, const Time &payloadDuration)
Fire the trace indicating that the PHY is starting to receive the payload of a PPDU.
Ptr< WifiPhyStateHelper > m_state
Pointer to WifiPhyStateHelper of the WifiPhy (to make it reachable for child classes)
std::tuple< double, double, double > GetTxMaskRejectionParams() const
virtual Time DoStartReceivePayload(Ptr< Event > event)
Start receiving the PSDU (i.e.
virtual bool CanStartRx(Ptr< const WifiPpdu > ppdu, uint16_t txChannelWidth) const
Determine whether the PHY shall issue a PHY-RXSTART.indication primitive in response to a given PPDU.
virtual void StartReceivePreamble(Ptr< const WifiPpdu > ppdu, RxPowerWattPerChannelBand &rxPowersW, Time rxDuration)
Start receiving the PHY preamble of a PPDU (i.e.
Ptr< Event > CreateInterferenceEvent(Ptr< const WifiPpdu > ppdu, const WifiTxVector &txVector, Time duration, RxPowerWattPerChannelBand &rxPower, bool isStartOfdmaRxing=false)
Create an event using WifiPhy's InterferenceHelper class.
const std::map< std::pair< uint64_t, WifiPreamble >, Ptr< Event > > & GetCurrentPreambleEvents() const
Get the map of current preamble events (stored in WifiPhy).
std::map< UidStaIdPair, SignalNoiseDbm > m_signalNoiseMap
Map of the latest signal power and noise power in dBm (noise power includes the noise figure)
Ptr< WifiPhy > m_wifiPhy
Pointer to the owning WifiPhy.
void Transmit(Time txDuration, Ptr< const WifiPpdu > ppdu, double txPowerDbm, Ptr< SpectrumValue > txPowerSpectrum, const std::string &type)
This function prepares most of the WifiSpectrumSignalParameters parameters and invokes SpectrumWifiPh...
std::vector< EventId > m_endOfMpduEvents
the end of MPDU events (only used for A-MPDUs)
virtual std::pair< uint16_t, WifiSpectrumBand > GetChannelWidthAndBand(const WifiTxVector &txVector, uint16_t staId) const
Get the channel width and band to use (will be overloaded by child classes).
virtual void CancelAllEvents()
Cancel and clear all running events.
virtual void DoAbortCurrentReception(WifiPhyRxfailureReason reason)
Perform amendment-specific actions before aborting the current reception.
void EndReceivePayload(Ptr< Event > event)
The last symbol of the PPDU has arrived.
std::map< WifiPreamble, std::vector< WifiPpduField > > PpduFormats
A map of PPDU field elements per preamble type.
static uint64_t m_globalPpduUid
Global counter of the PPDU UID.
std::vector< EventId > m_endRxPayloadEvents
the end of receive events (only one unless UL MU reception)
virtual Ptr< Event > DoGetEvent(Ptr< const WifiPpdu > ppdu, RxPowerWattPerChannelBand &rxPowersW)
Get the event corresponding to the incoming PPDU.
double GetRxPowerWForPpdu(Ptr< Event > event) const
Obtain the received power (W) for a given band.
Time CalculatePhyPreambleAndHeaderDuration(const WifiTxVector &txVector) const
void NotifyInterferenceRxEndAndClear(bool reset)
Notify WifiPhy's InterferenceHelper of the end of the reception, clear maps and end of MPDU event,...
std::map< UidStaIdPair, std::vector< bool > > m_statusPerMpduMap
Map of the current reception status per MPDU that is filled in as long as MPDUs are being processed b...
virtual void StartTx(Ptr< const WifiPpdu > ppdu)
This function is called by SpectrumWifiPhy to send the PPDU while performing amendment-specific actio...
Time GetDelayUntilCcaEnd(double thresholdDbm, WifiSpectrumBand band)
Return the delay until CCA busy is ended for a given sensitivity threshold (in dBm) and a given band.
virtual uint16_t GetStaId(const Ptr< const WifiPpdu > ppdu) const
Return the STA ID that has been assigned to the station this PHY belongs to.
uint16_t GetGuardBandwidth(uint16_t currentChannelWidth) const
virtual bool IsModeSupported(WifiMode mode) const
Check if the WifiMode is supported.
void ResetReceive(Ptr< Event > event)
Reset PHY at the end of the PPDU under reception after it has failed the PHY header.
std::list< WifiMode > m_modeList
the list of supported modes
Ptr< const Event > GetCurrentEvent() const
Get the pointer to the current event (stored in WifiPhy).
virtual Ptr< const WifiPsdu > GetAddressedPsduInPpdu(Ptr< const WifiPpdu > ppdu) const
Get the PSDU addressed to that PHY in a PPDU (useful for MU PPDU).
void ErasePreambleEvent(Ptr< const WifiPpdu > ppdu, Time rxDuration)
Erase the event corresponding to the PPDU from the list of preamble events, but consider it as noise ...
virtual Ptr< const WifiPpdu > GetRxPpduFromTxPpdu(Ptr< const WifiPpdu > ppdu)
The WifiPpdu from the TX PHY is received by each RX PHY attached to the same channel.
void AddPreambleEvent(Ptr< Event > event)
Add an entry to the map of current preamble events (stored in WifiPhy).
virtual void DoEndReceivePayload(Ptr< const WifiPpdu > ppdu)
Perform amendment-specific actions at the end of the reception of the payload.
uint16_t GetCenterFrequencyForChannelWidth(const WifiTxVector &txVector) const
Get the center frequency of the channel corresponding the current TxVector rather than that of the su...
@ DROP
drop PPDU and set CCA_BUSY
void UpdateInterferenceEvent(Ptr< Event > event, const RxPowerWattPerChannelBand &rxPower)
Update an event in WifiPhy's InterferenceHelper class.
void ScheduleEndOfMpdus(Ptr< Event > event)
Schedule end of MPDUs events.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static Time Now()
Return the current simulation virtual time.
static Time GetDelayLeft(const EventId &id)
Get the remaining time until this event will execute.
Simulation virtual time values and global simulation resolution.
int64_t GetNanoSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
bool IsStrictlyPositive() const
Exactly equivalent to t > 0.
PHY entity for VHT (11ac)
static WifiMode GetVhtMcs0()
Return MCS 0 from VHT MCS values.
static WifiCodeRate GetCodeRate(uint8_t mcsValue)
Return the coding rate corresponding to the supplied VHT MCS index.
Time GetDuration(WifiPpduField field, const WifiTxVector &txVector) const override
Get the duration of the PPDU field (or group of fields) used by this entity for the given transmissio...
double GetCcaThreshold(const Ptr< const WifiPpdu > ppdu, WifiChannelListType channelType) const override
Return the CCA threshold in dBm for a given channel type.
static WifiMode GetVhtMcs5()
Return MCS 5 from VHT MCS values.
CcaIndication GetCcaIndication(const Ptr< const WifiPpdu > ppdu) override
Get CCA end time and its corresponding channel list type when a new signal has been received by the P...
static uint64_t CalculateNonHtReferenceRate(WifiCodeRate codeRate, uint16_t constellationSize)
Return the rate (in bps) of the non-HT Reference Rate which corresponds to the supplied code rate and...
static WifiMode GetVhtMcs3()
Return MCS 3 from VHT MCS values.
static WifiMode GetVhtMcs1()
Return MCS 1 from VHT MCS values.
static WifiMode GetVhtMcs4()
Return MCS 4 from VHT MCS values.
static WifiMode GetVhtMcs2()
Return MCS 2 from VHT MCS values.
static uint16_t GetConstellationSize(uint8_t mcsValue)
Return the constellation size corresponding to the supplied VHT MCS index.
WifiMode GetSigMode(WifiPpduField field, const WifiTxVector &txVector) const override
Get the WifiMode for the SIG field specified by the PPDU field.
TypeOfStation GetTypeOfStation() const
Return the type of station.
static WifiMode CreateWifiMcs(std::string uniqueName, uint8_t mcsValue, WifiModulationClass modClass, bool isMandatory, CodeRateCallback codeRateCallback, ConstellationSizeCallback constellationSizeCallback, PhyRateCallback phyRateCallback, DataRateCallback dataRateCallback, NonHtReferenceRateCallback nonHtReferenceRateCallback, AllowedCallback isAllowedCallback)
represent a single transmission mode
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
uint8_t GetMcsValue() const
Ptr< WifiMac > GetMac() const
Ptr< HeConfiguration > GetHeConfiguration() const
uint16_t GetChannelWidth() const
double GetTxGain() const
Return the transmission gain (dB).
void NotifyRxDrop(Ptr< const WifiPsdu > psdu, WifiPhyRxfailureReason reason)
Public method used to fire a PhyRxDrop trace.
uint16_t GetFrequency() const
uint8_t GetMaxSupportedRxSpatialStreams() const
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
virtual WifiSpectrumBand ConvertHeRuSubcarriers(uint16_t bandWidth, uint16_t guardBandwidth, HeRu::SubcarrierRange range, uint8_t bandIndex=0) const
WifiPhyBand GetPhyBand() const
Get the configured Wi-Fi band.
virtual WifiSpectrumBand GetBand(uint16_t bandWidth, uint8_t bandIndex=0)
Get the start band index and the stop band index for a given band.
static void AddStaticPhyEntity(WifiModulationClass modulation, Ptr< PhyEntity > phyEntity)
Add the PHY entity to the map of implemented PHY entities for the given modulation class.
Ptr< WifiNetDevice > GetDevice() const
Return the device this PHY is associated with.
double GetTxPowerForTransmission(Ptr< const WifiPpdu > ppdu) const
Compute the transmit power for the next transmission.
uint64_t GetPreviouslyRxPpduUid() const
Time GetLastRxEndTime() const
Return the end time of the last received packet.
const WifiPhyOperatingChannel & GetOperatingChannel() const
Get a const reference to the operating channel.
static Time CalculatePhyPreambleAndHeaderDuration(const WifiTxVector &txVector)
uint8_t GetPrimaryChannelIndex(uint16_t primaryChannelWidth) const
If the operating channel width is a multiple of 20 MHz, return the index of the primary channel of th...
std::set< uint8_t > GetAll20MHzChannelIndicesInPrimary(uint16_t width) const
Get the channel indices of all the 20 MHz channels included in the primary channel of the given width...
uint16_t GetPrimaryChannelCenterFrequency(uint16_t primaryChannelWidth) const
Get the center frequency of the primary channel of the given width.
static Ptr< SpectrumValue > CreateDuplicated20MhzTxPowerSpectralDensity(uint32_t centerFrequency, uint16_t channelWidth, double txPowerW, uint16_t guardBandwidth, double minInnerBandDbr=-20, double minOuterbandDbr=-28, double lowestPointDbr=-40, const std::vector< bool > &puncturedSubchannels=std::vector< bool >{})
Create a transmit power spectral density corresponding to OFDM duplicated over multiple 20 MHz subcha...
static Ptr< SpectrumValue > CreateHeMuOfdmTxPowerSpectralDensity(uint32_t centerFrequency, uint16_t channelWidth, double txPowerW, uint16_t guardBandwidth, WifiSpectrumBand ru)
Create a transmit power spectral density corresponding to the OFDMA part of HE TB PPDUs for a given R...
static Ptr< SpectrumValue > CreateHeOfdmTxPowerSpectralDensity(uint32_t centerFrequency, uint16_t channelWidth, double txPowerW, uint16_t guardBandwidth, double minInnerBandDbr=-20, double minOuterbandDbr=-28, double lowestPointDbr=-40, const std::vector< bool > &puncturedSubchannels=std::vector< bool >{})
Create a transmit power spectral density corresponding to OFDM High Efficiency (HE) (802....
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
bool IsTriggerResponding() const
Return true if the Trigger Responding parameter is set to true, false otherwise.
uint16_t GetGuardInterval() const
uint8_t GetBssColor() const
Get the BSS color.
std::map< uint16_t, HeMuUserInfo > HeMuUserInfoMap
map of HE MU specific user info parameters indexed by STA-ID
WifiMode GetMode(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the selected payload transmission mode.
WifiPreamble GetPreambleType() const
HeMuUserInfo GetHeMuUserInfo(uint16_t staId) const
Get the HE MU user-specific transmission information for the given STA-ID.
HeRu::RuSpec GetRu(uint16_t staId) const
Get the RU specification for the STA-ID.
uint16_t GetLength() const
Get the LENGTH field of the L-SIG.
const HeMuUserInfoMap & GetHeMuUserInfoMap() const
Get a const reference to the map HE MU user-specific transmission information indexed by STA-ID.
WifiModulationClass GetModulationClass() const
Get the modulation class specified by this TXVECTOR.
uint8_t GetNss(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the number of spatial streams.
uint8_t GetNssMax() const
std::pair< std::size_t, std::size_t > GetNumRusPerHeSigBContentChannel() const
Get the number of RUs per HE-SIG-B content channel.
uint16_t GetChannelWidth() const
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Minimum.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs &&... bargs)
Make Callbacks with varying number of bound arguments.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time FemtoSeconds(uint64_t value)
Construct a Time in the indicated unit.
WifiPhyRxfailureReason
Enumeration of the possible reception failure reasons.
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
WifiPhyBand
Identifies the PHY band.
WifiChannelListType
Enumeration of the possible channel-list parameter elements defined in Table 8-5 of IEEE 802....
WifiPpduField
The type of PPDU field (grouped for convenience)
@ WIFI_PHY_BAND_2_4GHZ
The 2.4 GHz band.
@ WIFI_MOD_CLASS_HT
HT (Clause 19)
@ WIFI_MOD_CLASS_HE
HE (Clause 27)
@ WIFI_PPDU_FIELD_SIG_B
SIG-B field.
@ WIFI_PPDU_FIELD_TRAINING
STF + LTF fields (excluding those in preamble for HT-GF)
@ WIFI_PPDU_FIELD_NON_HT_HEADER
PHY header field for DSSS or ERP, short PHY header field for HR/DSSS or ERP, field not present for HT...
@ WIFI_PPDU_FIELD_PREAMBLE
SYNC + SFD fields for DSSS or ERP, shortSYNC + shortSFD fields for HR/DSSS or ERP,...
@ WIFI_PPDU_FIELD_DATA
data field
@ WIFI_PPDU_FIELD_SIG_A
SIG-A field.
Declaration of ns3::HePhy class and ns3::HeSigAParameters struct.
#define HE_PHY
This defines the BSS membership value for HE PHY.
class anonymous_namespace{he-phy.cc}::ConstructorHe g_constructor_he
the constructor for HE modes
Every class exported by the ns3 library is enclosed in the ns3 namespace.
const uint16_t WIFI_CODE_RATE_3_4
3/4 coding rate
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
std::pair< uint32_t, uint32_t > WifiSpectrumBand
typedef for a pair of start and stop sub-band indexes
double DbmToW(double dBm)
Convert from dBm to Watts.
std::map< WifiSpectrumBand, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
uint16_t WifiCodeRate
These constants define the various convolutional coding rates used for the OFDM transmission modes in...
const uint16_t WIFI_CODE_RATE_5_6
5/6 coding rate
@ LOG_FUNCTION
Function tracing.
bool IsDlMu(WifiPreamble preamble)
Return true if a preamble corresponds to a downlink multi-user transmission.
bool IsUlMu(WifiPreamble preamble)
Return true if a preamble corresponds to a uplink multi-user transmission.
params
Fit Fluctuating Two Ray model to the 3GPP TR 38.901 using the Anderson-Darling goodness-of-fit ##.
Parameters for received HE-SIG-A for OBSS_PD based SR.
Status of the reception of the PPDU field.
bool isSuccess
outcome (true if success) of the reception
RxSignalInfo structure containing info on the received signal.
SignalNoiseDbm structure.