A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
lte-spectrum-phy.h
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;
72  bool harqFeedbackSent;
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 
135 
136 
137 
147 {
148 
149 public:
150  LteSpectrumPhy ();
151  virtual ~LteSpectrumPhy ();
152 
156  enum State
157  {
158  IDLE, TX, RX_DATA, RX_CTRL
159  };
160 
161  // inherited from Object
162  static TypeId GetTypeId (void);
163  virtual void DoDispose ();
164 
165  // inherited from SpectrumPhy
168  void SetDevice (Ptr<NetDevice> d);
174  void StartRxData (Ptr<LteSpectrumSignalParametersDataFrame> params);
175  void StartRxCtrl (Ptr<SpectrumSignalParameters> params);
176 
177  void SetHarqPhyModule (Ptr<LteHarqPhy> harq);
178 
185 
192 
197  void Reset ();
198 
204  void SetAntenna (Ptr<AntennaModel> a);
205 
217  bool StartTxDataFrame (Ptr<PacketBurst> pb, std::list<Ptr<LteControlMessage> > ctrlMsgList, Time duration);
218 
229  bool StartTxDlCtrlFrame (std::list<Ptr<LteControlMessage> > ctrlMsgList);
230 
231 
241  bool StartTxUlSrsFrame ();
242 
243 
251 
259 
267 
275 
283 
291 
299 
304  void SetState (State newState);
305 
311  void SetCellId (uint16_t cellId);
312 
313 
321 
328 
336 
337 
344 
357  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);
358 
359 
365  void UpdateSinrPerceived (const SpectrumValue& sinr);
366 
372  void SetTransmissionMode (uint8_t txMode);
373 
374 
380 
381  friend class LteUePhy;
382 
391  int64_t AssignStreams (int64_t stream);
392 
393 private:
394  void ChangeState (State newState);
395  void EndTx ();
396  void EndRxData ();
397  void EndRxDlCtrl ();
398  void EndRxUlSrs ();
399 
400  void SetTxModeGain (uint8_t txMode, double gain);
401 
402 
403  Ptr<MobilityModel> m_mobility;
404  Ptr<AntennaModel> m_antenna;
405  Ptr<NetDevice> m_device;
406 
407  Ptr<SpectrumChannel> m_channel;
408 
409  Ptr<const SpectrumModel> m_rxSpectrumModel;
410  Ptr<SpectrumValue> m_txPsd;
411  Ptr<PacketBurst> m_txPacketBurst;
412  std::list<Ptr<PacketBurst> > m_rxPacketBurstList;
413 
414  std::list<Ptr<LteControlMessage> > m_txControlMessageList;
415  std::list<Ptr<LteControlMessage> > m_rxControlMessageList;
416 
417 
418  State m_state;
419  Time m_firstRxStart;
420  Time m_firstRxDuration;
421 
422  TracedCallback<Ptr<const PacketBurst> > m_phyTxStartTrace;
423  TracedCallback<Ptr<const PacketBurst> > m_phyTxEndTrace;
424  TracedCallback<Ptr<const PacketBurst> > m_phyRxStartTrace;
425  TracedCallback<Ptr<const Packet> > m_phyRxEndOkTrace;
426  TracedCallback<Ptr<const Packet> > m_phyRxEndErrorTrace;
427 
428  LtePhyTxEndCallback m_ltePhyTxEndCallback;
429  LtePhyRxDataEndErrorCallback m_ltePhyRxDataEndErrorCallback;
430  LtePhyRxDataEndOkCallback m_ltePhyRxDataEndOkCallback;
431 
432  LtePhyRxCtrlEndOkCallback m_ltePhyRxCtrlEndOkCallback;
433  LtePhyRxCtrlEndErrorCallback m_ltePhyRxCtrlEndErrorCallback;
434 
435  Ptr<LteInterference> m_interferenceData;
436  Ptr<LteInterference> m_interferenceCtrl;
437 
438  uint16_t m_cellId;
439 
440  expectedTbs_t m_expectedTbs;
441  SpectrumValue m_sinrPerceived;
442 
445  bool m_dataErrorModelEnabled; // when true (default) the phy error model is enabled
446  bool m_ctrlErrorModelEnabled; // when true (default) the phy error model is enabled for DL ctrl frame
447 
448  uint8_t m_transmissionMode; // for UEs: store the transmission mode
449  uint8_t m_layersNum;
450  std::vector <double> m_txModeGain; // duplicate value of LteUePhy
451 
452  Ptr<LteHarqPhy> m_harqPhyModule;
453  LtePhyDlHarqFeedbackCallback m_ltePhyDlHarqFeedbackCallback;
454  LtePhyUlHarqFeedbackCallback m_ltePhyUlHarqFeedbackCallback;
455 
456 
462 
463 
469 
470  EventId m_endTxEvent;
471  EventId m_endRxDataEvent;
472  EventId m_endRxDlCtrlEvent;
473  EventId m_endRxUlSrsEvent;
474 
475 
476 };
477 
478 
479 
480 
481 
482 
483 }
484 
485 #endif /* LTE_SPECTRUM_PHY_H */
void SetLtePhyTxEndCallback(LtePhyTxEndCallback c)
keep track of time unit.
Definition: nstime.h:149
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
Callback template class.
Definition: callback.h:369
void SetState(State newState)
Set the state of the phy layer.
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
void SetLtePhyRxDataEndErrorCallback(LtePhyRxDataEndErrorCallback c)
void SetTransmissionMode(uint8_t txMode)
Callback< void, UlInfoListElement_s > LtePhyUlHarqFeedbackCallback
Callback< void > LtePhyRxCtrlEndErrorCallback
Ptr< SpectrumChannel > GetChannel()
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)
Callback< void, std::list< Ptr< LteControlMessage > > > LtePhyRxCtrlEndOkCallback
void SetLtePhyUlHarqFeedbackCallback(LtePhyUlHarqFeedbackCallback c)
void SetLtePhyRxCtrlEndOkCallback(LtePhyRxCtrlEndOkCallback c)
void SetTxPowerSpectralDensity(Ptr< SpectrumValue > txPsd)
void SetLtePhyRxCtrlEndErrorCallback(LtePhyRxCtrlEndErrorCallback c)
bool StartTxDataFrame(Ptr< PacketBurst > pb, std::list< Ptr< LteControlMessage > > ctrlMsgList, Time duration)
int64_t AssignStreams(int64_t stream)
virtual void DoDispose()
Ptr< NetDevice > GetDevice()
void SetAntenna(Ptr< AntennaModel > a)
void AddRsPowerChunkProcessor(Ptr< LteSinrChunkProcessor > p)
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()
Ptr< MobilityModel > GetMobility()
bool StartTxDlCtrlFrame(std::list< Ptr< LteControlMessage > > ctrlMsgList)
void SetChannel(Ptr< SpectrumChannel > c)
TracedCallback< PhyReceptionStatParameters > m_ulPhyReception
void SetLtePhyDlHarqFeedbackCallback(LtePhyDlHarqFeedbackCallback c)
an identifier for simulation events.
Definition: event-id.h:46
void AddCtrlSinrChunkProcessor(Ptr< LteSinrChunkProcessor > p)
void AddDataSinrChunkProcessor(Ptr< LteSinrChunkProcessor > p)
Callback< void, DlInfoListElement_s > LtePhyDlHarqFeedbackCallback
void SetLtePhyRxDataEndOkCallback(LtePhyRxDataEndOkCallback c)
void SetMobility(Ptr< MobilityModel > m)
Callback< void, Ptr< Packet > > LtePhyRxDataEndOkCallback
void AddInterferenceChunkProcessor(Ptr< LteSinrChunkProcessor > p)
Callback< void, Ptr< const Packet > > LtePhyTxEndCallback
void StartRx(Ptr< SpectrumSignalParameters > params)
Set of values corresponding to a given SpectrumModel.
interface for antenna radiation pattern models
Definition: antenna-model.h:44
a unique identifier for an interface.
Definition: type-id.h:44
void UpdateSinrPerceived(const SpectrumValue &sinr)
void SetCellId(uint16_t cellId)
TracedCallback< PhyReceptionStatParameters > m_dlPhyReception
Callback< void > LtePhyRxDataEndErrorCallback