21#include "ns3/dsss-phy.h"
22#include "ns3/eht-phy.h"
23#include "ns3/eht-ppdu.h"
24#include "ns3/erp-ofdm-phy.h"
27#include "ns3/packet.h"
28#include "ns3/simulator.h"
30#include "ns3/wifi-psdu.h"
31#include "ns3/yans-wifi-phy.h"
51 void DoRun()
override;
69 uint16_t channelWidth,
70 uint16_t guardInterval,
89 uint16_t channelWidth,
90 uint16_t guardInterval,
108 std::list<HeMuUserInfo> userInfos,
109 uint16_t channelWidth,
110 uint16_t guardInterval,
129 std::list<uint16_t> staIds,
146 uint16_t channelWidth,
147 uint16_t guardInterval,
159 std::list<WifiPhyBand> testedBands;
173 for (
auto& testedBand : testedBands)
181 Time calculatedDuration = phy->GetPayloadDuration(size, txVector, testedBand);
182 if (calculatedDuration != knownDuration)
184 std::cerr <<
"size=" << size <<
" band=" << testedBand <<
" mode=" << payloadMode
185 <<
" channelWidth=" << channelWidth <<
" guardInterval=" << guardInterval
186 <<
" datarate=" << payloadMode.
GetDataRate(channelWidth, guardInterval, 1)
187 <<
" known=" << knownDuration <<
" calculated=" << calculatedDuration
198 uint16_t channelWidth,
199 uint16_t guardInterval,
211 std::list<WifiPhyBand> testedBands;
225 for (
auto& testedBand : testedBands)
233 Time calculatedDuration = phy->CalculateTxDuration(size, txVector, testedBand);
234 Time calculatedDurationUsingList =
239 if (calculatedDuration != knownDuration ||
240 calculatedDuration != calculatedDurationUsingList)
242 std::cerr <<
"size=" << size <<
" band=" << testedBand <<
" mode=" << payloadMode
243 <<
" channelWidth=" << +channelWidth <<
" guardInterval=" << guardInterval
244 <<
" datarate=" << payloadMode.
GetDataRate(channelWidth, guardInterval, 1)
245 <<
" preamble=" << preamble <<
" known=" << knownDuration
246 <<
" calculated=" << calculatedDuration
247 <<
" calculatedUsingList=" << calculatedDurationUsingList << std::endl;
256 std::list<HeMuUserInfo> userInfos,
257 uint16_t channelWidth,
258 uint16_t guardInterval,
262 NS_ASSERT(sizes.size() == userInfos.size() && sizes.size() > 1);
264 channelWidth < std::accumulate(
265 std::begin(userInfos),
271 "Cannot accommodate all the RUs in the provided band");
283 std::list<uint16_t> staIds;
286 for (
const auto& userInfo : userInfos)
289 staIds.push_back(staId++);
295 std::list<WifiPhyBand> testedBands{
300 for (
auto& testedBand : testedBands)
309 auto iterStaId = staIds.begin();
310 for (
auto& size : sizes)
312 Time ppduDurationForSta =
313 phy->CalculateTxDuration(size, txVector, testedBand, *iterStaId);
314 if (ppduDurationForSta > calculatedDuration)
316 calculatedDuration = ppduDurationForSta;
322 Time calculatedDurationUsingList =
324 if (calculatedDuration != knownDuration ||
325 calculatedDuration != calculatedDurationUsingList)
327 std::cerr <<
"size=" << longestSize <<
" band=" << testedBand <<
" staId=" << staId
328 <<
" nss=" << +txVector.
GetNss(staId) <<
" mode=" << txVector.
GetMode(staId)
329 <<
" channelWidth=" << channelWidth <<
" guardInterval=" << guardInterval
334 <<
" known=" << knownDuration <<
" calculated=" << calculatedDuration
335 <<
" calculatedUsingList=" << calculatedDurationUsingList << std::endl;
344 std::list<uint16_t> staIds,
348 NS_ASSERT(sizes.size() == staIds.size());
350 auto itStaId = staIds.begin();
353 for (
auto& size : sizes)
356 psduMap[*itStaId++] =
1244 std::list<uint32_t>{1536, 1536},
1329 uint16_t channelWidth,
1332 const std::pair<std::size_t, std::size_t>& expectedNumUsersPerCc,
1333 Time expectedSigBDuration);
1336 void DoRun()
override;
1350 std::pair<std::size_t, std::size_t>
1356 const std::list<HeMuUserInfo>& userInfos,
1358 uint16_t channelWidth,
1361 const std::pair<std::size_t, std::size_t>& expectedNumUsersPerCc,
1362 Time expectedSigBDuration)
1363 :
TestCase{
"Check HE-SIG-B duration computation"},
1364 m_userInfos{userInfos},
1365 m_sigBMode{sigBMode},
1366 m_channelWidth{channelWidth},
1367 m_expectedMuType{expectedMuType},
1368 m_expectedRuAllocation{expectedRuAllocation},
1369 m_expectedNumUsersPerCc{expectedNumUsersPerCc},
1370 m_expectedSigBDuration{expectedSigBDuration}
1383 std::list<uint16_t> staIds;
1388 staIds.push_back(staId++);
1404 "Incorrect mode used to send HE-SIG-B");
1409 "Incorrect RU_ALLOCATION");
1413 txVector.GetChannelWidth(),
1414 txVector.GetRuAllocation(0),
1415 txVector.IsSigBCompression(),
1416 txVector.IsSigBCompression() ? txVector.GetHeMuUserInfoMap().size() : 0);
1420 "Incorrect number of users in HE-SIG-B content channel 1");
1423 "Incorrect number of users in HE-SIG-B content channel 2");
1426 "Incorrect number of users in HE-SIG-B content channel 1");
1429 "Incorrect number of users in HE-SIG-B content channel 2");
1434 "Incorrect duration for HE-SIG-B");
1448 void DoRun()
override;
1463 :
TestCase(
"PHY header sections consistency")
1476 "The expected map size (" << expected.size() <<
") was not obtained ("
1477 << obtained.size() <<
")");
1479 auto itObtained = obtained.begin();
1480 auto itExpected = expected.begin();
1481 for (; itObtained != obtained.end() || itExpected != expected.end();)
1484 auto window = itObtained->second.first;
1485 auto mode = itObtained->second.second;
1488 auto windowRef = itExpected->second.first;
1489 auto modeRef = itExpected->second.second;
1493 "The expected PPDU field (" << fieldRef <<
") was not obtained ("
1497 "The expected start time (" << windowRef.first
1498 <<
") was not obtained (" << window.first
1502 "The expected stop time (" << windowRef.second
1503 <<
") was not obtained (" << window.second
1507 "The expected mode (" << modeRef <<
") was not obtained (" << mode
1525 phyEntity = Create<DsssPhy>();
1559 std::map<OfdmPhyVariant, std::size_t> variants{
1565 for (
auto variant : variants)
1567 phyEntity = Create<OfdmPhy>(variant.first);
1568 std::size_t ratio = variant.second;
1569 uint16_t bw = 20 / ratio;
1575 {{ppduStart, ppduStart +
MicroSeconds(16 * ratio)}, nonHtMode}},
1585 phyEntity = Create<ErpOfdmPhy>();
1598 phyEntity = Create<HtPhy>(4);
1633 phyEntity = Create<VhtPhy>();
1676 phyEntity = Create<HePhy>();
1681 std::map<uint16_t, HeMuUserInfo> userInfoMap = {{1, {{
HeRu::RU_106_TONE, 1,
true}, 4, 2}},
1683 sigAMode = HePhy::GetVhtMcs0();
1684 sigBMode = HePhy::GetVhtMcs4();
1748 phyEntity = Create<EhtPhy>();
1755 WifiMode uSigMode = EhtPhy::GetVhtMcs0();
1756 WifiMode ehtSigMode = EhtPhy::GetVhtMcs4();
1803 :
TestSuite(
"wifi-devices-tx-duration", UNIT)
1811 {{{
HeRu::RU_106_TONE, 1,
true}, 11, 1}, {{
HeRu::RU_106_TONE, 2,
true}, 10, 4}},
1816 std::make_pair(2, 0),
1832 std::make_pair(2, 4),
1850 std::make_pair(2, 5),
1870 std::make_pair(3, 6),
1890 {96, 15, 192, 192, 208, 208, 208, 208},
1891 std::make_pair(4, 7),
1910 std::make_pair(9, 0),
1925 std::make_pair(4, 4),
1941 std::make_pair(4, 4),
1947 {{{
HeRu::RU_242_TONE, 1,
true}, 11, 1}, {{
HeRu::RU_242_TONE, 1,
true}, 10, 4}},
1952 std::make_pair(2, 0),
1965 std::make_pair(3, 0),
1979 std::make_pair(4, 0),
1995 std::make_pair(6, 0),
2013 std::make_pair(8, 0),
2019 {{{
HeRu::RU_484_TONE, 1,
true}, 11, 1}, {{
HeRu::RU_484_TONE, 1,
true}, 10, 4}},
2024 std::make_pair(1, 1),
2038 std::make_pair(2, 1),
2052 std::make_pair(2, 2),
2068 std::make_pair(3, 3),
2086 std::make_pair(4, 4),
2092 {{{
HeRu::RU_996_TONE, 1,
true}, 11, 1}, {{
HeRu::RU_996_TONE, 1,
true}, 10, 4}},
2096 {208, 208, 208, 208},
2097 std::make_pair(1, 1),
2110 {208, 208, 208, 208},
2111 std::make_pair(2, 1),
2124 {208, 208, 208, 208},
2125 std::make_pair(2, 2),
2140 {208, 208, 208, 208},
2141 std::make_pair(3, 3),
2158 {208, 208, 208, 208},
2159 std::make_pair(4, 4),
2166 {{{
HeRu::RU_2x996_TONE, 1,
true}, 11, 1}, {{
HeRu::RU_2x996_TONE, 1,
true}, 10, 4}},
2170 {208, 208, 208, 208, 208, 208, 208, 208},
2171 std::make_pair(1, 1),
2184 {208, 208, 208, 208, 208, 208, 208, 208},
2185 std::make_pair(2, 1),
2198 {208, 208, 208, 208, 208, 208, 208, 208},
2199 std::make_pair(2, 2),
2214 {208, 208, 208, 208, 208, 208, 208, 208},
2215 std::make_pair(3, 3),
2232 {208, 208, 208, 208, 208, 208, 208, 208},
2233 std::make_pair(4, 4),
std::list< HeMuUserInfo > m_userInfos
HE MU specific per-user information.
MuType m_expectedMuType
Expected MU type (OFDMA or MU-MIMO)
HeSigBDurationTest(const std::list< HeMuUserInfo > &userInfos, const WifiMode &sigBMode, uint16_t channelWidth, MuType expectedMuType, const RuAllocation &expectedRuAllocation, const std::pair< std::size_t, std::size_t > &expectedNumUsersPerCc, Time expectedSigBDuration)
Constructor.
RuAllocation m_expectedRuAllocation
Expected RU_ALLOCATION.
Time m_expectedSigBDuration
Expected duration of the HE-SIG-B header.
WifiMode m_sigBMode
Mode used to transmit HE-SIG-B.
WifiTxVector BuildTxVector() const
Build a TXVECTOR for HE MU.
void DoRun() override
Implementation to actually run this TestCase.
std::pair< std::size_t, std::size_t > m_expectedNumUsersPerCc
Expected number of users per content channel.
uint16_t m_channelWidth
Channel width in MHz.
~TxDurationTest() override
static Time CalculateTxDurationUsingList(std::list< uint32_t > sizes, std::list< uint16_t > staIds, WifiTxVector txVector, WifiPhyBand band)
Calculate the overall Tx duration returned by WifiPhy for list of sizes.
static bool CheckMuTxDuration(std::list< uint32_t > sizes, std::list< HeMuUserInfo > userInfos, uint16_t channelWidth, uint16_t guardInterval, WifiPreamble preamble, Time knownDuration)
Check if the overall Tx duration returned by WifiPhy for a MU PPDU corresponds to a known value.
bool CheckTxDuration(uint32_t size, WifiMode payloadMode, uint16_t channelWidth, uint16_t guardInterval, WifiPreamble preamble, Time knownDuration)
Check if the overall tx duration returned by InterferenceHelper corresponds to a known value.
bool CheckPayloadDuration(uint32_t size, WifiMode payloadMode, uint16_t channelWidth, uint16_t guardInterval, WifiPreamble preamble, Time knownDuration)
Check if the payload tx duration returned by InterferenceHelper corresponds to a known value.
void DoRun() override
Implementation to actually run this TestCase.
static WifiMode GetDsssRate5_5Mbps()
Return a WifiMode for HR/DSSS at 5.5 Mbps.
static WifiMode GetDsssRate1Mbps()
Return a WifiMode for DSSS at 1 Mbps.
static WifiMode GetDsssRate11Mbps()
Return a WifiMode for HR/DSSS at 11 Mbps.
static WifiMode GetDsssRate2Mbps()
Return a WifiMode for DSSS at 2 Mbps.
static WifiMode GetEhtMcs9()
Return MCS 9 from EHT MCS values.
static WifiMode GetErpOfdmRate(uint64_t rate)
Return a WifiMode for ERP-OFDM corresponding to the provided rate.
static WifiMode GetErpOfdmRate6Mbps()
Return a WifiMode for ERP-OFDM at 6 Mbps.
static WifiMode GetErpOfdmRate54Mbps()
Return a WifiMode for ERP-OFDM at 54 Mbps.
static WifiMode GetHeMcs9()
Return MCS 9 from HE MCS values.
static WifiMode GetHeMcs11()
Return MCS 11 from HE MCS values.
static WifiMode GetHeMcs0()
Return MCS 0 from HE MCS values.
static std::pair< std::size_t, std::size_t > GetNumRusPerHeSigBContentChannel(uint16_t channelWidth, const RuAllocation &ruAllocation, bool sigBCompression, uint8_t numMuMimoUsers)
Get the number of STAs per HE-SIG-B content channel.
static HeSigBContentChannels GetHeSigBContentChannels(const WifiTxVector &txVector, uint8_t p20Index)
Get the HE SIG-B content channels for a given PPDU IEEE 802.11ax-2021 27.3.11.8.2 HE-SIG-B content ch...
RuType GetRuType() const
Get the RU type.
static uint16_t GetBandwidth(RuType ruType)
Get the approximate bandwidth occupied by a RU.
static WifiMode GetHtMcs0()
Return MCS 0 from HT MCS values.
static WifiMode GetHtMcs6()
Return MCS 6 from HT MCS values.
static WifiMode GetHtMcs7()
Return MCS 7 from HT MCS values.
static WifiMode GetOfdmRate6Mbps()
Return a WifiMode for OFDM at 6 Mbps.
static WifiMode GetOfdmRate54Mbps()
Return a WifiMode for OFDM at 54 Mbps.
static WifiMode GetOfdmRate(uint64_t rate, uint16_t bw=20)
Return a WifiMode for OFDM corresponding to the provided rate and the channel bandwidth (20,...
std::map< WifiPpduField, PhyHeaderChunkInfo > PhyHeaderSections
A map of PhyHeaderChunkInfo elements per PPDU field.
Smart pointer class similar to boost::intrusive_ptr.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
static WifiMode GetVhtMcs0()
Return MCS 0 from VHT MCS values.
static WifiMode GetVhtMcs5()
Return MCS 5 from VHT MCS values.
static WifiMode GetVhtMcs3()
Return MCS 3 from VHT MCS values.
static WifiMode GetVhtMcs1()
Return MCS 1 from VHT MCS values.
static WifiMode GetVhtMcs4()
Return MCS 4 from VHT MCS values.
static WifiMode GetVhtMcs9()
Return MCS 9 from VHT MCS values.
static WifiMode GetVhtMcs8()
Return MCS 8 from VHT MCS values.
static WifiMode GetVhtMcs7()
Return MCS 7 from VHT MCS values.
represent a single transmission mode
WifiModulationClass GetModulationClass() const
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
static const Ptr< const PhyEntity > GetStaticPhyEntity(WifiModulationClass modulation)
Get the implemented PHY entity corresponding to the modulation class.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void SetRuAllocation(const RuAllocation &ruAlloc, uint8_t p20Index)
Set RU_ALLOCATION field.
void SetStbc(bool stbc)
Sets if STBC is being used.
void SetNess(uint8_t ness)
Sets the Ness number.
void SetEhtPpduType(uint8_t type)
Set the EHT_PPDU_TYPE parameter.
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 SetHeMuUserInfo(uint16_t staId, HeMuUserInfo userInfo)
Set the HE MU user-specific transmission information for the given STA-ID.
bool IsDlOfdma() const
Return true if this TX vector is used for a downlink multi-user transmission using OFDMA.
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.
void SetSigBMode(const WifiMode &mode)
Set the MCS used for SIG-B.
bool IsDlMuMimo() const
Return true if this TX vector is used for a downlink multi-user transmission using MU-MIMO.
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,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
WifiPhyBand
Identifies the PHY band.
WifiPpduField
The type of PPDU field (grouped for convenience)
@ WIFI_PHY_BAND_6GHZ
The 6 GHz band.
@ WIFI_PHY_BAND_2_4GHZ
The 2.4 GHz band.
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
@ WIFI_MOD_CLASS_OFDM
OFDM (Clause 17)
@ WIFI_MOD_CLASS_VHT
VHT (Clause 22)
@ WIFI_MOD_CLASS_HE
HE (Clause 27)
@ WIFI_PPDU_FIELD_SIG_B
SIG-B field.
@ WIFI_PPDU_FIELD_TRAINING
STF + LTF fields (excluding those in preamble for HT-GF)
@ WIFI_PPDU_FIELD_NON_HT_HEADER
PHY header field for DSSS or ERP, short PHY header field for HR/DSSS or ERP, field not present for HT...
@ WIFI_PPDU_FIELD_EHT_SIG
EHT-SIG field.
@ WIFI_PPDU_FIELD_HT_SIG
HT-SIG field.
@ WIFI_PPDU_FIELD_PREAMBLE
SYNC + SFD fields for DSSS or ERP, shortSYNC + shortSFD fields for HR/DSSS or ERP,...
@ WIFI_PPDU_FIELD_U_SIG
U-SIG field.
@ WIFI_PPDU_FIELD_SIG_A
SIG-A field.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
bool IsEht(WifiPreamble preamble)
Return true if a preamble corresponds to an EHT transmission.
std::vector< uint8_t > RuAllocation
8 bit RU_ALLOCATION per 20 MHz
static constexpr uint16_t SU_STA_ID
STA_ID to identify a single user (SU)
HE MU specific user transmission parameters.
HeRu::RuSpec ru
RU specification.
static TxDurationTestSuite g_txDurationTestSuite
the test suite