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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Rediet <getachew.redieteab@orange.com>
7 * Muhammad Iqbal Rochman <muhiqbalcr@uchicago.edu>
8 * Sébastien Deronne <sebastien.deronne@gmail.com> (VhtSigHeader)
9 */
10
11#include "vht-ppdu.h"
12
13#include "vht-phy.h"
14
15#include "ns3/log.h"
16#include "ns3/wifi-phy-operating-channel.h"
17#include "ns3/wifi-phy.h"
18#include "ns3/wifi-psdu.h"
19
20namespace ns3
21{
22
24
26 const WifiTxVector& txVector,
27 const WifiPhyOperatingChannel& channel,
28 Time ppduDuration,
29 uint64_t uid)
30 : OfdmPpdu(psdu,
31 txVector,
32 channel,
33 uid,
34 false) // don't instantiate LSigHeader of OfdmPpdu
35{
36 NS_LOG_FUNCTION(this << psdu << txVector << channel << ppduDuration << uid);
37 SetPhyHeaders(txVector, ppduDuration);
38}
39
40void
41VhtPpdu::SetPhyHeaders(const WifiTxVector& txVector, Time ppduDuration)
42{
43 NS_LOG_FUNCTION(this << txVector << ppduDuration);
44 SetLSigHeader(m_lSig, ppduDuration);
45 SetVhtSigHeader(m_vhtSig, txVector, ppduDuration);
46}
47
48void
49VhtPpdu::SetLSigHeader(LSigHeader& lSig, Time ppduDuration) const
50{
51 uint16_t length =
52 ((ceil((static_cast<double>(ppduDuration.GetNanoSeconds() - (20 * 1000)) / 1000) / 4.0) *
53 3) -
54 3);
55 lSig.SetLength(length);
56}
57
58void
60 const WifiTxVector& txVector,
61 Time ppduDuration) const
62{
64 vhtSig.SetChannelWidth(txVector.GetChannelWidth());
65 const auto sgi = txVector.GetGuardInterval().GetNanoSeconds() == 400;
66 vhtSig.SetShortGuardInterval(sgi);
67 uint32_t nSymbols =
68 (static_cast<double>(
69 (ppduDuration - WifiPhy::CalculatePhyPreambleAndHeaderDuration(txVector))
70 .GetNanoSeconds()) /
71 (3200 + txVector.GetGuardInterval().GetNanoSeconds()));
72 if (sgi)
73 {
74 vhtSig.SetShortGuardIntervalDisambiguation((nSymbols % 10) == 9);
75 }
76 vhtSig.SetSuMcs(txVector.GetMode().GetMcsValue());
77 vhtSig.SetNStreams(txVector.GetNss());
78}
79
82{
83 WifiTxVector txVector;
86 return txVector;
87}
88
89void
91 const LSigHeader& lSig,
92 const VhtSigHeader& vhtSig) const
93{
94 txVector.SetMode(VhtPhy::GetVhtMcs(vhtSig.GetSuMcs()));
95 txVector.SetChannelWidth(vhtSig.GetChannelWidth());
96 txVector.SetNss(vhtSig.GetNStreams());
97 txVector.SetGuardInterval(NanoSeconds(vhtSig.GetShortGuardInterval() ? 400 : 800));
98 txVector.SetAggregation(GetPsdu()->IsAggregate());
99}
100
101Time
103{
104 const auto& txVector = GetTxVector();
105 const auto length = m_lSig.GetLength();
106 const auto sgi = m_vhtSig.GetShortGuardInterval();
107 const auto sgiDisambiguation = m_vhtSig.GetShortGuardIntervalDisambiguation();
108 const auto tSymbol = NanoSeconds(3200) + txVector.GetGuardInterval();
109 const auto preambleDuration = WifiPhy::CalculatePhyPreambleAndHeaderDuration(txVector);
110 const auto calculatedDuration =
111 MicroSeconds(((ceil(static_cast<double>(length + 3) / 3)) * 4) + 20);
112 uint32_t nSymbols =
113 floor(static_cast<double>((calculatedDuration - preambleDuration).GetNanoSeconds()) /
114 tSymbol.GetNanoSeconds());
115 if (sgi && sgiDisambiguation)
116 {
117 nSymbols--;
118 }
119 return (preambleDuration + (nSymbols * tSymbol));
120}
121
124{
125 return Ptr<WifiPpdu>(new VhtPpdu(*this), false);
126}
127
133
135 : m_bw(0),
136 m_nsts(0),
137 m_sgi(0),
138 m_sgi_disambiguation(0),
139 m_suMcs(0),
140 m_mu(false)
141{
142}
143
144void
146{
147 m_mu = mu;
148}
149
150void
152{
153 if (channelWidth == 160)
154 {
155 m_bw = 3;
156 }
157 else if (channelWidth == 80)
158 {
159 m_bw = 2;
160 }
161 else if (channelWidth == 40)
162 {
163 m_bw = 1;
164 }
165 else
166 {
167 m_bw = 0;
168 }
169}
170
171MHz_u
173{
174 if (m_bw == 3)
175 {
176 return 160;
177 }
178 else if (m_bw == 2)
179 {
180 return 80;
181 }
182 else if (m_bw == 1)
183 {
184 return 40;
185 }
186 else
187 {
188 return 20;
189 }
190}
191
192void
194{
195 NS_ASSERT(nStreams <= 8);
196 m_nsts = (nStreams - 1);
197}
198
199uint8_t
201{
202 return (m_nsts + 1);
203}
204
205void
207{
208 m_sgi = sgi ? 1 : 0;
209}
210
211bool
213{
214 return m_sgi;
215}
216
217void
219{
220 m_sgi_disambiguation = disambiguation ? 1 : 0;
221}
222
223bool
225{
226 return m_sgi_disambiguation;
227}
228
229void
231{
232 NS_ASSERT(mcs <= 9);
233 m_suMcs = mcs;
234}
235
236uint8_t
238{
239 return m_suMcs;
240}
241
242} // namespace ns3
OFDM and ERP OFDM L-SIG PHY header.
Definition ofdm-ppdu.h:43
uint16_t GetLength() const
Return the LENGTH field of L-SIG (in bytes).
Definition ofdm-ppdu.cc:199
void SetLength(uint16_t length)
Fill the LENGTH field of L-SIG (in bytes).
Definition ofdm-ppdu.cc:192
OFDM PPDU (11a)
Definition ofdm-ppdu.h:36
LSigHeader m_lSig
the L-SIG PHY header
Definition ofdm-ppdu.h:99
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
int64_t GetNanoSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition nstime.h:407
static WifiMode GetVhtMcs(uint8_t index)
Return the VHT MCS corresponding to the provided index.
Definition vht-phy.cc:334
VHT PHY header (VHT-SIG-A1/A2/B).
Definition vht-ppdu.h:42
void SetNStreams(uint8_t nStreams)
Fill the number of streams field of VHT-SIG-A1.
Definition vht-ppdu.cc:193
MHz_u GetChannelWidth() const
Return the channel width.
Definition vht-ppdu.cc:172
uint8_t GetSuMcs() const
Return the SU VHT MCS field of VHT-SIG-A2.
Definition vht-ppdu.cc:237
uint8_t GetNStreams() const
Return the number of streams.
Definition vht-ppdu.cc:200
bool GetShortGuardInterval() const
Return the short GI field of VHT-SIG-A2.
Definition vht-ppdu.cc:212
void SetMuFlag(bool mu)
Set the Multi-User (MU) flag.
Definition vht-ppdu.cc:145
void SetSuMcs(uint8_t mcs)
Fill the SU VHT MCS field of VHT-SIG-A2.
Definition vht-ppdu.cc:230
void SetChannelWidth(MHz_u channelWidth)
Fill the channel width field of VHT-SIG-A1.
Definition vht-ppdu.cc:151
void SetShortGuardIntervalDisambiguation(bool disambiguation)
Fill the short GI NSYM disambiguation field of VHT-SIG-A2.
Definition vht-ppdu.cc:218
bool GetShortGuardIntervalDisambiguation() const
Return the short GI NSYM disambiguation field of VHT-SIG-A2.
Definition vht-ppdu.cc:224
void SetShortGuardInterval(bool sgi)
Fill the short guard interval field of VHT-SIG-A2.
Definition vht-ppdu.cc:206
VhtSigHeader m_vhtSig
the VHT-SIG PHY header
Definition vht-ppdu.h:189
virtual void SetPhyHeaders(const WifiTxVector &txVector, Time ppduDuration)
Fill in the PHY headers.
Definition vht-ppdu.cc:41
WifiPpduType GetType() const override
Return the PPDU type (.
Definition vht-ppdu.cc:129
WifiTxVector DoGetTxVector() const override
Get the TXVECTOR used to send the PPDU.
Definition vht-ppdu.cc:81
VhtPpdu(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector, const WifiPhyOperatingChannel &channel, Time ppduDuration, uint64_t uid)
Create a VHT PPDU.
Definition vht-ppdu.cc:25
void SetTxVectorFromPhyHeaders(WifiTxVector &txVector, const LSigHeader &lSig, const VhtSigHeader &vhtSig) const
Fill in the TXVECTOR from PHY headers.
Definition vht-ppdu.cc:90
void SetVhtSigHeader(VhtSigHeader &vhtSig, const WifiTxVector &txVector, Time ppduDuration) const
Fill in the VHT-SIG header.
Definition vht-ppdu.cc:59
Time GetTxDuration() const override
Get the total transmission duration of the PPDU.
Definition vht-ppdu.cc:102
Ptr< WifiPpdu > Copy() const override
Copy this instance.
Definition vht-ppdu.cc:123
virtual void SetLSigHeader(LSigHeader &lSig, Time ppduDuration) const
Fill in the L-SIG header.
Definition vht-ppdu.cc:49
uint8_t GetMcsValue() const
Definition wifi-mode.cc:152
static Time CalculatePhyPreambleAndHeaderDuration(const WifiTxVector &txVector)
Definition wifi-phy.cc:1565
Class that keeps track of all information about the current PHY operating channel.
WifiPreamble m_preamble
the PHY preamble
Definition wifi-ppdu.h:192
Ptr< const WifiPsdu > GetPsdu() const
Get the payload of the PPDU.
Definition wifi-ppdu.cc:149
const WifiTxVector & GetTxVector() const
Get the TXVECTOR used to send the PPDU.
Definition wifi-ppdu.cc:113
bool IsAggregate() const
Return true if the PSDU is an S-MPDU or A-MPDU.
Definition wifi-psdu.cc:72
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void SetGuardInterval(Time 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.
void SetChannelWidth(MHz_u channelWidth)
Sets the selected channelWidth.
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.
MHz_u GetChannelWidth() const
Time GetGuardInterval() 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:55
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#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:1332
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1344
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.