A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
uan-tx-mode.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 University of Washington
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Leonard Tracy <lentracy@gmail.com>
7 */
8
9#ifndef UAN_TX_MODE_H
10#define UAN_TX_MODE_H
11
12#include "ns3/object.h"
13
14#include <map>
15
16namespace ns3
17{
18
19class UanTxModeFactory;
20class UanTxMode;
21
22/**
23 * \ingroup uan
24 *
25 * Abstraction of packet modulation information.
26 *
27 * This contains a lightweight globally unique id for the mode.
28 * Mode details are held in the UanTxModeFactory. Attributes
29 * are set in by the UanTxModeFactory constructor.
30 */
32{
33 public:
34 UanTxMode(); //!< Constructor.
35 ~UanTxMode(); //!< Destructor.
36
37 /**
38 * Modulation type.
39 */
41 {
42 PSK, //!< Phase shift keying.
43 QAM, //!< Quadrature amplitude modulation.
44 FSK, //!< Frequency shift keying.
45 OTHER //!< Unspecified/undefined.
46 };
47
48 /**
49 * Get the modulation type of the mode.
50 *
51 * \return The modulation type.
52 */
53 ModulationType GetModType() const;
54 /**
55 * Get the data rate of the transmit mode.
56 *
57 * \return Data rate of the TX mode, in bits per second.
58 */
60 /**
61 * Get the physical signaling rate.
62 *
63 * \return PHY rate in symbols per second.
64 */
65 uint32_t GetPhyRateSps() const;
66 /**
67 * Get the transmission center frequency.
68 *
69 * \return Center frequency, in Hz.
70 */
72 /**
73 * Get the transmission signal bandwidth.
74 *
75 * \return Bandwidth in Hz.
76 */
78 /**
79 * Get the number of constellation points in the modulation scheme.
80 *
81 * \return Number of constellation points.
82 */
84 /**
85 * Get the mode name.
86 *
87 * \return Name
88 */
89 std::string GetName() const;
90 /**
91 * Get a unique id for the mode.
92 *
93 * \return Unique ID.
94 */
95 uint32_t GetUid() const;
96
97 private:
98 friend class UanTxModeFactory;
99 friend std::ostream& operator<<(std::ostream& os, const UanTxMode& mode);
100 friend std::istream& operator>>(std::istream& is, UanTxMode& mode);
101
102 uint32_t m_uid; //!< Mode id
103
104}; // class UanTxMode
105
106/**
107 * Writes tx mode entry to stream os.
108 *
109 * \param os The output stream.
110 * \param mode The mode.
111 * \return The stream.
112 */
113std::ostream& operator<<(std::ostream& os, const UanTxMode& mode);
114/**
115 * Reads tx mode entry from stream is
116 *
117 * \param is The input stream.
118 * \param mode The mode.
119 * \return The stream.
120 */
121std::istream& operator>>(std::istream& is, UanTxMode& mode);
122
123/**
124 * \ingroup uan
125 *
126 * Global database of UanTxMode objects, retrievable by id or name.
127 */
129{
130 public:
131 UanTxModeFactory(); //!< Constructor.
132 ~UanTxModeFactory(); //!< Destructor.
133
134 /**
135 *
136 * \param type Modulation type.
137 * \param dataRateBps Data rate in BPS.
138 * \param phyRateSps Symbol rate in symbols per second.
139 * \param cfHz Center frequency in Hz.
140 * \param bwHz Bandwidth in Hz.
141 * \param constSize Modulation constellation size (2 for BPSK, 4 for QPSK).
142 * \param name Unique string name for this transmission mode.
143 *
144 * \return the transmit mode object
145 */
147 uint32_t dataRateBps,
148 uint32_t phyRateSps,
149 uint32_t cfHz,
150 uint32_t bwHz,
151 uint32_t constSize,
152 std::string name);
153
154 /**
155 * Get a mode by name.
156 *
157 * \param name String name of mode.
158 * \return Mode with given name.
159 */
160 static UanTxMode GetMode(std::string name);
161 /**
162 * Get a mode by id.
163 *
164 * \param uid Unique ID of mode.
165 * \return The mode with given uid.
166 */
167 static UanTxMode GetMode(uint32_t uid);
168
169 private:
170 friend class UanTxMode;
171 uint32_t m_nextUid; //!< next id number
172
173 /**
174 * \ingroup uan
175 * Container for the UanTxMode properties.
176 */
178 {
179 UanTxMode::ModulationType m_type; //!< Modulation type.
180 uint32_t m_cfHz; //!< Center frequency in Hz.
181 uint32_t m_bwHz; //!< Bandwidth in Hz.
182 uint32_t m_dataRateBps; //!< Data rate in BPS.
183 uint32_t m_phyRateSps; //!< Symbol rate in symbols per second.
184 uint32_t m_constSize; //!< Modulation constellation size (2 for BPSK, 4 for QPSK).
185 uint32_t m_uid; //!< Unique id.
186 std::string m_name; //!< Unique string name for this transmission mode.
187 };
188
189 /**
190 * Container for modes
191 *
192 * \internal
193 * Accessed internally by uid and name, so a multimap might be more
194 * appropriate. If name accesses are predominant, perhaps a map
195 * indexed by name, with a find for uid. If accesses by uid dominate
196 * then vector (since uid's are sequential), and find by name.
197 */
198 std::map<uint32_t, UanTxModeItem> m_modes;
199
200 /**
201 * Check if the mode \pname{name} already exists.
202 *
203 * \param name The mode name to test.
204 * \return True if \pname{name} exists.
205 */
206 bool NameUsed(std::string name);
207
208 /**
209 * Construct and get the static global factory instance.
210 *
211 * \return The global instance.
212 */
214
215 /**
216 * Get a mode by id.
217 *
218 * \param uid The unique id to find.
219 * \return The corresponding mode.
220 */
222
223 /**
224 * Get a mode by name.
225 * \param name The mode name to find.
226 * \return The corresponding mode.
227 */
228 UanTxModeItem& GetModeItem(std::string name);
229
230 /**
231 * Create a public UanTxMode from an internal UanTxModeItem.
232 *
233 * \param item The UanTxModeItem to reference.
234 * \return A public UanTxMode.
235 */
237
238}; // class UanTxModeFactory
239
240/**
241 * \ingroup uan
242 *
243 * Container for UanTxModes.
244 *
245 * \see attribute_UanModesList
246 */
248{
249 public:
250 UanModesList(); //!< Constructor
251 virtual ~UanModesList(); //!< Destructor
252
253 /**
254 * Add mode to this list.
255 * \param mode The mode to add.
256 */
257 void AppendMode(UanTxMode mode);
258 /**
259 * Delete the mode at given index.
260 * \param num Index of mode to delete.
261 */
262 void DeleteMode(uint32_t num);
263 /**
264 * Retrieve a mode by index.
265 *
266 * \param index Mode index.
267 * \return Mode at given index.
268 */
269 UanTxMode operator[](uint32_t index) const;
270 /**
271 * Get the number of modes in this list.
272 *
273 * \return Number of modes.
274 */
275 uint32_t GetNModes() const;
276
277 private:
278 /** The vector of modes in this list. */
279 std::vector<UanTxMode> m_modes;
280
281 friend std::ostream& operator<<(std::ostream& os, const UanModesList& ml);
282 friend std::istream& operator>>(std::istream& is, UanModesList& ml);
283
284}; // class UanModesList
285
286/**
287 * Write UanModesList to stream os
288 *
289 * \param os The output stream.
290 * \param ml The mode list.
291 * \return The stream.
292 */
293std::ostream& operator<<(std::ostream& os, const UanModesList& ml);
294/**
295 * Read UanModesList from stream is.
296 *
297 * \param is The input stream.
298 * \param ml The mode list to fill.
299 * \return The stream.
300 */
301std::istream& operator>>(std::istream& is, UanModesList& ml);
302
304
305} // namespace ns3
306
307#endif /* UAN_TX_MODE_H */
Container for UanTxModes.
void DeleteMode(uint32_t num)
Delete the mode at given index.
UanModesList()
Constructor.
uint32_t GetNModes() const
Get the number of modes in this list.
friend std::istream & operator>>(std::istream &is, UanModesList &ml)
Read UanModesList from stream is.
void AppendMode(UanTxMode mode)
Add mode to this list.
UanTxMode operator[](uint32_t index) const
Retrieve a mode by index.
virtual ~UanModesList()
Destructor.
friend std::ostream & operator<<(std::ostream &os, const UanModesList &ml)
Write UanModesList to stream os.
std::vector< UanTxMode > m_modes
The vector of modes in this list.
Global database of UanTxMode objects, retrievable by id or name.
static UanTxMode CreateMode(UanTxMode::ModulationType type, uint32_t dataRateBps, uint32_t phyRateSps, uint32_t cfHz, uint32_t bwHz, uint32_t constSize, std::string name)
UanTxMode MakeModeFromItem(const UanTxModeItem &item)
Create a public UanTxMode from an internal UanTxModeItem.
UanTxModeFactory()
Constructor.
static UanTxModeFactory & GetFactory()
Construct and get the static global factory instance.
static UanTxMode GetMode(std::string name)
Get a mode by name.
std::map< uint32_t, UanTxModeItem > m_modes
Container for modes.
~UanTxModeFactory()
Destructor.
bool NameUsed(std::string name)
Check if the mode name already exists.
uint32_t m_nextUid
next id number
UanTxModeItem & GetModeItem(uint32_t uid)
Get a mode by id.
Abstraction of packet modulation information.
Definition uan-tx-mode.h:32
uint32_t GetUid() const
Get a unique id for the mode.
ModulationType
Modulation type.
Definition uan-tx-mode.h:41
@ QAM
Quadrature amplitude modulation.
Definition uan-tx-mode.h:43
@ OTHER
Unspecified/undefined.
Definition uan-tx-mode.h:45
@ PSK
Phase shift keying.
Definition uan-tx-mode.h:42
@ FSK
Frequency shift keying.
Definition uan-tx-mode.h:44
friend std::ostream & operator<<(std::ostream &os, const UanTxMode &mode)
Writes tx mode entry to stream os.
friend std::istream & operator>>(std::istream &is, UanTxMode &mode)
Reads tx mode entry from stream is.
uint32_t GetConstellationSize() const
Get the number of constellation points in the modulation scheme.
uint32_t GetPhyRateSps() const
Get the physical signaling rate.
uint32_t GetDataRateBps() const
Get the data rate of the transmit mode.
~UanTxMode()
Destructor.
uint32_t GetBandwidthHz() const
Get the transmission signal bandwidth.
std::string GetName() const
Get the mode name.
UanTxMode()
Constructor.
uint32_t m_uid
Mode id.
ModulationType GetModType() const
Get the modulation type of the mode.
uint32_t GetCenterFreqHz() const
Get the transmission center frequency.
#define ATTRIBUTE_HELPER_HEADER(type)
Declare the attribute value, accessor and checkers for class type
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition angles.cc:148
std::istream & operator>>(std::istream &is, Angles &a)
Definition angles.cc:172
Container for the UanTxMode properties.
uint32_t m_constSize
Modulation constellation size (2 for BPSK, 4 for QPSK).
uint32_t m_phyRateSps
Symbol rate in symbols per second.
std::string m_name
Unique string name for this transmission mode.
UanTxMode::ModulationType m_type
Modulation type.
uint32_t m_bwHz
Bandwidth in Hz.
uint32_t m_dataRateBps
Data rate in BPS.
uint32_t m_cfHz
Center frequency in Hz.