A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ht-ppdu.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 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> (HtSigHeader)
9 */
10
11#include "ht-ppdu.h"
12
13#include "ht-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#include "ns3/wifi-utils.h"
20
21namespace ns3
22{
23
25
27 const WifiTxVector& txVector,
28 const WifiPhyOperatingChannel& channel,
29 Time ppduDuration,
30 uint64_t uid)
31 : OfdmPpdu(psdu,
32 txVector,
33 channel,
34 uid,
35 false) // don't instantiate LSigHeader of OfdmPpdu
36{
37 NS_LOG_FUNCTION(this << psdu << txVector << channel << ppduDuration << uid);
38 SetPhyHeaders(txVector, ppduDuration, psdu->GetSize());
39}
40
41void
42HtPpdu::SetPhyHeaders(const WifiTxVector& txVector, Time ppduDuration, std::size_t psduSize)
43{
44 NS_LOG_FUNCTION(this << txVector << ppduDuration << psduSize);
45 SetLSigHeader(m_lSig, ppduDuration);
46 SetHtSigHeader(m_htSig, txVector, psduSize);
47}
48
49void
50HtPpdu::SetLSigHeader(LSigHeader& lSig, Time ppduDuration) const
51{
52 uint8_t sigExtension = 0;
55 {
56 sigExtension = 6;
57 }
58 uint16_t length = ((ceil((static_cast<double>(ppduDuration.GetNanoSeconds() - (20 * 1000) -
59 (sigExtension * 1000)) /
60 1000) /
61 4.0) *
62 3) -
63 3);
64 lSig.SetLength(length);
65}
66
67void
68HtPpdu::SetHtSigHeader(HtSigHeader& htSig, const WifiTxVector& txVector, std::size_t psduSize) const
69{
70 htSig.SetMcs(txVector.GetMode().GetMcsValue());
71 htSig.SetChannelWidth(txVector.GetChannelWidth());
72 htSig.SetHtLength(psduSize);
73 htSig.SetAggregation(txVector.IsAggregation());
74 htSig.SetShortGuardInterval(txVector.GetGuardInterval().GetNanoSeconds() == 400);
75}
76
79{
80 WifiTxVector txVector;
83 return txVector;
84}
85
86void
88 const LSigHeader& lSig,
89 const HtSigHeader& htSig) const
90{
91 txVector.SetMode(HtPhy::GetHtMcs(htSig.GetMcs()));
92 txVector.SetChannelWidth(htSig.GetChannelWidth());
93 txVector.SetNss(1 + (htSig.GetMcs() / 8));
94 txVector.SetGuardInterval(NanoSeconds(htSig.GetShortGuardInterval() ? 400 : 800));
95 txVector.SetAggregation(htSig.GetAggregation());
96}
97
98Time
100{
101 const auto& txVector = GetTxVector();
102 const auto htLength = m_htSig.GetHtLength();
104 return WifiPhy::CalculateTxDuration(htLength, txVector, m_operatingChannel.GetPhyBand());
105}
106
109{
110 return Ptr<WifiPpdu>(new HtPpdu(*this), false);
111}
112
114 : m_mcs(0),
115 m_cbw20_40(0),
116 m_htLength(0),
117 m_aggregation(0),
118 m_sgi(0)
119{
120}
121
122void
124{
125 NS_ASSERT(mcs <= 31);
126 m_mcs = mcs;
127}
128
129uint8_t
131{
132 return m_mcs;
133}
134
135void
137{
138 m_cbw20_40 = (channelWidth > 20) ? 1 : 0;
139}
140
141MHz_u
143{
144 return m_cbw20_40 ? 40 : 20;
145}
146
147void
149{
150 m_htLength = length;
151}
152
153uint16_t
155{
156 return m_htLength;
157}
158
159void
161{
162 m_aggregation = aggregation ? 1 : 0;
163}
164
165bool
167{
168 return m_aggregation;
169}
170
171void
173{
174 m_sgi = sgi ? 1 : 0;
175}
176
177bool
179{
180 return m_sgi;
181}
182
183} // namespace ns3
static WifiMode GetHtMcs(uint8_t index)
Return the HT MCS corresponding to the provided index.
Definition ht-phy.cc:482
HT PHY header (HT-SIG1/2).
Definition ht-ppdu.h:41
uint16_t GetHtLength() const
Return the HT length field of HT-SIG (in bytes).
Definition ht-ppdu.cc:154
uint8_t GetMcs() const
Return the MCS field of HT-SIG.
Definition ht-ppdu.cc:130
void SetHtLength(uint16_t length)
Fill the HT length field of HT-SIG (in bytes).
Definition ht-ppdu.cc:148
bool GetAggregation() const
Return the aggregation field of HT-SIG.
Definition ht-ppdu.cc:166
void SetMcs(uint8_t mcs)
Fill the MCS field of HT-SIG.
Definition ht-ppdu.cc:123
void SetChannelWidth(MHz_u channelWidth)
Fill the channel width field of HT-SIG.
Definition ht-ppdu.cc:136
bool GetShortGuardInterval() const
Return the short guard interval field of HT-SIG.
Definition ht-ppdu.cc:178
MHz_u GetChannelWidth() const
Return the channel width.
Definition ht-ppdu.cc:142
void SetAggregation(bool aggregation)
Fill the aggregation field of HT-SIG.
Definition ht-ppdu.cc:160
void SetShortGuardInterval(bool sgi)
Fill the short guard interval field of HT-SIG.
Definition ht-ppdu.cc:172
HtSigHeader m_htSig
the HT-SIG PHY header
Definition ht-ppdu.h:174
HtPpdu(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector, const WifiPhyOperatingChannel &channel, Time ppduDuration, uint64_t uid)
Create an HT PPDU.
Definition ht-ppdu.cc:26
WifiTxVector DoGetTxVector() const override
Get the TXVECTOR used to send the PPDU.
Definition ht-ppdu.cc:78
Ptr< WifiPpdu > Copy() const override
Copy this instance.
Definition ht-ppdu.cc:108
void SetHtSigHeader(HtSigHeader &htSig, const WifiTxVector &txVector, std::size_t psduSize) const
Fill in the HT-SIG header.
Definition ht-ppdu.cc:68
virtual void SetLSigHeader(LSigHeader &lSig, Time ppduDuration) const
Fill in the L-SIG header.
Definition ht-ppdu.cc:50
void SetPhyHeaders(const WifiTxVector &txVector, Time ppduDuration, std::size_t psduSize)
Fill in the PHY headers.
Definition ht-ppdu.cc:42
void SetTxVectorFromPhyHeaders(WifiTxVector &txVector, const LSigHeader &lSig, const HtSigHeader &htSig) const
Fill in the TXVECTOR from PHY headers.
Definition ht-ppdu.cc:87
Time GetTxDuration() const override
Get the total transmission duration of the PPDU.
Definition ht-ppdu.cc:99
OFDM and ERP OFDM L-SIG PHY header.
Definition ofdm-ppdu.h:43
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
uint8_t GetMcsValue() const
Definition wifi-mode.cc:152
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
Definition wifi-phy.cc:1572
Class that keeps track of all information about the current PHY operating channel.
bool IsSet() const
Return true if a valid channel has been set, false otherwise.
WifiPhyBand GetPhyBand() const
Return the PHY band of the operating channel.
const WifiPhyOperatingChannel & m_operatingChannel
the operating channel of the PHY
Definition wifi-ppdu.h:201
WifiPreamble m_preamble
the PHY preamble
Definition wifi-ppdu.h:192
const WifiTxVector & GetTxVector() const
Get the TXVECTOR used to send the PPDU.
Definition wifi-ppdu.cc:113
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.
MHz_u GetChannelWidth() const
bool IsAggregation() const
Checks whether the PSDU contains A-MPDU.
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 NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1344
@ WIFI_PHY_BAND_2_4GHZ
The 2.4 GHz band.
Declaration of ns3::HtPhy class.
Declaration of ns3::HtPpdu class.
Every class exported by the ns3 library is enclosed in the ns3 namespace.