OLD | NEW |
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2005,2006,2007 INRIA | 3 * Copyright (c) 2005,2006,2007 INRIA |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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· | 6 * it under the terms of the GNU General Public License version 2 as· |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include <stdint.h> | 23 #include <stdint.h> |
24 #include <string> | 24 #include <string> |
25 #include <vector> | 25 #include <vector> |
26 #include <ostream> | 26 #include <ostream> |
27 #include "ns3/attribute-helper.h" | 27 #include "ns3/attribute-helper.h" |
28 #include "ns3/wifi-phy-standard.h" | 28 #include "ns3/wifi-phy-standard.h" |
29 | 29 |
30 namespace ns3 { | 30 namespace ns3 { |
31 | 31 |
32 /** | 32 /** |
| 33 * This enumeration defines the modulation classes per IEEE |
| 34 * 802.11-2007, Section 9.6.1, Table 9-2. |
| 35 */ |
| 36 enum WifiModulationClass { |
| 37 /** Modulation class unknown or unspecified. A WifiMode with this |
| 38 WifiModulationClass has not been properly initialised. */ |
| 39 WIFI_MOD_CLASS_UNKNOWN = 0, |
| 40 /** Infrared (IR) (Clause 16) */ |
| 41 WIFI_MOD_CLASS_IR, |
| 42 /** Frequency-hopping spread spectrum (FHSS) PHY (Clause 14) */ |
| 43 WIFI_MOD_CLASS_FHSS, |
| 44 /** DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18) */ |
| 45 WIFI_MOD_CLASS_DSSS, |
| 46 /** ERP-PBCC PHY (19.6) */ |
| 47 WIFI_MOD_CLASS_ERP_PBCC, |
| 48 /** DSSS-OFDM PHY (19.7) */ |
| 49 WIFI_MOD_CLASS_DSSS_OFDM, |
| 50 /** ERP-OFDM PHY (19.5) */ |
| 51 WIFI_MOD_CLASS_ERP_OFDM, |
| 52 /** OFDM PHY (Clause 17) */ |
| 53 WIFI_MOD_CLASS_OFDM, |
| 54 /** HT PHY (Clause 20) */ |
| 55 WIFI_MOD_CLASS_HT |
| 56 }; |
| 57 |
| 58 |
| 59 /** |
| 60 * This enumeration defines the various convolutional coding rates |
| 61 * used for the OFDM transmission modes in the IEEE 802.11 |
| 62 * standard. DSSS (for example) rates which do not have an explicit |
| 63 * coding stage in their generation should have this parameter set to |
| 64 * WIFI_CODE_RATE_UNDEFINED. |
| 65 */ |
| 66 enum WifiCodeRate { |
| 67 /** No explicit coding (e.g., DSSS rates) */ |
| 68 WIFI_CODE_RATE_UNDEFINED, |
| 69 /** Rate 3/4 */ |
| 70 WIFI_CODE_RATE_3_4, |
| 71 /** Rate 2/3 */ |
| 72 WIFI_CODE_RATE_2_3, |
| 73 /** Rate 1/2 */ |
| 74 WIFI_CODE_RATE_1_2 |
| 75 }; |
| 76 |
| 77 /** |
33 * \brief represent a single transmission mode | 78 * \brief represent a single transmission mode |
34 * | 79 * |
35 * A WifiMode is implemented by a single integer which is used | 80 * A WifiMode is implemented by a single integer which is used |
36 * to lookup in a global array the characteristics of the | 81 * to lookup in a global array the characteristics of the |
37 * associated transmission mode. It is thus extremely cheap to | 82 * associated transmission mode. It is thus extremely cheap to |
38 * keep a WifiMode variable around. | 83 * keep a WifiMode variable around. |
39 */ | 84 */ |
40 class WifiMode | 85 class WifiMode |
41 { | 86 { |
42 public: | 87 public: |
43 enum ModulationType { | |
44 BPSK, | |
45 QPSK, | |
46 DBPSK, | |
47 DQPSK, | |
48 QAM, | |
49 UNKNOWN | |
50 }; | |
51 ·· | |
52 /** | 88 /** |
53 * \returns the number of Hz used by this signal | 89 * \returns the number of Hz used by this signal |
54 */ | 90 */ |
55 uint32_t GetBandwidth (void) const; | 91 uint32_t GetBandwidth (void) const; |
56 /** | 92 /** |
57 * \returns the physical bit rate of this signal. | 93 * \returns the physical bit rate of this signal. |
58 * | 94 * |
59 * If a transmission mode uses 1/2 FEC, and if its | 95 * If a transmission mode uses 1/2 FEC, and if its |
60 * data rate is 3Mbs, the phy rate is 6Mbs | 96 * data rate is 3Mbs, the phy rate is 6Mbs |
61 */ | 97 */ |
62 uint32_t GetPhyRate (void) const; | 98 uint32_t GetPhyRate (void) const; |
63 /** | 99 /** |
64 * \returns the data bit rate of this signal. | 100 * \returns the data bit rate of this signal. |
65 */ | 101 */ |
66 uint32_t GetDataRate (void) const; | 102 uint32_t GetDataRate (void) const; |
67 /** | 103 /** |
68 * \returns true if this mode uses a bpsk modulation, false | 104 * \returns the coding rate of this transmission mode |
69 * otherwise. | |
70 */ | 105 */ |
71 bool IsModulationBpsk (void) const; | 106 enum WifiCodeRate GetCodeRate (void) const; |
72 /** | |
73 * \returns true if this mode uses a qam modulation, false | |
74 * otherwise. | |
75 */ | |
76 bool IsModulationQam (void) const; | |
77 /** | |
78 * \returns the type of modulation used by this mode. | |
79 */ | |
80 enum ModulationType GetModulationType (void) const; | |
81 /** | 107 /** |
82 * \returns the size of the modulation constellation. | 108 * \returns the size of the modulation constellation. |
83 */ | 109 */ |
84 uint8_t GetConstellationSize (void) const; | 110 uint8_t GetConstellationSize (void) const; |
85 | 111 |
86 /** | 112 /** |
87 * \returns a human-readable representation of this WifiMode | 113 * \returns a human-readable representation of this WifiMode |
88 * instance. | 114 * instance. |
89 */ | 115 */ |
90 std::string GetUniqueName (void) const; | 116 std::string GetUniqueName (void) const; |
91 | 117 |
92 /** | 118 /** |
93 * \returns true if this mode is a mandatory mode, false | 119 * \returns true if this mode is a mandatory mode, false |
94 * otherwise. | 120 * otherwise. |
95 */ | 121 */ |
96 bool IsMandatory (void) const; | 122 bool IsMandatory (void) const; |
97 | 123 |
98 /** | 124 /** |
99 * \returns the uid associated to this wireless mode. | 125 * \returns the uid associated to this wireless mode. |
100 * | 126 * |
101 * Each specific wireless mode should have a different uid. | 127 * Each specific wireless mode should have a different uid. |
102 * For example, the 802.11b 1Mbs and the 802.11b 2Mbs modes | 128 * For example, the 802.11b 1Mbs and the 802.11b 2Mbs modes |
103 * should have different uids. | 129 * should have different uids. |
104 */ | 130 */ |
105 uint32_t GetUid (void) const; | 131 uint32_t GetUid (void) const; |
106 | 132 |
107 /**· | 133 /** |
108 *· | 134 * |
109 * @return the WifiPhyStandard to which the WifiMode belongs | 135 * \returns the Modulation Class (see IEEE 802.11-2007 Section |
| 136 * 9.6.1) to which this WifiMode belongs. |
110 */ | 137 */ |
111 enum WifiPhyStandard GetStandard () const; | 138 enum WifiModulationClass GetModulationClass () const; |
112 | 139 |
113 /** | 140 /** |
114 * Create an invalid WifiMode. Calling any method on the | 141 * Create an invalid WifiMode. Calling any method on the |
115 * instance created will trigger an assert. This is useful | 142 * instance created will trigger an assert. This is useful |
116 * to separate the declaration of a WifiMode variable from | 143 * to separate the declaration of a WifiMode variable from |
117 * its initialization. | 144 * its initialization. |
118 */ | 145 */ |
119 WifiMode (); | 146 WifiMode (); |
120 WifiMode (std::string name); | 147 WifiMode (std::string name); |
121 private: | 148 private: |
(...skipping 17 matching lines...) Expand all Loading... |
139 * \brief create WifiMode class instances and keep track of them. | 166 * \brief create WifiMode class instances and keep track of them. |
140 * | 167 * |
141 * This factory ensures that each WifiMode created has a unique name | 168 * This factory ensures that each WifiMode created has a unique name |
142 * and assigns to each of them a unique integer. | 169 * and assigns to each of them a unique integer. |
143 */ | 170 */ |
144 class WifiModeFactory | 171 class WifiModeFactory |
145 { | 172 { |
146 public: | 173 public: |
147 /** | 174 /** |
148 * \param uniqueName the name of the associated WifiMode. This name | 175 * \param uniqueName the name of the associated WifiMode. This name |
149 * must be unique across _all_ instances. | 176 * must be unique accross _all_ instances. |
| 177 * \param modClass the class of modulation |
150 * \param isMandatory true if this WifiMode is mandatory, false otherwise. | 178 * \param isMandatory true if this WifiMode is mandatory, false otherwise. |
151 * \param bandwidth the bandwidth (Hz) of the signal generated when the | 179 * \param bandwidth the bandwidth (Hz) of the signal generated when the |
152 * associated WifiMode is used. | 180 * associated WifiMode is used. |
153 * \param dataRate the rate (bits/second) at which the user data is transmitte
d | 181 * \param dataRate the rate (bits/second) at which the user data is transmitte
d |
154 * \param phyRate the rate (bits/second) at which the encoded user data is tra
nsmitted | 182 * \param codingRate if convolutional coding is used for this rate |
155 * \param standard the Wifi Phy standard to apply | 183 * then this parameter specifies the convolutional coding rate |
156 * The phyRate includes FEC so, is typically higher than the dataRate. | 184 * used. If there is no explicit convolutional coding step (e.g., |
| 185 * for DSSS rates) then the caller should set this parameter to |
| 186 * WIFI_CODE_RATE_UNCODED. |
| 187 * \param constellationSize the order of the constellation used. |
157 * | 188 * |
158 * Create a BPSK WifiMode. | 189 * Create a WifiMode. |
159 */ | 190 */ |
160 static WifiMode CreateBpsk (std::string uniqueName, | 191 static WifiMode CreateWifiMode (std::string uniqueName, |
161 » » » bool isMandatory, | 192 enum WifiModulationClass modClass, |
162 » » » uint32_t bandwidth, | 193 bool isMandatory, |
163 » » » uint32_t dataRate, | 194 uint32_t bandwidth, |
164 » » » uint32_t phyRate, | 195 uint32_t dataRate, |
165 enum WifiPhyStandard standard); | 196 enum WifiCodeRate codingRate, |
166 /** | 197 uint8_t constellationSize); |
167 * \param uniqueName the name of the associated WifiMode. This name | |
168 * must be unique across _all_ instances. | |
169 * \param isMandatory true if this WifiMode is mandatory, false otherwise. | |
170 * \param bandwidth the bandwidth (Hz) of the signal generated when the | |
171 * associated WifiMode is used. | |
172 * \param dataRate the rate (bits/second) at which the user data is transmitte
d | |
173 * \param phyRate the rate (bits/second) at which the encoded user data is tra
nsmitted | |
174 * \param standard the Wifi Phy standard to apply | |
175 * The phyRate includes FEC so, is typically higher than the dataRate. | |
176 * | |
177 * Create a QPSK WifiMode. | |
178 */ | |
179 static WifiMode CreateQpsk (std::string uniqueName, | |
180 » » » bool isMandatory, | |
181 » » » uint32_t bandwidth, | |
182 » » » uint32_t dataRate, | |
183 » » » uint32_t phyRate, | |
184 enum WifiPhyStandard standard); | |
185 /** | |
186 * \param uniqueName the name of the associated WifiMode. This name | |
187 * must be unique across _all_ instances. | |
188 * \param isMandatory true if this WifiMode is mandatory, false otherwise. | |
189 * \param bandwidth the bandwidth (Hz) of the signal generated when the | |
190 * associated WifiMode is used. | |
191 * \param dataRate the rate (bits/second) at which the user data is transmitte
d | |
192 * \param phyRate the rate (bits/second) at which the encoded user data is tra
nsmitted | |
193 * The phyRate includes FEC so, is typically higher than the dataRate. | |
194 * \param constellationSize the number of elements included in the QAM constel
lation.· | |
195 * \param standard the Wifi Phy standard to apply | |
196 * | |
197 * Create a QAM WifiMode. | |
198 */ | |
199 static WifiMode CreateQam (std::string uniqueName, | |
200 bool isMandatory, | |
201 » » » uint32_t bandwidth, | |
202 » » » uint32_t dataRate, | |
203 » » » uint32_t phyRate, | |
204 » » » uint8_t constellationSize, | |
205 enum WifiPhyStandard standard); | |
206 | 198 |
207 /** | |
208 * \param uniqueName the name of the associated WifiMode. This name | |
209 * must be unique across _all_ instances. | |
210 * \param isMandatory true if this WifiMode is mandatory, false otherwise. | |
211 * \param bandwidth the bandwidth (Hz) of the signal generated when the | |
212 * associated WifiMode is used. | |
213 * \param dataRate the rate (bits/second) at which the user data is transmitte
d | |
214 * \param phyRate the rate (bits/second) at which the encoded user data is tra
nsmitted | |
215 * \param standard the Wifi Phy standard to apply | |
216 * The phyRate includes FEC so, is typically higher than the dataRate. | |
217 * | |
218 * Create a DBPSK WifiMode. | |
219 */ | |
220 static WifiMode CreateDbpsk (std::string uniqueName, | |
221 bool isMandatory, | |
222 uint32_t bandwidth, | |
223 uint32_t dataRate, | |
224 uint32_t phyRate, | |
225 enum WifiPhyStandard standard); | |
226 /** | |
227 * \param uniqueName the name of the associated WifiMode. This name | |
228 * must be unique across _all_ instances. | |
229 * \param isMandatory true if this WifiMode is mandatory, false otherwise. | |
230 * \param bandwidth the bandwidth (Hz) of the signal generated when the | |
231 * associated WifiMode is used. | |
232 * \param dataRate the rate (bits/second) at which the user data is transmitte
d | |
233 * \param phyRate the rate (bits/second) at which the encoded user data is tra
nsmitted | |
234 * \param standard the Wifi Phy standard to apply | |
235 * The phyRate includes FEC so, is typically higher than the dataRate. | |
236 * | |
237 * Create a DQPSK WifiMode. | |
238 */ | |
239 static WifiMode CreateDqpsk (std::string uniqueName, | |
240 bool isMandatory, | |
241 uint32_t bandwidth, | |
242 uint32_t dataRate, | |
243 uint32_t phyRate, | |
244 enum WifiPhyStandard standard); | |
245 private: | 199 private: |
246 friend class WifiMode;·· | 200 friend class WifiMode;·· |
247 friend std::istream & operator >> (std::istream &is, WifiMode &mode); | 201 friend std::istream & operator >> (std::istream &is, WifiMode &mode); |
248 static WifiModeFactory *GetFactory (); | 202 static WifiModeFactory *GetFactory (); |
249 WifiModeFactory (); | 203 WifiModeFactory (); |
250 | 204 |
251 /** | 205 /** |
252 * This is the data associated to a unique WifiMode. | 206 * This is the data associated to a unique WifiMode. |
253 * The integer stored in a WifiMode is in fact an index | 207 * The integer stored in a WifiMode is in fact an index |
254 * in an array of WifiModeItem objects. | 208 * in an array of WifiModeItem objects. |
255 */ | 209 */ |
256 struct WifiModeItem { | 210 struct WifiModeItem { |
257 std::string uniqueUid; | 211 std::string uniqueUid; |
258 uint32_t bandwidth; | 212 uint32_t bandwidth; |
259 uint32_t dataRate; | 213 uint32_t dataRate; |
260 uint32_t phyRate; | 214 uint32_t phyRate; |
261 enum WifiMode::ModulationType modulation; | 215 enum WifiModulationClass modClass; |
262 uint8_t constellationSize; | 216 uint8_t constellationSize; |
| 217 enum WifiCodeRate codingRate; |
263 bool isMandatory; | 218 bool isMandatory; |
264 enum WifiPhyStandard standard; | |
265 }; | 219 }; |
266 | 220 |
267 bool Search (std::string name, WifiMode *mode); | 221 WifiMode Search (std::string name); |
268 uint32_t AllocateUid (std::string uniqueName); | 222 uint32_t AllocateUid (std::string uniqueName); |
269 WifiModeItem *Get (uint32_t uid); | 223 WifiModeItem *Get (uint32_t uid); |
270 | 224 |
271 typedef std::vector<struct WifiModeItem> WifiModeItemList; | 225 typedef std::vector<struct WifiModeItem> WifiModeItemList; |
272 WifiModeItemList m_itemList; | 226 WifiModeItemList m_itemList; |
273 }; | 227 }; |
274 | 228 |
275 } // namespace ns3 | 229 } // namespace ns3 |
276 | 230 |
277 #endif /* WIFI_MODE_H */ | 231 #endif /* WIFI_MODE_H */ |
OLD | NEW |