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"
50 void DoRun()
override;
68 uint16_t channelWidth,
69 uint16_t guardInterval,
88 uint16_t channelWidth,
89 uint16_t guardInterval,
107 std::list<HeMuUserInfo> userInfos,
108 uint16_t channelWidth,
109 uint16_t guardInterval,
128 std::list<uint16_t> staIds,
145 uint16_t channelWidth,
146 uint16_t guardInterval,
158 std::list<WifiPhyBand> testedBands;
172 for (
auto& testedBand : testedBands)
180 Time calculatedDuration = phy->GetPayloadDuration(size, txVector, testedBand);
181 if (calculatedDuration != knownDuration)
183 std::cerr <<
"size=" << size <<
" band=" << testedBand <<
" mode=" << payloadMode
184 <<
" channelWidth=" << channelWidth <<
" guardInterval=" << guardInterval
185 <<
" datarate=" << payloadMode.
GetDataRate(channelWidth, guardInterval, 1)
186 <<
" known=" << knownDuration <<
" calculated=" << calculatedDuration
197 uint16_t channelWidth,
198 uint16_t guardInterval,
210 std::list<WifiPhyBand> testedBands;
224 for (
auto& testedBand : testedBands)
232 Time calculatedDuration = phy->CalculateTxDuration(size, txVector, testedBand);
233 Time calculatedDurationUsingList =
238 if (calculatedDuration != knownDuration ||
239 calculatedDuration != calculatedDurationUsingList)
241 std::cerr <<
"size=" << size <<
" band=" << testedBand <<
" mode=" << payloadMode
242 <<
" channelWidth=" << +channelWidth <<
" guardInterval=" << guardInterval
243 <<
" datarate=" << payloadMode.
GetDataRate(channelWidth, guardInterval, 1)
244 <<
" preamble=" << preamble <<
" known=" << knownDuration
245 <<
" calculated=" << calculatedDuration
246 <<
" calculatedUsingList=" << calculatedDurationUsingList << std::endl;
255 std::list<HeMuUserInfo> userInfos,
256 uint16_t channelWidth,
257 uint16_t guardInterval,
261 NS_ASSERT(sizes.size() == userInfos.size() && sizes.size() > 1);
263 channelWidth < std::accumulate(
264 std::begin(userInfos),
270 "Cannot accommodate all the RUs in the provided band");
282 std::list<uint16_t> staIds;
285 for (
const auto& userInfo : userInfos)
288 staIds.push_back(staId++);
294 std::list<WifiPhyBand> testedBands{
299 for (
auto& testedBand : testedBands)
308 auto iterStaId = staIds.begin();
309 for (
auto& size : sizes)
311 Time ppduDurationForSta =
312 phy->CalculateTxDuration(size, txVector, testedBand, *iterStaId);
313 if (ppduDurationForSta > calculatedDuration)
315 calculatedDuration = ppduDurationForSta;
321 Time calculatedDurationUsingList =
323 if (calculatedDuration != knownDuration ||
324 calculatedDuration != calculatedDurationUsingList)
326 std::cerr <<
"size=" << longestSize <<
" band=" << testedBand <<
" staId=" << staId
327 <<
" nss=" << +txVector.
GetNss(staId) <<
" mode=" << txVector.
GetMode(staId)
328 <<
" channelWidth=" << channelWidth <<
" guardInterval=" << guardInterval
333 <<
" known=" << knownDuration <<
" calculated=" << calculatedDuration
334 <<
" calculatedUsingList=" << calculatedDurationUsingList << std::endl;
343 std::list<uint16_t> staIds,
347 NS_ASSERT(sizes.size() == staIds.size());
349 auto itStaId = staIds.begin();
352 for (
auto& size : sizes)
355 psduMap[*itStaId++] =
1243 std::list<uint32_t>{1536, 1536},
1318 uint16_t channelWidth,
1320 const std::pair<std::size_t, std::size_t>& expectedNumUsersPerCc,
1321 Time expectedSigBDuration);
1324 void DoRun()
override;
1337 std::pair<std::size_t, std::size_t>
1343 const std::list<HeMuUserInfo>& userInfos,
1345 uint16_t channelWidth,
1347 const std::pair<std::size_t, std::size_t>& expectedNumUsersPerCc,
1348 Time expectedSigBDuration)
1349 :
TestCase{
"Check HE-SIG-B duration computation"},
1350 m_userInfos{userInfos},
1351 m_sigBMode{sigBMode},
1352 m_channelWidth{channelWidth},
1353 m_expectedRuAllocation{expectedRuAllocation},
1354 m_expectedNumUsersPerCc{expectedNumUsersPerCc},
1355 m_expectedSigBDuration{expectedSigBDuration}
1368 std::list<uint16_t> staIds;
1373 staIds.push_back(staId++);
1388 "Incorrect mode used to send HE-SIG-B");
1393 "Incorrect RU_ALLOCATION");
1396 const auto& numUsersPerCc =
1398 txVector.GetRuAllocation(0));
1402 "Incorrect number of users in HE-SIG-B content channel 1");
1405 "Incorrect number of users in HE-SIG-B content channel 2");
1408 "Incorrect number of users in HE-SIG-B content channel 1");
1411 "Incorrect number of users in HE-SIG-B content channel 2");
1416 "Incorrect duration for HE-SIG-B");
1430 void DoRun()
override;
1445 :
TestCase(
"PHY header sections consistency")
1458 "The expected map size (" << expected.size() <<
") was not obtained ("
1459 << obtained.size() <<
")");
1461 auto itObtained = obtained.begin();
1462 auto itExpected = expected.begin();
1463 for (; itObtained != obtained.end() || itExpected != expected.end();)
1466 auto window = itObtained->second.first;
1467 auto mode = itObtained->second.second;
1470 auto windowRef = itExpected->second.first;
1471 auto modeRef = itExpected->second.second;
1475 "The expected PPDU field (" << fieldRef <<
") was not obtained ("
1479 "The expected start time (" << windowRef.first
1480 <<
") was not obtained (" << window.first
1484 "The expected stop time (" << windowRef.second
1485 <<
") was not obtained (" << window.second
1489 "The expected mode (" << modeRef <<
") was not obtained (" << mode
1507 phyEntity = Create<DsssPhy>();
1541 std::map<OfdmPhyVariant, std::size_t> variants{
1547 for (
auto variant : variants)
1549 phyEntity = Create<OfdmPhy>(variant.first);
1550 std::size_t ratio = variant.second;
1551 uint16_t bw = 20 / ratio;
1557 {{ppduStart, ppduStart +
MicroSeconds(16 * ratio)}, nonHtMode}},
1567 phyEntity = Create<ErpOfdmPhy>();
1580 phyEntity = Create<HtPhy>(4);
1615 phyEntity = Create<VhtPhy>();
1658 phyEntity = Create<HePhy>();
1663 std::map<uint16_t, HeMuUserInfo> userInfoMap = {{1, {{
HeRu::RU_106_TONE, 1,
true}, 4, 2}},
1665 sigAMode = HePhy::GetVhtMcs0();
1666 sigBMode = HePhy::GetVhtMcs4();
1730 phyEntity = Create<EhtPhy>();
1737 WifiMode uSigMode = EhtPhy::GetVhtMcs0();
1738 WifiMode ehtSigMode = EhtPhy::GetVhtMcs4();
1785 :
TestSuite(
"wifi-devices-tx-duration", UNIT)
1793 {{{
HeRu::RU_106_TONE, 1,
true}, 11, 1}, {{
HeRu::RU_106_TONE, 2,
true}, 10, 4}},
1797 std::make_pair(2, 0),
1812 std::make_pair(2, 4),
1829 std::make_pair(2, 5),
1848 std::make_pair(3, 6),
1867 {96, 15, 192, 192, 208, 208, 208, 208},
1868 std::make_pair(4, 7),
1886 std::make_pair(9, 0),
1900 std::make_pair(4, 4),
1915 std::make_pair(4, 4),
std::list< HeMuUserInfo > m_userInfos
HE MU specific per-user information.
HeSigBDurationTest(const std::list< HeMuUserInfo > &userInfos, const WifiMode &sigBMode, uint16_t channelWidth, 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)
Get the number of RUs 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.
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.
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