A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lr-wpan-phy.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 The Boeing Company
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author:
18 * Gary Pei <guangyu.pei@boeing.com>
19 * Sascha Alexander Jopen <jopen@cs.uni-bonn.de>
20 */
21#ifndef LR_WPAN_PHY_H
22#define LR_WPAN_PHY_H
23
25
26#include <ns3/event-id.h>
27#include <ns3/spectrum-phy.h>
28#include <ns3/traced-callback.h>
29#include <ns3/traced-value.h>
30
31#include <iostream>
32
33namespace ns3
34{
35
36class Packet;
37class SpectrumValue;
38class MobilityModel;
39class SpectrumChannel;
40class SpectrumModel;
41class AntennaModel;
42class NetDevice;
43class UniformRandomVariable;
44class ErrorModel;
45
46namespace lrwpan
47{
48
50struct LrWpanSpectrumSignalParameters;
51
52/**
53 * \ingroup lr-wpan
54 *
55 * Helper structure to manage the power measurement during ED.
56 */
57struct EdPower
58{
59 double averagePower; //!< Average measured power
60 Time lastUpdate; //!< Last update time
61 Time measurementLength; //!< Total measurement period
62};
63
64/**
65 * \ingroup lr-wpan
66 *
67 * This data structure provides the Bit rate and Symbol rate for a given channel
68 * See IEEE802.15.4-2006 Table 1 and 2 in section 6.1.1 and 6.1.2
69 */
71{
72 double bitRate; //!< bit rate
73 double symbolRate; //!< symbol rate
74};
75
76/**
77 * \ingroup lr-wpan
78 *
79 * This data structure provides number of symbols for the PPDU headers: SHR and PHR
80 * See IEEE802.15.4-2006 Figure 16, Table 19 and 20 in section 6.3
81 */
83{
84 double shrPreamble; //!< Number of symbols for the SHR preamble
85 double shrSfd; //!< Number of symbols for the SHR SFD
86 double phr; //!< Number of symbols for the PHR
87};
88
89/**
90 * \ingroup lr-wpan
91 *
92 * This Phy option will be used to index various Tables in IEEE802.15.4-2011
93 */
95{
107
108/**
109 * \ingroup lr-wpan
110 *
111 * IEEE802.15.4-2006 PHY Emumerations Table 18
112 * in section 6.2.3
113 */
115{
128 IEEE_802_15_4_PHY_UNSPECIFIED = 0xc // all cases not covered by ieee802.15.4
130
131/**
132 * Overloaded operator to print the value of a PhyEnumeration.
133 *
134 * \param os The output stream
135 * \param state The text value of the PHY state
136 * \return The output stream with text value of the PHY state
137 */
138std::ostream& operator<<(std::ostream& os, const PhyEnumeration& state);
139
140/**
141 * Overloaded operator to print the value of a TracedValue<PhyEnumeration>.
142 *
143 * \param os The output stream
144 * \param state The text value of the PHY state
145 * \return The output stream with text value of the PHY state
146 */
147std::ostream& operator<<(std::ostream& os, const TracedValue<PhyEnumeration>& state);
148
149namespace TracedValueCallback
150{
151/**
152 * \ingroup lr-wpan
153 * TracedValue callback signature for PhyEnumeration.
154 *
155 * \param [in] oldValue original value of the traced variable
156 * \param [in] newValue new value of the traced variable
157 */
158typedef void (*PhyEnumeration)(PhyEnumeration oldValue, PhyEnumeration newValue);
159} // namespace TracedValueCallback
160
161/**
162 * \ingroup lr-wpan
163 *
164 * IEEE802.15.4-2006 PHY PIB Attribute Identifiers Table 23 in section 6.4.2
165 */
167{
175 phySymbolsPerOctet = 0x07
177
178/**
179 * \ingroup lr-wpan
180 *
181 * IEEE802.15.4-2006 PHY PIB Attributes Table 23 in section 6.4.2
182 */
183struct PhyPibAttributes : public SimpleRefCount<PhyPibAttributes>
184{
185 uint8_t phyCurrentChannel; //!< The RF channel to use
186 uint32_t phyChannelsSupported[32]; //!< BitField representing the available channels supported
187 //!< by a channel page.
188 uint8_t phyTransmitPower; //!< 2 MSB: tolerance on the transmit power, 6 LSB: Tx power in dBm
189 //!< relative to 1mW (signed int in 2-complement format)
190 uint8_t phyCCAMode; //!< CCA mode
191 uint8_t phyCurrentPage; //!< Current channel page
192 uint32_t phyMaxFrameDuration; //!< The maximum number of symbols in a frame
193 uint32_t phySHRDuration; //!< The duration of the synchronization header (SHR) in symbols
194 double phySymbolsPerOctet; //!< The number of symbols per octet
195};
196
197/**
198 * \ingroup lr-wpan
199 *
200 * This method implements the PD SAP: PdDataIndication
201 *
202 * \param psduLength number of bytes in the PSDU
203 * \param p the packet to be transmitted
204 * \param lqi Link quality (LQI) value measured during reception of the PPDU
205 */
207
208/**
209 * \ingroup lr-wpan
210 *
211 * This method implements the PD SAP: PdDataConfirm
212 *
213 * @param status the status to be transmitted
214 */
216
217/**
218 * \ingroup lr-wpan
219 *
220 * This method implements the PD SAP: PlmeCcaConfirm
221 *
222 * @param status the status of CCA
223 */
225
226/**
227 * \ingroup lr-wpan
228 *
229 * This method implements the PD SAP: PlmeEdConfirm
230 *
231 * @param status the status of ED
232 * @param energyLevel the energy level of ED
233 */
235
236/**
237 * \ingroup lr-wpan
238 *
239 * This method implements the PD SAP: PlmeGetAttributeConfirm
240 *
241 * @param status the status of PlmeGetAttributeRequest
242 * @param id the identifier of attribute
243 * @param attribute the pointer to attribute struct
244 */
247
248/**
249 * \ingroup lr-wpan
250 *
251 * This method implements the PD SAP: PlmeSetTRXStateConfirm
252 *
253 * @param status the status of PlmeSetTRXStateRequest
254 */
256
257/**
258 * \ingroup lr-wpan
259 *
260 * This method implements the PD SAP: PlmeSetAttributeConfirm
261 *
262 * @param status the status of PlmeSetAttributeRequest
263 * @param id the identifier of attribute
264 */
266
267/**
268 * \ingroup lr-wpan
269 *
270 * Make LrWpanPhy a SpectrumPhy so we can enable the eventual modeling of
271 * device interference
272 */
273class LrWpanPhy : public SpectrumPhy
274{
275 public:
276 /**
277 * Get the type ID.
278 *
279 * \return the object TypeId
280 */
281 static TypeId GetTypeId();
282
283 /**
284 * Default constructor.
285 */
286 LrWpanPhy();
287 ~LrWpanPhy() override;
288
289 // inherited from SpectrumPhy
290 void SetMobility(Ptr<MobilityModel> m) override;
291 Ptr<MobilityModel> GetMobility() const override;
292 void SetChannel(Ptr<SpectrumChannel> c) override;
293
294 /**
295 * Get the currently attached channel.
296 *
297 * \return the channel
298 */
300 void SetDevice(Ptr<NetDevice> d) override;
301 Ptr<NetDevice> GetDevice() const override;
302
303 /**
304 * Set the attached antenna.
305 *
306 * \param a the antenna
307 */
309 Ptr<Object> GetAntenna() const override;
311
312 /**
313 * Set the Power Spectral Density of outgoing signals in W/Hz.
314 *
315 * @param txPsd the Power Spectral Density value
316 */
318
319 /**
320 * Set the noise power spectral density.
321 *
322 * @param noisePsd the Noise Power Spectral Density in power units
323 * (Watt, Pascal...) per Hz.
324 */
326
327 /**
328 * Get the noise power spectral density.
329 *
330 * @return the Noise Power Spectral Density
331 */
333
334 /**
335 * Set the modulation option used by this PHY.
336 * See IEEE 802.15.4-2011, section 8, Table 66.
337 *
338 * @param phyOption The phy modulation option used by the model.
339 */
340 void SetPhyOption(PhyOption phyOption);
341
342 /**
343 * Set the receiver power sensitivity used by this device in dBm.
344 *
345 * In ns-3 , rx sensitivity is only checked to be at least what is specified by
346 * the standard (-85dBm or -92dBm for BPSK bands). Most vendors provide better sensitivity
347 * options and exceed the minimum values proposed by the standard. Default sensitivity
348 * is -106.58 dBm (This does not include any noise figure).
349 * A sensitivity of -95dBm or less is considered by many vendors a high sensitivity.
350 *
351 * \param dbmSensitivity The receiver power sensitivity to set in dBm.
352 */
353 void SetRxSensitivity(double dbmSensitivity);
354
355 /**
356 * Get the receiver power sensitivity used by this device in dBm.
357 *
358 * \return The receiver power sensitivity used by this device in dBm.
359 */
360 double GetRxSensitivity();
361
362 /**
363 * Notify the SpectrumPhy instance of an incoming waveform.
364 *
365 * @param params the SpectrumSignalParameters associated with the incoming waveform
366 */
367 void StartRx(Ptr<SpectrumSignalParameters> params) override;
368
369 /**
370 * IEEE 802.15.4-2006 section 6.2.1.1
371 * PD-DATA.request
372 * Request to transfer MPDU from MAC (transmitting)
373 * \param psduLength number of bytes in the PSDU
374 * \param p the packet to be transmitted
375 */
376 void PdDataRequest(const uint32_t psduLength, Ptr<Packet> p);
377
378 /**
379 * IEEE 802.15.4-2006 section 6.2.2.1
380 * PLME-CCA.request
381 * Perform a CCA per section 6.9.9
382 */
383 void PlmeCcaRequest();
384
385 /**
386 * Cancel an ongoing CCA request.
387 */
388 void CcaCancel();
389
390 /**
391 * IEEE 802.15.4-2006 section 6.2.2.3
392 * PLME-ED.request
393 * Perform an ED per section 6.9.7
394 */
395 void PlmeEdRequest();
396
397 /**
398 * IEEE 802.15.4-2006 section 6.2.2.5
399 * PLME-GET.request
400 * Get attributes per definition from Table 23 in section 6.4.2
401 * \param id the attributed identifier
402 */
404
405 /**
406 * IEEE 802.15.4-2006 section 6.2.2.7
407 * PLME-SET-TRX-STATE.request
408 * Set PHY state
409 * \param state in RX_ON,TRX_OFF,FORCE_TRX_OFF,TX_ON
410 */
412
413 /**
414 * IEEE 802.15.4-2006 section 6.2.2.9
415 * PLME-SET.request
416 * Set attributes per definition from Table 23 in section 6.4.2
417 * \param id the attributed identifier
418 * \param attribute the attribute value
419 */
421
422 /**
423 * set the callback for the end of a RX, as part of the
424 * interconnections between the PHY and the MAC. The callback
425 * implements PD Indication SAP.
426 * \param c the callback
427 */
429
430 /**
431 * set the callback for the end of a TX, as part of the
432 * interconnections between the PHY and the MAC. The callback
433 * implements PD SAP.
434 * \param c the callback
435 */
437
438 /**
439 * set the callback for the end of a CCA, as part of the
440 * interconnections between the PHY and the MAC. The callback
441 * implement PLME CCA confirm SAP
442 * \param c the callback
443 */
445
446 /**
447 * set the callback for the end of an ED, as part of the
448 * interconnections between the PHY and the MAC. The callback
449 * implement PLME ED confirm SAP
450 * \param c the callback
451 */
453
454 /**
455 * set the callback for the end of an GetAttribute, as part of the
456 * interconnections between the PHY and the MAC. The callback
457 * implement PLME GetAttribute confirm SAP
458 * \param c the callback
459 */
461
462 /**
463 * set the callback for the end of an SetTRXState, as part of the
464 * interconnections between the PHY and the MAC. The callback
465 * implement PLME SetTRXState confirm SAP
466 * \param c the callback
467 */
469
470 /**
471 * set the callback for the end of an SetAttribute, as part of the
472 * interconnections between the PHY and the MAC. The callback
473 * implement PLME SetAttribute confirm SAP
474 * \param c the callback
475 */
477
478 /**
479 * Get The current channel page number in use in this PHY from the PIB attributes.
480 *
481 * \return The current page number
482 */
483 uint8_t GetCurrentPage() const;
484
485 /**
486 * Get The current channel number in use in this PHY from the PIB attributes.
487 *
488 * \return The current channel number
489 */
490 uint8_t GetCurrentChannelNum() const;
491
492 /**
493 * implement PLME SetAttribute confirm SAP
494 * bit rate is in bit/s. Symbol rate is in symbol/s.
495 * \param isData is true for data rate or false for symbol rate
496 * \return the rate value of this PHY
497 */
498 double GetDataOrSymbolRate(bool isData);
499
500 /**
501 * set the error model to use
502 *
503 * \param e pointer to LrWpanErrorModel to use
504 */
506
507 /**
508 * get the error model in use
509 *
510 * \return pointer to LrWpanErrorModel in use
511 */
513
514 /**
515 * Attach a receive ErrorModel to the LrWpanPhy.
516 *
517 * The LrWpanPhy may optionally include an ErrorModel in
518 * the packet receive chain. The error model is additive
519 * to any modulation-based error model based on SNR, and
520 * is typically used to force specific packet losses or
521 * for testing purposes.
522 *
523 * \param em Pointer to the ErrorModel.
524 */
526
527 /**
528 * Get the duration of the SHR (preamble and SFD) in symbols, depending on
529 * the currently selected channel.
530 *
531 * \return the SHR duration in symbols
532 */
533 uint64_t GetPhySHRDuration() const;
534
535 /**
536 * Get the number of symbols per octet, depending on the currently selected
537 * channel.
538 *
539 * \return the number of symbols per octet
540 */
541 double GetPhySymbolsPerOctet() const;
542
543 /**
544 * Get the current accumulated sum of signals in the transceiver including
545 * signals considered as interference.
546 *
547 * \return the accumulated signal power spectral density value in Dbm.
548 */
549 double GetCurrentSignalPsd();
550
551 /**
552 * Assign a fixed random variable stream number to the random variables
553 * used by this model. Return the number of streams that have been assigned.
554 *
555 * \param stream first stream index to use
556 * \return the number of stream indices assigned by this model
557 */
558 int64_t AssignStreams(int64_t stream);
559
560 /**
561 * TracedCallback signature for Trx state change events.
562 *
563 * \param [in] time The time of the state change.
564 * \param [in] oldState The old state.
565 * \param [in] newState The new state.
566 * \deprecated The LrWpanPhyEnumeration state is now accessible as the
567 * TracedValue \c TrxStateValue. The \c TrxState TracedCallback will
568 * be removed in a future release.
569 */
570 typedef void (*StateTracedCallback)(Time time,
571 PhyEnumeration oldState,
572 PhyEnumeration newState);
573
574 private:
575 /**
576 * The second is true if the first is flagged as error/invalid.
577 */
578 typedef std::pair<Ptr<Packet>, bool> PacketAndStatus;
579
580 // Inherited from Object.
581 void DoInitialize() override;
582 void DoDispose() override;
583
584 /**
585 * Change the PHY state to the given new state, firing the state change trace.
586 *
587 * \param newState the new state
588 */
589 void ChangeTrxState(PhyEnumeration newState);
590
591 /**
592 * Get the currently configured PHY option.
593 * See IEEE 802.15.4-2006, section 6.1.2, Table 2.
594 *
595 * \return the PHY option
596 */
598
599 /**
600 * Finish the transmission of a frame. This is called at the end of a frame
601 * transmission, applying possibly pending PHY state changes and firing the
602 * appropriate trace sources and confirm callbacks to the MAC.
603 */
604 void EndTx();
605
606 /**
607 * Check if the interference destroys a frame currently received. Called
608 * whenever a change in interference is detected.
609 */
610 void CheckInterference();
611
612 /**
613 * Finish the reception of a frame. This is called at the end of a frame
614 * reception, applying possibly pending PHY state changes and firing the
615 * appropriate trace sources and indication callbacks to the MAC. A frame
616 * destroyed by noise/interference is dropped here, but not during reception.
617 * This method is also called for every packet which only contributes to
618 * interference.
619 *
620 * \param params signal parameters of the packet
621 */
623
624 /**
625 * Cancel an ongoing ED procedure. This is called when the transceiver is
626 * switched off or set to TX mode. This calls the appropriate confirm callback
627 * of the MAC.
628 *
629 * \param state the new state which is the cause for canceling ED
630 */
631 void CancelEd(PhyEnumeration state);
632
633 /**
634 * Called at the end of the ED procedure. The average energy detected is
635 * reported to the MAC.
636 */
637 void EndEd();
638
639 /**
640 * Called at the end of the CCA. The channel condition (busy or idle) is
641 * reported to the MAC or CSMA/CA.
642 */
643 void EndCca();
644
645 /**
646 * Called after applying a deferred transceiver state switch. The result of
647 * the state switch is reported to the MAC.
648 */
649 void EndSetTRXState();
650
651 /**
652 * Calculate the time required for sending the given packet, including
653 * preamble, SFD and PHR.
654 *
655 * \param packet the packet for which the transmission time should be calculated
656 * \return the time required for transmitting the packet
657 */
659
660 /**
661 * Calculate the time required for sending the PPDU header, that is the
662 * preamble, SFD and PHR.
663 * \returns The time required for sending the PPDU header.
664 */
666
667 /**
668 * Check if the given channel is supported by the PHY.
669 *
670 * \param channel the channel to check
671 * \return true, if the channel is supported, false otherwise
672 */
673 bool ChannelSupported(uint8_t channel);
674
675 /**
676 * Check if the given page is supported by the PHY.
677 *
678 * \param page the page to check
679 * \return true, if the page is supported, false otherwise
680 */
681 bool PageSupported(uint8_t page);
682
683 /**
684 * Check if the PHY is busy, which is the case if the PHY is currently sending
685 * or receiving a frame.
686 *
687 * \return true, if the PHY is busy, false otherwise
688 */
689 bool PhyIsBusy() const;
690
691 // Trace sources
692 /**
693 * The trace source fired when a packet begins the transmission process on
694 * the medium.
695 *
696 * \see class CallBackTraceSource
697 */
699
700 /**
701 * The trace source fired when a packet ends the transmission process on
702 * the medium.
703 *
704 * \see class CallBackTraceSource
705 */
707
708 /**
709 * The trace source fired when the phy layer drops a packet as it tries
710 * to transmit it.
711 *
712 * \see class CallBackTraceSource
713 */
715
716 /**
717 * The trace source fired when a packet begins the reception process from
718 * the medium.
719 *
720 * \see class CallBackTraceSource
721 */
723
724 /**
725 * The trace source fired when a packet ends the reception process from
726 * the medium. In essence, the notional event of receiving all the energy
727 * of a signal is traced. The received completed signal might represent
728 * a complete packet or a packet that is later on dropped because of interference,
729 * cancellation or post-rx corruption. Second quantity is the received SINR (LQI).
730 *
731 * \see class CallBackTraceSource
732 */
734
735 /**
736 * The trace source fired when the phy layer drops a packet it has received.
737 * (Destruction of a packet due to interference, post-rx corruption or
738 * cancellation of packet rx)
739 *
740 * \see class CallBackTraceSource
741 */
743
744 /**
745 * The trace source fired when the phy layer changes the transceiver state.
746 *
747 * \see class CallBackTraceSource
748 * \deprecated The PhyEnumeration state is now accessible as the
749 * TracedValue \c TrxStateValue. This TracedCallback will
750 * be removed in a future release.
751 */
753
754 /**
755 * Calculates the nominal transmit power of the device in decibels relative to 1 mW
756 * according to the representation of the PIB attribute phyTransmitPower.
757 *
758 * The phyTransmitPower (table 23 of IEEE 802.15.4-2006) is a 8-bit bitmap, stored
759 * as a `uint8_t`. The bitmap has the following meaning:
760 * The 2 MSBs represent the tolerance on the transmit power.
761 * The 6 LSBs represent a signed integer in twos-complement format, corresponding
762 * to the nominal transmit power of the device in decibels relative to 1 mW.
763 *
764 * This function extracts the 6 LSBs corresponding to the nominal transmit power and
765 * converts it to a `int8_t`.
766 *
767 * \param phyTransmitPower the PIB attribute
768 * \return The nominal transmit power in dBm.
769 */
771
772 /**
773 * Transform watts (W) to decibels milliwatts (dBm).
774 *
775 * \param watt The Watts that will be converted to dBm.
776 * \return The value of Watts in dBm.
777 */
778 double WToDbm(double watt);
779
780 /**
781 * Transforms decibels milliwatts (dBm) to watts (W).
782 *
783 * \param dbm The DBm that will be converted to Watts.
784 * \return The value of DBm in Watts.
785 */
786 double DbmToW(double dbm);
787
788 /**
789 * The mobility model used by the PHY.
790 */
792
793 /**
794 * The configured net device.
795 */
797
798 /**
799 * The channel attached to this transceiver.
800 */
802
803 /**
804 * The antenna used by the transceiver.
805 */
807
808 /**
809 * The transmit power spectral density.
810 */
812
813 /**
814 * The spectral density for for the noise.
815 */
817
818 /**
819 * The error model describing the bit and packet error rates.
820 */
822
823 /**
824 * The current PHY PIB attributes.
825 */
827
828 // State variables
829 /**
830 * The current transceiver state.
831 */
833
834 /**
835 * The next pending state to applied after the current action of the PHY is
836 * completed.
837 */
839
840 // Callbacks
841 /**
842 * This callback is used to notify incoming packets to the MAC layer.
843 * See IEEE 802.15.4-2006, section 6.2.1.3.
844 */
846
847 /**
848 * This callback is used to report packet transmission status to the MAC layer.
849 * See IEEE 802.15.4-2006, section 6.2.1.2.
850 */
852
853 /**
854 * This callback is used to report CCA status to the MAC or CSMA/CA.
855 * See IEEE 802.15.4-2006, section 6.2.2.2.
856 */
858
859 /**
860 * This callback is used to report ED status to the MAC.
861 * See IEEE 802.15.4-2006, section 6.2.2.4.
862 */
864
865 /**
866 * This callback is used to report requested attribute values back to the MAC.
867 * See IEEE 802.15.4-2006, section 6.2.2.6.
868 */
870
871 /**
872 * This callback is used to report transceiver state change status to the MAC.
873 * See IEEE 802.15.4-2006, section 6.2.2.8.
874 */
876
877 /**
878 * This callback is used to report attribute set results back to the MAC.
879 * See IEEE 802.15.4-2006, section 6.2.2.10.
880 */
882
883 /**
884 * The currently configured PHY type.
885 */
887
888 /**
889 * Helper value for tracking the average power during ED.
890 */
892
893 /**
894 * Helper value for the peak power value during CCA.
895 */
897
898 /**
899 * The receiver sensitivity.
900 */
902
903 /**
904 * Indicates if the reception of frame has been canceled.
905 */
907
908 /**
909 * The accumulated signals currently received by the transceiver, including
910 * the signal of a possibly received packet, as well as all signals
911 * considered noise.
912 */
914
915 /**
916 * Timestamp of the last calculation of the PER of a packet currently received.
917 */
919
920 /**
921 * Status information of the currently received packet. The first parameter
922 * contains the frame, as well the signal power of the frame. If the second
923 * parameter is set to true, the frame is either invalid, destroyed
924 * due to interference or cancelled.
925 */
926 std::pair<Ptr<LrWpanSpectrumSignalParameters>, bool> m_currentRxPacket;
927
928 /**
929 * Status information of the currently transmitted packet. The first parameter
930 * contains the frame. If the second parameter is set to true, the frame has not
931 * been completely transmitted (in the event of a force transceiver switch, for
932 * example).
933 */
935
936 /**
937 * Scheduler event of a currently running CCA request.
938 */
940
941 /**
942 * Scheduler event of a currently running ED request.
943 */
945
946 /**
947 * Scheduler event of a currently running deferred transceiver state switch.
948 */
950
951 /**
952 * Scheduler event of a currently running data transmission request.
953 */
955
956 /**
957 * Uniform random variable stream.
958 */
960
961 Ptr<ErrorModel> m_postReceptionErrorModel; //!< Error model for receive packet events
962};
963
964} // namespace lrwpan
965} // namespace ns3
966
967#endif /* LR_WPAN_PHY_H */
Callback template class.
Definition: callback.h:438
An identifier for simulation events.
Definition: event-id.h:55
Introspection did not find any typical Config paths.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
A template-based reference counting class.
Abstract base class for Spectrum-aware PHY layers.
Definition: spectrum-phy.h:46
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Forward calls to a chain of Callback.
Trace classes with value semantics.
Definition: traced-value.h:116
a unique identifier for an interface.
Definition: type-id.h:59
Make LrWpanPhy a SpectrumPhy so we can enable the eventual modeling of device interference.
Definition: lr-wpan-phy.h:274
void PlmeEdRequest()
IEEE 802.15.4-2006 section 6.2.2.3 PLME-ED.request Perform an ED per section 6.9.7.
Definition: lr-wpan-phy.cc:744
void PlmeSetAttributeRequest(PhyPibAttributeIdentifier id, Ptr< PhyPibAttributes > attribute)
IEEE 802.15.4-2006 section 6.2.2.9 PLME-SET.request Set attributes per definition from Table 23 in se...
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
void SetRxSensitivity(double dbmSensitivity)
Set the receiver power sensitivity used by this device in dBm.
EventId m_pdDataRequest
Scheduler event of a currently running data transmission request.
Definition: lr-wpan-phy.h:954
void EndRx(Ptr< SpectrumSignalParameters > params)
Finish the reception of a frame.
Definition: lr-wpan-phy.cc:549
void SetTxPowerSpectralDensity(Ptr< SpectrumValue > txPsd)
Set the Power Spectral Density of outgoing signals in W/Hz.
Ptr< AntennaModel > m_antenna
The antenna used by the transceiver.
Definition: lr-wpan-phy.h:806
std::pair< Ptr< LrWpanSpectrumSignalParameters >, bool > m_currentRxPacket
Status information of the currently received packet.
Definition: lr-wpan-phy.h:926
Ptr< NetDevice > m_device
The configured net device.
Definition: lr-wpan-phy.h:796
bool ChannelSupported(uint8_t channel)
Check if the given channel is supported by the PHY.
Definition: lr-wpan-phy.cc:992
void SetPlmeGetAttributeConfirmCallback(PlmeGetAttributeConfirmCallback c)
set the callback for the end of an GetAttribute, as part of the interconnections between the PHY and ...
int8_t GetNominalTxPowerFromPib(uint8_t phyTransmitPower)
Calculates the nominal transmit power of the device in decibels relative to 1 mW according to the rep...
void DoInitialize() override
Initialize() implementation.
Definition: lr-wpan-phy.cc:230
void SetAntenna(Ptr< AntennaModel > a)
Set the attached antenna.
Definition: lr-wpan-phy.cc:356
Ptr< const SpectrumModel > GetRxSpectrumModel() const override
Definition: lr-wpan-phy.cc:336
void DoDispose() override
Destructor implementation.
Definition: lr-wpan-phy.cc:255
TracedCallback< Ptr< const Packet > > m_phyTxBeginTrace
The trace source fired when a packet begins the transmission process on the medium.
Definition: lr-wpan-phy.h:698
void EndCca()
Called at the end of the CCA.
Ptr< SpectrumChannel > m_channel
The channel attached to this transceiver.
Definition: lr-wpan-phy.h:801
void SetPostReceptionErrorModel(const Ptr< ErrorModel > em)
Attach a receive ErrorModel to the LrWpanPhy.
double GetRxSensitivity()
Get the receiver power sensitivity used by this device in dBm.
PhyOption GetMyPhyOption()
Get the currently configured PHY option.
PacketAndStatus m_currentTxPacket
Status information of the currently transmitted packet.
Definition: lr-wpan-phy.h:934
void EndSetTRXState()
Called after applying a deferred transceiver state switch.
PdDataConfirmCallback m_pdDataConfirmCallback
This callback is used to report packet transmission status to the MAC layer.
Definition: lr-wpan-phy.h:851
void SetChannel(Ptr< SpectrumChannel > c) override
Set the channel attached to this device.
Definition: lr-wpan-phy.cc:322
void PlmeGetAttributeRequest(PhyPibAttributeIdentifier id)
IEEE 802.15.4-2006 section 6.2.2.5 PLME-GET.request Get attributes per definition from Table 23 in se...
Definition: lr-wpan-phy.cc:771
void SetPdDataConfirmCallback(PdDataConfirmCallback c)
set the callback for the end of a TX, as part of the interconnections between the PHY and the MAC.
Ptr< LrWpanInterferenceHelper > m_signal
The accumulated signals currently received by the transceiver, including the signal of a possibly rec...
Definition: lr-wpan-phy.h:913
void SetPdDataIndicationCallback(PdDataIndicationCallback c)
set the callback for the end of a RX, as part of the interconnections between the PHY and the MAC.
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
The trace source fired when a packet ends the transmission process on the medium.
Definition: lr-wpan-phy.h:706
double WToDbm(double watt)
Transform watts (W) to decibels milliwatts (dBm).
uint8_t GetCurrentPage() const
Get The current channel page number in use in this PHY from the PIB attributes.
PhyPibAttributes m_phyPIBAttributes
The current PHY PIB attributes.
Definition: lr-wpan-phy.h:826
Ptr< MobilityModel > m_mobility
The mobility model used by the PHY.
Definition: lr-wpan-phy.h:791
void SetErrorModel(Ptr< LrWpanErrorModel > e)
set the error model to use
void SetMobility(Ptr< MobilityModel > m) override
Set the mobility model associated with this device.
Definition: lr-wpan-phy.cc:315
PlmeSetTRXStateConfirmCallback m_plmeSetTRXStateConfirmCallback
This callback is used to report transceiver state change status to the MAC.
Definition: lr-wpan-phy.h:875
void SetNoisePowerSpectralDensity(Ptr< const SpectrumValue > noisePsd)
Set the noise power spectral density.
TracedCallback< Time, PhyEnumeration, PhyEnumeration > m_trxStateLogger
The trace source fired when the phy layer changes the transceiver state.
Definition: lr-wpan-phy.h:752
EdPower m_edPower
Helper value for tracking the average power during ED.
Definition: lr-wpan-phy.h:891
Time m_rxLastUpdate
Timestamp of the last calculation of the PER of a packet currently received.
Definition: lr-wpan-phy.h:918
EventId m_setTRXState
Scheduler event of a currently running deferred transceiver state switch.
Definition: lr-wpan-phy.h:949
Ptr< MobilityModel > GetMobility() const override
Get the associated MobilityModel instance.
Definition: lr-wpan-phy.cc:302
void SetPlmeSetAttributeConfirmCallback(PlmeSetAttributeConfirmCallback c)
set the callback for the end of an SetAttribute, as part of the interconnections between the PHY and ...
void SetPhyOption(PhyOption phyOption)
Set the modulation option used by this PHY.
void PlmeCcaRequest()
IEEE 802.15.4-2006 section 6.2.2.1 PLME-CCA.request Perform a CCA per section 6.9....
Definition: lr-wpan-phy.cc:710
TracedValue< PhyEnumeration > m_trxState
The current transceiver state.
Definition: lr-wpan-phy.h:832
void SetPlmeSetTRXStateConfirmCallback(PlmeSetTRXStateConfirmCallback c)
set the callback for the end of an SetTRXState, as part of the interconnections between the PHY and t...
double GetCurrentSignalPsd()
Get the current accumulated sum of signals in the transceiver including signals considered as interfe...
void SetPlmeCcaConfirmCallback(PlmeCcaConfirmCallback c)
set the callback for the end of a CCA, as part of the interconnections between the PHY and the MAC.
Ptr< LrWpanErrorModel > m_errorModel
The error model describing the bit and packet error rates.
Definition: lr-wpan-phy.h:821
void EndTx()
Finish the transmission of a frame.
void SetPlmeEdConfirmCallback(PlmeEdConfirmCallback c)
set the callback for the end of an ED, as part of the interconnections between the PHY and the MAC.
uint8_t GetCurrentChannelNum() const
Get The current channel number in use in this PHY from the PIB attributes.
void PlmeSetTRXStateRequest(PhyEnumeration state)
IEEE 802.15.4-2006 section 6.2.2.7 PLME-SET-TRX-STATE.request Set PHY state.
Definition: lr-wpan-phy.cc:804
LrWpanPhy()
Default constructor.
Definition: lr-wpan-phy.cc:204
TracedCallback< Ptr< const Packet > > m_phyRxBeginTrace
The trace source fired when a packet begins the reception process from the medium.
Definition: lr-wpan-phy.h:722
PlmeSetAttributeConfirmCallback m_plmeSetAttributeConfirmCallback
This callback is used to report attribute set results back to the MAC.
Definition: lr-wpan-phy.h:881
PhyEnumeration m_trxStatePending
The next pending state to applied after the current action of the PHY is completed.
Definition: lr-wpan-phy.h:838
TracedCallback< Ptr< const Packet > > m_phyRxDropTrace
The trace source fired when the phy layer drops a packet it has received.
Definition: lr-wpan-phy.h:742
double GetPhySymbolsPerOctet() const
Get the number of symbols per octet, depending on the currently selected channel.
PdDataIndicationCallback m_pdDataIndicationCallback
This callback is used to notify incoming packets to the MAC layer.
Definition: lr-wpan-phy.h:845
Ptr< LrWpanErrorModel > GetErrorModel() const
get the error model in use
void StartRx(Ptr< SpectrumSignalParameters > params) override
Notify the SpectrumPhy instance of an incoming waveform.
Definition: lr-wpan-phy.cc:363
double m_rxSensitivity
The receiver sensitivity.
Definition: lr-wpan-phy.h:901
void CcaCancel()
Cancel an ongoing CCA request.
Definition: lr-wpan-phy.cc:737
void CheckInterference()
Check if the interference destroys a frame currently received.
Definition: lr-wpan-phy.cc:499
std::pair< Ptr< Packet >, bool > PacketAndStatus
The second is true if the first is flagged as error/invalid.
Definition: lr-wpan-phy.h:578
EventId m_ccaRequest
Scheduler event of a currently running CCA request.
Definition: lr-wpan-phy.h:939
Ptr< SpectrumChannel > GetChannel()
Get the currently attached channel.
Definition: lr-wpan-phy.cc:329
Ptr< ErrorModel > m_postReceptionErrorModel
Error model for receive packet events.
Definition: lr-wpan-phy.h:961
PlmeCcaConfirmCallback m_plmeCcaConfirmCallback
This callback is used to report CCA status to the MAC or CSMA/CA.
Definition: lr-wpan-phy.h:857
uint64_t GetPhySHRDuration() const
Get the duration of the SHR (preamble and SFD) in symbols, depending on the currently selected channe...
bool m_isRxCanceled
Indicates if the reception of frame has been canceled.
Definition: lr-wpan-phy.h:906
void CancelEd(PhyEnumeration state)
Cancel an ongoing ED procedure.
Ptr< NetDevice > GetDevice() const override
Get the associated NetDevice instance.
Definition: lr-wpan-phy.cc:296
void PdDataRequest(const uint32_t psduLength, Ptr< Packet > p)
IEEE 802.15.4-2006 section 6.2.1.1 PD-DATA.request Request to transfer MPDU from MAC (transmitting)
Definition: lr-wpan-phy.cc:634
double DbmToW(double dbm)
Transforms decibels milliwatts (dBm) to watts (W).
Ptr< UniformRandomVariable > m_random
Uniform random variable stream.
Definition: lr-wpan-phy.h:959
EventId m_edRequest
Scheduler event of a currently running ED request.
Definition: lr-wpan-phy.h:944
PhyOption m_phyOption
The currently configured PHY type.
Definition: lr-wpan-phy.h:886
Ptr< SpectrumValue > m_txPsd
The transmit power spectral density.
Definition: lr-wpan-phy.h:811
bool PageSupported(uint8_t page)
Check if the given page is supported by the PHY.
Time GetPpduHeaderTxTime()
Calculate the time required for sending the PPDU header, that is the preamble, SFD and PHR.
void EndEd()
Called at the end of the ED procedure.
void SetDevice(Ptr< NetDevice > d) override
Set the associated NetDevice instance.
Definition: lr-wpan-phy.cc:308
double GetDataOrSymbolRate(bool isData)
implement PLME SetAttribute confirm SAP bit rate is in bit/s.
PlmeGetAttributeConfirmCallback m_plmeGetAttributeConfirmCallback
This callback is used to report requested attribute values back to the MAC.
Definition: lr-wpan-phy.h:869
Ptr< Object > GetAntenna() const override
Get the AntennaModel used by this SpectrumPhy instance for transmission and/or reception.
Definition: lr-wpan-phy.cc:350
TracedCallback< Ptr< const Packet > > m_phyTxDropTrace
The trace source fired when the phy layer drops a packet as it tries to transmit it.
Definition: lr-wpan-phy.h:714
TracedCallback< Ptr< const Packet >, double > m_phyRxEndTrace
The trace source fired when a packet ends the reception process from the medium.
Definition: lr-wpan-phy.h:733
double m_ccaPeakPower
Helper value for the peak power value during CCA.
Definition: lr-wpan-phy.h:896
Time CalculateTxTime(Ptr< const Packet > packet)
Calculate the time required for sending the given packet, including preamble, SFD and PHR.
Ptr< const SpectrumValue > GetNoisePowerSpectralDensity()
Get the noise power spectral density.
void(* StateTracedCallback)(Time time, PhyEnumeration oldState, PhyEnumeration newState)
TracedCallback signature for Trx state change events.
Definition: lr-wpan-phy.h:570
bool PhyIsBusy() const
Check if the PHY is busy, which is the case if the PHY is currently sending or receiving a frame.
PlmeEdConfirmCallback m_plmeEdConfirmCallback
This callback is used to report ED status to the MAC.
Definition: lr-wpan-phy.h:863
Ptr< const SpectrumValue > m_noise
The spectral density for for the noise.
Definition: lr-wpan-phy.h:816
void ChangeTrxState(PhyEnumeration newState)
Change the PHY state to the given new state, firing the state change trace.
static TypeId GetTypeId()
Get the type ID.
Definition: lr-wpan-phy.cc:147
Callback< void, uint32_t, Ptr< Packet >, uint8_t > PdDataIndicationCallback
This method implements the PD SAP: PdDataIndication.
Definition: lr-wpan-phy.h:206
PhyOption
This Phy option will be used to index various Tables in IEEE802.15.4-2011.
Definition: lr-wpan-phy.h:95
Callback< void, PhyEnumeration > PlmeCcaConfirmCallback
This method implements the PD SAP: PlmeCcaConfirm.
Definition: lr-wpan-phy.h:224
Callback< void, PhyEnumeration > PlmeSetTRXStateConfirmCallback
This method implements the PD SAP: PlmeSetTRXStateConfirm.
Definition: lr-wpan-phy.h:255
Callback< void, PhyEnumeration, uint8_t > PlmeEdConfirmCallback
This method implements the PD SAP: PlmeEdConfirm.
Definition: lr-wpan-phy.h:234
Callback< void, PhyEnumeration, PhyPibAttributeIdentifier, Ptr< PhyPibAttributes > > PlmeGetAttributeConfirmCallback
This method implements the PD SAP: PlmeGetAttributeConfirm.
Definition: lr-wpan-phy.h:246
PhyEnumeration
IEEE802.15.4-2006 PHY Emumerations Table 18 in section 6.2.3.
Definition: lr-wpan-phy.h:115
Callback< void, PhyEnumeration > PdDataConfirmCallback
This method implements the PD SAP: PdDataConfirm.
Definition: lr-wpan-phy.h:215
Callback< void, PhyEnumeration, PhyPibAttributeIdentifier > PlmeSetAttributeConfirmCallback
This method implements the PD SAP: PlmeSetAttributeConfirm.
Definition: lr-wpan-phy.h:265
PhyPibAttributeIdentifier
IEEE802.15.4-2006 PHY PIB Attribute Identifiers Table 23 in section 6.4.2.
Definition: lr-wpan-phy.h:167
@ IEEE_802_15_4_915MHZ_OQPSK
Definition: lr-wpan-phy.h:103
@ IEEE_802_15_4_2_4GHZ_OQPSK
Definition: lr-wpan-phy.h:104
@ IEEE_802_15_4_915MHZ_ASK
Definition: lr-wpan-phy.h:100
@ IEEE_802_15_4_780MHZ_OQPSK
Definition: lr-wpan-phy.h:101
@ IEEE_802_15_4_868MHZ_OQPSK
Definition: lr-wpan-phy.h:102
@ IEEE_802_15_4_915MHZ_BPSK
Definition: lr-wpan-phy.h:97
@ IEEE_802_15_4_868MHZ_BPSK
Definition: lr-wpan-phy.h:96
@ IEEE_802_15_4_950MHZ_BPSK
Definition: lr-wpan-phy.h:98
@ IEEE_802_15_4_INVALID_PHY_OPTION
Definition: lr-wpan-phy.h:105
@ IEEE_802_15_4_868MHZ_ASK
Definition: lr-wpan-phy.h:99
@ IEEE_802_15_4_PHY_BUSY
Definition: lr-wpan-phy.h:116
@ IEEE_802_15_4_PHY_READ_ONLY
Definition: lr-wpan-phy.h:127
@ IEEE_802_15_4_PHY_BUSY_TX
Definition: lr-wpan-phy.h:118
@ IEEE_802_15_4_PHY_RX_ON
Definition: lr-wpan-phy.h:122
@ IEEE_802_15_4_PHY_TRX_OFF
Definition: lr-wpan-phy.h:124
@ IEEE_802_15_4_PHY_TX_ON
Definition: lr-wpan-phy.h:125
@ IEEE_802_15_4_PHY_INVALID_PARAMETER
Definition: lr-wpan-phy.h:121
@ IEEE_802_15_4_PHY_UNSUPPORTED_ATTRIBUTE
Definition: lr-wpan-phy.h:126
@ IEEE_802_15_4_PHY_SUCCESS
Definition: lr-wpan-phy.h:123
@ IEEE_802_15_4_PHY_FORCE_TRX_OFF
Definition: lr-wpan-phy.h:119
@ IEEE_802_15_4_PHY_BUSY_RX
Definition: lr-wpan-phy.h:117
@ IEEE_802_15_4_PHY_IDLE
Definition: lr-wpan-phy.h:120
@ IEEE_802_15_4_PHY_UNSPECIFIED
Definition: lr-wpan-phy.h:128
@ phySymbolsPerOctet
Definition: lr-wpan-phy.h:175
@ phyChannelsSupported
Definition: lr-wpan-phy.h:169
@ phyMaxFrameDuration
Definition: lr-wpan-phy.h:173
std::ostream & operator<<(std::ostream &os, const SuperframeField &superframeField)
Stream insertion operator.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Helper structure to manage the power measurement during ED.
Definition: lr-wpan-phy.h:58
double averagePower
Average measured power.
Definition: lr-wpan-phy.h:59
Time lastUpdate
Last update time.
Definition: lr-wpan-phy.h:60
Time measurementLength
Total measurement period.
Definition: lr-wpan-phy.h:61
This data structure provides the Bit rate and Symbol rate for a given channel See IEEE802....
Definition: lr-wpan-phy.h:71
IEEE802.15.4-2006 PHY PIB Attributes Table 23 in section 6.4.2.
Definition: lr-wpan-phy.h:184
uint32_t phySHRDuration
The duration of the synchronization header (SHR) in symbols.
Definition: lr-wpan-phy.h:193
uint8_t phyCCAMode
CCA mode.
Definition: lr-wpan-phy.h:190
double phySymbolsPerOctet
The number of symbols per octet.
Definition: lr-wpan-phy.h:194
uint8_t phyCurrentChannel
The RF channel to use.
Definition: lr-wpan-phy.h:185
uint8_t phyCurrentPage
Current channel page.
Definition: lr-wpan-phy.h:191
uint8_t phyTransmitPower
2 MSB: tolerance on the transmit power, 6 LSB: Tx power in dBm relative to 1mW (signed int in 2-compl...
Definition: lr-wpan-phy.h:188
uint32_t phyChannelsSupported[32]
BitField representing the available channels supported by a channel page.
Definition: lr-wpan-phy.h:186
uint32_t phyMaxFrameDuration
The maximum number of symbols in a frame.
Definition: lr-wpan-phy.h:192
This data structure provides number of symbols for the PPDU headers: SHR and PHR See IEEE802....
Definition: lr-wpan-phy.h:83
double phr
Number of symbols for the PHR.
Definition: lr-wpan-phy.h:86
double shrPreamble
Number of symbols for the SHR preamble.
Definition: lr-wpan-phy.h:84
double shrSfd
Number of symbols for the SHR SFD.
Definition: lr-wpan-phy.h:85