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 uint32_t m_uid; //!< Mode id
99
100 friend class UanTxModeFactory;
101 friend std::ostream& operator<<(std::ostream& os, const UanTxMode& mode);
102 friend std::istream& operator>>(std::istream& is, UanTxMode& mode);
103
104 // end of class UanTxMode
105};
106
107/**
108 * Writes tx mode entry to stream os.
109 *
110 * @param os The output stream.
111 * @param mode The mode.
112 * @return The stream.
113 */
114std::ostream& operator<<(std::ostream& os, const UanTxMode& mode);
115/**
116 * Reads tx mode entry from stream is
117 *
118 * @param is The input stream.
119 * @param mode The mode.
120 * @return The stream.
121 */
122std::istream& operator>>(std::istream& is, UanTxMode& mode);
123
124/**
125 * @ingroup uan
126 *
127 * Global database of UanTxMode objects, retrievable by id or name.
128 */
130{
131 public:
132 UanTxModeFactory(); //!< Constructor.
133 ~UanTxModeFactory(); //!< Destructor.
134
135 /**
136 *
137 * @param type Modulation type.
138 * @param dataRateBps Data rate in BPS.
139 * @param phyRateSps Symbol rate in symbols per second.
140 * @param cfHz Center frequency in Hz.
141 * @param bwHz Bandwidth in Hz.
142 * @param constSize Modulation constellation size (2 for BPSK, 4 for QPSK).
143 * @param name Unique string name for this transmission mode.
144 *
145 * @return the transmit mode object
146 */
148 uint32_t dataRateBps,
149 uint32_t phyRateSps,
150 uint32_t cfHz,
151 uint32_t bwHz,
152 uint32_t constSize,
153 std::string name);
154
155 /**
156 * Get a mode by name.
157 *
158 * @param name String name of mode.
159 * @return Mode with given name.
160 */
161 static UanTxMode GetMode(std::string name);
162 /**
163 * Get a mode by id.
164 *
165 * @param uid Unique ID of mode.
166 * @return The mode with given uid.
167 */
168 static UanTxMode GetMode(uint32_t uid);
169
170 private:
171 friend class UanTxMode;
172 uint32_t m_nextUid; //!< next id number
173
174 /**
175 * @ingroup uan
176 * Container for the UanTxMode properties.
177 */
179 {
180 UanTxMode::ModulationType m_type; //!< Modulation type.
181 uint32_t m_cfHz; //!< Center frequency in Hz.
182 uint32_t m_bwHz; //!< Bandwidth in Hz.
183 uint32_t m_dataRateBps; //!< Data rate in BPS.
184 uint32_t m_phyRateSps; //!< Symbol rate in symbols per second.
185 uint32_t m_constSize; //!< Modulation constellation size (2 for BPSK, 4 for QPSK).
186 uint32_t m_uid; //!< Unique id.
187 std::string m_name; //!< Unique string name for this transmission mode.
188 };
189
190 /**
191 * Container for modes
192 *
193 * @internal
194 * Accessed internally by uid and name, so a multimap might be more
195 * appropriate. If name accesses are predominant, perhaps a map
196 * indexed by name, with a find for uid. If accesses by uid dominate
197 * then vector (since uid's are sequential), and find by name.
198 */
199 std::map<uint32_t, UanTxModeItem> m_modes;
200
201 /**
202 * Check if the mode \pname{name} already exists.
203 *
204 * @param name The mode name to test.
205 * @return True if \pname{name} exists.
206 */
207 bool NameUsed(std::string name);
208
209 /**
210 * Construct and get the static global factory instance.
211 *
212 * @return The global instance.
213 */
215
216 /**
217 * Get a mode by id.
218 *
219 * @param uid The unique id to find.
220 * @return The corresponding mode.
221 */
223
224 /**
225 * Get a mode by name.
226 * @param name The mode name to find.
227 * @return The corresponding mode.
228 */
229 UanTxModeItem& GetModeItem(std::string name);
230
231 /**
232 * Create a public UanTxMode from an internal UanTxModeItem.
233 *
234 * @param item The UanTxModeItem to reference.
235 * @return A public UanTxMode.
236 */
238
239 // end of class UanTxModeFactory
240};
241
242/**
243 * @ingroup uan
244 *
245 * Container for UanTxModes.
246 *
247 * @see attribute_UanModesList
248 */
250{
251 public:
252 UanModesList(); //!< Constructor
253 virtual ~UanModesList(); //!< Destructor
254
255 /**
256 * Add mode to this list.
257 * @param mode The mode to add.
258 */
259 void AppendMode(UanTxMode mode);
260 /**
261 * Delete the mode at given index.
262 * @param num Index of mode to delete.
263 */
264 void DeleteMode(uint32_t num);
265 /**
266 * Retrieve a mode by index.
267 *
268 * @param index Mode index.
269 * @return Mode at given index.
270 */
271 UanTxMode operator[](uint32_t index) const;
272 /**
273 * Get the number of modes in this list.
274 *
275 * @return Number of modes.
276 */
277 uint32_t GetNModes() const;
278
279 private:
280 /** The vector of modes in this list. */
281 std::vector<UanTxMode> m_modes;
282
283 friend std::ostream& operator<<(std::ostream& os, const UanModesList& ml);
284 friend std::istream& operator>>(std::istream& is, UanModesList& ml);
285
286 // end of class UanModesList
287};
288
289/**
290 * Write UanModesList to stream os
291 *
292 * @param os The output stream.
293 * @param ml The mode list.
294 * @return The stream.
295 */
296std::ostream& operator<<(std::ostream& os, const UanModesList& ml);
297/**
298 * Read UanModesList from stream is.
299 *
300 * @param is The input stream.
301 * @param ml The mode list to fill.
302 * @return The stream.
303 */
304std::istream& operator>>(std::istream& is, UanModesList& ml);
305
307
308} // namespace ns3
309
310#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.
Definition uan-tx-mode.h:98
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.