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