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_retries (0),
28  m_preamble (WIFI_PREAMBLE_NONE),
29  m_channelWidth (20),
30  m_guardInterval (800),
31  m_nTx (1),
32  m_nss (1),
33  m_ness (0),
34  m_aggregation (false),
35  m_stbc (false),
36  m_modeInitialized (false),
37  m_txPowerLevelInitialized (false)
38 {
39 }
40 
42  uint8_t powerLevel,
43  uint8_t retries,
44  WifiPreamble preamble,
45  uint16_t guardInterval,
46  uint8_t nTx,
47  uint8_t nss,
48  uint8_t ness,
49  uint8_t channelWidth,
50  bool aggregation,
51  bool stbc)
52  : m_mode (mode),
53  m_txPowerLevel (powerLevel),
54  m_retries (retries),
55  m_preamble (preamble),
56  m_channelWidth (channelWidth),
57  m_guardInterval (guardInterval),
58  m_nTx (nTx),
59  m_nss (nss),
60  m_ness (ness),
61  m_aggregation (aggregation),
62  m_stbc (stbc),
63  m_modeInitialized (true),
64  m_txPowerLevelInitialized (true)
65 {
66 }
67 
70 {
71  if (!m_modeInitialized)
72  {
73  NS_FATAL_ERROR ("WifiTxVector mode must be set before using");
74  }
75  return m_mode;
76 }
77 
78 uint8_t
80 {
82  {
83  NS_FATAL_ERROR ("WifiTxVector txPowerLevel must be set before using");
84  }
85  return m_txPowerLevel;
86 }
87 
88 uint8_t
90 {
91  return m_retries;
92 }
93 
96 {
97  return m_preamble;
98 }
99 
100 uint8_t
102 {
103  return m_channelWidth;
104 }
105 
106 uint16_t
108 {
109  return m_guardInterval;
110 }
111 
112 uint8_t
114 {
115  return m_nTx;
116 }
117 
118 uint8_t
120 {
121  return m_nss;
122 }
123 
124 uint8_t
126 {
127  return m_ness;
128 }
129 
130 bool
132 {
133  return m_aggregation;
134 }
135 
136 bool
138 {
139  return m_stbc;
140 }
141 
142 void
144 {
145  m_mode = mode;
146  m_modeInitialized = true;
147 }
148 
149 void
150 WifiTxVector::SetTxPowerLevel (uint8_t powerlevel)
151 {
152  m_txPowerLevel = powerlevel;
154 }
155 
156 void
157 WifiTxVector::SetRetries (uint8_t retries)
158 {
159  m_retries = retries;
160 }
161 
162 void
164 {
165  m_preamble = preamble;
166 }
167 
168 void
169 WifiTxVector::SetChannelWidth (uint8_t channelWidth)
170 {
171  m_channelWidth = channelWidth;
172 }
173 
174 void
175 WifiTxVector::SetGuardInterval (uint16_t guardInterval)
176 {
177  m_guardInterval = guardInterval;
178 }
179 
180 void
181 WifiTxVector::SetNTx (uint8_t nTx)
182 {
183  m_nTx = nTx;
184 }
185 
186 void
187 WifiTxVector::SetNss (uint8_t nss)
188 {
189  m_nss = nss;
190 }
191 
192 void
193 WifiTxVector::SetNess (uint8_t ness)
194 {
195  m_ness = ness;
196 }
197 
198 void
200 {
201  m_aggregation = aggregation;
202 }
203 
204 void
206 {
207  m_stbc = stbc;
208 }
209 
210 std::ostream & operator << ( std::ostream &os, const WifiTxVector &v)
211 {
212  os << "mode: " << v.GetMode () <<
213  " txpwrlvl: " << (uint16_t)v.GetTxPowerLevel () <<
214  " retries: " << (uint16_t)v.GetRetries () <<
215  " preamble: " << v.GetPreambleType () <<
216  " channel width: " << (uint16_t)v.GetChannelWidth () <<
217  " GI: " << v.GetGuardInterval () <<
218  " NTx: " << (uint16_t)v.GetNTx () <<
219  " Nss: " << (uint16_t)v.GetNss () <<
220  " Ness: " << (uint16_t)v.GetNess () <<
221  " MPDU aggregation: " << v.IsAggregation () <<
222  " STBC: " << v.IsStbc ();
223  return os;
224 }
225 
226 } //namespace ns3
uint16_t GetGuardInterval(void) const
uint8_t m_nTx
number of TX antennas
uint8_t m_channelWidth
channel width in MHz
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
bool IsAggregation(void) const
Checks whether the PSDU contains A-MPDU.
void SetStbc(bool stbc)
Sets if STBC is being used.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:97
uint8_t GetTxPowerLevel(void) const
uint8_t m_nss
number of spatial streams
uint8_t GetChannelWidth(void) const
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Definition: wifi-preamble.h:30
void SetGuardInterval(uint16_t guardInterval)
Sets the guard interval duration (in nanoseconds)
uint8_t GetNess(void) const
uint16_t m_guardInterval
guard interval duration in nanoseconds
bool IsStbc(void) const
Check if STBC is used or not.
uint8_t m_retries
The DATA_RETRIES/RTS_RETRIES parameter for Click radiotap information.
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.
WifiPreamble GetPreambleType(void) const
uint8_t GetNss(void) const
uint8_t GetNTx(void) const
void SetNess(uint8_t ness)
Sets the Ness number refer to IEEE 802.11n Table 20-6 for explanation.
void SetRetries(uint8_t retries)
Sets the number of retries.
void SetChannelWidth(uint8_t channelWidth)
Sets the selected channelWidth (in MHz)
uint8_t GetRetries(void) const
uint8_t m_ness
number of spatial streams in beamforming
WifiMode GetMode(void) const
bool m_txPowerLevelInitialized
Internal initialization flag.
uint8_t m_txPowerLevel
The TXPWR_LEVEL parameter in Table 15-4.
WifiMode m_mode
The DATARATE parameter in Table 15-4.
WifiPreamble m_preamble
preamble