A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
vht-ppdu.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Orange Labs
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Rediet <getachew.redieteab@orange.com>
18 * Muhammad Iqbal Rochman <muhiqbalcr@uchicago.edu>
19 * Sébastien Deronne <sebastien.deronne@gmail.com> (VhtSigHeader)
20 */
21
22#include "vht-ppdu.h"
23
24#include "vht-phy.h"
25
26#include "ns3/log.h"
27#include "ns3/wifi-phy-operating-channel.h"
28#include "ns3/wifi-phy.h"
29#include "ns3/wifi-psdu.h"
30
31namespace ns3
32{
33
35
37 const WifiTxVector& txVector,
38 const WifiPhyOperatingChannel& channel,
39 Time ppduDuration,
40 uint64_t uid)
41 : OfdmPpdu(psdu,
42 txVector,
43 channel,
44 uid,
45 false) // don't instantiate LSigHeader of OfdmPpdu
46{
47 NS_LOG_FUNCTION(this << psdu << txVector << channel << ppduDuration << uid);
48 SetPhyHeaders(txVector, ppduDuration);
49}
50
51void
52VhtPpdu::SetPhyHeaders(const WifiTxVector& txVector, Time ppduDuration)
53{
54 NS_LOG_FUNCTION(this << txVector << ppduDuration);
55 SetLSigHeader(m_lSig, ppduDuration);
56 SetVhtSigHeader(m_vhtSig, txVector, ppduDuration);
57}
58
59void
60VhtPpdu::SetLSigHeader(LSigHeader& lSig, Time ppduDuration) const
61{
62 uint16_t length =
63 ((ceil((static_cast<double>(ppduDuration.GetNanoSeconds() - (20 * 1000)) / 1000) / 4.0) *
64 3) -
65 3);
66 lSig.SetLength(length);
67}
68
69void
71 const WifiTxVector& txVector,
72 Time ppduDuration) const
73{
75 vhtSig.SetChannelWidth(txVector.GetChannelWidth());
76 vhtSig.SetShortGuardInterval(txVector.GetGuardInterval() == 400);
77 uint32_t nSymbols =
78 (static_cast<double>(
79 (ppduDuration - WifiPhy::CalculatePhyPreambleAndHeaderDuration(txVector))
80 .GetNanoSeconds()) /
81 (3200 + txVector.GetGuardInterval()));
82 if (txVector.GetGuardInterval() == 400)
83 {
84 vhtSig.SetShortGuardIntervalDisambiguation((nSymbols % 10) == 9);
85 }
86 vhtSig.SetSuMcs(txVector.GetMode().GetMcsValue());
87 vhtSig.SetNStreams(txVector.GetNss());
88}
89
92{
93 WifiTxVector txVector;
96 return txVector;
97}
98
99void
101 const LSigHeader& lSig,
102 const VhtSigHeader& vhtSig) const
103{
104 txVector.SetMode(VhtPhy::GetVhtMcs(vhtSig.GetSuMcs()));
105 txVector.SetChannelWidth(vhtSig.GetChannelWidth());
106 txVector.SetNss(vhtSig.GetNStreams());
107 txVector.SetGuardInterval(vhtSig.GetShortGuardInterval() ? 400 : 800);
108 txVector.SetAggregation(GetPsdu()->IsAggregate());
109}
110
111Time
113{
114 const auto& txVector = GetTxVector();
115 const auto length = m_lSig.GetLength();
116 const auto sgi = m_vhtSig.GetShortGuardInterval();
117 const auto sgiDisambiguation = m_vhtSig.GetShortGuardIntervalDisambiguation();
118 const auto tSymbol = NanoSeconds(3200 + txVector.GetGuardInterval());
119 const auto preambleDuration = WifiPhy::CalculatePhyPreambleAndHeaderDuration(txVector);
120 const auto calculatedDuration =
121 MicroSeconds(((ceil(static_cast<double>(length + 3) / 3)) * 4) + 20);
122 uint32_t nSymbols =
123 floor(static_cast<double>((calculatedDuration - preambleDuration).GetNanoSeconds()) /
124 tSymbol.GetNanoSeconds());
125 if (sgi && sgiDisambiguation)
126 {
127 nSymbols--;
128 }
129 return (preambleDuration + (nSymbols * tSymbol));
130}
131
134{
135 return Ptr<WifiPpdu>(new VhtPpdu(*this), false);
136}
137
140{
142}
143
145 : m_bw(0),
146 m_nsts(0),
147 m_sgi(0),
148 m_sgi_disambiguation(0),
149 m_suMcs(0),
150 m_mu(false)
151{
152}
153
154void
156{
157 m_mu = mu;
158}
159
160void
162{
163 if (channelWidth == 160)
164 {
165 m_bw = 3;
166 }
167 else if (channelWidth == 80)
168 {
169 m_bw = 2;
170 }
171 else if (channelWidth == 40)
172 {
173 m_bw = 1;
174 }
175 else
176 {
177 m_bw = 0;
178 }
179}
180
181uint16_t
183{
184 if (m_bw == 3)
185 {
186 return 160;
187 }
188 else if (m_bw == 2)
189 {
190 return 80;
191 }
192 else if (m_bw == 1)
193 {
194 return 40;
195 }
196 else
197 {
198 return 20;
199 }
200}
201
202void
204{
205 NS_ASSERT(nStreams <= 8);
206 m_nsts = (nStreams - 1);
207}
208
209uint8_t
211{
212 return (m_nsts + 1);
213}
214
215void
217{
218 m_sgi = sgi ? 1 : 0;
219}
220
221bool
223{
224 return m_sgi;
225}
226
227void
229{
230 m_sgi_disambiguation = disambiguation ? 1 : 0;
231}
232
233bool
235{
236 return m_sgi_disambiguation;
237}
238
239void
241{
242 NS_ASSERT(mcs <= 9);
243 m_suMcs = mcs;
244}
245
246uint8_t
248{
249 return m_suMcs;
250}
251
252} // namespace ns3
OFDM and ERP OFDM L-SIG PHY header.
Definition: ofdm-ppdu.h:54
uint16_t GetLength() const
Return the LENGTH field of L-SIG (in bytes).
Definition: ofdm-ppdu.cc:210
void SetLength(uint16_t length)
Fill the LENGTH field of L-SIG (in bytes).
Definition: ofdm-ppdu.cc:203
OFDM PPDU (11a)
Definition: ofdm-ppdu.h:47
LSigHeader m_lSig
the L-SIG PHY header
Definition: ofdm-ppdu.h:110
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
int64_t GetNanoSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:418
static WifiMode GetVhtMcs(uint8_t index)
Return the VHT MCS corresponding to the provided index.
Definition: vht-phy.cc:345
VHT PHY header (VHT-SIG-A1/A2/B).
Definition: vht-ppdu.h:53
void SetNStreams(uint8_t nStreams)
Fill the number of streams field of VHT-SIG-A1.
Definition: vht-ppdu.cc:203
void SetChannelWidth(uint16_t channelWidth)
Fill the channel width field of VHT-SIG-A1 (in MHz).
Definition: vht-ppdu.cc:161
uint16_t GetChannelWidth() const
Return the channel width (in MHz).
Definition: vht-ppdu.cc:182
uint8_t GetSuMcs() const
Return the SU VHT MCS field of VHT-SIG-A2.
Definition: vht-ppdu.cc:247
uint8_t GetNStreams() const
Return the number of streams.
Definition: vht-ppdu.cc:210
bool GetShortGuardInterval() const
Return the short GI field of VHT-SIG-A2.
Definition: vht-ppdu.cc:222
void SetMuFlag(bool mu)
Set the Multi-User (MU) flag.
Definition: vht-ppdu.cc:155
void SetSuMcs(uint8_t mcs)
Fill the SU VHT MCS field of VHT-SIG-A2.
Definition: vht-ppdu.cc:240
void SetShortGuardIntervalDisambiguation(bool disambiguation)
Fill the short GI NSYM disambiguation field of VHT-SIG-A2.
Definition: vht-ppdu.cc:228
bool GetShortGuardIntervalDisambiguation() const
Return the short GI NSYM disambiguation field of VHT-SIG-A2.
Definition: vht-ppdu.cc:234
void SetShortGuardInterval(bool sgi)
Fill the short guard interval field of VHT-SIG-A2.
Definition: vht-ppdu.cc:216
VHT PPDU (11ac)
Definition: vht-ppdu.h:46
VhtSigHeader m_vhtSig
the VHT-SIG PHY header
Definition: vht-ppdu.h:200
virtual void SetPhyHeaders(const WifiTxVector &txVector, Time ppduDuration)
Fill in the PHY headers.
Definition: vht-ppdu.cc:52
WifiPpduType GetType() const override
Return the PPDU type (.
Definition: vht-ppdu.cc:139
WifiTxVector DoGetTxVector() const override
Get the TXVECTOR used to send the PPDU.
Definition: vht-ppdu.cc:91
VhtPpdu(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector, const WifiPhyOperatingChannel &channel, Time ppduDuration, uint64_t uid)
Create a VHT PPDU.
Definition: vht-ppdu.cc:36
void SetTxVectorFromPhyHeaders(WifiTxVector &txVector, const LSigHeader &lSig, const VhtSigHeader &vhtSig) const
Fill in the TXVECTOR from PHY headers.
Definition: vht-ppdu.cc:100
void SetVhtSigHeader(VhtSigHeader &vhtSig, const WifiTxVector &txVector, Time ppduDuration) const
Fill in the VHT-SIG header.
Definition: vht-ppdu.cc:70
Time GetTxDuration() const override
Get the total transmission duration of the PPDU.
Definition: vht-ppdu.cc:112
Ptr< WifiPpdu > Copy() const override
Copy this instance.
Definition: vht-ppdu.cc:133
virtual void SetLSigHeader(LSigHeader &lSig, Time ppduDuration) const
Fill in the L-SIG header.
Definition: vht-ppdu.cc:60
uint8_t GetMcsValue() const
Definition: wifi-mode.cc:163
static Time CalculatePhyPreambleAndHeaderDuration(const WifiTxVector &txVector)
Definition: wifi-phy.cc:1522
Class that keeps track of all information about the current PHY operating channel.
WifiPreamble m_preamble
the PHY preamble
Definition: wifi-ppdu.h:202
Ptr< const WifiPsdu > GetPsdu() const
Get the payload of the PPDU.
Definition: wifi-ppdu.cc:121
const WifiTxVector & GetTxVector() const
Get the TXVECTOR used to send the PPDU.
Definition: wifi-ppdu.cc:85
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
uint16_t GetGuardInterval() const
void SetChannelWidth(uint16_t channelWidth)
Sets the selected channelWidth (in MHz)
void SetGuardInterval(uint16_t guardInterval)
Sets the guard interval duration (in nanoseconds)
WifiMode GetMode(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the selected payload transmission mode.
void SetAggregation(bool aggregation)
Sets if PSDU contains A-MPDU.
uint8_t GetNss(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the number of spatial streams.
uint16_t GetChannelWidth() const
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
void SetNss(uint8_t nss)
Sets the number of Nss.
void SetPreambleType(WifiPreamble preamble)
Sets the preamble type.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1350
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1362
WifiPpduType
The type of PPDU (SU, DL MU, or UL MU)
@ WIFI_PREAMBLE_VHT_MU
@ WIFI_PPDU_TYPE_DL_MU
@ WIFI_PPDU_TYPE_SU
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Declaration of ns3::VhtPhy class.
Declaration of ns3::VhtPpdu class.