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++] =
1245 std::list<uint32_t>{1536, 1536},
1330 uint16_t channelWidth,
1333 const std::pair<std::size_t, std::size_t>& expectedNumUsersPerCc,
1334 Time expectedSigBDuration);
1337 void DoRun()
override;
1351 std::pair<std::size_t, std::size_t>
1357 const std::list<HeMuUserInfo>& userInfos,
1359 uint16_t channelWidth,
1362 const std::pair<std::size_t, std::size_t>& expectedNumUsersPerCc,
1363 Time expectedSigBDuration)
1364 :
TestCase{
"Check HE-SIG-B duration computation"},
1365 m_userInfos{userInfos},
1366 m_sigBMode{sigBMode},
1367 m_channelWidth{channelWidth},
1368 m_expectedMuType{expectedMuType},
1369 m_expectedRuAllocation{expectedRuAllocation},
1370 m_expectedNumUsersPerCc{expectedNumUsersPerCc},
1371 m_expectedSigBDuration{expectedSigBDuration}
1384 std::list<uint16_t> staIds;
1389 staIds.push_back(staId++);
1405 "Incorrect mode used to send HE-SIG-B");
1410 "Incorrect RU_ALLOCATION");
1414 txVector.GetChannelWidth(),
1415 txVector.GetRuAllocation(0),
1416 txVector.IsSigBCompression(),
1417 txVector.IsSigBCompression() ? txVector.GetHeMuUserInfoMap().size() : 0);
1421 "Incorrect number of users in HE-SIG-B content channel 1");
1424 "Incorrect number of users in HE-SIG-B content channel 2");
1427 "Incorrect number of users in HE-SIG-B content channel 1");
1430 "Incorrect number of users in HE-SIG-B content channel 2");
1435 "Incorrect duration for HE-SIG-B");
1449 void DoRun()
override;
1464 :
TestCase(
"PHY header sections consistency")
1477 "The expected map size (" << expected.size() <<
") was not obtained ("
1478 << obtained.size() <<
")");
1480 auto itObtained = obtained.begin();
1481 auto itExpected = expected.begin();
1482 for (; itObtained != obtained.end() || itExpected != expected.end();)
1485 auto window = itObtained->second.first;
1486 auto mode = itObtained->second.second;
1489 auto windowRef = itExpected->second.first;
1490 auto modeRef = itExpected->second.second;
1494 "The expected PPDU field (" << fieldRef <<
") was not obtained ("
1498 "The expected start time (" << windowRef.first
1499 <<
") was not obtained (" << window.first
1503 "The expected stop time (" << windowRef.second
1504 <<
") was not obtained (" << window.second
1508 "The expected mode (" << modeRef <<
") was not obtained (" << mode
1526 phyEntity = Create<DsssPhy>();
1560 std::map<OfdmPhyVariant, std::size_t> variants{
1566 for (
auto variant : variants)
1568 phyEntity = Create<OfdmPhy>(variant.first);
1569 std::size_t ratio = variant.second;
1570 uint16_t bw = 20 / ratio;
1576 {{ppduStart, ppduStart +
MicroSeconds(16 * ratio)}, nonHtMode}},
1586 phyEntity = Create<ErpOfdmPhy>();
1599 phyEntity = Create<HtPhy>(4);
1634 phyEntity = Create<VhtPhy>();
1677 phyEntity = Create<HePhy>();
1682 std::map<uint16_t, HeMuUserInfo> userInfoMap = {{1, {{
HeRu::RU_106_TONE, 1,
true}, 4, 2}},
1684 sigAMode = HePhy::GetVhtMcs0();
1685 sigBMode = HePhy::GetVhtMcs4();
1749 phyEntity = Create<EhtPhy>();
1756 WifiMode uSigMode = EhtPhy::GetVhtMcs0();
1757 WifiMode ehtSigMode = EhtPhy::GetVhtMcs4();
1804 :
TestSuite(
"wifi-devices-tx-duration", UNIT)
1812 {{{
HeRu::RU_106_TONE, 1,
true}, 11, 1}, {{
HeRu::RU_106_TONE, 2,
true}, 10, 4}},
1817 std::make_pair(2, 0),
1833 std::make_pair(2, 4),
1851 std::make_pair(2, 5),
1871 std::make_pair(3, 6),
1891 {96, 15, 192, 192, 208, 208, 208, 208},
1892 std::make_pair(4, 7),
1911 std::make_pair(9, 0),
1926 std::make_pair(4, 4),
1942 std::make_pair(4, 4),
1948 {{{
HeRu::RU_242_TONE, 1,
true}, 11, 1}, {{
HeRu::RU_242_TONE, 1,
true}, 10, 4}},
1953 std::make_pair(2, 0),
1966 std::make_pair(3, 0),
1980 std::make_pair(4, 0),
1996 std::make_pair(6, 0),
2014 std::make_pair(8, 0),
2020 {{{
HeRu::RU_484_TONE, 1,
true}, 11, 1}, {{
HeRu::RU_484_TONE, 1,
true}, 10, 4}},
2025 std::make_pair(1, 1),
2039 std::make_pair(2, 1),
2053 std::make_pair(2, 2),
2069 std::make_pair(3, 3),
2087 std::make_pair(4, 4),
2093 {{{
HeRu::RU_996_TONE, 1,
true}, 11, 1}, {{
HeRu::RU_996_TONE, 1,
true}, 10, 4}},
2097 {208, 208, 208, 208},
2098 std::make_pair(1, 1),
2111 {208, 208, 208, 208},
2112 std::make_pair(2, 1),
2125 {208, 208, 208, 208},
2126 std::make_pair(2, 2),
2141 {208, 208, 208, 208},
2142 std::make_pair(3, 3),
2159 {208, 208, 208, 208},
2160 std::make_pair(4, 4),
2167 {{{
HeRu::RU_2x996_TONE, 1,
true}, 11, 1}, {{
HeRu::RU_2x996_TONE, 1,
true}, 10, 4}},
2171 {208, 208, 208, 208, 208, 208, 208, 208},
2172 std::make_pair(1, 1),
2185 {208, 208, 208, 208, 208, 208, 208, 208},
2186 std::make_pair(2, 1),
2199 {208, 208, 208, 208, 208, 208, 208, 208},
2200 std::make_pair(2, 2),
2215 {208, 208, 208, 208, 208, 208, 208, 208},
2216 std::make_pair(3, 3),
2233 {208, 208, 208, 208, 208, 208, 208, 208},
2234 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