A Discrete-Event Network Simulator
API
wifi-tx-vector.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2010 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  * Authors: Nicola Baldo <nbaldo@cttc.es>
19  * Ghada Badawy <gbadawy@gmail.com>
20  */
21 
22 #include "wifi-tx-vector.h"
23 
24 namespace ns3 {
25 
27  : m_preamble (WIFI_PREAMBLE_LONG),
28  m_channelWidth (20),
29  m_guardInterval (800),
30  m_nTx (1),
31  m_nss (1),
32  m_ness (0),
33  m_aggregation (false),
34  m_stbc (false),
35  m_bssColor (0),
36  m_modeInitialized (false)
37 {
38 }
39 
41  uint8_t powerLevel,
42  WifiPreamble preamble,
43  uint16_t guardInterval,
44  uint8_t nTx,
45  uint8_t nss,
46  uint8_t ness,
47  uint16_t channelWidth,
48  bool aggregation,
49  bool stbc,
50  uint8_t bssColor)
51  : m_mode (mode),
52  m_txPowerLevel (powerLevel),
53  m_preamble (preamble),
54  m_channelWidth (channelWidth),
55  m_guardInterval (guardInterval),
56  m_nTx (nTx),
57  m_nss (nss),
58  m_ness (ness),
59  m_aggregation (aggregation),
60  m_stbc (stbc),
61  m_bssColor (bssColor),
62  m_modeInitialized (true)
63 {
64 }
65 
66 bool
68 {
69  return m_modeInitialized;
70 }
71 
74 {
75  if (!m_modeInitialized)
76  {
77  NS_FATAL_ERROR ("WifiTxVector mode must be set before using");
78  }
79  return m_mode;
80 }
81 
82 uint8_t
84 {
85  return m_txPowerLevel;
86 }
87 
90 {
91  return m_preamble;
92 }
93 
94 uint16_t
96 {
97  return m_channelWidth;
98 }
99 
100 uint16_t
102 {
103  return m_guardInterval;
104 }
105 
106 uint8_t
108 {
109  return m_nTx;
110 }
111 
112 uint8_t
114 {
115  return m_nss;
116 }
117 
118 uint8_t
120 {
121  return m_ness;
122 }
123 
124 bool
126 {
127  return m_aggregation;
128 }
129 
130 bool
132 {
133  return m_stbc;
134 }
135 
136 void
138 {
139  m_mode = mode;
140  m_modeInitialized = true;
141 }
142 
143 void
144 WifiTxVector::SetTxPowerLevel (uint8_t powerlevel)
145 {
146  m_txPowerLevel = powerlevel;
147 }
148 
149 void
151 {
152  m_preamble = preamble;
153 }
154 
155 void
156 WifiTxVector::SetChannelWidth (uint16_t channelWidth)
157 {
158  m_channelWidth = channelWidth;
159 }
160 
161 void
162 WifiTxVector::SetGuardInterval (uint16_t guardInterval)
163 {
164  m_guardInterval = guardInterval;
165 }
166 
167 void
168 WifiTxVector::SetNTx (uint8_t nTx)
169 {
170  m_nTx = nTx;
171 }
172 
173 void
174 WifiTxVector::SetNss (uint8_t nss)
175 {
176  m_nss = nss;
177 }
178 
179 void
180 WifiTxVector::SetNess (uint8_t ness)
181 {
182  m_ness = ness;
183 }
184 
185 void
187 {
188  m_aggregation = aggregation;
189 }
190 
191 void
193 {
194  m_stbc = stbc;
195 }
196 
197 void
199 {
200  m_bssColor = color;
201 }
202 
203 uint8_t
205 {
206  return m_bssColor;
207 }
208 
209 bool
211 {
212  std::string modeName = m_mode.GetUniqueName ();
213  if (m_channelWidth == 20)
214  {
215  if (m_nss != 3 && m_nss != 6)
216  {
217  return (modeName != "VhtMcs9");
218  }
219  }
220  else if (m_channelWidth == 80)
221  {
222  if (m_nss == 3 || m_nss == 7)
223  {
224  return (modeName != "VhtMcs6");
225  }
226  else if (m_nss == 6)
227  {
228  return (modeName != "VhtMcs9");
229  }
230  }
231  else if (m_channelWidth == 160)
232  {
233  if (m_nss == 3)
234  {
235  return (modeName != "VhtMcs9");
236  }
237  }
238  return true;
239 }
240 
241 std::ostream & operator << ( std::ostream &os, const WifiTxVector &v)
242 {
243  os << "mode: " << v.GetMode () <<
244  " txpwrlvl: " << +v.GetTxPowerLevel () <<
245  " preamble: " << v.GetPreambleType () <<
246  " channel width: " << v.GetChannelWidth () <<
247  " GI: " << v.GetGuardInterval () <<
248  " NTx: " << +v.GetNTx () <<
249  " Nss: " << +v.GetNss () <<
250  " Ness: " << +v.GetNess () <<
251  " MPDU aggregation: " << v.IsAggregation () <<
252  " STBC: " << v.IsStbc ();
253  return os;
254 }
255 
256 } //namespace ns3
uint16_t m_channelWidth
channel width in MHz
bool IsAggregation(void) const
Checks whether the PSDU contains A-MPDU.
uint8_t m_nTx
number of TX antennas
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void SetChannelWidth(uint16_t channelWidth)
Sets the selected channelWidth (in MHz)
void SetBssColor(uint8_t color)
Set the BSS color.
void SetStbc(bool stbc)
Sets if STBC is being used.
bool IsStbc(void) const
Check if STBC is used or not.
bool GetModeInitialized(void) const
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
uint8_t GetNess(void) const
uint16_t GetGuardInterval(void) const
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:97
uint8_t m_nss
number of spatial streams
WifiPreamble GetPreambleType(void) const
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Definition: wifi-preamble.h:32
uint8_t m_bssColor
BSS color.
bool IsValid(void) const
The standard disallows certain combinations of WifiMode, number of spatial streams, and channel widths.
void SetGuardInterval(uint16_t guardInterval)
Sets the guard interval duration (in nanoseconds)
WifiMode GetMode(void) const
uint16_t m_guardInterval
guard interval duration in nanoseconds
uint8_t GetNTx(void) const
std::string GetUniqueName(void) const
Definition: wifi-mode.cc:457
void SetNss(uint8_t nss)
Sets the number of Nss refer to IEEE 802.11n Table 20-28 for explanation and range.
bool m_modeInitialized
Internal initialization flag.
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:42
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetAggregation(bool aggregation)
Sets if PSDU contains A-MPDU.
void SetPreambleType(WifiPreamble preamble)
Sets the preamble type.
void SetTxPowerLevel(uint8_t powerlevel)
Sets the selected transmission power level.
void SetNTx(uint8_t nTx)
Sets the number of TX antennas.
bool m_aggregation
Flag whether the PSDU contains A-MPDU.
bool m_stbc
STBC used or not.
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
uint8_t GetBssColor(void) const
Get the BSS color.
void SetNess(uint8_t ness)
Sets the Ness number refer to IEEE 802.11n Table 20-6 for explanation.
uint8_t GetTxPowerLevel(void) const
uint16_t GetChannelWidth(void) const
uint8_t m_ness
number of spatial streams in beamforming
uint8_t m_txPowerLevel
The TXPWR_LEVEL parameter in Table 15-4.
uint8_t GetNss(void) const
WifiMode m_mode
The DATARATE parameter in Table 15-4.
WifiPreamble m_preamble
preamble