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 SPECTRUM_CHANNEL_H 23 #define SPECTRUM_CHANNEL_H 24 25 #include <ns3/object.h> 26 #include <ns3/nstime.h> 27 #include <ns3/channel.h> 28 #include <ns3/spectrum-signal-parameters.h> 29 #include <ns3/spectrum-propagation-loss-model.h> 30 #include <ns3/propagation-delay-model.h> 31 #include <ns3/propagation-loss-model.h> 32 #include <ns3/spectrum-phy.h> 33 #include <ns3/traced-callback.h> 34 #include <ns3/mobility-model.h> 35 36 namespace ns3 { 37 38 39 class PacketBurst; 40 class SpectrumValue; 41 42 /** 43 * \ingroup spectrum 44 * 45 * Defines the interface for spectrum-aware channel implementations 46 * 47 */ 48 class SpectrumChannel : public Channel 49 { 50 public: 51 52 /** 53 * constructor 54 * 55 */ 56 SpectrumChannel (); 57 /** 58 * destructor 59 * 60 */ 61 virtual ~SpectrumChannel (); 62 63 // inherited from Object 64 virtual void DoDispose (void); 65 66 /** 67 * \brief Get the type ID. 68 * \return the object TypeId 69 */ 70 static TypeId GetTypeId (void); 71 72 /** 73 * Add the single-frequency propagation loss model to be used 74 * \warning only models that do not depend on the TX power should be used. 75 * 76 * \param loss a pointer to the propagation loss model to be used. 77 */ 78 void AddPropagationLossModel (Ptr<PropagationLossModel> loss); 79 80 /** 81 * Add the frequency-dependent propagation loss model to be used 82 * \param loss a pointer to the propagation loss model to be used. 83 */ 84 void AddSpectrumPropagationLossModel (Ptr<SpectrumPropagationLossModel> loss); 85 86 /** 87 * Set the propagation delay model to be used 88 * \param delay Ptr to the propagation delay model to be used. 89 */ 90 void SetPropagationDelayModel (Ptr<PropagationDelayModel> delay); 91 92 /** 93 * Get the frequency-dependent propagation loss model. 94 * \returns a pointer to the propagation loss model. 95 */ 96 Ptr<SpectrumPropagationLossModel> GetSpectrumPropagationLossModel (void); 97 98 /** 99 * Get the propagation loss model. 100 * \returns a pointer to the propagation loss model. 101 */ 102 Ptr<PropagationLossModel> GetPropagationLossModel (void); 103 104 /** 105 * Used by attached PHY instances to transmit signals on the channel 106 * 107 * \param params the parameters of the signals being transmitted 108 */ 109 virtual void StartTx (Ptr<SpectrumSignalParameters> params) = 0; 110 111 /** 112 * \brief Add a SpectrumPhy to a channel, so it can receive packets 113 * 114 * This method is used to attach a SpectrumPhy instance to a 115 * SpectrumChannel instance, so that the SpectrumPhy can receive 116 * packets sent on that channel. Note that a SpectrumPhy that only 117 * transmits (without receiving ever) does not need to be added to 118 * the channel. 119 * 120 * This method is to be implemented by all classes inheriting from 121 * SpectrumChannel. 122 * 123 * \param phy the SpectrumPhy instance to be added to the channel as 124 * a receiver. 125 */ 126 virtual void AddRx (Ptr<SpectrumPhy> phy) = 0; 127 128 /** 129 * TracedCallback signature for path loss calculation events. 130 * 131 * \param [in] txPhy The TX SpectrumPhy instance. 132 * \param [in] rxPhy The RX SpectrumPhy instance. 133 * \param [in] lossDb The loss value, in dB. 134 */ 135 typedef void (* LossTracedCallback) 136 (Ptr<const SpectrumPhy> txPhy, Ptr<const SpectrumPhy> rxPhy, 137 double lossDb); 138 /** 139 * TracedCallback signature for path loss calculation events. 140 * 141 * \param [in] txMobility The mobility model of the transmitter. 142 * \param [in] rxMobility The mobility model of the receiver. 143 * \param [in] txAntennaGain The transmitter antenna gain, in dB. 144 * \param [in] rxAntennaGain The receiver antenna gain, in dB. 145 * \param [in] propagationGain The propagation gain, in dB. 146 * \param [in] pathloss The path loss value, in dB. 147 */ 148 typedef void (* GainTracedCallback) 149 (Ptr<const MobilityModel> txMobility, Ptr<const MobilityModel> rxMobility, 150 double txAntennaGain, double rxAntennaGain, 151 double propagationGain, double pathloss); 152 /** 153 * TracedCallback signature for Ptr<const SpectrumSignalParameters>. 154 * 155 * \param [in] params SpectrumSignalParameters instance. 156 */ 157 typedef void (* SignalParametersTracedCallback) (Ptr<SpectrumSignalParameters> params); 158 159 protected: 160 161 /** 162 * The `PathLoss` trace source. Exporting the pointers to the Tx and Rx 163 * SpectrumPhy and a pathloss value, in dB. 164 */ 165 TracedCallback<Ptr<const SpectrumPhy>, Ptr<const SpectrumPhy>, double > m_pathLossTrace; 166 167 /** 168 * The `Gain` trace source. Fired whenever a new path loss value 169 * is calculated. Exporting pointer to the mobility model of the transmitter and 170 * the receiver, Tx antenna gain, Rx antenna gain, propagation gain and pathloss 171 */ 172 TracedCallback<Ptr<const MobilityModel>, Ptr<const MobilityModel>, double, double, double, double> m_gainTrace; 173 174 /** 175 * Traced callback for SpectrumSignalParameters in StartTx requests 176 */ 177 TracedCallback<Ptr<SpectrumSignalParameters> > m_txSigParamsTrace; 178 179 /** 180 * Maximum loss [dB]. 181 * 182 * Any device above this loss is considered out of range. 183 */ 184 double m_maxLossDb; 185 186 /** 187 * Single-frequency propagation loss model to be used with this channel. 188 */ 189 Ptr<PropagationLossModel> m_propagationLoss; 190 191 /** 192 * Propagation delay model to be used with this channel. 193 */ 194 Ptr<PropagationDelayModel> m_propagationDelay; 195 196 /** 197 * Frequency-dependent propagation loss model to be used with this channel. 198 */ 199 Ptr<SpectrumPropagationLossModel> m_spectrumPropagationLoss; 200 201 202 }; 203 204 205 } 206 207 208 #endif /* SPECTRUM_CHANNEL_H */ 209