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_NONE),
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_modeInitialized (false),
36  m_txPowerLevelInitialized (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  : m_mode (mode),
51  m_txPowerLevel (powerLevel),
52  m_preamble (preamble),
53  m_channelWidth (channelWidth),
54  m_guardInterval (guardInterval),
55  m_nTx (nTx),
56  m_nss (nss),
57  m_ness (ness),
58  m_aggregation (aggregation),
59  m_stbc (stbc),
60  m_modeInitialized (true),
61  m_txPowerLevelInitialized (true)
62 {
63 }
64 
67 {
68  if (!m_modeInitialized)
69  {
70  NS_FATAL_ERROR ("WifiTxVector mode must be set before using");
71  }
72  return m_mode;
73 }
74 
75 uint8_t
77 {
79  {
80  NS_FATAL_ERROR ("WifiTxVector txPowerLevel must be set before using");
81  }
82  return m_txPowerLevel;
83 }
84 
87 {
88  return m_preamble;
89 }
90 
91 uint16_t
93 {
94  return m_channelWidth;
95 }
96 
97 uint16_t
99 {
100  return m_guardInterval;
101 }
102 
103 uint8_t
105 {
106  return m_nTx;
107 }
108 
109 uint8_t
111 {
112  return m_nss;
113 }
114 
115 uint8_t
117 {
118  return m_ness;
119 }
120 
121 bool
123 {
124  return m_aggregation;
125 }
126 
127 bool
129 {
130  return m_stbc;
131 }
132 
133 void
135 {
136  m_mode = mode;
137  m_modeInitialized = true;
138 }
139 
140 void
141 WifiTxVector::SetTxPowerLevel (uint8_t powerlevel)
142 {
143  m_txPowerLevel = powerlevel;
145 }
146 
147 void
149 {
150  m_preamble = preamble;
151 }
152 
153 void
154 WifiTxVector::SetChannelWidth (uint16_t channelWidth)
155 {
156  m_channelWidth = channelWidth;
157 }
158 
159 void
160 WifiTxVector::SetGuardInterval (uint16_t guardInterval)
161 {
162  m_guardInterval = guardInterval;
163 }
164 
165 void
166 WifiTxVector::SetNTx (uint8_t nTx)
167 {
168  m_nTx = nTx;
169 }
170 
171 void
172 WifiTxVector::SetNss (uint8_t nss)
173 {
174  m_nss = nss;
175 }
176 
177 void
178 WifiTxVector::SetNess (uint8_t ness)
179 {
180  m_ness = ness;
181 }
182 
183 void
185 {
186  m_aggregation = aggregation;
187 }
188 
189 void
191 {
192  m_stbc = stbc;
193 }
194 
195 bool
197 {
198  std::string modeName = m_mode.GetUniqueName ();
199  if (m_channelWidth == 20)
200  {
201  if (m_nss != 3 && m_nss != 6)
202  {
203  return (modeName != "VhtMcs9");
204  }
205  }
206  else if (m_channelWidth == 80)
207  {
208  if (m_nss == 3 || m_nss == 7)
209  {
210  return (modeName != "VhtMcs6");
211  }
212  else if (m_nss == 6)
213  {
214  return (modeName != "VhtMcs9");
215  }
216  }
217  else if (m_channelWidth == 160)
218  {
219  if (m_nss == 3)
220  {
221  return (modeName != "VhtMcs9");
222  }
223  }
224  return true;
225 }
226 
227 std::ostream & operator << ( std::ostream &os, const WifiTxVector &v)
228 {
229  os << "mode: " << v.GetMode () <<
230  " txpwrlvl: " << +v.GetTxPowerLevel () <<
231  " preamble: " << v.GetPreambleType () <<
232  " channel width: " << v.GetChannelWidth () <<
233  " GI: " << v.GetGuardInterval () <<
234  " NTx: " << +v.GetNTx () <<
235  " Nss: " << +v.GetNss () <<
236  " Ness: " << +v.GetNess () <<
237  " MPDU aggregation: " << v.IsAggregation () <<
238  " STBC: " << v.IsStbc ();
239  return os;
240 }
241 
242 } //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 SetStbc(bool stbc)
Sets if STBC is being used.
bool IsStbc(void) const
Check if STBC is used or not.
#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:30
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:463
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.
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
bool m_txPowerLevelInitialized
Internal initialization flag.
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