OLD | NEW |
(Empty) | |
| 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 MULTI_MODEL_SPECTRUM_CHANNEL_H |
| 23 #define MULTI_MODEL_SPECTRUM_CHANNEL_H |
| 24 |
| 25 #include <ns3/spectrum-value.h> |
| 26 #include <ns3/spectrum-converter.h> |
| 27 #include <ns3/spectrum-channel.h> |
| 28 #include <ns3/spectrum-propagation-loss-model.h> |
| 29 #include <ns3/propagation-delay-model.h> |
| 30 #include <map> |
| 31 #include <list> |
| 32 |
| 33 namespace ns3 { |
| 34 |
| 35 |
| 36 typedef std::map<SpectrumModelUid_t, SpectrumConverter> SpectrumConverterMap_t; |
| 37 |
| 38 |
| 39 class TxSpectrumModelInfo |
| 40 { |
| 41 public: |
| 42 TxSpectrumModelInfo (Ptr<const SpectrumModel> txSpectrumModel); |
| 43 ·· |
| 44 Ptr<const SpectrumModel> m_txSpectrumModel; |
| 45 SpectrumConverterMap_t m_spectrumConverterMap; |
| 46 }; |
| 47 |
| 48 typedef std::map<SpectrumModelUid_t, TxSpectrumModelInfo> TxSpectrumModelInfoMap
_t; |
| 49 |
| 50 |
| 51 class RxSpectrumModelInfo |
| 52 { |
| 53 public: |
| 54 RxSpectrumModelInfo (Ptr<const SpectrumModel> rxSpectrumModel); |
| 55 ·· |
| 56 Ptr<const SpectrumModel> m_rxSpectrumModel; |
| 57 std::list<Ptr<SpectrumPhy> > m_rxPhyList;·· |
| 58 }; |
| 59 |
| 60 typedef std::map<SpectrumModelUid_t, RxSpectrumModelInfo> RxSpectrumModelInfoMap
_t; |
| 61 |
| 62 |
| 63 |
| 64 |
| 65 /** |
| 66 * This SpectrumChannel implementation can handle the presence of |
| 67 * SpectrumPhy instances which can use |
| 68 * different spectrum models, i.e., different SpectrumModel. The only |
| 69 * requirement is that every SpectrumPhy instance uses the same |
| 70 * SpectrumModel for the whole simulation. |
| 71 */ |
| 72 class MultiModelSpectrumChannel : public SpectrumChannel |
| 73 { |
| 74 |
| 75 public: |
| 76 MultiModelSpectrumChannel (); |
| 77 |
| 78 static TypeId GetTypeId (void); |
| 79 |
| 80 /** |
| 81 * |
| 82 * |
| 83 * @param phy |
| 84 */ |
| 85 |
| 86 |
| 87 // inherited from SpectrumChannel |
| 88 virtual void AddSpectrumPropagationLossModel (Ptr<SpectrumPropagationLossModel
> loss); |
| 89 virtual void SetPropagationDelayModel (Ptr<PropagationDelayModel> delay); |
| 90 virtual void AddRx (Ptr<SpectrumPhy> phy); |
| 91 virtual void StartTx (Ptr<const Packet> p, Ptr <SpectrumValue> rxPsd, Spectrum
Type st, Time duration, Ptr<SpectrumPhy> sender); |
| 92 |
| 93 |
| 94 // inherited from Channel |
| 95 virtual uint32_t GetNDevices (void) const; |
| 96 virtual Ptr<NetDevice> GetDevice (uint32_t i) const; |
| 97 |
| 98 |
| 99 |
| 100 |
| 101 private: |
| 102 · |
| 103 |
| 104 /**· |
| 105 * this method checks if m_rxSpectrumModelInfoMap contains an entry |
| 106 * for the given TX SpectrumModel. If such entry exists, it returns |
| 107 * an interator pointing to it. If not, it creates a new entry in |
| 108 * m_txSpectrumMpodelInfoMap, and returns an iterator to it. |
| 109 *· |
| 110 * @param txSpectrumModel the TX SpectrumModel being considered |
| 111 *· |
| 112 * @return an iterator pointing to the corresponding entry in m_txSpectrumMode
lInfoMap |
| 113 */ |
| 114 TxSpectrumModelInfoMap_t::const_iterator FindAndEventuallyAddTxSpectrumModel (
Ptr<const SpectrumModel> txSpectrumModel); |
| 115 |
| 116 |
| 117 /**· |
| 118 * make sure that there are SpectrumConverters from any |
| 119 * SpectrumPhy being used for TX to the given SpectrumModel being used for RX |
| 120 *· |
| 121 * @param rxPhy the RXing SpectrumPhy |
| 122 * @param rxSpectrumModel the SpectrumModel used for RX by rxPhy |
| 123 */ |
| 124 void CheckAddRxSpectrumModel (Ptr<SpectrumPhy> rxPhy, Ptr<const SpectrumModel>
rxSpectrumModel); |
| 125 |
| 126 |
| 127 |
| 128 /** |
| 129 * used internally to reschedule transmission after the propagation delay |
| 130 * |
| 131 * @param p |
| 132 * @param rxPowerSpectrum |
| 133 * @param duration |
| 134 * @param receiver |
| 135 */ |
| 136 virtual void StartRx (Ptr<Packet> p, Ptr <SpectrumValue> rxPowerSpectrum, Spec
trumType st, Time duration, Ptr<SpectrumPhy> receiver); |
| 137 |
| 138 |
| 139 |
| 140 /** |
| 141 * propagation delay model to be used with this channel |
| 142 * |
| 143 */ |
| 144 Ptr<PropagationDelayModel> m_PropagationDelay; |
| 145 |
| 146 |
| 147 /** |
| 148 * propagation loss model to be used with this channel |
| 149 * |
| 150 */ |
| 151 Ptr<SpectrumPropagationLossModel> m_PropagationLoss; |
| 152 |
| 153 |
| 154 |
| 155 /** |
| 156 * data structure holding, for each TX SpectrumModel, all the |
| 157 * converters to any RX SpectrumModel, and all the corresponding |
| 158 * SpectrumPhy instances.· |
| 159 *· |
| 160 */ |
| 161 TxSpectrumModelInfoMap_t m_txSpectrumModelInfoMap; |
| 162 |
| 163 |
| 164 /** |
| 165 * data structure holding, for each RX spectrum model, all the |
| 166 * corresponding SpectrumPhy instances. |
| 167 *· |
| 168 */ |
| 169 RxSpectrumModelInfoMap_t m_rxSpectrumModelInfoMap; |
| 170 ·· |
| 171 /** |
| 172 * this is only used to provide a straighforward implementation of |
| 173 * GetNDevices() and GetDevice() |
| 174 * |
| 175 */ |
| 176 std::vector<Ptr<SpectrumPhy> > m_phyVector; |
| 177 }; |
| 178 |
| 179 |
| 180 |
| 181 } |
| 182 |
| 183 |
| 184 |
| 185 #endif /* MULTI_MODEL_SPECTRUM_CHANNEL_H */ |
OLD | NEW |