33#include "ns3/assert.h"
35#include "ns3/packet.h"
36#include "ns3/simulator.h"
51 return (os <<
"DROP");
53 return (os <<
"ABORT");
55 return (os <<
"IGNORE");
58 return (os <<
"unknown");
67 return os <<
"success";
119 "This method should be used only for HtPhy and child classes. Use GetMode instead.");
126 NS_ABORT_MSG(
"This method should be used only for HtPhy and child classes. Use IsModeSupported "
137std::list<WifiMode>::const_iterator
143std::list<WifiMode>::const_iterator
152 NS_FATAL_ERROR(
"PPDU field is not a SIG field (no sense in retrieving the signaled mode) or is "
162 const auto itPpdu = ppduFormats.find(preamble);
163 if (itPpdu != ppduFormats.end())
165 const auto itField = std::find(itPpdu->second.begin(), itPpdu->second.end(), currentField);
166 if (itField != itPpdu->second.end())
168 const auto itNextField = std::next(itField, 1);
169 if (itNextField != itPpdu->second.end())
171 return *(itNextField);
173 NS_FATAL_ERROR(
"No field after " << currentField <<
" for " << preamble
174 <<
" for the provided PPDU formats");
178 NS_FATAL_ERROR(
"Unsupported PPDU field " << currentField <<
" for " << preamble
179 <<
" for the provided PPDU formats");
184 NS_FATAL_ERROR(
"Unsupported preamble " << preamble <<
" for the provided PPDU formats");
219 return ppdu->GetPsdu();
227 Time start = ppduStart;
233 std::make_pair(std::make_pair(start, start + duration),
GetSigMode(field, txVector));
245 NS_FATAL_ERROR(
"This method is unsupported for the base PhyEntity class. Use the overloaded "
246 "version in the amendment-specific subclasses instead!");
247 return Create<WifiPpdu>(psdus.begin()->second,
261 auto it = sections.find(field);
263 const auto& startStopTimes = it->second.first;
264 return startStopTimes
274 measurementChannelWidth,
286 "Use the StartReceivePreamble method for preamble reception");
297 << field <<
" for this PHY entity");
313 const auto& txVector =
event->GetPpdu()->GetTxVector();
361 const auto& txVector = ppdu->GetTxVector();
362 return ppdu->GetTxDuration() -
373 auto itFormat = ppduFormats.find(event->GetPpdu()->GetPreamble());
374 if (itFormat != ppduFormats.end())
376 auto itField = std::find(itFormat->second.begin(), itFormat->second.end(), field);
377 if (itField != itFormat->second.end())
404 std::max_element(rxPowersW.begin(), rxPowersW.end(), [](
const auto& p1,
const auto& p2) {
405 return p1.second < p2.second;
418 if (
m_state->GetState() == WifiPhyState::OFF)
429 if (ppdu->IsTruncatedTx())
431 NS_LOG_DEBUG(
"Packet reception stopped because transmitter has been switched off");
442 case WifiPhyState::SWITCHING:
443 NS_LOG_DEBUG(
"Drop packet because of channel switching");
454 case WifiPhyState::RX:
481 case WifiPhyState::TX:
485 case WifiPhyState::CCA_BUSY:
499 NS_LOG_DEBUG(
"Drop packet because already decoding preamble");
508 case WifiPhyState::IDLE:
512 case WifiPhyState::SLEEP:
528 std::make_pair(ppdu->GetUid(), ppdu->GetPreamble()));
546 std::make_pair(ppdu->GetUid(), ppdu->GetPreamble()));
556 if (rxDuration >
m_state->GetDelayUntilIdle())
576 m_state->SwitchToRx(payloadDuration);
587 m_statusPerMpduMap.insert({std::make_pair(ppdu->GetUid(), staId), std::vector<bool>()});
589 const auto& txVector =
event->GetPpdu()->GetTxVector();
598 return payloadDuration;
607 const auto& txVector =
event->GetPpdu()->GetTxVector();
612 Time remainingAmpduDuration = psduDuration;
613 size_t nMpdus = psdu->GetNMpdus();
617 double totalAmpduNumSymbols = 0.0;
618 auto mpdu = psdu->begin();
619 for (
size_t i = 0; i < nMpdus && mpdu != psdu->end(); ++mpdu)
621 uint32_t size = (mpduType ==
NORMAL_MPDU) ? psdu->GetSize() : psdu->GetAmpduSubframeSize(i);
628 totalAmpduNumSymbols,
631 remainingAmpduDuration -= mpduDuration;
632 if (i == (nMpdus - 1) && !remainingAmpduDuration.
IsZero())
634 if (remainingAmpduDuration <
637 mpduDuration += remainingAmpduDuration;
642 endOfMpduDuration += mpduDuration;
644 << i <<
" in " << endOfMpduDuration.
As(
Time::NS) <<
" (relativeStart="
646 <<
", remainingAmdpuDuration=" << remainingAmpduDuration.
As(
Time::NS) <<
")");
651 Create<WifiPsdu>(*mpdu,
false),
658 relativeStart += mpduDuration;
670 NS_LOG_FUNCTION(
this << *event << mpduIndex << relativeStart << mpduDuration);
671 const auto ppdu =
event->GetPpdu();
672 const auto& txVector = ppdu->GetTxVector();
675 std::pair<bool, SignalNoiseDbm> rxInfo =
678 <<
", correct reception: " << rxInfo.first <<
", Signal/Noise: "
679 << rxInfo.second.signal <<
"/" << rxInfo.second.noise <<
"dBm");
681 auto signalNoiseIt =
m_signalNoiseMap.find(std::make_pair(ppdu->GetUid(), staId));
683 signalNoiseIt->second = rxInfo.second;
686 rxSignalInfo.
snr = rxInfo.second.signal / rxInfo.second.noise;
687 rxSignalInfo.
rssi = rxInfo.second.signal;
689 auto statusPerMpduIt =
m_statusPerMpduMap.find(std::make_pair(ppdu->GetUid(), staId));
691 statusPerMpduIt->second.push_back(rxInfo.first);
696 m_state->NotifyRxMpdu(psdu, rxSignalInfo, txVector);
703 const auto ppdu =
event->GetPpdu();
704 const auto& txVector = ppdu->GetTxVector();
705 const auto psduDuration =
712 channelWidthAndBand.first,
713 txVector.GetNss(staId),
714 channelWidthAndBand.second);
719 auto signalNoiseIt =
m_signalNoiseMap.find(std::make_pair(ppdu->GetUid(), staId));
721 auto statusPerMpduIt =
m_statusPerMpduMap.find(std::make_pair(ppdu->GetUid(), staId));
724 if (std::count(statusPerMpduIt->second.begin(), statusPerMpduIt->second.end(),
true))
730 signalNoiseIt->second,
731 statusPerMpduIt->second,
734 rxSignalInfo.
snr = snr;
735 rxSignalInfo.
rssi = signalNoiseIt->second.signal;
755 const std::vector<bool>& statusPerMpdu)
758 m_state->NotifyRxPsduSucceeded(psdu, rxSignalInfo, txVector, staId, statusPerMpdu);
766 m_state->NotifyRxPsduFailed(psdu, snr);
767 m_state->SwitchFromRxEndError();
782std::pair<bool, SignalNoiseDbm>
786 Time relativeMpduStart,
789 NS_LOG_FUNCTION(
this << *psdu << *event << staId << relativeMpduStart << mpduDuration);
793 channelWidthAndBand.first,
794 channelWidthAndBand.second,
796 std::make_pair(relativeMpduStart, relativeMpduStart + mpduDuration));
798 WifiMode mode =
event->GetPpdu()->GetTxVector().GetMode(staId);
801 <<
", size=" << psdu->GetSize()
802 <<
", relativeStart = " << relativeMpduStart.
As(
Time::NS)
803 <<
", duration = " << mpduDuration.
As(
Time::NS));
810 signalNoise.
signal =
WToDbm(event->GetRxPowerW(channelWidthAndBand.second));
811 signalNoise.
noise =
WToDbm(event->GetRxPowerW(channelWidthAndBand.second) / snrPer.
snr);
817 return std::make_pair(
true, signalNoise);
822 return std::make_pair(
false, signalNoise);
826std::pair<uint16_t, WifiSpectrumBandInfo>
830 return std::make_pair(channelWidth,
GetPrimaryBand(channelWidth));
833const std::map<std::pair<uint64_t, WifiPreamble>,
Ptr<Event>>&
845 {std::make_pair(ppdu->GetUid(), ppdu->GetPreamble()),
event});
853 const auto uidPreamblePair = std::make_pair(ppdu->GetUid(), ppdu->GetPreamble());
855 const auto it = currentPreambleEvents.find(uidPreamblePair);
856 if (it != currentPreambleEvents.cend())
859 NS_LOG_DEBUG(
"Received another PPDU for UID " << ppdu->GetUid());
860 const auto foundEvent = it->second;
874 bool isStartHePortionRxing )
884 if (
const auto maxDelay =
900 const auto& txVector = ppdu->GetTxVector();
901 const auto& eventTxVector =
event->GetPpdu()->GetTxVector();
902 auto updatedTxVector{eventTxVector};
903 updatedTxVector.SetChannelWidth(
904 std::max(eventTxVector.GetChannelWidth(), txVector.GetChannelWidth()));
905 if (updatedTxVector.GetChannelWidth() != eventTxVector.GetChannelWidth())
907 event->UpdatePpdu(ppdu);
963 double maxRxPowerW = -1;
969 double rxPowerW = preambleEvent.second->GetRxPowerW(measurementBand);
970 if (rxPowerW > maxRxPowerW)
972 maxRxPowerW = rxPowerW;
973 maxEvent = preambleEvent.second;
978 if (maxEvent != event)
981 << maxEvent->GetPpdu()->GetUid()
982 <<
" during preamble detection: drop packet with UID "
983 << event->GetPpdu()->GetUid());
986 std::make_pair(event->GetPpdu()->GetUid(), event->GetPpdu()->GetPreamble()));
1000 measurementChannelWidth,
1010 measurementChannelWidth)))
1015 it.second->CancelRunningEndPreambleDetectionEvents(
true);
1023 NS_LOG_DEBUG(
"Drop packet with UID " << it->first.first <<
" and preamble "
1024 << it->first.second <<
" arrived at time "
1025 << it->second->GetStartTime());
1057 Time durationTillEnd =
1070 NS_LOG_DEBUG(
"Drop packet because PHY preamble detection failed");
1091 WifiMode txMode = ppdu->GetTxVector().GetMode();
1094 NS_LOG_DEBUG(
"Drop packet because it was sent using an unsupported mode (" << txMode
1107 endPreambleDetectionEvent.Cancel();
1112 endRxPayloadEvent.Cancel();
1117 endMpduEvent.Cancel();
1134 if (endPreambleDetectionEvent.IsRunning())
1136 endPreambleDetectionEvent.Cancel();
1161 endMpduEvent.Cancel();
1252 if (ccaIndication.has_value())
1254 NS_LOG_DEBUG(
"CCA busy for " << ccaIndication.value().second <<
" during "
1255 << ccaIndication.value().first.As(
Time::S));
1256 m_state->SwitchMaybeToCcaBusy(ccaIndication.value().first,
1257 ccaIndication.value().second,
1273 const Time delayUntilCcaEnd =
1279 return std::nullopt;
1289 m_state->SwitchMaybeToCcaBusy(duration, channelType, {});
1325 auto txVector = ppdu->GetTxVector();
1327 Transmit(ppdu->GetTxDuration(), ppdu, txPowerDbm, txPowerSpectrum,
"transmission");
1335 const std::string& type)
1338 NS_LOG_DEBUG(
"Start " << type <<
": signal power before antenna gain=" << txPowerDbm <<
"dBm");
1339 auto txParams = Create<WifiSpectrumSignalParameters>();
1340 txParams->duration = txDuration;
1341 txParams->psd = txPowerSpectrum;
1342 txParams->ppdu = ppdu;
1343 NS_LOG_DEBUG(
"Starting " << type <<
" with power " << txPowerDbm <<
" dBm on channel "
1345 << txParams->duration.As(
Time::MS));
1346 NS_LOG_DEBUG(
"Starting " << type <<
" with integrated spectrum power "
1347 <<
WToDbm(
Integral(*txPowerSpectrum)) <<
" dBm; spectrum model Uid: "
1348 << txPowerSpectrum->GetSpectrumModel()->GetUid());
1349 auto spectrumWifiPhy = DynamicCast<SpectrumWifiPhy>(
m_wifiPhy);
1351 spectrumWifiPhy->Transmit(txParams);
1360std::tuple<double, double, double>
1372 const auto& it = psduMap.begin();
1382 const auto primaryWidth =
1383 ((channelWidth % 20 == 0) ? 20
1386 const auto p20CenterFreq =
1388 const auto p20MinFreq = p20CenterFreq - (primaryWidth / 2);
1389 const auto p20MaxFreq = p20CenterFreq + (primaryWidth / 2);
1390 const auto txCenterFreq = ppdu->GetTxCenterFreq();
1391 const auto txChannelWidth = ppdu->GetTxChannelWidth();
1392 const auto minTxFreq = txCenterFreq - txChannelWidth / 2;
1393 const auto maxTxFreq = txCenterFreq + txChannelWidth / 2;
1394 return p20MinFreq >= minTxFreq && p20MaxFreq <= maxTxFreq;
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
bool IsExpired() const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
void NotifyPayloadBegin(const WifiTxVector &txVector, const Time &payloadDuration)
Fire the trace indicating that the PHY is starting to receive the payload of a PPDU.
virtual void HandleRxPpduWithSameContent(Ptr< Event > event, Ptr< const WifiPpdu > ppdu, RxPowerWattPerChannelBand &rxPower)
Handle reception of a PPDU that carries the same content of another PPDU.
void DropPreambleEvent(Ptr< const WifiPpdu > ppdu, WifiPhyRxfailureReason reason, Time endRx)
Drop the PPDU and the corresponding preamble detection event, but keep CCA busy state after the compl...
std::list< WifiMode >::const_iterator end() const
Return a const iterator to past-the-last WifiMode.
virtual void RxPayloadSucceeded(Ptr< const WifiPsdu > psdu, RxSignalInfo rxSignalInfo, const WifiTxVector &txVector, uint16_t staId, const std::vector< bool > &statusPerMpdu)
Perform amendment-specific actions when the payload is successfully received.
virtual PhyFieldRxStatus DoEndReceivePreamble(Ptr< Event > event)
End receiving the preamble, perform amendment-specific actions, and provide the status of the recepti...
Ptr< WifiPhyStateHelper > m_state
Pointer to WifiPhyStateHelper of the WifiPhy (to make it reachable for child classes)
virtual void RxPayloadFailed(Ptr< const WifiPsdu > psdu, double snr, const WifiTxVector &txVector)
Perform amendment-specific actions when the payload is unsuccessfuly received.
void EndPreambleDetectionPeriod(Ptr< Event > event)
End the preamble detection period.
virtual void NotifyCcaBusy(const Ptr< const WifiPpdu > ppdu, Time duration, WifiChannelListType channelType)
Notify PHY state helper to switch to CCA busy state,.
virtual Ptr< WifiPpdu > BuildPpdu(const WifiConstPsduMap &psdus, const WifiTxVector &txVector, Time ppduDuration)
Build amendment-specific PPDU.
virtual Time GetDuration(WifiPpduField field, const WifiTxVector &txVector) const
Get the duration of the PPDU field (or group of fields) used by this entity for the given transmissio...
std::tuple< double, double, double > GetTxMaskRejectionParams() const
virtual uint64_t ObtainNextUid(const WifiTxVector &txVector)
Obtain the next UID for the PPDU to transmit.
virtual Time DoStartReceivePayload(Ptr< Event > event)
Start receiving the PSDU (i.e.
Time GetDelayUntilCcaEnd(double thresholdDbm, const WifiSpectrumBandInfo &band)
Return the delay until CCA busy is ended for a given sensitivity threshold (in dBm) and a given band.
virtual void StartReceivePreamble(Ptr< const WifiPpdu > ppdu, RxPowerWattPerChannelBand &rxPowersW, Time rxDuration)
Start receiving the PHY preamble of a PPDU (i.e.
bool NoEndPreambleDetectionEvents() const
virtual bool HandlesMcsModes() const
Check if the WifiModes handled by this PHY are MCSs.
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...
virtual Ptr< SpectrumValue > GetTxPowerSpectralDensity(double txPowerW, Ptr< const WifiPpdu > ppdu) const =0
WifiSpectrumBandInfo GetSecondaryBand(uint16_t bandWidth) const
If the channel bonding is used, return the info corresponding to the secondary channel of the given b...
std::vector< EventId > m_endOfMpduEvents
the end of MPDU events (only used for A-MPDUs)
virtual uint16_t GetMeasurementChannelWidth(const Ptr< const WifiPpdu > ppdu) const =0
Return the channel width used to measure the RSSI.
virtual ~PhyEntity()
Destructor for PHY entity.
virtual double GetCcaThreshold(const Ptr< const WifiPpdu > ppdu, WifiChannelListType channelType) const
Return the CCA threshold in dBm for a given channel type.
virtual const PpduFormats & GetPpduFormats() const =0
Return the PPDU formats of the PHY.
virtual uint8_t GetNumModes() const
virtual bool DoStartReceiveField(WifiPpduField field, Ptr< Event > event)
Start receiving a given field, perform amendment-specific actions, and signify if it is supported.
void SetOwner(Ptr< WifiPhy > wifiPhy)
Set the WifiPhy owning this PHY entity.
std::list< WifiMode >::const_iterator begin() const
Return a const iterator to the first WifiMode.
virtual void CancelAllEvents()
Cancel and clear all running events.
virtual void DoAbortCurrentReception(WifiPhyRxfailureReason reason)
Perform amendment-specific actions before aborting the current reception.
void AbortCurrentReception(WifiPhyRxfailureReason reason)
Abort the current reception.
void EndReceivePayload(Ptr< Event > event)
The last symbol of the PPDU has arrived.
static uint64_t m_globalPpduUid
Global counter of the PPDU UID.
PhyHeaderSections GetPhyHeaderSections(const WifiTxVector &txVector, Time ppduStart) const
Return a map of PHY header chunk information per PPDU field.
virtual bool IsMcsSupported(uint8_t index) const
Check if the WifiMode corresponding to the given MCS index is supported.
void StartReceivePayload(Ptr< Event > event)
Start receiving the PSDU (i.e.
std::vector< EventId > m_endRxPayloadEvents
the end of receive events (only one unless UL MU reception)
virtual void DoResetReceive(Ptr< Event > event)
Perform amendment-specific actions before resetting PHY at the end of the PPDU under reception after ...
void EndReceiveField(WifiPpduField field, Ptr< Event > event)
End receiving a given field.
virtual Ptr< Event > DoGetEvent(Ptr< const WifiPpdu > ppdu, RxPowerWattPerChannelBand &rxPowersW)
Get the event corresponding to the incoming PPDU.
virtual WifiMode GetSigMode(WifiPpduField field, const WifiTxVector &txVector) const
Get the WifiMode for the SIG field specified by the PPDU field.
WifiPpduField GetNextField(WifiPpduField currentField, WifiPreamble preamble) const
Return the field following the provided one.
std::map< WifiPpduField, PhyHeaderChunkInfo > PhyHeaderSections
A map of PhyHeaderChunkInfo elements per PPDU field.
double GetRxPowerWForPpdu(Ptr< Event > event) const
Obtain the received power (W) for a given band.
virtual void SwitchMaybeToCcaBusy(const Ptr< const WifiPpdu > ppdu)
Check if PHY state should move to CCA busy state based on current state of interference tracker.
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,...
void StartPreambleDetectionPeriod(Ptr< Event > event)
Start the preamble detection period.
Time GetDurationUpToField(WifiPpduField field, const WifiTxVector &txVector) const
Get the duration of the PPDU up to (but excluding) the given field.
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 bool CanStartRx(Ptr< const WifiPpdu > ppdu) const
Determine whether the PHY shall issue a PHY-RXSTART.indication primitive in response to a given PPDU.
virtual void StartTx(Ptr< const WifiPpdu > ppdu)
This function is called by SpectrumWifiPhy to send the PPDU while performing amendment-specific actio...
virtual uint16_t GetRxChannelWidth(const WifiTxVector &txVector) const
Return the channel width used in the reception spectrum model.
void CancelRunningEndPreambleDetectionEvents(bool clear=false)
Cancel and eventually clear all end preamble detection events.
Time GetRemainingDurationAfterField(Ptr< const WifiPpdu > ppdu, WifiPpduField field) const
Get the remaining duration of the PPDU after the end of the given field.
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.
virtual Time CalculateTxDuration(WifiConstPsduMap psduMap, const WifiTxVector &txVector, WifiPhyBand band) const
void StartReceiveField(WifiPpduField field, Ptr< Event > event)
Start receiving a given field.
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::optional< std::pair< Time, WifiChannelListType > > CcaIndication
CCA end time and its corresponding channel list type (can be std::nullopt if IDLE)
virtual CcaIndication GetCcaIndication(const Ptr< const WifiPpdu > ppdu)
Get CCA end time and its corresponding channel list type when a new signal has been received by the P...
std::list< WifiMode > m_modeList
the list of supported modes
virtual Time GetMaxDelayPpduSameUid(const WifiTxVector &txVector)
Obtain the maximum time between two PPDUs with the same UID to consider they are identical and their ...
Ptr< const Event > GetCurrentEvent() const
Get the pointer to the current event (stored in WifiPhy).
double GetRandomValue() const
Obtain a random value from the WifiPhy's generator.
std::vector< EventId > m_endPreambleDetectionEvents
the end of preamble detection events
virtual Ptr< const WifiPsdu > GetAddressedPsduInPpdu(Ptr< const WifiPpdu > ppdu) const
Get the PSDU addressed to that PHY in a PPDU (useful for MU PPDU).
SnrPer GetPhyHeaderSnrPer(WifiPpduField field, Ptr< Event > event) const
Obtain the SNR and PER of the PPDU field from the WifiPhy's InterferenceHelper class.
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.
virtual WifiMode GetMcs(uint8_t index) const
Get the WifiMode corresponding to the given MCS index.
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...
virtual WifiConstPsduMap GetWifiConstPsduMap(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector) const
Get a WifiConstPsduMap from a PSDU and the TXVECTOR to use to send the PSDU.
virtual std::pair< uint16_t, WifiSpectrumBandInfo > GetChannelWidthAndBand(const WifiTxVector &txVector, uint16_t staId) const
Get the channel width and band to use (will be overloaded by child classes).
virtual bool IsConfigSupported(Ptr< const WifiPpdu > ppdu) const
Checks if the signaled configuration (excluding bandwidth) is supported by the PHY.
Ptr< Event > CreateInterferenceEvent(Ptr< const WifiPpdu > ppdu, Time duration, RxPowerWattPerChannelBand &rxPower, bool isStartHePortionRxing=false)
Create an event using WifiPhy's InterferenceHelper class.
PhyRxFailureAction
Action to perform in case of RX failure.
@ DROP
drop PPDU and set CCA_BUSY
@ IGNORE
ignore the reception
@ ABORT
abort reception of PPDU
std::pair< bool, SignalNoiseDbm > GetReceptionStatus(Ptr< const WifiPsdu > psdu, Ptr< Event > event, uint16_t staId, Time relativeMpduStart, Time mpduDuration)
Get the reception status for the provided MPDU and notify.
WifiSpectrumBandInfo GetPrimaryBand(uint16_t bandWidth) const
If the operating channel width is a multiple of 20 MHz, return the info corresponding to the primary ...
void EndOfMpdu(Ptr< Event > event, Ptr< const WifiPsdu > psdu, size_t mpduIndex, Time relativeStart, Time mpduDuration)
The last symbol of an MPDU in an A-MPDU has arrived.
virtual PhyFieldRxStatus DoEndReceiveField(WifiPpduField field, Ptr< Event > event)
End receiving a given field, perform amendment-specific actions, and provide the status of the recept...
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.
Simulation virtual time values and global simulation resolution.
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.
bool IsZero() const
Exactly equivalent to t == 0.
represent a single transmission mode
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Ptr< WifiPhyStateHelper > m_state
Pointer to WifiPhyStateHelper.
double GetCcaEdThreshold() const
Return the CCA energy detection threshold (dBm).
Ptr< UniformRandomVariable > m_random
Provides uniform random variables.
void NotifyCcaBusy(const Ptr< const WifiPpdu > ppdu, Time duration)
Notify PHY state helper to switch to CCA busy state,.
WifiPhyOperatingChannel m_operatingChannel
Operating channel.
static Time GetPayloadDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, MpduType mpdutype=NORMAL_MPDU, uint16_t staId=SU_STA_ID)
uint16_t GetChannelWidth() const
std::map< std::pair< uint64_t, WifiPreamble >, Ptr< Event > > m_currentPreambleEvents
store event associated to a PPDU (that has a unique ID and preamble combination) whose preamble is be...
EventId m_endPhyRxEvent
the end of PHY receive event
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
static Time GetPreambleDetectionDuration()
void AbortCurrentReception(WifiPhyRxfailureReason reason)
Due to newly arrived signal, the current reception cannot be continued and has to be aborted.
Ptr< FrameCaptureModel > m_frameCaptureModel
Frame capture model.
void NotifyRxBegin(Ptr< const WifiPsdu > psdu, const RxPowerWattPerChannelBand &rxPowersW)
Public method used to fire a PhyRxBegin trace.
virtual uint16_t GetGuardBandwidth(uint16_t currentChannelWidth) const =0
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
std::map< WifiModulationClass, Ptr< PhyEntity > > m_phyEntities
This map holds the supported PHY entities.
Ptr< ErrorModel > m_postReceptionErrorModel
Error model for receive packet events.
WifiPhyBand GetPhyBand() const
Get the configured Wi-Fi band.
Ptr< Event > m_currentEvent
Hold the current event.
uint8_t GetChannelNumber() const
Return current channel number.
uint64_t m_previouslyRxPpduUid
UID of the previously received PPDU, reset to UINT64_MAX upon transmission.
Ptr< PreambleDetectionModel > m_preambleDetectionModel
Preamble detection model.
void NotifyRxEnd(Ptr< const WifiPsdu > psdu)
Public method used to fire a PhyRxEnd trace.
bool IsStateSleep() const
virtual FrequencyRange GetCurrentFrequencyRange() const =0
Get the frequency range of the current RF interface.
virtual WifiSpectrumBandInfo GetBand(uint16_t bandWidth, uint8_t bandIndex=0)=0
Get the info of a given band.
Ptr< InterferenceHelper > m_interference
Pointer to a helper responsible for interference computations.
double GetTxPowerForTransmission(Ptr< const WifiPpdu > ppdu) const
Compute the transmit power for the next transmission.
virtual std::tuple< double, double, double > GetTxMaskRejectionParams() const =0
void NotifyMonitorSniffRx(Ptr< const WifiPsdu > psdu, uint16_t channelFreqMhz, WifiTxVector txVector, SignalNoiseDbm signalNoise, std::vector< bool > statusPerMpdu, uint16_t staId=SU_STA_ID)
Public method used to fire a MonitorSniffer trace for a wifi PSDU being received.
Ptr< PhyEntity > GetPhyEntityForPpdu(const Ptr< const WifiPpdu > ppdu) const
Get the supported PHY entity to use for a received PPDU.
void Reset()
Reset data upon end of TX or RX.
TracedCallback< WifiTxVector, Time > m_phyRxPayloadBeginTrace
The trace source fired when the reception of the PHY payload (PSDU) begins.
Time GetLastRxEndTime() const
Return the end time of the last received packet.
Time m_timeLastPreambleDetected
Record the time the last preamble was detected.
void SwitchMaybeToCcaBusy(const Ptr< const WifiPpdu > ppdu)
Check if PHY state should move to CCA busy state based on current state of interference tracker.
const WifiPhyOperatingChannel & GetOperatingChannel() const
Get a const reference to the operating channel.
double GetCcaSensitivityThreshold() const
Return the CCA sensitivity threshold (dBm).
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...
uint8_t GetSecondaryChannelIndex(uint16_t secondaryChannelWidth) const
If the operating channel width is made of a multiple of 20 MHz, return the index of the secondary cha...
uint16_t GetPrimaryChannelCenterFrequency(uint16_t primaryChannelWidth) const
Get the center frequency of the primary channel of the given width.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
WifiPreamble GetPreambleType() const
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_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_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_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.
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.
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)
MpduType
The type of an MPDU.
@ PREAMBLE_DETECT_FAILURE
@ FRAME_CAPTURE_PACKET_SWITCH
@ PREAMBLE_DETECTION_PACKET_SWITCH
@ WIFI_PPDU_FIELD_EHT_SIG
EHT-SIG field.
@ 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
@ LAST_MPDU_IN_AGGREGATE
The MPDU is the last aggregate in an A-MPDU with multiple MPDUs.
@ NORMAL_MPDU
The MPDU is not part of an A-MPDU.
@ FIRST_MPDU_IN_AGGREGATE
The MPDU is the first aggregate in an A-MPDU with multiple MPDUs, but is not the last aggregate.
@ SINGLE_MPDU
The MPDU is a single MPDU.
@ MIDDLE_MPDU_IN_AGGREGATE
The MPDU is part of an A-MPDU with multiple MPDUs, but is neither the first nor the last aggregate.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double RatioToDb(double ratio)
Convert from ratio to dB.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
double WToDbm(double w)
Convert from Watts to dBm.
std::ostream & operator<<(std::ostream &os, const Angles &a)
double Integral(const SpectrumValue &arg)
double DbmToW(double dBm)
Convert from dBm to Watts.
std::map< WifiSpectrumBandInfo, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
static constexpr uint16_t SU_STA_ID
STA_ID to identify a single user (SU)
Status of the reception of the PPDU field.
WifiPhyRxfailureReason reason
failure reason
PhyRxFailureAction actionIfFailure
action to perform in case of failure
bool isSuccess
outcome (true if success) of the reception
A struct for both SNR and PER.
double snr
SNR in linear scale.
RxSignalInfo structure containing info on the received signal.
double snr
SNR in linear scale.
SignalNoiseDbm structure.
double noise
noise power in dBm
double signal
signal strength in dBm
WifiSpectrumBandInfo structure containing info about a spectrum band.