A Discrete-Event Network Simulator
API
lte-spectrum-phy.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 CTTC
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: Nicola Baldo <nbaldo@cttc.es>
19  * Giuseppe Piro <g.piro@poliba.it>
20  * Modified by: Marco Miozzo <mmiozzo@cttc.es> (introduce physical error model)
21  */
22 
23 #ifndef LTE_SPECTRUM_PHY_H
24 #define LTE_SPECTRUM_PHY_H
25 
26 #include <ns3/event-id.h>
27 #include <ns3/spectrum-value.h>
28 #include <ns3/mobility-model.h>
29 #include <ns3/packet.h>
30 #include <ns3/nstime.h>
31 #include <ns3/net-device.h>
32 #include <ns3/spectrum-phy.h>
33 #include <ns3/spectrum-channel.h>
34 #include <ns3/spectrum-interference.h>
35 #include <ns3/data-rate.h>
36 #include <ns3/generic-phy.h>
37 #include <ns3/packet-burst.h>
38 #include <ns3/lte-interference.h>
39 #include "ns3/random-variable-stream.h"
40 #include <map>
41 #include <ns3/ff-mac-common.h>
42 #include <ns3/lte-harq-phy.h>
43 #include <ns3/lte-common.h>
44 
45 namespace ns3 {
46 
47 struct TbId_t
48 {
49  uint16_t m_rnti;
50  uint8_t m_layer;
51 
52  public:
53  TbId_t ();
54  TbId_t (const uint16_t a, const uint8_t b);
55 
56  friend bool operator == (const TbId_t &a, const TbId_t &b);
57  friend bool operator < (const TbId_t &a, const TbId_t &b);
58 };
59 
60 
61 struct tbInfo_t
62 {
63  uint8_t ndi;
64  uint16_t size;
65  uint8_t mcs;
66  std::vector<int> rbBitmap;
67  uint8_t harqProcessId;
68  uint8_t rv;
69  double mi;
70  bool downlink;
71  bool corrupt;
73 };
74 
75 typedef std::map<TbId_t, tbInfo_t> expectedTbs_t;
76 
77 
78 class LteNetDevice;
79 class AntennaModel;
80 class LteControlMessage;
84 
85 
93 
106 
107 
116 
123 
129 
130 
136 
142 
143 
144 
154 {
155 
156 public:
157  LteSpectrumPhy ();
158  virtual ~LteSpectrumPhy ();
159 
163  enum State
164  {
166  };
167 
168  // inherited from Object
169  static TypeId GetTypeId (void);
170  virtual void DoDispose ();
171 
172  // inherited from SpectrumPhy
175  void SetDevice (Ptr<NetDevice> d);
177  Ptr<NetDevice> GetDevice () const;
184 
185  void SetHarqPhyModule (Ptr<LteHarqPhy> harq);
186 
193 
200 
205  void Reset ();
206 
212  void SetAntenna (Ptr<AntennaModel> a);
213 
225  bool StartTxDataFrame (Ptr<PacketBurst> pb, std::list<Ptr<LteControlMessage> > ctrlMsgList, Time duration);
226 
237  bool StartTxDlCtrlFrame (std::list<Ptr<LteControlMessage> > ctrlMsgList, bool pss);
238 
239 
246  bool StartTxUlSrsFrame ();
247 
248 
255  void SetLtePhyTxEndCallback (LtePhyTxEndCallback c);
256 
263  void SetLtePhyRxDataEndErrorCallback (LtePhyRxDataEndErrorCallback c);
264 
271  void SetLtePhyRxDataEndOkCallback (LtePhyRxDataEndOkCallback c);
272 
279  void SetLtePhyRxCtrlEndOkCallback (LtePhyRxCtrlEndOkCallback c);
280 
287  void SetLtePhyRxCtrlEndErrorCallback (LtePhyRxCtrlEndErrorCallback c);
288 
295  void SetLtePhyRxPssCallback (LtePhyRxPssCallback c);
296 
303  void SetLtePhyDlHarqFeedbackCallback (LtePhyDlHarqFeedbackCallback c);
304 
311  void SetLtePhyUlHarqFeedbackCallback (LtePhyUlHarqFeedbackCallback c);
312 
317  void SetState (State newState);
318 
324  void SetCellId (uint16_t cellId);
325 
326 
334 
342 
349 
357 
365 
366 
373 
386  void AddExpectedTb (uint16_t rnti, uint8_t ndi, uint16_t size, uint8_t mcs, std::vector<int> map, uint8_t layer, uint8_t harqId, uint8_t rv, bool downlink);
387 
388 
394  void UpdateSinrPerceived (const SpectrumValue& sinr);
395 
401  void SetTransmissionMode (uint8_t txMode);
402 
403 
409 
410  friend class LteUePhy;
411 
420  int64_t AssignStreams (int64_t stream);
421 
422 private:
423  void ChangeState (State newState);
424  void EndTxData ();
425  void EndTxDlCtrl ();
426  void EndTxUlSrs ();
427  void EndRxData ();
428  void EndRxDlCtrl ();
429  void EndRxUlSrs ();
430 
431  void SetTxModeGain (uint8_t txMode, double gain);
432 
433 
437 
439 
443  std::list<Ptr<PacketBurst> > m_rxPacketBurstList;
444 
445  std::list<Ptr<LteControlMessage> > m_txControlMessageList;
446  std::list<Ptr<LteControlMessage> > m_rxControlMessageList;
447 
448 
452 
458 
459  LtePhyRxDataEndErrorCallback m_ltePhyRxDataEndErrorCallback;
460  LtePhyRxDataEndOkCallback m_ltePhyRxDataEndOkCallback;
461 
462  LtePhyRxCtrlEndOkCallback m_ltePhyRxCtrlEndOkCallback;
463  LtePhyRxCtrlEndErrorCallback m_ltePhyRxCtrlEndErrorCallback;
464  LtePhyRxPssCallback m_ltePhyRxPssCallback;
465 
468 
469  uint16_t m_cellId;
470 
471  expectedTbs_t m_expectedTbs;
473 
476  bool m_dataErrorModelEnabled; // when true (default) the phy error model is enabled
477  bool m_ctrlErrorModelEnabled; // when true (default) the phy error model is enabled for DL ctrl frame
478 
479  uint8_t m_transmissionMode; // for UEs: store the transmission mode
480  uint8_t m_layersNum;
481  std::vector <double> m_txModeGain; // duplicate value of LteUePhy
482 
484  LtePhyDlHarqFeedbackCallback m_ltePhyDlHarqFeedbackCallback;
485  LtePhyUlHarqFeedbackCallback m_ltePhyUlHarqFeedbackCallback;
486 
487 
493 
494 
500 
505 
506 
507 };
508 
509 
510 
511 
512 
513 
514 }
515 
516 #endif /* LTE_SPECTRUM_PHY_H */
Ptr< LteHarqPhy > m_harqPhyModule
void SetLtePhyTxEndCallback(LtePhyTxEndCallback c)
set the callback for the end of a TX, as part of the interconnections between the PHY and the MAC ...
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
void StartRxData(Ptr< LteSpectrumSignalParametersDataFrame > params)
Abstract base class for Spectrum-aware PHY layers.
Definition: spectrum-phy.h:45
Ptr< LteInterference > m_interferenceCtrl
LtePhyRxCtrlEndOkCallback m_ltePhyRxCtrlEndOkCallback
Callback template class.
Definition: callback.h:1176
TracedCallback< Ptr< const PacketBurst > > m_phyTxEndTrace
The LteControlMessage provides a basic implementations for control messages (such as PDCCH allocation...
void AddDataSinrChunkProcessor(Ptr< LteChunkProcessor > p)
void SetState(State newState)
Set the state of the phy layer.
Forward calls to a chain of Callback.
void StartRxUlSrs(Ptr< LteSpectrumSignalParametersUlSrsFrame > lteUlSrsRxParams)
TracedCallback< Ptr< const Packet > > m_phyRxEndErrorTrace
void SetLtePhyRxDataEndErrorCallback(LtePhyRxDataEndErrorCallback c)
set the callback for the end of a RX in error, as part of the interconnections between the PHY and th...
void SetTxModeGain(uint8_t txMode, double gain)
LtePhyRxCtrlEndErrorCallback m_ltePhyRxCtrlEndErrorCallback
void SetTransmissionMode(uint8_t txMode)
Ptr< SpectrumChannel > m_channel
std::list< Ptr< LteControlMessage > > m_txControlMessageList
Callback< void, UlInfoListElement_s > LtePhyUlHarqFeedbackCallback
This method is used by the LteSpectrumPhy to notify the PHY about the status of a certain UL HARQ pro...
expectedTbs_t m_expectedTbs
Signal parameters for Lte Data Frame (PDSCH), and eventually after some control messages through othe...
Ptr< LteInterference > m_interferenceData
Callback< void > LtePhyRxCtrlEndErrorCallback
This method is used by the LteSpectrumPhy to notify the PHY that a previously started RX of a control...
Ptr< SpectrumChannel > GetChannel()
uint8_t harqProcessId
LtePhyRxDataEndErrorCallback m_ltePhyRxDataEndErrorCallback
void AddCtrlSinrChunkProcessor(Ptr< LteChunkProcessor > p)
void SetNoisePowerSpectralDensity(Ptr< const SpectrumValue > noisePsd)
set the noise power spectral density
Ptr< UniformRandomVariable > m_random
Provides uniform random variables.
void SetDevice(Ptr< NetDevice > d)
Set the associated NetDevice instance.
std::list< Ptr< PacketBurst > > m_rxPacketBurstList
Callback< void, std::list< Ptr< LteControlMessage > > > LtePhyRxCtrlEndOkCallback
This method is used by the LteSpectrumPhy to notify the PHY that a previously started RX of a control...
void AddInterferenceCtrlChunkProcessor(Ptr< LteChunkProcessor > p)
LteChunkProcessor devoted to evaluate interference + noise power in control symbols of the subframe...
void SetLtePhyUlHarqFeedbackCallback(LtePhyUlHarqFeedbackCallback c)
set the callback for the UL HARQ feedback as part of the interconnections between the LteSpectrumPhy ...
void ChangeState(State newState)
std::list< Ptr< LteControlMessage > > m_rxControlMessageList
void SetLtePhyRxCtrlEndOkCallback(LtePhyRxCtrlEndOkCallback c)
set the callback for the successful end of a RX ctrl frame, as part of the interconnections between t...
void SetTxPowerSpectralDensity(Ptr< SpectrumValue > txPsd)
set the Power Spectral Density of outgoing signals in W/Hz.
void SetLtePhyRxCtrlEndErrorCallback(LtePhyRxCtrlEndErrorCallback c)
set the callback for the erroneous end of a RX ctrl frame, as part of the interconnections between th...
friend bool operator==(const TbId_t &a, const TbId_t &b)
Ptr< AntennaModel > m_antenna
TracedCallback< Ptr< const PacketBurst > > m_phyRxStartTrace
LtePhyRxDataEndOkCallback m_ltePhyRxDataEndOkCallback
void AddDataPowerChunkProcessor(Ptr< LteChunkProcessor > p)
bool StartTxDataFrame(Ptr< PacketBurst > pb, std::list< Ptr< LteControlMessage > > ctrlMsgList, Time duration)
Start a transmission of data frame in DL and UL.
std::map< TbId_t, tbInfo_t > expectedTbs_t
Ptr< MobilityModel > m_mobility
void SetHarqPhyModule(Ptr< LteHarqPhy > harq)
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
#define list
virtual void DoDispose()
Destructor implementation.
Ptr< SpectrumValue > m_txPsd
friend bool operator<(const TbId_t &a, const TbId_t &b)
void SetAntenna(Ptr< AntennaModel > a)
set the AntennaModel to be used
uint16_t m_rnti
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< void, uint16_t, Ptr< SpectrumValue > > LtePhyRxPssCallback
This method is used by the LteSpectrumPhy to notify the UE PHY that a PSS has been received...
void AddExpectedTb(uint16_t rnti, uint8_t ndi, uint16_t size, uint8_t mcs, std::vector< int > map, uint8_t layer, uint8_t harqId, uint8_t rv, bool downlink)
Ptr< const SpectrumModel > GetRxSpectrumModel() const
Ptr< AntennaModel > GetRxAntenna()
Get the AntennaModel used by the NetDevice for reception.
Ptr< MobilityModel > GetMobility()
Get the associated MobilityModel instance.
Ptr< const SpectrumModel > m_rxSpectrumModel
Signal parameters for Lte DL Ctrl Frame (RS, PCFICH and PDCCH)
LtePhyDlHarqFeedbackCallback m_ltePhyDlHarqFeedbackCallback
Ptr< PacketBurst > m_txPacketBurst
void SetChannel(Ptr< SpectrumChannel > c)
Set the channel attached to this device.
void AddInterferenceDataChunkProcessor(Ptr< LteChunkProcessor > p)
LteChunkProcessor devoted to evaluate interference + noise power in data symbols of the subframe...
void Reset()
reset the internal state
TracedCallback< PhyReceptionStatParameters > m_ulPhyReception
Trace information regarding PHY stats from UL Rx perspective PhyReceptionStatParameters (see lte-comm...
Ptr< NetDevice > m_device
LtePhyUlHarqFeedbackCallback m_ltePhyUlHarqFeedbackCallback
static TypeId GetTypeId(void)
TracedCallback< Ptr< const Packet > > m_phyRxEndOkTrace
bool StartTxDlCtrlFrame(std::list< Ptr< LteControlMessage > > ctrlMsgList, bool pss)
Start a transmission of control frame in DL.
void SetLtePhyDlHarqFeedbackCallback(LtePhyDlHarqFeedbackCallback c)
set the callback for the DL HARQ feedback as part of the interconnections between the LteSpectrumPhy ...
An identifier for simulation events.
Definition: event-id.h:53
Ptr< NetDevice > GetDevice() const
Get the associated NetDevice instance.
void SetLtePhyRxPssCallback(LtePhyRxPssCallback c)
set the callback for the reception of the PSS as part of the interconnections between the LteSpectrum...
LtePhyRxPssCallback m_ltePhyRxPssCallback
Callback< void, DlInfoListElement_s > LtePhyDlHarqFeedbackCallback
This method is used by the LteSpectrumPhy to notify the PHY about the status of a certain DL HARQ pro...
void SetLtePhyRxDataEndOkCallback(LtePhyRxDataEndOkCallback c)
set the callback for the successful end of a RX, as part of the interconnections between the PHY and ...
void AddRsPowerChunkProcessor(Ptr< LteChunkProcessor > p)
void SetMobility(Ptr< MobilityModel > m)
Set the mobility model associated with this device.
Callback< void, Ptr< Packet > > LtePhyRxDataEndOkCallback
This method is used by the LteSpectrumPhy to notify the PHY that a previously started RX attempt has ...
Callback< void, Ptr< const Packet > > LtePhyTxEndCallback
this method is invoked by the LteSpectrumPhy to notify the PHY that the transmission of a given packe...
The LteSpectrumPhy models the physical layer of LTE.
Definition: lte-ue-phy.h:51
LteNetDevice provides basic implementation for all LTE network devices.
void StartRx(Ptr< SpectrumSignalParameters > params)
Notify the SpectrumPhy instance of an incoming signal.
TracedCallback< Ptr< const PacketBurst > > m_phyTxStartTrace
Set of values corresponding to a given SpectrumModel.
interface for antenna radiation pattern models
Definition: antenna-model.h:44
void StartRxDlCtrl(Ptr< LteSpectrumSignalParametersDlCtrlFrame > lteDlCtrlRxParams)
a unique identifier for an interface.
Definition: type-id.h:58
void UpdateSinrPerceived(const SpectrumValue &sinr)
bool StartTxUlSrsFrame()
Start a transmission of control frame in UL.
void SetCellId(uint16_t cellId)
std::vector< int > rbBitmap
SpectrumValue m_sinrPerceived
std::vector< double > m_txModeGain
TracedCallback< PhyReceptionStatParameters > m_dlPhyReception
Trace information regarding PHY stats from DL Rx perspective PhyReceptionStatParameters (see lte-comm...
The LteSpectrumPhy models the physical layer of LTE.
Callback< void > LtePhyRxDataEndErrorCallback
This method is used by the LteSpectrumPhy to notify the PHY that a previously started RX attempt has ...