A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
phy-entity.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Orange Labs
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Rediet <getachew.redieteab@orange.com>
7 * Sébastien Deronne <sebastien.deronne@gmail.com> (for logic ported from wifi-phy and
8 * spectrum-wifi-phy)
9 * Mathieu Lacage <mathieu.lacage@sophia.inria.fr> (for logic ported from wifi-phy)
10 */
11
12#include "phy-entity.h"
13
14#include "frame-capture-model.h"
15#include "interference-helper.h"
17#include "spectrum-wifi-phy.h"
18#include "wifi-net-device.h"
19#include "wifi-psdu.h"
22#include "wifi-utils.h"
23
24#include "ns3/assert.h"
25#include "ns3/data-rate.h"
26#include "ns3/log.h"
27#include "ns3/mobility-model.h"
28#include "ns3/packet.h"
29#include "ns3/simulator.h"
30
31#include <algorithm>
32
33#undef NS_LOG_APPEND_CONTEXT
34#define NS_LOG_APPEND_CONTEXT WIFI_PHY_NS_LOG_APPEND_CONTEXT(m_wifiPhy)
35
36namespace ns3
37{
38
39NS_LOG_COMPONENT_DEFINE("PhyEntity");
40
41std::ostream&
42operator<<(std::ostream& os, const PhyEntity::PhyRxFailureAction& action)
43{
44 switch (action)
45 {
46 case PhyEntity::DROP:
47 return (os << "DROP");
49 return (os << "ABORT");
51 return (os << "IGNORE");
52 default:
53 NS_FATAL_ERROR("Unknown action");
54 return (os << "unknown");
55 }
56}
57
58std::ostream&
59operator<<(std::ostream& os, const PhyEntity::PhyFieldRxStatus& status)
60{
61 if (status.isSuccess)
62 {
63 return os << "success";
64 }
65 else
66 {
67 return os << "failure (" << status.reason << "/" << status.actionIfFailure << ")";
68 }
69}
70
71/*******************************************************
72 * Abstract base class for PHY entities
73 *******************************************************/
74
76
83
84void
86{
87 NS_LOG_FUNCTION(this << wifiPhy);
88 m_wifiPhy = wifiPhy;
89 m_state = m_wifiPhy->m_state;
90}
91
92bool
94{
95 for (const auto& m : m_modeList)
96 {
97 if (m == mode)
98 {
99 return true;
100 }
101 }
102 return false;
103}
104
105uint8_t
107{
108 return m_modeList.size();
109}
110
112PhyEntity::GetMcs(uint8_t /* index */) const
113{
115 "This method should be used only for HtPhy and child classes. Use GetMode instead.");
116 return WifiMode();
117}
118
119bool
120PhyEntity::IsMcsSupported(uint8_t /* index */) const
121{
122 NS_ABORT_MSG("This method should be used only for HtPhy and child classes. Use IsModeSupported "
123 "instead.");
124 return false;
125}
126
127bool
129{
130 return false;
131}
132
133std::list<WifiMode>::const_iterator
135{
136 return m_modeList.begin();
137}
138
139std::list<WifiMode>::const_iterator
141{
142 return m_modeList.end();
143}
144
147{
148 NS_FATAL_ERROR("PPDU field is not a SIG field (no sense in retrieving the signaled mode) or is "
149 "unsupported: "
150 << field);
151 return WifiMode(); // should be overloaded
152}
153
156{
157 const auto& ppduFormats = GetPpduFormats();
158 const auto itPpdu = ppduFormats.find(preamble);
159 if (itPpdu != ppduFormats.end())
160 {
161 const auto itField = std::find(itPpdu->second.begin(), itPpdu->second.end(), currentField);
162 if (itField != itPpdu->second.end())
163 {
164 const auto itNextField = std::next(itField, 1);
165 if (itNextField != itPpdu->second.end())
166 {
167 return *(itNextField);
168 }
169 NS_FATAL_ERROR("No field after " << currentField << " for " << preamble
170 << " for the provided PPDU formats");
171 }
172 else
173 {
174 NS_FATAL_ERROR("Unsupported PPDU field " << currentField << " for " << preamble
175 << " for the provided PPDU formats");
176 }
177 }
178 else
179 {
180 NS_FATAL_ERROR("Unsupported preamble " << preamble << " for the provided PPDU formats");
181 }
182 return WifiPpduField::WIFI_PPDU_FIELD_PREAMBLE; // Silence compiler warning
183}
184
185Time
187{
188 if (field > WIFI_PPDU_FIELD_EHT_SIG)
189 {
190 NS_FATAL_ERROR("Unsupported PPDU field");
191 }
192 return Time(); // should be overloaded
193}
194
195Time
197{
198 Time duration;
199 for (uint8_t field = WIFI_PPDU_FIELD_PREAMBLE; field < WIFI_PPDU_FIELD_DATA; ++field)
200 {
201 duration += GetDuration(static_cast<WifiPpduField>(field), txVector);
202 }
203 return duration;
204}
205
208{
209 return WifiConstPsduMap({{SU_STA_ID, psdu}});
210}
211
214{
215 return ppdu->GetPsdu();
216}
217
219PhyEntity::GetPhyHeaderSections(const WifiTxVector& txVector, Time ppduStart) const
220{
222 WifiPpduField field = WIFI_PPDU_FIELD_PREAMBLE; // preamble always present
223 Time start = ppduStart;
224
225 while (field != WIFI_PPDU_FIELD_DATA)
226 {
227 Time duration = GetDuration(field, txVector);
228 map[field] = {{start, start + duration}, GetSigMode(field, txVector)};
229 // Move to next field
230 start += duration;
231 field = GetNextField(field, txVector.GetPreambleType());
232 }
233 return map;
234}
235
237PhyEntity::BuildPpdu(const WifiConstPsduMap& psdus, const WifiTxVector& txVector, Time ppduDuration)
238{
239 NS_LOG_FUNCTION(this << psdus << txVector << ppduDuration);
240 NS_FATAL_ERROR("This method is unsupported for the base PhyEntity class. Use the overloaded "
241 "version in the amendment-specific subclasses instead!");
242 return Create<WifiPpdu>(psdus.begin()->second,
243 txVector,
244 m_wifiPhy->GetOperatingChannel()); // should be overloaded
245}
246
247Time
249{
250 if (field ==
251 WIFI_PPDU_FIELD_DATA) // this field is not in the map returned by GetPhyHeaderSections
252 {
254 }
255 const auto& sections = GetPhyHeaderSections(txVector, Time());
256 auto it = sections.find(field);
257 NS_ASSERT(it != sections.end());
258 const auto& startStopTimes = it->second.first;
259 return startStopTimes
260 .first; // return the start time of field relatively to the beginning of the PPDU
261}
262
263SnrPer
265{
266 const auto measurementChannelWidth = GetMeasurementChannelWidth(event->GetPpdu());
267 return m_wifiPhy->m_interference->CalculatePhyHeaderSnrPer(
268 event,
269 measurementChannelWidth,
270 GetPrimaryBand(measurementChannelWidth),
271 field);
272}
273
274void
276{
277 NS_LOG_FUNCTION(this << field << *event);
278 NS_ASSERT(m_wifiPhy); // no sense if no owner WifiPhy instance
279 NS_ASSERT(m_wifiPhy->m_endPhyRxEvent.IsExpired());
281 "Use the StartReceivePreamble method for preamble reception");
282 // Handle special cases of data reception
283 if (field == WIFI_PPDU_FIELD_DATA)
284 {
285 StartReceivePayload(event);
286 return;
287 }
288
289 bool supported = DoStartReceiveField(field, event);
290 NS_ABORT_MSG_IF(!supported,
291 "Unknown field "
292 << field << " for this PHY entity"); // TODO see what to do if not supported
293 Time duration = GetDuration(field, event->GetPpdu()->GetTxVector());
294 m_wifiPhy->m_endPhyRxEvent =
295 Simulator::Schedule(duration, &PhyEntity::EndReceiveField, this, field, event);
296 m_wifiPhy->NotifyCcaBusy(
297 event->GetPpdu(),
298 duration); // keep in CCA busy state up to reception of Data (will then switch to RX)
299}
300
301void
303{
304 NS_LOG_FUNCTION(this << field << *event);
305 NS_ASSERT(m_wifiPhy); // no sense if no owner WifiPhy instance
306 NS_ASSERT(m_wifiPhy->m_endPhyRxEvent.IsExpired());
307 PhyFieldRxStatus status = DoEndReceiveField(field, event);
308 const auto& txVector = event->GetPpdu()->GetTxVector();
309 if (status.isSuccess) // move to next field if reception succeeded
310 {
311 StartReceiveField(GetNextField(field, txVector.GetPreambleType()), event);
312 }
313 else
314 {
315 Ptr<const WifiPpdu> ppdu = event->GetPpdu();
316 switch (status.actionIfFailure)
317 {
318 case ABORT:
319 // Abort reception, but consider medium as busy
321 if (event->GetEndTime() > (Simulator::Now() + m_state->GetDelayUntilIdle()))
322 {
323 m_wifiPhy->SwitchMaybeToCcaBusy(ppdu);
324 }
325 break;
326 case DROP:
327 // Notify drop, keep in CCA busy, and perform same processing as IGNORE case
328 if (status.reason == FILTERED)
329 {
330 // PHY-RXSTART is immediately followed by PHY-RXEND (Filtered)
331 m_wifiPhy->m_phyRxPayloadBeginTrace(
332 txVector,
333 NanoSeconds(0)); // this callback (equivalent to PHY-RXSTART primitive) is also
334 // triggered for filtered PPDUs
335 }
336 m_wifiPhy->NotifyRxPpduDrop(ppdu, status.reason);
337 m_wifiPhy->NotifyCcaBusy(ppdu, GetRemainingDurationAfterField(ppdu, field));
338 // no break
339 case IGNORE:
340 // Keep in Rx state and reset at end
341 m_endRxPayloadEvents.push_back(
344 this,
345 event));
346 break;
347 default:
348 NS_FATAL_ERROR("Unknown action in case of failure");
349 }
350 }
351}
352
353Time
355{
356 const auto& txVector = ppdu->GetTxVector();
357 return ppdu->GetTxDuration() -
358 (GetDurationUpToField(field, txVector) + GetDuration(field, txVector));
359}
360
361bool
363{
364 NS_LOG_FUNCTION(this << field << *event);
366 field != WIFI_PPDU_FIELD_DATA); // handled apart for the time being
367 const auto& ppduFormats = GetPpduFormats();
368 auto itFormat = ppduFormats.find(event->GetPpdu()->GetPreamble());
369 if (itFormat != ppduFormats.end())
370 {
371 auto itField = std::find(itFormat->second.begin(), itFormat->second.end(), field);
372 if (itField != itFormat->second.end())
373 {
374 return true; // supported field so we can start receiving
375 }
376 }
377 return false; // unsupported otherwise
378}
379
382{
383 NS_LOG_FUNCTION(this << field << *event);
384 NS_ASSERT(field != WIFI_PPDU_FIELD_DATA); // handled apart for the time being
385 if (field == WIFI_PPDU_FIELD_PREAMBLE)
386 {
387 return DoEndReceivePreamble(event);
388 }
389 return PhyFieldRxStatus(false); // failed reception by default
390}
391
392void
394 RxPowerWattPerChannelBand& rxPowersW,
395 Time rxDuration)
396{
397 // The total RX power corresponds to the maximum over all the bands
398 auto it =
399 std::max_element(rxPowersW.begin(), rxPowersW.end(), [](const auto& p1, const auto& p2) {
400 return p1.second < p2.second;
401 });
402 NS_LOG_FUNCTION(this << ppdu << it->second);
403
404 auto event = DoGetEvent(ppdu, rxPowersW);
405 if (!event)
406 {
407 // PPDU should be simply considered as interference (once it has been accounted for in
408 // InterferenceHelper)
409 return;
410 }
411
412 Time endRx = Simulator::Now() + rxDuration;
413 if (ppdu->IsTruncatedTx())
414 {
415 NS_LOG_DEBUG("Packet reception stopped because transmitter has been switched off");
416 if (endRx > (Simulator::Now() + m_state->GetDelayUntilIdle()))
417 {
418 m_wifiPhy->SwitchMaybeToCcaBusy(ppdu);
419 }
421 return;
422 }
423
424 switch (m_state->GetState())
425 {
427 NS_LOG_DEBUG("Drop packet because of channel switching");
428 /*
429 * Packets received on the upcoming channel are added to the event list
430 * during the switching state. This way the medium can be correctly sensed
431 * when the device listens to the channel for the first time after the
432 * switching e.g. after channel switching, the channel may be sensed as
433 * busy due to other devices' transmissions started before the end of
434 * the switching.
435 */
437 break;
438 case WifiPhyState::RX:
439 if (m_wifiPhy->m_frameCaptureModel &&
440 m_wifiPhy->m_frameCaptureModel->IsInCaptureWindow(
441 m_wifiPhy->m_timeLastPreambleDetected) &&
442 m_wifiPhy->m_frameCaptureModel->CaptureNewFrame(m_wifiPhy->m_currentEvent, event))
443 {
445 NS_LOG_DEBUG("Switch to new packet");
447 }
448 else
449 {
450 NS_LOG_DEBUG("Drop packet because already in Rx");
451 DropPreambleEvent(ppdu, RXING, endRx);
452 if (!m_wifiPhy->m_currentEvent)
453 {
454 /*
455 * We are here because the non-legacy PHY header has not been successfully received.
456 * The PHY is kept in RX state for the duration of the PPDU, but EndReceive function
457 * is not called when the reception of the PPDU is finished, which is responsible to
458 * clear m_currentPreambleEvents. As a result, m_currentPreambleEvents should be
459 * cleared here.
460 */
461 m_wifiPhy->m_currentPreambleEvents.clear();
462 }
463 }
464 break;
465 case WifiPhyState::TX:
466 NS_LOG_DEBUG("Drop packet because already in Tx");
467 DropPreambleEvent(ppdu, TXING, endRx);
468 break;
470 if (m_wifiPhy->m_currentEvent)
471 {
472 if (m_wifiPhy->m_frameCaptureModel &&
473 m_wifiPhy->m_frameCaptureModel->IsInCaptureWindow(
474 m_wifiPhy->m_timeLastPreambleDetected) &&
475 m_wifiPhy->m_frameCaptureModel->CaptureNewFrame(m_wifiPhy->m_currentEvent, event))
476 {
478 NS_LOG_DEBUG("Switch to new packet");
480 }
481 else
482 {
483 NS_LOG_DEBUG("Drop packet because already decoding preamble");
485 }
486 }
487 else
488 {
490 }
491 break;
493 NS_ASSERT(!m_wifiPhy->m_currentEvent);
495 break;
497 NS_LOG_DEBUG("Drop packet because in sleep mode");
498 DropPreambleEvent(ppdu, SLEEPING, endRx);
499 break;
501 NS_LOG_DEBUG("Drop packet because in switched off");
503 break;
504 default:
505 NS_FATAL_ERROR("Invalid WifiPhy state.");
506 break;
507 }
508}
509
510void
512{
513 NS_LOG_FUNCTION(this << ppdu << reason << endRx);
514 m_wifiPhy->NotifyRxPpduDrop(ppdu, reason);
515 auto it = m_wifiPhy->m_currentPreambleEvents.find({ppdu->GetUid(), ppdu->GetPreamble()});
516 if (it != m_wifiPhy->m_currentPreambleEvents.end())
517 {
518 m_wifiPhy->m_currentPreambleEvents.erase(it);
519 }
520 if (!m_wifiPhy->IsStateSleep() && !m_wifiPhy->IsStateOff() &&
521 (endRx > (Simulator::Now() + m_state->GetDelayUntilIdle())))
522 {
523 // that PPDU will be noise _after_ the end of the current event.
524 m_wifiPhy->SwitchMaybeToCcaBusy(ppdu);
525 }
526}
527
528void
530{
531 NS_LOG_FUNCTION(this << ppdu << rxDuration);
532 auto it = m_wifiPhy->m_currentPreambleEvents.find({ppdu->GetUid(), ppdu->GetPreamble()});
533 if (it != m_wifiPhy->m_currentPreambleEvents.end())
534 {
535 m_wifiPhy->m_currentPreambleEvents.erase(it);
536 }
537 if (m_wifiPhy->m_currentPreambleEvents.empty())
538 {
539 m_wifiPhy->Reset();
540 }
541
542 if (rxDuration > m_state->GetDelayUntilIdle())
543 {
544 // this PPDU will be noise _after_ the completion of the current event
545 m_wifiPhy->SwitchMaybeToCcaBusy(ppdu);
546 }
547}
548
549uint16_t
551{
552 return SU_STA_ID;
553}
554
555void
557{
558 NS_LOG_FUNCTION(this << *event);
559 NS_ASSERT(m_wifiPhy->m_endPhyRxEvent.IsExpired());
560
561 Time payloadDuration = DoStartReceivePayload(event);
562 m_state->SwitchToRx(payloadDuration);
563}
564
565Time
567{
568 NS_LOG_FUNCTION(this << *event);
569 Ptr<const WifiPpdu> ppdu = event->GetPpdu();
570 NS_LOG_DEBUG("Receiving PSDU");
571 uint16_t staId = GetStaId(ppdu);
572 m_signalNoiseMap.insert({{ppdu->GetUid(), staId}, SignalNoiseDbm()});
573 m_statusPerMpduMap.insert({{ppdu->GetUid(), staId}, std::vector<bool>()});
574 ScheduleEndOfMpdus(event);
575 const auto& txVector = event->GetPpdu()->GetTxVector();
576 Time payloadDuration = ppdu->GetTxDuration() - CalculatePhyPreambleAndHeaderDuration(txVector);
577 m_endRxPayloadEvents.push_back(
578 Simulator::Schedule(payloadDuration, &PhyEntity::EndReceivePayload, this, event));
579 // this callback (equivalent to PHY-RXSTART primitive) is triggered only if headers have been
580 // correctly decoded and that the mode within is supported. It must be called after scheduling
581 // the call to EndReceivePayload (above) because EndReceivePayload must be called before the
582 // expiration of the timer started by the MAC when receiving the RXSTART indication.
583 m_wifiPhy->m_phyRxPayloadBeginTrace(txVector, payloadDuration);
584 return payloadDuration;
585}
586
587void
589{
590 NS_LOG_FUNCTION(this << *event);
591 Ptr<const WifiPpdu> ppdu = event->GetPpdu();
593 const auto& txVector = event->GetPpdu()->GetTxVector();
594 uint16_t staId = GetStaId(ppdu);
595 Time endOfMpduDuration;
596 Time relativeStart;
597 Time psduDuration = ppdu->GetTxDuration() - CalculatePhyPreambleAndHeaderDuration(txVector);
598 Time remainingAmpduDuration = psduDuration;
599 size_t nMpdus = psdu->GetNMpdus();
600 MpduType mpduType =
601 (nMpdus > 1) ? FIRST_MPDU_IN_AGGREGATE : (psdu->IsSingle() ? SINGLE_MPDU : NORMAL_MPDU);
602 uint32_t totalAmpduSize = 0;
603 double totalAmpduNumSymbols = 0.0;
604 auto mpdu = psdu->begin();
605 for (size_t i = 0; i < nMpdus && mpdu != psdu->end(); ++mpdu)
606 {
607 if (m_wifiPhy->m_notifyRxMacHeaderEnd)
608 {
609 // calculate MAC header size (including A-MPDU subframe header, if present)
610 auto macHdrSize =
611 (*mpdu)->GetHeader().GetSerializedSize() + (mpduType == NORMAL_MPDU ? 0 : 4);
612 // calculate the (approximate) duration of the MAC header TX
613 auto macHdrDuration = DataRate(txVector.GetMode(staId).GetDataRate(txVector, staId))
614 .CalculateBytesTxTime(macHdrSize);
615 const auto widthBand = GetChannelWidthAndBand(txVector, staId);
616 const auto snrPer = m_wifiPhy->m_interference->CalculatePayloadSnrPer(
617 event,
618 widthBand.first,
619 widthBand.second,
620 staId,
621 {relativeStart, relativeStart + macHdrDuration});
622 if (GetRandomValue() > snrPer.per)
623 {
624 // interference level should permit to correctly decode the MAC header
625 m_endOfMacHdrEvents[staId].push_back(
626 Simulator::Schedule(endOfMpduDuration + macHdrDuration, [=, this]() {
627 m_wifiPhy->m_phyRxMacHeaderEndTrace((*mpdu)->GetHeader(),
628 txVector,
629 remainingAmpduDuration -
630 macHdrDuration);
631 }));
632 }
633 }
634
635 uint32_t size = (mpduType == NORMAL_MPDU) ? psdu->GetSize() : psdu->GetAmpduSubframeSize(i);
636 Time mpduDuration = WifiPhy::GetPayloadDuration(size,
637 txVector,
638 m_wifiPhy->GetPhyBand(),
639 mpduType,
640 true,
641 totalAmpduSize,
642 totalAmpduNumSymbols,
643 staId);
644
645 remainingAmpduDuration -= mpduDuration;
646 if (i == (nMpdus - 1) && !remainingAmpduDuration.IsZero()) // no more MPDUs coming
647 {
648 if (remainingAmpduDuration < txVector.GetGuardInterval()) // enables to ignore padding
649 {
650 mpduDuration += remainingAmpduDuration; // apply a correction just in case rounding
651 // had induced slight shift
652 }
653 }
654
655 endOfMpduDuration += mpduDuration;
656 NS_LOG_INFO("Schedule end of MPDU #"
657 << i << " in " << endOfMpduDuration.As(Time::NS) << " (relativeStart="
658 << relativeStart.As(Time::NS) << ", mpduDuration=" << mpduDuration.As(Time::NS)
659 << ", remainingAmdpuDuration=" << remainingAmpduDuration.As(Time::NS) << ")");
660 m_endOfMpduEvents.push_back(Simulator::Schedule(endOfMpduDuration,
662 this,
663 event,
664 *mpdu,
665 i,
666 relativeStart,
667 mpduDuration));
668
669 // Prepare next iteration
670 ++i;
671 relativeStart += mpduDuration;
672 mpduType = (i == (nMpdus - 1)) ? LAST_MPDU_IN_AGGREGATE : MIDDLE_MPDU_IN_AGGREGATE;
673 }
674}
675
676void
678 Ptr<WifiMpdu> mpdu,
679 size_t mpduIndex,
680 Time relativeStart,
681 Time mpduDuration)
682{
683 NS_LOG_FUNCTION(this << *event << mpduIndex << relativeStart << mpduDuration);
684 const auto ppdu = event->GetPpdu();
685 const auto& txVector = ppdu->GetTxVector();
686 uint16_t staId = GetStaId(ppdu);
687
688 std::pair<bool, SignalNoiseDbm> rxInfo =
689 GetReceptionStatus(mpdu, event, staId, relativeStart, mpduDuration);
690 NS_LOG_DEBUG("Extracted MPDU #" << mpduIndex << ": duration: " << mpduDuration.As(Time::NS)
691 << ", correct reception: " << rxInfo.first << ", Signal/Noise: "
692 << rxInfo.second.signal << "/" << rxInfo.second.noise << "dBm");
693
694 auto signalNoiseIt = m_signalNoiseMap.find({ppdu->GetUid(), staId});
695 NS_ASSERT(signalNoiseIt != m_signalNoiseMap.end());
696 signalNoiseIt->second = rxInfo.second;
697
698 RxSignalInfo rxSignalInfo;
699 rxSignalInfo.snr = DbToRatio(dB_u{rxInfo.second.signal - rxInfo.second.noise});
700 rxSignalInfo.rssi = rxInfo.second.signal;
701
702 auto statusPerMpduIt = m_statusPerMpduMap.find({ppdu->GetUid(), staId});
703 NS_ASSERT(statusPerMpduIt != m_statusPerMpduMap.end());
704 statusPerMpduIt->second.push_back(rxInfo.first);
705
706 if (rxInfo.first && GetAddressedPsduInPpdu(ppdu)->GetNMpdus() > 1)
707 {
708 // only done for correct MPDU that is part of an A-MPDU
709 m_state->NotifyRxMpdu(Create<const WifiPsdu>(mpdu, false), rxSignalInfo, txVector);
710 }
711}
712
713void
715{
716 const auto ppdu = event->GetPpdu();
717 const auto& txVector = ppdu->GetTxVector();
718 NS_LOG_FUNCTION(this << *event);
719 NS_ASSERT(event->GetEndTime() == Simulator::Now());
720 const auto staId = GetStaId(ppdu);
721 const auto channelWidthAndBand = GetChannelWidthAndBand(txVector, staId);
722 const auto snr = m_wifiPhy->m_interference->CalculateSnr(event,
723 channelWidthAndBand.first,
724 txVector.GetNss(staId),
725 channelWidthAndBand.second);
726
728 m_wifiPhy->NotifyRxEnd(psdu);
729
730 auto signalNoiseIt = m_signalNoiseMap.find({ppdu->GetUid(), staId});
731 NS_ASSERT(signalNoiseIt != m_signalNoiseMap.end());
732 auto statusPerMpduIt = m_statusPerMpduMap.find({ppdu->GetUid(), staId});
733 NS_ASSERT(statusPerMpduIt != m_statusPerMpduMap.end());
734 // store per-MPDU status, which is cleared by the call to DoEndReceivePayload below
735 auto statusPerMpdu = statusPerMpduIt->second;
736
737 RxSignalInfo rxSignalInfo;
738 bool success;
739
740 if (std::any_of(statusPerMpdu.cbegin(), statusPerMpdu.cend(), [](const auto status) {
741 return status;
742 }))
743 {
744 // At least one MPDU has been successfully received
745 m_wifiPhy->NotifyMonitorSniffRx(psdu,
746 m_wifiPhy->GetFrequency(),
747 txVector,
748 signalNoiseIt->second,
749 statusPerMpdu,
750 staId);
751 rxSignalInfo.snr = snr;
752 rxSignalInfo.rssi = signalNoiseIt->second.signal; // same information for all MPDUs
753 RxPayloadSucceeded(psdu, rxSignalInfo, txVector, staId, statusPerMpdu);
754 m_wifiPhy->m_previouslyRxPpduUid =
755 ppdu->GetUid(); // store UID only if reception is successful (because otherwise trigger
756 // won't be read by MAC layer)
757 success = true;
758 }
759 else
760 {
761 RxPayloadFailed(psdu, snr, txVector);
762 success = false;
763 }
764
765 m_state->NotifyRxPpduOutcome(ppdu, rxSignalInfo, txVector, staId, statusPerMpduIt->second);
767 m_wifiPhy->SwitchMaybeToCcaBusy(ppdu);
768
769 // notify the MAC through the PHY state helper as the last action. Indeed, the notification
770 // of the RX end may lead the MAC to request a PHY state change (e.g., channel switch, sleep).
771 // Hence, all actions the PHY has to perform when RX ends should be completed before
772 // notifying the MAC.
773 success ? m_state->NotifyRxPsduSucceeded(psdu, rxSignalInfo, txVector, staId, statusPerMpdu)
774 : m_state->NotifyRxPsduFailed(psdu, snr);
775}
776
777void
779 RxSignalInfo rxSignalInfo,
780 const WifiTxVector& txVector,
781 uint16_t staId,
782 const std::vector<bool>& statusPerMpdu)
783{
784 NS_LOG_FUNCTION(this << *psdu << txVector);
785 m_state->SwitchFromRxEndOk();
786}
787
788void
790{
791 NS_LOG_FUNCTION(this << *psdu << txVector << snr);
792 m_state->SwitchFromRxEndError(txVector);
793}
794
795void
797{
798 NS_LOG_FUNCTION(this << ppdu);
799 NS_ASSERT(m_wifiPhy->GetLastRxEndTime() == Simulator::Now());
800 NotifyInterferenceRxEndAndClear(false); // don't reset WifiPhy
801
802 m_wifiPhy->m_currentEvent = nullptr;
803 m_wifiPhy->m_currentPreambleEvents.clear();
804 m_endRxPayloadEvents.clear();
805}
806
807std::pair<bool, SignalNoiseDbm>
809 Ptr<Event> event,
810 uint16_t staId,
811 Time relativeMpduStart,
812 Time mpduDuration)
813{
814 NS_LOG_FUNCTION(this << *mpdu << *event << staId << relativeMpduStart << mpduDuration);
815 const auto channelWidthAndBand = GetChannelWidthAndBand(event->GetPpdu()->GetTxVector(), staId);
816 SnrPer snrPer = m_wifiPhy->m_interference->CalculatePayloadSnrPer(
817 event,
818 channelWidthAndBand.first,
819 channelWidthAndBand.second,
820 staId,
821 {relativeMpduStart, relativeMpduStart + mpduDuration});
822
823 WifiMode mode = event->GetPpdu()->GetTxVector().GetMode(staId);
824 NS_LOG_DEBUG("rate=" << (mode.GetDataRate(event->GetPpdu()->GetTxVector(), staId))
825 << ", SNR(dB)=" << RatioToDb(snrPer.snr) << ", PER=" << snrPer.per
826 << ", size=" << mpdu->GetSize()
827 << ", relativeStart = " << relativeMpduStart.As(Time::NS)
828 << ", duration = " << mpduDuration.As(Time::NS));
829
830 // There are two error checks: PER and receive error model check.
831 // PER check models is typical for Wi-Fi and is based on signal modulation;
832 // Receive error model is optional, if we have an error model and
833 // it indicates that the packet is corrupt, drop the packet.
834 SignalNoiseDbm signalNoise;
835 signalNoise.signal = WToDbm(event->GetRxPower(channelWidthAndBand.second));
836 signalNoise.noise = WToDbm(event->GetRxPower(channelWidthAndBand.second) / snrPer.snr);
837 if (GetRandomValue() > snrPer.per &&
838 !(m_wifiPhy->m_postReceptionErrorModel &&
839 m_wifiPhy->m_postReceptionErrorModel->IsCorrupt(mpdu->GetPacket()->Copy())))
840 {
841 NS_LOG_DEBUG("Reception succeeded: " << *mpdu);
842 return {true, signalNoise};
843 }
844 else
845 {
846 NS_LOG_DEBUG("Reception failed: " << *mpdu);
847 return {false, signalNoise};
848 }
849}
850
851std::optional<Time>
853{
855 {
856 return {};
857 }
858
859 std::optional<Time> delayUntilPreambleDetectionEnd;
860 for (const auto& endPreambleDetectionEvent : m_endPreambleDetectionEvents)
861 {
862 if (endPreambleDetectionEvent.IsPending())
863 {
864 delayUntilPreambleDetectionEnd =
865 std::max(delayUntilPreambleDetectionEnd.value_or(Time{0}),
866 Simulator::GetDelayLeft(endPreambleDetectionEvent));
867 }
868 }
869 return delayUntilPreambleDetectionEnd;
870}
871
872std::optional<Time>
873PhyEntity::GetTimeToMacHdrEnd(uint16_t staId) const
874{
875 const auto it = m_endOfMacHdrEvents.find(staId);
876
877 if (it == m_endOfMacHdrEvents.cend())
878 {
879 return std::nullopt;
880 }
881
882 for (const auto& endOfMacHdrEvent : it->second)
883 {
884 if (endOfMacHdrEvent.IsPending())
885 {
886 return Simulator::GetDelayLeft(endOfMacHdrEvent);
887 }
888 }
889
890 return std::nullopt;
891}
892
893std::pair<MHz_u, WifiSpectrumBandInfo>
894PhyEntity::GetChannelWidthAndBand(const WifiTxVector& txVector, uint16_t /* staId */) const
895{
896 const auto channelWidth = GetRxChannelWidth(txVector);
897 return {channelWidth, GetPrimaryBand(channelWidth)};
898}
899
900const std::map<std::pair<uint64_t, WifiPreamble>, Ptr<Event>>&
902{
903 return m_wifiPhy->m_currentPreambleEvents;
904}
905
906void
908{
909 NS_LOG_FUNCTION(this << *event);
910 Ptr<const WifiPpdu> ppdu = event->GetPpdu();
911 m_wifiPhy->m_currentPreambleEvents.insert({{ppdu->GetUid(), ppdu->GetPreamble()}, event});
912}
913
916{
917 // We store all incoming preamble events, and a decision is made at the end of the preamble
918 // detection window.
919 const auto& currentPreambleEvents = GetCurrentPreambleEvents();
920 const auto it = currentPreambleEvents.find({ppdu->GetUid(), ppdu->GetPreamble()});
921 if (it != currentPreambleEvents.cend())
922 {
923 // received another signal with the same content
924 NS_LOG_DEBUG("Received another PPDU for UID " << ppdu->GetUid());
925 const auto foundEvent = it->second;
926 HandleRxPpduWithSameContent(foundEvent, ppdu, rxPowersW);
927 return nullptr;
928 }
929
930 auto event = CreateInterferenceEvent(ppdu, ppdu->GetTxDuration(), rxPowersW);
931 AddPreambleEvent(event);
932 return event;
933}
934
937 Time duration,
939 bool isStartHePortionRxing /* = false */)
940{
941 return m_wifiPhy->m_interference->Add(ppdu,
942 duration,
943 rxPower,
944 m_wifiPhy->GetCurrentFrequencyRange(),
945 isStartHePortionRxing);
946}
947
948void
952{
953 if (const auto maxDelay =
954 m_wifiPhy->GetPhyEntityForPpdu(ppdu)->GetMaxDelayPpduSameUid(ppdu->GetTxVector());
955 Simulator::Now() - event->GetStartTime() > maxDelay)
956 {
957 // This PPDU arrived too late to be decoded properly. The PPDU is dropped and added as
958 // interference
959 event = CreateInterferenceEvent(ppdu, ppdu->GetTxDuration(), rxPower);
960 NS_LOG_DEBUG("Drop PPDU that arrived too late");
961 m_wifiPhy->NotifyRxPpduDrop(ppdu, PPDU_TOO_LATE);
962 return;
963 }
964
965 // Update received power and TXVECTOR of the event associated to that transmission upon
966 // reception of a signal adding up constructively (in case of a UL MU PPDU or non-HT duplicate
967 // PPDU)
968 m_wifiPhy->m_interference->UpdateEvent(event, rxPower);
969 const auto& txVector = ppdu->GetTxVector();
970 const auto& eventTxVector = event->GetPpdu()->GetTxVector();
971 auto updatedTxVector{eventTxVector};
972 updatedTxVector.SetChannelWidth(
973 std::max(eventTxVector.GetChannelWidth(), txVector.GetChannelWidth()));
974 if (updatedTxVector.GetChannelWidth() != eventTxVector.GetChannelWidth())
975 {
976 event->UpdatePpdu(ppdu);
977 }
978}
979
980void
982{
983 m_wifiPhy->m_interference->NotifyRxEnd(Simulator::Now(), m_wifiPhy->GetCurrentFrequencyRange());
984 m_signalNoiseMap.clear();
985 m_statusPerMpduMap.clear();
986 for (const auto& endOfMpduEvent : m_endOfMpduEvents)
987 {
988 NS_ASSERT(endOfMpduEvent.IsExpired());
989 }
990 m_endOfMpduEvents.clear();
991 for (const auto& [staId, endOfMacHdrEvents] : m_endOfMacHdrEvents)
992 {
993 for (const auto& endOfMacHdrEvent : endOfMacHdrEvents)
994 {
995 NS_ASSERT(endOfMacHdrEvent.IsExpired());
996 }
997 }
998 m_endOfMacHdrEvents.clear();
999 if (reset)
1000 {
1001 m_wifiPhy->Reset();
1002 }
1003}
1004
1007{
1008 NS_LOG_FUNCTION(this << *event);
1009 NS_ASSERT(m_wifiPhy->m_currentPreambleEvents.size() ==
1010 1); // Synched on one after detection period
1011 return PhyFieldRxStatus(true); // always consider that preamble has been correctly received if
1012 // preamble detection was OK
1013}
1014
1015void
1017{
1018 NS_LOG_FUNCTION(this << *event);
1019 const auto rxPower = GetRxPowerForPpdu(event);
1020 NS_LOG_DEBUG("Sync to signal (power=" << (rxPower > Watt_u{0.0}
1021 ? std::to_string(WToDbm(rxPower)) + "dBm)"
1022 : std::to_string(rxPower) + "W)"));
1023 m_wifiPhy->m_interference->NotifyRxStart(
1024 m_wifiPhy->GetCurrentFrequencyRange()); // We need to notify it now so that it starts
1025 // recording events
1029 this,
1030 event));
1031}
1032
1033void
1035{
1036 NS_LOG_FUNCTION(this << *event);
1037 NS_ASSERT(!m_wifiPhy->IsStateRx());
1038 NS_ASSERT(m_wifiPhy->m_endPhyRxEvent.IsExpired()); // since end of preamble reception is
1039 // scheduled by this method upon success
1040
1041 // calculate PER on the measurement channel for PHY headers
1042 const auto measurementChannelWidth = GetMeasurementChannelWidth(event->GetPpdu());
1043 auto measurementBand = GetPrimaryBand(measurementChannelWidth);
1044 std::optional<Watt_u>
1045 maxRxPower; // in case current event may not be sent on measurement channel
1046 Ptr<Event> maxEvent;
1047 NS_ASSERT(!m_wifiPhy->m_currentPreambleEvents.empty());
1048 for (auto preambleEvent : m_wifiPhy->m_currentPreambleEvents)
1049 {
1050 const auto rxPower = preambleEvent.second->GetRxPower(measurementBand);
1051 if (!maxRxPower || (rxPower > *maxRxPower))
1052 {
1053 maxRxPower = rxPower;
1054 maxEvent = preambleEvent.second;
1055 }
1056 }
1057
1058 NS_ASSERT(maxEvent);
1059 if (maxEvent != event)
1060 {
1061 NS_LOG_DEBUG("Receiver got a stronger packet with UID "
1062 << maxEvent->GetPpdu()->GetUid()
1063 << " during preamble detection: drop packet with UID "
1064 << event->GetPpdu()->GetUid());
1065 m_wifiPhy->NotifyRxPpduDrop(event->GetPpdu(), BUSY_DECODING_PREAMBLE);
1066
1067 auto it = m_wifiPhy->m_currentPreambleEvents.find(
1068 {event->GetPpdu()->GetUid(), event->GetPpdu()->GetPreamble()});
1069 m_wifiPhy->m_currentPreambleEvents.erase(it);
1070 // This is needed to cleanup the m_firstPowerPerBand so that the first power corresponds to
1071 // the power at the start of the PPDU
1072 m_wifiPhy->m_interference->NotifyRxEnd(maxEvent->GetStartTime(),
1073 m_wifiPhy->GetCurrentFrequencyRange());
1074 // Make sure InterferenceHelper keeps recording events
1075 m_wifiPhy->m_interference->NotifyRxStart(m_wifiPhy->GetCurrentFrequencyRange());
1076 return;
1077 }
1078
1079 m_wifiPhy->m_currentEvent = event;
1080
1081 const auto snr = m_wifiPhy->m_interference->CalculateSnr(m_wifiPhy->m_currentEvent,
1082 measurementChannelWidth,
1083 1,
1084 measurementBand);
1085 NS_LOG_DEBUG("SNR(dB)=" << RatioToDb(snr) << " at end of preamble detection period");
1086
1087 if (const auto power = m_wifiPhy->m_currentEvent->GetRxPower(measurementBand);
1088 (!m_wifiPhy->m_preambleDetectionModel && maxRxPower && (*maxRxPower > Watt_u{0.0})) ||
1089 (m_wifiPhy->m_preambleDetectionModel && power > Watt_u{0.0} &&
1090 m_wifiPhy->m_preambleDetectionModel->IsPreambleDetected(WToDbm(power),
1091 snr,
1092 measurementChannelWidth)))
1093 {
1094 // A bit convoluted but it enables to sync all PHYs
1095 for (auto& it : m_wifiPhy->m_phyEntities)
1096 {
1097 it.second->CancelRunningEndPreambleDetectionEvents();
1098 }
1099
1100 for (auto it = m_wifiPhy->m_currentPreambleEvents.begin();
1101 it != m_wifiPhy->m_currentPreambleEvents.end();)
1102 {
1103 if (it->second != m_wifiPhy->m_currentEvent)
1104 {
1105 NS_LOG_DEBUG("Drop packet with UID " << it->first.first << " and preamble "
1106 << it->first.second << " arrived at time "
1107 << it->second->GetStartTime());
1109 if (m_wifiPhy->m_currentEvent->GetPpdu()->GetUid() > it->first.first)
1110 {
1112 // This is needed to cleanup the m_firstPowerPerBand so that the first power
1113 // corresponds to the power at the start of the PPDU
1114 m_wifiPhy->m_interference->NotifyRxEnd(
1115 m_wifiPhy->m_currentEvent->GetStartTime(),
1116 m_wifiPhy->GetCurrentFrequencyRange());
1117 }
1118 else
1119 {
1120 reason = BUSY_DECODING_PREAMBLE;
1121 }
1122 m_wifiPhy->NotifyRxPpduDrop(it->second->GetPpdu(), reason);
1123
1124 it = m_wifiPhy->m_currentPreambleEvents.erase(it);
1125 }
1126 else
1127 {
1128 ++it;
1129 }
1130 }
1131
1132 // Make sure InterferenceHelper keeps recording events
1133 m_wifiPhy->m_interference->NotifyRxStart(m_wifiPhy->GetCurrentFrequencyRange());
1134
1135 m_wifiPhy->NotifyRxBegin(GetAddressedPsduInPpdu(m_wifiPhy->m_currentEvent->GetPpdu()),
1136 m_wifiPhy->m_currentEvent->GetRxPowerPerBand());
1137 m_wifiPhy->m_timeLastPreambleDetected = Simulator::Now();
1138
1139 // Continue receiving preamble
1140 const auto durationTillEnd =
1141 GetDuration(WIFI_PPDU_FIELD_PREAMBLE, event->GetPpdu()->GetTxVector()) -
1143 m_wifiPhy->NotifyCcaBusy(event->GetPpdu(),
1144 durationTillEnd); // will be prolonged by next field
1145 m_wifiPhy->m_endPhyRxEvent = Simulator::Schedule(durationTillEnd,
1147 this,
1149 event);
1150 }
1151 else
1152 {
1153 NS_LOG_DEBUG("Drop packet because PHY preamble detection failed");
1154 // Like CCA-SD, CCA-ED is governed by the 4 us CCA window to flag CCA-BUSY
1155 // for any received signal greater than the CCA-ED threshold.
1156 DropPreambleEvent(m_wifiPhy->m_currentEvent->GetPpdu(),
1158 m_wifiPhy->m_currentEvent->GetEndTime());
1159 if (m_wifiPhy->m_currentPreambleEvents.empty())
1160 {
1161 // Do not erase events if there are still pending preamble events to be processed
1162 m_wifiPhy->m_interference->NotifyRxEnd(Simulator::Now(),
1163 m_wifiPhy->GetCurrentFrequencyRange());
1164 }
1165 m_wifiPhy->m_currentEvent = nullptr;
1166 // Cancel preamble reception
1167 m_wifiPhy->m_endPhyRxEvent.Cancel();
1168 }
1169}
1170
1171bool
1173{
1174 WifiMode txMode = ppdu->GetTxVector().GetMode();
1175 if (!IsModeSupported(txMode))
1176 {
1177 NS_LOG_DEBUG("Drop packet because it was sent using an unsupported mode (" << txMode
1178 << ")");
1179 return false;
1180 }
1181 return true;
1182}
1183
1184void
1186{
1187 NS_LOG_FUNCTION(this);
1189 for (auto& endRxPayloadEvent : m_endRxPayloadEvents)
1190 {
1191 endRxPayloadEvent.Cancel();
1192 }
1193 m_endRxPayloadEvents.clear();
1194 for (auto& endMpduEvent : m_endOfMpduEvents)
1195 {
1196 endMpduEvent.Cancel();
1197 }
1198 m_endOfMpduEvents.clear();
1199 for (auto& [staId, endOfMacHdrEvents] : m_endOfMacHdrEvents)
1200 {
1201 for (auto& endMacHdrEvent : endOfMacHdrEvents)
1202 {
1203 endMacHdrEvent.Cancel();
1204 }
1205 }
1206 m_endOfMacHdrEvents.clear();
1207}
1208
1209void
1211{
1212 NS_LOG_FUNCTION(this);
1213 for (auto& endPreambleDetectionEvent : m_endPreambleDetectionEvents)
1214 {
1215 endPreambleDetectionEvent.Cancel();
1216 }
1218}
1219
1220void
1222{
1223 NS_LOG_FUNCTION(this << reason);
1225 m_wifiPhy->AbortCurrentReception(reason);
1226}
1227
1228void
1230{
1231 NS_LOG_FUNCTION(this << reason);
1232 if (m_wifiPhy->m_currentEvent) // Otherwise abort has already been called just before
1233 {
1234 for (auto& endMpduEvent : m_endOfMpduEvents)
1235 {
1236 endMpduEvent.Cancel();
1237 }
1238 m_endOfMpduEvents.clear();
1239 for (auto& [staId, endOfMacHdrEvents] : m_endOfMacHdrEvents)
1240 {
1241 for (auto& endMacHdrEvent : endOfMacHdrEvents)
1242 {
1243 endMacHdrEvent.Cancel();
1244 }
1245 }
1246 m_endOfMacHdrEvents.clear();
1247 }
1248}
1249
1250void
1252{
1253 NS_LOG_FUNCTION(this << *event);
1254 DoResetReceive(event);
1255 NS_ASSERT(!m_wifiPhy->IsStateRx());
1256 m_wifiPhy->m_interference->NotifyRxEnd(Simulator::Now(), m_wifiPhy->GetCurrentFrequencyRange());
1257 NS_ASSERT(m_endRxPayloadEvents.size() == 1 && m_endRxPayloadEvents.front().IsExpired());
1258 m_endRxPayloadEvents.clear();
1259 m_wifiPhy->m_currentEvent = nullptr;
1260 m_wifiPhy->m_currentPreambleEvents.clear();
1261 m_wifiPhy->SwitchMaybeToCcaBusy(event->GetPpdu());
1262}
1263
1264void
1266{
1267 NS_LOG_FUNCTION(this << *event);
1268 NS_ASSERT(event->GetEndTime() == Simulator::Now());
1269}
1270
1271double
1273{
1274 return m_wifiPhy->m_random->GetValue();
1275}
1276
1277Watt_u
1279{
1280 return event->GetRxPower(GetPrimaryBand(GetMeasurementChannelWidth(event->GetPpdu())));
1281}
1282
1285{
1286 return m_wifiPhy->m_currentEvent;
1287}
1288
1291{
1292 if (static_cast<uint16_t>(m_wifiPhy->GetChannelWidth()) % 20 != 0)
1293 {
1294 return m_wifiPhy->GetBand(bandWidth);
1295 }
1296 return m_wifiPhy->GetBand(bandWidth,
1297 m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(bandWidth));
1298}
1299
1302{
1303 NS_ASSERT(m_wifiPhy->GetChannelWidth() >= MHz_u{40});
1304 return m_wifiPhy->GetBand(bandWidth,
1305 m_wifiPhy->GetOperatingChannel().GetSecondaryChannelIndex(bandWidth));
1306}
1307
1308MHz_u
1310{
1311 return std::min(m_wifiPhy->GetChannelWidth(), txVector.GetChannelWidth());
1312}
1313
1314dBm_u
1316 WifiChannelListType /*channelType*/) const
1317{
1318 return (!ppdu) ? m_wifiPhy->GetCcaEdThreshold() : m_wifiPhy->GetCcaSensitivityThreshold();
1319}
1320
1321Time
1323{
1324 return m_wifiPhy->m_interference->GetEnergyDuration(DbmToW(threshold), band);
1325}
1326
1327void
1329{
1330 if (const auto ccaIndication = GetCcaIndication(ppdu))
1331 {
1332 NS_LOG_DEBUG("CCA indication for " << ccaIndication.value().second << " during "
1333 << ccaIndication.value().first.As(Time::US));
1334 m_state->SwitchMaybeToCcaBusy(ccaIndication.value().first,
1335 ccaIndication.value().second,
1336 {});
1337 if (m_wifiPhy->IsStateCcaBusy())
1338 {
1339 NS_LOG_DEBUG("CCA busy for " << m_state->GetDelayUntilIdle().As(Time::US));
1340 }
1341 return;
1342 }
1343
1344 if (ppdu)
1345 {
1347 return;
1348 }
1349
1350 if (m_wifiPhy->IsStateCcaBusy())
1351 {
1352 NS_LOG_DEBUG("Update CCA indication");
1353 m_state->SwitchMaybeToCcaBusy(Seconds(0), WIFI_CHANLIST_PRIMARY, {});
1354 if (m_wifiPhy->IsStateIdle())
1355 {
1356 NS_LOG_DEBUG("CCA indication updated to IDLE");
1357 }
1358 }
1359}
1360
1363{
1364 const auto channelWidth = GetMeasurementChannelWidth(ppdu);
1365 NS_LOG_FUNCTION(this << channelWidth);
1366 const auto ccaThreshold = GetCcaThreshold(ppdu, WIFI_CHANLIST_PRIMARY);
1367 const Time delayUntilCcaEnd = GetDelayUntilCcaEnd(ccaThreshold, GetPrimaryBand(channelWidth));
1368 if (delayUntilCcaEnd.IsStrictlyPositive())
1369 {
1370 return std::make_pair(delayUntilCcaEnd, WIFI_CHANLIST_PRIMARY);
1371 }
1372 return std::nullopt;
1373}
1374
1375void
1377 Time duration,
1378 WifiChannelListType channelType)
1379{
1380 NS_LOG_FUNCTION(this << duration << channelType);
1381 NS_LOG_DEBUG("CCA busy for " << channelType << " during " << duration.As(Time::S));
1382 m_state->SwitchMaybeToCcaBusy(duration, channelType, {});
1383}
1384
1385uint64_t
1387{
1388 NS_LOG_FUNCTION(this);
1389 return m_globalPpduUid++;
1390}
1391
1392Time
1394{
1395 return Seconds(0);
1396}
1397
1398void
1399PhyEntity::NotifyPayloadBegin(const WifiTxVector& txVector, const Time& payloadDuration)
1400{
1401 m_wifiPhy->m_phyRxPayloadBeginTrace(txVector, payloadDuration);
1402}
1403
1404void
1406{
1407 NS_LOG_FUNCTION(this << ppdu);
1408 auto txPower = m_wifiPhy->GetTxPowerForTransmission(ppdu) + m_wifiPhy->GetTxGain();
1409 auto txVector = ppdu->GetTxVector();
1410 auto txPowerSpectrum = GetTxPowerSpectralDensity(DbmToW(txPower), ppdu);
1411 Transmit(ppdu->GetTxDuration(), ppdu, txPower, txPowerSpectrum, "transmission");
1412}
1413
1414void
1417 dBm_u txPower,
1418 Ptr<SpectrumValue> txPowerSpectrum,
1419 const std::string& type)
1420{
1421 NS_LOG_FUNCTION(this << txDuration << ppdu << txPower << type);
1422 NS_LOG_DEBUG("Start " << type << ": signal power before antenna gain=" << txPower << "dBm");
1423 auto txParams = Create<WifiSpectrumSignalParameters>();
1424 txParams->duration = txDuration;
1425 txParams->psd = txPowerSpectrum;
1426 txParams->ppdu = ppdu;
1427 NS_LOG_DEBUG("Starting " << type << " with power " << txPower << " dBm on channel "
1428 << +m_wifiPhy->GetChannelNumber() << " for "
1429 << txParams->duration.As(Time::MS));
1430 NS_LOG_DEBUG("Starting " << type << " with integrated spectrum power "
1431 << WToDbm(Integral(*txPowerSpectrum)) << " dBm; spectrum model Uid: "
1432 << txPowerSpectrum->GetSpectrumModel()->GetUid());
1433 auto spectrumWifiPhy = DynamicCast<SpectrumWifiPhy>(m_wifiPhy);
1434 NS_ASSERT(spectrumWifiPhy);
1435 spectrumWifiPhy->Transmit(txParams);
1436}
1437
1438MHz_u
1439PhyEntity::GetGuardBandwidth(MHz_u currentChannelWidth) const
1440{
1441 return m_wifiPhy->GetGuardBandwidth(currentChannelWidth);
1442}
1443
1444std::tuple<dBr_u, dBr_u, dBr_u>
1446{
1447 return m_wifiPhy->GetTxMaskRejectionParams();
1448}
1449
1450Time
1452 const WifiTxVector& txVector,
1453 WifiPhyBand band) const
1454{
1455 NS_ASSERT(psduMap.size() == 1);
1456 const auto& it = psduMap.begin();
1457 return WifiPhy::CalculateTxDuration(it->second->GetSize(), txVector, band, it->first);
1458}
1459
1460bool
1462{
1463 // The PHY shall not issue a PHY-RXSTART.indication primitive in response to a PPDU that does
1464 // not overlap the primary channel
1465 const auto channelWidth = m_wifiPhy->GetChannelWidth();
1466 const auto primaryWidth = ((static_cast<uint16_t>(channelWidth) % 20 == 0)
1467 ? MHz_u{20}
1468 : channelWidth); // if the channel width is a multiple of 20 MHz,
1469 // then we consider the primary20 channel
1470 const auto p20CenterFreq =
1471 m_wifiPhy->GetOperatingChannel().GetPrimaryChannelCenterFrequency(primaryWidth);
1472 const auto p20MinFreq = p20CenterFreq - (primaryWidth / 2);
1473 const auto p20MaxFreq = p20CenterFreq + (primaryWidth / 2);
1474 const auto txChannelWidth = (ppdu->GetTxChannelWidth() / ppdu->GetTxCenterFreqs().size());
1475 for (auto txCenterFreq : ppdu->GetTxCenterFreqs())
1476 {
1477 const auto minTxFreq = txCenterFreq - txChannelWidth / 2;
1478 const auto maxTxFreq = txCenterFreq + txChannelWidth / 2;
1479 if ((p20MinFreq >= minTxFreq) && (p20MaxFreq <= maxTxFreq))
1480 {
1481 return true;
1482 }
1483 }
1484 return false;
1485}
1486
1489{
1490 return ppdu;
1491}
1492
1493} // namespace ns3
Class for representing data rates.
Definition data-rate.h:78
Time CalculateBytesTxTime(uint32_t bytes) const
Calculate transmission time.
Definition data-rate.cc:187
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.
void EndOfMpdu(Ptr< Event > event, Ptr< WifiMpdu > mpdu, size_t mpduIndex, Time relativeStart, Time mpduDuration)
The last symbol of an MPDU in an A-MPDU has arrived.
MHz_u GetGuardBandwidth(MHz_u currentChannelWidth) const
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).
Definition phy-entity.h:903
virtual void RxPayloadFailed(Ptr< const WifiPsdu > psdu, double snr, const WifiTxVector &txVector)
Perform amendment-specific actions when the payload is unsuccessfully 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...
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.
virtual void StartReceivePreamble(Ptr< const WifiPpdu > ppdu, RxPowerWattPerChannelBand &rxPowersW, Time rxDuration)
Start receiving the PHY preamble of a PPDU (i.e.
std::optional< std::pair< Time, WifiChannelListType > > CcaIndication
CCA end time and its corresponding channel list type (can be std::nullopt if IDLE).
Definition phy-entity.h:887
virtual std::optional< Time > GetTimeToPreambleDetectionEnd() const
Get the remaining time to preamble detection period to elapse, if preamble detection is ongoing.
virtual bool HandlesMcsModes() const
Check if the WifiModes handled by this PHY are MCSs.
void Transmit(Time txDuration, Ptr< const WifiPpdu > ppdu, dBm_u txPower, Ptr< SpectrumValue > txPowerSpectrum, const std::string &type)
This function prepares most of the WifiSpectrumSignalParameters parameters and invokes SpectrumWifiPh...
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).
Definition phy-entity.h:925
Watt_u GetRxPowerForPpdu(Ptr< Event > event) const
Obtain the received power for a given band.
Ptr< WifiPhy > m_wifiPhy
Pointer to the owning WifiPhy.
Definition phy-entity.h:902
std::pair< bool, SignalNoiseDbm > GetReceptionStatus(Ptr< WifiMpdu > mpdu, Ptr< Event > event, uint16_t staId, Time relativeMpduStart, Time mpduDuration)
Get the reception status for the provided MPDU and notify.
std::vector< EventId > m_endOfMpduEvents
the end of MPDU events (only used for A-MPDUs)
Definition phy-entity.h:909
virtual MHz_u GetRxChannelWidth(const WifiTxVector &txVector) const
Return the channel width used in the reception spectrum model.
virtual ~PhyEntity()
Destructor for PHY entity.
Definition phy-entity.cc:77
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.
Definition phy-entity.cc:85
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 Time CalculateTxDuration(const WifiConstPsduMap &psduMap, const WifiTxVector &txVector, WifiPhyBand band) const
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.
virtual std::pair< MHz_u, WifiSpectrumBandInfo > GetChannelWidthAndBand(const WifiTxVector &txVector, uint16_t staId) const
Get the channel width and band to use (will be overloaded by child classes).
static uint64_t m_globalPpduUid
Global counter of the PPDU UID.
Definition phy-entity.h:928
virtual Ptr< SpectrumValue > GetTxPowerSpectralDensity(Watt_u txPower, Ptr< const WifiPpdu > ppdu) const =0
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)
Definition phy-entity.h:914
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.
WifiSpectrumBandInfo GetPrimaryBand(MHz_u bandWidth) const
If the operating channel width is a multiple of 20 MHz, return the info corresponding to the primary ...
WifiPpduField GetNextField(WifiPpduField currentField, WifiPreamble preamble) const
Return the field following the provided one.
void CancelRunningEndPreambleDetectionEvents()
Cancel all end preamble detection events.
Time GetDelayUntilCcaEnd(dBm_u threshold, const WifiSpectrumBandInfo &band)
Return the delay until CCA busy is ended for a given sensitivity threshold and 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,...
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...
Definition phy-entity.h:922
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 SwitchMaybeToCcaBusy(const Ptr< const WifiPpdu > ppdu=nullptr)
Check if PHY state should move to CCA busy state based on current state of interference tracker.
virtual void StartTx(Ptr< const WifiPpdu > ppdu)
This function is called by SpectrumWifiPhy to send the PPDU while performing amendment-specific actio...
SnrPer GetPhyHeaderSnrPer(WifiPpduField field, Ptr< Event > event) const
Obtain the SNR and PER of the PPDU field from the WifiPhy's InterferenceHelper class.
virtual dBm_u GetCcaThreshold(const Ptr< const WifiPpdu > ppdu, WifiChannelListType channelType) const
Return the CCA threshold for a given channel type.
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.
void StartReceiveField(WifiPpduField field, Ptr< Event > event)
Start receiving a given field.
virtual bool IsModeSupported(WifiMode mode) const
Check if the WifiMode is supported.
Definition phy-entity.cc:93
void ResetReceive(Ptr< Event > event)
Reset PHY at the end of the PPDU under reception after it has failed the PHY header.
PhyHeaderSections GetPhyHeaderSections(const WifiTxVector &txVector, Time ppduStart) const
Return a map of PHY header chunk information per PPDU field.
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
Definition phy-entity.h:906
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
Definition phy-entity.h:908
virtual std::optional< Time > GetTimeToMacHdrEnd(uint16_t staId) const
Get the remaining time to the end of the MAC header reception of the next MPDU being received from th...
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.
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.
std::tuple< dBr_u, dBr_u, dBr_u > GetTxMaskRejectionParams() const
virtual MHz_u GetMeasurementChannelWidth(const Ptr< const WifiPpdu > ppdu) const =0
Return the channel width used to measure the RSSI.
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 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.
Definition phy-entity.h:68
@ DROP
drop PPDU and set CCA_BUSY
Definition phy-entity.h:69
@ IGNORE
ignore the reception
Definition phy-entity.h:71
@ ABORT
abort reception of PPDU
Definition phy-entity.h:70
WifiSpectrumBandInfo GetSecondaryBand(MHz_u bandWidth) const
If the channel bonding is used, return the info corresponding to the secondary channel of the given b...
virtual PhyFieldRxStatus DoEndReceiveField(WifiPpduField field, Ptr< Event > event)
End receiving a given field, perform amendment-specific actions, and provide the status of the recept...
std::map< uint16_t, std::vector< EventId > > m_endOfMacHdrEvents
STA_ID-indexed map of the RX end of MAC header events.
Definition phy-entity.h:911
void ScheduleEndOfMpdus(Ptr< Event > event)
Schedule end of MPDUs events.
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
Received power (W) per spectrum band.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition simulator.h:580
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:191
static Time GetDelayLeft(const EventId &id)
Get the remaining time until this event will execute.
Definition simulator.cc:200
Simulation virtual time values and global simulation resolution.
Definition nstime.h:95
@ US
microsecond
Definition nstime.h:108
@ MS
millisecond
Definition nstime.h:107
@ S
second
Definition nstime.h:106
@ NS
nanosecond
Definition nstime.h:109
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition time.cc:422
bool IsStrictlyPositive() const
Exactly equivalent to t > 0.
Definition nstime.h:341
bool IsZero() const
Exactly equivalent to t == 0.
Definition nstime.h:305
represent a single transmission mode
Definition wifi-mode.h:39
uint64_t GetDataRate(MHz_u channelWidth, Time guardInterval, uint8_t nss) const
Definition wifi-mode.cc:110
static Time GetPayloadDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, MpduType mpdutype=NORMAL_MPDU, uint16_t staId=SU_STA_ID)
Definition wifi-phy.cc:1527
static Time GetPreambleDetectionDuration()
Definition wifi-phy.cc:1515
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
Definition wifi-phy.cc:1574
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
WifiPreamble GetPreambleType() const
MHz_u GetChannelWidth() const
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
#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.
Definition abort.h:38
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition abort.h:99
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:201
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:267
#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.
Definition log.h:274
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:492
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1364
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1313
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.
Definition wifi-types.h:54
@ PREAMBLE_DETECT_FAILURE
@ FRAME_CAPTURE_PACKET_SWITCH
@ CHANNEL_SWITCHING
@ BUSY_DECODING_PREAMBLE
@ PPDU_TOO_LATE
@ PREAMBLE_DETECTION_PACKET_SWITCH
@ WIFI_CHANLIST_PRIMARY
@ 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.
Definition wifi-types.h:66
@ NORMAL_MPDU
The MPDU is not part of an A-MPDU.
Definition wifi-types.h:56
@ FIRST_MPDU_IN_AGGREGATE
The MPDU is the first aggregate in an A-MPDU with multiple MPDUs, but is not the last aggregate.
Definition wifi-types.h:61
@ SINGLE_MPDU
The MPDU is a single MPDU.
Definition wifi-types.h:58
@ MIDDLE_MPDU_IN_AGGREGATE
The MPDU is part of an A-MPDU with multiple MPDUs, but is neither the first nor the last aggregate.
Definition wifi-types.h:64
Every class exported by the ns3 library is enclosed in the ns3 namespace.
dBm_u WToDbm(Watt_u val)
Convert from Watts to dBm.
Definition wifi-utils.cc:38
@ SWITCHING
The PHY layer is switching to other channel.
@ TX
The PHY layer is sending a packet.
@ OFF
The PHY layer is switched off.
@ IDLE
The PHY layer is IDLE.
@ CCA_BUSY
The PHY layer has sense the medium busy through the CCA mechanism.
@ SLEEP
The PHY layer is sleeping.
@ RX
The PHY layer is receiving a packet.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition angles.cc:148
double Integral(const SpectrumValue &arg)
std::map< WifiPpduField, PhyHeaderChunkInfo > PhyHeaderSections
A map of PhyHeaderChunkInfo elements per PPDU field.
double MHz_u
MHz weak type.
Definition wifi-units.h:31
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:643
double dBm_u
dBm weak type
Definition wifi-units.h:27
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
Definition wifi-ppdu.h:39
double DbToRatio(dB_u val)
Convert from dB to ratio.
Definition wifi-utils.cc:26
static constexpr uint16_t SU_STA_ID
STA_ID to identify a single user (SU).
double Watt_u
Watt weak type.
Definition wifi-units.h:25
double dB_u
dB weak type
Definition wifi-units.h:28
dB_u RatioToDb(double ratio)
Convert from ratio to dB.
Definition wifi-utils.cc:45
Watt_u DbmToW(dBm_u val)
Convert from dBm to Watts.
Definition wifi-utils.cc:32
Declaration of:
Status of the reception of the PPDU field.
Definition phy-entity.h:78
WifiPhyRxfailureReason reason
failure reason
Definition phy-entity.h:80
PhyRxFailureAction actionIfFailure
action to perform in case of failure
Definition phy-entity.h:81
bool isSuccess
outcome (true if success) of the reception
Definition phy-entity.h:79
RxSignalInfo structure containing info on the received signal.
Definition wifi-types.h:85
double snr
SNR in linear scale.
Definition wifi-types.h:86
dBm_u rssi
RSSI.
Definition wifi-types.h:87
SignalNoiseDbm structure.
Definition wifi-types.h:71
dBm_u noise
noise power
Definition wifi-types.h:73
dBm_u signal
signal strength
Definition wifi-types.h:72
A struct for both SNR and PER.
double snr
SNR in linear scale.
WifiSpectrumBandInfo structure containing info about a spectrum band.