A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
multi-model-spectrum-channel.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 CTTC
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Nicola Baldo <nbaldo@cttc.es>
18 */
19
20#ifndef MULTI_MODEL_SPECTRUM_CHANNEL_H
21#define MULTI_MODEL_SPECTRUM_CHANNEL_H
22
23#include "spectrum-channel.h"
24#include "spectrum-converter.h"
26#include "spectrum-value.h"
27
28#include <ns3/propagation-delay-model.h>
29
30#include <map>
31#include <set>
32
33namespace ns3
34{
35
36/**
37 * \ingroup spectrum
38 * Container: SpectrumModelUid_t, SpectrumConverter
39 */
40typedef std::map<SpectrumModelUid_t, SpectrumConverter> SpectrumConverterMap_t;
41
42/**
43 * \ingroup spectrum
44 * The Tx spectrum model information. This class is used to convert
45 * one spectrum model into another one.
46 */
48{
49 public:
50 /**
51 * Constructor.
52 * \param txSpectrumModel the Tx Spectrum model.
53 */
55
58};
59
60/**
61 * \ingroup spectrum
62 * Container: SpectrumModelUid_t, TxSpectrumModelInfo
63 */
64typedef std::map<SpectrumModelUid_t, TxSpectrumModelInfo> TxSpectrumModelInfoMap_t;
65
66/**
67 * \ingroup spectrum
68 * The Rx spectrum model information. This class is used to convert
69 * one spectrum model into another one.
70 */
72{
73 public:
74 /**
75 * Constructor.
76 * \param rxSpectrumModel the Rx Spectrum model.
77 */
79
81 std::vector<Ptr<SpectrumPhy>> m_rxPhys; //!< Container of the Rx Spectrum phy objects.
82};
83
84/**
85 * \ingroup spectrum
86 * Container: SpectrumModelUid_t, RxSpectrumModelInfo
87 */
88typedef std::map<SpectrumModelUid_t, RxSpectrumModelInfo> RxSpectrumModelInfoMap_t;
89
90/**
91 * \ingroup spectrum
92 *
93 * This SpectrumChannel implementation can handle the presence of
94 * SpectrumPhy instances which can use
95 * different spectrum models, i.e., different SpectrumModel.
96 *
97 * \note It is allowed for a receiving SpectrumPhy to switch to a
98 * different SpectrumModel during the simulation. The requirement
99 * for this to work is that, after the SpectrumPhy switched its
100 * SpectrumModel, MultiModelSpectrumChannel::AddRx () is
101 * called again passing the pointer to that SpectrumPhy.
102 */
104{
105 public:
107
108 /**
109 * \brief Get the type ID.
110 * \return the object TypeId
111 */
112 static TypeId GetTypeId();
113
114 // inherited from SpectrumChannel
115 void RemoveRx(Ptr<SpectrumPhy> phy) override;
116 void AddRx(Ptr<SpectrumPhy> phy) override;
117 void StartTx(Ptr<SpectrumSignalParameters> params) override;
118
119 // inherited from Channel
120 std::size_t GetNDevices() const override;
121 Ptr<NetDevice> GetDevice(std::size_t i) const override;
122
123 protected:
124 void DoDispose() override;
125
126 private:
127 /**
128 * This method checks if m_rxSpectrumModelInfoMap contains an entry
129 * for the given TX SpectrumModel. If such entry exists, it returns
130 * an iterator pointing to it. If not, it creates a new entry in
131 * m_txSpectrumModelInfoMap, and returns an iterator to it.
132 *
133 * \param txSpectrumModel The TX SpectrumModel being considered
134 *
135 * \return An iterator pointing to the corresponding entry in m_txSpectrumModelInfoMap
136 */
137 TxSpectrumModelInfoMap_t::const_iterator FindAndEventuallyAddTxSpectrumModel(
138 Ptr<const SpectrumModel> txSpectrumModel);
139
140 /**
141 * Used internally to reschedule transmission after the propagation delay.
142 *
143 * \param params The signal parameters.
144 * \param receiver A pointer to the receiver SpectrumPhy.
145 */
146 virtual void StartRx(Ptr<SpectrumSignalParameters> params, Ptr<SpectrumPhy> receiver);
147
148 /**
149 * Data structure holding, for each TX SpectrumModel, all the
150 * converters to any RX SpectrumModel, and all the corresponding
151 * SpectrumPhy instances.
152 *
153 */
155
156 /**
157 * Data structure holding, for each RX spectrum model, all the
158 * corresponding SpectrumPhy instances.
159 */
161
162 /**
163 * Number of devices connected to the channel.
164 */
165 std::size_t m_numDevices;
166};
167
168} // namespace ns3
169
170#endif /* MULTI_MODEL_SPECTRUM_CHANNEL_H */
This SpectrumChannel implementation can handle the presence of SpectrumPhy instances which can use di...
void RemoveRx(Ptr< SpectrumPhy > phy) override
Remove a SpectrumPhy from a channel.
Ptr< NetDevice > GetDevice(std::size_t i) const override
std::size_t GetNDevices() const override
void AddRx(Ptr< SpectrumPhy > phy) override
Add a SpectrumPhy to a channel, so it can receive packets.
TxSpectrumModelInfoMap_t m_txSpectrumModelInfoMap
Data structure holding, for each TX SpectrumModel, all the converters to any RX SpectrumModel,...
std::size_t m_numDevices
Number of devices connected to the channel.
void DoDispose() override
Destructor implementation.
void StartTx(Ptr< SpectrumSignalParameters > params) override
Used by attached PHY instances to transmit signals on the channel.
TxSpectrumModelInfoMap_t::const_iterator FindAndEventuallyAddTxSpectrumModel(Ptr< const SpectrumModel > txSpectrumModel)
This method checks if m_rxSpectrumModelInfoMap contains an entry for the given TX SpectrumModel.
static TypeId GetTypeId()
Get the type ID.
virtual void StartRx(Ptr< SpectrumSignalParameters > params, Ptr< SpectrumPhy > receiver)
Used internally to reschedule transmission after the propagation delay.
RxSpectrumModelInfoMap_t m_rxSpectrumModelInfoMap
Data structure holding, for each RX spectrum model, all the corresponding SpectrumPhy instances.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
The Rx spectrum model information.
std::vector< Ptr< SpectrumPhy > > m_rxPhys
Container of the Rx Spectrum phy objects.
Ptr< const SpectrumModel > m_rxSpectrumModel
Rx Spectrum model.
Defines the interface for spectrum-aware channel implementations.
The Tx spectrum model information.
Ptr< const SpectrumModel > m_txSpectrumModel
Tx Spectrum model.
SpectrumConverterMap_t m_spectrumConverterMap
Spectrum converter.
a unique identifier for an interface.
Definition: type-id.h:59
std::map< SpectrumModelUid_t, TxSpectrumModelInfo > TxSpectrumModelInfoMap_t
Container: SpectrumModelUid_t, TxSpectrumModelInfo.
std::map< SpectrumModelUid_t, SpectrumConverter > SpectrumConverterMap_t
Container: SpectrumModelUid_t, SpectrumConverter.
std::map< SpectrumModelUid_t, RxSpectrumModelInfo > RxSpectrumModelInfoMap_t
Container: SpectrumModelUid_t, RxSpectrumModelInfo.
Every class exported by the ns3 library is enclosed in the ns3 namespace.