A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
phy-entity.h
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#ifndef PHY_ENTITY_H
13#define PHY_ENTITY_H
14
15#include "wifi-phy-band.h"
16#include "wifi-phy-common.h"
18#include "wifi-phy.h"
19#include "wifi-ppdu.h"
20#include "wifi-tx-vector.h"
21#include "wifi-types.h"
22
23#include "ns3/event-id.h"
24#include "ns3/nstime.h"
25#include "ns3/simple-ref-count.h"
26#include "ns3/wifi-export.h"
27
28#include <list>
29#include <map>
30#include <optional>
31#include <tuple>
32#include <utility>
33
34/**
35 * @file
36 * @ingroup wifi
37 * Declaration of:
38 * - ns3::PhyEntity class
39 * - ns3::RxPowerWattPerChannelBand typedef
40 */
41
42namespace ns3
43{
44
45class WifiMpdu;
46class WifiPhy;
48class Event;
50class WifiPsdu;
51class WifiPpdu;
52
53/**
54 * @brief Abstract class for PHY entities
55 * @ingroup wifi
56 *
57 * This class enables to have a unique set of APIs
58 * to be used by each PHY entity, corresponding to
59 * the different amendments of the IEEE 802.11 standard.
60 */
61class WIFI_EXPORT PhyEntity
62{
63 public:
64 /**
65 * Action to perform in case of RX failure.
66 */
68 {
69 DROP = 0, //!< drop PPDU and set CCA_BUSY
70 ABORT, //!< abort reception of PPDU
71 IGNORE //!< ignore the reception
72 };
73
74 /**
75 * Status of the reception of the PPDU field.
76 */
78 {
79 bool isSuccess{true}; //!< outcome (\c true if success) of the reception
82 DROP}; //!< action to perform in case of failure \see PhyRxFailureAction
83
84 /**
85 * Constructor setting outcome of reception.
86 *
87 * @param s \c true if success
88 */
90 : isSuccess(s)
91 {
92 }
93
94 /**
95 * Constructor.
96 *
97 * @param s \c true if success
98 * @param r reason of failure
99 * @param a action to perform in case of failure
100 */
107 };
108
109 /**
110 * Destructor for PHY entity
111 */
112 virtual ~PhyEntity();
113
114 /**
115 * Set the WifiPhy owning this PHY entity.
116 *
117 * @param wifiPhy the WifiPhy owning this PHY entity
118 */
119 void SetOwner(Ptr<WifiPhy> wifiPhy);
120
121 /**
122 * Check if the WifiMode is supported.
123 *
124 * @param mode the WifiMode to check
125 * @return true if the WifiMode is supported,
126 * false otherwise
127 */
128 virtual bool IsModeSupported(WifiMode mode) const;
129 /**
130 * @return the number of WifiModes supported by this entity
131 */
132 virtual uint8_t GetNumModes() const;
133
134 /**
135 * Get the WifiMode corresponding to the given MCS index.
136 *
137 * @param index the index of the MCS
138 * @return the WifiMode corresponding to the MCS index
139 *
140 * This method should be used only for HtPhy and child classes.
141 */
142 virtual WifiMode GetMcs(uint8_t index) const;
143 /**
144 * Check if the WifiMode corresponding to the given MCS index is supported.
145 *
146 * @param index the index of the MCS
147 * @return true if the WifiMode corresponding to the MCS index is supported,
148 * false otherwise
149 *
150 * Will return false for non-MCS modes.
151 */
152 virtual bool IsMcsSupported(uint8_t index) const;
153 /**
154 * Check if the WifiModes handled by this PHY are MCSs.
155 *
156 * @return true if the handled WifiModes are MCSs,
157 * false if they are non-MCS modes
158 */
159 virtual bool HandlesMcsModes() const;
160
161 /**
162 * Get the WifiMode for the SIG field specified by the PPDU field.
163 *
164 * @param field the PPDU field
165 * @param txVector the transmission parameters
166 *
167 * @return the WifiMode used for the SIG field
168 */
169 virtual WifiMode GetSigMode(WifiPpduField field, const WifiTxVector& txVector) const;
170
171 /**
172 * @brief Return a const iterator to the first WifiMode
173 *
174 * @return a const iterator to the first WifiMode.
175 */
176 std::list<WifiMode>::const_iterator begin() const;
177 /**
178 * @brief Return a const iterator to past-the-last WifiMode
179 *
180 * @return a const iterator to past-the-last WifiMode.
181 */
182 std::list<WifiMode>::const_iterator end() const;
183
184 /**
185 * Return the field following the provided one.
186 *
187 * @param currentField the considered PPDU field
188 * @param preamble the preamble indicating the PPDU format
189 * @return the PPDU field following the reference one
190 */
191 WifiPpduField GetNextField(WifiPpduField currentField, WifiPreamble preamble) const;
192
193 /**
194 * Get the duration of the PPDU field (or group of fields)
195 * used by this entity for the given transmission parameters.
196 *
197 * @param field the PPDU field (or group of fields)
198 * @param txVector the transmission parameters
199 *
200 * @return the duration of the PPDU field
201 */
202 virtual Time GetDuration(WifiPpduField field, const WifiTxVector& txVector) const;
203 /**
204 * @param txVector the transmission parameters
205 *
206 * @return the total duration of the PHY preamble and PHY header.
207 */
208 Time CalculatePhyPreambleAndHeaderDuration(const WifiTxVector& txVector) const;
209
210 /**
211 * @param size the number of bytes in the packet to send
212 * @param txVector the TXVECTOR used for the transmission of this packet
213 * @param band the frequency band
214 * @param mpdutype the type of the MPDU as defined in WifiPhy::MpduType.
215 * @param incFlag this flag is used to indicate that the variables need to be update or not
216 * This function is called a couple of times for the same packet so variables should not be
217 * increased each time.
218 * @param totalAmpduSize the total size of the previously transmitted MPDUs for the concerned
219 * A-MPDU. If incFlag is set, this parameter will be updated.
220 * @param totalAmpduNumSymbols the number of symbols previously transmitted for the MPDUs in the
221 * concerned A-MPDU, used for the computation of the number of symbols needed for the last MPDU.
222 * If incFlag is set, this parameter will be updated.
223 * @param staId the STA-ID of the PSDU (only used for MU PPDUs)
224 *
225 * @return the duration of the PSDU
226 */
228 const WifiTxVector& txVector,
229 WifiPhyBand band,
230 MpduType mpdutype,
231 bool incFlag,
232 uint32_t& totalAmpduSize,
233 double& totalAmpduNumSymbols,
234 uint16_t staId) const = 0;
235
236 /**
237 * Get a WifiConstPsduMap from a PSDU and the TXVECTOR to use to send the PSDU.
238 * The STA-ID value is properly determined based on whether the given PSDU has
239 * to be transmitted as a DL or UL frame.
240 *
241 * @param psdu the given PSDU
242 * @param txVector the TXVECTOR to use to send the PSDU
243 * @return a WifiConstPsduMap built from the given PSDU and the given TXVECTOR
244 */
246 const WifiTxVector& txVector) const;
247
248 /**
249 * Get the maximum PSDU size in bytes.
250 *
251 * @return the maximum PSDU size in bytes
252 */
253 virtual uint32_t GetMaxPsduSize() const = 0;
254
255 /**
256 * Return a map of PHY header chunk information per PPDU field.
257 * This map will contain the PPDU fields that are actually present based
258 * on the \p txVector information.
259 *
260 * @param txVector the transmission parameters
261 * @param ppduStart the time at which the PPDU started
262 * @return the list of preamble sections
263 *
264 * @see PhyHeaderSections
265 */
266 PhyHeaderSections GetPhyHeaderSections(const WifiTxVector& txVector, Time ppduStart) const;
267
268 /**
269 * Build amendment-specific PPDU.
270 *
271 * @param psdus the PHY payloads (PSDUs)
272 * @param txVector the TXVECTOR that was used for the PPDU
273 * @param ppduDuration the transmission duration of the PPDU
274 *
275 * @return the amendment-specific WifiPpdu
276 */
277 virtual Ptr<WifiPpdu> BuildPpdu(const WifiConstPsduMap& psdus,
278 const WifiTxVector& txVector,
279 Time ppduDuration);
280
281 /**
282 * Get the duration of the PPDU up to (but excluding) the given field.
283 *
284 * @param field the considered PPDU field
285 * @param txVector the transmission parameters
286 * @return the duration from the beginning of the PPDU up to the field
287 */
288 Time GetDurationUpToField(WifiPpduField field, const WifiTxVector& txVector) const;
289 /**
290 * Get the remaining duration of the PPDU after the end of the given field.
291 *
292 * @param field the considered PPDU field
293 * @param ppdu the received PPDU
294 * @return the remaining duration of the PPDU after the end of to the field
295 */
297
298 /**
299 * Get the PSDU addressed to that PHY in a PPDU (useful for MU PPDU).
300 *
301 * @param ppdu the PPDU to extract the PSDU from
302 * @return the PSDU addressed to that PHY
303 */
305
306 /**
307 * Start receiving the PHY preamble of a PPDU (i.e. the first bit of the preamble has arrived).
308 *
309 * This method triggers the start of the preamble detection period (\see
310 * StartPreambleDetectionPeriod) if the PHY can process the PPDU.
311 *
312 * @param ppdu the arriving PPDU
313 * @param rxPowersW the receive power in W per band
314 * @param rxDuration the duration of the PPDU
315 */
317 RxPowerWattPerChannelBand& rxPowersW,
318 Time rxDuration);
319 /**
320 * Start receiving a given field.
321 *
322 * This method will call the DoStartReceiveField.
323 * EndReceiveField is also scheduled after the duration of the field
324 * (except for the special case of preambles \see DoStartReceivePreamble).
325 * The PHY is kept in CCA busy during the reception of the field (except for
326 * data field which should be in RX).
327 *
328 * @param field the starting PPDU field
329 * @param event the event holding incoming PPDU's information
330 */
331 void StartReceiveField(WifiPpduField field, Ptr<Event> event);
332 /**
333 * End receiving a given field.
334 *
335 * This method will call the DoEndReceiveField to obtain the outcome of the reception.
336 * In case of success, reception of the next field is triggered.
337 * In case of failure, the indications in the returned \see PhyFieldRxStatus
338 * are performed.
339 *
340 * @param field the ending PPDU field
341 * @param event the event holding incoming PPDU's information
342 */
343 void EndReceiveField(WifiPpduField field, Ptr<Event> event);
344
345 /**
346 * The last symbol of the PPDU has arrived.
347 *
348 * @param event the event holding incoming PPDU's information
349 */
350 void EndReceivePayload(Ptr<Event> event);
351
352 /**
353 * Reset PHY at the end of the PPDU under reception after it has failed the PHY header.
354 *
355 * @param event the event holding incoming PPDU's information
356 */
357 void ResetReceive(Ptr<Event> event);
358
359 /**
360 * Cancel and clear all running events.
361 */
362 virtual void CancelAllEvents();
363 /**
364 * Cancel all end preamble detection events.
365 */
367
368 /// @copydoc WifiPhy::GetTimeToPreambleDetectionEnd
369 virtual std::optional<Time> GetTimeToPreambleDetectionEnd() const;
370
371 /// @copydoc WifiPhy::GetTimeToMacHdrEnd
372 virtual std::optional<Time> GetTimeToMacHdrEnd(uint16_t staId) const;
373
374 /**
375 * Return the STA ID that has been assigned to the station this PHY belongs to.
376 * This is typically called for MU PPDUs, in order to pick the correct PSDU.
377 *
378 * @param ppdu the PPDU for which the STA ID is requested
379 * @return the STA ID
380 */
381 virtual uint16_t GetStaId(const Ptr<const WifiPpdu> ppdu) const;
382
383 /**
384 * Determine whether the PHY shall issue a PHY-RXSTART.indication primitive in response to a
385 * given PPDU.
386 *
387 * @param ppdu the PPDU
388 * @return true if the PHY shall issue a PHY-RXSTART.indication primitive in response to a PPDU,
389 * false otherwise
390 */
391 virtual bool CanStartRx(Ptr<const WifiPpdu> ppdu) const;
392
393 /**
394 * Check if PHY state should move to CCA busy state based on current
395 * state of interference tracker.
396 *
397 * @param ppdu the incoming PPDU or nullptr for any signal
398 */
399 virtual void SwitchMaybeToCcaBusy(const Ptr<const WifiPpdu> ppdu = nullptr);
400
401 /**
402 * Notify PHY state helper to switch to CCA busy state,
403 *
404 * @param ppdu the incoming PPDU or nullptr for any signal
405 * @param duration the duration of the CCA state
406 * @param channelType the channel type for which the CCA busy state is reported.
407 */
408 virtual void NotifyCcaBusy(const Ptr<const WifiPpdu> ppdu,
409 Time duration,
410 WifiChannelListType channelType);
411 /**
412 * This function is called by SpectrumWifiPhy to send
413 * the PPDU while performing amendment-specific actions.
414 * @see SpectrumWifiPhy::StartTx
415 *
416 * @param ppdu the PPDU to send
417 */
418 virtual void StartTx(Ptr<const WifiPpdu> ppdu);
419
420 /**
421 * This function prepares most of the WifiSpectrumSignalParameters
422 * parameters and invokes SpectrumWifiPhy's Transmit method.
423 * @see SpectrumWifiPhy::Transmit
424 *
425 * @param txDuration the duration of the transmission
426 * @param ppdu the PPDU to send
427 * @param txPower the total TX power
428 * @param txPowerSpectrum the TX PSD
429 * @param type the type of transmission (for logging)
430 */
431 void Transmit(Time txDuration,
433 dBm_u txPower,
434 Ptr<SpectrumValue> txPowerSpectrum,
435 const std::string& type);
436
437 /**
438 * @param psduMap the PSDU(s) to transmit indexed by STA-ID
439 * @param txVector the TXVECTOR used for the transmission of the PPDU
440 * @param band the frequency band being used
441 *
442 * @return the total amount of time this PHY will stay busy for the transmission of the PPDU
443 */
444 virtual Time CalculateTxDuration(const WifiConstPsduMap& psduMap,
445 const WifiTxVector& txVector,
446 WifiPhyBand band) const;
447 /**
448 * Return the CCA threshold for a given channel type.
449 * If the channel type is not provided, the default CCA threshold is returned.
450 *
451 * @param ppdu the PPDU that is being received
452 * @param channelType the channel type
453 * @return the CCA threshold
454 */
455 virtual dBm_u GetCcaThreshold(const Ptr<const WifiPpdu> ppdu,
456 WifiChannelListType channelType) const;
457
458 /**
459 * The WifiPpdu from the TX PHY is received by each RX PHY attached to the same channel.
460 * By default and for performance reasons, all RX PHYs will work on the same WifiPpdu instance
461 * from TX instead of a copy of it. Child classes can change that behavior and do a copy and/or
462 * change the content of the parameters stored in WifiPpdu.
463 *
464 * @param ppdu the WifiPpdu transmitted by the TX PHY
465 * @return the WifiPpdu to be used by the RX PHY
466 */
468
469 /**
470 * Obtain the next UID for the PPDU to transmit.
471 * Note that the global UID counter could be incremented.
472 *
473 * @param txVector the transmission parameters
474 * @return the UID to use for the PPDU to transmit
475 */
476 virtual uint64_t ObtainNextUid(const WifiTxVector& txVector);
477
478 /**
479 * Obtain the maximum time between two PPDUs with the same UID to consider they are identical
480 * and their power can be added construtively.
481 *
482 * @param txVector the TXVECTOR used for the transmission of the PPDUs
483 * @return the maximum time between two PPDUs with the same UID to decode them
484 */
485 virtual Time GetMaxDelayPpduSameUid(const WifiTxVector& txVector);
486
487 protected:
488 /**
489 * A map of PPDU field elements per preamble type.
490 * This corresponds to the different PPDU formats introduced by each amendment.
491 */
492 typedef std::map<WifiPreamble, std::vector<WifiPpduField>> PpduFormats;
493
494 /**
495 * A pair to hold modulation information: code rate and constellation size.
496 */
497 typedef std::pair<WifiCodeRate, uint16_t> CodeRateConstellationSizePair;
498
499 /**
500 * A modulation lookup table using unique name of modulation as key.
501 */
502 typedef std::map<std::string, CodeRateConstellationSizePair> ModulationLookupTable;
503
504 /**
505 * Return the PPDU formats of the PHY.
506 *
507 * @return the PPDU formats of the PHY
508 */
509 virtual const PpduFormats& GetPpduFormats() const = 0;
510
511 /**
512 * Start receiving a given field, perform amendment-specific actions, and
513 * signify if it is supported.
514 *
515 * @param field the starting PPDU field
516 * @param event the event holding incoming PPDU's information
517 * @return \c true if the field is supported, \c false otherwise
518 */
519 virtual bool DoStartReceiveField(WifiPpduField field, Ptr<Event> event);
520 /**
521 * End receiving a given field, perform amendment-specific actions, and
522 * provide the status of the reception.
523 *
524 * @param field the ending PPDU field
525 * @param event the event holding incoming PPDU's information
526 * @return status of the reception of the PPDU field
527 */
529
530 /**
531 * Get the event corresponding to the incoming PPDU.
532 *
533 * We store all incoming preamble events, perform amendment-specific actions,
534 * and a decision is made at the end of the preamble detection window.
535 *
536 * @param ppdu the incoming PPDU
537 * @param rxPowersW the receive power in W per band
538 * @return the event holding the incoming PPDU's information
539 */
541 /**
542 * End receiving the preamble, perform amendment-specific actions, and
543 * provide the status of the reception.
544 *
545 * @param event the event holding incoming PPDU's information
546 * @return status of the reception of the preamble
547 */
549 /**
550 * Start the preamble detection period.
551 *
552 * @param event the event holding incoming PPDU's information
553 */
555 /**
556 * End the preamble detection period.
557 *
558 * The PHY will focus on the strongest PPDU and drop others.
559 * In addition, in case of successful detection, the end of the
560 * preamble reception is triggered (\see DoEndReceivePreamble).
561 *
562 * @param event the event holding incoming PPDU's information
563 */
565
566 /**
567 * Start receiving the PSDU (i.e. the first symbol of the PSDU has arrived).
568 *
569 * @param event the event holding incoming PPDU's information
570 */
572
573 /**
574 * Start receiving the PSDU (i.e. the first symbol of the PSDU has arrived)
575 * and perform amendment-specific actions.
576 *
577 * @param event the event holding incoming PPDU's information
578 * @return the payload duration
579 */
581
582 /**
583 * Perform amendment-specific actions before resetting PHY at
584 * the end of the PPDU under reception after it has failed the PHY header.
585 *
586 * @param event the event holding incoming PPDU's information
587 */
588 virtual void DoResetReceive(Ptr<Event> event);
589
590 /**
591 * Perform amendment-specific actions before aborting the
592 * current reception.
593 *
594 * @param reason the reason the reception is aborted
595 */
597
598 /**
599 * Checks if the signaled configuration (excluding bandwidth)
600 * is supported by the PHY.
601 *
602 * @param ppdu the received PPDU
603 * @return \c true if supported, \c false otherwise
604 */
605 virtual bool IsConfigSupported(Ptr<const WifiPpdu> ppdu) const;
606
607 /**
608 * Drop the PPDU and the corresponding preamble detection event, but keep CCA busy
609 * state after the completion of the currently processed event.
610 *
611 * @param ppdu the incoming PPDU
612 * @param reason the reason the PPDU is dropped
613 * @param endRx the end of the incoming PPDU's reception
614 */
616
617 /**
618 * Erase the event corresponding to the PPDU from the list of preamble events,
619 * but consider it as noise after the completion of the current event.
620 *
621 * @param ppdu the incoming PPDU
622 * @param rxDuration the duration of the PPDU
623 */
624 void ErasePreambleEvent(Ptr<const WifiPpdu> ppdu, Time rxDuration);
625
626 /**
627 * Get the reception status for the provided MPDU and notify.
628 *
629 * @param mpdu the arriving MPDU
630 * @param event the event holding incoming PPDU's information
631 * @param staId the station ID of the PSDU (only used for MU)
632 * @param relativeMpduStart the relative start time of the MPDU within the A-MPDU.
633 * 0 for normal MPDUs
634 * @param mpduDuration the duration of the MPDU
635 *
636 * @return information on MPDU reception: status, signal power (dBm), and noise power (in dBm)
637 */
638 std::pair<bool, SignalNoiseDbm> GetReceptionStatus(Ptr<WifiMpdu> mpdu,
639 Ptr<Event> event,
640 uint16_t staId,
641 Time relativeMpduStart,
642 Time mpduDuration);
643 /**
644 * The last symbol of an MPDU in an A-MPDU has arrived.
645 *
646 * @param event the event holding incoming PPDU's information
647 * @param mpdu the arriving MPDU
648 * @param mpduIndex the index of the MPDU within the A-MPDU
649 * @param relativeStart the relative start time of the MPDU within the A-MPDU.
650 * @param mpduDuration the duration of the MPDU
651 */
652 void EndOfMpdu(Ptr<Event> event,
653 Ptr<WifiMpdu> mpdu,
654 size_t mpduIndex,
655 Time relativeStart,
656 Time mpduDuration);
657
658 /**
659 * Schedule end of MPDUs events.
660 *
661 * @param event the event holding incoming PPDU's information
662 */
663 void ScheduleEndOfMpdus(Ptr<Event> event);
664
665 /**
666 * Perform amendment-specific actions when the payload is successfully received.
667 *
668 * @param psdu the successfully received PSDU
669 * @param rxSignalInfo the info on the received signal (\see RxSignalInfo)
670 * @param txVector TXVECTOR of the PSDU
671 * @param staId the station ID of the PSDU (only used for MU)
672 * @param statusPerMpdu reception status per MPDU
673 */
674 virtual void RxPayloadSucceeded(Ptr<const WifiPsdu> psdu,
675 RxSignalInfo rxSignalInfo,
676 const WifiTxVector& txVector,
677 uint16_t staId,
678 const std::vector<bool>& statusPerMpdu);
679 /**
680 * Perform amendment-specific actions when the payload is unsuccessfully received.
681 *
682 * @param psdu the PSDU that we failed to received
683 * @param snr the SNR of the received PSDU in linear scale
684 * @param txVector TXVECTOR of the PSDU
685 */
686 virtual void RxPayloadFailed(Ptr<const WifiPsdu> psdu,
687 double snr,
688 const WifiTxVector& txVector);
689
690 /**
691 * Perform amendment-specific actions at the end of the reception of
692 * the payload.
693 *
694 * @param ppdu the incoming PPDU
695 */
696 virtual void DoEndReceivePayload(Ptr<const WifiPpdu> ppdu);
697
698 /**
699 * Get the channel width and band to use (will be overloaded by child classes).
700 *
701 * @param txVector the transmission parameters
702 * @param staId the station ID of the PSDU
703 * @return a pair of channel width and band
704 */
705 virtual std::pair<MHz_u, WifiSpectrumBandInfo> GetChannelWidthAndBand(
706 const WifiTxVector& txVector,
707 uint16_t staId) const;
708
709 /**
710 * Abort the current reception.
711 *
712 * @param reason the reason the reception is aborted
713 */
715
716 /**
717 * Obtain a random value from the WifiPhy's generator.
718 * Wrapper used by child classes.
719 *
720 * @return a uniform random value
721 */
722 double GetRandomValue() const;
723 /**
724 * Obtain the SNR and PER of the PPDU field from the WifiPhy's InterferenceHelper class.
725 * Wrapper used by child classes.
726 *
727 * @param field the PPDU field
728 * @param event the event holding incoming PPDU's information
729 * @return the SNR and PER
730 */
732 /**
733 * Obtain the received power for a given band.
734 * Wrapper used by child classes.
735 *
736 * @param event the event holding incoming PPDU's information
737 * @return the received power for the event over a given band
738 */
740 /**
741 * Get the pointer to the current event (stored in WifiPhy).
742 * Wrapper used by child classes.
743 *
744 * @return the pointer to the current event
745 */
747 /**
748 * Get the map of current preamble events (stored in WifiPhy).
749 * Wrapper used by child classes.
750 *
751 * @return the reference to the map of current preamble events
752 */
753 const std::map<std::pair<uint64_t, WifiPreamble>, Ptr<Event>>& GetCurrentPreambleEvents() const;
754 /**
755 * Add an entry to the map of current preamble events (stored in WifiPhy).
756 * Wrapper used by child classes.
757 *
758 * @param event the event holding incoming PPDU's information
759 */
760 void AddPreambleEvent(Ptr<Event> event);
761
762 /**
763 * Create an event using WifiPhy's InterferenceHelper class.
764 * Wrapper used by child classes.
765 *
766 * @param ppdu the PPDU
767 * @param duration the PPDU duration
768 * @param rxPower received power per band (W)
769 * @param isStartHePortionRxing flag whether the event corresponds to the start of the OFDMA
770 * payload reception (only used for UL-OFDMA)
771 * @return the created event
772 */
774 Time duration,
776 bool isStartHePortionRxing = false);
777 /**
778 * Handle reception of a PPDU that carries the same content of another PPDU.
779 * This is typically called upon reception of preambles of HE MU PPDUs or reception
780 * of non-HT duplicate control frames that carries the exact same content sent from different
781 * STAs. If the delay between the PPDU and the first PPDU carrying the same content is small
782 * enough, PPDU can be decoded and its power is added constructively, and the TXVECTOR is
783 * updated accordingly. Otherwise, a new interference event is created and PPDU is dropped by
784 * the PHY.
785 *
786 * @param event the event of the ongoing reception
787 * @param ppdu the newly received PPDU (UL MU or non-HT duplicate)
788 * @param rxPower the received power (W) per band of the newly received PPDU
789 */
790 virtual void HandleRxPpduWithSameContent(Ptr<Event> event,
793
794 /**
795 * Notify WifiPhy's InterferenceHelper of the end of the reception,
796 * clear maps and end of MPDU event, and eventually reset WifiPhy.
797 *
798 * @param reset whether to reset WifiPhy
799 */
800 void NotifyInterferenceRxEndAndClear(bool reset);
801
802 /**
803 * @param txPower power to spread across the bands
804 * @param ppdu the PPDU that will be transmitted
805 * @return Pointer to SpectrumValue
806 *
807 * This is a helper function to create the right TX PSD corresponding
808 * to the amendment of this PHY.
809 */
811 Ptr<const WifiPpdu> ppdu) const = 0;
812
813 /**
814 * Fire the trace indicating that the PHY is starting to receive the payload of a PPDU.
815 *
816 * @param txVector the TXVECTOR used to transmit the PPDU
817 * @param payloadDuration the TX duration of the PPDU payload
818 */
819 void NotifyPayloadBegin(const WifiTxVector& txVector, const Time& payloadDuration);
820
821 /**
822 * If the operating channel width is a multiple of 20 MHz, return the info
823 * corresponding to the primary channel of the given
824 * bandwidth (which must be a multiple of 20 MHz and not exceed the operating
825 * channel width). Otherwise, this call is equivalent to GetBand with
826 * <i>bandIndex</i> equal to zero.
827 *
828 * @param bandWidth the width of the band to be returned
829 *
830 * @return the info corresponding to the band
831 */
833 /**
834 * If the channel bonding is used, return the info corresponding to
835 * the secondary channel of the given bandwidth (which must be a multiple of 20 MHz
836 * and not exceed the operating channel width).
837 *
838 * @param bandWidth the width of the band to be returned
839 *
840 * @return the info corresponding to the band
841 */
843
844 /**
845 * Return the channel width used to measure the RSSI.
846 *
847 * @param ppdu the PPDU that is being received
848 * @return the channel width used for RSSI measurement
849 */
851
852 /**
853 * Return the channel width used in the reception spectrum model.
854 *
855 * @param txVector the TXVECTOR of the PPDU that is being received
856 * @return the channel width used for RxSpectrumModel
857 */
858 virtual MHz_u GetRxChannelWidth(const WifiTxVector& txVector) const;
859
860 /**
861 * Return the delay until CCA busy is ended for a given sensitivity threshold and a given band.
862 *
863 * @param threshold the CCA sensitivity threshold
864 * @param band identify the requested band
865 * @return the delay until CCA busy is ended
866 */
867 Time GetDelayUntilCcaEnd(dBm_u threshold, const WifiSpectrumBandInfo& band);
868
869 /**
870 * @param currentChannelWidth channel width of the current transmission
871 * @return the width of the guard band
872 *
873 * Wrapper method used by child classes for PSD generation.
874 * Note that this method is necessary for testing UL OFDMA.
875 */
876 MHz_u GetGuardBandwidth(MHz_u currentChannelWidth) const;
877 /**
878 * @return a tuple containing the minimum rejection for the inner band,
879 * the minimum rejection for the outer band, and
880 * the maximum rejection for the outer band
881 * for the transmit spectrum mask.
882 *
883 * Wrapper method used by child classes for PSD generation.
884 */
885 std::tuple<dBr_u, dBr_u, dBr_u> GetTxMaskRejectionParams() const;
886
888 std::optional<std::pair<Time, WifiChannelListType>>; //!< CCA end time and its corresponding
889 //!< channel list type (can be
890 //!< std::nullopt if IDLE)
891
892 /**
893 * Get CCA end time and its corresponding channel list type when a new signal has been received
894 * by the PHY.
895 *
896 * @param ppdu the incoming PPDU or nullptr for any signal
897 * @return CCA end time and its corresponding channel list type when a new signal has been
898 * received by the PHY, or std::nullopt if all channel list types are IDLE.
899 */
901
902 Ptr<WifiPhy> m_wifiPhy; //!< Pointer to the owning WifiPhy
903 Ptr<WifiPhyStateHelper> m_state; //!< Pointer to WifiPhyStateHelper of the WifiPhy (to make it
904 //!< reachable for child classes)
905
906 std::list<WifiMode> m_modeList; //!< the list of supported modes
907
908 std::vector<EventId> m_endPreambleDetectionEvents; //!< the end of preamble detection events
909 std::vector<EventId> m_endOfMpduEvents; //!< the end of MPDU events (only used for A-MPDUs)
910 std::map<uint16_t, std::vector<EventId>>
911 m_endOfMacHdrEvents; //!< STA_ID-indexed map of the RX end of MAC header events
912
913 std::vector<EventId>
914 m_endRxPayloadEvents; //!< the end of receive events (only one unless UL MU reception)
915
916 /**
917 * A pair of a UID and STA_ID
918 */
919 typedef std::pair<uint64_t /* UID */, uint16_t /* STA-ID */> UidStaIdPair;
920
921 std::map<UidStaIdPair, std::vector<bool>>
922 m_statusPerMpduMap; //!< Map of the current reception status per MPDU that is filled in as
923 //!< long as MPDUs are being processed by the PHY in case of an A-MPDU
924 std::map<UidStaIdPair, SignalNoiseDbm>
925 m_signalNoiseMap; //!< Map of the latest signal power and noise power in dBm (noise power
926 //!< includes the noise figure)
927
928 static uint64_t m_globalPpduUid; //!< Global counter of the PPDU UID
929};
930
931/**
932 * @brief Stream insertion operator.
933 *
934 * @param os the stream
935 * @param action the action to perform in case of failure
936 * @returns a reference to the stream
937 */
938std::ostream& operator<<(std::ostream& os, const PhyEntity::PhyRxFailureAction& action);
939/**
940 * @brief Stream insertion operator.
941 *
942 * @param os the stream
943 * @param status the status of the reception of a PPDU field
944 * @returns a reference to the stream
945 */
946std::ostream& operator<<(std::ostream& os, const PhyEntity::PhyFieldRxStatus& status);
947
948} // namespace ns3
949
950#endif /* PHY_ENTITY_H */
uint32_t r
handles interference calculations
handles interference calculations
Abstract class for PHY entities.
Definition phy-entity.h:62
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...
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 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.
virtual std::optional< Time > GetTimeToPreambleDetectionEnd() const
Get the remaining time to preamble detection period to elapse, if preamble detection is ongoing.
virtual Time GetPayloadDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, MpduType mpdutype, bool incFlag, uint32_t &totalAmpduSize, double &totalAmpduNumSymbols, uint16_t staId) const =0
std::pair< WifiCodeRate, uint16_t > CodeRateConstellationSizePair
A pair to hold modulation information: code rate and constellation size.
Definition phy-entity.h:497
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::map< std::string, CodeRateConstellationSizePair > ModulationLookupTable
A modulation lookup table using unique name of modulation as key.
Definition phy-entity.h:502
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
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 const PpduFormats & GetPpduFormats() const =0
Return the PPDU formats of the PHY.
virtual bool DoStartReceiveField(WifiPpduField field, Ptr< Event > event)
Start receiving a given field, perform amendment-specific actions, and signify if it is supported.
virtual void CancelAllEvents()
Cancel and clear all running events.
virtual uint32_t GetMaxPsduSize() const =0
Get the maximum PSDU size in bytes.
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.
std::map< WifiPreamble, std::vector< WifiPpduField > > PpduFormats
A map of PPDU field elements per preamble type.
Definition phy-entity.h:492
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
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.
WifiSpectrumBandInfo GetPrimaryBand(MHz_u bandWidth) const
If the operating channel width is a multiple of 20 MHz, return the info corresponding to the primary ...
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.
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.
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 ...
std::pair< uint64_t, uint16_t > UidStaIdPair
A pair of a UID and STA_ID.
Definition phy-entity.h:919
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.
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
Simulation virtual time values and global simulation resolution.
Definition nstime.h:95
represent a single transmission mode
Definition wifi-mode.h:38
WifiMpdu stores a (const) packet along with a MAC header.
Definition wifi-mpdu.h:51
802.11 PHY layer model
Definition wifi-phy.h:66
This objects implements the PHY state machine of the Wifi device.
WifiPpdu stores a preamble, a modulation class, PHY headers and a PSDU.
Definition wifi-ppdu.h:47
WifiPsdu stores an MPDU, S-MPDU or A-MPDU, by keeping header(s) and payload(s) separate for each cons...
Definition wifi-psdu.h:33
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
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:53
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition angles.cc:148
std::map< WifiPpduField, PhyHeaderChunkInfo > PhyHeaderSections
A map of PhyHeaderChunkInfo elements per PPDU field.
double MHz_u
MHz weak type.
Definition wifi-units.h:31
std::map< WifiSpectrumBandInfo, Watt_u > RxPowerWattPerChannelBand
A map of the received power for each band.
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:38
double Watt_u
Watt weak type.
Definition wifi-units.h:25
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
PhyFieldRxStatus(bool s, WifiPhyRxfailureReason r, PhyRxFailureAction a)
Constructor.
Definition phy-entity.h:101
PhyFieldRxStatus(bool s)
Constructor setting outcome of reception.
Definition phy-entity.h:89
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:84
A struct for both SNR and PER.
WifiSpectrumBandInfo structure containing info about a spectrum band.
Declaration of the following enums:
Declaration of ns3::WifiPpdu class and ns3::WifiConstPsduMap.