A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
lr-wpan-phy.h
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 The Boeing Company
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author:
19  * Gary Pei <guangyu.pei@boeing.com>
20  * Sascha Alexander Jopen <jopen@cs.uni-bonn.de>
21  */
22 #ifndef LR_WPAN_PHY_H
23 #define LR_WPAN_PHY_H
24 
26 
27 #include <ns3/spectrum-phy.h>
28 #include <ns3/traced-callback.h>
29 #include <ns3/event-id.h>
30 
31 namespace ns3 {
32 
33 class Packet;
34 class SpectrumValue;
35 class LrWpanErrorModel;
36 struct LrWpanSpectrumSignalParameters;
37 class MobilityModel;
38 class SpectrumChannel;
39 class SpectrumModel;
40 class AntennaModel;
41 class NetDevice;
42 class UniformRandomVariable;
43 
47 typedef struct
48 {
49  double averagePower;
53 
57 typedef struct
58 {
59  double bitRate;
60  double symbolRate;
62 
67 typedef struct
68 {
69  double shrPreamble;
70  double shrSfd;
71  double phr;
73 
77 typedef enum
78 {
88 
93 typedef enum
94 {
107  IEEE_802_15_4_PHY_UNSPECIFIED = 0xc // all cases not covered by ieee802.15.4
109 
113 typedef enum
114 {
118  phyCCAMode = 0x03,
124 
128 typedef struct
129 {
131  uint32_t phyChannelsSupported[32];
133  uint8_t phyCCAMode;
134  uint32_t phyCurrentPage;
136  uint32_t phySHRDuration;
139 
148 
155 
162 
170 
178 typedef Callback< void, LrWpanPhyEnumeration,
181 
188 
195 typedef Callback< void, LrWpanPhyEnumeration,
197 
204 class LrWpanPhy : public SpectrumPhy
205 {
206 
207 public:
213  static TypeId GetTypeId (void);
214 
219  static const uint32_t aMaxPhyPacketSize;
220 
226  static const uint32_t aTurnaroundTime;
227 
231  LrWpanPhy (void);
232  virtual ~LrWpanPhy (void);
233 
234  // inherited from SpectrumPhy
238 
245  void SetDevice (Ptr<NetDevice> d);
246  Ptr<NetDevice> GetDevice (void);
247 
253  void SetAntenna (Ptr<AntennaModel> a);
255  virtual Ptr<const SpectrumModel> GetRxSpectrumModel (void) const;
256 
263 
271 
278 
284  virtual void StartRx (Ptr<SpectrumSignalParameters> params);
285 
293  void PdDataRequest (const uint32_t psduLength, Ptr<Packet> p);
294 
300  void PlmeCcaRequest (void);
301 
307  void PlmeEdRequest (void);
308 
316 
324 
333 
341 
349 
357 
365 
373 
381 
389 
395  double GetDataOrSymbolRate (bool isData);
396 
403 
410 
417  uint64_t GetPhySHRDuration (void) const;
418 
425  double GetPhySymbolsPerOctet (void) const;
426 
434  int64_t AssignStreams (int64_t stream);
435 
436 protected:
447 
448 private:
452  typedef std::pair<Ptr<Packet>, bool> PacketAndStatus;
453 
454  // Inherited from Object.
455  virtual void DoDispose (void);
456 
462  void ChangeTrxState (LrWpanPhyEnumeration newState);
463 
468  void SetMyPhyOption (void);
469 
477 
483  void EndTx (void);
484 
489  void CheckInterference (void);
490 
502 
510  void CancelEd (LrWpanPhyEnumeration state);
511 
516  void EndEd (void);
517 
522  void EndCca (void);
523 
528  void EndSetTRXState (void);
529 
538 
543  Time GetPpduHeaderTxTime (void);
544 
551  bool ChannelSupported (uint8_t channel);
552 
559  bool PhyIsBusy (void) const;
560 
561  // Trace sources
569 
577 
585 
593 
601 
608 
615 
620 
625 
630 
635 
640 
645 
651 
652  // State variables
657 
663 
664  // Callbacks
670 
676 
682 
688 
694 
700 
706 
711 
716 
721 
726 
733 
738 
745  std::pair<Ptr<LrWpanSpectrumSignalParameters>, bool> m_currentRxPacket;
746 
754 
759 
764 
769 
774 
779 };
780 
781 
782 } // namespace ns3
783 
784 #endif /* LR_WPAN_PHY_H */
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:79
Callback< void, LrWpanPhyEnumeration, uint8_t > PlmeEdConfirmCallback
This method implements the PD SAP: PlmeEdConfirm.
Definition: lr-wpan-phy.h:169
void SetPlmeSetTRXStateConfirmCallback(PlmeSetTRXStateConfirmCallback c)
set the callback for the end of an SetTRXState, as part of the interconnections betweenthe PHY and th...
Definition: lr-wpan-phy.cc:981
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:584
Abstract base class for Spectrum-aware PHY layers.
Definition: spectrum-phy.h:45
Make LrWpanPhy a SpectrumPhy so we can enable the eventual modeling of device interference.
Definition: lr-wpan-phy.h:204
Callback template class.
Definition: callback.h:924
static const uint32_t aTurnaroundTime
The turnaround time for switching the transceiver from RX to TX or vice versa.
Definition: lr-wpan-phy.h:226
void SetPdDataConfirmCallback(PdDataConfirmCallback c)
set the callback for the end of a TX, as part of the interconnections betweenthe PHY and the MAC...
Definition: lr-wpan-phy.cc:953
LrWpanPhyOption GetMyPhyOption(void)
Get the currently configured PHY option.
Ptr< UniformRandomVariable > m_random
Uniform random variable stream.
Definition: lr-wpan-phy.h:778
PdDataConfirmCallback m_pdDataConfirmCallback
This callback is used to report packet transmission status to the MAC layer.
Definition: lr-wpan-phy.h:675
void SetPdDataIndicationCallback(PdDataIndicationCallback c)
set the callback for the end of a RX, as part of the interconnections betweenthe PHY and the MAC...
Definition: lr-wpan-phy.cc:946
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
void SetPlmeCcaConfirmCallback(PlmeCcaConfirmCallback c)
set the callback for the end of a CCA, as part of the interconnections betweenthe PHY and the MAC...
Definition: lr-wpan-phy.cc:960
PlmeEdConfirmCallback m_plmeEdConfirmCallback
This callback is used to report ED status to the MAC.
Definition: lr-wpan-phy.h:687
void SetDevice(Ptr< NetDevice > d)
set the associated NetDevice instance
Definition: lr-wpan-phy.cc:198
void SetPlmeEdConfirmCallback(PlmeEdConfirmCallback c)
set the callback for the end of an ED, as part of the interconnections betweenthe PHY and the MAC...
Definition: lr-wpan-phy.cc:967
LrWpanEdPower m_edPower
Helper value for tracking the average power during ED.
Definition: lr-wpan-phy.h:715
LrWpanPhyEnumeration m_trxState
The current transceiver state.
Definition: lr-wpan-phy.h:656
void ChangeTrxState(LrWpanPhyEnumeration newState)
Change the PHY state to the given new state, firing the state change trace.
Definition: lr-wpan-phy.cc:995
bool PhyIsBusy(void) const
Check if the PHY is busy, which is the case if the PHY is currently sending or receiving a frame...
PacketAndStatus m_currentTxPacket
Statusinformation of the currently transmitted packet.
Definition: lr-wpan-phy.h:753
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:592
PlmeGetAttributeConfirmCallback m_plmeGetAttributeConfirmCallback
This callback is used to report requested attribute values back to the MAC.
Definition: lr-wpan-phy.h:693
void EndSetTRXState(void)
Called after applying a deferred transceiver state switch.
Ptr< SpectrumValue > m_txPsd
The transmit power spectral density.
Definition: lr-wpan-phy.h:639
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:607
IEEE802.15.4-2006 Figure 16, Table 19 and 20 in section 6.3 this data structure provides number of sy...
Definition: lr-wpan-phy.h:67
IEEE802.15.4-2006 PHY PIB Attributes Table 23 in section 6.4.2.
Definition: lr-wpan-phy.h:128
static const LrWpanPhyPpduHeaderSymbolNumber ppduHeaderSymbolNumbers[7]
The preamble, SFD, and PHR lengths in symbols for the different PHY options.
Definition: lr-wpan-phy.h:446
double m_rxSensitivity
The receiver sensitivity.
Definition: lr-wpan-phy.h:725
double GetDataOrSymbolRate(bool isData)
implement PLME SetAttribute confirm SAP
TracedCallback< Time, LrWpanPhyEnumeration, LrWpanPhyEnumeration > m_trxStateLogger
The trace source fired when the phy layer changes the transceiver state.
Definition: lr-wpan-phy.h:614
Callback< void, LrWpanPhyEnumeration > PlmeCcaConfirmCallback
This method implements the PD SAP: PlmeCcaConfirm.
Definition: lr-wpan-phy.h:161
PlmeSetTRXStateConfirmCallback m_plmeSetTRXStateConfirmCallback
This callback is used to report transceiver state change status to the MAC.
Definition: lr-wpan-phy.h:699
Ptr< NetDevice > GetDevice(void)
get the associated NetDevice instance
Definition: lr-wpan-phy.cc:182
Callback< void, LrWpanPhyEnumeration > PlmeSetTRXStateConfirmCallback
This method implements the PD SAP: PlmeSetTRXStateConfirm.
Definition: lr-wpan-phy.h:187
static const uint32_t aMaxPhyPacketSize
The maximum packet size accepted by the PHY.
Definition: lr-wpan-phy.h:219
static TypeId GetTypeId(void)
Get the type ID.
Definition: lr-wpan-phy.cc:74
void SetPlmeSetAttributeConfirmCallback(PlmeSetAttributeConfirmCallback c)
set the callback for the end of an SetAttribute, as part of the interconnections betweenthe PHY and t...
Definition: lr-wpan-phy.cc:988
Ptr< SpectrumChannel > m_channel
The channel attached to this transceiver.
Definition: lr-wpan-phy.h:629
void SetChannel(Ptr< SpectrumChannel > c)
Set the channel attached to this device.
Definition: lr-wpan-phy.cc:214
static const LrWpanPhyDataAndSymbolRates dataSymbolRates[7]
The data and symbol rates for the different PHY options.
Definition: lr-wpan-phy.h:441
void SetPlmeGetAttributeConfirmCallback(PlmeGetAttributeConfirmCallback c)
set the callback for the end of an GetAttribute, as part of the interconnections betweenthe PHY and t...
Definition: lr-wpan-phy.cc:974
LrWpanPhyEnumeration m_trxStatePending
The next pending state to applied after the current action of the PHY is completed.
Definition: lr-wpan-phy.h:662
void SetErrorModel(Ptr< LrWpanErrorModel > e)
set the error model to use
double m_ccaPeakPower
Helper value for the peak power value during CCA.
Definition: lr-wpan-phy.h:720
Ptr< LrWpanErrorModel > GetErrorModel(void) const
get the error model in use
Time GetPpduHeaderTxTime(void)
Calculate the time required for sending the PPDU header, that is the preamble, SFD and PHR...
Ptr< const SpectrumValue > GetNoisePowerSpectralDensity(void)
Get the noise power spectral density.
Ptr< LrWpanInterferenceHelper > m_signal
The accumulated signals currently received by the transceiver, including the signal of a possibly rec...
Definition: lr-wpan-phy.h:732
void SetMyPhyOption(void)
Configure the PHY option according to the current channel and channel page.
virtual Ptr< const SpectrumModel > GetRxSpectrumModel(void) const
Definition: lr-wpan-phy.cc:230
Ptr< AntennaModel > m_antenna
The antenna used by the transceiver.
Definition: lr-wpan-phy.h:634
void SetTxPowerSpectralDensity(Ptr< SpectrumValue > txPsd)
Set the Power Spectral Density of outgoing signals in W/Hz.
Time m_rxLastUpdate
Timestamp of the last calculation of the PER of a packet currently received.
Definition: lr-wpan-phy.h:737
void SetAntenna(Ptr< AntennaModel > a)
Set the attached antenna.
Definition: lr-wpan-phy.cc:251
Ptr< const SpectrumValue > m_noise
The spectral density for for the noise.
Definition: lr-wpan-phy.h:644
EventId m_setTRXState
Scheduler event of a currently running deferred transceiver state switch.
Definition: lr-wpan-phy.h:768
Ptr< NetDevice > m_device
The configured net device.
Definition: lr-wpan-phy.h:624
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...
Definition: lr-wpan-phy.cc:603
LrWpanPhy(void)
Default constructor.
Definition: lr-wpan-phy.cc:104
Ptr< SpectrumChannel > GetChannel(void)
Get the currently attached channel.
Definition: lr-wpan-phy.cc:222
void EndRx(Ptr< LrWpanSpectrumSignalParameters > params)
Finish the reception of a frame.
Definition: lr-wpan-phy.cc:405
Ptr< MobilityModel > GetMobility(void)
get the associated MobilityModel instance
Definition: lr-wpan-phy.cc:190
EventId m_edRequest
Scheduler event of a currently running ED request.
Definition: lr-wpan-phy.h:763
Callback< void, LrWpanPhyEnumeration, LrWpanPibAttributeIdentifier > PlmeSetAttributeConfirmCallback
This method implements the PD SAP: PlmeSetAttributeConfirm.
Definition: lr-wpan-phy.h:196
std::pair< Ptr< Packet >, bool > PacketAndStatus
The second is true if the first is flagged as error/invalid.
Definition: lr-wpan-phy.h:452
std::pair< Ptr< LrWpanSpectrumSignalParameters >, bool > m_currentRxPacket
Statusinformation of the currently received packet.
Definition: lr-wpan-phy.h:745
Ptr< MobilityModel > m_mobility
The mobility model used by the PHY.
Definition: lr-wpan-phy.h:619
LrWpanPhyOption m_phyOption
The currently configured PHY type.
Definition: lr-wpan-phy.h:710
void EndCca(void)
Called at the end of the CCA.
void PlmeSetTRXStateRequest(LrWpanPhyEnumeration state)
IEEE 802.15.4-2006 section 6.2.2.7 PLME-SET-TRX-STATE.request Set PHY state.
Definition: lr-wpan-phy.cc:638
bool ChannelSupported(uint8_t channel)
Check if the given channel is supported by the PHY.
Definition: lr-wpan-phy.cc:826
void SetMobility(Ptr< MobilityModel > m)
Set the mobility model associated with this device.
Definition: lr-wpan-phy.cc:206
PdDataIndicationCallback m_pdDataIndicationCallback
This callback is used to notify incoming packets to the MAC layer.
Definition: lr-wpan-phy.h:669
PlmeSetAttributeConfirmCallback m_plmeSetAttributeConfirmCallback
This callback is used to report attribute set results back to the MAC.
Definition: lr-wpan-phy.h:705
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:576
Ptr< AntennaModel > GetRxAntenna(void)
get the AntennaModel used by the NetDevice for reception
Definition: lr-wpan-phy.cc:244
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:568
void EndTx(void)
Finish the transmission of a frame.
EventId m_ccaRequest
Scheduler event of a currently running CCA request.
Definition: lr-wpan-phy.h:758
Helper structure to manage the power measurement during ED.
Definition: lr-wpan-phy.h:47
void CheckInterference(void)
Check if the interference destroys a frame currently received.
Definition: lr-wpan-phy.cc:359
double GetPhySymbolsPerOctet(void) const
Get the number of symbols per octet, depending on the currently selected channel. ...
virtual ~LrWpanPhy(void)
Definition: lr-wpan-phy.cc:149
EventId m_pdDataRequest
Scheduler event of a currently running data transmission request.
Definition: lr-wpan-phy.h:773
PlmeCcaConfirmCallback m_plmeCcaConfirmCallback
This callback is used to report CCA status to the MAC or CSMA/CA.
Definition: lr-wpan-phy.h:681
an identifier for simulation events.
Definition: event-id.h:46
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
void SetNoisePowerSpectralDensity(Ptr< const SpectrumValue > noisePsd)
Set the noise power spectral density.
LrWpanPhyPibAttributes m_phyPIBAttributes
Definition: lr-wpan-phy.h:650
virtual void StartRx(Ptr< SpectrumSignalParameters > params)
Notify the SpectrumPhy instance of an incoming waveform.
Definition: lr-wpan-phy.cc:258
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:600
Callback< void, LrWpanPhyEnumeration > PdDataConfirmCallback
This method implements the PD SAP: PdDataConfirm.
Definition: lr-wpan-phy.h:154
void EndEd(void)
Called at the end of the ED procedure.
void PlmeSetAttributeRequest(LrWpanPibAttributeIdentifier id, LrWpanPhyPibAttributes *attribute)
IEEE 802.15.4-2006 section 6.2.2.9 PLME-SET.request Set attributes per definition from Table 23 in se...
Definition: lr-wpan-phy.cc:844
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:475
LrWpanPhyOption
This Phy option will be used to index various Tables in IEEE802.15.4-2006.
Definition: lr-wpan-phy.h:77
Callback< void, LrWpanPhyEnumeration, LrWpanPibAttributeIdentifier, LrWpanPhyPibAttributes * > PlmeGetAttributeConfirmCallback
This method implements the PD SAP: PlmeGetAttributeConfirm.
Definition: lr-wpan-phy.h:180
Time CalculateTxTime(Ptr< const Packet > packet)
Calculate the time required for sending the given packet, including preamble, SFD and PHR...
void PlmeCcaRequest(void)
IEEE 802.15.4-2006 section 6.2.2.1 PLME-CCA.request Perform a CCA per section 6.9.9.
Definition: lr-wpan-phy.cc:549
void PlmeEdRequest(void)
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:576
void CancelEd(LrWpanPhyEnumeration state)
Cancel an ongoing ED procedure.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: lr-wpan-phy.cc:154
IEEE802.15.4-2006 Table 1 and 2 in section 6.1.1 and 6.1.2.
Definition: lr-wpan-phy.h:57
uint64_t GetPhySHRDuration(void) const
Get the duration of the SHR (preamble and SFD) in symbols, depending on the currently selected channe...
Ptr< LrWpanErrorModel > m_errorModel
The error model describing the bit and packet error rates.
Definition: lr-wpan-phy.h:649
a unique identifier for an interface.
Definition: type-id.h:49
Callback< void, uint32_t, Ptr< Packet >, uint8_t > PdDataIndicationCallback
This method implements the PD SAP: PdDataIndication.
Definition: lr-wpan-phy.h:147
LrWpanPhyEnumeration
IEEE802.15.4-2006 PHY Emumerations Table 18 in section 6.2.3.
Definition: lr-wpan-phy.h:93
LrWpanPibAttributeIdentifier
IEEE802.15.4-2006 PHY PIB Attribute Identifiers Table 23 in section 6.4.2.
Definition: lr-wpan-phy.h:113