23 #include "ns3/simulator.h" 25 #include "ns3/yans-wifi-phy.h" 26 #include "ns3/he-ru.h" 27 #include "ns3/wifi-psdu.h" 28 #include "ns3/packet.h" 46 virtual void DoRun (
void);
63 bool CheckPayloadDuration (uint32_t size,
WifiMode payloadMode, uint16_t channelWidth, uint16_t guardInterval,
WifiPreamble preamble,
Time knownDuration);
78 bool CheckTxDuration (uint32_t size,
WifiMode payloadMode, uint16_t channelWidth, uint16_t guardInterval,
WifiPreamble preamble,
Time knownDuration);
92 static bool CheckHeMuTxDuration (std::list<uint32_t> sizes, std::list<HeMuUserInfo> userInfos,
93 uint16_t channelWidth, uint16_t guardInterval,
110 static Time CalculateTxDurationUsingList (std::list<uint32_t> sizes, std::list<uint16_t> staIds,
127 txVector.
SetMode (payloadMode);
143 Time calculatedDuration =
phy->GetPayloadDuration (size, txVector, band);
144 if (calculatedDuration != knownDuration)
146 std::cerr <<
"size=" << size
147 <<
" mode=" << payloadMode
148 <<
" channelWidth=" << channelWidth
149 <<
" guardInterval=" << guardInterval
150 <<
" datarate=" << payloadMode.
GetDataRate (channelWidth, guardInterval, 1)
151 <<
" known=" << knownDuration
152 <<
" calculated=" << calculatedDuration
160 calculatedDuration =
phy->GetPayloadDuration (size, txVector, band);
162 if (calculatedDuration != knownDuration)
164 std::cerr <<
"size=" << size
165 <<
" mode=" << payloadMode
166 <<
" channelWidth=" << channelWidth
167 <<
" guardInterval=" << guardInterval
168 <<
" datarate=" << payloadMode.
GetDataRate (channelWidth, guardInterval, 1)
169 <<
" known=" << knownDuration
170 <<
" calculated=" << calculatedDuration
182 txVector.
SetMode (payloadMode);
198 Time calculatedDuration =
phy->CalculateTxDuration (size, txVector, band);
201 if (calculatedDuration != knownDuration || calculatedDuration != calculatedDurationUsingList)
203 std::cerr <<
"size=" << size
204 <<
" mode=" << payloadMode
205 <<
" channelWidth=" << +channelWidth
206 <<
" guardInterval=" << guardInterval
207 <<
" datarate=" << payloadMode.
GetDataRate (channelWidth, guardInterval, 1)
208 <<
" preamble=" << preamble
209 <<
" known=" << knownDuration
210 <<
" calculated=" << calculatedDuration
211 <<
" calculatedUsingList=" << calculatedDurationUsingList
219 calculatedDuration =
phy->CalculateTxDuration (size, txVector, band);
223 if (calculatedDuration != knownDuration || calculatedDuration != calculatedDurationUsingList)
225 std::cerr <<
"size=" << size
226 <<
" mode=" << payloadMode
227 <<
" channelWidth=" << channelWidth
228 <<
" guardInterval=" << guardInterval
229 <<
" datarate=" << payloadMode.
GetDataRate (channelWidth, guardInterval, 1)
230 <<
" preamble=" << preamble
231 <<
" known=" << knownDuration
232 <<
" calculated=" << calculatedDuration
233 <<
" calculatedUsingList=" << calculatedDurationUsingList
243 uint16_t channelWidth, uint16_t guardInterval,
246 NS_ASSERT (sizes.size () == userInfos.size () && sizes.size () > 1);
247 NS_ABORT_MSG_IF (channelWidth < std::accumulate (std::begin (userInfos), std::end (userInfos), 0,
249 {
return prevBw + HeRu::GetBandwidth (info.
ru.
ruType); }),
250 "Cannot accommodate all the RUs in the provided band");
257 std::list<uint16_t> staIds;
259 for (
const auto & userInfo : userInfos)
262 staIds.push_back (staId++);
266 for (
auto & testedBand : testedBands)
273 uint32_t longuestSize = 0;
274 auto iterStaId = staIds.begin ();
275 for (
auto & size : sizes)
277 Time ppduDurationForSta =
phy->CalculateTxDuration (size, txVector, testedBand, *iterStaId);
278 if (ppduDurationForSta > calculatedDuration)
280 calculatedDuration = ppduDurationForSta;
287 if (calculatedDuration != knownDuration || calculatedDuration != calculatedDurationUsingList)
289 std::cerr <<
"size=" << longuestSize
290 <<
" band=" << testedBand
291 <<
" staId=" << staId
292 <<
" nss=" << +txVector.
GetNss (staId)
293 <<
" mode=" << txVector.
GetMode (staId)
294 <<
" channelWidth=" << channelWidth
295 <<
" guardInterval=" << guardInterval
297 <<
" known=" << knownDuration
298 <<
" calculated=" << calculatedDuration
299 <<
" calculatedUsingList=" << calculatedDurationUsingList
311 NS_ASSERT (sizes.size () == staIds.size ());
313 auto itStaId = staIds.begin ();
316 for (
auto & size : sizes)
319 psduMap[*itStaId++] = Create<WifiPsdu> (Create<Packet> (size - hdr.
GetSerializedSize () - 4), hdr);
321 return WifiPhy::CalculateTxDuration (psduMap, txVector, band);
555 std::list<HeMuUserInfo> { {{
true, HeRu::RU_242_TONE, 1}, WifiPhy::GetHeMcs0 (), 1},
556 {{
true, HeRu::RU_242_TONE, 2}, WifiPhy::GetHeMcs0 (), 1} },
560 std::list<HeMuUserInfo> { {{
true, HeRu::RU_242_TONE, 1}, WifiPhy::GetHeMcs1 (), 1},
561 {{
true, HeRu::RU_242_TONE, 2}, WifiPhy::GetHeMcs0 (), 1} },
565 std::list<HeMuUserInfo> { {{
true, HeRu::RU_242_TONE, 1}, WifiPhy::GetHeMcs0 (), 1},
566 {{
true, HeRu::RU_242_TONE, 2}, WifiPhy::GetHeMcs0 (), 1} },
571 Simulator::Destroy ();
587 :
TestSuite (
"wifi-devices-tx-duration", UNIT)
Simulation virtual time values and global simulation resolution.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void SetChannelWidth(uint16_t channelWidth)
Sets the selected channelWidth (in MHz)
static TxDurationTestSuite g_txDurationTestSuite
the test suite
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
void SetStbc(bool stbc)
Sets if STBC is being used.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
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.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
virtual void DoRun(void)
Implementation to actually run this TestCase.
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.
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...
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
virtual ~TxDurationTest()
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 of the p...
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
void SetGuardInterval(uint16_t guardInterval)
Sets the guard interval duration (in nanoseconds)
WifiModulationClass GetModulationClass() const
void SetHeMuUserInfo(uint16_t staId, HeMuUserInfo userInfo)
Set the HE MU user-specific transmission information for the given STA-ID.
void SetNss(uint8_t nss)
Sets the number of Nss.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetPreambleType(WifiPreamble preamble)
Sets the preamble type.
HeRu::RuSpec ru
RU specification.
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
WifiPhyBand
Identifies the PHY band.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
void SetNess(uint8_t ness)
Sets the Ness number.
static bool CheckHeMuTxDuration(std::list< uint32_t > sizes, std::list< HeMuUserInfo > userInfos, uint16_t channelWidth, uint16_t guardInterval, Time knownDuration)
Check if the overall Tx duration returned by WifiPhy for a HE MU PPDU corresponds to a known value...
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
HE MU specific user transmission parameters.
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
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 of the p...