20 #include "ns3/header-serialization-test.h"
22 #include "ns3/wifi-information-element.h"
55 uint16_t GetInformationFieldSize()
const override;
65 m_content.resize(count);
66 std::iota(m_content.begin(), m_content.end(),
start);
78 return m_content.size();
85 for (
const auto&
byte : m_content)
96 for (uint16_t i = 0; i < length; i++)
98 m_content.push_back(
start.ReadU8());
129 uint16_t GetInformationFieldSize()
const override;
160 m_content.push_back(std::move(subelement));
169 size += subelement.GetSerializedSize();
192 while (count < length)
196 m_content.push_back(std::move(subelement));
221 void Print(std::ostream& os)
const override;
241 .SetGroupName(
"Wifi")
263 size += elem.GetSerializedSize();
287 std::optional<TestWifiInformationElement> elem;
288 i = WifiInformationElement::DeserializeIfPresent(elem, i,
true);
289 if (!elem.has_value())
292 i = WifiInformationElement::DeserializeIfPresent(elem, i,
false);
294 if (elem.has_value())
343 void DoRun()
override;
368 uint8_t
byte = it.
ReadU8();
384 uint16_t sub01Size = 50;
385 uint16_t sub02Size = limit - sub01Size;
392 testIe.AddSubelement(std::move(sub01));
393 testIe.AddSubelement(std::move(sub02));
413 uint32_t expectedHdrSize = 2 + 255;
422 sub02Size = limit + 1 - sub01Size;
429 testIe.AddSubelement(std::move(sub01));
430 testIe.AddSubelement(std::move(sub02));
454 expectedHdrSize += 2 + 255
465 uint16_t sub03Size = limit + 255 - sub01Size - sub02Size;
473 testIe.AddSubelement(std::move(sub01));
474 testIe.AddSubelement(std::move(sub02));
475 testIe.AddSubelement(std::move(sub03));
497 expectedHdrSize += 2 + 255
508 sub03Size = limit + 255 + 1 - sub01Size - sub02Size;
516 testIe.AddSubelement(std::move(sub01));
517 testIe.AddSubelement(std::move(sub02));
518 testIe.AddSubelement(std::move(sub03));
538 (
m_extended ? 3 : 2) + sub01Size + 2 + sub02Size,
541 (
m_extended ? 3 : 2) + sub01Size + 2 + sub02Size + 1,
548 expectedHdrSize += 2 + 255
564 testIe.AddSubelement(std::move(sub01));
582 expectedHdrSize += 2 + 255
597 testIe.AddSubelement(std::move(sub01));
627 expectedHdrSize += 2 + 255
Subelement to test fragmentation.
WifiInformationElementId ElementId() const override
Get the wifi information element ID.
TestWifiSubElement()=default
std::list< uint8_t > m_content
content of the IE
void SerializeInformationField(Buffer::Iterator start) const override
Serialize information (i.e., the body of the IE, not including the Element ID and length octets)
uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) override
Deserialize information (i.e., the body of the IE, not including the Element ID and length octets)
uint16_t GetInformationFieldSize() const override
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
Test fragmentation of Information Elements.
Buffer SerializeIntoBuffer(const WifiInformationElement &element)
Serialize the given element in a buffer.
WifiIeFragmentationTest(bool extended)
Constructor.
bool m_extended
whether the IE includes an Element ID Extension field
void CheckSerializedByte(const Buffer &buffer, uint32_t position, uint8_t value)
Check that the given buffer contains the given value at the given position.
void DoRun() override
Implementation to actually run this TestCase.
~WifiIeFragmentationTest() override=default
wifi Information Element fragmentation Test Suite
WifiIeFragmentationTestSuite()
iterator in a Buffer instance
uint32_t GetDistanceFrom(const Iterator &o) const
void Next()
go forward by one byte
automatically resized byte buffer
void AddAtStart(uint32_t start)
Buffer::Iterator Begin() const
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
static WifiIeFragmentationTestSuite g_wifiIeFragmentationTestSuite
the test suite