26#include <ns3/event-id.h>
27#include <ns3/spectrum-phy.h>
28#include <ns3/traced-callback.h>
29#include <ns3/traced-value.h>
36class LrWpanErrorModel;
37struct LrWpanSpectrumSignalParameters;
43class UniformRandomVariable;
125namespace TracedValueCallback
754 double WToDbm(
double watt);
762 double DbmToW(
double dbm);
An identifier for simulation events.
Make LrWpanPhy a SpectrumPhy so we can enable the eventual modeling of device interference.
double GetCurrentSignalPsd()
Get the current accumulated sum of signals in the transceiver including signals considered as interfe...
static TypeId GetTypeId()
Get the type ID.
Ptr< const SpectrumValue > m_noise
The spectral density for for the noise.
std::pair< Ptr< Packet >, bool > PacketAndStatus
The second is true if the first is flagged as error/invalid.
void SetPdDataConfirmCallback(PdDataConfirmCallback c)
set the callback for the end of a TX, as part of the interconnections between the PHY and the MAC.
void SetPhyOption(LrWpanPhyOption phyOption)
Set the modulation option used by this PHY.
void(* StateTracedCallback)(Time time, LrWpanPhyEnumeration oldState, LrWpanPhyEnumeration newState)
TracedCallback signature for Trx state change events.
void EndTx()
Finish the transmission of a frame.
EventId m_setTRXState
Scheduler event of a currently running deferred transceiver state switch.
Ptr< const SpectrumValue > GetNoisePowerSpectralDensity()
Get the noise power spectral density.
bool ChannelSupported(uint8_t channel)
Check if the given channel is supported by the PHY.
Ptr< SpectrumValue > m_txPsd
The transmit power spectral density.
void ChangeTrxState(LrWpanPhyEnumeration newState)
Change the PHY state to the given new state, firing the state change trace.
PlmeSetAttributeConfirmCallback m_plmeSetAttributeConfirmCallback
This callback is used to report attribute set results back to the MAC.
void SetPlmeGetAttributeConfirmCallback(PlmeGetAttributeConfirmCallback c)
set the callback for the end of an GetAttribute, as part of the interconnections between the PHY and ...
Time CalculateTxTime(Ptr< const Packet > packet)
Calculate the time required for sending the given packet, including preamble, SFD and PHR.
Ptr< AntennaModel > m_antenna
The antenna used by the transceiver.
double GetDataOrSymbolRate(bool isData)
implement PLME SetAttribute confirm SAP bit rate is in bit/s.
void SetPlmeSetTRXStateConfirmCallback(PlmeSetTRXStateConfirmCallback c)
set the callback for the end of an SetTRXState, as part of the interconnections between the PHY and t...
void PlmeSetTRXStateRequest(LrWpanPhyEnumeration state)
IEEE 802.15.4-2006 section 6.2.2.7 PLME-SET-TRX-STATE.request Set PHY state.
void SetTxPowerSpectralDensity(Ptr< SpectrumValue > txPsd)
Set the Power Spectral Density of outgoing signals in W/Hz.
void PlmeGetAttributeRequest(LrWpanPibAttributeIdentifier id)
IEEE 802.15.4-2006 section 6.2.2.5 PLME-GET.request Get attributes per definition from Table 23 in se...
Ptr< UniformRandomVariable > m_random
Uniform random variable stream.
TracedValue< LrWpanPhyEnumeration > m_trxState
The current transceiver state.
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
The trace source fired when a packet ends the transmission process on the medium.
void SetPlmeEdConfirmCallback(PlmeEdConfirmCallback c)
set the callback for the end of an ED, as part of the interconnections between the PHY and the MAC.
LrWpanPhyOption GetMyPhyOption()
Get the currently configured PHY option.
void EndRx(Ptr< SpectrumSignalParameters > params)
Finish the reception of a frame.
PlmeCcaConfirmCallback m_plmeCcaConfirmCallback
This callback is used to report CCA status to the MAC or CSMA/CA.
bool PhyIsBusy() const
Check if the PHY is busy, which is the case if the PHY is currently sending or receiving a frame.
Ptr< NetDevice > m_device
The configured net device.
uint64_t GetPhySHRDuration() const
Get the duration of the SHR (preamble and SFD) in symbols, depending on the currently selected channe...
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 SetRxSensitivity(double dbmSensitivity)
Set the receiver power sensitivity used by this device in dBm.
Ptr< ErrorModel > m_postReceptionErrorModel
Error model for receive packet events.
Ptr< LrWpanErrorModel > m_errorModel
The error model describing the bit and packet error rates.
uint8_t GetCurrentPage() const
Get The current channel page number in use in this PHY from the PIB attributes.
bool PageSupported(uint8_t page)
Check if the given page is supported by the PHY.
void DoInitialize() override
Initialize() implementation.
void EndEd()
Called at the end of the ED procedure.
PlmeEdConfirmCallback m_plmeEdConfirmCallback
This callback is used to report ED status to the MAC.
std::pair< Ptr< LrWpanSpectrumSignalParameters >, bool > m_currentRxPacket
Statusinformation of the currently received packet.
EventId m_ccaRequest
Scheduler event of a currently running CCA request.
void CheckInterference()
Check if the interference destroys a frame currently received.
void EndCca()
Called at the end of the CCA.
LrWpanEdPower m_edPower
Helper value for tracking the average power during ED.
Ptr< LrWpanErrorModel > GetErrorModel() const
get the error model in use
uint8_t GetCurrentChannelNum() const
Get The current channel number in use in this PHY from the PIB attributes.
PacketAndStatus m_currentTxPacket
Statusinformation of the currently transmitted packet.
TracedCallback< Ptr< const Packet >, double > m_phyRxEndTrace
The trace source fired when a packet ends the reception process from the medium.
void SetMobility(Ptr< MobilityModel > m) override
Set the mobility model associated with this device.
Ptr< SpectrumChannel > m_channel
The channel attached to this transceiver.
PdDataConfirmCallback m_pdDataConfirmCallback
This callback is used to report packet transmission status to the MAC layer.
TracedCallback< Ptr< const Packet > > m_phyTxBeginTrace
The trace source fired when a packet begins the transmission process on the medium.
Ptr< MobilityModel > m_mobility
The mobility model used by the PHY.
double GetPhySymbolsPerOctet() const
Get the number of symbols per octet, depending on the currently selected channel.
double m_ccaPeakPower
Helper value for the peak power value during CCA.
LrWpanPhyOption m_phyOption
The currently configured PHY type.
EventId m_edRequest
Scheduler event of a currently running ED request.
LrWpanPhyPibAttributes m_phyPIBAttributes
The current PHY PIB attributes.
double m_rxSensitivity
The receiver sensitivity.
LrWpanPhyEnumeration m_trxStatePending
The next pending state to applied after the current action of the PHY is completed.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
void EndSetTRXState()
Called after applying a deferred transceiver state switch.
Ptr< LrWpanInterferenceHelper > m_signal
The accumulated signals currently received by the transceiver, including the signal of a possibly rec...
int8_t GetNominalTxPowerFromPib(uint8_t phyTransmitPower)
Calculates the nominal transmit power of the device in decibels relative to 1 mW according to the rep...
Ptr< MobilityModel > GetMobility() const override
Get the associated MobilityModel instance.
PdDataIndicationCallback m_pdDataIndicationCallback
This callback is used to notify incoming packets to the MAC layer.
Time GetPpduHeaderTxTime()
Calculate the time required for sending the PPDU header, that is the preamble, SFD and PHR.
void PlmeSetAttributeRequest(LrWpanPibAttributeIdentifier id, Ptr< LrWpanPhyPibAttributes > attribute)
IEEE 802.15.4-2006 section 6.2.2.9 PLME-SET.request Set attributes per definition from Table 23 in se...
void DoDispose() override
Destructor implementation.
void SetErrorModel(Ptr< LrWpanErrorModel > e)
set the error model to use
TracedCallback< Ptr< const Packet > > m_phyRxDropTrace
The trace source fired when the phy layer drops a packet it has received.
double WToDbm(double watt)
Transform watts (W) to decibels milliwatts (dBm).
void SetChannel(Ptr< SpectrumChannel > c) override
Set the channel attached to this device.
void CcaCancel()
Cancel an ongoing CCA request.
PlmeSetTRXStateConfirmCallback m_plmeSetTRXStateConfirmCallback
This callback is used to report transceiver state change status to the MAC.
PlmeGetAttributeConfirmCallback m_plmeGetAttributeConfirmCallback
This callback is used to report requested attribute values back to the MAC.
void SetPdDataIndicationCallback(PdDataIndicationCallback c)
set the callback for the end of a RX, as part of the interconnections between the PHY and the MAC.
EventId m_pdDataRequest
Scheduler event of a currently running data transmission request.
Ptr< NetDevice > GetDevice() const override
Get the associated NetDevice instance.
void PlmeEdRequest()
IEEE 802.15.4-2006 section 6.2.2.3 PLME-ED.request Perform an ED per section 6.9.7.
TracedCallback< Ptr< const Packet > > m_phyTxDropTrace
The trace source fired when the phy layer drops a packet as it tries to transmit it.
void SetPostReceptionErrorModel(const Ptr< ErrorModel > em)
Attach a receive ErrorModel to the LrWpanPhy.
TracedCallback< Ptr< const Packet > > m_phyRxBeginTrace
The trace source fired when a packet begins the reception process from the medium.
bool m_isRxCanceled
Indicates if the reception of frame has been canceled.
void SetPlmeSetAttributeConfirmCallback(PlmeSetAttributeConfirmCallback c)
set the callback for the end of an SetAttribute, as part of the interconnections between the PHY and ...
double DbmToW(double dbm)
Transforms decibels milliwatts (dBm) to watts (W).
Time m_rxLastUpdate
Timestamp of the last calculation of the PER of a packet currently received.
Ptr< SpectrumChannel > GetChannel()
Get the currently attached channel.
TracedCallback< Time, LrWpanPhyEnumeration, LrWpanPhyEnumeration > m_trxStateLogger
The trace source fired when the phy layer changes the transceiver state.
void StartRx(Ptr< SpectrumSignalParameters > params) override
Notify the SpectrumPhy instance of an incoming waveform.
LrWpanPhy()
Default constructor.
void PlmeCcaRequest()
IEEE 802.15.4-2006 section 6.2.2.1 PLME-CCA.request Perform a CCA per section 6.9....
void SetDevice(Ptr< NetDevice > d) override
Set the associated NetDevice instance.
void CancelEd(LrWpanPhyEnumeration state)
Cancel an ongoing ED procedure.
void SetAntenna(Ptr< AntennaModel > a)
Set the attached antenna.
double GetRxSensitivity()
Get the receiver power sensitivity used by this device in dBm.
void SetNoisePowerSpectralDensity(Ptr< const SpectrumValue > noisePsd)
Set the noise power spectral density.
Ptr< Object > GetAntenna() const override
Get the AntennaModel used by this SpectrumPhy instance for transmission and/or reception.
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< const SpectrumModel > GetRxSpectrumModel() const override
Smart pointer class similar to boost::intrusive_ptr.
A template-based reference counting class.
Abstract base class for Spectrum-aware PHY layers.
Simulation virtual time values and global simulation resolution.
Forward calls to a chain of Callback.
Trace classes with value semantics.
a unique identifier for an interface.
Callback< void, LrWpanPhyEnumeration > PlmeSetTRXStateConfirmCallback
This method implements the PD SAP: PlmeSetTRXStateConfirm.
LrWpanPhyOption
This Phy option will be used to index various Tables in IEEE802.15.4-2011.
Callback< void, LrWpanPhyEnumeration > PdDataConfirmCallback
This method implements the PD SAP: PdDataConfirm.
LrWpanPhyEnumeration
IEEE802.15.4-2006 PHY Emumerations Table 18 in section 6.2.3.
Callback< void, LrWpanPhyEnumeration, LrWpanPibAttributeIdentifier, Ptr< LrWpanPhyPibAttributes > > PlmeGetAttributeConfirmCallback
This method implements the PD SAP: PlmeGetAttributeConfirm.
Callback< void, LrWpanPhyEnumeration, uint8_t > PlmeEdConfirmCallback
This method implements the PD SAP: PlmeEdConfirm.
Callback< void, LrWpanPhyEnumeration, LrWpanPibAttributeIdentifier > PlmeSetAttributeConfirmCallback
This method implements the PD SAP: PlmeSetAttributeConfirm.
Callback< void, uint32_t, Ptr< Packet >, uint8_t > PdDataIndicationCallback
This method implements the PD SAP: PdDataIndication.
Callback< void, LrWpanPhyEnumeration > PlmeCcaConfirmCallback
This method implements the PD SAP: PlmeCcaConfirm.
LrWpanPibAttributeIdentifier
IEEE802.15.4-2006 PHY PIB Attribute Identifiers Table 23 in section 6.4.2.
@ IEEE_802_15_4_868MHZ_BPSK
@ IEEE_802_15_4_915MHZ_OQPSK
@ IEEE_802_15_4_868MHZ_ASK
@ IEEE_802_15_4_950MHZ_BPSK
@ IEEE_802_15_4_868MHZ_OQPSK
@ IEEE_802_15_4_780MHZ_OQPSK
@ IEEE_802_15_4_2_4GHZ_OQPSK
@ IEEE_802_15_4_915MHZ_ASK
@ IEEE_802_15_4_915MHZ_BPSK
@ IEEE_802_15_4_INVALID_PHY_OPTION
@ IEEE_802_15_4_PHY_BUSY_RX
@ IEEE_802_15_4_PHY_UNSUPPORTED_ATTRIBUTE
@ IEEE_802_15_4_PHY_SUCCESS
@ IEEE_802_15_4_PHY_UNSPECIFIED
@ IEEE_802_15_4_PHY_TRX_OFF
@ IEEE_802_15_4_PHY_FORCE_TRX_OFF
@ IEEE_802_15_4_PHY_BUSY_TX
@ IEEE_802_15_4_PHY_RX_ON
@ IEEE_802_15_4_PHY_TX_ON
@ IEEE_802_15_4_PHY_INVALID_PARAMETER
@ IEEE_802_15_4_PHY_READ_ONLY
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Helper structure to manage the power measurement during ED.
double averagePower
Average measured power.
Time lastUpdate
Last update time.
Time measurementLength
Total measurement period.
This data structure provides the Bit rate and Symbol rate for a given channel See IEEE802....
double symbolRate
symbol rate
IEEE802.15.4-2006 PHY PIB Attributes Table 23 in section 6.4.2.
uint32_t phyChannelsSupported[32]
BitField representing the available channels supported by a 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...
uint8_t phyCCAMode
CCA mode.
uint8_t phyCurrentPage
Current channel page.
double phySymbolsPerOctet
The number of symbols per octet.
uint8_t phyCurrentChannel
The RF channel to use.
uint32_t phySHRDuration
The duration of the synchronization header (SHR) in symbols.
uint32_t phyMaxFrameDuration
The maximum number of symbols in a frame.