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 */ 20 21 22 #ifndef LTE_INTERFERENCE_H 23 #define LTE_INTERFERENCE_H 24 25 #include <ns3/object.h> 26 #include <ns3/packet.h> 27 #include <ns3/nstime.h> 28 #include <ns3/spectrum-value.h> 29 30 #include <list> 31 32 namespace ns3 { 33 34 class LteChunkProcessor; 35 36 37 /** 38 * This class implements a gaussian interference model, i.e., all 39 * incoming signals are added to the total interference. 40 * 41 */ 42 class LteInterference : public Object 43 { 44 public: 45 LteInterference (); 46 virtual ~LteInterference (); 47 48 /** 49 * \brief Get the type ID. 50 * \return the object TypeId 51 */ 52 static TypeId GetTypeId (void); 53 virtual void DoDispose (); 54 55 /** 56 * \brief Add a LteChunkProcessor that will use the time-vs-frequency SINR 57 * calculated by this LteInterference instance. Note that all the 58 * added LteChunkProcessors will work in parallel. 59 * 60 * @param p 61 */ 62 virtual void AddSinrChunkProcessor (Ptr<LteChunkProcessor> p); 63 64 /** 65 * \brief Add a LteChunkProcessor that will use the time-vs-frequency 66 * interference calculated by this LteInterference instance. Note 67 * that all the added LteChunkProcessors will work in parallel. 68 * 69 * @param p 70 */ 71 virtual void AddInterferenceChunkProcessor (Ptr<LteChunkProcessor> p); 72 73 /** 74 * Add a LteChunkProcessor that will use the time-vs-frequency 75 * power calculated by this LteInterference instance. Note 76 * that all the added LteChunkProcessors will work in parallel. 77 * 78 * @param p 79 */ 80 virtual void AddRsPowerChunkProcessor (Ptr<LteChunkProcessor> p); 81 82 /** 83 * \brief Notify that the PHY is starting a RX attempt 84 * 85 * @param rxPsd the power spectral density of the signal being RX 86 */ 87 virtual void StartRx (Ptr<const SpectrumValue> rxPsd); 88 89 /** 90 * notify that the RX attempt has ended. The receiving PHY must call 91 * this method when RX ends or RX is aborted. 92 * 93 */ 94 virtual void EndRx (); 95 96 /** 97 * notify that a new signal is being perceived in the medium. This 98 * method is to be called for all incoming signal, regardless of 99 * whether they're useful signals or interferers. 100 * 101 * @param spd the power spectral density of the new signal 102 * @param duration the duration of the new signal 103 */ 104 virtual void AddSignal (Ptr<const SpectrumValue> spd, const Time duration); 105 106 /** 107 * 108 * @param noisePsd the Noise Power Spectral Density in power units 109 * (Watt, Pascal...) per Hz. 110 */ 111 virtual void SetNoisePowerSpectralDensity (Ptr<const SpectrumValue> noisePsd); 112 113 protected: 114 /** 115 * Conditionally evaluate chunk 116 */ 117 virtual void ConditionallyEvaluateChunk (); 118 /** 119 * Add signal function 120 * 121 * @param spd the power spectral density of the new signal 122 */ 123 virtual void DoAddSignal (Ptr<const SpectrumValue> spd); 124 /** 125 * Subtract signal 126 * 127 * @param spd the power spectral density of the new signal 128 * @param signalId the signal ID 129 */ 130 virtual void DoSubtractSignal (Ptr<const SpectrumValue> spd, uint32_t signalId); 131 132 bool m_receiving {false}; ///< are we receiving? 133 134 Ptr<SpectrumValue> m_rxSignal {nullptr}; /**< stores the power spectral density of 135 * the signal whose RX is being 136 * attempted 137 */ 138 139 Ptr<SpectrumValue> m_allSignals {nullptr}; /**< stores the spectral 140 * power density of the sum of incoming signals; 141 * does not include noise, includes the SPD of the signal being RX 142 */ 143 144 Ptr<const SpectrumValue> m_noise {nullptr}; ///< the noise value 145 146 Time m_lastChangeTime {Seconds(0)}; /**< the time of the last change in 147 * m_TotalPower 148 */ 149 150 uint32_t m_lastSignalId {0}; ///< the last signal ID 151 uint32_t m_lastSignalIdBeforeReset {0}; ///< the last signal ID before reset 152 153 /** all the processor instances that need to be notified whenever 154 a new interference chunk is calculated */ 155 std::list<Ptr<LteChunkProcessor> > m_rsPowerChunkProcessorList; 156 157 /** all the processor instances that need to be notified whenever 158 a new SINR chunk is calculated */ 159 std::list<Ptr<LteChunkProcessor> > m_sinrChunkProcessorList; 160 161 /** all the processor instances that need to be notified whenever 162 a new interference chunk is calculated */ 163 std::list<Ptr<LteChunkProcessor> > m_interfChunkProcessorList; 164 165 166 }; 167 168 169 170 } // namespace ns3 171 172 173 174 175 176 #endif /* LTE_INTERFERENCE_H */ 177