10#include "ns3/dsss-phy.h"
11#include "ns3/eht-phy.h"
12#include "ns3/eht-ppdu.h"
13#include "ns3/erp-ofdm-phy.h"
16#include "ns3/packet.h"
17#include "ns3/simulator.h"
19#include "ns3/wifi-psdu.h"
20#include "ns3/yans-wifi-phy.h"
40 void DoRun()
override;
97 std::list<HeMuUserInfo> userInfos,
118 std::list<uint16_t> staIds,
148 std::list<WifiPhyBand> testedBands;
162 for (
auto& testedBand : testedBands)
170 Time calculatedDuration = phy->GetPayloadDuration(size, txVector, testedBand);
171 if (calculatedDuration != knownDuration)
173 std::cerr <<
"size=" << size <<
" band=" << testedBand <<
" mode=" << payloadMode
174 <<
" channelWidth=" << channelWidth <<
" guardInterval=" << guardInterval
175 <<
" datarate=" << payloadMode.
GetDataRate(channelWidth, guardInterval, 1)
176 <<
" known=" << knownDuration <<
" calculated=" << calculatedDuration
200 std::list<WifiPhyBand> testedBands;
214 for (
auto& testedBand : testedBands)
222 Time calculatedDuration = phy->CalculateTxDuration(size, txVector, testedBand);
223 Time calculatedDurationUsingList =
228 if (calculatedDuration != knownDuration ||
229 calculatedDuration != calculatedDurationUsingList)
231 std::cerr <<
"size=" << size <<
" band=" << testedBand <<
" mode=" << payloadMode
232 <<
" channelWidth=" << +channelWidth <<
" guardInterval=" << guardInterval
233 <<
" datarate=" << payloadMode.
GetDataRate(channelWidth, guardInterval, 1)
234 <<
" preamble=" << preamble <<
" known=" << knownDuration
235 <<
" calculated=" << calculatedDuration
236 <<
" calculatedUsingList=" << calculatedDurationUsingList << std::endl;
245 std::list<HeMuUserInfo> userInfos,
251 NS_ASSERT(sizes.size() == userInfos.size() && sizes.size() > 1);
253 channelWidth < std::accumulate(
254 std::begin(userInfos),
260 "Cannot accommodate all the RUs in the provided band");
272 std::list<uint16_t> staIds;
275 for (
const auto& userInfo : userInfos)
278 staIds.push_back(staId++);
284 std::list<WifiPhyBand> testedBands{
289 for (
auto& testedBand : testedBands)
296 Time calculatedDuration;
298 auto iterStaId = staIds.begin();
299 for (
auto& size : sizes)
301 Time ppduDurationForSta =
302 phy->CalculateTxDuration(size, txVector, testedBand, *iterStaId);
303 if (ppduDurationForSta > calculatedDuration)
305 calculatedDuration = ppduDurationForSta;
311 Time calculatedDurationUsingList =
313 if (calculatedDuration != knownDuration ||
314 calculatedDuration != calculatedDurationUsingList)
316 std::cerr <<
"size=" << longestSize <<
" band=" << testedBand <<
" staId=" << staId
317 <<
" nss=" << +txVector.
GetNss(staId) <<
" mode=" << txVector.
GetMode(staId)
318 <<
" channelWidth=" << channelWidth <<
" guardInterval=" << guardInterval
323 <<
" known=" << knownDuration <<
" calculated=" << calculatedDuration
324 <<
" calculatedUsingList=" << calculatedDurationUsingList << std::endl;
333 std::list<uint16_t> staIds,
337 NS_ASSERT(sizes.size() == staIds.size());
339 auto itStaId = staIds.begin();
342 for (
auto& size : sizes)
345 psduMap[*itStaId++] =
1382 std::list<uint32_t>{1536, 1536},
1468 MuType expectedMuType,
1470 const std::pair<std::size_t, std::size_t>& expectedNumUsersPerCc,
1471 Time expectedSigBDuration);
1474 void DoRun()
override;
1488 std::pair<std::size_t, std::size_t>
1494 const std::list<HeMuUserInfo>& userInfos,
1499 const std::pair<std::size_t, std::size_t>& expectedNumUsersPerCc,
1500 Time expectedSigBDuration)
1501 :
TestCase{
"Check HE-SIG-B duration computation"},
1502 m_userInfos{userInfos},
1503 m_sigBMode{sigBMode},
1504 m_channelWidth{channelWidth},
1505 m_expectedMuType{expectedMuType},
1506 m_expectedRuAllocation{expectedRuAllocation},
1507 m_expectedNumUsersPerCc{expectedNumUsersPerCc},
1508 m_expectedSigBDuration{expectedSigBDuration}
1521 std::list<uint16_t> staIds;
1526 staIds.push_back(staId++);
1542 "Incorrect mode used to send HE-SIG-B");
1547 "Incorrect RU_ALLOCATION");
1551 txVector.GetChannelWidth(),
1552 txVector.GetRuAllocation(0),
1553 txVector.IsSigBCompression(),
1554 txVector.IsSigBCompression() ? txVector.GetHeMuUserInfoMap().size() : 0);
1558 "Incorrect number of users in HE-SIG-B content channel 1");
1561 "Incorrect number of users in HE-SIG-B content channel 2");
1564 "Incorrect number of users in HE-SIG-B content channel 1");
1567 "Incorrect number of users in HE-SIG-B content channel 2");
1572 "Incorrect duration for HE-SIG-B");
1586 void DoRun()
override;
1601 :
TestCase(
"PHY header sections consistency")
1614 "The expected map size (" << expected.size() <<
") was not obtained ("
1615 << obtained.size() <<
")");
1617 auto itObtained = obtained.begin();
1618 auto itExpected = expected.begin();
1619 for (; itObtained != obtained.end() || itExpected != expected.end();)
1622 auto window = itObtained->second.first;
1623 auto mode = itObtained->second.second;
1626 auto windowRef = itExpected->second.first;
1627 auto modeRef = itExpected->second.second;
1631 "The expected PPDU field (" << fieldRef <<
") was not obtained ("
1635 "The expected start time (" << windowRef.first
1636 <<
") was not obtained (" << window.first
1640 "The expected stop time (" << windowRef.second
1641 <<
") was not obtained (" << window.second
1645 "The expected mode (" << modeRef <<
") was not obtained (" << mode
1697 std::map<OfdmPhyVariant, std::size_t> variants{
1703 for (
auto variant : variants)
1706 std::size_t ratio = variant.second;
1707 MHz_u bw = 20 / ratio;
1713 {{ppduStart, ppduStart +
MicroSeconds(16 * ratio)}, nonHtMode}},
1819 std::map<uint16_t, HeMuUserInfo> userInfoMap = {{1, {{
HeRu::RU_106_TONE, 1,
true}, 4, 2}},
1821 sigAMode = HePhy::GetVhtMcs0();
1822 sigBMode = HePhy::GetVhtMcs4();
1893 WifiMode uSigMode = EhtPhy::GetVhtMcs0();
1894 WifiMode ehtSigMode = EhtPhy::GetVhtMcs4();
1949 {{{
HeRu::RU_106_TONE, 1,
true}, 11, 1}, {{
HeRu::RU_106_TONE, 2,
true}, 10, 4}},
1954 std::make_pair(2, 0),
1956 TestCase::Duration::QUICK);
1970 std::make_pair(2, 4),
1973 TestCase::Duration::QUICK);
1988 std::make_pair(2, 5),
1991 TestCase::Duration::QUICK);
2008 std::make_pair(3, 6),
2011 TestCase::Duration::QUICK);
2028 {96, 15, 192, 192, 208, 208, 208, 208},
2029 std::make_pair(4, 7),
2032 TestCase::Duration::QUICK);
2048 std::make_pair(9, 0),
2050 TestCase::Duration::QUICK);
2063 std::make_pair(4, 4),
2065 TestCase::Duration::QUICK);
2079 std::make_pair(4, 4),
2081 TestCase::Duration::QUICK);
2085 {{{
HeRu::RU_242_TONE, 1,
true}, 11, 1}, {{
HeRu::RU_242_TONE, 1,
true}, 10, 4}},
2090 std::make_pair(2, 0),
2092 TestCase::Duration::QUICK);
2103 std::make_pair(3, 0),
2105 TestCase::Duration::QUICK);
2117 std::make_pair(4, 0),
2119 TestCase::Duration::QUICK);
2133 std::make_pair(6, 0),
2135 TestCase::Duration::QUICK);
2151 std::make_pair(8, 0),
2153 TestCase::Duration::QUICK);
2157 {{{
HeRu::RU_484_TONE, 1,
true}, 11, 1}, {{
HeRu::RU_484_TONE, 1,
true}, 10, 4}},
2162 std::make_pair(1, 1),
2164 TestCase::Duration::QUICK);
2176 std::make_pair(2, 1),
2178 TestCase::Duration::QUICK);
2190 std::make_pair(2, 2),
2192 TestCase::Duration::QUICK);
2206 std::make_pair(3, 3),
2208 TestCase::Duration::QUICK);
2224 std::make_pair(4, 4),
2226 TestCase::Duration::QUICK);
2230 {{{
HeRu::RU_996_TONE, 1,
true}, 11, 1}, {{
HeRu::RU_996_TONE, 1,
true}, 10, 4}},
2234 {208, 208, 208, 208},
2235 std::make_pair(1, 1),
2237 TestCase::Duration::QUICK);
2248 {208, 208, 208, 208},
2249 std::make_pair(2, 1),
2251 TestCase::Duration::QUICK);
2262 {208, 208, 208, 208},
2263 std::make_pair(2, 2),
2265 TestCase::Duration::QUICK);
2278 {208, 208, 208, 208},
2279 std::make_pair(3, 3),
2281 TestCase::Duration::QUICK);
2296 {208, 208, 208, 208},
2297 std::make_pair(4, 4),
2299 TestCase::Duration::QUICK);
2304 {{{
HeRu::RU_2x996_TONE, 1,
true}, 11, 1}, {{
HeRu::RU_2x996_TONE, 1,
true}, 10, 4}},
2308 {208, 208, 208, 208, 208, 208, 208, 208},
2309 std::make_pair(1, 1),
2311 TestCase::Duration::QUICK);
2322 {208, 208, 208, 208, 208, 208, 208, 208},
2323 std::make_pair(2, 1),
2325 TestCase::Duration::QUICK);
2336 {208, 208, 208, 208, 208, 208, 208, 208},
2337 std::make_pair(2, 2),
2339 TestCase::Duration::QUICK);
2352 {208, 208, 208, 208, 208, 208, 208, 208},
2353 std::make_pair(3, 3),
2355 TestCase::Duration::QUICK);
2370 {208, 208, 208, 208, 208, 208, 208, 208},
2371 std::make_pair(4, 4),
2373 TestCase::Duration::QUICK);
std::list< HeMuUserInfo > m_userInfos
HE MU specific per-user information.
MuType m_expectedMuType
Expected MU type (OFDMA or MU-MIMO)
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.
HeSigBDurationTest(const std::list< HeMuUserInfo > &userInfos, const WifiMode &sigBMode, MHz_u channelWidth, MuType expectedMuType, const RuAllocation &expectedRuAllocation, const std::pair< std::size_t, std::size_t > &expectedNumUsersPerCc, Time expectedSigBDuration)
Constructor.
MHz_u m_channelWidth
Channel width.
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.
~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.
bool CheckTxDuration(uint32_t size, WifiMode payloadMode, MHz_u channelWidth, Time guardInterval, WifiPreamble preamble, Time knownDuration)
Check if the overall tx duration returned by InterferenceHelper corresponds to a known value.
static bool CheckMuTxDuration(std::list< uint32_t > sizes, std::list< HeMuUserInfo > userInfos, MHz_u channelWidth, Time guardInterval, WifiPreamble preamble, Time knownDuration)
Check if the overall Tx duration returned by WifiPhy for a MU PPDU corresponds to a known value.
void DoRun() override
Implementation to actually run this TestCase.
bool CheckPayloadDuration(uint32_t size, WifiMode payloadMode, MHz_u channelWidth, Time guardInterval, WifiPreamble preamble, Time knownDuration)
Check if the payload tx duration returned by InterferenceHelper corresponds to a known value.
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 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...
static std::pair< std::size_t, std::size_t > GetNumRusPerHeSigBContentChannel(MHz_u channelWidth, const RuAllocation &ruAllocation, bool sigBCompression, uint8_t numMuMimoUsers)
Get the number of STAs per HE-SIG-B content channel.
RuType GetRuType() const
Get the RU type.
static MHz_u 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 GetOfdmRate(uint64_t rate, MHz_u bw=20)
Return a WifiMode for OFDM corresponding to the provided rate and the channel bandwidth (20,...
static WifiMode GetOfdmRate54Mbps()
Return a WifiMode for OFDM at 54 Mbps.
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, Duration duration=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(MHz_u channelWidth, Time 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 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 SetHeMuUserInfo(uint16_t staId, HeMuUserInfo userInfo)
Set the HE MU user-specific transmission information for the given STA-ID.
void SetChannelWidth(MHz_u channelWidth)
Sets the selected channelWidth.
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.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
#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.
static constexpr uint16_t SU_STA_ID
STA_ID to identify a single user (SU)
std::vector< uint16_t > RuAllocation
9 bits RU_ALLOCATION per 20 MHz
HE MU specific user transmission parameters.
HeRu::RuSpec ru
RU specification.
static TxDurationTestSuite g_txDurationTestSuite
the test suite