A Discrete-Event Network Simulator
API
wifi-eht-info-elems-test.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 Universita' degli Studi di Napoli Federico II
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Stefano Avallone <stavallo@unina.it>
18 */
19
20#include "ns3/header-serialization-test.h"
21#include "ns3/log.h"
22#include "ns3/mgt-headers.h"
23#include "ns3/multi-link-element.h"
24#include "ns3/reduced-neighbor-report.h"
25#include "ns3/wifi-phy-operating-channel.h"
26
27#include <sstream>
28#include <vector>
29
30using namespace ns3;
31
32NS_LOG_COMPONENT_DEFINE("WifiEhtInfoElemsTest");
33
41{
42 public:
48
58 const CommonInfoBasicMle& commonInfo,
59 std::vector<MultiLinkElement::PerStaProfileSubelement> subelements);
60
61 private:
62 void DoRun() override;
63
65};
66
69 "Check serialization and deserialization of Basic variant Multi-Link elements"),
71{
72}
73
75{
76}
77
80 const CommonInfoBasicMle& commonInfo,
81 std::vector<MultiLinkElement::PerStaProfileSubelement> subelements)
82{
83 MultiLinkElement mle(MultiLinkElement::BASIC_VARIANT, m_frameType);
84 mle.SetMldMacAddress(commonInfo.m_mldMacAddress);
85 if (commonInfo.m_linkIdInfo.has_value())
86 {
87 mle.SetLinkIdInfo(*commonInfo.m_linkIdInfo);
88 }
89 if (commonInfo.m_bssParamsChangeCount.has_value())
90 {
92 }
93 if (commonInfo.m_mediumSyncDelayInfo.has_value())
94 {
96 MicroSeconds(32 * commonInfo.m_mediumSyncDelayInfo->mediumSyncDuration));
98 commonInfo.m_mediumSyncDelayInfo->mediumSyncOfdmEdThreshold - 72);
99 mle.SetMediumSyncMaxNTxops(commonInfo.m_mediumSyncDelayInfo->mediumSyncMaxNTxops + 1);
100 }
101
102 for (std::size_t i = 0; i < subelements.size(); ++i)
103 {
105 mle.GetPerStaProfile(i) = std::move(subelements[i]);
106 }
107 return mle;
108}
109
110void
112{
113 CommonInfoBasicMle commonInfo = {
114 .m_mldMacAddress = Mac48Address("01:23:45:67:89:ab"),
115 };
116
117 // Common Info with MLD MAC address
119
120 commonInfo.m_linkIdInfo = 3;
121
122 // Adding Link ID Info
124
125 commonInfo.m_bssParamsChangeCount = 1;
126
127 // Adding BSS Paraemeters Change Count
129
130 commonInfo.m_mediumSyncDelayInfo =
132 .mediumSyncOfdmEdThreshold = 4,
133 .mediumSyncMaxNTxops = 5};
134
135 // Adding Medium Sync Delay Information
137
138 SupportedRates rates;
139 rates.AddSupportedRate(6);
140 rates.AddSupportedRate(12);
141 rates.AddSupportedRate(24);
142
143 CapabilityInformation capabilities;
144 capabilities.SetShortPreamble(true);
145 capabilities.SetShortSlotTime(true);
146 capabilities.SetEss();
147
149 assoc.SetSsid(Ssid("MySsid"));
150 assoc.SetSupportedRates(rates);
151 assoc.SetCapabilities(capabilities);
152 assoc.SetListenInterval(0);
153
154 MultiLinkElement::PerStaProfileSubelement perStaProfile(MultiLinkElement::BASIC_VARIANT,
156 perStaProfile.SetLinkId(5);
157 perStaProfile.SetCompleteProfile();
158 perStaProfile.SetStaMacAddress(Mac48Address("ba:98:76:54:32:10"));
159 perStaProfile.SetAssocRequest(assoc);
160
161 // Adding Per-STA Profile Subelement
162 TestHeaderSerialization(GetMultiLinkElement(commonInfo, {perStaProfile}), m_frameType);
163
164 // Adding two Per-STA Profile Subelements
165 TestHeaderSerialization(GetMultiLinkElement(commonInfo, {perStaProfile, perStaProfile}),
167}
168
176{
177 public:
183
186
196 PhyOpChannelIt channel5It,
197 PhyOpChannelIt channel6It);
198
199 private:
200 void DoRun() override;
201};
202
205 "Check serialization and deserialization of Reduced Neighbor Report elements")
206{
207}
208
210{
211}
212
215 PhyOpChannelIt channel5It,
216 PhyOpChannelIt channel6It)
217{
219
220 std::stringstream info;
221
222 if (channel2_4It != WifiPhyOperatingChannel::m_frequencyChannels.cend())
223 {
224 WifiPhyOperatingChannel channel(channel2_4It);
225
226 info << "{Ch=" << +channel.GetNumber() << ", Bw=" << channel.GetWidth() << ", 2.4 GHz} ";
227 rnr.AddNbrApInfoField();
228 std::size_t nbrId = rnr.GetNNbrApInfoFields() - 1;
229 rnr.SetOperatingChannel(nbrId, channel);
230 // Add a TBTT Information Field
231 rnr.AddTbttInformationField(nbrId);
232 rnr.SetBssid(nbrId, 0, Mac48Address("00:00:00:00:00:24"));
233 rnr.SetShortSsid(nbrId, 0, 0);
234 rnr.SetBssParameters(nbrId, 0, 10);
235 rnr.SetPsd20MHz(nbrId, 0, 50);
236 rnr.SetMldParameters(nbrId, 0, 0, 2, 3);
237 }
238
239 if (channel5It != WifiPhyOperatingChannel::m_frequencyChannels.cend())
240 {
242
243 info << "{Ch=" << +channel.GetNumber() << ", Bw=" << channel.GetWidth() << ", 5 GHz} ";
244 rnr.AddNbrApInfoField();
245 std::size_t nbrId = rnr.GetNNbrApInfoFields() - 1;
246 rnr.SetOperatingChannel(nbrId, channel);
247 // Add a TBTT Information Field
248 rnr.AddTbttInformationField(nbrId);
249 rnr.SetBssid(nbrId, 0, Mac48Address("00:00:00:00:00:05"));
250 rnr.SetShortSsid(nbrId, 0, 0);
251 rnr.SetBssParameters(nbrId, 0, 20);
252 rnr.SetPsd20MHz(nbrId, 0, 60);
253 rnr.SetMldParameters(nbrId, 0, 0, 3, 4);
254 // Add another TBTT Information Field
255 rnr.AddTbttInformationField(nbrId);
256 rnr.SetBssid(nbrId, 1, Mac48Address("00:00:00:00:01:05"));
257 rnr.SetShortSsid(nbrId, 1, 0);
258 rnr.SetBssParameters(nbrId, 1, 30);
259 rnr.SetPsd20MHz(nbrId, 1, 70);
260 rnr.SetMldParameters(nbrId, 1, 0, 4, 5);
261 }
262
263 if (channel6It != WifiPhyOperatingChannel::m_frequencyChannels.cend())
264 {
266
267 info << "{Ch=" << +channel.GetNumber() << ", Bw=" << channel.GetWidth() << ", 6 GHz} ";
268 rnr.AddNbrApInfoField();
269 std::size_t nbrId = rnr.GetNNbrApInfoFields() - 1;
270 rnr.SetOperatingChannel(nbrId, channel);
271 // Add a TBTT Information Field
272 rnr.AddTbttInformationField(nbrId);
273 rnr.SetBssid(nbrId, 0, Mac48Address("00:00:00:00:00:06"));
274 rnr.SetShortSsid(nbrId, 0, 0);
275 rnr.SetBssParameters(nbrId, 0, 40);
276 rnr.SetPsd20MHz(nbrId, 0, 80);
277 rnr.SetMldParameters(nbrId, 0, 0, 5, 6);
278 }
279
280 NS_LOG_DEBUG(info.str());
281 return rnr;
282}
283
284void
286{
287 PhyOpChannelIt channel2_4It;
288 PhyOpChannelIt channel5It;
289 PhyOpChannelIt channel6It;
290 channel2_4It = channel5It = channel6It = WifiPhyOperatingChannel::m_frequencyChannels.cbegin();
291
292 // Test all available frequency channels
293 while (channel2_4It != WifiPhyOperatingChannel::m_frequencyChannels.cend() ||
294 channel5It != WifiPhyOperatingChannel::m_frequencyChannels.cend() ||
295 channel6It != WifiPhyOperatingChannel::m_frequencyChannels.cend())
296 {
297 if (channel2_4It != WifiPhyOperatingChannel::m_frequencyChannels.cend())
298 {
299 channel2_4It = WifiPhyOperatingChannel::FindFirst(0,
300 0,
301 0,
304 channel2_4It);
305 }
306 if (channel5It != WifiPhyOperatingChannel::m_frequencyChannels.cend())
307 {
308 channel5It = WifiPhyOperatingChannel::FindFirst(0,
309 0,
310 0,
313 channel5It);
314 }
315 if (channel6It != WifiPhyOperatingChannel::m_frequencyChannels.cend())
316 {
317 channel6It = WifiPhyOperatingChannel::FindFirst(0,
318 0,
319 0,
322 channel6It);
323 }
324
325 TestHeaderSerialization(GetReducedNeighborReport(channel2_4It, channel5It, channel6It));
326
327 // advance all channel iterators
328 if (channel2_4It != WifiPhyOperatingChannel::m_frequencyChannels.cend())
329 {
330 channel2_4It++;
331 }
332 if (channel5It != WifiPhyOperatingChannel::m_frequencyChannels.cend())
333 {
334 channel5It++;
335 }
336 if (channel6It != WifiPhyOperatingChannel::m_frequencyChannels.cend())
337 {
338 channel6It++;
339 }
340 }
341}
342
350{
351 public:
353};
354
356 : TestSuite("wifi-eht-info-elems", UNIT)
357{
358 AddTestCase(new BasicMultiLinkElementTest(), TestCase::QUICK);
359 AddTestCase(new ReducedNeighborReportTest(), TestCase::QUICK);
360}
361
Test Reduced Neighbor Report serialization and deserialization.
ReducedNeighborReport GetReducedNeighborReport(PhyOpChannelIt channel2_4It, PhyOpChannelIt channel5It, PhyOpChannelIt channel6It)
Get a Reduced Neighbor Report element including the given operating channels.
void DoRun() override
Implementation to actually run this TestCase.
WifiPhyOperatingChannel::ConstIterator PhyOpChannelIt
typedef for const iterator on the set of available channels
wifi EHT Information Elements Test Suite
void SetEss()
Set the Extended Service Set (ESS) bit in the capability information field.
void SetShortSlotTime(bool shortSlotTime)
Set the short slot time bit in the capability information field.
void SetShortPreamble(bool shortPreamble)
Set the short preamble bit in the capability information field.
Subclass of TestCase class adding the ability to test the serialization and deserialization of a Head...
void TestHeaderSerialization(const T &hdr, Args &&... args)
Serialize the given header in a buffer, then create a new header by deserializing from the buffer and...
an EUI-48 address
Definition: mac48-address.h:46
Implement the header for management frames of type association request.
Definition: mgt-headers.h:54
void SetSupportedRates(const SupportedRates &rates)
Set the supported rates.
Definition: mgt-headers.cc:904
void SetListenInterval(uint16_t interval)
Set the listen interval.
Definition: mgt-headers.cc:916
void SetCapabilities(const CapabilityInformation &capabilities)
Set the Capability information.
Definition: mgt-headers.cc:922
void SetSsid(const Ssid &ssid)
Set the Service Set Identifier (SSID).
Definition: mgt-headers.cc:892
The Reduced Neighbor Report element.
std::size_t GetNNbrApInfoFields() const
Get the number of Neighbor AP Information fields.
void SetMldParameters(std::size_t nbrApInfoId, std::size_t index, uint8_t mldId, uint8_t linkId, uint8_t changeSequence)
Set the MLD Parameters subfield of the i-th TBTT Information field of the given Neighbor AP Informati...
void SetShortSsid(std::size_t nbrApInfoId, std::size_t index, uint32_t shortSsid)
Set the Short SSID field of the i-th TBTT Information field of the given Neighbor AP Information fiel...
void SetBssid(std::size_t nbrApInfoId, std::size_t index, Mac48Address bssid)
Set the BSSID field of the i-th TBTT Information field of the given Neighbor AP Information field.
void SetPsd20MHz(std::size_t nbrApInfoId, std::size_t index, uint8_t psd20MHz)
Set the 20 MHz PSD field of the i-th TBTT Information field of the given Neighbor AP Information fiel...
void AddNbrApInfoField()
Add a Neighbor AP Information field.
void SetBssParameters(std::size_t nbrApInfoId, std::size_t index, uint8_t bssParameters)
Set the BSS Parameters field of the i-th TBTT Information field of the given Neighbor AP Information ...
void AddTbttInformationField(std::size_t nbrApInfoId)
Add a TBTT Information fields to the TBTT Information Set field of the given Neighbor AP Information ...
void SetOperatingChannel(std::size_t nbrApInfoId, const WifiPhyOperatingChannel &channel)
Set the Operating Class and the Channel Number fields of the given Neighbor AP Information field base...
The IEEE 802.11 SSID Information Element.
Definition: ssid.h:36
The Supported Rates Information Element.
void AddSupportedRate(uint64_t bs)
Add the given rate to the supported rates.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:305
A suite of tests to run.
Definition: test.h:1256
Class that keeps track of all information about the current PHY operating channel.
std::set< FrequencyChannelInfo >::const_iterator ConstIterator
Typedef for a const iterator pointing to a channel in the set of available channels.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1362
@ WIFI_STANDARD_80211be
@ WIFI_PHY_BAND_6GHZ
The 6 GHz band.
Definition: wifi-phy-band.h:39
@ WIFI_PHY_BAND_2_4GHZ
The 2.4 GHz band.
Definition: wifi-phy-band.h:35
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
Definition: wifi-phy-band.h:37
Every class exported by the ns3 library is enclosed in the ns3 namespace.
WifiMacType
Combination of valid MAC header type/subtype.
@ WIFI_MAC_MGT_ASSOCIATION_REQUEST
channel
Definition: third.py:81
Medium Synchronization Delay Information subfield.
uint8_t mediumSyncDuration
Medium Synchronization Duration.
Common Info field of the Basic Multi-Link element.
std::optional< MediumSyncDelayInfo > m_mediumSyncDelayInfo
Medium Synchronization Delay Information.
Mac48Address m_mldMacAddress
Subfields.
std::optional< uint8_t > m_bssParamsChangeCount
BSS Parameters Change Count.
std::optional< uint8_t > m_linkIdInfo
Link ID Info.
static WifiEhtInfoElemsTestSuite g_wifiEhtInfoElemsTestSuite
the test suite